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

Merge branch 'bugfix-textures' into 'master'

Bugfix: textures should be implemented as textures without changes

See merge request pycodegen/pystencils!73
parents b321d363 89ed566a
......@@ -12,12 +12,11 @@ import itertools
from enum import Enum
from typing import Set
import sympy as sp
from sympy.core.cache import cacheit
import pystencils
import sympy as sp
from pystencils.astnodes import Node
from pystencils.data_types import TypedSymbol, cast_func, create_type
from sympy.core.cache import cacheit
import pycuda.driver
......@@ -304,18 +303,19 @@ class TextureCachedField:
self.filter_mode = filter_mode
self.read_as_integer = read_as_integer
self.use_normalized_coordinates = use_normalized_coordinates
self.interpolation_mode = interpolation_mode
self.symbol = TypedSymbol(str(self), self.field.dtype.numpy_dtype)
self.symbol.interpolator = self
self.symbol.field = self.field
self.required_global_declarations = [TextureDeclaration(self)]
self.interpolation_mode = interpolation_mode
# assert str(self.field.dtype) != 'double', "CUDA does not support double textures!"
# assert dtype_supports_textures(self.field.dtype), "CUDA only supports texture types with 32 bits or less"
def from_interpolator(cls, interpolator: LinearInterpolator):
if hasattr(interpolator, 'allow_textures') and not interpolator.allow_textures:
if (isinstance(interpolator, cls)
or (hasattr(interpolator, 'allow_textures') and not interpolator.allow_textures)):
return interpolator
obj = cls(interpolator.field, interpolator.address_mode, interpolation_mode=interpolator.interpolation_mode)
return obj
......@@ -327,11 +327,19 @@ class TextureCachedField:
return TextureAccess(self.symbol, *offset)
def __str__(self):
return '%s_texture_%x' % (, abs(hash(self.field) + hash(str(self.address_mode))))
return '%s_texture_%x' % (, abs(hash(self)))
def __repr__(self):
return self.__str__()
def __hash__(self):
return hash((str(type(self)),
class TextureAccess(InterpolatorAccess):
def __new__(cls, texture_symbol, offsets, *args, **kwargs):
Supports Markdown
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