17#include "rgpot/CalculatorGroup.hpp"
21extern "C" void __gcov_dump(
void);
29int agree(
const char *local,
char *shared, std::size_t cap) {
31 MPI_Initialized(&inited);
33 MPI_Init(
nullptr,
nullptr);
34 ::rgpot::finalizeMpiAtExit();
35 const std::size_t localLen = local ==
nullptr ? 0 : std::strlen(local);
36 const int ok = localLen == 0 ? 1 : 0;
38 MPI_Allreduce(&ok, &all_ok, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD);
45 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
46 MPI_Comm_size(MPI_COMM_WORLD, &size);
47 const int mine = ok ? size : rank;
49 MPI_Allreduce(&mine, &owner, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD);
52 len =
static_cast<int>(std::min(localLen, std::size_t{4095}));
53 MPI_Bcast(&len, 1, MPI_INT, owner, MPI_COMM_WORLD);
54 std::vector<char> buf(
static_cast<std::size_t
>(len) + 1,
'\0');
55 if (rank == owner && len > 0)
56 std::memcpy(buf.data(), local,
static_cast<std::size_t
>(len));
58 MPI_Bcast(buf.data(), len, MPI_CHAR, owner, MPI_COMM_WORLD);
60 const std::size_t n = std::min(
static_cast<std::size_t
>(len), cap - 1);
61 std::memcpy(shared, buf.data(), n);
71void hardExit(
int status,
void *) {
77 MPI_Initialized(&inited);
78 MPI_Finalized(&finalized);
79 if (inited && !finalized) {
80 if (::rgpot::mpiAbortRequested()) {
82 MPI_Abort(MPI_COMM_WORLD, status != 0 ? status : 1);
const EonRgpotGroupMpi * eon_rgpot_group_mpi_v1()
#define EON_RGPOT_GROUP_MPI_VERSION
Function table of librgpot_pot_mpi, the MPI half of RgpotPot's calculator groups.