diff --git a/examples/taylor_green/taylor_green_monoscale.py b/examples/taylor_green/taylor_green_monoscale.py index 6f06a949506767b17b263c9266579172739e0ba4..d599b58deef39647775e230e82295e4627731985 100644 --- a/examples/taylor_green/taylor_green_monoscale.py +++ b/examples/taylor_green/taylor_green_monoscale.py @@ -34,7 +34,7 @@ def do_solve(npts, viscosity=1./1600., lcfl=0.125, cfl=0.50): prune_threshold=1.2, override_cache=False, verbose=2) kernel_config = KernelConfig(autotuner_config=autotuner_config) - dim = 3 + dim = 1 box = Box(length=(2*pi,)*dim) @@ -44,7 +44,7 @@ def do_solve(npts, viscosity=1./1600., lcfl=0.125, cfl=0.50): name='V', is_vector=True) vorti = Field(domain=box, formula=init_vorticity, name='W', is_vector=True, - nb_components=(1 if dim==2 else 3)) + nb_components=(1 if dim==2 else dim)) d3d = Discretization(resolution=resolution) @@ -66,10 +66,10 @@ def do_solve(npts, viscosity=1./1600., lcfl=0.125, cfl=0.50): # method = {SpaceDiscretization: SpaceDiscretization.FDC4} # ) - poisson = Poisson(name='poisson', velocity=velo, vorticity=vorti, - variables={velo:d3d, vorti: d3d}) - diffusion = Diffusion(name='diffusion', input_field=vorti, viscosity=viscosity, - variables={vorti: d3d}) + # poisson = Poisson(name='poisson', velocity=velo, vorticity=vorti, + # variables={velo:d3d, vorti: d3d}) + # diffusion = Diffusion(name='diffusion', input_field=vorti, viscosity=viscosity, + # variables={vorti: d3d}) splitting = StrangSplitting(splitting_dim=dim, order=StrangOrder.STRANG_SECOND_ORDER, method={KernelConfig: kernel_config}) @@ -88,6 +88,6 @@ def do_solve(npts, viscosity=1./1600., lcfl=0.125, cfl=0.50): problem.finalize() if __name__=='__main__': - N = 721 + N = 128*128 + 1 do_solve(N) diff --git a/hysop/__init__.py b/hysop/__init__.py index bf30fb5f76c4386cc4ad27c05887f0e38342b4aa..feb4b0717e7c1c3061a00285652cdfce439f9119 100644 --- a/hysop/__init__.py +++ b/hysop/__init__.py @@ -16,7 +16,7 @@ __FFTW_ENABLED__ = "ON" is "ON" __SCALES_ENABLED__ = "ON" is "ON" __OPTIMIZE__ = "OFF" is "ON" -__VERBOSE__ = True +__VERBOSE__ = "ON" in ["1", "3"] __DEBUG__ = "ON" in ["2", "3"] __TRACE__ = "ON" in ["5"] __KERNEL_DEBUG__ = "ON" in ["4", "3"] @@ -25,8 +25,8 @@ __PROFILE__ = "OFF" in ["0", "1"] __ENABLE_LONG_TESTS__ = "OFF" is "ON" # OpenCL -__DEFAULT_PLATFORM_ID__ = 0 -__DEFAULT_DEVICE_ID__ = 1 +__DEFAULT_PLATFORM_ID__ = 1 +__DEFAULT_DEVICE_ID__ = 0 diff --git a/hysop/backend/device/codegen/kernels/directional_remesh.py b/hysop/backend/device/codegen/kernels/directional_remesh.py index 562e1ada679c8d4d0b17ee7339bda70762e9eb27..ecd550c02558f3be2d8c2730b974d959352652b2 100644 --- a/hysop/backend/device/codegen/kernels/directional_remesh.py +++ b/hysop/backend/device/codegen/kernels/directional_remesh.py @@ -11,7 +11,7 @@ from hysop.tools.misc import Utils from hysop.tools.types import check_instance from hysop.deps import np -from hysop.constants import DirectionLabels, BoundaryCondition, Backend +from hysop.constants import DirectionLabels, BoundaryCondition, Backend, Precision from hysop.core.arrays.all import OpenClArray from hysop.backend.device.codegen.base.opencl_codegen import OpenClCodeGenerator @@ -1051,6 +1051,28 @@ class DirectionalRemeshKernel(KernelCodeGenerator): nparticles_options = [1,2,4,8,16] use_atomics_options = [True] if force_atomics else [False, True] + if True in use_atomics_options: + msg=None + if ftype == 'float': + if not cl_env.has_extension('cl_khr_local_int32_base_atomics'): + msg='Your device does not support int32 atomics (cl_khr_local_int32_base_atomics).' + elif ftype == 'double': + if not cl_env.has_extension('cl_khr_int64_base_atomics'): + msg='Your device does not support int64 atomics (cl_khr_int64_base_atomics).' + else: + msg = 'Atomic remeshing kernel has not been implemented for {} yet.'.format(precision) + raise RuntimeError(msg) + + if msg: + if force_atomics: + msg += '\nParameter force_atomics was set to True, aborting...' + raise RuntimeError(msg) + else: + msg += '\nAtomic version of the remeshing kernel will be disabled.' + import warnings + warnings.warn(msg) + use_atomics_options.remove(True) + autotuner_flag = autotuner_config.autotuner_flag if (autotuner_flag == AutotunerFlags.ESTIMATE): max_workitem_workload = [1,1,1] diff --git a/hysop/constants.py b/hysop/constants.py index e85cc975b76b788c6c2ee7622f57241054d7d40e..1cca17bde937c3eacc9efb87a79bc85409a16323 100644 --- a/hysop/constants.py +++ b/hysop/constants.py @@ -22,7 +22,7 @@ HYSOP_ROOT=os.path.dirname(inspect.getfile(hysop)) PI = math.pi -HYSOP_REAL = np.float32 +HYSOP_REAL = np.float64 """Set default type for real numbers""" SIZEOF_HYSOP_REAL = int(HYSOP_REAL(1.).nbytes) """Size in memory of hysop real default type""" diff --git a/hysop/core/mpi/topology.py b/hysop/core/mpi/topology.py index afe862db5b26974ed78097d6247ca54b956e1228..400ec94c504d3c1efeadc15e75baef9f13dadaeb 100644 --- a/hysop/core/mpi/topology.py +++ b/hysop/core/mpi/topology.py @@ -349,12 +349,14 @@ class Cartesian(Topology): assert shape is None, 'shape ' + msg assert dim is None, 'dim ' + msg self.cutdir = npw.asboolarray(cutdir).copy() - self.dimension = self.cutdir[self.cutdir].size + self.dimension = self.cutdir[self.cutdir != 0].size shape = npw.asdimarray(MPI.Compute_dims(origin_size, self.dimension)) + self._optimizeshape(shape) + self.shape = npw.dim_ones(self.domain.dimension) - self.shape[self.cutdir] = shape + self.shape[self.cutdir != 0] = shape else: if dim is not None: @@ -394,7 +396,7 @@ class Cartesian(Topology): self._isperiodic = tuple(isperiodic) # compute real dim ... - self.dimension = self.shape[self.cutdir].size + self.dimension = self.shape[self.cutdir != 0].size # Special care for the 1 process case: if origin_size == 1: diff --git a/hysop/tools/enum.py b/hysop/tools/enum.py index dfd0c06af8a7303697bcc1794b14e6d83c19374e..5638134881189c16e2c3c9f59c7cb0ea9813b7aa 100644 --- a/hysop/tools/enum.py +++ b/hysop/tools/enum.py @@ -221,10 +221,10 @@ class EnumFactory(object): return '{}({})'.format(self.svalue(),self.value()) def __eq__(self, other): - assert isinstance(other, self.__class__) + assert isinstance(other, self.__class__), 'other.cls = {}'.format(other.__class__) return self._value == other._value def __ne__(self, other): - assert isinstance(other, self.__class__) + assert isinstance(other, self.__class__), 'other.cls = {}'.format(other.__class__) return self._value != other._value #pickling