diff --git a/loopy/kernel/function_interface.py b/loopy/kernel/function_interface.py index cbc0e641b58dc3269964ba77d29b8fb3412dfc1d..2ea260656b8d89031849d43364977404e1ca6690 100644 --- a/loopy/kernel/function_interface.py +++ b/loopy/kernel/function_interface.py @@ -45,7 +45,6 @@ class ValueArgDescriptor(ImmutableRecord): hash_fields = () update_persistent_hash = LoopKernel.update_persistent_hash - pass class ArrayArgDescriptor(ImmutableRecord): @@ -90,6 +89,13 @@ class ArrayArgDescriptor(ImmutableRecord): address_space=address_space, dim_tags=dim_tags) + hash_fields = ( + "shape", + "address_space", + "dim_tags") + + update_persistent_hash = LoopKernel.update_persistent_hash + # }}} diff --git a/loopy/library/reduction.py b/loopy/library/reduction.py index 383337b2f25523626e9ef79a51c6c272f4880994..6ec8e4b219d93e717ebdc4a1965531c28171c84f 100644 --- a/loopy/library/reduction.py +++ b/loopy/library/reduction.py @@ -31,6 +31,7 @@ import numpy as np from loopy.symbolic import FunctionIdentifier from loopy.diagnostic import LoopyError from loopy.types import NumpyType +from loopy.kernel import LoopKernel class ReductionOperation(object): @@ -223,6 +224,11 @@ class ReductionOpFunction(FunctionIdentifier): return type(self)(reduction_op) + hash_fields = ( + "reduction_op",) + + update_persistent_hash = LoopKernel.update_persistent_hash + # }}} @@ -276,12 +282,25 @@ class SegmentedSumReductionOperation(_SegmentedScalarReductionOperation): which = "sum" op = "((%s) + (%s))" + hash_fields = ( + "which", + "op",) + + update_persistent_hash = LoopKernel.update_persistent_hash + class SegmentedProductReductionOperation(_SegmentedScalarReductionOperation): base_reduction_class = ProductReductionOperation op = "((%s) * (%s))" which = "product" + hash_fields = ( + "which", + "op", + "base_reduction_class",) + + update_persistent_hash = LoopKernel.update_persistent_hash + # }}} @@ -332,12 +351,24 @@ class ArgMaxReductionOperation(_ArgExtremumReductionOperation): update_comparison = ">=" neutral_sign = -1 + hash_fields = ("which", + "update_comparison", + "neutral_sign",) + + update_persistent_hash = LoopKernel.update_persistent_hash + class ArgMinReductionOperation(_ArgExtremumReductionOperation): which = "min" update_comparison = "<=" neutral_sign = +1 + hash_fields = ("which", + "update_comparison", + "neutral_sign",) + + update_persistent_hash = LoopKernel.update_persistent_hash + # }}} diff --git a/loopy/tools.py b/loopy/tools.py index 8c5d36390d75123ca433a30947ac2631d734f779..b243a79492dacc17f70e5afc7626c17a6ee03774 100644 --- a/loopy/tools.py +++ b/loopy/tools.py @@ -73,7 +73,8 @@ class LoopyKeyBuilder(KeyBuilderBase): def update_for_dict(self, key_hash, key): # Order matters for the hash--insert in sorted order. - for dict_key in sorted(six.iterkeys(key)): + for dict_key in sorted(six.iterkeys(key), key=lambda obj: + type(obj).__name__ + str(obj)): self.rec(key_hash, (dict_key, key[dict_key])) update_for_defaultdict = update_for_dict