RAJA
RAJA provides a collection of platform portability abstractions for C++ HPC applications.
ExpressionTemplateBase.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_ET_ExpressionTemplateBase_HPP
21 #define RAJA_pattern_tensor_ET_ExpressionTemplateBase_HPP
22 
23 #include "RAJA/config.hpp"
24 
25 #include "RAJA/util/macros.hpp"
26 
28 
31 
32 namespace RAJA
33 {
34 namespace internal
35 {
36 namespace expt
37 {
38 
39 
40 class TensorRegisterConcreteBase;
41 
42 namespace ET
43 {
44 
45 //
46 // forward decls
47 //
48 
49 template<typename TENSOR_REGISTER_TYPE, typename REF_TYPE>
50 class TensorLoadStore;
51 
52 
53 template<typename LHS_TYPE, typename RHS_TYPE>
54 class TensorMultiply;
55 
56 template<typename LHS_TYPE, typename RHS_TYPE>
57 class TensorDivide;
58 
59 template<typename TENSOR_TYPE>
60 class TensorNegate;
61 
62 template<typename TENSOR_TYPE>
63 class TensorTranspose;
64 
65 // provides a non-templated base-type for all ET's
66 // this allows using things like std::is_base_of
68 {};
69 
70 template<typename DERIVED_TYPE>
72 {
73 public:
74  using self_type = DERIVED_TYPE;
75 
76 private:
77  RAJA_INLINE
78 
80  self_type* getThis() { return static_cast<self_type*>(this); }
81 
82  RAJA_INLINE
83 
85  constexpr self_type const* getThis() const
86  {
87  return static_cast<self_type const*>(this);
88  }
89 
90 public:
91  RAJA_INLINE
92 
94  constexpr camp::idx_t getDimBegin(camp::idx_t) const { return 0; }
95 
97  template<typename RHS>
99  operator+(RHS const& rhs) const
100  {
102  *getThis(), normalizeOperand(rhs));
103  }
104 
106  template<typename RHS>
107  RAJA_INLINE RAJA_HOST_DEVICE
109  operator-(RHS const& rhs) const
110  {
112  *getThis(), normalizeOperand(rhs));
113  }
114 
116  RAJA_INLINE
117 
120  {
121  return TensorNegate<self_type>(*getThis());
122  }
123 
125  template<typename RHS>
126  RAJA_INLINE RAJA_HOST_DEVICE
128  operator*(RHS const& rhs) const
129  {
131  *getThis(), normalizeOperand(rhs));
132  }
133 
135  template<typename RHS>
137  operator/(RHS const& rhs) const
138  {
140  *getThis(), normalizeOperand(rhs));
141  }
142 
144  RAJA_INLINE
145 
148  {
149  return TensorTranspose<self_type>(*getThis());
150  }
151 };
152 
153 
154 } // namespace ET
155 
156 } // namespace expt
157 } // namespace internal
158 
159 } // namespace RAJA
160 
161 
162 #endif
RAJA header defining expression template behavior for operator*.
RAJA header file defining SIMD/SIMT register operations.
Definition: BinaryOperator.hpp:46
Definition: TensorDivide.hpp:320
Definition: ExpressionTemplateBase.hpp:72
RAJA_SUPPRESS_HD_WARN RAJA_INLINE RAJA_HOST_DEVICE TensorMultiply< self_type, normalize_operand_t< RHS > > operator*(RHS const &rhs) const
Definition: ExpressionTemplateBase.hpp:128
DERIVED_TYPE self_type
Definition: ExpressionTemplateBase.hpp:74
RAJA_SUPPRESS_HD_WARN RAJA_INLINE RAJA_HOST_DEVICE TensorAdd< self_type, normalize_operand_t< RHS > > operator+(RHS const &rhs) const
Definition: ExpressionTemplateBase.hpp:99
RAJA_SUPPRESS_HD_WARN RAJA_INLINE RAJA_HOST_DEVICE TensorDivide< self_type, normalize_operand_t< RHS > > operator/(RHS const &rhs) const
Definition: ExpressionTemplateBase.hpp:137
RAJA_SUPPRESS_HD_WARN RAJA_INLINE RAJA_HOST_DEVICE TensorTranspose< self_type > transpose() const
Definition: ExpressionTemplateBase.hpp:147
RAJA_SUPPRESS_HD_WARN RAJA_INLINE RAJA_HOST_DEVICE TensorSubtract< self_type, normalize_operand_t< RHS > > operator-(RHS const &rhs) const
Definition: ExpressionTemplateBase.hpp:109
RAJA_SUPPRESS_HD_WARN RAJA_INLINE RAJA_HOST_DEVICE TensorNegate< self_type > operator-() const
Definition: ExpressionTemplateBase.hpp:119
RAJA_INLINE constexpr RAJA_HOST_DEVICE camp::idx_t getDimBegin(camp::idx_t) const
Definition: ExpressionTemplateBase.hpp:94
Definition: ExpressionTemplateBase.hpp:68
Definition: TensorMultiply.hpp:50
Definition: TensorNegate.hpp:42
Definition: TensorTranspose.hpp:42
Header file for common RAJA internal macro definitions.
#define RAJA_HOST_DEVICE
Definition: macros.hpp:65
#define RAJA_SUPPRESS_HD_WARN
Definition: macros.hpp:68
RAJA_INLINE RAJA_HOST_DEVICE auto normalizeOperand(RHS const &rhs) -> typename NormalizeOperandHelper< RHS >::return_type
Definition: normalizeOperand.hpp:73
Definition: AlignedRangeIndexSetBuilders.cpp:35
RAJA header file defining SIMD/SIMT register operations.