-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added non-blocking root communicator #1478
base: develop
Are you sure you want to change the base?
added non-blocking root communicator #1478
Conversation
Unit testing and documentation will be added to this PR in follow-up commits. |
src/axom/lumberjack/MPIUtility.cpp
Outdated
MPI_Status mpiStatus; | ||
|
||
// Get size and source of MPI message | ||
int mpiFlag = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment here and below. You could define static constexpr integer variables that use names containing true and false to make the code more readable and avoid magic numbers.
src/axom/lumberjack/MPIUtility.cpp
Outdated
|
||
// Get size and source of MPI message | ||
int mpiFlag = true; | ||
MPI_Iprobe(MPI_ANY_SOURCE, tag, comm, &mpiFlag, &mpiStatus); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MPI_Iprobe
is nonblocking here, so is there a chance the mpiFlag
is not set to true
when it is expected to be? Would it be better to have this be a blocking MPI_Probe
? Basing this comment off this stackoverflow post: https://stackoverflow.com/questions/43823458/mpi-iprobe-vs-mpi-probe
Additionally, if using MPI_Iprobe
, should mpiFlag
default be set to false
, so it can be set to true
only by a successful function call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the mpiFlag will be set in either context to either true or false, but to your point, it is safer to initialize this as false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The stackoverflow example illustrates an interesting but slightly different approach than what I'm intending to do. They are calling MPI_Iprobe in a while loop that does not exit until it returns a flag that is non-zero. In my case, I am checking to see if any messages need to be received only once, and if there are no messages, the function exits by returning nullptr. This intent in the stackoverflow example is to continuously monitor the status, whereas I'm only intending to periodically monitor the status whenever the code path enters into this function. Both could be relevant to the problem I'm trying to solve with this communicator, where the root rank needs to receive information from other ranks that they are aborting. I had a preference toward the latter option (periodically monitoring the status whenever the root rank reaches a point where it enters this code path) because it seemed to me like the more efficient option, even if it comes at a cost of sometimes not receiving the status before the program aborts. But I'm not really sure which option is best for this scenario. I'd be curious to hear your thoughts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a preference toward the latter option (periodically monitoring the status whenever the root rank reaches a point where it enters this code path) because it seemed to me like the more efficient option, even if it comes at a cost of sometimes not receiving the status before the program aborts.
I agree, I would expect the latter option to have less overhead, doing a single poll with MPI_Iprobe
instead of spinning on MPI_Iprobe
until status is updated in the former case. Nevertheless, I might not be considering something, so am also curious if others have ideas.
7921ec5
to
926fd00
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
…or to NonCollectiveRootCommunicator
… and added unit testing
1b09d37
to
0c0da25
Compare
src/axom/lumberjack/tests/lumberjack_NonCollectiveRootCommunicator.hpp
Outdated
Show resolved
Hide resolved
Co-authored-by: Chris White <white238@llnl.gov>
Co-authored-by: Chris White <white238@llnl.gov>
…ator.hpp Co-authored-by: Chris White <white238@llnl.gov>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The axom team needs to discuss the implications of this further before this is merged.
@white238 @bmhan12 I talked with @gunney1 and we decided the best path forward is to duplicate the MPI communicator passed in the initialize() call, and have this duplicate owned by the Lumberjack communicator object. With this change, we can avoid having to create MPI tags for each non-collective communicator object, and instead have each communicator object have its own MPI communicator using the same default MPI tag. Please let me know if you have any further concerns. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @gberg617
Sounds like we'll need to discuss some details before merging this. I've added a few minor comments in the meantime.
@@ -0,0 +1,135 @@ | |||
// Copyright (c) 2017-2024, Lawrence Livermore National Security, LLC and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After merging in develop
, please run our update_copyright_script
to update the copyright on the new files to 2025.
See: https://github.com/LLNL/axom/blob/develop/scripts/update_copyright_date.sh
* \param [in] ranksLimit Limit on how many ranks are individually tracked per | ||
* Message. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion:
* \param [in] ranksLimit Limit on how many ranks are individually tracked per | |
* Message. | |
* \param [in] ranksLimit Upper limit on number of ranks are tracked per Message. |
MPI_Comm_dup(comm, &m_mpiComm); | ||
MPI_Comm_rank(m_mpiComm, &m_mpiCommRank); | ||
MPI_Comm_size(m_mpiComm, &m_mpiCommSize); | ||
m_ranksLimit = ranksLimit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Presumably, this needs to be a positive number greater than or equal to 1. Should we check it w/ a SLIC_ASSERT
?
* MPI communication uses default LJ_Tag. | ||
***************************************************************************** | ||
*/ | ||
const char* mpiNonBlockingReceiveMessages(MPI_Comm comm); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we update the docs for this function (and mpiBlockingReceiveMessages
) to indicate that the caller is responsible for deallocating the memory in the returned pointer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gberg617 We should update docs as @kennyweiss suggested.
/*! | ||
***************************************************************************** | ||
* \brief Receives any Message sent to this rank, if there are any messages | ||
* that are sent. Returns null if no messages are sent. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we return from a non-blocking probe, there could be sent messages that haven't arrived yet. I suggest replacing "are sent" with "have arrived." It's pedantic but can avoid confusion when the unexpected happens.
{ | ||
currPackedMessages = mpiNonBlockingReceiveMessages(m_mpiComm); | ||
|
||
if(isPackedMessagesEmpty(currPackedMessages)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks odd to me that currPackedMessages
is used before checking if it's null.
Update on the failing tests: The multiple_communicators test I added sporadically fails on Azure. This test is important to capture certain behavior when multiple communicators are sending/receiving messages. Looking into this, it sometimes fails when run with other unit tests (and only on Azure), but consistently passes when it is run by itself. I have heard that gtest+MPI is somewhat fragile in some cases, so I attempted to remove gtest from the tests I added by converting the ASSERT macros to my own version, and having each test become a function that is called within |
For reference, this is the error that is seen on Azure Pipelines and when ran locally in Docker:
|
src/axom/lumberjack/tests/lumberjack_NonCollectiveRootCommunicator.hpp
Outdated
Show resolved
Hide resolved
…ator.hpp attempting to fix sporadic failures on Azure. Co-authored-by: Brian Han <han12@llnl.gov>
Summary
This PR is a feature which adds a communicator for sending messages from any rank to the root rank non-collectively. This can be useful in cases where an arbitrary rank throws an error that needs to be sent to the root rank to output to a file.