diff --git a/devito/symbolics/printer.py b/devito/symbolics/printer.py index ffb91b7cf5..48f4d2d524 100644 --- a/devito/symbolics/printer.py +++ b/devito/symbolics/printer.py @@ -213,7 +213,8 @@ def _print_Abs(self, expr): # Unary function, single argument arg = expr.args[0] # AOMPCC errors with abs, always use fabs - if isinstance(self.compiler, AOMPCompiler): + if isinstance(self.compiler, AOMPCompiler) and not \ + np.issubdtype(self._prec(arg), np.integer): return "fabs(%s)" % self._print(arg) func = f'{self.func_prefix(arg, abs=True)}abs{self.func_literal(arg)}' return f"{self._ns}{func}({self._print(arg)})" diff --git a/devito/types/basic.py b/devito/types/basic.py index 8e131c7357..a1182cc313 100644 --- a/devito/types/basic.py +++ b/devito/types/basic.py @@ -14,8 +14,7 @@ from devito.data import default_allocator from devito.parameters import configuration from devito.tools import (Pickable, as_tuple, dtype_to_ctype, - frozendict, memoized_meth, sympy_mutex, CustomDtype, - Reconstructable) + frozendict, memoized_meth, sympy_mutex, CustomDtype) from devito.types.args import ArgProvider from devito.types.caching import Cached, Uncached from devito.types.lazy import Evaluable @@ -881,7 +880,6 @@ def __new__(cls, *args, **kwargs): name = kwargs.get('name') alias = kwargs.get('alias') function = kwargs.get('function') - dtype = kwargs.get('dtype') if alias is True or (function and function.name != name): function = kwargs['function'] = None @@ -889,8 +887,7 @@ def __new__(cls, *args, **kwargs): # definitely a reconstruction if function is not None and \ function.name == name and \ - function.indices == indices and \ - function.dtype == dtype: + function.indices == indices: # Special case: a syntactically identical alias of `function`, so # let's just return `function` itself return function @@ -1231,8 +1228,7 @@ def bound_symbols(self): @cached_property def indexed(self): """The wrapped IndexedData object.""" - return IndexedData(self.name, shape=self._shape, function=self.function, - dtype=self.dtype) + return IndexedData(self.name, shape=self._shape, function=self.function) @cached_property def dmap(self): @@ -1507,14 +1503,13 @@ class IndexedBase(sympy.IndexedBase, Basic, Pickable): __rargs__ = ('label', 'shape') __rkwargs__ = ('function',) - def __new__(cls, label, shape, function=None, dtype=None): + def __new__(cls, label, shape, function=None): # Make sure `label` is a devito.Symbol, not a sympy.Symbol if isinstance(label, str): label = Symbol(name=label, dtype=None) with sympy_mutex: obj = sympy.IndexedBase.__new__(cls, label, shape) obj.function = function - obj._dtype = dtype or function.dtype return obj func = Pickable._rebuild @@ -1548,7 +1543,7 @@ def indices(self): @property def dtype(self): - return self._dtype + return self.function.dtype @cached_property def free_symbols(self): @@ -1610,7 +1605,7 @@ def _C_ctype(self): return self.function._C_ctype -class Indexed(sympy.Indexed, Reconstructable): +class Indexed(sympy.Indexed): # The two type flags have changed in upstream sympy as of version 1.1, # but the below interpretation is used throughout the compiler to @@ -1622,17 +1617,6 @@ class Indexed(sympy.Indexed, Reconstructable): is_Dimension = False - __rargs__ = ('base', 'indices') - __rkwargs__ = ('dtype',) - - def __new__(cls, base, *indices, dtype=None, **kwargs): - if len(indices) == 1: - indices = as_tuple(indices[0]) - newobj = sympy.Indexed.__new__(cls, base, *indices) - newobj._dtype = dtype or base.dtype - - return newobj - @memoized_meth def __str__(self): return super().__str__() @@ -1654,7 +1638,7 @@ def function(self): @property def dtype(self): - return self._dtype + return self.function.dtype @property def name(self): diff --git a/devito/types/misc.py b/devito/types/misc.py index 38beeaee53..29514bb99a 100644 --- a/devito/types/misc.py +++ b/devito/types/misc.py @@ -83,7 +83,7 @@ class FIndexed(Indexed, Pickable): __rkwargs__ = ('strides_map', 'accessor') def __new__(cls, base, *args, strides_map=None, accessor=None): - obj = super().__new__(cls, base, args) + obj = super().__new__(cls, base, *args) obj.strides_map = frozendict(strides_map or {}) obj.accessor = accessor