Skip to content

Commit a6d5b36

Browse files
authored
Merge pull request #12691 from bosilca/topic/request_single_instance_fix
Check that requests belong to similar sessions
2 parents 1a60234 + ae5b0f6 commit a6d5b36

File tree

9 files changed

+65
-131
lines changed

9 files changed

+65
-131
lines changed

ompi/communicator/communicator.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* Copyright (c) 2018-2024 Triad National Security, LLC. All rights
2626
* reserved.
2727
* Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
28+
* Copyright (c) 2024 NVIDIA Corporation. All rights reserved.
2829
* $COPYRIGHT$
2930
*
3031
* Additional copyrights may follow
@@ -613,11 +614,6 @@ static inline struct ompi_proc_t* ompi_comm_peer_lookup (const ompi_communicator
613614
return ompi_group_peer_lookup(comm->c_remote_group,peer_id);
614615
}
615616

616-
static inline bool ompi_comm_instances_same(const ompi_communicator_t *comm1, const ompi_communicator_t *comm2)
617-
{
618-
return comm1->instance == comm2->instance;
619-
}
620-
621617
#if OPAL_ENABLE_FT_MPI
622618
/*
623619
* Support for MPI_ANY_SOURCE point-to-point operations

ompi/mpi/c/testall.c

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* and Technology (RIST). All rights reserved.
1818
* Copyright (c) 2021 Triad National Security, LLC. All rights
1919
* reserved.
20+
* Copyright (c) 2024 NVIDIA Corporation. All rights reserved.
2021
* $COPYRIGHT$
2122
*
2223
* Additional copyrights may follow
@@ -57,31 +58,13 @@ int MPI_Testall(int count, MPI_Request requests[], int *flag,
5758
);
5859

5960
if ( MPI_PARAM_CHECK ) {
60-
int i, rc = MPI_SUCCESS;
61-
MPI_Request check_req = NULL;
61+
int rc = MPI_SUCCESS;
6262
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
6363
if( (NULL == requests) && (0 != count) ) {
6464
rc = MPI_ERR_REQUEST;
6565
} else {
66-
for (i = 0; i < count; i++) {
67-
if (NULL == requests[i]) {
68-
rc = MPI_ERR_REQUEST;
69-
break;
70-
}
71-
if (&ompi_request_empty == requests[i]) {
72-
continue;
73-
} else if (NULL == requests[i]->req_mpi_object.comm) {
74-
continue;
75-
} else if (NULL == check_req) {
76-
check_req = requests[i];
77-
}
78-
else {
79-
if (!ompi_comm_instances_same(requests[i]->req_mpi_object.comm,
80-
check_req->req_mpi_object.comm)) {
81-
rc = MPI_ERR_REQUEST;
82-
break;
83-
}
84-
}
66+
if(!ompi_request_check_same_instance(requests, count) ) {
67+
rc = MPI_ERR_REQUEST;
8568
}
8669
}
8770
if ((NULL == flag) || (count < 0)) {

ompi/mpi/c/testany.c

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* and Technology (RIST). All rights reserved.
1818
* Copyright (c) 2021 Triad National Security, LLC. All rights
1919
* reserved.
20+
* Copyright (c) 2024 NVIDIA Corporation. All rights reserved.
2021
* $COPYRIGHT$
2122
*
2223
* Additional copyrights may follow
@@ -56,31 +57,13 @@ int MPI_Testany(int count, MPI_Request requests[], int *indx, int *completed, MP
5657
);
5758

5859
if ( MPI_PARAM_CHECK ) {
59-
int i, rc = MPI_SUCCESS;
60-
MPI_Request check_req = NULL;
60+
int rc = MPI_SUCCESS;
6161
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
6262
if ((NULL == requests) && (0 != count)) {
6363
rc = MPI_ERR_REQUEST;
6464
} else {
65-
for (i = 0; i < count; i++) {
66-
if (NULL == requests[i]) {
67-
rc = MPI_ERR_REQUEST;
68-
break;
69-
}
70-
if (&ompi_request_empty == requests[i]) {
71-
continue;
72-
} else if (NULL == requests[i]->req_mpi_object.comm) {
73-
continue;
74-
} else if (NULL == check_req) {
75-
check_req = requests[i];
76-
}
77-
else {
78-
if (!ompi_comm_instances_same(requests[i]->req_mpi_object.comm,
79-
check_req->req_mpi_object.comm)) {
80-
rc = MPI_ERR_REQUEST;
81-
break;
82-
}
83-
}
65+
if(!ompi_request_check_same_instance(requests, count) ) {
66+
rc = MPI_ERR_REQUEST;
8467
}
8568
}
8669
if (((NULL == indx || NULL == completed) && count > 0) ||

ompi/mpi/c/testsome.c

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* and Technology (RIST). All rights reserved.
1818
* Copyright (c) 2021 Triad National Security, LLC. All rights
1919
* reserved.
20+
* Copyright (c) 2024 NVIDIA Corporation. All rights reserved.
2021
* $COPYRIGHT$
2122
*
2223
* Additional copyrights may follow
@@ -58,31 +59,13 @@ int MPI_Testsome(int incount, MPI_Request requests[],
5859
);
5960

6061
if ( MPI_PARAM_CHECK ) {
61-
int indx, rc = MPI_SUCCESS;
62-
MPI_Request check_req = NULL;
62+
int rc = MPI_SUCCESS;
6363
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
6464
if ((NULL == requests) && (0 != incount)) {
6565
rc = MPI_ERR_REQUEST;
6666
} else {
67-
for (indx = 0; indx < incount; ++indx) {
68-
if (NULL == requests[indx]) {
69-
rc = MPI_ERR_REQUEST;
70-
break;
71-
}
72-
if (&ompi_request_empty == requests[indx]) {
73-
continue;
74-
} else if (NULL == requests[indx]->req_mpi_object.comm) {
75-
continue;
76-
} else if (NULL == check_req) {
77-
check_req = requests[indx];
78-
}
79-
else {
80-
if (!ompi_comm_instances_same(requests[indx]->req_mpi_object.comm,
81-
check_req->req_mpi_object.comm)) {
82-
rc = MPI_ERR_REQUEST;
83-
break;
84-
}
85-
}
67+
if(!ompi_request_check_same_instance(requests, incount) ) {
68+
rc = MPI_ERR_REQUEST;
8669
}
8770
}
8871
if (((NULL == outcount || NULL == indices) && incount > 0) ||

ompi/mpi/c/waitall.c

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* and Technology (RIST). All rights reserved.
1717
* Copyright (c) 2021 Triad National Security, LLC. All rights
1818
* reserved.
19+
* Copyright (c) 2024 NVIDIA Corporation. All rights reserved.
1920
* $COPYRIGHT$
2021
*
2122
* Additional copyrights may follow
@@ -55,31 +56,13 @@ int MPI_Waitall(int count, MPI_Request requests[], MPI_Status statuses[])
5556
);
5657

5758
if ( MPI_PARAM_CHECK ) {
58-
int i, rc = MPI_SUCCESS;
59-
MPI_Request check_req = NULL;
59+
int rc = MPI_SUCCESS;
6060
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
6161
if( (NULL == requests) && (0 != count) ) {
6262
rc = MPI_ERR_REQUEST;
6363
} else {
64-
for (i = 0; i < count; i++) {
65-
if (NULL == requests[i]) {
66-
rc = MPI_ERR_REQUEST;
67-
break;
68-
}
69-
if (&ompi_request_empty == requests[i]) {
70-
continue;
71-
} else if (NULL == requests[i]->req_mpi_object.comm) {
72-
continue;
73-
} else if (NULL == check_req) {
74-
check_req = requests[i];
75-
}
76-
else {
77-
if (!ompi_comm_instances_same(requests[i]->req_mpi_object.comm,
78-
check_req->req_mpi_object.comm)) {
79-
rc = MPI_ERR_REQUEST;
80-
break;
81-
}
82-
}
64+
if(!ompi_request_check_same_instance(requests, count) ) {
65+
rc = MPI_ERR_REQUEST;
8366
}
8467
}
8568
if (count < 0) {

ompi/mpi/c/waitany.c

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* and Technology (RIST). All rights reserved.
1818
* Copyright (c) 2021 Triad National Security, LLC. All rights
1919
* reserved.
20+
* Copyright (c) 2024 NVIDIA Corporation. All rights reserved.
2021
* $COPYRIGHT$
2122
*
2223
* Additional copyrights may follow
@@ -56,31 +57,13 @@ int MPI_Waitany(int count, MPI_Request requests[], int *indx, MPI_Status *status
5657
);
5758

5859
if ( MPI_PARAM_CHECK ) {
59-
int i, rc = MPI_SUCCESS;
60-
MPI_Request check_req = NULL;
60+
int rc = MPI_SUCCESS;
6161
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
6262
if ((NULL == requests) && (0 != count)) {
6363
rc = MPI_ERR_REQUEST;
6464
} else {
65-
for (i = 0; i < count; i++) {
66-
if (NULL == requests[i]) {
67-
rc = MPI_ERR_REQUEST;
68-
break;
69-
}
70-
if (requests[i] == &ompi_request_empty) {
71-
continue;
72-
} else if (NULL == requests[i]->req_mpi_object.comm) {
73-
continue;
74-
} else if (NULL == check_req) {
75-
check_req = requests[i];
76-
}
77-
else {
78-
if (!ompi_comm_instances_same(requests[i]->req_mpi_object.comm,
79-
check_req->req_mpi_object.comm)) {
80-
rc = MPI_ERR_REQUEST;
81-
break;
82-
}
83-
}
65+
if(!ompi_request_check_same_instance(requests, count) ) {
66+
rc = MPI_ERR_REQUEST;
8467
}
8568
}
8669
if ((NULL == indx && count > 0) ||

ompi/mpi/c/waitsome.c

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* and Technology (RIST). All rights reserved.
1818
* Copyright (c) 2021 Triad National Security, LLC. All rights
1919
* reserved.
20+
* Copyright (c) 2024 NVIDIA Corporation. All rights reserved.
2021
* $COPYRIGHT$
2122
*
2223
* Additional copyrights may follow
@@ -58,31 +59,13 @@ int MPI_Waitsome(int incount, MPI_Request requests[],
5859
);
5960

6061
if ( MPI_PARAM_CHECK ) {
61-
int indx, rc = MPI_SUCCESS;
62-
MPI_Request check_req = NULL;
62+
int rc = MPI_SUCCESS;
6363
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
6464
if ((NULL == requests) && (0 != incount)) {
6565
rc = MPI_ERR_REQUEST;
6666
} else {
67-
for (indx = 0; indx < incount; ++indx) {
68-
if (NULL == requests[indx]) {
69-
rc = MPI_ERR_REQUEST;
70-
break;
71-
}
72-
if (&ompi_request_empty == requests[indx]) {
73-
continue;
74-
} else if (NULL == requests[indx]->req_mpi_object.comm) {
75-
continue;
76-
} else if (NULL == check_req) {
77-
check_req = requests[indx];
78-
}
79-
else {
80-
if (!ompi_comm_instances_same(requests[indx]->req_mpi_object.comm,
81-
check_req->req_mpi_object.comm)) {
82-
rc = MPI_ERR_REQUEST;
83-
break;
84-
}
85-
}
67+
if(!ompi_request_check_same_instance(requests, incount) ) {
68+
rc = MPI_ERR_REQUEST;
8669
}
8770
}
8871
if (((NULL == outcount || NULL == indices) && incount > 0) ||

ompi/request/request.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* Copyright (c) 2018 Triad National Security, LLC. All rights
2222
* reserved.
2323
* Copyright (c) 2022 IBM Corporation. All rights reserved.
24+
* Copyright (c) 2024 NVIDIA Corporation. All rights reserved.
2425
* $COPYRIGHT$
2526
*
2627
* Additional copyrights may follow
@@ -248,3 +249,25 @@ int ompi_request_persistent_noop_create(ompi_request_t** request)
248249
*request = req;
249250
return OMPI_SUCCESS;
250251
}
252+
253+
bool ompi_request_check_same_instance(ompi_request_t** requests,
254+
int count)
255+
{
256+
ompi_request_t *req, *base = NULL;
257+
258+
for(int idx = 0; idx < count; idx++ ) {
259+
req = requests[idx];
260+
if(OMPI_REQUEST_NULL == req->req_type) /* predefined requests are generic */
261+
continue;
262+
/* Only PML requests have support for MPI sessions */
263+
if(OMPI_REQUEST_PML != req->req_type)
264+
continue;
265+
if(NULL == base) {
266+
base = req;
267+
continue;
268+
}
269+
if(base->req_mpi_object.comm != req->req_mpi_object.comm)
270+
return false;
271+
}
272+
return true;
273+
}

ompi/request/request.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
* Copyright (c) 2018 Triad National Security, LLC. All rights
2020
* reserved.
2121
* Copyright (c) 2022 IBM Corporation. All rights reserved.
22+
* Copyright (c) 2024 NVIDIA Corporation. All rights reserved.
2223
* $COPYRIGHT$
2324
*
2425
* Additional copyrights may follow
@@ -558,6 +559,22 @@ static inline int ompi_request_set_callback(ompi_request_t* request,
558559
return OMPI_SUCCESS;
559560
}
560561

562+
/**
563+
* Check if an array of requests contains only requests that belong to the same
564+
* instance or MPI Session. Exclude predefined requests, that are generic and part
565+
* of all instances.
566+
* Right now, only tests for PML requests as they are the only requests that have
567+
* support for MPI Sessions.
568+
*
569+
* @param requests (IN) Array of requests
570+
* @param count (IN) Number of requests
571+
* @return true if all requests are part of the same instance
572+
* or MPI Session, false otherwise.
573+
*
574+
*/
575+
bool ompi_request_check_same_instance(ompi_request_t** requests,
576+
int count);
577+
561578
END_C_DECLS
562579

563580
#endif

0 commit comments

Comments
 (0)