diff --git a/pystencils/boundaries/boundaryhandling.py b/pystencils/boundaries/boundaryhandling.py index 4056874ed8a3926c63c6e00136cbe39c820d1c5d..5a60ca6ebed58cbcbdb454fa4215da13738aa1b0 100644 --- a/pystencils/boundaries/boundaryhandling.py +++ b/pystencils/boundaries/boundaryhandling.py @@ -96,21 +96,21 @@ class BoundaryHandling: fi = flag_interface self.flag_interface = fi if fi is not None else FlagInterface(data_handling, name + "Flags") + if ParallelDataHandling and isinstance(self.data_handling, ParallelDataHandling): + array_handler = PyCudaArrayHandler() + else: + array_handler = self.data_handling.array_handler + def to_cpu(gpu_version, cpu_version): gpu_version = gpu_version.boundary_object_to_index_list cpu_version = cpu_version.boundary_object_to_index_list for obj, cpu_arr in cpu_version.items(): - gpu_version[obj].get(cpu_arr) + array_handler.download(gpu_version[obj], cpu_arr) def to_gpu(gpu_version, cpu_version): gpu_version = gpu_version.boundary_object_to_index_list cpu_version = cpu_version.boundary_object_to_index_list - if ParallelDataHandling and isinstance(self.data_handling, ParallelDataHandling): - array_handler = PyCudaArrayHandler() - else: - array_handler = self.data_handling.array_handler - for obj, cpu_arr in cpu_version.items(): if obj not in gpu_version or gpu_version[obj].shape != cpu_arr.shape: gpu_version[obj] = array_handler.to_gpu(cpu_arr) diff --git a/pystencils/datahandling/serial_datahandling.py b/pystencils/datahandling/serial_datahandling.py index a9fca34e370d5918e1e80b7387d76e79570e3472..d4af43f189333a260b9a266b83c21335cd4a1c44 100644 --- a/pystencils/datahandling/serial_datahandling.py +++ b/pystencils/datahandling/serial_datahandling.py @@ -226,7 +226,7 @@ class SerialDataHandling(DataHandling): def swap(self, name1, name2, gpu=None): if gpu is None: - gpu = self.default_target == "gpu" + gpu = self.default_target in self._GPU_LIKE_TARGETS arr = self.gpu_arrays if gpu else self.cpu_arrays arr[name1], arr[name2] = arr[name2], arr[name1] diff --git a/pystencils/gpucuda/periodicity.py b/pystencils/gpucuda/periodicity.py index 8bb0109bef388eb1fbf5cecab643307dadf5072b..a947d94a1ac24c922a8e9d19211b69b6cbd83004 100644 --- a/pystencils/gpucuda/periodicity.py +++ b/pystencils/gpucuda/periodicity.py @@ -35,13 +35,14 @@ def get_periodic_boundary_functor(stencil, domain_size, index_dimensions=0, inde assert target in ['gpu', 'opencl'] src_dst_slice_tuples = get_periodic_boundary_src_dst_slices(stencil, ghost_layers, thickness) kernels = [] - index_dimensions = index_dimensions for src_slice, dst_slice in src_dst_slice_tuples: ast = create_copy_kernel(domain_size, src_slice, dst_slice, index_dimensions, index_dim_shape, dtype) if target == 'gpu': kernels.append(pystencils.gpucuda.make_python_function(ast)) else: + ast._target = 'opencl' + ast._backend = 'opencl' kernels.append(pystencils.opencl.make_python_function(ast, opencl_queue, opencl_ctx)) def functor(pdfs, **_):