RAJA
RAJA provides a collection of platform portability abstractions for C++ HPC applications.
BlockLiteral.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_BlockLiteral_HPP
21 #define RAJA_pattern_tensor_ET_BlockLiteral_HPP
22 
23 #include "RAJA/config.hpp"
24 
25 #include "RAJA/util/macros.hpp"
26 
29 
30 namespace RAJA
31 {
32 namespace internal
33 {
34 namespace expt
35 {
36 
37 
38 namespace ET
39 {
40 
41 
48 template<typename STORAGE_TYPE, typename TENSOR_TYPE>
50  : public TensorExpressionBase<BlockLiteral<STORAGE_TYPE, TENSOR_TYPE>>
51 {
52 public:
54  using storage_type = STORAGE_TYPE;
55  using tensor_type = TENSOR_TYPE;
56  using result_type = TENSOR_TYPE;
57  using ref_type = typename STORAGE_TYPE::ref_type;
58  using tile_type = typename ref_type::tile_type;
59  using index_type = camp::idx_t;
60 
61  static constexpr camp::idx_t s_num_dims = result_type::s_num_dims;
62 
63 
64 private:
65  storage_type m_storage;
66  tile_type m_tile_origin;
67 
68 public:
69  RAJA_INLINE
70 
72  constexpr index_type getDimSize(index_type dim) const
73  {
74  return storage_type::s_dim_elem(dim);
75  }
76 
77  RAJA_INLINE
78 
80  constexpr BlockLiteral(tile_type tile_origin)
81  : m_storage(),
82  m_tile_origin(tile_origin)
83  {}
84 
85  template<typename TILE_TYPE>
86  RAJA_INLINE RAJA_HOST_DEVICE result_type eval(TILE_TYPE const& tile) const
87  {
88  result_type result;
89 
90  // load result from storage
91  result.load_ref(merge_ref_tile(m_storage.get_ref(), tile - m_tile_origin));
92 
93  return result;
94  }
95 
99  RAJA_INLINE
100 
103  {
104 
105  // compute shifited origin ref
106  return shift_tile_origin(m_storage.get_ref(), m_tile_origin);
107  }
108 
109  RAJA_INLINE
110 
112  void print_ast() const { printf("BlockLiteral()"); }
113 };
114 
115 // /*
116 // * For TensorRegister nodes, we need to wrap this in a constant value ET
117 // node
118 // */
119 // template<typename RHS>
120 // struct NormalizeOperandHelper<RHS,
121 // typename
122 // std::enable_if<std::is_base_of<RAJA::internal::TensorRegisterConcreteBase,
123 // RHS>::value>::type>
124 // {
125 // using return_type = BlockLiteral<RHS>;
126 //
127 // RAJA_INLINE
128 // RAJA_HOST_DEVICE
129 // static
130 // constexpr
131 // return_type normalize(RHS const &rhs){
132 // return return_type(rhs);
133 // }
134 // };
135 
136 } // namespace ET
137 
138 } // namespace expt
139 } // namespace internal
140 
141 } // namespace RAJA
142 
143 
144 #endif
RAJA header file defining SIMD/SIMT register operations.
RAJA header file defining SIMD/SIMT register operations.
Definition: BlockLiteral.hpp:51
RAJA_INLINE RAJA_HOST_DEVICE void print_ast() const
Definition: BlockLiteral.hpp:112
TENSOR_TYPE tensor_type
Definition: BlockLiteral.hpp:55
static constexpr camp::idx_t s_num_dims
Definition: BlockLiteral.hpp:61
RAJA_INLINE constexpr RAJA_HOST_DEVICE index_type getDimSize(index_type dim) const
Definition: BlockLiteral.hpp:72
camp::idx_t index_type
Definition: BlockLiteral.hpp:59
typename STORAGE_TYPE::ref_type ref_type
Definition: BlockLiteral.hpp:57
typename ref_type::tile_type tile_type
Definition: BlockLiteral.hpp:58
RAJA_INLINE RAJA_HOST_DEVICE result_type eval(TILE_TYPE const &tile) const
Definition: BlockLiteral.hpp:86
RAJA_INLINE RAJA_HOST_DEVICE ref_type get_ref()
Definition: BlockLiteral.hpp:102
STORAGE_TYPE storage_type
Definition: BlockLiteral.hpp:54
TENSOR_TYPE result_type
Definition: BlockLiteral.hpp:56
RAJA_INLINE constexpr RAJA_HOST_DEVICE BlockLiteral(tile_type tile_origin)
Definition: BlockLiteral.hpp:80
Definition: ExpressionTemplateBase.hpp:72
Header file for common RAJA internal macro definitions.
#define RAJA_HOST_DEVICE
Definition: macros.hpp:65
RAJA_INLINE constexpr RAJA_HOST_DEVICE auto shift_tile_origin(REF_TYPE const &ref, TILE_TYPE const &tile_origin) -> typename MergeRefTile< REF_TYPE, TILE_TYPE, camp::make_idx_seq_t< TILE_TYPE::s_num_dims >>::shift_type
Definition: TensorRef.hpp:700
RAJA_INLINE constexpr RAJA_HOST_DEVICE auto merge_ref_tile(REF_TYPE const &ref, TILE_TYPE const &tile) -> typename MergeRefTile< REF_TYPE, TILE_TYPE, camp::make_idx_seq_t< TILE_TYPE::s_num_dims >>::merge_type
Definition: TensorRef.hpp:682
Definition: AlignedRangeIndexSetBuilders.cpp:35
RAJA_HOST_DEVICE RAJA_INLINE void tile(CONTEXT const &ctx, TILE_T tile_size, SEGMENT const &segment, BODY const &body)
Definition: launch_core.hpp:589