Skip to content

Non-Collective Root Communicator Managed MPI Buffer#1908

Draft
gberg617 wants to merge 1 commit into
developfrom
bugfix/bergel1/lumberjack-noncollective-comm-mpi-fix
Draft

Non-Collective Root Communicator Managed MPI Buffer#1908
gberg617 wants to merge 1 commit into
developfrom
bugfix/bergel1/lumberjack-noncollective-comm-mpi-fix

Conversation

@gberg617

@gberg617 gberg617 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

This PR fixes a bug for the NonCollectiveRootCommunicator class where messages it sends may be deleted prior to the send being complete. The NonCollectiveRootCommunicator is used to try to send non-blocking point-to-point messages to the root rank when we know that the job will abort due to an error. In Lumberjack, these sorts of lines in pushMessagesOnce() and pushMessagesFully() may lead to cases where the messages are deleted before the send completes:

    m_communicator->push(packedMessagesToBeSent, receivedPackedMessages);

    if(!m_communicator->isOutputNode() && !isPackedMessagesEmpty(packedMessagesToBeSent))
    {
      delete[] packedMessagesToBeSent;
    }

It's important to keep the MPI sends as non-blocking for this communicator in case the root rank is not able to receive the message. However, we want to prevent cases where the message finishes sending after it's deleted because this will lead to the root rank not receiving a proper message.

The fix being proposed here only applies to the NonCollectiveCommunicator's push() method, and involves copying the message contents into a buffer owned by the NonCollectiveCommunicator stored in a vector of pending messages. Messages will only be sent by this owned communicator, and will be removed from the list of pending messages once we can confirm that the message sending completed.

NOTE: This is still a WIP.
NOTE: PR is Co-authored by Codex

…deleting the buffer before message is finished being sent
@gberg617 gberg617 self-assigned this Jul 8, 2026
@gberg617 gberg617 requested review from bmhan12 and white238 July 9, 2026 00:16

@bmhan12 bmhan12 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this change makes sense, only concern might be if there is significant overhead you've observed with maintaining a buffer of messages.

Comment on lines +152 to +153
void drainCompletedSends();
void releasePendingSends();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add descriptions of what these functions will do.

Comment on lines +95 to +108
drainCompletedSends();
if(isPackedMessagesEmpty(packedMessagesToBeSent) == false)
{
mpiNonBlockingSendMessages(m_mpiComm, 0, packedMessagesToBeSent);
const int messageSize = static_cast<int>(std::strlen(packedMessagesToBeSent));
PendingSend pendingSend;
pendingSend.request = MPI_REQUEST_NULL;
pendingSend.buffer.reset(new char[messageSize + 1]);
std::memcpy(pendingSend.buffer.get(), packedMessagesToBeSent, messageSize + 1);

pendingSend.request =
mpiNonBlockingSendMessagesWithRequest(m_mpiComm, 0, pendingSend.buffer.get());
m_pendingSends.push_back(std::move(pendingSend));
}
drainCompletedSends();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are two drain calls necessary here?

{
void NonCollectiveRootCommunicator::initialize(MPI_Comm comm, int ranksLimit)
{
m_pendingSends.clear();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary? Shouldn't the pending send buffer start in a valid state?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants