From 8689cf5ba5910814584aa6ce17b1f743331a1a1c Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Keck <Jean-Baptiste.Keck@imag.fr> Date: Sun, 2 Dec 2018 19:36:38 +0100 Subject: [PATCH] fixed creation of additional unused opencl environment --- examples/analytic/analytic.py | 2 +- examples/scalar_advection/scalar_advection.py | 2 +- examples/scalar_diffusion/scalar_diffusion.py | 2 +- examples/shear_layer/shear_layer.py | 4 ++-- examples/taylor_green/taylor_green.py | 4 ++-- hysop/backend/device/opencl/opencl_array_backend.py | 3 ++- hysop/operator/base/spectral_operator.py | 1 - hysop/topology/topology.py | 3 ++- hysop/topology/topology_descriptor.py | 3 +++ 9 files changed, 14 insertions(+), 10 deletions(-) diff --git a/examples/analytic/analytic.py b/examples/analytic/analytic.py index 0f2e1eff5..09f01a5cd 100755 --- a/examples/analytic/analytic.py +++ b/examples/analytic/analytic.py @@ -83,7 +83,7 @@ def compute(args): **op_kwds) # Write output field at given frequency - analytic.dump_outputs(fields=scalar, frequency=args.dump_freq, filename='F') + analytic.dump_outputs(fields=scalar, frequency=args.dump_freq, filename='F', **op_kwds) # Create the problem we want to solve and insert our operator problem = Problem() diff --git a/examples/scalar_advection/scalar_advection.py b/examples/scalar_advection/scalar_advection.py index 3cf75c6cc..11d007844 100644 --- a/examples/scalar_advection/scalar_advection.py +++ b/examples/scalar_advection/scalar_advection.py @@ -109,7 +109,7 @@ def compute(args): problem.insert(splitting) # Add a writer of input field at given frequency. - problem.dump_inputs(fields=scalar, filename='S0', frequency=args.dump_freq) + problem.dump_inputs(fields=scalar, filename='S0', frequency=args.dump_freq, **extra_op_kwds) problem.build(args) # If a visu_rank was provided, and show_graph was set, diff --git a/examples/scalar_diffusion/scalar_diffusion.py b/examples/scalar_diffusion/scalar_diffusion.py index 88683431b..4ee0f75ce 100755 --- a/examples/scalar_diffusion/scalar_diffusion.py +++ b/examples/scalar_diffusion/scalar_diffusion.py @@ -80,7 +80,7 @@ def compute(args): # Add a writer of input field at given frequency. problem = Problem(method=method) problem.insert(splitting) - problem.dump_inputs(fields=scalar, filename='S0', frequency=args.dump_freq) + problem.dump_inputs(fields=scalar, filename='S0', frequency=args.dump_freq, **extra_op_kwds) problem.build(args) # If a visu_rank was provided, and show_graph was set, diff --git a/examples/shear_layer/shear_layer.py b/examples/shear_layer/shear_layer.py index 81dc9768b..210494ba3 100644 --- a/examples/shear_layer/shear_layer.py +++ b/examples/shear_layer/shear_layer.py @@ -103,8 +103,8 @@ def compute(args): diffusion=nu, dt=dt, implementation=impl, **extra_op_kwds) #> We ask to dump the inputs and the outputs of this operator - poisson.dump_outputs(fields=(vorti,), frequency=args.dump_freq) - poisson.dump_outputs(fields=(velo,), frequency=args.dump_freq) + poisson.dump_outputs(fields=(vorti,), frequency=args.dump_freq, **extra_op_kwds) + poisson.dump_outputs(fields=(velo,), frequency=args.dump_freq, **extra_op_kwds) #> Operator to compute the infinite norm of the velocity min_max_U = MinMaxFieldStatistics(name='min_max_U', field=velo, Finf=True, implementation=impl, variables={velo:npts}, diff --git a/examples/taylor_green/taylor_green.py b/examples/taylor_green/taylor_green.py index d582b457e..24cb866ae 100644 --- a/examples/taylor_green/taylor_green.py +++ b/examples/taylor_green/taylor_green.py @@ -135,8 +135,8 @@ def compute(args): diffusion=viscosity, dt=dt, implementation=impl, **extra_op_kwds) #> We ask to dump the outputs of this operator - poisson.dump_outputs(fields=(vorti,), frequency=args.dump_freq) - poisson.dump_outputs(fields=(velo,), frequency=args.dump_freq) + poisson.dump_outputs(fields=(vorti,), frequency=args.dump_freq, **extra_op_kwds) + poisson.dump_outputs(fields=(velo,), frequency=args.dump_freq, **extra_op_kwds) #> Operator to compute the infinite norm of the velocity if (impl is Implementation.FORTRAN): diff --git a/hysop/backend/device/opencl/opencl_array_backend.py b/hysop/backend/device/opencl/opencl_array_backend.py index 4e004a04e..8aaae7bdc 100644 --- a/hysop/backend/device/opencl/opencl_array_backend.py +++ b/hysop/backend/device/opencl/opencl_array_backend.py @@ -351,7 +351,8 @@ class OpenClArrayBackend(ArrayBackend): raise RuntimeError(msg) if (queue is None): - cl_env = cl_env or get_or_create_opencl_env() + if (cl_env is None): + cl_env = get_or_create_opencl_env() context = cl_env.context queue = cl_env.default_queue allocator = allocator or cl_env.allocator diff --git a/hysop/operator/base/spectral_operator.py b/hysop/operator/base/spectral_operator.py index 0f89b45a3..347403136 100644 --- a/hysop/operator/base/spectral_operator.py +++ b/hysop/operator/base/spectral_operator.py @@ -1225,7 +1225,6 @@ class PlannedSpectralTransform(object): buf_nbytes = compute_nbytes(buf.shape, buf.dtype) input_nbytes = compute_nbytes(input_shape, input_dtype) assert buf_nbytes >= input_nbytes, (buf_nbytes, input_nbytes) - print buf.shape, buf.strides, buf.dtype buf = buf.view(dtype=np.int8)[:input_nbytes].view(dtype=input_dtype).reshape(input_shape) if isinstance(buf, Array): buf = buf.handle diff --git a/hysop/topology/topology.py b/hysop/topology/topology.py index 249f03683..77300f5ee 100644 --- a/hysop/topology/topology.py +++ b/hysop/topology/topology.py @@ -362,7 +362,8 @@ class Topology(RegisteredObject): elif (backend == Backend.OPENCL): from hysop.backend.device.opencl.opencl_tools import get_or_create_opencl_env from hysop.core.arrays.all import OpenClArrayBackend - cl_env = first_not_None(cl_env, get_or_create_opencl_env(mpi_params)) + if (cl_env is None): + cl_env = get_or_create_opencl_env(mpi_params) assert cl_env.mpi_params == mpi_params backend = OpenClArrayBackend.get_or_create(cl_env=cl_env, queue=queue, allocator=allocator) assert backend.cl_env.mpi_params == mpi_params diff --git a/hysop/topology/topology_descriptor.py b/hysop/topology/topology_descriptor.py index d5a8ee659..ff0bd717e 100644 --- a/hysop/topology/topology_descriptor.py +++ b/hysop/topology/topology_descriptor.py @@ -31,6 +31,9 @@ class TopologyDescriptor(object): self._backend=backend self._extra_kwds = frozenset(kwds.items()) + if ('cl_env' in kwds): + assert kwds['cl_env'].mpi_params is mpi_params + def _get_mpi_params(self): """Get mpi parameters.""" return self._mpi_params -- GitLab