Matthew Poremba has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/67073?usp=email )

Change subject: base: Specialize bitwise atomics so FP types can be used
......................................................................

base: Specialize bitwise atomics so FP types can be used

The current atomic memory operations are templated so any type can be
used. However floating point types can not perform bitwise operations.
The GPU model contains some instructions which do atomics on floating
point types, so they need to be supported. To allow this, template
specialization is added to atomic AND, OR, and XOR which does nothing
if the type is floating point and operates as normal for integral
types.

Change-Id: I60f935756355462e99c59a9da032c5bf5afa246c
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67073
Reviewed-by: Matt Sinclair <mattdsincl...@gmail.com>
Reviewed-by: Daniel Carvalho <oda...@yahoo.com.br>
Tested-by: kokoro <noreply+kok...@google.com>
Maintainer: Matt Sinclair <mattdsincl...@gmail.com>
---
M src/base/amo.hh
1 file changed, 52 insertions(+), 3 deletions(-)

Approvals:
  kokoro: Regressions pass
  Daniel Carvalho: Looks good to me, approved
  Matt Sinclair: Looks good to me, approved; Looks good to me, approved




diff --git a/src/base/amo.hh b/src/base/amo.hh
index 81bf069..c990d15 100644
--- a/src/base/amo.hh
+++ b/src/base/amo.hh
@@ -129,30 +129,57 @@
 template<typename T>
 class AtomicOpAnd : public TypedAtomicOpFunctor<T>
 {
+    // Bitwise operations are only legal on integral types
+    template<typename B>
+    typename std::enable_if<std::is_integral<B>::value, void>::type
+    executeImpl(B *b) { *b &= a; }
+
+    template<typename B>
+    typename std::enable_if<!std::is_integral<B>::value, void>::type
+    executeImpl(B *b) { }
+
   public:
     T a;
     AtomicOpAnd(T _a) : a(_a) { }
-    void execute(T *b) { *b &= a; }
+    void execute(T *b) { executeImpl<T>(b); }
     AtomicOpFunctor* clone () { return new AtomicOpAnd(a); }
 };

 template<typename T>
 class AtomicOpOr : public TypedAtomicOpFunctor<T>
 {
+    // Bitwise operations are only legal on integral types
+    template<typename B>
+    typename std::enable_if<std::is_integral<B>::value, void>::type
+    executeImpl(B *b) { *b |= a; }
+
+    template<typename B>
+    typename std::enable_if<!std::is_integral<B>::value, void>::type
+    executeImpl(B *b) { }
+
   public:
     T a;
     AtomicOpOr(T _a) : a(_a) { }
-    void execute(T *b) { *b |= a; }
+    void execute(T *b) { executeImpl<T>(b); }
     AtomicOpFunctor* clone () { return new AtomicOpOr(a); }
 };

 template<typename T>
 class AtomicOpXor : public TypedAtomicOpFunctor<T>
 {
+    // Bitwise operations are only legal on integral types
+    template<typename B>
+    typename std::enable_if<std::is_integral<B>::value, void>::type
+    executeImpl(B *b) { *b ^= a; }
+
+    template<typename B>
+    typename std::enable_if<!std::is_integral<B>::value, void>::type
+    executeImpl(B *b) { }
+
   public:
     T a;
     AtomicOpXor(T _a) : a(_a) {}
-    void execute(T *b) { *b ^= a; }
+    void execute(T *b) { executeImpl<T>(b); }
     AtomicOpFunctor* clone () { return new AtomicOpXor(a); }
 };


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/67073?usp=email To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I60f935756355462e99c59a9da032c5bf5afa246c
Gerrit-Change-Number: 67073
Gerrit-PatchSet: 3
Gerrit-Owner: Matthew Poremba <matthew.pore...@amd.com>
Gerrit-Reviewer: Bobby Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-Reviewer: Matt Sinclair <mattdsincl...@gmail.com>
Gerrit-Reviewer: Matthew Poremba <matthew.pore...@amd.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org

Reply via email to