1#ifndef __MC_EVENTS_HPP__
2#define __MC_EVENTS_HPP__
4#include "biocma_cst_config.hpp"
5#include <Kokkos_Core.hpp>
6#include <common/execinfo.hpp>
34 template <EventType event>
35 KOKKOS_INLINE_FUNCTION
consteval size_t
38 return static_cast<size_t>(event);
51 Kokkos::View<std::size_t[number_event_type], Kokkos::SharedSpace>
65 [[nodiscard]] std::span<std::size_t>
76 KOKKOS_INLINE_FUNCTION
void
88 template <EventType event>
89 [[nodiscard]]
constexpr std::size_t
93 "Count is not a valid event");
104 template <EventType event>
105 KOKKOS_FORCEINLINE_FUNCTION
constexpr void
109 "Count is not a valid event");
113 template <EventType event>
114 KOKKOS_FORCEINLINE_FUNCTION
constexpr void
118 "Count is not a valid event");
122 template <EventType event>
123 KOKKOS_FORCEINLINE_FUNCTION
constexpr void
126 if constexpr (AutoGenerated::FlagCompileTime::enable_event_counter)
140 template <
class Archive>
144 std::array<std::size_t, number_event_type> array{};
148 std::copy(rd.begin(), rd.end(), array.begin());
149 assert(rd[0] ==
_events[0] && rd[0] == array[0]);
154 template <
class Archive>
159 std::array<std::size_t, number_event_type> array{};
164 std::copy(array.begin(), array.end(), rd.begin());
Namespace that contains classes and structures related to Monte Carlo (MC) simulations.
Definition alias.hpp:15
constexpr size_t number_event_type
Definition events.hpp:27
EventType
Enumeration that represents events that can occurs during a Monte-Carlo cycle.
Definition events.hpp:17
@ Overflow
Definition events.hpp:22
@ Death
Remove particle from list.
Definition events.hpp:21
@ Move
Move in domain.
Definition events.hpp:20
@ __COUNT__
Definition events.hpp:24
@ NewParticle
Spawn new particle.
Definition events.hpp:18
@ ChangeWeight
Update in weight.
Definition events.hpp:23
@ Exit
Definition alias.hpp:61
KOKKOS_INLINE_FUNCTION consteval size_t event_index()
inline getter, converts event to its value in order to be use as array index
Definition events.hpp:36
Use to count events that occurs during Monte-Carlo processing cycles.
Definition events.hpp:45
KOKKOS_FORCEINLINE_FUNCTION constexpr void wrap_incr() const
Definition events.hpp:124
std::span< std::size_t > get_span() const
Get std const view of _events counter.
Definition events.hpp:66
void save(Archive &ar) const
Definition events.hpp:142
constexpr std::size_t get() const
Getter to specific event counter.
Definition events.hpp:90
KOKKOS_FORCEINLINE_FUNCTION constexpr void incr() const
Increment specific event counter.
Definition events.hpp:106
EventContainer()
Default container, initalise counter.
Definition events.hpp:57
KOKKOS_INLINE_FUNCTION void clear() const
Reset counters.
Definition events.hpp:77
static EventContainer reduce(std::span< std::size_t > _data)
Transform a linear contiguous counter data obtained via MPI gather into EventContainer object.
Definition events.cpp:8
KOKKOS_FORCEINLINE_FUNCTION constexpr void add(size_t val) const
Definition events.hpp:115
Kokkos::View< std::size_t[number_event_type], Kokkos::SharedSpace > _events
Definition events.hpp:52
void load(Archive &ar)
Definition events.hpp:156