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> KOKKOS_INLINE_FUNCTION
consteval size_t event_index()
36 return static_cast<size_t>(event);
49 Kokkos::View<std::size_t[number_event_type], Kokkos::SharedSpace>
63 [[nodiscard]] std::span<std::size_t>
get_span()
const
73 KOKKOS_INLINE_FUNCTION
void clear()
const
84 template <EventType event> [[nodiscard]]
constexpr std::size_t
get()
const
97 template <EventType event> KOKKOS_FORCEINLINE_FUNCTION
constexpr void incr()
const
103 template <EventType event> KOKKOS_FORCEINLINE_FUNCTION
constexpr void add(
size_t val)
const
109 template <EventType event> KOKKOS_FORCEINLINE_FUNCTION
constexpr void wrap_incr()
const
111 if constexpr (AutoGenerated::FlagCompileTime::enable_event_counter)
125 template <
class Archive>
void save(Archive& ar)
const
127 std::array<std::size_t, number_event_type> array{};
131 std::copy(rd.begin(), rd.end(), array.begin());
132 assert(rd[0] ==
_events[0] && rd[0] == array[0]);
137 template <
class Archive>
void load(Archive& ar)
140 std::array<std::size_t, number_event_type> array{};
145 std::copy(array.begin(), array.end(), rd.begin());
Namespace that contains classes and structures related to Monte Carlo (MC) simulations.
Definition alias.hpp:9
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
@ Death
Remove particle from list.
@ NewParticle
Spawn new particle.
@ ChangeWeight
Update in weight.
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:34
Use to count events that occurs during Monte-Carlo processing cycles.
Definition events.hpp:43
KOKKOS_FORCEINLINE_FUNCTION constexpr void wrap_incr() const
Definition events.hpp:109
std::span< std::size_t > get_span() const
Get std const view of _events counter.
Definition events.hpp:63
void save(Archive &ar) const
Definition events.hpp:125
constexpr std::size_t get() const
Getter to specific event counter.
Definition events.hpp:84
KOKKOS_FORCEINLINE_FUNCTION constexpr void incr() const
Increment specific event counter.
Definition events.hpp:97
EventContainer()
Default container, initalise counter.
Definition events.hpp:55
KOKKOS_INLINE_FUNCTION void clear() const
Reset counters.
Definition events.hpp:73
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:7
KOKKOS_FORCEINLINE_FUNCTION constexpr void add(size_t val) const
Definition events.hpp:103
Kokkos::View< std::size_t[number_event_type], Kokkos::SharedSpace > _events
Definition events.hpp:50
void load(Archive &ar)
Definition events.hpp:137