6#ifndef DIST_DATA_COLLECTOR
7#define DIST_DATA_COLLECTOR
22 std::size_t numChunks;
28 double* collectedData;
36 const double BAD_VALUE = std::numeric_limits<double>::quiet_NaN();
70 MPI_Win_lock_all(MPI_MODE_NOCHECK, this->win);
77 MPI_Win_flush_all(this->win);
84 MPI_Win_unlock_all(this->win);
93 void put(
int chunkId,
const double* data);
102 void inline putAsync(
int chunkId,
const double* data) {
103 MPI_Put(data, this->numSize, MPI_DOUBLE, 0, chunkId * this->numSize, this->numSize, MPI_DOUBLE, this->win);
112 std::vector<double>
get(
int chunkId);
120 void get(
int chunkId,
double* buffer);
129 void inline getAsync(
int chunkId,
double* buffer) {
130 MPI_Get(buffer, this->numSize, MPI_DOUBLE, 0, chunkId * this->numSize, this->numSize, MPI_DOUBLE, this->win);
139 return this->collectedData;
147 return this->numChunks;
155 return this->numSize;
162 if (this->win != MPI_WIN_NULL) {
163 MPI_Win_free(&this->win);
DistDataCollector is a class that collects data stored on multiple MPI processes into a large array s...
Definition DistDataCollector.h:14
void fence()
Definition DistDataCollector.cpp:39
void endEpoch()
End an epoch for RMA operations.
Definition DistDataCollector.h:83
void put(int chunkId, const double *data)
Put the local data into the collected array.
Definition DistDataCollector.cpp:44
int getNumSize() const
Definition DistDataCollector.h:154
std::vector< double > get(int chunkId)
Get a slice of the remote, collected array to the local worker.
Definition DistDataCollector.cpp:60
void startEpoch()
Start an epoch for RMA operations.
Definition DistDataCollector.h:68
double * getCollectedDataPtr()
Definition DistDataCollector.h:138
void putAsync(int chunkId, const double *data)
Put the local data into the collected array (non-blocking).
Definition DistDataCollector.h:102
void free()
Free the MPI window and empty the collected data.
Definition DistDataCollector.h:161
void flush()
Ensure that all RMA operations are completed.
Definition DistDataCollector.h:76
int getNumChunks() const
Definition DistDataCollector.h:146
void getAsync(int chunkId, double *buffer)
Get a slice of the remote, collected array to the local worker (non-blocking).
Definition DistDataCollector.h:129
~DistDataCollector()
Destructor.
Definition DistDataCollector.cpp:28
DistDataCollector(MPI_Comm comm, int numChunks, int numSize)
Constructor.
Definition DistDataCollector.cpp:8
MPI_Win & getWin()
Definition DistDataCollector.h:54