Skip to content

Commit

Permalink
Merge pull request #12691 from bosilca/topic/request_single_instance_fix
Browse files Browse the repository at this point in the history
Check that requests belong to similar sessions
  • Loading branch information
bosilca authored Jul 18, 2024
2 parents 1a60234 + ae5b0f6 commit a6d5b36
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 131 deletions.
6 changes: 1 addition & 5 deletions ompi/communicator/communicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* Copyright (c) 2018-2024 Triad National Security, LLC. All rights
* reserved.
* Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2024 NVIDIA Corporation. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -613,11 +614,6 @@ static inline struct ompi_proc_t* ompi_comm_peer_lookup (const ompi_communicator
return ompi_group_peer_lookup(comm->c_remote_group,peer_id);
}

static inline bool ompi_comm_instances_same(const ompi_communicator_t *comm1, const ompi_communicator_t *comm2)
{
return comm1->instance == comm2->instance;
}

#if OPAL_ENABLE_FT_MPI
/*
* Support for MPI_ANY_SOURCE point-to-point operations
Expand Down
25 changes: 4 additions & 21 deletions ompi/mpi/c/testall.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* and Technology (RIST). All rights reserved.
* Copyright (c) 2021 Triad National Security, LLC. All rights
* reserved.
* Copyright (c) 2024 NVIDIA Corporation. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -57,31 +58,13 @@ int MPI_Testall(int count, MPI_Request requests[], int *flag,
);

if ( MPI_PARAM_CHECK ) {
int i, rc = MPI_SUCCESS;
MPI_Request check_req = NULL;
int rc = MPI_SUCCESS;
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
if( (NULL == requests) && (0 != count) ) {
rc = MPI_ERR_REQUEST;
} else {
for (i = 0; i < count; i++) {
if (NULL == requests[i]) {
rc = MPI_ERR_REQUEST;
break;
}
if (&ompi_request_empty == requests[i]) {
continue;
} else if (NULL == requests[i]->req_mpi_object.comm) {
continue;
} else if (NULL == check_req) {
check_req = requests[i];
}
else {
if (!ompi_comm_instances_same(requests[i]->req_mpi_object.comm,
check_req->req_mpi_object.comm)) {
rc = MPI_ERR_REQUEST;
break;
}
}
if(!ompi_request_check_same_instance(requests, count) ) {
rc = MPI_ERR_REQUEST;
}
}
if ((NULL == flag) || (count < 0)) {
Expand Down
25 changes: 4 additions & 21 deletions ompi/mpi/c/testany.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* and Technology (RIST). All rights reserved.
* Copyright (c) 2021 Triad National Security, LLC. All rights
* reserved.
* Copyright (c) 2024 NVIDIA Corporation. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -56,31 +57,13 @@ int MPI_Testany(int count, MPI_Request requests[], int *indx, int *completed, MP
);

if ( MPI_PARAM_CHECK ) {
int i, rc = MPI_SUCCESS;
MPI_Request check_req = NULL;
int rc = MPI_SUCCESS;
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
if ((NULL == requests) && (0 != count)) {
rc = MPI_ERR_REQUEST;
} else {
for (i = 0; i < count; i++) {
if (NULL == requests[i]) {
rc = MPI_ERR_REQUEST;
break;
}
if (&ompi_request_empty == requests[i]) {
continue;
} else if (NULL == requests[i]->req_mpi_object.comm) {
continue;
} else if (NULL == check_req) {
check_req = requests[i];
}
else {
if (!ompi_comm_instances_same(requests[i]->req_mpi_object.comm,
check_req->req_mpi_object.comm)) {
rc = MPI_ERR_REQUEST;
break;
}
}
if(!ompi_request_check_same_instance(requests, count) ) {
rc = MPI_ERR_REQUEST;
}
}
if (((NULL == indx || NULL == completed) && count > 0) ||
Expand Down
25 changes: 4 additions & 21 deletions ompi/mpi/c/testsome.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* and Technology (RIST). All rights reserved.
* Copyright (c) 2021 Triad National Security, LLC. All rights
* reserved.
* Copyright (c) 2024 NVIDIA Corporation. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -58,31 +59,13 @@ int MPI_Testsome(int incount, MPI_Request requests[],
);

if ( MPI_PARAM_CHECK ) {
int indx, rc = MPI_SUCCESS;
MPI_Request check_req = NULL;
int rc = MPI_SUCCESS;
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
if ((NULL == requests) && (0 != incount)) {
rc = MPI_ERR_REQUEST;
} else {
for (indx = 0; indx < incount; ++indx) {
if (NULL == requests[indx]) {
rc = MPI_ERR_REQUEST;
break;
}
if (&ompi_request_empty == requests[indx]) {
continue;
} else if (NULL == requests[indx]->req_mpi_object.comm) {
continue;
} else if (NULL == check_req) {
check_req = requests[indx];
}
else {
if (!ompi_comm_instances_same(requests[indx]->req_mpi_object.comm,
check_req->req_mpi_object.comm)) {
rc = MPI_ERR_REQUEST;
break;
}
}
if(!ompi_request_check_same_instance(requests, incount) ) {
rc = MPI_ERR_REQUEST;
}
}
if (((NULL == outcount || NULL == indices) && incount > 0) ||
Expand Down
25 changes: 4 additions & 21 deletions ompi/mpi/c/waitall.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* and Technology (RIST). All rights reserved.
* Copyright (c) 2021 Triad National Security, LLC. All rights
* reserved.
* Copyright (c) 2024 NVIDIA Corporation. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -55,31 +56,13 @@ int MPI_Waitall(int count, MPI_Request requests[], MPI_Status statuses[])
);

if ( MPI_PARAM_CHECK ) {
int i, rc = MPI_SUCCESS;
MPI_Request check_req = NULL;
int rc = MPI_SUCCESS;
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
if( (NULL == requests) && (0 != count) ) {
rc = MPI_ERR_REQUEST;
} else {
for (i = 0; i < count; i++) {
if (NULL == requests[i]) {
rc = MPI_ERR_REQUEST;
break;
}
if (&ompi_request_empty == requests[i]) {
continue;
} else if (NULL == requests[i]->req_mpi_object.comm) {
continue;
} else if (NULL == check_req) {
check_req = requests[i];
}
else {
if (!ompi_comm_instances_same(requests[i]->req_mpi_object.comm,
check_req->req_mpi_object.comm)) {
rc = MPI_ERR_REQUEST;
break;
}
}
if(!ompi_request_check_same_instance(requests, count) ) {
rc = MPI_ERR_REQUEST;
}
}
if (count < 0) {
Expand Down
25 changes: 4 additions & 21 deletions ompi/mpi/c/waitany.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* and Technology (RIST). All rights reserved.
* Copyright (c) 2021 Triad National Security, LLC. All rights
* reserved.
* Copyright (c) 2024 NVIDIA Corporation. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -56,31 +57,13 @@ int MPI_Waitany(int count, MPI_Request requests[], int *indx, MPI_Status *status
);

if ( MPI_PARAM_CHECK ) {
int i, rc = MPI_SUCCESS;
MPI_Request check_req = NULL;
int rc = MPI_SUCCESS;
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
if ((NULL == requests) && (0 != count)) {
rc = MPI_ERR_REQUEST;
} else {
for (i = 0; i < count; i++) {
if (NULL == requests[i]) {
rc = MPI_ERR_REQUEST;
break;
}
if (requests[i] == &ompi_request_empty) {
continue;
} else if (NULL == requests[i]->req_mpi_object.comm) {
continue;
} else if (NULL == check_req) {
check_req = requests[i];
}
else {
if (!ompi_comm_instances_same(requests[i]->req_mpi_object.comm,
check_req->req_mpi_object.comm)) {
rc = MPI_ERR_REQUEST;
break;
}
}
if(!ompi_request_check_same_instance(requests, count) ) {
rc = MPI_ERR_REQUEST;
}
}
if ((NULL == indx && count > 0) ||
Expand Down
25 changes: 4 additions & 21 deletions ompi/mpi/c/waitsome.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* and Technology (RIST). All rights reserved.
* Copyright (c) 2021 Triad National Security, LLC. All rights
* reserved.
* Copyright (c) 2024 NVIDIA Corporation. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -58,31 +59,13 @@ int MPI_Waitsome(int incount, MPI_Request requests[],
);

if ( MPI_PARAM_CHECK ) {
int indx, rc = MPI_SUCCESS;
MPI_Request check_req = NULL;
int rc = MPI_SUCCESS;
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
if ((NULL == requests) && (0 != incount)) {
rc = MPI_ERR_REQUEST;
} else {
for (indx = 0; indx < incount; ++indx) {
if (NULL == requests[indx]) {
rc = MPI_ERR_REQUEST;
break;
}
if (&ompi_request_empty == requests[indx]) {
continue;
} else if (NULL == requests[indx]->req_mpi_object.comm) {
continue;
} else if (NULL == check_req) {
check_req = requests[indx];
}
else {
if (!ompi_comm_instances_same(requests[indx]->req_mpi_object.comm,
check_req->req_mpi_object.comm)) {
rc = MPI_ERR_REQUEST;
break;
}
}
if(!ompi_request_check_same_instance(requests, incount) ) {
rc = MPI_ERR_REQUEST;
}
}
if (((NULL == outcount || NULL == indices) && incount > 0) ||
Expand Down
23 changes: 23 additions & 0 deletions ompi/request/request.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* Copyright (c) 2018 Triad National Security, LLC. All rights
* reserved.
* Copyright (c) 2022 IBM Corporation. All rights reserved.
* Copyright (c) 2024 NVIDIA Corporation. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -248,3 +249,25 @@ int ompi_request_persistent_noop_create(ompi_request_t** request)
*request = req;
return OMPI_SUCCESS;
}

bool ompi_request_check_same_instance(ompi_request_t** requests,
int count)
{
ompi_request_t *req, *base = NULL;

for(int idx = 0; idx < count; idx++ ) {
req = requests[idx];
if(OMPI_REQUEST_NULL == req->req_type) /* predefined requests are generic */
continue;
/* Only PML requests have support for MPI sessions */
if(OMPI_REQUEST_PML != req->req_type)
continue;
if(NULL == base) {
base = req;
continue;
}
if(base->req_mpi_object.comm != req->req_mpi_object.comm)
return false;
}
return true;
}
17 changes: 17 additions & 0 deletions ompi/request/request.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* Copyright (c) 2018 Triad National Security, LLC. All rights
* reserved.
* Copyright (c) 2022 IBM Corporation. All rights reserved.
* Copyright (c) 2024 NVIDIA Corporation. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -558,6 +559,22 @@ static inline int ompi_request_set_callback(ompi_request_t* request,
return OMPI_SUCCESS;
}

/**
* Check if an array of requests contains only requests that belong to the same
* instance or MPI Session. Exclude predefined requests, that are generic and part
* of all instances.
* Right now, only tests for PML requests as they are the only requests that have
* support for MPI Sessions.
*
* @param requests (IN) Array of requests
* @param count (IN) Number of requests
* @return true if all requests are part of the same instance
* or MPI Session, false otherwise.
*
*/
bool ompi_request_check_same_instance(ompi_request_t** requests,
int count);

END_C_DECLS

#endif

0 comments on commit a6d5b36

Please sign in to comment.