BioCMAMC-ST
MC Namespace Reference

Namespace that contains classes and structures related to Monte Carlo (MC) simulations. More...

Namespaces

namespace  Distributions
 Kokkos compatible method to draw from specific probability distribution.
namespace  Impl

Classes

struct  ContribIndexBounds
struct  DomainState
 Structure to store information about domain needed during MC cycle data is likely to change between each iteration. More...
struct  EventContainer
 Use to count events that occurs during Monte-Carlo processing cycles. More...
class  KPRNG
 Utilities and wrap around kokkos random generator. More...
struct  LeavingFlow
 Store position and value of volumic flow at outlet. More...
struct  MonteCarloUnit
 General-purpose Monte Carlo unit to carry out simulations. More...
class  ParticlesContainer
 Main owning object for Monte-Carlo particles. More...
class  ReactorDomain
 Represents the spatial domain where Monte Carlo particles can exist. More...
struct  RuntimeParameters

Typedefs

using ComputeSpace = Kokkos::DefaultExecutionSpace
using HostSpace = Kokkos::DefaultHostExecutionSpace
using ComputeLayout = ComputeSpace::array_layout
template<uint64_t Nd, FloatingPointType F>
using ParticlesModel
template<uint64_t Nc, FloatingPointType F>
using ParticlesContribs
template<FloatingPointType F>
using DynParticlesModel
template<FloatingPointType F>
using DynParticlesContribs
template<typename ExecSpace>
using gen_pool_type = Kokkos::Random_XorShift1024_Pool<ExecSpace>
using pool_type = gen_pool_type<Kokkos::DefaultExecutionSpace>
using generator_type = pool_type::generator_type
using restrict_mt = Kokkos::MemoryTraits<Kokkos::MemoryTraitsFlags::Restrict>
using ParticlePositions = Kokkos::View<uint64_t*, ComputeSpace>
using ParticleStatus = Kokkos::View<Status*, ComputeSpace>
template<FloatingPointType ftype>
using ParticleWeigths = Kokkos::View<ftype*, ComputeSpace>
using ParticleAges = ParticleAgesBase<ComputeSpace>
using ParticleSamples = Kokkos::View<float**, Kokkos::LayoutRight, ComputeSpace>
template<typename MemorySpace>
using ParticlePropertyViewType = Kokkos::View<double**, Kokkos::LayoutRight, MemorySpace>
using PropertySubViewtype
using kernelContribution = Kokkos::View<float**, Kokkos::LayoutLeft, MC::ComputeSpace, kernelMT>
using ContributionView
using KernelConcentrationType
using LocalConcentration = KernelConcentrationType
template<class ExecSpace, bool is_const>
using VolumeView
template<class ExecSpace, bool is_const>
using MoveProbabilityView
 d_t * flow / volume per compartment. Owned by ReactorDomain
template<class ExecSpace, bool is_const>
using DiagonalView
template<bool is_const>
using LeavingFlowView
template<class ExecSpace, bool is_const>
using CumulativeProbabilityView
template<class ExecSpace, bool is_const>
using NeighborsView

Enumerations

enum class  Status : char { Idle = 0 , Division , Exit , Dead }
enum class  EventType : char {
  NewParticle = 0 , Exit , Move , Death ,
  Overflow , ChangeWeight , __COUNT__
}
 Enumeration that represents events that can occurs during a Monte-Carlo cycle. More...

Functions

template<EventType event>
KOKKOS_INLINE_FUNCTION consteval size_t event_index ()
 inline getter, converts event to its value in order to be use as array index
template<typename ViewType>
void first_touch (const ViewType &view, std::size_t begin, std::size_t end, std::size_t npt)
 Write-touch [begin, end) with the move kernel's team decomposition.
template<typename ViewType, typename... Extents>
void resize_first_touch (ViewType &view, std::size_t n_alloc, std::size_t n_live, std::size_t npt, Extents... rest)
 Kokkos::resize, but with the first touch placed by us.
void impl_init (const ExecInfo &info, double &total_mass, uint64_t n_particles, MonteCarloUnit &unit, AutoGenerated::ContainerVariant &&container, bool uniform_init)
void post_init_weight (std::unique_ptr< MonteCarloUnit > &unit, double x0, double total_mass)
template<ModelType Model>
std::unique_ptr< MonteCarloUnitinit (const std::shared_ptr< IO::Logger > &_logger, const ExecInfo &info, uint64_t n_particles, std::size_t seed, std::span< double > volumes, std::span< const size_t > _neighbors, bool uniform_mc_init, double &total_mass)
 Helper function to initialize a MonteCarloUnit.
pool_type get_pool (std::size_t seed=0)
uint64_t master_seed ()
uint64_t next_splitmix64 (uint64_t &x) noexcept
KOKKOS_INLINE_FUNCTION auto sample_random_variables (const pool_type &pool, auto &&functor)
template<class ExecutionSpace, class ViewType, class RandomPool, class IndexType = int64_t, const std::size_t CHUNK_SIZE>
void fill_random (const ExecutionSpace &exec, ViewType a, RandomPool g, typename ViewType::const_value_type begin, typename ViewType::const_value_type end)
RuntimeParameters load_tuning_constant ()

Variables

constexpr size_t number_event_type
constexpr std::size_t event_stride = 64 / sizeof(std::size_t)
 Number of std::size_t slots reserved per counter.

Detailed Description

Namespace that contains classes and structures related to Monte Carlo (MC) simulations.

This namespace encapsulates all the components used in Monte Carlo simulations, including data structures for managing simulation state and results.

Typedef Documentation

◆ ComputeLayout

using MC::ComputeLayout = ComputeSpace::array_layout

◆ ComputeSpace

using MC::ComputeSpace = Kokkos::DefaultExecutionSpace

◆ ContributionView

Initial value:
decltype(Kokkos::Experimental::create_scatter_view(
Kokkos::View< float **, Kokkos::LayoutLeft, MC::ComputeSpace, kernelMT > kernelContribution
Definition alias.hpp:160
Examples
example_model.cxx.

◆ CumulativeProbabilityView

template<class ExecSpace, bool is_const>
using MC::CumulativeProbabilityView
Initial value:
std::conditional_t<
is_const,
Kokkos::View<const double**,
Kokkos::LayoutRight,
ExecSpace,
Kokkos::MemoryTraits<Kokkos::RandomAccess>>,
Kokkos::View<double**, Kokkos::LayoutRight, ExecSpace>>

◆ DiagonalView

template<class ExecSpace, bool is_const>
using MC::DiagonalView
Initial value:
std::conditional_t<
is_const,
Kokkos::View<const double*,
Kokkos::LayoutLeft,
ExecSpace,
Kokkos::MemoryTraits<Kokkos::RandomAccess>>,
Kokkos::View<double*, Kokkos::LayoutLeft, ExecSpace>>

◆ DynParticlesContribs

Initial value:
Kokkos::View<F**,
ComputeSpace::array_layout,
Kokkos::MemoryTraits<Kokkos::MemoryTraitsFlags::Restrict>>
Kokkos::DefaultExecutionSpace ComputeSpace
Definition alias.hpp:17

◆ DynParticlesModel

Initial value:
Kokkos::View<F**,
ComputeSpace::array_layout,
Kokkos::MemoryTraits<Kokkos::MemoryTraitsFlags::Restrict>>

◆ gen_pool_type

template<typename ExecSpace>
using MC::gen_pool_type = Kokkos::Random_XorShift1024_Pool<ExecSpace>

◆ generator_type

using MC::generator_type = pool_type::generator_type

◆ HostSpace

using MC::HostSpace = Kokkos::DefaultHostExecutionSpace

◆ KernelConcentrationType

Initial value:
Kokkos::View<const double**,
Kokkos::LayoutLeft,
Kokkos::MemoryTraits<Kokkos::RandomAccess>>

◆ kernelContribution

using MC::kernelContribution = Kokkos::View<float**, Kokkos::LayoutLeft, MC::ComputeSpace, kernelMT>

◆ LeavingFlowView

template<bool is_const>
using MC::LeavingFlowView
Initial value:
std::conditional_t<
is_const,
Kokkos::View<const LeavingFlow*, Kokkos::SharedHostPinnedSpace>,
Kokkos::View<LeavingFlow*, Kokkos::SharedHostPinnedSpace>>

◆ LocalConcentration

◆ MoveProbabilityView

template<class ExecSpace, bool is_const>
using MC::MoveProbabilityView
Initial value:
std::conditional_t<
is_const,
Kokkos::View<const double*,
ExecSpace,
Kokkos::MemoryTraits<Kokkos::RandomAccess>>,
Kokkos::View<double*, ExecSpace>>

d_t * flow / volume per compartment. Owned by ReactorDomain

◆ NeighborsView

template<class ExecSpace, bool is_const>
using MC::NeighborsView
Initial value:
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>>

◆ ParticleAges

using MC::ParticleAges = ParticleAgesBase<ComputeSpace>

◆ ParticlePositions

using MC::ParticlePositions = Kokkos::View<uint64_t*, ComputeSpace>

◆ ParticlePropertyViewType

template<typename MemorySpace>
using MC::ParticlePropertyViewType = Kokkos::View<double**, Kokkos::LayoutRight, MemorySpace>

◆ ParticleSamples

using MC::ParticleSamples = Kokkos::View<float**, Kokkos::LayoutRight, ComputeSpace>

◆ ParticlesContribs

template<uint64_t Nc, FloatingPointType F>
using MC::ParticlesContribs
Initial value:
Kokkos::View<F* [Nc],
ComputeSpace::array_layout,
Kokkos::MemoryTraits<Kokkos::MemoryTraitsFlags::Restrict>>

◆ ParticlesModel

template<uint64_t Nd, FloatingPointType F>
using MC::ParticlesModel
Initial value:
Kokkos::View<F* [Nd],
ComputeSpace::array_layout,
Kokkos::MemoryTraits<Kokkos::MemoryTraitsFlags::Restrict>>
Examples
example_model.cxx.

◆ ParticleStatus

using MC::ParticleStatus = Kokkos::View<Status*, ComputeSpace>

◆ ParticleWeigths

template<FloatingPointType ftype>
using MC::ParticleWeigths = Kokkos::View<ftype*, ComputeSpace>

◆ pool_type

◆ PropertySubViewtype

Initial value:
Kokkos::Subview<ParticlePropertyViewType<ComputeSpace>,
decltype(Kokkos::ALL),
std::size_t>

◆ restrict_mt

using MC::restrict_mt = Kokkos::MemoryTraits<Kokkos::MemoryTraitsFlags::Restrict>

◆ VolumeView

template<class ExecSpace, bool is_const>
using MC::VolumeView
Initial value:
std::conditional_t<
is_const,
Kokkos::View<const double*,
ExecSpace,
Kokkos::MemoryTraits<Kokkos::RandomAccess>>,
Kokkos::View<double*, ExecSpace>>

Enumeration Type Documentation

◆ EventType

enum class MC::EventType : char
strong

Enumeration that represents events that can occurs during a Monte-Carlo cycle.

Enumerator
NewParticle 

Spawn new particle.

Exit 

Remove particle from list due to move in domain.

Move 

Move in domain.

Death 

Remove particle from list.

Overflow 
ChangeWeight 

Update in weight.

__COUNT__ 

◆ Status

enum class MC::Status : char
strong
Enumerator
Idle 
Division 
Exit 
Dead 
Examples
example_model.cxx.

Function Documentation

◆ event_index()

template<EventType event>
KOKKOS_INLINE_FUNCTION consteval size_t MC::event_index ( )
consteval

inline getter, converts event to its value in order to be use as array index

Here is the caller graph for this function:

◆ fill_random()

template<class ExecutionSpace, class ViewType, class RandomPool, class IndexType = int64_t, const std::size_t CHUNK_SIZE>
void MC::fill_random ( const ExecutionSpace & exec,
ViewType a,
RandomPool g,
typename ViewType::const_value_type begin,
typename ViewType::const_value_type end )

◆ first_touch()

template<typename ViewType>
void MC::first_touch ( const ViewType & view,
std::size_t begin,
std::size_t end,
std::size_t npt )

Write-touch [begin, end) with the move kernel's team decomposition.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_pool()

pool_type MC::get_pool ( std::size_t seed = 0)
Examples
/home/runner/work/BioCMA-MCST/BioCMA-MCST/apps/libs/mc/public/mc/prng/prng.hpp.
Here is the caller graph for this function:

◆ impl_init()

void MC::impl_init ( const ExecInfo & info,
double & total_mass,
uint64_t n_particles,
MonteCarloUnit & unit,
AutoGenerated::ContainerVariant && container,
bool uniform_init )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init()

template<ModelType Model>
std::unique_ptr< MonteCarloUnit > MC::init ( const std::shared_ptr< IO::Logger > & _logger,
const ExecInfo & info,
uint64_t n_particles,
std::size_t seed,
std::span< double > volumes,
std::span< const size_t > _neighbors,
bool uniform_mc_init,
double & total_mass )

Helper function to initialize a MonteCarloUnit.

Since MonteCarloUnit is not a generic type and the model type is resolved at runtime, no constructors are defined to avoid carrying template functions when using the unit. This function wraps the constructor externally, providing a convenient way to initialize a MonteCarloUnit with the appropriate model type and parameters.

Template Parameters
ModelThe particle model type, specified at compile time.
Returns
A unique pointer to the initialized MonteCarloUnit.
Here is the call graph for this function:

◆ load_tuning_constant()

RuntimeParameters MC::load_tuning_constant ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ master_seed()

uint64_t MC::master_seed ( )
Examples
/home/runner/work/BioCMA-MCST/BioCMA-MCST/apps/libs/mc/public/mc/prng/prng.hpp.
Here is the caller graph for this function:

◆ next_splitmix64()

uint64_t MC::next_splitmix64 ( uint64_t & x)
noexcept
Examples
/home/runner/work/BioCMA-MCST/BioCMA-MCST/apps/libs/mc/public/mc/prng/prng.hpp.
Here is the caller graph for this function:

◆ post_init_weight()

void MC::post_init_weight ( std::unique_ptr< MonteCarloUnit > & unit,
double x0,
double total_mass )
Here is the caller graph for this function:

◆ resize_first_touch()

template<typename ViewType, typename... Extents>
void MC::resize_first_touch ( ViewType & view,
std::size_t n_alloc,
std::size_t n_live,
std::size_t npt,
Extents... rest )

Kokkos::resize, but with the first touch placed by us.

Same observable result as Kokkos::resize – contents preserved up to the overlap, remainder zeroed but the pages of the live range are placed by the threads that will read them.

Like Kokkos::resize, this is a no-op when the leading extent already matches: reallocating would throw away the placement it is here to establish.

Parameters
n_livethe range the compute kernels will actually walk, i.e. the used particle count, not the allocation.
nptparticles per team, from KernelDispatchOptions::m_p_p_team_move. It must be what CycleFunctors launches the move kernel with, otherwise the touch and the compute walk the array with different partitions and the whole point is lost.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sample_random_variables()

KOKKOS_INLINE_FUNCTION auto MC::sample_random_variables ( const pool_type & pool,
auto && functor )
Examples
/home/runner/work/BioCMA-MCST/BioCMA-MCST/apps/libs/mc/public/mc/prng/prng.hpp.
Here is the caller graph for this function:

Variable Documentation

◆ event_stride

std::size_t MC::event_stride = 64 / sizeof(std::size_t)
constexpr

Number of std::size_t slots reserved per counter.

Counters are updated with atomics from every thread of the node. Packing them contiguously puts all of them on a single cache line, so unrelated tallies (typically Move and Exit) false-share and serialise against each other. One counter per cache line removes that coupling.

Note
Kokkos::AllowPadding does not help here: it only rounds the leading dimension of a rank>=2 view up to Impl::MEMORY_ALIGNMENT, and its rank-1 specialisation is explicitly the "no padding / striding" one. The stride is instead carried by the layout trait, Kokkos::LayoutStride, which keeps the view rank-1 and lets Kokkos own the offset arithmetic.

◆ number_event_type

size_t MC::number_event_type
constexpr
Initial value:
= static_cast<std::size_t>(
@ __COUNT__
Definition events.hpp:27