Commit 4bb98441 authored by Pierre Paleo's avatar Pierre Paleo
Browse files

Add test_double_flatfield for cuda backend

parent 36db2fcc
Pipeline #26950 failed with stages
in 1 minute and 1 second
......@@ -7,7 +7,10 @@ from silx.io.url import DataUrl
from tomoscan.esrf.mock import MockHDF5
from nabu.io.reader import HDF5Reader
from nabu.preproc.double_flatfield import DoubleFlatField, __have_scipy__
from nabu.preproc.double_flatfield_cuda import CudaDoubleFlatField, __has_pycuda__
if __has_pycuda__:
import pycuda.gpuarray as garray
@pytest.fixture(scope="class")
def bootstrap(request):
......@@ -35,7 +38,10 @@ def bootstrap(request):
file_path=path.join(cls.dname, "dff.h5"),
data_path="/entry/double_flatfield/results/data"
)
cls.ff_cuda_dump_url = DataUrl(
file_path=path.join(cls.dname, "dff_cuda.h5"),
data_path="/entry/double_flatfield/results/data"
)
golden = 0
for i in range(10):
golden += exp(-i)
......@@ -64,3 +70,26 @@ class TestDoubleFlatField:
assert np.max(np.abs(mydf2 - mydf)) < self.tol
assert np.max(np.abs(mydf - self.golden)) < self.tol
@pytest.mark.skipif(not(__has_pycuda__), reason="Need pycuda for double flatfield with cuda backend")
def test_dff_cuda(self):
import pycuda.autoinit
dff = CudaDoubleFlatField(
self.radios.shape,
result_url=self.ff_cuda_dump_url
)
d_radios = garray.to_gpu(self.radios)
mydf = dff.get_double_flatfield(radios=d_radios).get()
assert path.isfile(dff.result_url.file_path())
dff2 = CudaDoubleFlatField(
self.radios.shape,
result_url=self.ff_cuda_dump_url
)
mydf2 = dff2.get_double_flatfield(radios=d_radios).get()
assert np.max(np.abs(mydf2 - mydf)) < self.tol
assert np.max(np.abs(mydf - self.golden)) < self.tol
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment