From efcc9a20fe4d47a93b1c394a49ec1467fa7b11f3 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 29 Jan 2018 12:20:00 -0500 Subject: [PATCH 1/2] change AtomicInit to OrderedAtomic to fix stringification --- loopy/kernel/instruction.py | 40 +++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/loopy/kernel/instruction.py b/loopy/kernel/instruction.py index 464bfc926..8682ccf6e 100644 --- a/loopy/kernel/instruction.py +++ b/loopy/kernel/instruction.py @@ -607,26 +607,6 @@ class VarAtomicity(object): return not self.__eq__(other) -class AtomicInit(VarAtomicity): - """Describes initialization of an atomic variable. A subclass of - :class:`VarAtomicity`. - """ - - def update_persistent_hash(self, key_hash, key_builder): - """Custom hash computation function for use with - :class:`pytools.persistent_dict.PersistentDict`. - """ - - super(AtomicInit, self).update_persistent_hash(key_hash, key_builder) - key_builder.rec(key_hash, "AtomicInit") - - def __str__(self): - return "update[%s]%s/%s" % ( - self.var_name, - memory_ordering.to_string(self.ordering), - memory_scope.to_string(self.scope)) - - class OrderedAtomic(VarAtomicity): """Properties of an atomic operation. A subclass of :class:`VarAtomicity`. @@ -665,8 +645,24 @@ class OrderedAtomic(VarAtomicity): memory_scope.to_string(self.scope)) +class AtomicInit(OrderedAtomic): + """Describes initialization of an atomic variable. A subclass of + :class:`OrderedAtomic`. + + .. attribute:: ordering + + One of the values from :class:`memory_ordering` + + .. attribute:: scope + + One of the values from :class:`memory_scope` + """ + op_name = 'init' + + + class AtomicUpdate(OrderedAtomic): - """Properties of an atomic update. A subclass of :class:`VarAtomicity`. + """Properties of an atomic update. A subclass of :class:`OrderedAtomic`. .. attribute:: ordering @@ -680,7 +676,7 @@ class AtomicUpdate(OrderedAtomic): class AtomicLoad(OrderedAtomic): - """Properties of an atomic load. A subclass of :class:`VarAtomicity`. + """Properties of an atomic load. A subclass of :class:`OrderedAtomic`. .. attribute:: ordering -- GitLab From da269cd6aaecbb06cbd149a19c50df6b70f1e50a Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 29 Jan 2018 12:26:33 -0500 Subject: [PATCH 2/2] fix bug in stringification of atomicinit that crops up during printing --- loopy/kernel/instruction.py | 1 - test/test_loopy.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/loopy/kernel/instruction.py b/loopy/kernel/instruction.py index 8682ccf6e..9d95408ac 100644 --- a/loopy/kernel/instruction.py +++ b/loopy/kernel/instruction.py @@ -660,7 +660,6 @@ class AtomicInit(OrderedAtomic): op_name = 'init' - class AtomicUpdate(OrderedAtomic): """Properties of an atomic update. A subclass of :class:`OrderedAtomic`. diff --git a/test/test_loopy.py b/test/test_loopy.py index e33412001..8bb8f37f0 100644 --- a/test/test_loopy.py +++ b/test/test_loopy.py @@ -1129,7 +1129,7 @@ def test_atomic_init(dtype): ], silenced_warnings=["write_race(init)"]) knl = lp.split_iname(knl, 'i', vec_width, inner_tag='l.0') - + print(knl) print(lp.generate_code_v2(knl).device_code()) -- GitLab