Skip to content
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

Add test for mpi_request_null to avoid error in wait[xxx]/test[xxx] when using sessions #12525

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

HawkmoonEternal
Copy link

Issue:
The MPI Standard explicitly allows for MPI_REQUEST_NULL in the list of requests passed to MPI_Wait[xxx]/MPI_Test[xxx].
However, using MPI_Wait[xxx]/MPI_Test[xxx] with a list containing active requests together with null requests leads to the following MPI error:

[n01:00000] *** An error occurred in MPI_Waitall
[n01:00000] *** reported by process [3991601153,3]
[n01:00000] *** on a NULL communicator
[n01:00000] *** Unknown error
[n01:00000] *** MPI_ERRORS_ARE_FATAL (processes in this communicator will now abort,
[n01:00000] ***    and MPI will try to terminate your MPI job as well)
--------------------------------------------------------------------------

Reproducer:
The following code snippet is a minimal reproducer of the issue:

#include "mpi.h"
#include <stdio.h>

int main(int argc, char *argv[]){
    MPI_Request requests[] = {MPI_REQUEST_NULL, MPI_REQUEST_NULL, MPI_REQUEST_NULL};
    MPI_Session session;
    MPI_Group wgroup;
    MPI_Comm wcomm;
    int wrank, wsize;

    MPI_Session_init(MPI_INFO_NULL, MPI_ERRORS_ARE_FATAL, &session);
    MPI_Group_from_session_pset(session, "mpi://WORLD", &wgroup);
    MPI_Comm_create_from_group(wgroup, "test", MPI_INFO_NULL, MPI_ERRORS_RETURN, &wcomm);
    MPI_Comm_size(wcomm, &wsize);
    MPI_Comm_rank(wcomm, &wrank);

    printf("Rank %d isend to rank %d and irecv from rank %d\n", wrank, (wrank + 1) % wsize, (wsize + wrank - 1) % wsize);
    MPI_Isend(&wrank, 1, MPI_INT, (wrank + 1) % wsize, 42, wcomm, &requests[0]);
    MPI_Irecv(&wrank, 1, MPI_INT, (wsize + wrank - 1) % wsize, 42, wcomm, &requests[1]);
    MPI_Waitall(3, requests, MPI_STATUSES_IGNORE); 

    MPI_Session_finalize(&session);

    return 0;
}

Root Cause:
The root cause of the issue is that ompi_comm_instances_same() fails, because MPI_REQUEST_NULL is not associated with a particular instance and therefore the instance is not the same for null requests and valid requests.

Proposed Solution:
This pull request adds a check for ompi_request_null in MPI_Wait[xxx]/MPI_Test[xxx] to avoid it being passed to the ompi_comm_instances_same() check.

Copy link
Contributor

@devreal devreal left a comment

Choose a reason for hiding this comment

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

Thanks for the fix @HawkmoonEternal! Would you mind removing the changes that are not strictly addressing the issue? The change from indx to i is not strictly needed here.

Signed-off-by: HawkmoonEternal <domi.huber@tum.de>
@HawkmoonEternal
Copy link
Author

I removed all changes that are not strictly addressing the issue. I will include these changes in another pull request to address code consistency.

Copy link
Member

@bosilca bosilca left a comment

Choose a reason for hiding this comment

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

I wonder what is ompi_request_empty ? Nothing in the MPI standard related to this, and the documentation in request.c begs for more questions than answers.

@devreal
Copy link
Contributor

devreal commented May 6, 2024

@bosilca AFAIK, this is the request we hand out if the operation completes immediately, e.g., if it fits the eager protocol.

Copy link
Contributor

@devreal devreal left a comment

Choose a reason for hiding this comment

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

@bosilca
Copy link
Member

bosilca commented May 7, 2024

Makes sense, we gain peanuts on the small send but we pay the branching/testing cost for all multiple test/wait requests.

Let's put aside the discussion about performance, the code we have today seems incomplete with regard to sessions because we need to test for all OMPI predefined requests ompi_request_empty, ompi_request_empty_send and ompi_request_null

@devreal
Copy link
Contributor

devreal commented May 7, 2024

You're right that ompi_request_empty_send is missing from that list. Maybe these requests should be caught by the check for the req_mpi_object in the line below the new check. Currently, they are set to comm_world. I'm not sure why. My understanding is that the req_mpi_object is used for error handling but we won't hand out empty/null requests if an error occurred.

Having said that, these checks are not performance critical since they are only done if argument error checking is enabled.

@bosilca
Copy link
Member

bosilca commented May 7, 2024

that's our default. Literally everyone in the world is doing these checks.

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

Successfully merging this pull request may close these issues.

None yet

3 participants