Skip to content

Commit 2d0108d

Browse files
committed
re-implemented the free method
1 parent 0ad8b23 commit 2d0108d

3 files changed

Lines changed: 19 additions & 15 deletions

File tree

src/DistDataCollector.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,11 @@ class DistDataCollector {
157157
/**
158158
* @brief Free the MPI window and empty the collected data
159159
*/
160-
void free() { // This should be removed
161-
// if (this->win != MPI_WIN_NULL) {
162-
// MPI_Win_free(&this->win);
163-
// }
164-
// No need to free the data, MPI_Win_free will free the pointer
160+
void free() { // Should this be removed and just implemented in the destructor?
161+
if (this->win != MPI_WIN_NULL) {
162+
MPI_Win_free(&this->win);
163+
}
164+
//No need to free the data, MPI_Win_free will free the pointer
165165
//MPI_Free_mem(this->collectedData);
166166
}
167167

tests/testAsyncPutGet.cxx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,20 @@ void testPutGet(int num_chunks, int num_size, int ms) {
141141
// make sure data has been initialized before remote memory accesses are issued
142142
MPI_Barrier(MPI_COMM_WORLD);
143143

144+
std::vector<double> localData(num_size);
145+
dataCollector1.fence();
144146
if (rank > 0) {
145147
int chunk_id = rank;
146-
std::vector<double> localData(num_size);
147-
148-
dataCollector1.get(chunk_id, localData.data());
148+
dataCollector1.getAsync(chunk_id, localData.data());
149+
}
150+
dataCollector1.fence();
149151

150-
dataCollector2.put(chunk_id, localData.data());
152+
dataCollector2.fence();
153+
if (rank > 0) {
154+
int chunk_id = rank;
155+
dataCollector2.putAsync(chunk_id, localData.data());
151156
}
157+
dataCollector2.fence();
152158

153159
MPI_Barrier(MPI_COMM_WORLD);
154160

@@ -161,7 +167,7 @@ void testPutGet(int num_chunks, int num_size, int ms) {
161167
for (auto i = 0; i < num_chunks; ++i) {
162168

163169
// fetch a chunk asynchronously
164-
dataCollector2.get(i, localData.data());
170+
dataCollector2.getAsync(i, localData.data());
165171

166172
// ... do some work ...
167173
std::this_thread::sleep_for(std::chrono::milliseconds(ms));

tests/testDistDataCollector.cxx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void test(int numSize, int numChunksPerRank) {
3333
}
3434

3535
// Make sure all the chunks have been received. All the above "put" operations
36-
// must have completed. Now the data cane be read.
36+
// must have completed. Now the data can be read.
3737
ddc.fence();
3838

3939
double toc = MPI_Wtime();
@@ -49,19 +49,17 @@ void test(int numSize, int numChunksPerRank) {
4949
std::vector<double> localData = ddc.get(chunkId);
5050

5151
for (auto val : localData) {
52-
//assert(val == chunkId); // this sometimes fails
5352
if (val != chunkId) {
5453
std::cout << "rank = " << rank << " val = " << val << " should have been " << chunkId << '\n';
5554
}
55+
assert(val == chunkId);
5656
}
5757
}
5858

5959
double toc = MPI_Wtime();
6060
timeGet += toc - tic;
6161
}
6262

63-
MPI_Barrier(MPI_COMM_WORLD);
64-
6563
if (rank == 0) {
6664
int numChunk = ddc.getNumChunks();
6765
int numSize = ddc.getNumSize();
@@ -98,7 +96,7 @@ int main(int argc, char* argv[]) {
9896

9997
// Parse the command line arguments
10098
CmdLineArgParser cmdLine;
101-
cmdLine.set("-numSize", 15000, "Size of the data to put/get");
99+
cmdLine.set("-numSize", 100000, "Size of the data to put/get");
102100
cmdLine.set("-numChunksPerRank", 1, "Number of chunks per rank");
103101
bool success = cmdLine.parse(argc, argv);
104102
bool help = cmdLine.get<bool>("-help") || cmdLine.get<bool>("-h");

0 commit comments

Comments
 (0)