Commit 92231944 authored by Martin Bauer's avatar Martin Bauer
Browse files

Merge branch 'bugfix-fields_accessed-for-InterpolatorAccess' into 'master'

Bugfix fields accessed for interpolator access

See merge request pycodegen/pystencils!62
parents 89f158d0 32d636c4
......@@ -211,17 +211,18 @@ class KernelFunction(Node):
return self._body,
def fields_accessed(self) -> Set['ResolvedFieldAccess']:
def fields_accessed(self) -> Set[Field]:
"""Set of Field instances: fields which are accessed inside this kernel function"""
return set(o.field for o in self.atoms(ResolvedFieldAccess))
from pystencils.interpolation_astnodes import InterpolatorAccess
return set(o.field for o in itertools.chain(self.atoms(ResolvedFieldAccess), self.atoms(InterpolatorAccess)))
def fields_written(self) -> Set['ResolvedFieldAccess']:
def fields_written(self) -> Set[Field]:
assignments = self.atoms(SympyAssignment)
return {a.lhs.field for a in assignments if isinstance(a.lhs, ResolvedFieldAccess)}
def fields_read(self) -> Set['ResolvedFieldAccess']:
def fields_read(self) -> Set[Field]:
assignments = self.atoms(SympyAssignment)
return set().union(itertools.chain.from_iterable([f.field for f in a.rhs.free_symbols if hasattr(f, 'field')]
for a in assignments))
......@@ -7,9 +7,11 @@
import itertools
from os.path import dirname, join
import numpy as np
import pytest
import sympy
import pycuda.autoinit # NOQA
......@@ -215,10 +217,11 @@ def test_rotate_interpolation_size_change():
pyconrad.imshow(out, "small out " + address_mode)
def test_field_interpolated():
@pytest.mark.parametrize('address_mode, target',
itertools.product(['border', 'wrap', 'clamp', 'mirror'], ['cpu', 'gpu']))
def test_field_interpolated(address_mode, target):
x_f, y_f = pystencils.fields('x,y: float64 [2d]')
for address_mode in ['border', 'wrap', 'clamp', 'mirror']:
assignments = pystencils.AssignmentCollection({ x_f.interpolated_access([0.5 * x_ + 2.7, 0.25 * y_ + 7.2], address_mode=address_mode)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment