RAJA
RAJA provides a collection of platform portability abstractions for C++ HPC applications.
SoAArray.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_SOA_ARRAY_HPP
21 #define RAJA_SOA_ARRAY_HPP
22 
23 #include "RAJA/config.hpp"
24 
25 // for RAJA::reduce::detail::ValueLoc
27 
28 namespace RAJA
29 {
30 
31 namespace detail
32 {
33 
40 template<typename T, size_t size>
41 class SoAArray
42 {
43  using value_type = T;
44 
45 public:
46  constexpr RAJA_HOST_DEVICE value_type get(size_t i) const { return mem[i]; }
47 
48  constexpr RAJA_HOST_DEVICE void set(size_t i, value_type val)
49  {
50  mem[i] = val;
51  }
52 
53 private:
54  value_type mem[size];
55 };
56 
60 template<typename T, typename IndexType, bool doing_min, size_t size>
61 class SoAArray<::RAJA::reduce::detail::ValueLoc<T, IndexType, doing_min>, size>
62 {
64  using first_type = T;
65  using second_type = IndexType;
66 
67 public:
68  constexpr RAJA_HOST_DEVICE value_type get(size_t i) const
69  {
70  return value_type(mem[i], mem_idx[i]);
71  }
72 
73  constexpr RAJA_HOST_DEVICE void set(size_t i, value_type val)
74  {
75  mem[i] = val;
76  mem_idx[i] = val.getLoc();
77  }
78 
79 private:
80  first_type mem[size];
81  second_type mem_idx[size];
82 };
83 
84 } // namespace detail
85 
86 } // namespace RAJA
87 
88 #endif /* RAJA_SOA_ARRAY_HPP */
constexpr RAJA_HOST_DEVICE value_type get(size_t i) const
Definition: SoAArray.hpp:68
constexpr RAJA_HOST_DEVICE void set(size_t i, value_type val)
Definition: SoAArray.hpp:73
Array class specialized for Struct of Array data layout.
Definition: SoAArray.hpp:42
constexpr RAJA_HOST_DEVICE value_type get(size_t i) const
Definition: SoAArray.hpp:46
constexpr RAJA_HOST_DEVICE void set(size_t i, value_type val)
Definition: SoAArray.hpp:48
Definition: reduce.hpp:131
RAJA_HOST_DEVICE IndexType getLoc()
Definition: reduce.hpp:170
#define RAJA_HOST_DEVICE
Definition: macros.hpp:65
Definition: AlignedRangeIndexSetBuilders.cpp:35
Base types used in common for RAJA reducer objects.