RAJA
RAJA provides a collection of platform portability abstractions for C++ HPC applications.
TensorRegister.hpp
Go to the documentation of this file.
1 
11 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
12 // Copyright (c) Lawrence Livermore National Security, LLC and other
13 // RAJA Project Developers. See top-level LICENSE and COPYRIGHT
14 // files for dates and other details. No copyright assignment is required
15 // to contribute to RAJA.
16 //
17 // SPDX-License-Identifier: (BSD-3-Clause)
18 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
19 
20 #ifndef RAJA_pattern_tensor_TensorRegister_HPP
21 #define RAJA_pattern_tensor_TensorRegister_HPP
22 
23 #include "RAJA/config.hpp"
24 
25 #include "RAJA/util/macros.hpp"
26 
27 #include "camp/camp.hpp"
30 
31 namespace RAJA
32 {
33 namespace internal
34 {
35 namespace expt
36 {
37 class TensorRegisterConcreteBase;
38 }
39 } // namespace internal
40 
41 namespace expt
42 {
43 
44 
45 template<typename REGISTER_POLICY, typename T, typename LAYOUT, typename SIZES>
47 
48 /*
49  * Overload for: arithmetic + TensorRegister
50 
51  */
52 template<
53  typename LEFT,
54  typename RIGHT,
55  typename std::enable_if<std::is_arithmetic<LEFT>::value, bool>::type = true,
56  typename std::enable_if<
58  RIGHT>::value,
59  bool>::type = true>
60 RAJA_INLINE RAJA_HOST_DEVICE RIGHT operator+(LEFT const& lhs, RIGHT const& rhs)
61 {
62  return RIGHT(lhs).add(rhs);
63 }
64 
65 /*
66  * Overload for: arithmetic - TensorRegister
67 
68  */
69 template<
70  typename LEFT,
71  typename RIGHT,
72  typename std::enable_if<std::is_arithmetic<LEFT>::value, bool>::type = true,
73  typename std::enable_if<
75  RIGHT>::value,
76  bool>::type = true>
77 RAJA_INLINE RAJA_HOST_DEVICE RIGHT operator-(LEFT const& lhs, RIGHT const& rhs)
78 {
79  return RIGHT(lhs).subtract(rhs);
80 }
81 
82 /*
83  * Overload for: arithmetic * TensorRegister
84 
85  */
86 template<
87  typename LEFT,
88  typename RIGHT,
89  typename std::enable_if<std::is_arithmetic<LEFT>::value, bool>::type = true,
90  typename std::enable_if<
92  RIGHT>::value,
93  bool>::type = true>
94 RAJA_INLINE RAJA_HOST_DEVICE RIGHT operator*(LEFT const& lhs, RIGHT const& rhs)
95 {
96  return rhs.scale(lhs);
97 }
98 
99 /*
100  * Overload for: arithmetic / TensorRegister
101 
102  */
103 template<
104  typename LEFT,
105  typename RIGHT,
106  typename std::enable_if<std::is_arithmetic<LEFT>::value, bool>::type = true,
107  typename std::enable_if<
109  RIGHT>::value,
110  bool>::type = true>
111 RAJA_INLINE RAJA_HOST_DEVICE RIGHT operator/(LEFT const& lhs, RIGHT const& rhs)
112 {
113  return RIGHT(lhs).divide(rhs);
114 }
115 
116 } // namespace expt
117 } // namespace RAJA
118 
120 
121 // Bring in the register policy file so we get the default register type
122 // and all of the register traits setup
124 
125 
126 #endif
RAJA header file defining SIMD/SIMT register operations.
RAJA header file defining SIMD/SIMT register operations.
RAJA header file defining SIMD/SIMT register operations.
Header file containing RAJA simd policy definitions.
Definition: TensorRegister.hpp:46
Definition: TensorRegisterBase.hpp:96
Header file for common RAJA internal macro definitions.
#define RAJA_HOST_DEVICE
Definition: macros.hpp:65
RAJA_INLINE RAJA_HOST_DEVICE RIGHT operator+(LEFT const &lhs, RIGHT const &rhs)
Definition: TensorRegister.hpp:60
RAJA_INLINE RAJA_HOST_DEVICE RIGHT operator-(LEFT const &lhs, RIGHT const &rhs)
Definition: TensorRegister.hpp:77
RAJA_INLINE RAJA_HOST_DEVICE RIGHT operator/(LEFT const &lhs, RIGHT const &rhs)
Definition: TensorRegister.hpp:111
RAJA_INLINE RAJA_HOST_DEVICE RIGHT operator*(LEFT const &lhs, RIGHT const &rhs)
Definition: TensorRegister.hpp:94
Definition: AlignedRangeIndexSetBuilders.cpp:35