diff options
author | Giacomo Travaglini <giacomo.travaglini@arm.com> | 2019-12-05 12:06:17 +0000 |
---|---|---|
committer | Giacomo Travaglini <giacomo.travaglini@arm.com> | 2020-01-09 09:50:02 +0000 |
commit | 2d2d579c4ad7f6b1b5aeae2605b0632fb4b05ad7 (patch) | |
tree | 8f581d82abc11e5a1b7f5a1abedecc247a5d6ddd /src | |
parent | 0f890f0653fc06e2e3d42caad78bdb91e3e39592 (diff) | |
download | gem5-2d2d579c4ad7f6b1b5aeae2605b0632fb4b05ad7.tar.xz |
base, gpu-compute: Move gpu AMOs into the generic header
Change-Id: I10d8aeaae83c232141ddd2fd21ee43bed8712539
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/23565
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Reviewed-by: Anthony Gutierrez <anthony.gutierrez@amd.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Anthony Gutierrez <anthony.gutierrez@amd.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/base/amo.hh | 114 | ||||
-rw-r--r-- | src/gpu-compute/gpu_dyn_inst.hh | 112 |
2 files changed, 115 insertions, 111 deletions
diff --git a/src/base/amo.hh b/src/base/amo.hh index 624c755ed..ec0598199 100644 --- a/src/base/amo.hh +++ b/src/base/amo.hh @@ -1,4 +1,7 @@ /* + * Copyright (c) 2015-2017 Advanced Micro Devices, Inc. + * All rights reserved. + * * Copyright (c) 2003-2005 The Regents of The University of Michigan * All rights reserved. * @@ -26,6 +29,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Authors: Nathan Binkert + * Anthony Gutierrez */ #ifndef __BASE_AMO_HH__ @@ -109,6 +113,116 @@ class AtomicGenericPair3Op : public TypedAtomicOpFunctor<T> std::function<void(T*, std::array<T, 2>&, std::array<T, 2>)> op; }; +template<typename T> +class AtomicOpAnd : public TypedAtomicOpFunctor<T> +{ + public: + T a; + AtomicOpAnd(T _a) : a(_a) { } + void execute(T *b) { *b &= a; } + AtomicOpFunctor* clone () { return new AtomicOpAnd(a); } +}; + +template<typename T> +class AtomicOpOr : public TypedAtomicOpFunctor<T> +{ + public: + T a; + AtomicOpOr(T _a) : a(_a) { } + void execute(T *b) { *b |= a; } + AtomicOpFunctor* clone () { return new AtomicOpOr(a); } +}; + +template<typename T> +class AtomicOpXor : public TypedAtomicOpFunctor<T> +{ + public: + T a; + AtomicOpXor(T _a) : a(_a) {} + void execute(T *b) { *b ^= a; } + AtomicOpFunctor* clone () { return new AtomicOpXor(a); } +}; + +template<typename T> +class AtomicOpExch : public TypedAtomicOpFunctor<T> +{ + public: + T a; + AtomicOpExch(T _a) : a(_a) { } + void execute(T *b) { *b = a; } + AtomicOpFunctor* clone () { return new AtomicOpExch(a); } +}; + +template<typename T> +class AtomicOpAdd : public TypedAtomicOpFunctor<T> +{ + public: + T a; + AtomicOpAdd(T _a) : a(_a) { } + void execute(T *b) { *b += a; } + AtomicOpFunctor* clone () { return new AtomicOpAdd(a); } +}; + +template<typename T> +class AtomicOpSub : public TypedAtomicOpFunctor<T> +{ + public: + T a; + AtomicOpSub(T _a) : a(_a) { } + void execute(T *b) { *b -= a; } + AtomicOpFunctor* clone () { return new AtomicOpSub(a); } +}; + +template<typename T> +class AtomicOpInc : public TypedAtomicOpFunctor<T> +{ + public: + AtomicOpInc() { } + void execute(T *b) { *b += 1; } + AtomicOpFunctor* clone () { return new AtomicOpInc(); } +}; + +template<typename T> +class AtomicOpDec : public TypedAtomicOpFunctor<T> +{ + public: + AtomicOpDec() {} + void execute(T *b) { *b -= 1; } + AtomicOpFunctor* clone () { return new AtomicOpDec(); } +}; + +template<typename T> +class AtomicOpMax : public TypedAtomicOpFunctor<T> +{ + public: + T a; + AtomicOpMax(T _a) : a(_a) { } + + void + execute(T *b) + { + if (a > *b) + *b = a; + } + AtomicOpFunctor* clone () { return new AtomicOpMax(a); } +}; + +template<typename T> +class AtomicOpMin : public TypedAtomicOpFunctor<T> +{ + public: + T a; + AtomicOpMin(T _a) : a(_a) {} + + void + execute(T *b) + { + if (a < *b) + *b = a; + } + AtomicOpFunctor* clone () { return new AtomicOpMin(a); } +}; + typedef std::unique_ptr<AtomicOpFunctor> AtomicOpFunctorPtr; #endif // __BASE_AMO_HH__ diff --git a/src/gpu-compute/gpu_dyn_inst.hh b/src/gpu-compute/gpu_dyn_inst.hh index 9e63c4459..1f7bb65ca 100644 --- a/src/gpu-compute/gpu_dyn_inst.hh +++ b/src/gpu-compute/gpu_dyn_inst.hh @@ -39,6 +39,7 @@ #include <cstdint> #include <string> +#include "base/amo.hh" #include "base/logging.hh" #include "enums/MemType.hh" #include "enums/StorageClassType.hh" @@ -48,37 +49,6 @@ class GPUStaticInst; template<typename T> -class AtomicOpAnd : public TypedAtomicOpFunctor<T> -{ - public: - T a; - - AtomicOpAnd(T _a) : a(_a) { } - void execute(T *b) { *b &= a; } - AtomicOpFunctor* clone () { return new AtomicOpAnd(a); } -}; - -template<typename T> -class AtomicOpOr : public TypedAtomicOpFunctor<T> -{ - public: - T a; - AtomicOpOr(T _a) : a(_a) { } - void execute(T *b) { *b |= a; } - AtomicOpFunctor* clone () { return new AtomicOpOr(a); } -}; - -template<typename T> -class AtomicOpXor : public TypedAtomicOpFunctor<T> -{ - public: - T a; - AtomicOpXor(T _a) : a(_a) {} - void execute(T *b) { *b ^= a; } - AtomicOpFunctor* clone () { return new AtomicOpXor(a); } -}; - -template<typename T> class AtomicOpCAS : public TypedAtomicOpFunctor<T> { public: @@ -108,86 +78,6 @@ class AtomicOpCAS : public TypedAtomicOpFunctor<T> AtomicOpFunctor* clone () { return new AtomicOpCAS(c, s, computeUnit); } }; -template<typename T> -class AtomicOpExch : public TypedAtomicOpFunctor<T> -{ - public: - T a; - AtomicOpExch(T _a) : a(_a) { } - void execute(T *b) { *b = a; } - AtomicOpFunctor* clone () { return new AtomicOpExch(a); } -}; - -template<typename T> -class AtomicOpAdd : public TypedAtomicOpFunctor<T> -{ - public: - T a; - AtomicOpAdd(T _a) : a(_a) { } - void execute(T *b) { *b += a; } - AtomicOpFunctor* clone () { return new AtomicOpAdd(a); } -}; - -template<typename T> -class AtomicOpSub : public TypedAtomicOpFunctor<T> -{ - public: - T a; - AtomicOpSub(T _a) : a(_a) { } - void execute(T *b) { *b -= a; } - AtomicOpFunctor* clone () { return new AtomicOpSub(a); } -}; - -template<typename T> -class AtomicOpInc : public TypedAtomicOpFunctor<T> -{ - public: - AtomicOpInc() { } - void execute(T *b) { *b += 1; } - AtomicOpFunctor* clone () { return new AtomicOpInc(); } -}; - -template<typename T> -class AtomicOpDec : public TypedAtomicOpFunctor<T> -{ - public: - AtomicOpDec() {} - void execute(T *b) { *b -= 1; } - AtomicOpFunctor* clone () { return new AtomicOpDec(); } -}; - -template<typename T> -class AtomicOpMax : public TypedAtomicOpFunctor<T> -{ - public: - T a; - AtomicOpMax(T _a) : a(_a) { } - - void - execute(T *b) - { - if (a > *b) - *b = a; - } - AtomicOpFunctor* clone () { return new AtomicOpMax(a); } -}; - -template<typename T> -class AtomicOpMin : public TypedAtomicOpFunctor<T> -{ - public: - T a; - AtomicOpMin(T _a) : a(_a) {} - - void - execute(T *b) - { - if (a < *b) - *b = a; - } - AtomicOpFunctor* clone () { return new AtomicOpMin(a); } -}; - typedef enum { VT_32, |