VIPRA Documentation
Loading...
Searching...
No Matches
ps_util.hpp
1#pragma once
2
3#include <cstddef>
4
5namespace VIPRA {
6[[nodiscard]] inline auto sim_count(size_t rank, size_t size,
7 size_t totSimCount) -> size_t
8{
9 size_t localCount = totSimCount / size;
10 if ( rank < totSimCount % size ) {
11 ++localCount;
12 }
13
14 return localCount;
15}
16
17[[nodiscard]] inline auto start_sim_id(size_t rank, size_t size,
18 size_t totSimCount) -> size_t
19{
20 size_t idx = rank * sim_count(rank, size, totSimCount);
21 if ( rank >= totSimCount % size ) {
22 idx += totSimCount % size;
23 }
24
25 return idx;
26}
27} // namespace VIPRA