GPRidge v1.0.0
GPR-accelerated saddle point searches on potential energy surfaces
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
BlockOwnership.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
// Copyright (c) gpridge developers
3
// See LICENSE for details.
4
#pragma once
5
6
// Round-robin MPI block ownership for distributed covariance assembly.
7
// Pure predicate: no I/O, no DistributedState — callers supply rank/nprocs
8
// and a loop-local block counter.
9
10
namespace
gpr
{
11
12
// Invariant:
13
// - When serial_per_rank is false (reduce mode): every block_idx is owned
14
// by exactly one rank, namely rank == (block_idx % nprocs). This one-
15
// owner-per-block disjointness makes Allreduce / disjoint_sum_bcast
16
// assemblies exact.
17
// - When serial_per_rank is true: every rank owns every block (each rank
18
// computes the full matrix locally; no collective reduce).
19
//
20
// Requires nprocs >= 1. The predicate is block_idx % nprocs == rank in
21
// reduce mode and always true in serial mode.
22
[[nodiscard]]
inline
bool
ownsBlock
(
long
block_idx,
int
rank,
int
nprocs,
23
bool
serial_per_rank)
24
{
25
if
(serial_per_rank)
return
true
;
26
return
(block_idx % nprocs) == rank;
27
}
28
29
// Adapter for call sites that gate on do_reduce (true => reduce mode).
30
// Equivalent to ownsBlock(block_idx, rank, nprocs, /*serial=*/!do_reduce).
31
[[nodiscard]]
inline
bool
ownsBlockIfReduce
(
long
block_idx,
int
rank,
32
int
nprocs,
bool
do_reduce)
33
{
34
return
ownsBlock
(block_idx, rank, nprocs,
/*serial_per_rank=*/
!do_reduce);
35
}
36
37
}
// namespace gpr
gpr
Gaussian-process regression, kernels, priors, and the searches that run on the surrogate.
Definition
Macros.h:16
gpr::ownsBlock
bool ownsBlock(long block_idx, int rank, int nprocs, bool serial_per_rank)
Definition
BlockOwnership.h:22
gpr::ownsBlockIfReduce
bool ownsBlockIfReduce(long block_idx, int rank, int nprocs, bool do_reduce)
Definition
BlockOwnership.h:31
gpr
ml
BlockOwnership.h
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf