Loading...
Searching...
No Matches
OracleBatch.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright (c) gpridge developers
3// See LICENSE for details.
4
5#ifndef GPR_POTENTIALS_ORACLEBATCH_H_
6#define GPR_POTENTIALS_ORACLEBATCH_H_
7
8#include <Eigen/Dense>
9#include <string>
10#include <vector>
11
12#ifdef GPR_HAVE_MPI
13#include <mpi.h>
14#endif
15
34namespace pot {
35
36#ifdef GPR_HAVE_MPI
37using OracleBatchComm = MPI_Comm;
38#else
39using OracleBatchComm = int;
40#endif
41
44
47 int rank = 0;
48 int nprocs = 1;
57 Eigen::Index chunk = 0;
61 int owner_offset = 0;
63
65 static OracleBatchLayout world(Eigen::Index chunk = 0,
66 int owner_offset = 0);
67};
68
70int oracleBatchOwner(Eigen::Index point, Eigen::Index count,
71 const OracleBatchLayout& layout) noexcept;
72
74std::vector<std::vector<Eigen::Index>> ownedOracleGroups(
75 Eigen::Index count, const OracleBatchLayout& layout);
76
78enum class OracleBatchStatus : int {
79 Ok = 0,
81 Failed = 1,
86};
87
95
99 const std::string& local_message,
100 const OracleBatchLayout& layout);
101
106void allreduceOwnedOracleValues(std::vector<double>& energies,
107 Eigen::MatrixXd& gradients,
108 const OracleBatchLayout& layout,
109 double* communication_seconds = nullptr);
110
115void allreduceOwnedOracleMask(std::vector<char>& accepted,
116 const OracleBatchLayout& layout);
117
118} // namespace pot
119
120#endif // GPR_POTENTIALS_ORACLEBATCH_H_
Potential wrappers and the batched oracle interface.
void allreduceOwnedOracleMask(std::vector< char > &accepted, const OracleBatchLayout &layout)
OracleBatchStatus
What one rank reports about its groups before the value collectives.
Definition OracleBatch.h:78
@ Restart
The oracle asked for a session restart; takes precedence.
Definition OracleBatch.h:83
@ WallClockLimit
The enclosing search deadline expired; no further point may start.
Definition OracleBatch.h:85
@ Failed
A geometry was refused or a value was not finite; message set.
Definition OracleBatch.h:81
int OracleBatchComm
Definition OracleBatch.h:39
OracleBatchComm oracleBatchWorld() noexcept
The communicator of the whole run, or the no-MPI placeholder.
OracleBatchOutcome agreeOracleBatchStatus(OracleBatchStatus local_status, const std::string &local_message, const OracleBatchLayout &layout)
std::vector< std::vector< Eigen::Index > > ownedOracleGroups(Eigen::Index count, const OracleBatchLayout &layout)
The groups this rank evaluates, each one batch call, in point order.
int oracleBatchOwner(Eigen::Index point, Eigen::Index count, const OracleBatchLayout &layout) noexcept
Owner rank of one point of a batch of count points.
void allreduceOwnedOracleValues(std::vector< double > &energies, Eigen::MatrixXd &gradients, const OracleBatchLayout &layout, double *communication_seconds)
How a step's oracle points are shared out.
Definition OracleBatch.h:46
OracleBatchComm comm
Definition OracleBatch.h:62
static OracleBatchLayout world(Eigen::Index chunk=0, int owner_offset=0)
The layout of the running communicator (rank 0 of 1 without MPI).
std::string message
The failing owner's message, identical on every rank.
Definition OracleBatch.h:91
int owner
The lowest rank that failed, or -1.
Definition OracleBatch.h:93
OracleBatchStatus status
Definition OracleBatch.h:89