RAJA
RAJA provides a collection of platform portability abstractions for C++ HPC applications.
TensorLayout.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_TensorLayout_HPP
21 #define RAJA_pattern_tensor_TensorLayout_HPP
22 
23 #include "RAJA/config.hpp"
24 #include "RAJA/util/macros.hpp"
25 #include "camp/camp.hpp"
26 
27 namespace RAJA
28 {
29 namespace expt
30 {
31 
32 
33 template<camp::idx_t... DIM_SEQ>
34 struct TensorLayout : public camp::idx_seq<DIM_SEQ...>
35 {
36 
37  using seq_t = camp::idx_seq<DIM_SEQ...>;
38 
39  RAJA_INLINE
40 
42  static constexpr bool is_column_major() { return false; }
43 
44  RAJA_INLINE
45 
47  static constexpr bool is_row_major() { return false; }
48 };
49 
50 // specialization for Matrix layouts, where column vs row major matters
51 template<camp::idx_t S2, camp::idx_t S1>
52 struct TensorLayout<S2, S1> : public camp::idx_seq<S2, S1>
53 {
54  using seq_t = camp::idx_seq<S2, S1>;
55 
56  RAJA_INLINE
57 
59  static constexpr bool is_column_major()
60  {
61  return S1 == 0; // Rows are stride-1
62  }
63 
64  RAJA_INLINE
65 
67  static constexpr bool is_row_major()
68  {
69  return S1 == 1; // Columns are stride-1
70  }
71 };
72 
73 // 0d tensor (scalar) layout
75 
76 // 1d tensor (vector) layout
78 
79 // 2d tensor (matrix) layouts
82 
83 
84 } // namespace expt
85 } // namespace RAJA
86 
87 
88 #endif
Header file for common RAJA internal macro definitions.
#define RAJA_HOST_DEVICE
Definition: macros.hpp:65
Definition: AlignedRangeIndexSetBuilders.cpp:35
RAJA_INLINE static constexpr RAJA_HOST_DEVICE bool is_row_major()
Definition: TensorLayout.hpp:67
RAJA_INLINE static constexpr RAJA_HOST_DEVICE bool is_column_major()
Definition: TensorLayout.hpp:59
camp::idx_seq< S2, S1 > seq_t
Definition: TensorLayout.hpp:54
Definition: TensorLayout.hpp:35
RAJA_INLINE static constexpr RAJA_HOST_DEVICE bool is_row_major()
Definition: TensorLayout.hpp:47
camp::idx_seq< DIM_SEQ... > seq_t
Definition: TensorLayout.hpp:37
RAJA_INLINE static constexpr RAJA_HOST_DEVICE bool is_column_major()
Definition: TensorLayout.hpp:42