diff --git a/hysop/core/arrays/tests/test_array.py b/hysop/core/arrays/tests/test_array.py index cca81b5d627b97fda68c1567d0169af8cfc3b7b0..2520b3435bcd3d58773478a7b27cb79bfcc8f62b 100644 --- a/hysop/core/arrays/tests/test_array.py +++ b/hysop/core/arrays/tests/test_array.py @@ -704,8 +704,8 @@ class TestArray(object): float_types = (np.float16,np.float32,np.float64, np.longdouble) complex_types = (np.complex64, np.complex128, np.clongdouble) else: - signed_types = (np.int32,) - unsigned_types = (np.uint32,) + signed_types = () + unsigned_types = () float_types = (np.float32,) complex_types = (np.complex64,) diff --git a/hysop/fields/tests/test_cartesian.py b/hysop/fields/tests/test_cartesian.py index 5e417c4627d1ea7dd44a5018e556d825cc36dbc6..3b8a5ed96122e4ebaca67f72b2d885430b955830 100644 --- a/hysop/fields/tests/test_cartesian.py +++ b/hysop/fields/tests/test_cartesian.py @@ -498,7 +498,7 @@ def test_mpi_ghost_exchange_periodic(comm): print msg print '*'*len(msg) print 'test_mpi_ghost_exchange_periodic()'.format(size) - for dim in xrange(1,4+__ENABLE_LONG_TESTS__): + for dim in xrange(1,2+__ENABLE_LONG_TESTS__): if rank==0: print(' >DIM={}'.format(dim)) @@ -608,7 +608,7 @@ def test_mpi_ghost_exchange_runtime(comm): print '*'*len(msg) print 'test_mpi_ghost_exchange_runtime()'.format(size) - for dim in xrange(1,3+__ENABLE_LONG_TESTS__): + for dim in xrange(1,2+__ENABLE_LONG_TESTS__): if rank==0: sys.stdout.write('>DIM={}\n'.format(dim)) @@ -689,7 +689,7 @@ def test_mpi_ghost_accumulate_periodic(comm): np.int16, np.int32, np.int64, np.uint16, np.uint32, np.uint64) assert size-1 < len(dtypes) - for dim in xrange(1,4+__ENABLE_LONG_TESTS__): + for dim in xrange(1,2+__ENABLE_LONG_TESTS__): if rank==0: print(' >DIM={}'.format(dim)) @@ -834,7 +834,8 @@ if __name__ == '__main__': if (size==1): test_serial_initialization_1d() test_serial_initialization_2d() - test_serial_initialization_3d() + if __ENABLE_LONG_TESTS__: + test_serial_initialization_3d() disable_hysop_warnings() test_mpi_ghost_exchange_runtime(comm=comm) diff --git a/hysop/fields/tests/test_cartesian.sh b/hysop/fields/tests/test_cartesian.sh index 9868dd035c9eb0ddd2e2163997c271c448d7a5a9..a2d07fa443880376327908629c58f0caf7d94c6b 100755 --- a/hysop/fields/tests/test_cartesian.sh +++ b/hysop/fields/tests/test_cartesian.sh @@ -20,6 +20,6 @@ popd > /dev/null TEST_FILE=$SCRIPT_PATH/test_cartesian.py -for i in 1 2; do +for i in 2; do mpirun --allow-run-as-root --oversubscribe -np $i python2 $TEST_FILE done diff --git a/hysop/numerics/tests/test_fft.py b/hysop/numerics/tests/test_fft.py index 65630fd329ec11f504ddf67e147af186e7ba3fb0..4b42e4e001d74ed1e7f9c4d6631e9ea3ea768f9a 100644 --- a/hysop/numerics/tests/test_fft.py +++ b/hysop/numerics/tests/test_fft.py @@ -8,7 +8,7 @@ import numpy as np import itertools as it from hysop.deps import it, sm, random -from hysop.constants import Implementation +from hysop.constants import Implementation, HYSOP_REAL from hysop.testsenv import __ENABLE_LONG_TESTS__, __HAS_OPENCL_BACKEND__ from hysop.testsenv import opencl_failed, iter_clenv from hysop.tools.contexts import printoptions @@ -610,8 +610,8 @@ class TestFFT(object): check_distances(results) def iter_shapes(self): - minj=(2,2) - maxj=(5,5) + minj=(3,3) + maxj=(6,6) msg = ('EVEN', 'ODD') def _mk_shape(shape, ghosts): assert len(shape)==len(ghosts) @@ -688,7 +688,11 @@ class TestFFT(object): # not testing np.longdouble because only one implementation supports it # ie. we cannot compare results between different implementations failures = {} - for dtype in (np.float32, np.float64,): + if __ENABLE_LONG_TESTS__: + dtypes = (np.float32, np.float64,) + else: + dtypes = (HYSOP_REAL,) + for dtype in dtypes: self._test_forward_backward_1d(dtype=dtype) self._test_1d(dtype=dtype, failures=failures.setdefault(dtype.__name__, {})) self.report_failures(failures) diff --git a/hysop/operator/tests/test_analytic.py b/hysop/operator/tests/test_analytic.py index f5424de33fd33180463e5ebab225894b362949d1..1ecf543384e74e9df5e5dfa3fe7c95e05b97124d 100644 --- a/hysop/operator/tests/test_analytic.py +++ b/hysop/operator/tests/test_analytic.py @@ -266,13 +266,14 @@ class TestAnalyticField(object): def perform_tests(self): - self.test_1d_float32() - self.test_2d_float32() - self.test_3d_float32() - - self.test_1d_float64() - self.test_2d_float64() - self.test_3d_float64() + if (HYSOP_REAL == npw.float32) or __ENABLE_LONG_TESTS__: + self.test_1d_float32() + self.test_2d_float32() + self.test_3d_float32() + if (HYSOP_REAL == npw.float64) or __ENABLE_LONG_TESTS__: + self.test_1d_float64() + self.test_2d_float64() + self.test_3d_float64() if __name__ == '__main__': TestAnalyticField.setup_class(enable_extra_tests=False, diff --git a/hysop/operator/tests/test_custom_symbolic.py b/hysop/operator/tests/test_custom_symbolic.py index ee588b91b04e08124a015463681a7259e1d311ea..62dd3e00bc4f95851103d5d99e362545b41a3c12 100644 --- a/hysop/operator/tests/test_custom_symbolic.py +++ b/hysop/operator/tests/test_custom_symbolic.py @@ -1,7 +1,7 @@ from hysop import Field, Box from hysop.deps import np, it, sm -from hysop.constants import Implementation, ComputeGranularity, SpaceDiscretization +from hysop.constants import Implementation, ComputeGranularity, SpaceDiscretization, HYSOP_REAL from hysop.testsenv import __ENABLE_LONG_TESTS__, __HAS_OPENCL_BACKEND__ from hysop.testsenv import opencl_failed, iter_clenv from hysop.tools.contexts import printoptions @@ -180,10 +180,13 @@ class TestCustomSymbolic(object): discretization = discretization + discretization0 print ' DISCRETIZATION {}'.format(discretization) - - dtypes = [ (np.float32,), (np.int64,), (np.float64,) ] + + if __ENABLE_LONG_TESTS__: + dtypes = (np.float32, np.float64) + else: + dtypes = (HYSOP_REAL,) - for dtype in dtypes[dim-1]: + for dtype in dtypes: print ' DTYPE {}'.format(dtype.__name__) A = Field(domain=domain, name='A', dtype=dtype, nb_components=1, register_object=False) @@ -210,24 +213,25 @@ class TestCustomSymbolic(object): self._test_affect((A,), (42,), discretization, granularity) self._test_affect((A,B,C), (1,2,3), discretization, granularity) - expr = Assignment(As, 1+P0s) - compute_outputs = lambda ifields, iparams, dfields, ovar, i: \ - np.full(fill_value=1+iparams['P0'], shape=ovar.resolution, dtype=ovar.dtype) - self._test_expr(expr, compute_outputs, - variables={A:discretization}, method={ComputeGranularity:granularity}) - P0.value = 4.0 - compute_outputs = lambda ifields, iparams, dfields, ovar, i: np.full(fill_value=5, shape=ovar.resolution, dtype=ovar.dtype) - self._test_expr(expr, compute_outputs, - variables={A:discretization}, method={ComputeGranularity:granularity}) - - expr = Assignment(Bs, np.sum(T0s[1::2])) - compute_outputs = lambda ifields, iparams, dfields, ovar, i: np.full(fill_value=1+3+5+7+9+11, shape=ovar.resolution, dtype=ovar.dtype) - self._test_expr(expr, compute_outputs, - variables={B:discretization}, method={ComputeGranularity:granularity}) - - compute_outputs = lambda ifields, iparams, dfields, ovar, i: ifields[C[0]] - self._test_expr(Assignment(As, C.s[0]()), compute_outputs, - variables={A:discretization, C:discretization}, method={ComputeGranularity:granularity}) + if __ENABLE_LONG_TESTS__: + expr = Assignment(As, 1+P0s) + compute_outputs = lambda ifields, iparams, dfields, ovar, i: \ + np.full(fill_value=1+iparams['P0'], shape=ovar.resolution, dtype=ovar.dtype) + self._test_expr(expr, compute_outputs, + variables={A:discretization}, method={ComputeGranularity:granularity}) + P0.value = 4.0 + compute_outputs = lambda ifields, iparams, dfields, ovar, i: np.full(fill_value=5, shape=ovar.resolution, dtype=ovar.dtype) + self._test_expr(expr, compute_outputs, + variables={A:discretization}, method={ComputeGranularity:granularity}) + + expr = Assignment(Bs, np.sum(T0s[1::2])) + compute_outputs = lambda ifields, iparams, dfields, ovar, i: np.full(fill_value=1+3+5+7+9+11, shape=ovar.resolution, dtype=ovar.dtype) + self._test_expr(expr, compute_outputs, + variables={B:discretization}, method={ComputeGranularity:granularity}) + + compute_outputs = lambda ifields, iparams, dfields, ovar, i: ifields[C[0]] + self._test_expr(Assignment(As, C.s[0]()), compute_outputs, + variables={A:discretization, C:discretization}, method={ComputeGranularity:granularity}) compute_outputs = lambda ifields, iparams, dfields, ovar, i: 2*ifields[C[0]] + 8 self._test_expr(Assignment(As, 2*C.s[0]()+8), compute_outputs, @@ -308,9 +312,17 @@ class TestCustomSymbolic(object): refin['f'][field] = refin['f'][field][view] view = dfield.compute_slices - flatten = lambda x: tuple(__ for _ in x['f'].values() for __ in _) + \ - tuple(np.asarray(_) for _ in x['p'].values()) - + def flatten(x): + out = () + for _ in x['f'].values(): + if not isinstance(_, tuple): + _ = (_,) + for __ in _: + out += (__,) + for _ in x['p'].values(): + out += (np.asarray(_),) + return out + self._check_output(impl, op, in_names, flatten(refin), out_names, flatten(refout), flatten(out)) def _test_affect(self, fields, rhs, discretization, granularity): @@ -400,45 +412,51 @@ class TestCustomSymbolic(object): csg = CenteredStencilGenerator() csg.configure(dtype=MPQ, dim=1) + + if __ENABLE_LONG_TESTS__: + orders = (2,4) + else: + orders = (4,) - for order in [2, 4]: + for order in orders: print ' ORDER {}'.format(order) for granularity in xrange(dim): print ' GRANULARITY {}'.format(granularity) - expr = Assignment(As, B.s[0]().diff(x0,x0)) - stencil = csg.generate_exact_stencil(derivative=2, order=order) - def compute_outputs(fields, iparams, ifields, ovar, i): - return stencil.apply(fields[B[0]], symbols={stencil.dx:ovar.space_step[-1]}, axis=-1)[ifields[B[0]].compute_slices] - self._test_expr(expr, compute_outputs, - variables={A:discretization, B:discretization}, - method={ComputeGranularity:granularity, SpaceDiscretization:order}) - - - expr = Assignment(As, 1+2*B.s[0]().diff(x0)) - stencil = csg.generate_exact_stencil(derivative=1, order=order) - def compute_outputs(fields, iparams, ifields, ovar, i): - res = stencil.apply(fields[B[0]], symbols={stencil.dx:ovar.space_step[-1]}, axis=-1)[ifields[B[0]].compute_slices] - return 1+2*res - self._test_expr(expr, compute_outputs, - variables={A:discretization, B:discretization}, - method={ComputeGranularity:granularity, SpaceDiscretization:order}) - - expr = Assignment(Bs[0](), (1+np.dot([3,-2], Bs.diff(x0)))*As.diff(x0)) - - stencil = csg.generate_exact_stencil(derivative=1, order=order) - def compute_outputs(fields, iparams, ifields, ovar, i): - if (i==0): - res0 = stencil.apply(fields[B[0]], symbols={stencil.dx:ovar.space_step[-1]}, axis=-1) - res1 = stencil.apply(fields[B[1]], symbols={stencil.dx:ovar.space_step[-1]}, axis=-1) - res2 = stencil.apply(fields[A], symbols={stencil.dx:ovar.space_step[-1]}, axis=-1) - return (1+(3*res0)-(2*res1))*res2 - else: - return ovar.data[i].get().handle + if __ENABLE_LONG_TESTS__: + expr = Assignment(As, B.s[0]().diff(x0,x0)) + stencil = csg.generate_exact_stencil(derivative=2, order=order) + def compute_outputs(fields, iparams, ifields, ovar, i): + return stencil.apply(fields[B[0]], symbols={stencil.dx:ovar.space_step[-1]}, axis=-1)[ifields[B[0]].compute_slices] + self._test_expr(expr, compute_outputs, + variables={A:discretization, B:discretization}, + method={ComputeGranularity:granularity, SpaceDiscretization:order}) + + + expr = Assignment(As, 1+2*B.s[0]().diff(x0)) + stencil = csg.generate_exact_stencil(derivative=1, order=order) + def compute_outputs(fields, iparams, ifields, ovar, i): + res = stencil.apply(fields[B[0]], symbols={stencil.dx:ovar.space_step[-1]}, axis=-1)[ifields[B[0]].compute_slices] + return 1+2*res + self._test_expr(expr, compute_outputs, + variables={A:discretization, B:discretization}, + method={ComputeGranularity:granularity, SpaceDiscretization:order}) + + expr = Assignment(Bs[0](), (1+np.dot([3,-2], Bs.diff(x0)))*As.diff(x0)) + + stencil = csg.generate_exact_stencil(derivative=1, order=order) + def compute_outputs(fields, iparams, ifields, ovar, i): + if (i==0): + res0 = stencil.apply(fields[B[0]], symbols={stencil.dx:ovar.space_step[-1]}, axis=-1) + res1 = stencil.apply(fields[B[1]], symbols={stencil.dx:ovar.space_step[-1]}, axis=-1) + res2 = stencil.apply(fields[A], symbols={stencil.dx:ovar.space_step[-1]}, axis=-1) + return (1+(3*res0)-(2*res1))*res2 + else: + return ovar.data[i].get().handle - self._test_expr(expr, compute_outputs, - variables={A:discretization, B:discretization}, - method={ComputeGranularity:granularity, SpaceDiscretization:order}) + self._test_expr(expr, compute_outputs, + variables={A:discretization, B:discretization}, + method={ComputeGranularity:granularity, SpaceDiscretization:order}) expr0 = Assignment(B.s[0](), (1+np.dot([3,-2], Bs.diff(x0)))*As.diff(x0)) expr1 = Assignment(B.s[1](), (1-np.dot([3,-2], Bs.diff(x0)))*As.diff(x0)) @@ -535,166 +553,172 @@ class TestCustomSymbolic(object): D1 = csg.generate_exact_stencil(derivative=1, order=order) D2 = csg.generate_exact_stencil(derivative=2, order=order) D3 = csg.generate_exact_stencil(derivative=3, order=order) + + if __ENABLE_LONG_TESTS__: + integrators = [Euler, RK2, RK4, RK4_38] + else: + integrators = (RK2,) - for integrator in [Euler, RK2, RK4, RK4_38]: + for integrator in integrators: print ' INTEGRATOR {}'.format(integrator) - - expr = Assignment(As.diff(t), 0) - def compute_outputs(fields, iparams, ifields, ovar, i): - A0 = fields[A] - if (ovar.dfield._field is A) and (i==0): - return fields[A].copy() - else: - return ovar.dfield.data[i].get().handle - self._test_expr(expr, compute_outputs, - variables={A:discretization, B:discretization, C:discretization}, - method={ComputeGranularity:granularity, SpaceDiscretization:order, - TimeIntegrator:integrator}, dt=DT) - - expr = Assignment(As.diff(t), 1) - def compute_outputs(fields, iparams, ifields, ovar, i): - A0 = fields[A] - if (ovar.dfield._field is A) and (i==0): - Xin = { 'a': fields[A] } - Xout = { 'a': np.empty_like(Xin['a'][ifields[A].compute_slices]) } - def rhs(out, X, t, **kwds): - out['a'][...] = 1 - integrator(Xin=Xin, Xout=Xout, RHS=rhs, t=0.0, dt=DT()) - return Xout['a'] - else: - return ovar.dfield.data[i].get().handle - self._test_expr(expr, compute_outputs, - variables={A:discretization, B:discretization, C:discretization}, - method={ComputeGranularity:granularity, SpaceDiscretization:order, - TimeIntegrator:integrator}, dt=DT) - - - expr = Assignment(As.diff(t), np.dot([2,-3], Bs)) - def compute_outputs(fields, iparams, ifields, ovar, i): - A0 = fields[A] - B0 = fields[B[0]] - B1 = fields[B[1]] - if (ovar.dfield._field is A) and (i==0): - Xin = { 'a': A0 } - Xout = { 'a': np.empty_like(Xin['a'][ifields[A].compute_slices]) } - def rhs(out, X, t, **kwds): - out['a'][...] = 2*B0 -3*B1 - integrator(Xin=Xin, Xout=Xout, RHS=rhs, t=0.0, dt=DT()) - return Xout['a'] - else: - return ovar.dfield.data[i].get().handle - self._test_expr(expr, compute_outputs, - variables={A:discretization, B:discretization, C:discretization}, - method={ComputeGranularity:granularity, SpaceDiscretization:order, - TimeIntegrator:integrator}, dt=DT) - - expr = Assignment(As.diff(t), As*Bs[0] + Bs[1]) - def compute_outputs(fields, iparams, ifields, ovar, i): - A0 = fields[A] - B0 = fields[B[0]] - B1 = fields[B[1]] - if (ovar.dfield._field is A) and (i==0): - Xin = { 'a': A0 } - Xout = { 'a': np.empty_like(Xin['a'][ifields[A].compute_slices]) } - def rhs(out, X, t, **kwds): - out['a'][...] = X['a']*B0 + B1 - integrator(Xin=Xin, Xout=Xout, RHS=rhs, t=0.0, dt=DT()) - return Xout['a'] - else: - return ovar.dfield.data[i].get().handle - self._test_expr(expr, compute_outputs, - variables={A:discretization, B:discretization, C:discretization}, - method={ComputeGranularity:granularity, SpaceDiscretization:order, - TimeIntegrator:integrator}, dt=DT) - - expr0 = Assignment(Bs[0].diff(t), 1+Bs[1]) - expr1 = Assignment(Bs[1].diff(t), 1-Bs[0]) - expr = (expr0, expr1) - def compute_outputs(fields, iparams, ifields, ovar, i): - B0 = fields[B[0]] - B1 = fields[B[1]] - if (ovar.dfield._field in B.fields): - Xin = { 'b0': B0, 'b1': B1 } - Xout = { 'b0': np.empty_like(B0[ifields[B[0]].compute_slices]), - 'b1': np.empty_like(B1[ifields[B[1]].compute_slices]) } - def rhs(out, X, t, **kwds): - out['b0'][...] = 1+X['b1'] - out['b1'][...] = 1-X['b0'] - integrator(Xin=Xin, Xout=Xout, RHS=rhs, t=0.0, dt=DT()) - varname = 'b0' if (ovar.dfield._field is B[0]) else 'b1' - return Xout[varname] - else: - return ovar.dfield.data[i].get().handle - self._test_expr(expr, compute_outputs, - variables={A:discretization, B:discretization, C:discretization}, - method={ComputeGranularity:granularity, SpaceDiscretization:order, - TimeIntegrator:integrator}, dt=DT) - - expr = Assignment(As.diff(t), Bs[0].diff(x0)) - def compute_outputs(fields, iparams, ifields, ovar, i): - A0 = fields[A] - B0 = fields[B[0]] - dB0 = D1.apply(B0, symbols={D1.dx:ovar.space_step[-1]}, axis=-1) - if (ovar.dfield._field is A): - Xin = { 'a': A0 } - Xout = { 'a': np.empty_like(Xin['a'][ifields[A].compute_slices]) } - def rhs(out, X, t, **kwds): - out['a'][...] = dB0[ifields[B[0]].compute_slices] - integrator(Xin=Xin, Xout=Xout, RHS=rhs, t=0.0, dt=DT()) - return Xout['a'] - else: - return ovar.dfield.data[i].get().handle - self._test_expr(expr, compute_outputs, - variables={A:discretization, B:discretization}, - method={ComputeGranularity:granularity, SpaceDiscretization:order, - TimeIntegrator:integrator}, dt=DT) - - - expr = Assignment(As.diff(t), As.diff(x0)) - def compute_outputs(fields, iparams, ifields, ovar, i): - A0 = fields[A] - if (ovar.dfield._field is A): - Xin = { 'a': A0 } - Xout = { 'a': np.empty_like(Xin['a'][ifields[A].compute_slices]) } - views = { 'a': ifields[A].compute_slices } - def rhs(out, X, t, **kwds): - dA0 = D1.apply(X['a'], symbols={D1.dx:ovar.space_step[-1]}, axis=-1) - out['a'][...] = dA0 - integrator(Xin=Xin, Xout=Xout, views=views, RHS=rhs, t=0.0, dt=DT()) - return Xout['a'] - else: - return ovar.dfield.data[i].get().handle - self._test_expr(expr, compute_outputs, - variables={A:discretization}, - method={ComputeGranularity:granularity, SpaceDiscretization:order, - TimeIntegrator:integrator}, dt=DT, no_ref_view=True) - - expr = Assignment(As.diff(t), P0s*Bs[0]*As.diff(x0) + Bs[1].diff(x0,x0)*As) - def compute_outputs(fields, iparams, ifields, ovar, i): - A0 = fields[A] - B0 = fields[B[0]] - B1 = fields[B[1]] - d2B1 = D2.apply(B1, symbols={D2.dx:ovar.space_step[-1]}, axis=-1) - assert order%2==0 - bg = order//2 - v = (Ellipsis, slice(bg, -bg)) - if (ovar.dfield._field is A): - Xin = { 'a': A0 } - Xout = { 'a': np.empty_like(Xin['a'][ifields[A].compute_slices]) } - views = { 'a': ifields[A].compute_slices } - def rhs(out, X, t, **kwds): - A0 = X['a'] - dA0 = D1.apply(A0, symbols={D1.dx:ovar.space_step[-1]}, axis=-1) - out['a'][v] = P0()*B0*dA0[v] + d2B1[v]*A0[v] - integrator(Xin=Xin, Xout=Xout, views=views, RHS=rhs, t=0.0, dt=DT()) - return Xout['a'] - else: - return ovar.dfield.data[i].get().handle - self._test_expr(expr, compute_outputs, - variables={A:discretization, B:discretization}, - method={ComputeGranularity:granularity, SpaceDiscretization:order, - TimeIntegrator:integrator}, dt=DT, no_ref_view=True) + if __ENABLE_LONG_TESTS__: + expr = Assignment(As.diff(t), 0) + def compute_outputs(fields, iparams, ifields, ovar, i): + A0 = fields[A] + if (ovar.dfield._field is A) and (i==0): + return fields[A].copy() + else: + return ovar.dfield.data[i].get().handle + self._test_expr(expr, compute_outputs, + variables={A:discretization, B:discretization, C:discretization}, + method={ComputeGranularity:granularity, SpaceDiscretization:order, + TimeIntegrator:integrator}, dt=DT) + + expr = Assignment(As.diff(t), 1) + def compute_outputs(fields, iparams, ifields, ovar, i): + A0 = fields[A] + if (ovar.dfield._field is A) and (i==0): + Xin = { 'a': fields[A] } + Xout = { 'a': np.empty_like(Xin['a'][ifields[A].compute_slices]) } + def rhs(out, X, t, **kwds): + out['a'][...] = 1 + integrator(Xin=Xin, Xout=Xout, RHS=rhs, t=0.0, dt=DT()) + return Xout['a'] + else: + return ovar.dfield.data[i].get().handle + self._test_expr(expr, compute_outputs, + variables={A:discretization, B:discretization, C:discretization}, + method={ComputeGranularity:granularity, SpaceDiscretization:order, + TimeIntegrator:integrator}, dt=DT) + + + expr = Assignment(As.diff(t), np.dot([2,-3], Bs)) + def compute_outputs(fields, iparams, ifields, ovar, i): + A0 = fields[A] + B0 = fields[B[0]] + B1 = fields[B[1]] + if (ovar.dfield._field is A) and (i==0): + Xin = { 'a': A0 } + Xout = { 'a': np.empty_like(Xin['a'][ifields[A].compute_slices]) } + def rhs(out, X, t, **kwds): + out['a'][...] = 2*B0 -3*B1 + integrator(Xin=Xin, Xout=Xout, RHS=rhs, t=0.0, dt=DT()) + return Xout['a'] + else: + return ovar.dfield.data[i].get().handle + self._test_expr(expr, compute_outputs, + variables={A:discretization, B:discretization, C:discretization}, + method={ComputeGranularity:granularity, SpaceDiscretization:order, + TimeIntegrator:integrator}, dt=DT) + + expr = Assignment(As.diff(t), As*Bs[0] + Bs[1]) + def compute_outputs(fields, iparams, ifields, ovar, i): + A0 = fields[A] + B0 = fields[B[0]] + B1 = fields[B[1]] + if (ovar.dfield._field is A) and (i==0): + Xin = { 'a': A0 } + Xout = { 'a': np.empty_like(Xin['a'][ifields[A].compute_slices]) } + def rhs(out, X, t, **kwds): + out['a'][...] = X['a']*B0 + B1 + integrator(Xin=Xin, Xout=Xout, RHS=rhs, t=0.0, dt=DT()) + return Xout['a'] + else: + return ovar.dfield.data[i].get().handle + self._test_expr(expr, compute_outputs, + variables={A:discretization, B:discretization, C:discretization}, + method={ComputeGranularity:granularity, SpaceDiscretization:order, + TimeIntegrator:integrator}, dt=DT) + + expr0 = Assignment(Bs[0].diff(t), 1+Bs[1]) + expr1 = Assignment(Bs[1].diff(t), 1-Bs[0]) + expr = (expr0, expr1) + def compute_outputs(fields, iparams, ifields, ovar, i): + B0 = fields[B[0]] + B1 = fields[B[1]] + if (ovar.dfield._field in B.fields): + Xin = { 'b0': B0, 'b1': B1 } + Xout = { 'b0': np.empty_like(B0[ifields[B[0]].compute_slices]), + 'b1': np.empty_like(B1[ifields[B[1]].compute_slices]) } + def rhs(out, X, t, **kwds): + out['b0'][...] = 1+X['b1'] + out['b1'][...] = 1-X['b0'] + integrator(Xin=Xin, Xout=Xout, RHS=rhs, t=0.0, dt=DT()) + varname = 'b0' if (ovar.dfield._field is B[0]) else 'b1' + return Xout[varname] + else: + return ovar.dfield.data[i].get().handle + self._test_expr(expr, compute_outputs, + variables={A:discretization, B:discretization, C:discretization}, + method={ComputeGranularity:granularity, SpaceDiscretization:order, + TimeIntegrator:integrator}, dt=DT) + + + expr = Assignment(As.diff(t), Bs[0].diff(x0)) + def compute_outputs(fields, iparams, ifields, ovar, i): + A0 = fields[A] + B0 = fields[B[0]] + dB0 = D1.apply(B0, symbols={D1.dx:ovar.space_step[-1]}, axis=-1) + if (ovar.dfield._field is A): + Xin = { 'a': A0 } + Xout = { 'a': np.empty_like(Xin['a'][ifields[A].compute_slices]) } + def rhs(out, X, t, **kwds): + out['a'][...] = dB0[ifields[B[0]].compute_slices] + integrator(Xin=Xin, Xout=Xout, RHS=rhs, t=0.0, dt=DT()) + return Xout['a'] + else: + return ovar.dfield.data[i].get().handle + self._test_expr(expr, compute_outputs, + variables={A:discretization, B:discretization}, + method={ComputeGranularity:granularity, SpaceDiscretization:order, + TimeIntegrator:integrator}, dt=DT) + + + expr = Assignment(As.diff(t), As.diff(x0)) + def compute_outputs(fields, iparams, ifields, ovar, i): + A0 = fields[A] + if (ovar.dfield._field is A): + Xin = { 'a': A0 } + Xout = { 'a': np.empty_like(Xin['a'][ifields[A].compute_slices]) } + views = { 'a': ifields[A].compute_slices } + def rhs(out, X, t, **kwds): + dA0 = D1.apply(X['a'], symbols={D1.dx:ovar.space_step[-1]}, axis=-1) + out['a'][...] = dA0 + integrator(Xin=Xin, Xout=Xout, views=views, RHS=rhs, t=0.0, dt=DT()) + return Xout['a'] + else: + return ovar.dfield.data[i].get().handle + self._test_expr(expr, compute_outputs, + variables={A:discretization}, + method={ComputeGranularity:granularity, SpaceDiscretization:order, + TimeIntegrator:integrator}, dt=DT, no_ref_view=True) + + expr = Assignment(As.diff(t), P0s*Bs[0]*As.diff(x0) + Bs[1].diff(x0,x0)*As) + def compute_outputs(fields, iparams, ifields, ovar, i): + A0 = fields[A] + B0 = fields[B[0]] + B1 = fields[B[1]] + d2B1 = D2.apply(B1, symbols={D2.dx:ovar.space_step[-1]}, axis=-1) + assert order%2==0 + bg = order//2 + v = (Ellipsis, slice(bg, -bg)) + if (ovar.dfield._field is A): + Xin = { 'a': A0 } + Xout = { 'a': np.empty_like(Xin['a'][ifields[A].compute_slices]) } + views = { 'a': ifields[A].compute_slices } + def rhs(out, X, t, **kwds): + A0 = X['a'] + dA0 = D1.apply(A0, symbols={D1.dx:ovar.space_step[-1]}, axis=-1) + out['a'][v] = P0()*B0*dA0[v] + d2B1[v]*A0[v] + integrator(Xin=Xin, Xout=Xout, views=views, RHS=rhs, t=0.0, dt=DT()) + return Xout['a'] + else: + return ovar.dfield.data[i].get().handle + self._test_expr(expr, compute_outputs, + variables={A:discretization, B:discretization}, + method={ComputeGranularity:granularity, SpaceDiscretization:order, + TimeIntegrator:integrator}, dt=DT, no_ref_view=True) expr0 = Assignment(Bs[0].diff(t), 1 - As*Bs[1].diff(x0)) expr1 = Assignment(Bs[1].diff(t), 1 + As*Bs[0].diff(x0)) @@ -754,17 +778,20 @@ class TestCustomSymbolic(object): self._test_time_integrator(dim=3) def perform_tests(self): - #self.test_simple_1d() - #self.test_simple_2d() - #self.test_simple_3d() - - #self.test_stencil_1d() - #self.test_stencil_2d() - #self.test_stencil_3d() - - #self.test_time_integrator_1d() + self.test_simple_1d() + self.test_simple_2d() + if __ENABLE_LONG_TESTS__: + self.test_simple_3d() + + self.test_stencil_1d() + self.test_stencil_2d() + if __ENABLE_LONG_TESTS__: + self.test_stencil_3d() + + self.test_time_integrator_1d() self.test_time_integrator_2d() - #self.test_time_integrator_3d() + if __ENABLE_LONG_TESTS__: + self.test_time_integrator_3d() if __name__ == '__main__': TestCustomSymbolic.setup_class(enable_extra_tests=False, diff --git a/hysop/operator/tests/test_diffusion.py b/hysop/operator/tests/test_diffusion.py index 85ff85bb4786e98f146368e26c87fe5183482370..f697f732b8bb31bb8beceee073ffb83598e00b36 100644 --- a/hysop/operator/tests/test_diffusion.py +++ b/hysop/operator/tests/test_diffusion.py @@ -43,8 +43,11 @@ class TestDiffusionOperator(object): size_max = first_not_None(size_max, self.size_max) + 1 shape = tuple(npw.random.randint(low=size_min, high=size_max, size=dim).tolist()) - - flt_types = (npw.float32, npw.float64) + + if __ENABLE_LONG_TESTS__: + flt_types = (npw.float32, npw.float64) + else: + flt_types = (HYSOP_REAL,) domain = Box(length=(2*npw.pi,)*dim) for dtype in flt_types: @@ -129,6 +132,15 @@ class TestDiffusionOperator(object): sys.stdout.flush() diff = Diffusion(cl_env=cl_env, **base_kwds) yield diff.to_graph() + msg='\n *OpenCl FFTW: ' + print msg + cpu_envs = tuple(iter_clenv(device_type='cpu')) + if cpu_envs: + for cl_env in cpu_envs: + msg=' |platform {}, device {}'.format(cl_env.platform.name.strip(), + cl_env.device.name.strip()) + print msg, + yield Diffusion(cl_env=cl_env, enforce_implementation=False, **base_kwds) else: msg='Unknown implementation to test {}.'.format(impl) raise NotImplementedError(msg) @@ -261,7 +273,8 @@ class TestDiffusionOperator(object): def perform_tests(self): self.test_diffusion_1D_inplace() self.test_diffusion_2D_inplace() - self.test_diffusion_3D_inplace() + if __ENABLE_LONG_TESTS__: + self.test_diffusion_3D_inplace() print diff --git a/hysop/operator/tests/test_directional_diffusion.py b/hysop/operator/tests/test_directional_diffusion.py index a3ea8bb1c722bbc4bebef77ab553888766710c81..9d70d201c3c636e90371e5530616237684794585 100644 --- a/hysop/operator/tests/test_directional_diffusion.py +++ b/hysop/operator/tests/test_directional_diffusion.py @@ -12,7 +12,7 @@ from hysop.operator.directional.diffusion_dir import DirectionalDiffusion from hysop import Field, Box, Simulation from hysop.methods import Remesh, TimeIntegrator -from hysop.constants import Implementation, DirectionLabels, ComputeGranularity, SpaceDiscretization +from hysop.constants import Implementation, DirectionLabels, ComputeGranularity, SpaceDiscretization, HYSOP_REAL from hysop.numerics.splitting.strang import StrangSplitting, StrangOrder from hysop.numerics.remesh.remesh import RemeshKernel from hysop.numerics.stencil.stencil_generator import StencilGenerator, CenteredStencilGenerator, MPQ @@ -54,11 +54,11 @@ class TestDirectionalDiffusionOperator(object): if self.enable_extra_tests: flt_types = (npw.float32, npw.float64) - time_integrators = (Euler, RK2,) + time_integrators = (RK2, RK4) orders = (2, 4, 6) else: - flt_types = (npw.float32,) - time_integrators = (Euler, RK2) + flt_types = (HYSOP_REAL,) + time_integrators = (RK2,) orders = (4,) domain = Box(length=(2*npw.pi,)*dim) diff --git a/hysop/operator/tests/test_directional_stretching.py b/hysop/operator/tests/test_directional_stretching.py index 8ec099254ff88bc0a740be77c990787d37ee4a4d..99f8006e251d9677312a3ee403957621932efb78 100644 --- a/hysop/operator/tests/test_directional_stretching.py +++ b/hysop/operator/tests/test_directional_stretching.py @@ -13,7 +13,7 @@ from hysop.parameters.scalar_parameter import ScalarParameter from hysop import Field, Box, Simulation from hysop.methods import Remesh, TimeIntegrator from hysop.constants import Implementation, DirectionLabels, ComputeGranularity, \ - SpaceDiscretization, StretchingFormulation + SpaceDiscretization, StretchingFormulation, HYSOP_REAL from hysop.numerics.splitting.strang import StrangSplitting, StrangOrder from hysop.numerics.stencil.stencil_generator import StencilGenerator, CenteredStencilGenerator, \ MPQ @@ -61,8 +61,8 @@ class TestDirectionalStretchingOperator(object): time_integrators = (Euler, RK2,) orders = (2, 4, 6) else: - flt_types = (npw.float32,) - time_integrators = (Euler, RK2) + flt_types = (HYSOP_REAL,) + time_integrators = (RK2,) orders = (4,) domain = Box(length=(2*npw.pi,)*dim) diff --git a/hysop/operator/tests/test_fd_derivative.py b/hysop/operator/tests/test_fd_derivative.py index 13e16719646516a40a61c19a9a581e75f72bcb5c..334f8bed9b79800878d7b2c700bdd2d5f317d1bf 100644 --- a/hysop/operator/tests/test_fd_derivative.py +++ b/hysop/operator/tests/test_fd_derivative.py @@ -286,13 +286,17 @@ class TestFiniteDifferencesDerivative(object): self._test(dim=3, dtype=npw.float64) def perform_tests(self): - self.test_1d_float32() - self.test_2d_float32() - self.test_3d_float32() + if (HYSOP_REAL == npw.float32) or __ENABLE_LONG_TESTS__: + self.test_1d_float32() + self.test_2d_float32() + if __ENABLE_LONG_TESTS__: + self.test_3d_float32() - self.test_1d_float64() - self.test_2d_float64() - self.test_3d_float64() + if (HYSOP_REAL == npw.float64) or __ENABLE_LONG_TESTS__: + self.test_1d_float64() + self.test_2d_float64() + if __ENABLE_LONG_TESTS__: + self.test_3d_float64() if __name__ == '__main__': TestFiniteDifferencesDerivative.setup_class(enable_extra_tests=False, diff --git a/hysop/operator/tests/test_poisson.py b/hysop/operator/tests/test_poisson.py index 18dfc17e116bf0e76cb426607fa07e11aa1c26e8..d4cf58ea095dc926c07c905c3fc2d392fb5ebc41 100644 --- a/hysop/operator/tests/test_poisson.py +++ b/hysop/operator/tests/test_poisson.py @@ -194,10 +194,10 @@ class TestPoissonOperator(object): cl_env.device.name.strip()) print msg, yield Poisson(cl_env=cl_env, **base_kwds) + msg=' *OpenCl FFTW: ' + print msg cpu_envs = tuple(iter_clenv(device_type='cpu')) if cpu_envs: - msg=' *OpenCl FFTW: ' - print msg for cl_env in cpu_envs: msg=' |platform {}, device {}'.format(cl_env.platform.name.strip(), cl_env.device.name.strip()) @@ -359,13 +359,15 @@ class TestPoissonOperator(object): if __ENABLE_LONG_TESTS__ or (HYSOP_REAL==npw.float32): self.test_1d_float32(max_runs=max_1d_runs) self.test_2d_float32(max_runs=max_2d_runs) - self.test_3d_float32(max_runs=max_3d_runs) - self.test_4d_float32(max_runs=max_4d_runs) + if __ENABLE_LONG_TESTS__: + self.test_3d_float32(max_runs=max_3d_runs) + self.test_4d_float32(max_runs=max_4d_runs) if __ENABLE_LONG_TESTS__ or (HYSOP_REAL==npw.float64): self.test_1d_float64(max_runs=max_1d_runs) self.test_2d_float64(max_runs=max_2d_runs) - self.test_3d_float64(max_runs=max_3d_runs) - self.test_4d_float32(max_runs=max_4d_runs) + if __ENABLE_LONG_TESTS__: + self.test_3d_float64(max_runs=max_3d_runs) + self.test_4d_float32(max_runs=max_4d_runs) if __name__ == '__main__': TestPoissonOperator.setup_class(enable_extra_tests=False, diff --git a/hysop/operator/tests/test_poisson_curl.py b/hysop/operator/tests/test_poisson_curl.py index 50906379e67ddf76104c645ecfd882ac3e6232ac..33e779441918ce96aa44add9969a752c5ef8bb09 100644 --- a/hysop/operator/tests/test_poisson_curl.py +++ b/hysop/operator/tests/test_poisson_curl.py @@ -194,10 +194,10 @@ class TestPoissonCurlOperator(object): cl_env.device.name.strip()) print msg, yield PoissonCurl(cl_env=cl_env, projection=0, **base_kwds) + msg=' *OpenCl FFTW: ' + print msg cpu_envs = tuple(iter_clenv(device_type='cpu')) if cpu_envs: - msg=' *OpenCl FFTW: ' - print msg for cl_env in cpu_envs: msg=' |platform {}, device {}'.format(cl_env.platform.name.strip(), cl_env.device.name.strip()) @@ -339,8 +339,8 @@ class TestPoissonCurlOperator(object): self._test(dim=3, dtype=npw.float64, **kwds) def perform_tests(self): - max_2d_runs = None - max_3d_runs = None if __ENABLE_LONG_TESTS__ else 3 + max_2d_runs = None if __ENABLE_LONG_TESTS__ else 2 + max_3d_runs = None if __ENABLE_LONG_TESTS__ else 2 if __ENABLE_LONG_TESTS__ or (HYSOP_REAL==npw.float32): self.test_2d_float32(max_runs=max_2d_runs) diff --git a/hysop/operator/tests/test_solenoidal_projection.py b/hysop/operator/tests/test_solenoidal_projection.py index 9e7f4fd247479edf07fa59e9bee4812d4395b761..e43f3ec4e5dc949e67d241df3f2a0e70f6bd3537 100644 --- a/hysop/operator/tests/test_solenoidal_projection.py +++ b/hysop/operator/tests/test_solenoidal_projection.py @@ -243,10 +243,10 @@ class TestSolenoidalProjectionOperator(object): cl_env.device.name.strip()) print msg, yield SolenoidalProjection(cl_env=cl_env, **base_kwds) + msg=' *OpenCl FFTW: ' + print msg cpu_envs = tuple(iter_clenv(device_type='cpu')) if cpu_envs: - msg=' *OpenCl FFTW: ' - print msg for cl_env in cpu_envs: msg=' |platform {}, device {}'.format(cl_env.platform.name.strip(), cl_env.device.name.strip()) @@ -399,8 +399,10 @@ class TestSolenoidalProjectionOperator(object): def perform_tests(self): max_3d_runs = None if __ENABLE_LONG_TESTS__ else 3 - self.test_3d_float32(max_runs=max_3d_runs) - self.test_3d_float64(max_runs=max_3d_runs) + if __ENABLE_LONG_TESTS__ or (HYSOP_REAL==npw.float32): + self.test_3d_float32(max_runs=max_3d_runs) + if __ENABLE_LONG_TESTS__ or (HYSOP_REAL==npw.float64): + self.test_3d_float64(max_runs=max_3d_runs) if __name__ == '__main__': TestSolenoidalProjectionOperator.setup_class(enable_extra_tests=False, diff --git a/hysop/operator/tests/test_spectral_curl.py b/hysop/operator/tests/test_spectral_curl.py index db68fd77069131fc56a326f47280a46d9af950d8..3407397bd8ab9496da1f1fe72c32c75055b776dc 100644 --- a/hysop/operator/tests/test_spectral_curl.py +++ b/hysop/operator/tests/test_spectral_curl.py @@ -328,8 +328,8 @@ class TestSpectralCurl(object): self._test(dim=3, dtype=npw.float64, nb_components=3, **kwds) def perform_tests(self): - max_2d_runs = None if __ENABLE_LONG_TESTS__ else 3 - max_3d_runs = None if __ENABLE_LONG_TESTS__ else 3 + max_2d_runs = None if __ENABLE_LONG_TESTS__ else 2 + max_3d_runs = None if __ENABLE_LONG_TESTS__ else 2 if __ENABLE_LONG_TESTS__ or (HYSOP_REAL==npw.float32): self.test_2d_float32__1(max_runs=max_2d_runs) diff --git a/hysop/operator/tests/test_spectral_derivative.py b/hysop/operator/tests/test_spectral_derivative.py index 195aefd67e59729c41939bf1bf28debf0adfc772..5702c7f73ec2256b14f911062cc23b97f4a072aa 100644 --- a/hysop/operator/tests/test_spectral_derivative.py +++ b/hysop/operator/tests/test_spectral_derivative.py @@ -108,7 +108,7 @@ class TestSpectralDerivative(object): d[...] = fn(*(coord+(t(),))).astype(d.dtype) def _test(self, dim, dtype, polynomial, max_derivative=2, - size_min=None, size_max=None): + size_min=None, size_max=None, max_runs=None): enable_extra_tests = self.enable_extra_tests size_min = first_not_None(size_min, self.size_min) @@ -116,9 +116,15 @@ class TestSpectralDerivative(object): shape = tuple(npw.random.randint(low=size_min, high=size_max+1, size=dim).tolist()) - for (lboundaries, rboundaries) in domain_boundary_iterator(dim=dim): - domain = Box(origin=(-1.244544,)*dim, - length=(+6.985452,)*dim, + domain_boundaries = list(domain_boundary_iterator(dim=dim)) + periodic = domain_boundaries[0] + domain_boundaries = domain_boundaries[1:] + random.shuffle(domain_boundaries) + domain_boundaries.insert(0, periodic) + + for i, (lboundaries, rboundaries) in enumerate(domain_boundaries, 1): + domain = Box(origin=(npw.random.rand(dim)-0.5), + length=(npw.random.rand(dim)+0.5)*2*npw.pi, lboundaries=lboundaries, rboundaries=rboundaries) @@ -128,6 +134,20 @@ class TestSpectralDerivative(object): domain=domain, F=F, polynomial=polynomial, max_derivative=max_derivative) + + if (max_runs is not None) and (i==max_runs): + missing = ((4**(dim+1) - 1) / 3) - i + print + print '>> MAX RUNS ACHIEVED FOR {}D DOMAINS -- SKIPING {} OTHER BOUNDARY CONDITIONS <<'.format(dim, missing) + print + print + break + else: + assert (i==(4**(dim+1)-1)/3), (i+1, (4**(dim+1)-1)/3) + print + print '>> TESTED ALL {}D BOUNDARY CONDITIONS <<'.format(dim) + print + print def _test_one(self, shape, dim, dtype, @@ -323,12 +343,14 @@ class TestSpectralDerivative(object): self._test(dim=3, dtype=npw.float32, polynomial=True, **kwds) def perform_tests(self): + max_2d_runs = None if __ENABLE_LONG_TESTS__ else 2 + max_3d_runs = None if __ENABLE_LONG_TESTS__ else 2 + self.test_1d_trigonometric_float32(max_derivative=3) - self.test_2d_trigonometric_float32(max_derivative=2) + self.test_2d_trigonometric_float32(max_derivative=2, max_runs=max_2d_runs) + self.test_3d_trigonometric_float32(max_derivative=1, max_runs=max_3d_runs) if __ENABLE_LONG_TESTS__: - self.test_3d_trigonometric_float32(max_derivative=1) - self.test_1d_trigonometric_float64(max_derivative=3) self.test_2d_trigonometric_float64(max_derivative=2) self.test_3d_trigonometric_float64(max_derivative=1) diff --git a/hysop/operator/tests/test_transpose.py b/hysop/operator/tests/test_transpose.py index 116785c1ba72bedabf5d0a8ec553d9c80cd6c8a2..6ebe79df3d9fbc2c4bd47535218a6af2ef9473be 100644 --- a/hysop/operator/tests/test_transpose.py +++ b/hysop/operator/tests/test_transpose.py @@ -223,14 +223,14 @@ class TestTransposeOperator(object): def perform_tests(self): self.test_2d_out_of_place() - self.test_3d_out_of_place() if __ENABLE_LONG_TESTS__: + self.test_3d_out_of_place() self.test_4d_out_of_place() self.test_upper_dimensions_out_of_place() self.test_2d_inplace() - self.test_3d_inplace() if __ENABLE_LONG_TESTS__: + self.test_3d_inplace() self.test_4d_inplace() self.test_upper_dimensions_inplace() diff --git a/hysop/testsenv.py b/hysop/testsenv.py index 92ffbb2a6db633b61e8552e245ce8fedfa9ad6ad..8e1b7e1ec3f10ee6b186d3afd284d15d568d1389 100644 --- a/hysop/testsenv.py +++ b/hysop/testsenv.py @@ -80,16 +80,18 @@ if __HAS_OPENCL_BACKEND__: all_platforms = first_not_None(all_platforms, __TEST_ALL_OPENCL_PLATFORMS__) if isinstance(device_type, str): if (device_type=='cpu'): - device_type = cl.device_type.CPU + cl_device_type = cl.device_type.CPU elif (device_type=='gpu'): - device_type = cl.device_type.GPU + cl_device_type = cl.device_type.GPU else: raise NotImplementedError(device_type) + else: + cl_device_type = device_type cl_environments = iter_clenv.cl_environments - if (device_type not in cl_environments): - cl_environments[device_type] = [] - if (device_type is None): + if (cl_device_type not in cl_environments): + cl_environments[cl_device_type] = [] + if (cl_device_type is None): mpi_params = default_mpi_params() if all_platforms: for i,plat in enumerate(cl.get_platforms()): @@ -103,18 +105,18 @@ if __HAS_OPENCL_BACKEND__: mpi_params=mpi_params, **kwds) cl_environments[None].append(cl_env) else: - for cl_env in iter_clenv(device_type=None, all_platforms=True): - if (cl_env.device.type == device_type): - cl_environments[device_type].append(cl_env) + for cl_env in iter_clenv(cl_device_type=None, all_platforms=True): + if (cl_env.device.type & cl_device_type): + cl_environments[cl_device_type].append(cl_env) - if len(cl_environments[device_type])==0: - msg='::Could not generate any opencl environment for device type {}.' + if len(cl_environments[cl_device_type])==0: + msg=' |Could not generate any opencl environment for device type {}.' msg=msg.format(device_type) - if (device_type == None): + if (cl_device_type == None): raise RuntimeError(msg) else: print msg - for cl_env in cl_environments[device_type]: + for cl_env in cl_environments[cl_device_type]: yield cl_env if not all_platforms: return