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>
37 return static_cast<size_t>(event);
50 Kokkos::View<std::size_t[number_event_type], Kokkos::SharedSpace>
64 [[nodiscard]] std::span<std::size_t>
get_span()
const
74 KOKKOS_INLINE_FUNCTION
void clear()
const
85 template <EventType event> [[nodiscard]]
constexpr std::size_t
get()
const
88 "Count is not a valid event");
99 template <EventType event>
100 KOKKOS_FORCEINLINE_FUNCTION
constexpr void incr()
const
103 "Count is not a valid event");
107 template <EventType event>
108 KOKKOS_FORCEINLINE_FUNCTION
constexpr void add(
size_t val)
const
111 "Count is not a valid event");
115 template <EventType event>
116 KOKKOS_FORCEINLINE_FUNCTION
constexpr void wrap_incr()
const
118 if constexpr (AutoGenerated::FlagCompileTime::enable_event_counter)
132 template <
class Archive>
void save(Archive& ar)
const
134 std::array<std::size_t, number_event_type> array{};
138 std::copy(rd.begin(), rd.end(), array.begin());
139 assert(rd[0] ==
_events[0] && rd[0] == array[0]);
144 template <
class Archive>
void load(Archive& ar)
147 std::array<std::size_t, number_event_type> array{};
152 std::copy(array.begin(), array.end(), rd.begin());
Namespace that contains classes and structures related to Monte Carlo (MC) simulations.
Definition alias.hpp:11
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:42
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:35
Use to count events that occurs during Monte-Carlo processing cycles.
Definition events.hpp:44
KOKKOS_FORCEINLINE_FUNCTION constexpr void wrap_incr() const
Definition events.hpp:116
std::span< std::size_t > get_span() const
Get std const view of _events counter.
Definition events.hpp:64
void save(Archive &ar) const
Definition events.hpp:132
constexpr std::size_t get() const
Getter to specific event counter.
Definition events.hpp:85
KOKKOS_FORCEINLINE_FUNCTION constexpr void incr() const
Increment specific event counter.
Definition events.hpp:100
EventContainer()
Default container, initalise counter.
Definition events.hpp:56
KOKKOS_INLINE_FUNCTION void clear() const
Reset counters.
Definition events.hpp:74
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:108
Kokkos::View< std::size_t[number_event_type], Kokkos::SharedSpace > _events
Definition events.hpp:51
void load(Archive &ar)
Definition events.hpp:144