diff --git a/hysop/__init__.py b/hysop/__init__.py index 1382493cb73a43792564a9e8e5cb607d52a42240..9da1136999d6187df84dd1b3588f833216a6d72c 100644 --- a/hysop/__init__.py +++ b/hysop/__init__.py @@ -22,7 +22,7 @@ __TRACE__ = False __KERNEL_DEBUG__ = True __PROFILE__ = "OFF" in ["0", "1"] -__ENABLE_LONG_TESTS__ = "OFF" is "ON" +__ENABLE_LONG_TESTS__ = True # OpenCL __DEFAULT_PLATFORM_ID__ = 1 diff --git a/hysop/backend/device/codegen/kernels/directional_remesh.py b/hysop/backend/device/codegen/kernels/directional_remesh.py index def55d1f765a53fa3777dff64a5b66e24566fb87..7cc8b729802cdda0f58ff0ad97a5142a4bf06c9b 100644 --- a/hysop/backend/device/codegen/kernels/directional_remesh.py +++ b/hysop/backend/device/codegen/kernels/directional_remesh.py @@ -221,8 +221,10 @@ class DirectionalRemeshKernel(KernelCodeGenerator): mesh_info_struct = MeshInfoStruct(typegen=typegen, typedef='MeshInfo_s') reqs['MeshInfoStruct'] = mesh_info_struct + # without atomics we can only remesh on particle at a time + nparticles_remeshed = nparticles if use_atomics else 1 reqs['remesh'] = DirectionalRemeshFunction(typegen=typegen, work_dim=work_dim, - itype=itype, ftype=ftype, nparticles=nparticles, nscalars=nscalars, + itype=itype, ftype=ftype, nparticles=nparticles_remeshed, nscalars=nscalars, sboundary=sboundary, remesh_kernel=remesh_kernel, use_atomics=use_atomics, remesh_criteria_eps=remesh_criteria_eps, debug_mode=debug_mode) @@ -690,18 +692,32 @@ class DirectionalRemeshKernel(KernelCodeGenerator): s.comment('Remesh scalars in cache.') remesh = s.reqs['remesh'] remesh_kargs = { - 'p':pos, - 'dx':dx, 'inv_dx':inv_dx, - 'cache_ghosts': cache_ghosts, - 'active': active, - 'line_offset': line_offset} - for i,(scalar,cached_scalar) in enumerate(zip(scalars, cached_scalars)): - remesh_kargs['s{}'.format(i)] = scalar + 'dx':dx, + 'inv_dx':inv_dx, + 'cache_ghosts': cache_ghosts, + 'active': active, + 'line_offset': line_offset + } + for i,cached_scalar in enumerate(cached_scalars): remesh_kargs['S{}'.format(i)] = cached_scalar if is_periodic: remesh_kargs['grid_size'] = compute_grid_size[0] - call = remesh(**remesh_kargs) - s.append('{};'.format(call)) + + if use_atomics: + # with atomic summation in cache, we can remesh everything at a time + remesh_kargs['p'] = pos + for i,scalar in enumerate(scalars): + remesh_kargs['s{}'.format(i)] = scalar + call = remesh(**remesh_kargs) + s.append('{};'.format(call)) + else: + # without atomics we can only remesh on particle at a time + for j in xrange(nparticles): + remesh_kargs['p'] = pos[j] + for i,scalar in enumerate(scalars): + remesh_kargs['s{}'.format(i)] = scalar[j] + call = remesh(**remesh_kargs) + s.append('{};'.format(call)) s.jumpline() diff --git a/hysop/backend/device/codegen/kernels/tests/test_directional_remesh.py b/hysop/backend/device/codegen/kernels/tests/test_directional_remesh.py index f151f06d4e9e54b601e8a2de1878f09d62e3e608..a2481753b3fd9f1674130d3c62bad5b6be77352d 100644 --- a/hysop/backend/device/codegen/kernels/tests/test_directional_remesh.py +++ b/hysop/backend/device/codegen/kernels/tests/test_directional_remesh.py @@ -38,7 +38,7 @@ class TestDirectionalRemesh(object): eps = np.finfo(dtype).eps # compute grid - compute_grid_size = np.asarray([97,7,11]) + compute_grid_size = np.asarray([97,17,23]) compute_grid_shape = compute_grid_size[::-1] (A,compute_grid_mesh_info) = _test_mesh_info('base_mesh_info',typegen,3,0,compute_grid_size) @@ -124,7 +124,7 @@ class TestDirectionalRemesh(object): ## allocate and initialize buffers random = self.random - random.seed(42) + #random.seed(42) uinit = (umax-umin) * random.rand(*compute_grid_shape).astype(dtype) + umin # force worst case on boundaries @@ -575,12 +575,6 @@ class TestDirectionalRemesh(object): err1 = J1-J0+S1_not_remeshed if not np.allclose(I0, I1+S0_not_remeshed): - print I0 - print I1 - print S0_not_remeshed - print J0 - print J1 - print S1_not_remeshed msg = '#S0 failed: I0:{} != I1:{}, not remeshed {:3.02}%'.format(I0,I1, abs(100*S1_not_remeshed/J0)) raise ValueError(msg) @@ -782,7 +776,7 @@ class TestDirectionalRemesh(object): debug_mode=self.DEBUG, known_vars=known_vars) - # drk.edit() + #drk.edit() global_work_size = drk.get_global_size(work_size, local_work_size, work_load) (static_shared_bytes, dynamic_shared_bytes, total_sharedbytes) = \ @@ -1038,25 +1032,21 @@ class TestDirectionalRemesh(object): assert cfl>0 check_instance(rk_scheme,ExplicitRungeKutta) - nscalars=[1,2] - boundaries=[BoundaryCondition.NONE, BoundaryCondition.PERIODIC] + nscalars=[2] + boundaries=[BoundaryCondition.PERIODIC, BoundaryCondition.NONE] + + split_polys=[False, True] + use_atomics=[False, True] + is_inplaces=[False, True] + remesh_criterias=[None, 1000000] + nparticles=[1,2,4,8,16] if self.enable_extra_tests: kernels=[(2,1), (2,2), (4,2), (4,4), (6,4), (6,6), (8,4)] - nparticles=[1,2,4,8,16] work_dims=[1,2,3] - split_polys=[False, True] - use_atomics=[False, True] - is_inplaces=[False, True] - remesh_criterias=[None, 1000000] else: - kernels=[(2,1), (2,2), (4,2), (4,4), (6,4), (6,6), (8,4)] - nparticles=[1,2,4,8,16] - work_dims=[1,2,3] - split_polys=[False, True] - use_atomics=[False, True] - is_inplaces=[False, True] - remesh_criterias=[None, 1000000] + kernels=[(2,1),(8,4)] + work_dims=[2] ntests = 0 for cl_env in iter_clenv(precision=Precision.FLOAT): @@ -1074,7 +1064,7 @@ class TestDirectionalRemesh(object): for is_inplace in is_inplaces: for use_atomic in use_atomics: for nparticle in nparticles: - if (not use_atomic) and (nparticle<=np.ceil(cfl)): + if (not use_atomic) and (nparticle<=int(2*np.floor(cfl)+1)): continue for nscalar in nscalars: self._do_compute_on_gpu_and_check(cl_env=cl_env, @@ -1093,7 +1083,7 @@ class TestDirectionalRemesh(object): self._check_kernels(rk_scheme=rk_scheme, cfl=cfl) @opencl_failed - def test_remesh_from_Euler_advection_high_cfl(self, cfl=3.78): + def test_remesh_from_Euler_advection_high_cfl(self, cfl=1.78): rk_scheme=ExplicitRungeKutta('Euler') self._check_kernels(rk_scheme=rk_scheme, cfl=cfl) diff --git a/hysop/core/graph/computational_operator.py b/hysop/core/graph/computational_operator.py index ea630e4ca5567ad8873f84ec1058823d4f71f538..8dc3d4b50ea4422034eb932963960e6a75011e51 100644 --- a/hysop/core/graph/computational_operator.py +++ b/hysop/core/graph/computational_operator.py @@ -4,7 +4,7 @@ from hysop.tools.decorators import debug from hysop.core.graph.computational_node import ComputationalGraphNode from hysop.core.graph.graph import initialized, discretized from hysop.core.memory.memory_request import OperatorMemoryRequests -from hysop.field.field_requirements.DiscreteFieldRequirements +from hysop.fields.field_requirements import DiscreteFieldRequirements from abc import ABCMeta class ComputationalGraphOperator(ComputationalGraphNode): diff --git a/hysop/fields/field_requirements.py b/hysop/fields/field_requirements.py index 6f8e52995311aba30d86ade5560d4b278dee4388..59c9678c0cd0e8bb72d9c68213688540eae5ab9e 100644 --- a/hysop/fields/field_requirements.py +++ b/hysop/fields/field_requirements.py @@ -78,7 +78,7 @@ class DiscreteFieldRequirements(object): msg=msg.format(self.header, self.max_ghosts, topology.ghosts) raise RuntimeError(msg) - def check_state(self, dfield) + def check_state(self, dfield): check_instance(dfield, DiscreteField) self.check_topology(dfield.topology)