Skip to content

Commit

Permalink
#1909: Cache the communicator
Browse files Browse the repository at this point in the history
  • Loading branch information
lifflander authored and PhilMiller committed Aug 30, 2022
1 parent 825ce69 commit 287fd57
Show file tree
Hide file tree
Showing 3 changed files with 10 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
14 changes: 8 additions & 6 deletions src/vt/messaging/active.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ void ActiveMessenger::startup() {
bare_handler_dummy_elm_id_for_lb_data_ =
elm::ElmIDBits::createBareHandler(this_node);

comm_ = theContext()->getComm();

#if vt_check_enabled(lblite)
// Hook to collect LB data about objgroups
thePhase()->registerHookCollective(phase::PhaseHook::DataCollection, [this]{
Expand Down Expand Up @@ -370,7 +372,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 +608,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 +708,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 +793,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 +1029,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 +1053,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
1 change: 1 addition & 0 deletions src/vt/messaging/active.h
Original file line number Diff line number Diff line change
Expand Up @@ -1785,6 +1785,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 287fd57

Please sign in to comment.