diff --git a/field.py b/field.py index 03bcb0fec5e8fe753062f9abb38df5d1ad62ab33..cce2b91ed3c543b90499de61cf75524528ae63e7 100644 --- a/field.py +++ b/field.py @@ -10,6 +10,8 @@ from pystencils.data_types import create_type, StructType from pystencils.kernelparameters import FieldShapeSymbol, FieldStrideSymbol from pystencils.stencils import offset_to_direction_string, direction_string_to_offset from pystencils.sympyextensions import is_integer_sequence +import pickle +import hashlib __all__ = ['Field', 'fields', 'FieldType'] @@ -437,7 +439,7 @@ class Field: if i >= bound: raise ValueError("Field index out of bounds") else: - offset_name = "%0.10X" % (abs(hash(tuple(offsets_and_index)))) + offset_name = hashlib.md5(pickle.dumps(offsets_and_index)).hexdigest()[:12] superscript = None symbol_name = "%s_%s" % (field_name, offset_name) diff --git a/transformations.py b/transformations.py index 2681585408892a2994e43e98bea4fc9b5ccab28a..f5d09bb3159b092336a1a35721802b3c0d0c398c 100644 --- a/transformations.py +++ b/transformations.py @@ -2,7 +2,8 @@ import warnings from collections import defaultdict, OrderedDict, namedtuple from copy import deepcopy from types import MappingProxyType - +import pickle +import hashlib import sympy as sp from sympy.logic.boolalg import Boolean from sympy.tensor import IndexedBase @@ -179,7 +180,7 @@ def create_intermediate_base_pointer(field_access, coordinates, previous_ptr): list_to_hash.append(coordinate_value) if len(list_to_hash) > 0: - name += "_%0.6X" % (hash(tuple(list_to_hash))) + name += hashlib.md5(pickle.dumps(list_to_hash)).hexdigest()[:16] name = name.replace("-", 'm') new_ptr = TypedSymbol(previous_ptr.name + name, previous_ptr.dtype)