Skip to content

Commit

Permalink
Merge pull request #1925 from DARMA-tasking/1909-cache-the-mpi-commun…
Browse files Browse the repository at this point in the history
…icator-in-am

1909 Cache the MPI communicator in ActiveMessenger
  • Loading branch information
PhilMiller authored Aug 30, 2022
2 parents 825ce69 + f1b75c6 commit ae0086d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/vt/context/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ struct Context : runtime::component::Component<Context> {
NodeType thisNode_ = uninitialized_destination;
NodeType numNodes_ = uninitialized_destination;
WorkerCountType numWorkers_ = no_workers;
MPI_Comm communicator_ = MPI_COMM_WORLD;
MPI_Comm communicator_ = MPI_COMM_NULL;
DeclareClassInsideInitTLS(Context, WorkerIDType, thisWorker_, no_worker_id)
runnable::RunnableNew* cur_task_ = nullptr;
};
Expand Down
16 changes: 10 additions & 6 deletions src/vt/messaging/active.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ ActiveMessenger::ActiveMessenger()
};
}

void ActiveMessenger::initialize() {
comm_ = theContext()->getComm();
}

void ActiveMessenger::startup() {
auto const this_node = theContext()->getNode();
bare_handler_dummy_elm_id_for_lb_data_ =
Expand Down Expand Up @@ -370,7 +374,7 @@ EventType ActiveMessenger::sendMsgMPI(
#endif
int const ret = MPI_Isend(
untyped_msg, small_msg_size, MPI_BYTE, dest, send_tag,
theContext()->getComm(), mpi_event->getRequest()
comm_, mpi_event->getRequest()
);
vtAssertMPISuccess(ret, "MPI_Isend");

Expand Down Expand Up @@ -606,7 +610,7 @@ std::tuple<EventType, int> ActiveMessenger::sendDataMPI(

VT_ALLOW_MPI_CALLS;
int const ret = MPI_Isend(
ptr, subsize, MPI_BYTE, dest, tag, theContext()->getComm(),
ptr, subsize, MPI_BYTE, dest, tag, comm_,
mpi_event->getRequest()
);
vtAssertMPISuccess(ret, "MPI_Isend");
Expand Down Expand Up @@ -706,7 +710,7 @@ bool ActiveMessenger::recvDataMsgBuffer(
VT_ALLOW_MPI_CALLS;
const int probe_ret = MPI_Iprobe(
node == uninitialized_destination ? MPI_ANY_SOURCE : node,
tag, theContext()->getComm(), &flag, &stat
tag, comm_, &flag, &stat
);
vtAssertMPISuccess(probe_ret, "MPI_Iprobe");
}
Expand Down Expand Up @@ -791,7 +795,7 @@ void ActiveMessenger::recvDataDirect(
VT_ALLOW_MPI_CALLS;
int const ret = MPI_Irecv(
cbuf+(i*max_per_send), sublen, MPI_BYTE, from, tag,
theContext()->getComm(), &reqs[i]
comm_, &reqs[i]
);
vtAssertMPISuccess(ret, "MPI_Irecv");
}
Expand Down Expand Up @@ -1027,7 +1031,7 @@ bool ActiveMessenger::tryProcessIncomingActiveMsg() {

MPI_Iprobe(
MPI_ANY_SOURCE, static_cast<MPI_TagType>(MPITag::ActiveMsgTag),
theContext()->getComm(), &flag, &stat
comm_, &flag, &stat
);
}

Expand All @@ -1051,7 +1055,7 @@ bool ActiveMessenger::tryProcessIncomingActiveMsg() {
VT_ALLOW_MPI_CALLS;
MPI_Irecv(
buf, num_probe_bytes, MPI_BYTE, sender, stat.MPI_TAG,
theContext()->getComm(), &req
comm_, &req
);

amPostedCounterGauge.incrementUpdate(num_probe_bytes, 1);
Expand Down
2 changes: 2 additions & 0 deletions src/vt/messaging/active.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ struct ActiveMessenger : runtime::component::PollableComponent<ActiveMessenger>
std::string name() override { return "ActiveMessenger"; }

void startup() override;
void initialize() override;

/**
* \brief Mark a message as a termination message.
Expand Down Expand Up @@ -1785,6 +1786,7 @@ struct ActiveMessenger : runtime::component::PollableComponent<ActiveMessenger>
private:
elm::ElementIDStruct bare_handler_dummy_elm_id_for_lb_data_ = {};
elm::ElementLBData bare_handler_lb_data_;
MPI_Comm comm_ = MPI_COMM_NULL;
};

}} // end namespace vt::messaging
Expand Down

0 comments on commit ae0086d

Please sign in to comment.