Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
Public Member Functions | List of all members
shamalgs::collective::InvariantParallelGenerator< Engine > Class Template Reference

A parallel generator that will spit the same sequence regardless of the number of ranks. More...

#include <shamalgs/include/shamalgs/collective/InvariantParallelGenerator.hpp>

Public Member Functions

 InvariantParallelGenerator (Engine eng, u64 nval_max=u64_max)
 
 InvariantParallelGenerator (u64 seed, u64 nval_max=u64_max)
 
std::vector< u64next_n (u64 val_count, bool sequential=false)
 Generate the next val_count values.
 
bool is_done ()
 quite explicit isn't it ?
 
bool all_ranks_are_in_sync ()
 check if all ranks have the same generator state
 

Detailed Description

template<class Engine = std::mt19937_64>
class shamalgs::collective::InvariantParallelGenerator< Engine >

A parallel generator that will spit the same sequence regardless of the number of ranks.

Definition at line 28 of file InvariantParallelGenerator.hpp.

Constructor & Destructor Documentation

◆ InvariantParallelGenerator() [1/2]

template<class Engine = std::mt19937_64>
shamalgs::collective::InvariantParallelGenerator< Engine >::InvariantParallelGenerator ( Engine  eng,
u64  nval_max = u64_max 
)
inline

Definition at line 94 of file InvariantParallelGenerator.hpp.

◆ InvariantParallelGenerator() [2/2]

template<class Engine = std::mt19937_64>
shamalgs::collective::InvariantParallelGenerator< Engine >::InvariantParallelGenerator ( u64  seed,
u64  nval_max = u64_max 
)
inline

Definition at line 101 of file InvariantParallelGenerator.hpp.

Member Function Documentation

◆ all_ranks_are_in_sync()

template<class Engine = std::mt19937_64>
bool shamalgs::collective::InvariantParallelGenerator< Engine >::all_ranks_are_in_sync ( )
inline

check if all ranks have the same generator state

Definition at line 132 of file InvariantParallelGenerator.hpp.

+ Here is the call graph for this function:

◆ is_done()

template<class Engine = std::mt19937_64>
bool shamalgs::collective::InvariantParallelGenerator< Engine >::is_done ( )
inline

quite explicit isn't it ?

Definition at line 129 of file InvariantParallelGenerator.hpp.

◆ next_n()

template<class Engine = std::mt19937_64>
std::vector< u64 > shamalgs::collective::InvariantParallelGenerator< Engine >::next_n ( u64  val_count,
bool  sequential = false 
)
inline

Generate the next val_count values.

Parameters
val_countthe number of values to generate
sequentialif true, the values are generated sequentially on all ranks, otherwise in parallel on all ranks
Returns
std::vector<u64> the generated values (max size is val_count) actual size depends on the number of remaining values

If sequential is true, the values are generated sequentially on all ranks. If sequential is false, the values are generated in parallel on all ranks.

Note
allgatherv(next_n(n, false)) == next_n(n,true)
The values are generated in a way that is invariant to the number of ranks.

Definition at line 119 of file InvariantParallelGenerator.hpp.


The documentation for this class was generated from the following file: