Fenix @develop
 
Loading...
Searching...
No Matches
irecv_log.h
1#ifndef FENIX_LOGGING_OPS_IRECV_LOG_H
2#define FENIX_LOGGING_OPS_IRECV_LOG_H
3
4#include <cstring>
5#include <string>
6#include <mpi.h>
7#include "fenix/mpi_util.hpp"
8
9namespace fenix::logging {
10
11struct IrecvLog {
12 IrecvLog() = default;
13 IrecvLog(void* b, int c, MPI_Datatype d, int t, MPI_Request* r)
14 : buf(b), count(c), datatype(d), tag(t), request(r) {}
15 IrecvLog& operator=(const IrecvLog& o) {
16 buf = o.buf;
17 count = o.count;
18 datatype = o.datatype;
19 tag = o.tag;
20 request = o.request;
21 return *this;
22 }
23
24 void* buf = nullptr;
25 int count = -1;
26 MPI_Datatype datatype;
27 int tag = -1;
28 MPI_Request* request = nullptr;
29
30 int irecv(int src, MPI_Comm comm) {
31 fenix_assert(*this);
32 return PMPI_Irecv(buf, count, datatype, src, tag, comm, request);
33 }
34 bool operator==(MPI_Request* const& r) const { return request == r; }
35 void reset() { *this = IrecvLog(); }
36 operator bool() const { return request != nullptr; }
37 std::string str() const {
38 return "Recv 0x" + std::to_string((uintptr_t)request) + " (tag " +
39 std::to_string(tag) + ")";
40 }
41};
42
43} //namespace fenix::logging
44#endif
Definition irecv_log.h:11