Skip to content
Snippets Groups Projects
Commit fc81c5ae authored by Martin Bauer's avatar Martin Bauer
Browse files

Merge branch 'sync' into 'master'

SerialDataHandling: synchronization_function for tensor fields

See merge request pycodegen/pystencils!122
parents 91cae896 47dbf5d3
No related branches found
No related tags found
No related merge requests found
...@@ -307,8 +307,6 @@ class SerialDataHandling(DataHandling): ...@@ -307,8 +307,6 @@ class SerialDataHandling(DataHandling):
values_per_cell = (1, ) values_per_cell = (1, )
if len(values_per_cell) == 1: if len(values_per_cell) == 1:
values_per_cell = values_per_cell[0] values_per_cell = values_per_cell[0]
else:
raise NotImplementedError("Synchronization of this field is not supported: " + name)
if len(filtered_stencil) > 0: if len(filtered_stencil) > 0:
if target == 'cpu': if target == 'cpu':
......
import numpy as np import numpy as np
from itertools import product
import pystencils.gpucuda import pystencils.gpucuda
import pystencils.opencl import pystencils.opencl
...@@ -9,8 +10,6 @@ from pystencils.slicing import get_periodic_boundary_src_dst_slices, normalize_s ...@@ -9,8 +10,6 @@ from pystencils.slicing import get_periodic_boundary_src_dst_slices, normalize_s
def create_copy_kernel(domain_size, from_slice, to_slice, index_dimensions=0, index_dim_shape=1, dtype=np.float64): def create_copy_kernel(domain_size, from_slice, to_slice, index_dimensions=0, index_dim_shape=1, dtype=np.float64):
"""Copies a rectangular part of an array to another non-overlapping part""" """Copies a rectangular part of an array to another non-overlapping part"""
if index_dimensions not in (0, 1):
raise NotImplementedError("Works only for one or zero index coordinates")
f = Field.create_generic("pdfs", len(domain_size), index_dimensions=index_dimensions, dtype=dtype) f = Field.create_generic("pdfs", len(domain_size), index_dimensions=index_dimensions, dtype=dtype)
normalized_from_slice = normalize_slice(from_slice, f.spatial_shape) normalized_from_slice = normalize_slice(from_slice, f.spatial_shape)
...@@ -21,8 +20,10 @@ def create_copy_kernel(domain_size, from_slice, to_slice, index_dimensions=0, in ...@@ -21,8 +20,10 @@ def create_copy_kernel(domain_size, from_slice, to_slice, index_dimensions=0, in
"Slices have to have same size" "Slices have to have same size"
update_eqs = [] update_eqs = []
for i in range(index_dim_shape): if index_dimensions < 2:
eq = Assignment(f(i), f[tuple(offset)](i)) index_dim_shape = [index_dim_shape]
for i in product(*[range(d) for d in index_dim_shape]):
eq = Assignment(f(*i), f[tuple(offset)](*i))
update_eqs.append(eq) update_eqs.append(eq)
ast = create_cuda_kernel(update_eqs, iteration_slice=to_slice, skip_independence_check=True) ast = create_cuda_kernel(update_eqs, iteration_slice=to_slice, skip_independence_check=True)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment