16#ifndef PECLET_CORE_HALO_NBX_HPP
17#define PECLET_CORE_HALO_NBX_HPP
48 "NBX round tags must stay within the MPI-guaranteed tag space");
56 const long round = flag ?
reinterpret_cast<long>(attr) : 0;
95 template <
typename PackNext,
typename OnRecv>
96 void exchange(PackNext&& packNext, OnRecv&& onRecv,
int baseTag = 0) {
99 std::vector<std::unique_ptr<std::vector<char>>> sendBufs;
100 std::vector<MPI_Request> sendReqs;
102 auto buf = std::make_unique<std::vector<char>>();
103 int dest = packNext(*buf);
107 MPI_Issend(buf->data(),
static_cast<int>(buf->size()),
MPI_BYTE, dest, tag, comm_, &req);
108 sendBufs.push_back(std::move(buf));
109 sendReqs.push_back(req);
113 bool barrierStarted =
false;
116 std::vector<char> recvBuf;
124 recvBuf.resize(count);
130 if (!barrierStarted) {
132 MPI_Testall(
static_cast<int>(sendReqs.size()), sendReqs.data(), &allSent,
136 barrierStarted =
true;
void exchange(PackNext &&packNext, OnRecv &&onRecv, int baseTag=0)
NbxEngine(MPI_Comm comm=MPI_COMM_WORLD)
int MPI_Comm_size(MPI_Comm, int *s)
int MPI_Comm_get_attr(MPI_Comm c, int keyval, void *val, int *flag)
int MPI_Testall(int, MPI_Request *, int *flag, MPI_Status *)
int MPI_Comm_set_attr(MPI_Comm c, int keyval, void *val)
#define MPI_STATUS_IGNORE
int MPI_Iprobe(int, int, MPI_Comm, int *flag, MPI_Status *)
int MPI_Recv(void *, int, MPI_Datatype, int, int, MPI_Comm, MPI_Status *)
#define MPI_STATUSES_IGNORE
int MPI_Ibarrier(MPI_Comm, MPI_Request *)
int MPI_Get_count(const MPI_Status *, MPI_Datatype, int *c)
int MPI_Issend(const void *, int, MPI_Datatype, int, int, MPI_Comm, MPI_Request *)
int MPI_Comm_rank(MPI_Comm, int *r)
#define MPI_COMM_NULL_COPY_FN
#define MPI_COMM_NULL_DELETE_FN
int MPI_Comm_create_keyval(MPI_Comm_copy_attr_function *, MPI_Comm_delete_attr_function *, int *keyval, void *)
int MPI_Test(MPI_Request *, int *flag, MPI_Status *)
#define MPI_KEYVAL_INVALID
constexpr int kNbxTagBase
constexpr long kNbxRoundTags
Per-communicator round counter, kept as an MPI attribute so it lives and dies with the communicator (...
constexpr int kNbxFamilies
int nbxRoundTag(MPI_Comm comm, int baseTag)