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 <traits/Kokkos_IterationPatternTrait.hpp>
9#include <type_traits>
10
11// static_assert(FloatingPointType<Kokkos::Experimental::half_t>,
12// "Kokkos half_t ok");
13
14namespace MC
15{
16
17 // NOLINTBEGIN(hicpp-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays)
18 template <uint64_t Nd, FloatingPointType F>
19 using ParticlesModel = Kokkos::View<F* [Nd], Kokkos::LayoutRight>;
20 template <FloatingPointType F>
21 using DynParticlesModel = Kokkos::View<F**, Kokkos::LayoutRight>;
22 using ComputeSpace = Kokkos::DefaultExecutionSpace;
23 using HostSpace = Kokkos::DefaultHostExecutionSpace;
24 // NOLINTEND(hicpp-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays)
25
26}; // namespace MC
27
28using kernelMT = Kokkos::MemoryTraits<Kokkos::MemoryTraitsFlags::RandomAccess
29 | Kokkos::MemoryTraitsFlags::Atomic
30 | Kokkos::MemoryTraitsFlags::Restrict>;
31
32using kernelContribution
33 = Kokkos::View<float**, Kokkos::LayoutLeft, MC::ComputeSpace, kernelMT>;
34
35namespace MC
36{
37 template <typename ExecSpace>
38 using gen_pool_type = Kokkos::Random_XorShift1024_Pool<ExecSpace>;
42 using generator_type = pool_type::generator_type;
44 using restrict_mt = Kokkos::MemoryTraits<Kokkos::MemoryTraitsFlags::Restrict>;
45 namespace
46 {
47
53 template <typename Exec>
54 using ParticleAgesBase
55 = Kokkos::View<double* [2], Kokkos::LayoutLeft, Exec>; // NOLINT
56 } // namespace
58 enum class Status : char
59 {
60 Idle = 0,
63 Dead,
64 };
67 {
68 int begin;
69 int end;
70 };
71
72 struct LeavingFlow;
74 using ParticlePositions = Kokkos::View<uint64_t*, ComputeSpace>;
75 using ParticleStatus = Kokkos::View<Status*, ComputeSpace>;
76 using ParticleWeigths = Kokkos::View<double*, ComputeSpace>;
77 using ParticleAges = ParticleAgesBase<ComputeSpace>;
79 using ParticleSamples = Kokkos::
80 View<Kokkos::Experimental::half_t**, Kokkos::LayoutRight, ComputeSpace>;
81
82 template <typename MemorySpace>
84 = Kokkos::View<double**, Kokkos::LayoutRight, MemorySpace>;
85
87 = Kokkos::Subview<ParticlePropertyViewType<ComputeSpace>,
88 decltype(Kokkos::ALL),
89 std::size_t>;
90
91 using ContributionView = decltype(Kokkos::Experimental::create_scatter_view(
92 kernelContribution()));
93
95 = Kokkos::View<const double**,
96 Kokkos::LayoutLeft,
98 Kokkos::MemoryTraits<Kokkos::RandomAccess>>;
100 = Kokkos::Subview<KernelConcentrationType, int, decltype(Kokkos::ALL)>;
101
102 template <class ExecSpace, bool is_const>
103 using VolumeView = std::conditional_t<
104 is_const,
105 Kokkos::View<const double*,
106 ExecSpace,
107 Kokkos::MemoryTraits<Kokkos::RandomAccess>>,
108 Kokkos::View<double*, ExecSpace>>;
109
110 template <class ExecSpace, bool is_const>
111 using DiagonalView = std::conditional_t<
112 is_const,
113 Kokkos::View<const double*,
114 Kokkos::LayoutLeft,
115 ExecSpace,
116 Kokkos::MemoryTraits<Kokkos::RandomAccess>>,
117 Kokkos::View<double*, Kokkos::LayoutLeft, ExecSpace>>;
118
119 template <bool is_const>
120 using LeavingFlowView = std::conditional_t<
121 is_const,
122 Kokkos::View<const LeavingFlow*, Kokkos::SharedHostPinnedSpace>,
123 Kokkos::View<LeavingFlow*, Kokkos::SharedHostPinnedSpace>>;
124
125 template <class ExecSpace, bool is_const>
126 using CumulativeProbabilityView = std::conditional_t<
127 is_const,
128 Kokkos::View<const double**,
129 Kokkos::LayoutRight,
130 ExecSpace,
131 Kokkos::MemoryTraits<Kokkos::RandomAccess>>,
132 Kokkos::View<double**, Kokkos::LayoutRight, ExecSpace>>;
133
134 template <class ExecSpace, bool is_const>
135 using NeighborsView = std::conditional_t<
136 is_const,
137 Kokkos::View<const std::size_t**,
138 Kokkos::LayoutRight,
139 ExecSpace,
140 Kokkos::MemoryTraits<Kokkos::RandomAccess>>,
141 Kokkos::View<std::size_t**, Kokkos::LayoutRight, ExecSpace>>;
142
143}; // namespace MC
144// FIXME
145
146#endif
Namespace that contains classes and structures related to Monte Carlo (MC) simulations.
Definition alias.hpp:15
Kokkos::Subview< KernelConcentrationType, int, decltype(Kokkos::ALL)> LocalConcentration
Definition alias.hpp:95
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:130
Kokkos::View< double *, ComputeSpace > ParticleWeigths
Definition alias.hpp:75
Kokkos::DefaultHostExecutionSpace HostSpace
Definition alias.hpp:23
Kokkos::View< Status *, ComputeSpace > ParticleStatus
Definition alias.hpp:74
Kokkos::View< uint64_t *, ComputeSpace > ParticlePositions
Definition alias.hpp:73
Kokkos::MemoryTraits< Kokkos::MemoryTraitsFlags::Restrict > restrict_mt
Definition alias.hpp:43
decltype(Kokkos::Experimental::create_scatter_view( kernelContribution())) ContributionView
Definition alias.hpp:88
Kokkos::Subview< ParticlePropertyViewType< ComputeSpace >, decltype(Kokkos::ALL), std::size_t > PropertySubViewtype
Definition alias.hpp:84
Status
Definition alias.hpp:58
@ Dead
Definition alias.hpp:62
@ Division
Definition alias.hpp:60
@ Idle
Definition alias.hpp:59
@ Exit
Definition alias.hpp:61
ParticleAgesBase< ComputeSpace > ParticleAges
Definition alias.hpp:76
std::conditional_t< is_const, Kokkos::View< const double *, ExecSpace, Kokkos::MemoryTraits< Kokkos::RandomAccess > >, Kokkos::View< double *, ExecSpace > > VolumeView
Definition alias.hpp:98
gen_pool_type< Kokkos::DefaultExecutionSpace > pool_type
Definition alias.hpp:39
pool_type::generator_type generator_type
Definition alias.hpp:41
Kokkos::DefaultExecutionSpace ComputeSpace
Definition alias.hpp:22
Kokkos::View< const double **, Kokkos::LayoutLeft, ComputeSpace, Kokkos::MemoryTraits< Kokkos::RandomAccess > > KernelConcentrationType
Definition alias.hpp:91
std::conditional_t< is_const, Kokkos::View< const LeavingFlow *, Kokkos::SharedHostPinnedSpace >, Kokkos::View< LeavingFlow *, Kokkos::SharedHostPinnedSpace > > LeavingFlowView
Definition alias.hpp:115
Kokkos:: View< Kokkos::Experimental::half_t **, Kokkos::LayoutRight, ComputeSpace > ParticleSamples
Definition alias.hpp:78
Kokkos::View< double **, Kokkos::LayoutRight, MemorySpace > ParticlePropertyViewType
Definition alias.hpp:82
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:121
Kokkos::View< F *[Nd], Kokkos::LayoutRight > ParticlesModel
Definition alias.hpp:19
Kokkos::View< F **, Kokkos::LayoutRight > DynParticlesModel
Definition alias.hpp:21
Kokkos::Random_XorShift1024_Pool< ExecSpace > gen_pool_type
Definition alias.hpp:37
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:106
Definition alias.hpp:66
int end
Definition alias.hpp:68
int begin
Definition alias.hpp:67
Store position and value of volumic flow at outlet.
Definition domain.hpp:18