BioCMAMC-ST
unit.hpp
1#ifndef __MC_UNIT_HPP__
2#define __MC_UNIT_HPP__
3
4#include <mc/domain.hpp>
5#include <mc/events.hpp>
6#include <mc/particles_container.hpp>
7#include <mc/prng/prng.hpp>
8#include <mc/traits.hpp>
9#include <variant>
10#include <variant_model.hpp>
11
13{
14 KOKKOS_FUNCTION void
15 operator()(const Kokkos::TeamPolicy<ComputeSpace>::member_type& team_handle,
16 int& dead_count) const
17 {
18 (void)team_handle;
19 (void)dead_count;
20 }
21 TagDetector() = default;
22};
23
33namespace MC
34{
35
36 template <typename FunctorType, typename Tag = void>
37 Kokkos::TeamPolicy<ComputeSpace, Tag>
38 get_policy(const FunctorType& f, std::size_t range, bool reduce = false)
39 {
40 (void)f;
41 (void)reduce;
42 Kokkos::TeamPolicy<> _policy;
43
44 const char* env_team_size = std::getenv("BIOMC_TEAM_SIZE");
45
46 int recommended_team_size = _policy.team_size_recommended(
47 TagDetector(), Kokkos::ParallelReduceTag());
48 if (env_team_size != nullptr)
49 {
50 recommended_team_size = std::stoi(env_team_size);
51 }
52 // std::cout << recommended_team_size << std::endl;
53 int league_size = (static_cast<int>(range) + recommended_team_size - 1) /
54 recommended_team_size;
55
56 return Kokkos::TeamPolicy<ComputeSpace, Tag>(league_size,
57 recommended_team_size);
58 }
59
60 template <typename Tag = void>
61 Kokkos::TeamPolicy<ComputeSpace, Tag> get_policy_team()
62 {
63 const char* env_team_size = std::getenv("BIOMC_LEAGUE_SIZE");
64
65 auto league_size = 1;
66 if (env_team_size != nullptr)
67 {
68 league_size = std::stoi(env_team_size);
69 }
70
71 return Kokkos::TeamPolicy<ComputeSpace, Tag>(league_size, Kokkos::AUTO);
72 }
73
83 {
87
88 // AutoGenerated::ContainerVariant
89 // container; ///< Variant container holding various simulation entities
90
91 AutoGenerated::ContainerVariant container;
92
94 double init_weight{};
95
97 delete;
99 delete;
101 default;
103 default;
104
105 MonteCarloUnit() = default;
106 ~MonteCarloUnit() = default;
107
108 [[nodiscard]] uint64_t n_particle() const;
109
110 [[nodiscard]] std::vector<uint64_t> getRepartition() const;
111
112 template <class Archive> void serialize(Archive& ar)
113 {
115 std::visit([&ar](auto& container) { ar(container); }, container);
116 }
117 };
118
119} // namespace MC
120
121#endif //__MC_UNIT_HPP__
Utilities and wrap around kokkos random generator.
Definition prng.hpp:31
Represents the spatial domain where Monte Carlo particles can exist.
Definition domain.hpp:40
Namespace that contains classes and structures related to Monte Carlo (MC) simulations.
Definition alias.hpp:9
Kokkos::TeamPolicy< ComputeSpace, Tag > get_policy(const FunctorType &f, std::size_t range, bool reduce=false)
Definition unit.hpp:38
Kokkos::TeamPolicy< ComputeSpace, Tag > get_policy_team()
Definition unit.hpp:61
Use to count events that occurs during Monte-Carlo processing cycles.
Definition events.hpp:44
MonteCarloUnit(const MonteCarloUnit &)=delete
Prevent copying of the MonteCarloUnit.
std::vector< uint64_t > getRepartition() const
Definition unit.cpp:163
ReactorDomain domain
Represents the domain within which the simulation occurs.
Definition unit.hpp:86
KPRNG rng
Random number generator used for Monte Carlo methods.
Definition unit.hpp:93
double init_weight
Initial weight or factor used in the simulation.
Definition unit.hpp:94
void serialize(Archive &ar)
Definition unit.hpp:112
uint64_t n_particle() const
Definition unit.cpp:156
AutoGenerated::ContainerVariant container
Definition unit.hpp:91
MonteCarloUnit & operator=(const MonteCarloUnit &)=delete
Prevent copying of the MonteCarloUnit.
EventContainer events
Container to manage and store simulation events.
Definition unit.hpp:84
MonteCarloUnit & operator=(MonteCarloUnit &&) noexcept=default
Allow moving of the MonteCarloUn.
Definition unit.hpp:13
KOKKOS_FUNCTION void operator()(const Kokkos::TeamPolicy< ComputeSpace >::member_type &team_handle, int &dead_count) const
Definition unit.hpp:15
TagDetector()=default