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>;
78
79 // using ParticleSamples = Kokkos::
80 // View<Kokkos::Experimental::half_t**, Kokkos::LayoutRight,
81 // ComputeSpace>;
82 using ParticleSamples
83 = Kokkos::View<float**, Kokkos::LayoutRight, ComputeSpace>;
85 template <typename MemorySpace>
87 = Kokkos::View<double**, Kokkos::LayoutRight, MemorySpace>;
88
90 = Kokkos::Subview<ParticlePropertyViewType<ComputeSpace>,
91 decltype(Kokkos::ALL),
92 std::size_t>;
94 using ContributionView = decltype(Kokkos::Experimental::create_scatter_view(
95 kernelContribution()));
96
98 = Kokkos::View<const double**,
99 Kokkos::LayoutLeft,
101 Kokkos::MemoryTraits<Kokkos::RandomAccess>>;
103 = Kokkos::Subview<KernelConcentrationType, int, decltype(Kokkos::ALL)>;
104
105 template <class ExecSpace, bool is_const>
106 using VolumeView = std::conditional_t<
107 is_const,
108 Kokkos::View<const double*,
109 ExecSpace,
110 Kokkos::MemoryTraits<Kokkos::RandomAccess>>,
111 Kokkos::View<double*, ExecSpace>>;
112
113 template <class ExecSpace, bool is_const>
114 using DiagonalView = std::conditional_t<
115 is_const,
116 Kokkos::View<const double*,
117 Kokkos::LayoutLeft,
118 ExecSpace,
119 Kokkos::MemoryTraits<Kokkos::RandomAccess>>,
120 Kokkos::View<double*, Kokkos::LayoutLeft, ExecSpace>>;
121
122 template <bool is_const>
123 using LeavingFlowView = std::conditional_t<
124 is_const,
125 Kokkos::View<const LeavingFlow*, Kokkos::SharedHostPinnedSpace>,
126 Kokkos::View<LeavingFlow*, Kokkos::SharedHostPinnedSpace>>;
127
128 template <class ExecSpace, bool is_const>
129 using CumulativeProbabilityView = std::conditional_t<
130 is_const,
131 Kokkos::View<const double**,
132 Kokkos::LayoutRight,
133 ExecSpace,
134 Kokkos::MemoryTraits<Kokkos::RandomAccess>>,
135 Kokkos::View<double**, Kokkos::LayoutRight, ExecSpace>>;
136
137 template <class ExecSpace, bool is_const>
138 using NeighborsView = std::conditional_t<
139 is_const,
140 Kokkos::View<const std::size_t**,
141 Kokkos::LayoutRight,
142 ExecSpace,
143 Kokkos::MemoryTraits<Kokkos::RandomAccess>>,
144 Kokkos::View<std::size_t**, Kokkos::LayoutRight, ExecSpace>>;
145
146}; // namespace MC
147// FIXME
148
149#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:97
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:132
Kokkos::View< double *, ComputeSpace > ParticleWeigths
Definition alias.hpp:75
Kokkos::DefaultHostExecutionSpace HostSpace
Definition alias.hpp:23
Kokkos::View< float **, Kokkos::LayoutRight, ComputeSpace > ParticleSamples
Definition alias.hpp:81
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:90
Kokkos::Subview< ParticlePropertyViewType< ComputeSpace >, decltype(Kokkos::ALL), std::size_t > PropertySubViewtype
Definition alias.hpp:86
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:100
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:93
std::conditional_t< is_const, Kokkos::View< const LeavingFlow *, Kokkos::SharedHostPinnedSpace >, Kokkos::View< LeavingFlow *, Kokkos::SharedHostPinnedSpace > > LeavingFlowView
Definition alias.hpp:117
Kokkos::View< double **, Kokkos::LayoutRight, MemorySpace > ParticlePropertyViewType
Definition alias.hpp:84
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:123
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:108
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