Commit 21fcd7fc authored by Martin Bauer's avatar Martin Bauer
Browse files

waLBerla codegeneration improved

- removed warnings from generated code
- made generated code string deterministic, generating the same twice
  gives binary equally files now
parent c4853e5e
...@@ -10,6 +10,8 @@ from pystencils.data_types import create_type, StructType ...@@ -10,6 +10,8 @@ from pystencils.data_types import create_type, StructType
from pystencils.kernelparameters import FieldShapeSymbol, FieldStrideSymbol from pystencils.kernelparameters import FieldShapeSymbol, FieldStrideSymbol
from pystencils.stencils import offset_to_direction_string, direction_string_to_offset from pystencils.stencils import offset_to_direction_string, direction_string_to_offset
from pystencils.sympyextensions import is_integer_sequence from pystencils.sympyextensions import is_integer_sequence
import pickle
import hashlib
__all__ = ['Field', 'fields', 'FieldType'] __all__ = ['Field', 'fields', 'FieldType']
...@@ -437,7 +439,7 @@ class Field: ...@@ -437,7 +439,7 @@ class Field:
if i >= bound: if i >= bound:
raise ValueError("Field index out of bounds") raise ValueError("Field index out of bounds")
else: else:
offset_name = "%0.10X" % (abs(hash(tuple(offsets_and_index)))) offset_name = hashlib.md5(pickle.dumps(offsets_and_index)).hexdigest()[:12]
superscript = None superscript = None
symbol_name = "%s_%s" % (field_name, offset_name) symbol_name = "%s_%s" % (field_name, offset_name)
......
...@@ -2,7 +2,8 @@ import warnings ...@@ -2,7 +2,8 @@ import warnings
from collections import defaultdict, OrderedDict, namedtuple from collections import defaultdict, OrderedDict, namedtuple
from copy import deepcopy from copy import deepcopy
from types import MappingProxyType from types import MappingProxyType
import pickle
import hashlib
import sympy as sp import sympy as sp
from sympy.logic.boolalg import Boolean from sympy.logic.boolalg import Boolean
from sympy.tensor import IndexedBase from sympy.tensor import IndexedBase
...@@ -179,7 +180,7 @@ def create_intermediate_base_pointer(field_access, coordinates, previous_ptr): ...@@ -179,7 +180,7 @@ def create_intermediate_base_pointer(field_access, coordinates, previous_ptr):
list_to_hash.append(coordinate_value) list_to_hash.append(coordinate_value)
if len(list_to_hash) > 0: 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') name = name.replace("-", 'm')
new_ptr = TypedSymbol(previous_ptr.name + name, previous_ptr.dtype) new_ptr = TypedSymbol(previous_ptr.name + name, previous_ptr.dtype)
......
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