BioCMAMC-ST
alias.hpp
1#ifndef __MC__ALIAS_HPP__
2#define __MC__ALIAS_HPP__
3
4#include <Kokkos_Core_fwd.hpp>
5#include <Kokkos_Random.hpp>
6#include <Kokkos_ScatterView.hpp>
7#include <common/traits.hpp>
8#include <decl/Kokkos_Declare_OPENMP.hpp>
9#include <traits/Kokkos_IterationPatternTrait.hpp>
10#include <type_traits>
11
12// static_assert(FloatingPointType<Kokkos::Experimental::half_t>,
13// "Kokkos half_t ok");
14
15namespace MC
16{
17 using ComputeSpace = Kokkos::DefaultExecutionSpace;
18 using HostSpace = Kokkos::DefaultHostExecutionSpace;
19
20 using ComputeLayout = ComputeSpace::array_layout;
21
22 // NOLINTBEGIN(hicpp-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays)
23 template <uint64_t Nd, FloatingPointType F>
24 // using ParticlesModel = Kokkos::View<
25 // F* [Nd],
26 // Kokkos::LayoutRight,
27 // ComputeSpace,
28 // Kokkos::MemoryTraits<Kokkos::MemoryTraitsFlags::Restrict> >;
29
30 // template <uint64_t Nc, FloatingPointType F>
31 // using ParticlesContribs = Kokkos::View<
32 // F* [Nc],
33 // Kokkos::LayoutRight,
34 // ComputeSpace,
35 // Kokkos::MemoryTraits<Kokkos::MemoryTraitsFlags::Restrict
36 // | Kokkos::MemoryTraitsFlags::Aligned> >;
37
38 // template <FloatingPointType F>
39 // using DynParticlesModel = Kokkos::View<
40 // F**,
41 // Kokkos::LayoutRight,
42 // ComputeSpace,
43 // Kokkos::MemoryTraits<Kokkos::MemoryTraitsFlags::Restrict> >;
44
45 // template <FloatingPointType F>
46 // using DynParticlesContribs = Kokkos::View<
47 // F**,
48 // Kokkos::LayoutRight,
49 // ComputeSpace,
50 // Kokkos::MemoryTraits<Kokkos::MemoryTraitsFlags::Restrict> >;
51
53 = Kokkos::View<F* [Nd],
54 ComputeSpace::array_layout,
56 Kokkos::MemoryTraits<Kokkos::MemoryTraitsFlags::Restrict>>;
57
58 // template <uint64_t Nc, FloatingPointType F>
59 // using ParticlesContribs = Kokkos::View<
60 // F* [Nc],
61 // ComputeSpace::array_layout,
62 // ComputeSpace,
63 // Kokkos::MemoryTraits<Kokkos::MemoryTraitsFlags::Restrict
64 // | Kokkos::MemoryTraitsFlags::Aligned>>;
65
66 template <uint64_t Nc, FloatingPointType F>
68 = Kokkos::View<F* [Nc],
69 ComputeSpace::array_layout,
71 Kokkos::MemoryTraits<Kokkos::MemoryTraitsFlags::Restrict>>;
73 template <FloatingPointType F>
75 = Kokkos::View<F**,
76 ComputeSpace::array_layout,
78 Kokkos::MemoryTraits<Kokkos::MemoryTraitsFlags::Restrict>>;
79
80 template <FloatingPointType F>
82 = Kokkos::View<F**,
83 ComputeSpace::array_layout,
85 Kokkos::MemoryTraits<Kokkos::MemoryTraitsFlags::Restrict>>;
86
87 // NOLINTEND(hicpp-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays)
88
89}; // namespace MC
90
91using kernelMT = Kokkos::MemoryTraits<Kokkos::MemoryTraitsFlags::RandomAccess
92 | Kokkos::MemoryTraitsFlags::Atomic
93 | Kokkos::MemoryTraitsFlags::Restrict>;
94
95namespace MC
96{
97 template <typename ExecSpace>
98 using gen_pool_type = Kokkos::Random_XorShift1024_Pool<ExecSpace>;
99
101
102 using generator_type = pool_type::generator_type;
103
104 using restrict_mt = Kokkos::MemoryTraits<Kokkos::MemoryTraitsFlags::Restrict>;
105 namespace
106 {
107
113 // template <typename Exec>
114 // using ParticleAgesBase = Kokkos::
115 // View<double* [2], typename Exec::array_layout, Exec>; // NOLINT
116
117 // Force layout left because iteration on age(i,0)->age(i,1) is never done
118 // in compute kernel
119 template <typename Exec>
120 using ParticleAgesBase
121 = Kokkos::View<float* [2], Kokkos::LayoutLeft, Exec>; // NOLINT
122 } // namespace
123
124 enum class Status : char
125 {
126 Idle = 0,
130 };
131
133 {
134 int begin;
135 int end;
136 };
137
138 struct LeavingFlow;
139
140 using ParticlePositions = Kokkos::View<uint64_t*, ComputeSpace>;
141 using ParticleStatus = Kokkos::View<Status*, ComputeSpace>;
142 template <FloatingPointType ftype>
143 using ParticleWeigths = Kokkos::View<ftype*, ComputeSpace>;
144 using ParticleAges = ParticleAgesBase<ComputeSpace>;
145
146 // using ParticleSamples = Kokkos::
147 // View<Kokkos::Experimental::half_t**, Kokkos::LayoutRight,
148 // ComputeSpace>;
149
150 // V1.0-rc: LayoutRight seems to lead to better perf than Left for GPU
152 = Kokkos::View<float**, Kokkos::LayoutRight, ComputeSpace>;
153
154 template <typename MemorySpace>
156 = Kokkos::View<double**, Kokkos::LayoutRight, MemorySpace>;
157
159 = Kokkos::Subview<ParticlePropertyViewType<ComputeSpace>,
160 decltype(Kokkos::ALL),
161 std::size_t>;
164 = Kokkos::View<float**, Kokkos::LayoutLeft, MC::ComputeSpace, kernelMT>;
166 using ContributionView = decltype(Kokkos::Experimental::create_scatter_view(
168
170 = Kokkos::View<const double**,
171 Kokkos::LayoutLeft,
173 Kokkos::MemoryTraits<Kokkos::RandomAccess>>;
174
176
177 template <class ExecSpace, bool is_const>
178 using VolumeView = std::conditional_t<
179 is_const,
180 Kokkos::View<const double*,
181 ExecSpace,
182 Kokkos::MemoryTraits<Kokkos::RandomAccess>>,
183 Kokkos::View<double*, ExecSpace>>;
184
185 template <class ExecSpace, bool is_const>
186 using DiagonalView = std::conditional_t<
187 is_const,
188 Kokkos::View<const double*,
189 Kokkos::LayoutLeft,
190 ExecSpace,
191 Kokkos::MemoryTraits<Kokkos::RandomAccess>>,
192 Kokkos::View<double*, Kokkos::LayoutLeft, ExecSpace>>;
193
194 template <bool is_const>
195 using LeavingFlowView = std::conditional_t<
196 is_const,
197 Kokkos::View<const LeavingFlow*, Kokkos::SharedHostPinnedSpace>,
198 Kokkos::View<LeavingFlow*, Kokkos::SharedHostPinnedSpace>>;
199
200 // TODO Use execspace layout
201 template <class ExecSpace, bool is_const>
202 using CumulativeProbabilityView = std::conditional_t<
203 is_const,
204 Kokkos::View<const double**,
205 Kokkos::LayoutRight,
206 ExecSpace,
207 Kokkos::MemoryTraits<Kokkos::RandomAccess>>,
208 Kokkos::View<double**, Kokkos::LayoutRight, ExecSpace>>;
209
210 template <class ExecSpace, bool is_const>
211 using NeighborsView = std::conditional_t<
212 is_const,
213 Kokkos::View<const std::size_t**,
214 Kokkos::LayoutRight,
215 ExecSpace,
216 Kokkos::MemoryTraits<Kokkos::RandomAccess>>,
217 Kokkos::View<std::size_t**, Kokkos::LayoutRight, ExecSpace>>;
218
219}; // namespace MC
220// FIXME
221
222#endif
Namespace that contains classes and structures related to Monte Carlo (MC) simulations.
Definition alias.hpp:16
std::conditional_t< is_const, Kokkos::View< const std::size_t **, Kokkos::LayoutRight, ExecSpace, Kokkos::MemoryTraits< Kokkos::RandomAccess > >, Kokkos::View< std::size_t **, Kokkos::LayoutRight, ExecSpace > > NeighborsView
Definition alias.hpp:206
Kokkos::DefaultHostExecutionSpace HostSpace
Definition alias.hpp:18
Kokkos::View< float **, Kokkos::LayoutRight, ComputeSpace > ParticleSamples
Definition alias.hpp:151
Kokkos::View< Status *, ComputeSpace > ParticleStatus
Definition alias.hpp:141
Kokkos::View< uint64_t *, ComputeSpace > ParticlePositions
Definition alias.hpp:140
Kokkos::MemoryTraits< Kokkos::MemoryTraitsFlags::Restrict > restrict_mt
Definition alias.hpp:104
decltype(Kokkos::Experimental::create_scatter_view( kernelContribution())) ContributionView
Definition alias.hpp:162
Kokkos::Subview< ParticlePropertyViewType< ComputeSpace >, decltype(Kokkos::ALL), std::size_t > PropertySubViewtype
Definition alias.hpp:156
Kokkos::View< F **, ComputeSpace::array_layout, ComputeSpace, Kokkos::MemoryTraits< Kokkos::MemoryTraitsFlags::Restrict > > DynParticlesContribs
Definition alias.hpp:78
Status
Definition alias.hpp:125
@ Dead
Definition alias.hpp:129
@ Division
Definition alias.hpp:127
@ Idle
Definition alias.hpp:126
@ Exit
Definition alias.hpp:128
ParticleAgesBase< ComputeSpace > ParticleAges
Definition alias.hpp:144
std::conditional_t< is_const, Kokkos::View< const double *, ExecSpace, Kokkos::MemoryTraits< Kokkos::RandomAccess > >, Kokkos::View< double *, ExecSpace > > VolumeView
Definition alias.hpp:173
gen_pool_type< Kokkos::DefaultExecutionSpace > pool_type
Definition alias.hpp:100
ComputeSpace::array_layout ComputeLayout
Definition alias.hpp:20
pool_type::generator_type generator_type
Definition alias.hpp:102
Kokkos::View< ftype *, ComputeSpace > ParticleWeigths
Definition alias.hpp:143
Kokkos::View< float **, Kokkos::LayoutLeft, MC::ComputeSpace, kernelMT > kernelContribution
Definition alias.hpp:160
KernelConcentrationType LocalConcentration
Definition alias.hpp:170
Kokkos::DefaultExecutionSpace ComputeSpace
Definition alias.hpp:17
Kokkos::View< const double **, Kokkos::LayoutLeft, ComputeSpace, Kokkos::MemoryTraits< Kokkos::RandomAccess > > KernelConcentrationType
Definition alias.hpp:165
std::conditional_t< is_const, Kokkos::View< const LeavingFlow *, Kokkos::SharedHostPinnedSpace >, Kokkos::View< LeavingFlow *, Kokkos::SharedHostPinnedSpace > > LeavingFlowView
Definition alias.hpp:190
Kokkos::View< double **, Kokkos::LayoutRight, MemorySpace > ParticlePropertyViewType
Definition alias.hpp:154
Kokkos::View< F *[Nc], ComputeSpace::array_layout, ComputeSpace, Kokkos::MemoryTraits< Kokkos::MemoryTraitsFlags::Restrict > > ParticlesContribs
Definition alias.hpp:66
Kokkos::View< F *[Nd], ComputeSpace::array_layout, ComputeSpace, Kokkos::MemoryTraits< Kokkos::MemoryTraitsFlags::Restrict > > ParticlesModel
Definition alias.hpp:52
std::conditional_t< is_const, Kokkos::View< const double **, Kokkos::LayoutRight, ExecSpace, Kokkos::MemoryTraits< Kokkos::RandomAccess > >, Kokkos::View< double **, Kokkos::LayoutRight, ExecSpace > > CumulativeProbabilityView
Definition alias.hpp:197
Kokkos::Random_XorShift1024_Pool< ExecSpace > gen_pool_type
Definition alias.hpp:98
std::conditional_t< is_const, Kokkos::View< const double *, Kokkos::LayoutLeft, ExecSpace, Kokkos::MemoryTraits< Kokkos::RandomAccess > >, Kokkos::View< double *, Kokkos::LayoutLeft, ExecSpace > > DiagonalView
Definition alias.hpp:181
Kokkos::View< F **, ComputeSpace::array_layout, ComputeSpace, Kokkos::MemoryTraits< Kokkos::MemoryTraitsFlags::Restrict > > DynParticlesModel
Definition alias.hpp:72
Definition alias.hpp:133
int end
Definition alias.hpp:135
int begin
Definition alias.hpp:134
Store position and value of volumic flow at outlet.
Definition domain.hpp:18