RAJA
RAJA provides a collection of platform portability abstractions for C++ HPC applications.
OffsetOperators.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_OFFSETOPERATORS_HPP
21 #define RAJA_OFFSETOPERATORS_HPP
22 
23 #include "RAJA/config.hpp"
24 
25 #include "RAJA/util/concepts.hpp"
26 #include "RAJA/util/macros.hpp"
27 
28 namespace RAJA
29 {
30 
31 template<typename Ret, typename Arg1 = Ret, typename Arg2 = Arg1>
33 {
34  template<typename new_Ret,
35  typename new_Arg1 = new_Ret,
36  typename new_Arg2 = new_Ret>
38 
39  template<size_t>
41 
42  RAJA_INLINE RAJA_HOST_DEVICE constexpr Ret operator()(
43  Arg1 const& i,
44  Arg1 const& num_i,
45  Arg2 const& j,
46  Arg2 const& RAJA_UNUSED_ARG(num_j)) const noexcept
47  {
48  return i + j * num_i;
49  }
50 };
51 
52 template<typename Ret, typename Arg1 = Ret, typename Arg2 = Arg1>
54 {
55  template<typename new_Ret,
56  typename new_Arg1 = new_Ret,
57  typename new_Arg2 = new_Ret>
59 
60  template<size_t>
62 
63  RAJA_INLINE RAJA_HOST_DEVICE constexpr Ret operator()(
64  Arg1 const& i,
65  Arg1 const& RAJA_UNUSED_ARG(num_i),
66  Arg2 const& j,
67  Arg2 const& num_j) const noexcept
68  {
69  return i * num_j + j;
70  }
71 };
72 
73 template<size_t t_bunch_num_i,
74  typename Ret,
75  typename Arg1 = Ret,
76  typename Arg2 = Arg1>
78 {
79  template<typename new_Ret,
80  typename new_Arg1 = new_Ret,
81  typename new_Arg2 = new_Ret>
82  using rebind =
84 
85  template<size_t new_bunch_num_i>
87 
88  static constexpr Arg1 bunch_num_i {t_bunch_num_i};
89 
90  RAJA_INLINE RAJA_HOST_DEVICE constexpr Ret operator()(
91  Arg1 const& i,
92  Arg1 const& RAJA_UNUSED_ARG(num_i),
93  Arg2 const& j,
94  Arg2 const& num_j) const noexcept
95  {
96  // assert(num_i >= bunch_num_i)
97  Arg1 i_inner = i % bunch_num_i;
98  Arg1 i_outer = i / bunch_num_i;
99  return i_inner + j * bunch_num_i + i_outer * num_j * bunch_num_i;
100  }
101 };
102 
103 } // namespace RAJA
104 
105 #endif
Header file for RAJA concept definitions.
Header file for common RAJA internal macro definitions.
#define RAJA_HOST_DEVICE
Definition: macros.hpp:65
#define RAJA_UNUSED_ARG(x)
Definition: macros.hpp:97
Definition: AlignedRangeIndexSetBuilders.cpp:35
Definition: OffsetOperators.hpp:78
RAJA_INLINE constexpr RAJA_HOST_DEVICE Ret operator()(Arg1 const &i, Arg1 const &RAJA_UNUSED_ARG(num_i), Arg2 const &j, Arg2 const &num_j) const noexcept
Definition: OffsetOperators.hpp:90
static constexpr Arg1 bunch_num_i
Definition: OffsetOperators.hpp:88
Definition: OffsetOperators.hpp:33
RAJA_INLINE constexpr RAJA_HOST_DEVICE Ret operator()(Arg1 const &i, Arg1 const &num_i, Arg2 const &j, Arg2 const &RAJA_UNUSED_ARG(num_j)) const noexcept
Definition: OffsetOperators.hpp:42
Definition: OffsetOperators.hpp:54
RAJA_INLINE constexpr RAJA_HOST_DEVICE Ret operator()(Arg1 const &i, Arg1 const &RAJA_UNUSED_ARG(num_i), Arg2 const &j, Arg2 const &num_j) const noexcept
Definition: OffsetOperators.hpp:63