Skip to content

Commit

Permalink
requests insert method
Browse files Browse the repository at this point in the history
  • Loading branch information
patflick committed Feb 1, 2017
1 parent 709f722 commit 0fd3d9b
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions include/mxx/future.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,21 @@ class requests {
return m_requests[i];
}

void wait() {
void waitall() {
MPI_Waitall(m_requests.size(), &m_requests[0], MPI_STATUSES_IGNORE);
}

void wait() {
this->waitall();
}

// adds all requests from `r` into this requests object
void insert(requests& r) {
// `steal` the requests
m_requests.insert(m_requests.end(), r.m_requests.begin(), r.m_requests.end());
r.m_requests.clear();
}

bool test() {
int flag;
MPI_Testall(m_requests.size(), &m_requests[0], &flag, MPI_STATUSES_IGNORE);
Expand All @@ -87,11 +98,7 @@ class requests {
// TODO: functions to access/return `MPI_Status`

virtual ~requests() {
// TODO: just use waitall again?
for (MPI_Request& r : m_requests) {
if (r != MPI_REQUEST_NULL)
MPI_Request_free(&r);
}
this->waitall();
}

private:
Expand Down

0 comments on commit 0fd3d9b

Please sign in to comment.