MCPcopy Create free account
hub / github.com/FEniCS/dolfinx / local_range

Function local_range

cpp/dolfinx/common/MPI.h:89–105  ·  view source on GitHub ↗

@brief Return local range for the calling process, partitioning the global [0, N - 1] range across all ranks into partitions of almost equal size. @param[in] rank MPI rank of the caller @param[in] N The value to partition. @param[in] size Number of MPI ranks across which to partition `N`.

Source from the content-addressed store, hash-verified

87/// @param[in] N The value to partition.
88/// @param[in] size Number of MPI ranks across which to partition `N`.
89constexpr std::array<std::int64_t, 2> local_range(int rank, std::int64_t N,
90 int size)
91{
92 assert(rank >= 0);
93 assert(N >= 0);
94 assert(size > 0);
95
96 // Compute number of items per rank and remainder
97 const std::int64_t n = N / size;
98 const std::int64_t r = N % size;
99
100 // Compute local range
101 if (rank < r)
102 return {rank * (n + 1), rank * (n + 1) + n + 1};
103 else
104 return {rank * n + r, rank * n + r + n};
105}
106
107/// @brief Return which rank owns index in global range [0, N - 1]
108/// (inverse of MPI::local_range).

Callers 11

create_geomFunction · 0.85
build_tetFunction · 0.85
build_hexFunction · 0.85
build_prismFunction · 0.85
compute_distances_gjkFunction · 0.85
get_datasetFunction · 0.85
read_meshFunction · 0.85
distribute_to_postofficeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected