From 1ec756c01f25556ce8d0775943f162eae4521010 Mon Sep 17 00:00:00 2001 From: Howard Pritchard Date: Thu, 20 Nov 2025 06:29:22 -0700 Subject: [PATCH] nbc: rework the way to add arrays to clean up Turns out that in the course of working on PR #13280 , it was discovered that auxiliary arrays associated with a non-blocking/persistent collective requests were not in fact being cleaned up upon either completion of the non-blocking request or freeing of the persistent request except for instances where the 'c' interface detected certain cases for the arguments (in particular user-defined data types). So all the additions to the fortran code to cleanup temporary arrays needed, for example, when default integer type does not map to 'c' int, was not actually doing anything in the general case. This PR also hides the way the auxiliary array info is associated with the request rather than having the current array of pointers in the nbc request exposed in many different places. This PR also fixes up some problems found with handling of some of the arrays within the f90/f08 code as well as suppressing some compiler warnings. Signed-off-by: Howard Pritchard --- ompi/mca/coll/base/coll_base_util.c | 23 +++++++++- ompi/mca/coll/base/coll_base_util.h | 46 +++++++++++++++++++ ompi/mpi/fortran/mpif-h/allgatherv_init_f.c | 13 +++--- ompi/mpi/fortran/mpif-h/alltoallv_init_f.c | 17 +++---- ompi/mpi/fortran/mpif-h/alltoallw_init_f.c | 23 +++++----- ompi/mpi/fortran/mpif-h/gatherv_init_f.c | 13 +++--- ompi/mpi/fortran/mpif-h/iallgatherv_f.c | 13 +++--- ompi/mpi/fortran/mpif-h/ialltoallv_f.c | 17 +++---- ompi/mpi/fortran/mpif-h/ialltoallw_f.c | 23 +++++----- ompi/mpi/fortran/mpif-h/igatherv_f.c | 13 +++--- .../fortran/mpif-h/ineighbor_allgatherv_f.c | 13 +++--- .../fortran/mpif-h/ineighbor_alltoallv_f.c | 15 +++--- .../fortran/mpif-h/ineighbor_alltoallw_f.c | 13 +++--- ompi/mpi/fortran/mpif-h/ireduce_scatter_f.c | 7 +-- ompi/mpi/fortran/mpif-h/iscatterv_f.c | 13 +++--- .../mpif-h/neighbor_allgatherv_init_f.c | 11 +++-- .../mpif-h/neighbor_alltoallv_init_f.c | 17 +++---- .../mpif-h/neighbor_alltoallw_init_f.c | 15 +++--- .../fortran/mpif-h/reduce_scatter_init_f.c | 7 +-- ompi/mpi/fortran/mpif-h/scatterv_init_f.c | 13 +++--- .../use-mpi-f08/allgatherv_init_ts.c.in | 5 +- .../use-mpi-f08/alltoallv_init_ts.c.in | 5 +- .../use-mpi-f08/alltoallw_init_ts.c.in | 11 ++++- ompi/mpi/fortran/use-mpi-f08/base/bigcount.h | 5 +- .../fortran/use-mpi-f08/gatherv_init_ts.c.in | 3 ++ .../fortran/use-mpi-f08/iallgatherv_ts.c.in | 10 ++-- .../fortran/use-mpi-f08/ialltoallv_ts.c.in | 14 ++++-- .../fortran/use-mpi-f08/ialltoallw_ts.c.in | 32 ++++++++----- ompi/mpi/fortran/use-mpi-f08/igatherv_ts.c.in | 3 ++ .../use-mpi-f08/ineighbor_allgatherv_ts.c.in | 11 +++-- .../use-mpi-f08/ineighbor_alltoallv_ts.c.in | 15 +++--- .../use-mpi-f08/ineighbor_alltoallw_ts.c.in | 21 +++++---- .../use-mpi-f08/ireduce_scatter_ts.c.in | 5 +- .../mpi/fortran/use-mpi-f08/iscatterv_ts.c.in | 5 +- .../neighbor_allgatherv_init_ts.c.in | 3 ++ .../neighbor_alltoallv_init_ts.c.in | 3 ++ .../neighbor_alltoallw_init_ts.c.in | 13 ++++-- .../use-mpi-f08/reduce_scatter_init_ts.c.in | 5 +- .../fortran/use-mpi-f08/scatterv_init_ts.c.in | 5 +- 39 files changed, 325 insertions(+), 174 deletions(-) diff --git a/ompi/mca/coll/base/coll_base_util.c b/ompi/mca/coll/base/coll_base_util.c index ba74aa01350..d2771a1fbf5 100644 --- a/ompi/mca/coll/base/coll_base_util.c +++ b/ompi/mca/coll/base/coll_base_util.c @@ -14,6 +14,8 @@ * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * * Copyright (c) 2024 NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2025 Triad National Security, LLC. All rights + * reserved. * * $COPYRIGHT$ * @@ -134,7 +136,7 @@ int ompi_rounddown(int num, int factor) /** * Release all objects and arrays stored into the nbc_request. * The release_arrays are temporary memory to stored the values - * converted from Fortran, and should disappear in same time as the + * converted from Fortran or elsewhere, and should disappear in same time as the * request itself. */ static void @@ -268,6 +270,7 @@ static void release_vecs_callback(ompi_coll_base_nbc_request_t *request) } request->data.refcounted.vecs.rtypes = NULL; } + release_objs_callback(request); } static int complete_vecs_callback(struct ompi_request_t *req) { @@ -346,6 +349,24 @@ int ompi_coll_base_retain_datatypes_w( ompi_request_t *req, return OMPI_SUCCESS; } +int ompi_coll_base_add_release_arrays_cb(ompi_request_t *req) +{ + ompi_coll_base_nbc_request_t *request = (ompi_coll_base_nbc_request_t *)req; + + assert(NULL != request); + + if (req->req_persistent && (NULL == req->req_free)) { + request->cb.req_free = req->req_free; + req->req_free = free_objs_callback; + } else if (NULL == req->req_complete_cb) { + request->cb.req_complete_cb = req->req_complete_cb; + request->req_complete_cb_data = req->req_complete_cb_data; + req->req_complete_cb = complete_objs_callback; + req->req_complete_cb_data = request; + } + return OMPI_SUCCESS; +} + static void nbc_req_constructor(ompi_coll_base_nbc_request_t *req) { req->cb.req_complete_cb = NULL; diff --git a/ompi/mca/coll/base/coll_base_util.h b/ompi/mca/coll/base/coll_base_util.h index 7bceaa7dcc0..d9f5bc76112 100644 --- a/ompi/mca/coll/base/coll_base_util.h +++ b/ompi/mca/coll/base/coll_base_util.h @@ -12,6 +12,8 @@ * Copyright (c) 2014-2020 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2024 NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2025 Triad National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -95,6 +97,43 @@ ompi_coll_base_nbc_reserve_tags(ompi_communicator_t* comm, int32_t reserve) return tag; } +/** + * Append an array to a request object to be freed upon completion + * of the associated operation. + * The request object must be of type ompi_coll_base_nbc_request_t. + */ +__opal_attribute_always_inline__ static inline int +ompi_coll_base_append_array_to_release(struct ompi_request_t *req, void *array_ptr) +{ + int i, ret = OMPI_SUCCESS; + struct ompi_coll_base_nbc_request_t *request = (struct ompi_coll_base_nbc_request_t *)req; + + /* + * important sanity check - doing steps below on a non-libnbc request can lead + * to difficult to debug memory corruption problems + */ + assert(request->super.req_type == OMPI_REQUEST_COLL); + + for(i = 0; i < OMPI_REQ_NB_RELEASE_ARRAYS; i++ ) { + if (NULL == request->data.release_arrays[i]) { + break; + } + } + + if (OMPI_REQ_NB_RELEASE_ARRAYS > i) { + request->data.release_arrays[i] = array_ptr; + ++i; + if (OMPI_REQ_NB_RELEASE_ARRAYS > i) { + request->data.release_arrays[i] = NULL; + } + } else { + ret = OMPI_ERR_OUT_OF_RESOURCE; + } + + assert(OMPI_SUCCESS == ret); + return ret; +} + typedef struct ompi_coll_base_nbc_request_t ompi_coll_base_nbc_request_t; /* @@ -188,6 +227,13 @@ int ompi_coll_base_retain_datatypes_w( ompi_request_t *request, ompi_datatype_t * const rtypes[], bool use_topo); +/** + * If necessary, set callback to free extra memory regions + * set in release_arrays. Not set if a callback is already + * associated with the request. + */ +int ompi_coll_base_add_release_arrays_cb(ompi_request_t *request); + /* File reading function */ int ompi_coll_base_file_getnext_long(FILE *fptr, int *fileline, long* val); int ompi_coll_base_file_getnext_size_t(FILE *fptr, int *fileline, size_t* val); diff --git a/ompi/mpi/fortran/mpif-h/allgatherv_init_f.c b/ompi/mpi/fortran/mpif-h/allgatherv_init_f.c index 0d98627c440..b28b5803fc6 100644 --- a/ompi/mpi/fortran/mpif-h/allgatherv_init_f.c +++ b/ompi/mpi/fortran/mpif-h/allgatherv_init_f.c @@ -12,6 +12,8 @@ * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015-2021 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2025 Triad National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -77,7 +79,7 @@ void ompi_allgatherv_init_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendty MPI_Datatype c_sendtype, c_recvtype; MPI_Request c_request; MPI_Info c_info; - int size, idx = 0, ierr_c; + int size, ierr_c; OMPI_ARRAY_NAME_DECL(recvcounts); OMPI_ARRAY_NAME_DECL(displs); @@ -105,12 +107,11 @@ void ompi_allgatherv_init_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendty if (NULL != ierr) *ierr = OMPI_INT_2_FINT(ierr_c); if (MPI_SUCCESS == ierr_c) { *request = PMPI_Request_c2f(c_request); - ompi_coll_base_nbc_request_t* nb_request = (ompi_coll_base_nbc_request_t*)c_request; - if (recvcounts != OMPI_ARRAY_NAME_CONVERT(recvcounts)) { - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(recvcounts); - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(displs); + if ((void *)recvcounts != (void *)OMPI_ARRAY_NAME_CONVERT(recvcounts)) { + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(recvcounts)); + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(displs)); + ompi_coll_base_add_release_arrays_cb(c_request); } - nb_request->data.release_arrays[idx] = NULL; } else { OMPI_ARRAY_FINT_2_INT_CLEANUP(recvcounts); OMPI_ARRAY_FINT_2_INT_CLEANUP(displs); diff --git a/ompi/mpi/fortran/mpif-h/alltoallv_init_f.c b/ompi/mpi/fortran/mpif-h/alltoallv_init_f.c index 1a10b0eadad..286e5e8f08a 100644 --- a/ompi/mpi/fortran/mpif-h/alltoallv_init_f.c +++ b/ompi/mpi/fortran/mpif-h/alltoallv_init_f.c @@ -12,6 +12,8 @@ * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015-2021 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2025 Triad National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -77,7 +79,7 @@ void ompi_alltoallv_init_f(char *sendbuf, MPI_Fint *sendcounts, MPI_Fint *sdispl MPI_Datatype c_sendtype, c_recvtype; MPI_Info c_info; MPI_Request c_request; - int size, idx = 0, c_ierr; + int size, c_ierr; OMPI_ARRAY_NAME_DECL(sendcounts); OMPI_ARRAY_NAME_DECL(sdispls); OMPI_ARRAY_NAME_DECL(recvcounts); @@ -109,14 +111,13 @@ void ompi_alltoallv_init_f(char *sendbuf, MPI_Fint *sendcounts, MPI_Fint *sdispl if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); if (MPI_SUCCESS == c_ierr) { *request = PMPI_Request_c2f(c_request); - ompi_coll_base_nbc_request_t* nb_request = (ompi_coll_base_nbc_request_t*)c_request; - if (sendcounts != OMPI_ARRAY_NAME_CONVERT(sendcounts)) { - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(sendcounts); - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(sdispls); - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(recvcounts); - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(rdispls); + if ((void *)sendcounts != (void *)OMPI_ARRAY_NAME_CONVERT(sendcounts)) { + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(sendcounts)); + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(sdispls)); + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(recvcounts)); + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(rdispls)); + ompi_coll_base_add_release_arrays_cb(c_request); } - nb_request->data.release_arrays[idx] = NULL; } else { OMPI_ARRAY_FINT_2_INT_CLEANUP(sendcounts); OMPI_ARRAY_FINT_2_INT_CLEANUP(sdispls); diff --git a/ompi/mpi/fortran/mpif-h/alltoallw_init_f.c b/ompi/mpi/fortran/mpif-h/alltoallw_init_f.c index 24b0489ba43..97a1d6b5549 100644 --- a/ompi/mpi/fortran/mpif-h/alltoallw_init_f.c +++ b/ompi/mpi/fortran/mpif-h/alltoallw_init_f.c @@ -12,6 +12,8 @@ * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015-2021 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2025 Triad National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -78,7 +80,7 @@ void ompi_alltoallw_init_f(char *sendbuf, MPI_Fint *sendcounts, MPI_Datatype *c_sendtypes = NULL, *c_recvtypes; MPI_Info c_info; MPI_Request c_request; - int size, idx = 0, c_ierr; + int size, c_ierr; OMPI_ARRAY_NAME_DECL(sendcounts); OMPI_ARRAY_NAME_DECL(sdispls); OMPI_ARRAY_NAME_DECL(recvcounts); @@ -119,20 +121,19 @@ void ompi_alltoallw_init_f(char *sendbuf, MPI_Fint *sendcounts, if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); if (MPI_SUCCESS == c_ierr) { *request = PMPI_Request_c2f(c_request); - ompi_coll_base_nbc_request_t* nb_request = (ompi_coll_base_nbc_request_t*)c_request; - nb_request->data.release_arrays[idx++] = c_recvtypes; - if (recvcounts != OMPI_ARRAY_NAME_CONVERT(recvcounts)) { - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(recvcounts); - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(rdispls); + ompi_coll_base_append_array_to_release(c_request, c_recvtypes); + if ((void *)recvcounts != (void *)OMPI_ARRAY_NAME_CONVERT(recvcounts)) { + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(recvcounts)); + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(rdispls)); } if (NULL != c_sendtypes) { - nb_request->data.release_arrays[idx++] = c_sendtypes; - if (sendcounts != OMPI_ARRAY_NAME_CONVERT(sendcounts)) { - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(sendcounts); - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(sdispls); + ompi_coll_base_append_array_to_release(c_request, c_sendtypes); + if ((void *)sendcounts != (void *)OMPI_ARRAY_NAME_CONVERT(sendcounts)) { + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(sendcounts)); + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(sdispls)); } } - nb_request->data.release_arrays[idx] = NULL; + ompi_coll_base_add_release_arrays_cb(c_request); } else { OMPI_ARRAY_FINT_2_INT_CLEANUP(sendcounts); OMPI_ARRAY_FINT_2_INT_CLEANUP(sdispls); diff --git a/ompi/mpi/fortran/mpif-h/gatherv_init_f.c b/ompi/mpi/fortran/mpif-h/gatherv_init_f.c index a87a5c9ddcc..060548c000a 100644 --- a/ompi/mpi/fortran/mpif-h/gatherv_init_f.c +++ b/ompi/mpi/fortran/mpif-h/gatherv_init_f.c @@ -12,6 +12,8 @@ * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015-2021 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2025 Triad National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -77,7 +79,7 @@ void ompi_gatherv_init_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, MPI_Datatype c_sendtype, c_recvtype; MPI_Info c_info; MPI_Request c_request; - int size, idx = 0, c_ierr; + int size, c_ierr; OMPI_ARRAY_NAME_DECL(recvcounts); OMPI_ARRAY_NAME_DECL(displs); @@ -104,12 +106,11 @@ void ompi_gatherv_init_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); if (MPI_SUCCESS == c_ierr) { *request = PMPI_Request_c2f(c_request); - ompi_coll_base_nbc_request_t* nb_request = (ompi_coll_base_nbc_request_t*)c_request; - if (recvcounts != OMPI_ARRAY_NAME_CONVERT(recvcounts)) { - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(recvcounts); - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(displs); + if ((void *)recvcounts != (void *)OMPI_ARRAY_NAME_CONVERT(recvcounts)) { + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(recvcounts)); + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(displs)); + ompi_coll_base_add_release_arrays_cb(c_request); } - nb_request->data.release_arrays[idx] = NULL; } else { OMPI_ARRAY_FINT_2_INT_CLEANUP(recvcounts); OMPI_ARRAY_FINT_2_INT_CLEANUP(displs); diff --git a/ompi/mpi/fortran/mpif-h/iallgatherv_f.c b/ompi/mpi/fortran/mpif-h/iallgatherv_f.c index 37926247905..b0ae5ce3388 100644 --- a/ompi/mpi/fortran/mpif-h/iallgatherv_f.c +++ b/ompi/mpi/fortran/mpif-h/iallgatherv_f.c @@ -12,6 +12,8 @@ * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2025 Triad National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -76,7 +78,7 @@ void ompi_iallgatherv_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, MPI_Comm c_comm; MPI_Datatype c_sendtype, c_recvtype; MPI_Request c_request; - int size, idx = 0, ierr_c; + int size, ierr_c; OMPI_ARRAY_NAME_DECL(recvcounts); OMPI_ARRAY_NAME_DECL(displs); @@ -107,11 +109,10 @@ void ompi_iallgatherv_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, OMPI_ARRAY_FINT_2_INT_CLEANUP(recvcounts); OMPI_ARRAY_FINT_2_INT_CLEANUP(displs); } else { - ompi_coll_base_nbc_request_t* nb_request = (ompi_coll_base_nbc_request_t*)c_request; - if (recvcounts != OMPI_ARRAY_NAME_CONVERT(recvcounts)) { - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(recvcounts); - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(displs); + if ((void *)recvcounts != (void *)OMPI_ARRAY_NAME_CONVERT(recvcounts)) { + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(recvcounts)); + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(displs)); + ompi_coll_base_add_release_arrays_cb(c_request); } - nb_request->data.release_arrays[idx] = NULL; } } diff --git a/ompi/mpi/fortran/mpif-h/ialltoallv_f.c b/ompi/mpi/fortran/mpif-h/ialltoallv_f.c index b519a3c82cb..cc23bfb1232 100644 --- a/ompi/mpi/fortran/mpif-h/ialltoallv_f.c +++ b/ompi/mpi/fortran/mpif-h/ialltoallv_f.c @@ -12,6 +12,8 @@ * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2025 Triad National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -76,7 +78,7 @@ void ompi_ialltoallv_f(char *sendbuf, MPI_Fint *sendcounts, MPI_Fint *sdispls, MPI_Comm c_comm; MPI_Datatype c_sendtype, c_recvtype; MPI_Request c_request; - int size, idx = 0, c_ierr; + int size, c_ierr; OMPI_ARRAY_NAME_DECL(sendcounts); OMPI_ARRAY_NAME_DECL(sdispls); OMPI_ARRAY_NAME_DECL(recvcounts); @@ -113,13 +115,12 @@ void ompi_ialltoallv_f(char *sendbuf, MPI_Fint *sendcounts, MPI_Fint *sdispls, OMPI_ARRAY_FINT_2_INT_CLEANUP(recvcounts); OMPI_ARRAY_FINT_2_INT_CLEANUP(rdispls); } else { - ompi_coll_base_nbc_request_t* nb_request = (ompi_coll_base_nbc_request_t*)c_request; - if (sendcounts != OMPI_ARRAY_NAME_CONVERT(sendcounts)) { - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(sendcounts); - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(sdispls); - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(recvcounts); - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(rdispls); + if ((void *)sendcounts != (void *)OMPI_ARRAY_NAME_CONVERT(sendcounts)) { + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(sendcounts)); + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(sdispls)); + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(recvcounts)); + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(rdispls)); + ompi_coll_base_add_release_arrays_cb(c_request); } - nb_request->data.release_arrays[idx] = NULL; } } diff --git a/ompi/mpi/fortran/mpif-h/ialltoallw_f.c b/ompi/mpi/fortran/mpif-h/ialltoallw_f.c index 1c5dd1400f3..b4bf9f08f28 100644 --- a/ompi/mpi/fortran/mpif-h/ialltoallw_f.c +++ b/ompi/mpi/fortran/mpif-h/ialltoallw_f.c @@ -12,6 +12,8 @@ * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015-2019 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2025 Triad National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -78,7 +80,7 @@ void ompi_ialltoallw_f(char *sendbuf, MPI_Fint *sendcounts, MPI_Comm c_comm; MPI_Datatype *c_sendtypes = NULL, *c_recvtypes; MPI_Request c_request; - int size, idx = 0, c_ierr; + int size, c_ierr; OMPI_ARRAY_NAME_DECL(sendcounts); OMPI_ARRAY_NAME_DECL(sdispls); OMPI_ARRAY_NAME_DECL(recvcounts); @@ -128,17 +130,16 @@ void ompi_ialltoallw_f(char *sendbuf, MPI_Fint *sendcounts, OMPI_ARRAY_FINT_2_INT_CLEANUP(recvcounts); OMPI_ARRAY_FINT_2_INT_CLEANUP(rdispls); } else { - ompi_coll_base_nbc_request_t* nb_request = (ompi_coll_base_nbc_request_t*)c_request; - if (sendcounts != OMPI_ARRAY_NAME_CONVERT(sendcounts)) { - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(sendcounts); - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(recvcounts); + if ((void *)sendcounts != (void *)OMPI_ARRAY_NAME_CONVERT(sendcounts)) { + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(sendcounts)); + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(recvcounts)); } - if (sdispls != OMPI_ARRAY_NAME_CONVERT(sdispls)) { - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(sdispls); - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(rdispls); + if ((void *)sdispls != (void *)OMPI_ARRAY_NAME_CONVERT(sdispls)) { + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(sdispls)); + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(rdispls)); } - nb_request->data.release_arrays[idx++] = c_recvtypes; - nb_request->data.release_arrays[idx++] = c_sendtypes; - nb_request->data.release_arrays[idx] = NULL; + ompi_coll_base_append_array_to_release(c_request, c_recvtypes); + ompi_coll_base_append_array_to_release(c_request, c_sendtypes); + ompi_coll_base_add_release_arrays_cb(c_request); } } diff --git a/ompi/mpi/fortran/mpif-h/igatherv_f.c b/ompi/mpi/fortran/mpif-h/igatherv_f.c index 8af9e33b914..d0458dbe3fb 100644 --- a/ompi/mpi/fortran/mpif-h/igatherv_f.c +++ b/ompi/mpi/fortran/mpif-h/igatherv_f.c @@ -12,6 +12,8 @@ * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2025 Triad National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -76,7 +78,7 @@ void ompi_igatherv_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, MPI_Comm c_comm; MPI_Datatype c_sendtype, c_recvtype; MPI_Request c_request; - int size, idx = 0, c_ierr; + int size, c_ierr; OMPI_ARRAY_NAME_DECL(recvcounts); OMPI_ARRAY_NAME_DECL(displs); @@ -106,11 +108,10 @@ void ompi_igatherv_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, OMPI_ARRAY_FINT_2_INT_CLEANUP(recvcounts); OMPI_ARRAY_FINT_2_INT_CLEANUP(displs); } else { - ompi_coll_base_nbc_request_t* nb_request = (ompi_coll_base_nbc_request_t*)c_request; - if (recvcounts != OMPI_ARRAY_NAME_CONVERT(recvcounts)) { - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(recvcounts); - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(displs); + if ((void *)recvcounts != (void *)OMPI_ARRAY_NAME_CONVERT(recvcounts)) { + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(recvcounts)); + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(displs)); + ompi_coll_base_add_release_arrays_cb(c_request); } - nb_request->data.release_arrays[idx] = NULL; } } diff --git a/ompi/mpi/fortran/mpif-h/ineighbor_allgatherv_f.c b/ompi/mpi/fortran/mpif-h/ineighbor_allgatherv_f.c index 390e3dd2a74..b2ec0a5903d 100644 --- a/ompi/mpi/fortran/mpif-h/ineighbor_allgatherv_f.c +++ b/ompi/mpi/fortran/mpif-h/ineighbor_allgatherv_f.c @@ -15,6 +15,8 @@ * reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2025 Triad National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -79,7 +81,7 @@ void ompi_ineighbor_allgatherv_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *s MPI_Comm c_comm; MPI_Datatype c_sendtype, c_recvtype; MPI_Request c_request; - int size, idx = 0, ierr_c; + int size, ierr_c; OMPI_ARRAY_NAME_DECL(recvcounts); OMPI_ARRAY_NAME_DECL(displs); @@ -106,12 +108,11 @@ void ompi_ineighbor_allgatherv_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *s if (NULL != ierr) *ierr = OMPI_INT_2_FINT(ierr_c); if (MPI_SUCCESS == ierr_c) { *request = PMPI_Request_c2f(c_request); - ompi_coll_base_nbc_request_t* nb_request = (ompi_coll_base_nbc_request_t*)c_request; - if (recvcounts != OMPI_ARRAY_NAME_CONVERT(recvcounts)) { - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(recvcounts); - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(displs); + if ((void *)recvcounts != (void *)OMPI_ARRAY_NAME_CONVERT(recvcounts)) { + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(recvcounts)); + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(displs)); + ompi_coll_base_add_release_arrays_cb(c_request); } - nb_request->data.release_arrays[idx] = NULL; } else { OMPI_ARRAY_FINT_2_INT_CLEANUP(recvcounts); OMPI_ARRAY_FINT_2_INT_CLEANUP(displs); diff --git a/ompi/mpi/fortran/mpif-h/ineighbor_alltoallv_f.c b/ompi/mpi/fortran/mpif-h/ineighbor_alltoallv_f.c index c7b9901cadf..d3cf7a63680 100644 --- a/ompi/mpi/fortran/mpif-h/ineighbor_alltoallv_f.c +++ b/ompi/mpi/fortran/mpif-h/ineighbor_alltoallv_f.c @@ -15,6 +15,8 @@ * reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2025 Triad National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -79,7 +81,7 @@ void ompi_ineighbor_alltoallv_f(char *sendbuf, MPI_Fint *sendcounts, MPI_Fint *s MPI_Comm c_comm; MPI_Datatype c_sendtype, c_recvtype; MPI_Request c_request; - int size, idx = 0, c_ierr; + int size, c_ierr; OMPI_ARRAY_NAME_DECL(sendcounts); OMPI_ARRAY_NAME_DECL(sdispls); OMPI_ARRAY_NAME_DECL(recvcounts); @@ -116,11 +118,10 @@ void ompi_ineighbor_alltoallv_f(char *sendbuf, MPI_Fint *sendcounts, MPI_Fint *s OMPI_ARRAY_FINT_2_INT_CLEANUP(recvcounts); OMPI_ARRAY_FINT_2_INT_CLEANUP(rdispls); } else { - ompi_coll_base_nbc_request_t* nb_request = (ompi_coll_base_nbc_request_t*)c_request; - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(sendcounts); - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(sdispls); - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(sendcounts); - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(rdispls); - nb_request->data.release_arrays[idx] = NULL; + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(sendcounts)); + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(sdispls)); + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(recvcounts)); + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(rdispls)); + ompi_coll_base_add_release_arrays_cb(c_request); } } diff --git a/ompi/mpi/fortran/mpif-h/ineighbor_alltoallw_f.c b/ompi/mpi/fortran/mpif-h/ineighbor_alltoallw_f.c index 680d6a9d94a..2d113a5e575 100644 --- a/ompi/mpi/fortran/mpif-h/ineighbor_alltoallw_f.c +++ b/ompi/mpi/fortran/mpif-h/ineighbor_alltoallw_f.c @@ -80,7 +80,7 @@ void ompi_ineighbor_alltoallw_f(char *sendbuf, MPI_Fint *sendcounts, MPI_Comm c_comm; MPI_Datatype *c_sendtypes, *c_recvtypes; MPI_Request c_request; - int size, idx = 0, c_ierr; + int size, c_ierr; OMPI_ARRAY_NAME_DECL(sendcounts); OMPI_ARRAY_NAME_DECL(recvcounts); @@ -120,11 +120,10 @@ void ompi_ineighbor_alltoallw_f(char *sendbuf, MPI_Fint *sendcounts, free(c_sendtypes); free(c_recvtypes); } else { - ompi_coll_base_nbc_request_t* nb_request = (ompi_coll_base_nbc_request_t*)c_request; - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(sendcounts); - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(recvcounts); - nb_request->data.release_arrays[idx++] = c_sendtypes; - nb_request->data.release_arrays[idx++] = c_recvtypes; - nb_request->data.release_arrays[idx] = NULL; + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(sendcounts)); + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(recvcounts)); + ompi_coll_base_append_array_to_release(c_request, c_sendtypes); + ompi_coll_base_append_array_to_release(c_request, c_recvtypes); + ompi_coll_base_add_release_arrays_cb(c_request); } } diff --git a/ompi/mpi/fortran/mpif-h/ireduce_scatter_f.c b/ompi/mpi/fortran/mpif-h/ireduce_scatter_f.c index d09a397cac6..94d3e68800b 100644 --- a/ompi/mpi/fortran/mpif-h/ireduce_scatter_f.c +++ b/ompi/mpi/fortran/mpif-h/ireduce_scatter_f.c @@ -12,6 +12,8 @@ * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2025 Triad National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -100,8 +102,7 @@ void ompi_ireduce_scatter_f(char *sendbuf, char *recvbuf, if ( REQUEST_COMPLETE(c_request)) { OMPI_ARRAY_FINT_2_INT_CLEANUP(recvcounts); } else { - ompi_coll_base_nbc_request_t* nb_request = (ompi_coll_base_nbc_request_t*)c_request; - nb_request->data.release_arrays[0] = recvcounts; - nb_request->data.release_arrays[1] = NULL; + ompi_coll_base_append_array_to_release(c_request, recvcounts); + ompi_coll_base_add_release_arrays_cb(c_request); } } diff --git a/ompi/mpi/fortran/mpif-h/iscatterv_f.c b/ompi/mpi/fortran/mpif-h/iscatterv_f.c index 01226a83ea8..682656ce16e 100644 --- a/ompi/mpi/fortran/mpif-h/iscatterv_f.c +++ b/ompi/mpi/fortran/mpif-h/iscatterv_f.c @@ -13,6 +13,8 @@ * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2018 FUJITSU LIMITED. All rights reserved. + * Copyright (c) 2025 Triad National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -78,7 +80,7 @@ void ompi_iscatterv_f(char *sendbuf, MPI_Fint *sendcounts, MPI_Comm c_comm; MPI_Datatype c_sendtype, c_recvtype; MPI_Request c_request; - int size, idx = 0, c_ierr; + int size, c_ierr; OMPI_ARRAY_NAME_DECL(sendcounts); OMPI_ARRAY_NAME_DECL(displs); @@ -108,11 +110,10 @@ void ompi_iscatterv_f(char *sendbuf, MPI_Fint *sendcounts, OMPI_ARRAY_FINT_2_INT_CLEANUP(sendcounts); OMPI_ARRAY_FINT_2_INT_CLEANUP(displs); } else { - ompi_coll_base_nbc_request_t* nb_request = (ompi_coll_base_nbc_request_t*)c_request; - if (sendcounts != OMPI_ARRAY_NAME_CONVERT(sendcounts)) { - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(sendcounts); - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(displs); + if ((void *)sendcounts != (void *)OMPI_ARRAY_NAME_CONVERT(sendcounts)) { + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(sendcounts)); + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(displs)); + ompi_coll_base_add_release_arrays_cb(c_request); } - nb_request->data.release_arrays[idx] = NULL; } } diff --git a/ompi/mpi/fortran/mpif-h/neighbor_allgatherv_init_f.c b/ompi/mpi/fortran/mpif-h/neighbor_allgatherv_init_f.c index 532365e2aa7..86b51a12552 100644 --- a/ompi/mpi/fortran/mpif-h/neighbor_allgatherv_init_f.c +++ b/ompi/mpi/fortran/mpif-h/neighbor_allgatherv_init_f.c @@ -15,6 +15,8 @@ * reserved. * Copyright (c) 2015-2021 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2025 Triad National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -108,11 +110,10 @@ void ompi_neighbor_allgatherv_init_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fin if (NULL != ierr) *ierr = OMPI_INT_2_FINT(ierr_c); if (MPI_SUCCESS == ierr_c) { *request = PMPI_Request_c2f(c_request); - ompi_coll_base_nbc_request_t* nb_request = (ompi_coll_base_nbc_request_t*)c_request; - if (recvcounts != OMPI_ARRAY_NAME_CONVERT(recvcounts)) { - nb_request->data.release_arrays[0] = OMPI_ARRAY_NAME_CONVERT(recvcounts); - nb_request->data.release_arrays[1] = OMPI_ARRAY_NAME_CONVERT(displs); - nb_request->data.release_arrays[2] = NULL; + if ((void *)recvcounts != (void *)OMPI_ARRAY_NAME_CONVERT(recvcounts)) { + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(recvcounts)); + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(displs)); + ompi_coll_base_add_release_arrays_cb(c_request); } } else { OMPI_ARRAY_FINT_2_INT_CLEANUP(recvcounts); diff --git a/ompi/mpi/fortran/mpif-h/neighbor_alltoallv_init_f.c b/ompi/mpi/fortran/mpif-h/neighbor_alltoallv_init_f.c index 27ffadbc446..36d6a23dd28 100644 --- a/ompi/mpi/fortran/mpif-h/neighbor_alltoallv_init_f.c +++ b/ompi/mpi/fortran/mpif-h/neighbor_alltoallv_init_f.c @@ -15,6 +15,8 @@ * reserved. * Copyright (c) 2015-2021 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2025 Triad National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -80,7 +82,7 @@ void ompi_neighbor_alltoallv_init_f(char *sendbuf, MPI_Fint *sendcounts, MPI_Fin MPI_Datatype c_sendtype, c_recvtype; MPI_Info c_info; MPI_Request c_request; - int size, idx = 0, c_ierr; + int size, c_ierr; OMPI_ARRAY_NAME_DECL(sendcounts); OMPI_ARRAY_NAME_DECL(sdispls); OMPI_ARRAY_NAME_DECL(recvcounts); @@ -112,14 +114,13 @@ void ompi_neighbor_alltoallv_init_f(char *sendbuf, MPI_Fint *sendcounts, MPI_Fin if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); if (MPI_SUCCESS == c_ierr) { *request = PMPI_Request_c2f(c_request); - ompi_coll_base_nbc_request_t* nb_request = (ompi_coll_base_nbc_request_t*)c_request; - if (sendcounts != OMPI_ARRAY_NAME_CONVERT(sendcounts)) { - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(sendcounts); - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(sdispls); - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(recvcounts); - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(rdispls); + if ((void *)sendcounts != (void *)OMPI_ARRAY_NAME_CONVERT(sendcounts)) { + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(sendcounts)); + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(sdispls)); + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(recvcounts)); + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(rdispls)); + ompi_coll_base_add_release_arrays_cb(c_request); } - nb_request->data.release_arrays[idx] = NULL; } else { OMPI_ARRAY_FINT_2_INT_CLEANUP(sendcounts); OMPI_ARRAY_FINT_2_INT_CLEANUP(sdispls); diff --git a/ompi/mpi/fortran/mpif-h/neighbor_alltoallw_init_f.c b/ompi/mpi/fortran/mpif-h/neighbor_alltoallw_init_f.c index 59910c88e36..c15b397a9d1 100644 --- a/ompi/mpi/fortran/mpif-h/neighbor_alltoallw_init_f.c +++ b/ompi/mpi/fortran/mpif-h/neighbor_alltoallw_init_f.c @@ -15,6 +15,8 @@ * reserved. * Copyright (c) 2015-2021 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2025 Triad National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -81,7 +83,7 @@ void ompi_neighbor_alltoallw_init_f(char *sendbuf, MPI_Fint *sendcounts, MPI_Datatype *c_sendtypes, *c_recvtypes; MPI_Info c_info; MPI_Request c_request; - int size, idx = 0, c_ierr; + int size, c_ierr; OMPI_ARRAY_NAME_DECL(sendcounts); OMPI_ARRAY_NAME_DECL(recvcounts); @@ -116,13 +118,12 @@ void ompi_neighbor_alltoallw_init_f(char *sendbuf, MPI_Fint *sendcounts, if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); if (MPI_SUCCESS == c_ierr) { *request = PMPI_Request_c2f(c_request); - ompi_coll_base_nbc_request_t* nb_request = (ompi_coll_base_nbc_request_t*)c_request; - nb_request->data.release_arrays[idx++] = c_sendtypes; - if (sendcounts != OMPI_ARRAY_NAME_CONVERT(sendcounts)) { - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(sendcounts); - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(recvcounts); + ompi_coll_base_append_array_to_release(c_request, c_sendtypes); + if ((void *)sendcounts != (void *)OMPI_ARRAY_NAME_CONVERT(sendcounts)) { + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(sendcounts)); + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(recvcounts)); } - nb_request->data.release_arrays[idx] = NULL; + ompi_coll_base_add_release_arrays_cb(c_request); } else { OMPI_ARRAY_FINT_2_INT_CLEANUP(sendcounts); OMPI_ARRAY_FINT_2_INT_CLEANUP(recvcounts); diff --git a/ompi/mpi/fortran/mpif-h/reduce_scatter_init_f.c b/ompi/mpi/fortran/mpif-h/reduce_scatter_init_f.c index d60a69dbfef..e3812acba3e 100644 --- a/ompi/mpi/fortran/mpif-h/reduce_scatter_init_f.c +++ b/ompi/mpi/fortran/mpif-h/reduce_scatter_init_f.c @@ -12,6 +12,8 @@ * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015-2021 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2025 Triad National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -100,9 +102,8 @@ void ompi_reduce_scatter_init_f(char *sendbuf, char *recvbuf, if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); if (MPI_SUCCESS == c_ierr) { *request = PMPI_Request_c2f(c_request); - ompi_coll_base_nbc_request_t* nb_request = (ompi_coll_base_nbc_request_t*)c_request; - nb_request->data.release_arrays[0] = OMPI_ARRAY_NAME_CONVERT(recvcounts); - nb_request->data.release_arrays[1] = NULL; + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(recvcounts)); + ompi_coll_base_add_release_arrays_cb(c_request); } else { OMPI_ARRAY_FINT_2_INT_CLEANUP(recvcounts); } diff --git a/ompi/mpi/fortran/mpif-h/scatterv_init_f.c b/ompi/mpi/fortran/mpif-h/scatterv_init_f.c index 394984214dd..75740f0d7f3 100644 --- a/ompi/mpi/fortran/mpif-h/scatterv_init_f.c +++ b/ompi/mpi/fortran/mpif-h/scatterv_init_f.c @@ -12,6 +12,8 @@ * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015-2021 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2025 Triad National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -78,7 +80,7 @@ void ompi_scatterv_init_f(char *sendbuf, MPI_Fint *sendcounts, MPI_Datatype c_sendtype, c_recvtype; MPI_Info c_info; MPI_Request c_request; - int size, idx = 0, c_ierr; + int size, c_ierr; OMPI_ARRAY_NAME_DECL(sendcounts); OMPI_ARRAY_NAME_DECL(displs); @@ -105,12 +107,11 @@ void ompi_scatterv_init_f(char *sendbuf, MPI_Fint *sendcounts, if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); if (MPI_SUCCESS == c_ierr) { *request = PMPI_Request_c2f(c_request); - ompi_coll_base_nbc_request_t* nb_request = (ompi_coll_base_nbc_request_t*)c_request; - if (sendcounts != OMPI_ARRAY_NAME_CONVERT(sendcounts)) { - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(sendcounts); - nb_request->data.release_arrays[idx++] = OMPI_ARRAY_NAME_CONVERT(displs); + if ((void *)sendcounts != (void *)OMPI_ARRAY_NAME_CONVERT(sendcounts)) { + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(sendcounts)); + ompi_coll_base_append_array_to_release(c_request, OMPI_ARRAY_NAME_CONVERT(displs)); + ompi_coll_base_add_release_arrays_cb(c_request); } - nb_request->data.release_arrays[idx] = NULL; } else { OMPI_ARRAY_FINT_2_INT_CLEANUP(sendcounts); OMPI_ARRAY_FINT_2_INT_CLEANUP(displs); diff --git a/ompi/mpi/fortran/use-mpi-f08/allgatherv_init_ts.c.in b/ompi/mpi/fortran/use-mpi-f08/allgatherv_init_ts.c.in index c559a5f107a..9c540a98e4d 100644 --- a/ompi/mpi/fortran/use-mpi-f08/allgatherv_init_ts.c.in +++ b/ompi/mpi/fortran/use-mpi-f08/allgatherv_init_ts.c.in @@ -12,7 +12,7 @@ * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015-2021 Research Organization for Information Science * and Technology (RIST). All rights reserved. - * Copyright (c) 2024 Triad National Security, LLC. All rights + * Copyright (c) 2024-2025 Triad National Security, LLC. All rights * reserved. * $COPYRIGHT$ * @@ -97,4 +97,7 @@ PROTOTYPE VOID allgatherv_init(BUFFER_ASYNC x1, COUNT sendcount, DATATYPE sendty } OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(recvcounts, tmp_recvcounts, c_request, c_ierr, idx); OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(displs, tmp_displs, c_request, c_ierr, idx); + if (idx > 0) { + ompi_coll_base_add_release_arrays_cb(c_request); + } } diff --git a/ompi/mpi/fortran/use-mpi-f08/alltoallv_init_ts.c.in b/ompi/mpi/fortran/use-mpi-f08/alltoallv_init_ts.c.in index 0b1608fd32f..8ab3a033ab8 100644 --- a/ompi/mpi/fortran/use-mpi-f08/alltoallv_init_ts.c.in +++ b/ompi/mpi/fortran/use-mpi-f08/alltoallv_init_ts.c.in @@ -12,7 +12,7 @@ * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015-2021 Research Organization for Information Science * and Technology (RIST). All rights reserved. - * Copyright (c) 2024 Triad National Security, LLC. All rights + * Copyright (c) 2024-2025 Triad National Security, LLC. All rights * reserved. * $COPYRIGHT$ * @@ -85,4 +85,7 @@ PROTOTYPE VOID alltoallv_init(BUFFER_ASYNC x1, COUNT_ARRAY sendcounts, DISP_ARRA OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(sdispls, tmp_sdispls, c_request, c_ierr, idx); OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(recvcounts, tmp_recvcounts, c_request, c_ierr, idx); OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(rdispls, tmp_rdispls, c_request, c_ierr, idx); + if (idx > 0) { + ompi_coll_base_add_release_arrays_cb(c_request); + } } diff --git a/ompi/mpi/fortran/use-mpi-f08/alltoallw_init_ts.c.in b/ompi/mpi/fortran/use-mpi-f08/alltoallw_init_ts.c.in index 34765cd1af1..b921309a646 100644 --- a/ompi/mpi/fortran/use-mpi-f08/alltoallw_init_ts.c.in +++ b/ompi/mpi/fortran/use-mpi-f08/alltoallw_init_ts.c.in @@ -12,7 +12,7 @@ * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015-2021 Research Organization for Information Science * and Technology (RIST). All rights reserved. - * Copyright (c) 2024 Triad National Security, LLC. All rights + * Copyright (c) 2024-2025 Triad National Security, LLC. All rights * reserved. * $COPYRIGHT$ * @@ -88,10 +88,17 @@ PROTOTYPE VOID alltoallw_init(BUFFER_ASYNC x1, COUNT_ARRAY sendcounts, if (MPI_SUCCESS == c_ierr) { *request = PMPI_Request_c2f(c_request); if (NULL != c_sendtypes) { - free(c_sendtypes); + ompi_coll_base_append_array_to_release(c_request, c_sendtypes); } + ompi_coll_base_append_array_to_release(c_request, c_recvtypes); + ompi_coll_base_add_release_arrays_cb(c_request); + } else { free(c_recvtypes); + if (NULL != c_sendtypes) { + free(c_sendtypes); + } } + OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(sendcounts, tmp_sendcounts, c_request, c_ierr, idx); OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(sdispls, tmp_sdispls, c_request, c_ierr, idx); OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(recvcounts, tmp_recvcounts, c_request, c_ierr, idx); diff --git a/ompi/mpi/fortran/use-mpi-f08/base/bigcount.h b/ompi/mpi/fortran/use-mpi-f08/base/bigcount.h index d7dd109005b..535737f2011 100644 --- a/ompi/mpi/fortran/use-mpi-f08/base/bigcount.h +++ b/ompi/mpi/fortran/use-mpi-f08/base/bigcount.h @@ -45,11 +45,10 @@ #define OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(array, tmp_array, c_request, c_ierr, idx) \ do { \ if (MPI_SUCCESS == (c_ierr)) { \ - ompi_coll_base_nbc_request_t* nb_request = (ompi_coll_base_nbc_request_t*)c_request; \ if ((void *)(array) != (void *)(tmp_array) && (tmp_array) != NULL) { \ - nb_request->data.release_arrays[(idx)++] = tmp_array; \ + ompi_coll_base_append_array_to_release((c_request), (tmp_array)); \ + (idx)++; \ } \ - nb_request->data.release_arrays[idx] = NULL; \ } else { \ OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP((array), (tmp_array)); \ } \ diff --git a/ompi/mpi/fortran/use-mpi-f08/gatherv_init_ts.c.in b/ompi/mpi/fortran/use-mpi-f08/gatherv_init_ts.c.in index da4c954cebb..5c35dd094e6 100644 --- a/ompi/mpi/fortran/use-mpi-f08/gatherv_init_ts.c.in +++ b/ompi/mpi/fortran/use-mpi-f08/gatherv_init_ts.c.in @@ -111,5 +111,8 @@ PROTOTYPE VOID gatherv_init(BUFFER_ASYNC x1, COUNT sendcount, DATATYPE sendtype, OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(recvcounts, tmp_recvcounts, c_request, c_ierr, idx); OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(displs, tmp_displs, c_request, c_ierr, idx); + if (idx > 0) { + ompi_coll_base_add_release_arrays_cb(c_request); + } } diff --git a/ompi/mpi/fortran/use-mpi-f08/iallgatherv_ts.c.in b/ompi/mpi/fortran/use-mpi-f08/iallgatherv_ts.c.in index 0323d69bb33..4a279711df2 100644 --- a/ompi/mpi/fortran/use-mpi-f08/iallgatherv_ts.c.in +++ b/ompi/mpi/fortran/use-mpi-f08/iallgatherv_ts.c.in @@ -25,7 +25,7 @@ PROTOTYPE VOID iallgatherv(BUFFER_ASYNC x1, COUNT sendcount, DATATYPE sendtype, BUFFER_ASYNC_OUT x2, COUNT_ARRAY recvcounts, DISP_ARRAY displs, DATATYPE recvtype, COMM comm, REQUEST_OUT request) { - int c_ierr; + int c_ierr, idx = 0; MPI_Comm c_comm = PMPI_Comm_f2c(*comm); @COUNT_TYPE@ c_sendcount = (@COUNT_TYPE@)*sendcount; MPI_Datatype c_sendtype = NULL, c_senddatatype = NULL; @@ -86,6 +86,10 @@ PROTOTYPE VOID iallgatherv(BUFFER_ASYNC x1, COUNT sendcount, DATATYPE sendtype, if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); if (MPI_SUCCESS == c_ierr) *request = PMPI_Request_c2f(c_request); - OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP(recvcounts, tmp_recvcounts); - OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP(displs, tmp_displs); + OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(recvcounts, tmp_recvcounts, c_request, c_ierr, idx); + OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(displs, tmp_displs, c_request, c_ierr, idx); + if (idx > 0) { + ompi_coll_base_add_release_arrays_cb(c_request); + } + } diff --git a/ompi/mpi/fortran/use-mpi-f08/ialltoallv_ts.c.in b/ompi/mpi/fortran/use-mpi-f08/ialltoallv_ts.c.in index 1e6b401f934..fc12804dbb7 100644 --- a/ompi/mpi/fortran/use-mpi-f08/ialltoallv_ts.c.in +++ b/ompi/mpi/fortran/use-mpi-f08/ialltoallv_ts.c.in @@ -26,7 +26,7 @@ PROTOTYPE VOID ialltoallv(BUFFER_ASYNC x1, COUNT_ARRAY sendcounts, DISP_ARRAY sd DISP_ARRAY rdispls, DATATYPE recvtype, COMM comm, REQUEST_OUT request) { - int c_ierr; + int c_ierr, idx = 0; MPI_Comm c_comm = PMPI_Comm_f2c(*comm); char *sendbuf = OMPI_CFI_BASE_ADDR(x1), *recvbuf = OMPI_CFI_BASE_ADDR(x2); MPI_Datatype c_sendtype = NULL, c_recvtype = PMPI_Type_f2c(*recvtype); @@ -76,8 +76,12 @@ PROTOTYPE VOID ialltoallv(BUFFER_ASYNC x1, COUNT_ARRAY sendcounts, DISP_ARRAY sd if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); if (MPI_SUCCESS == c_ierr) *request = PMPI_Request_c2f(c_request); - OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP(sendcounts, tmp_sendcounts); - OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP(sdispls, tmp_sdispls); - OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP(recvcounts, tmp_recvcounts); - OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP(rdispls, tmp_rdispls); + OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(sendcounts, tmp_sendcounts, c_request, c_ierr, idx); + OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(sdispls, tmp_sdispls, c_request, c_ierr, idx); + OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(recvcounts, tmp_recvcounts, c_request, c_ierr, idx); + OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(rdispls, tmp_rdispls, c_request, c_ierr, idx); + if (idx > 0) { + ompi_coll_base_add_release_arrays_cb(c_request); + } + } diff --git a/ompi/mpi/fortran/use-mpi-f08/ialltoallw_ts.c.in b/ompi/mpi/fortran/use-mpi-f08/ialltoallw_ts.c.in index dbeebf41910..d907d429d15 100644 --- a/ompi/mpi/fortran/use-mpi-f08/ialltoallw_ts.c.in +++ b/ompi/mpi/fortran/use-mpi-f08/ialltoallw_ts.c.in @@ -12,7 +12,7 @@ * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015-2019 Research Organization for Information Science * and Technology (RIST). All rights reserved. - * Copyright (c) 2024 Triad National Security, LLC. All rights + * Copyright (c) 2024-2025 Triad National Security, LLC. All rights * reserved. * $COPYRIGHT$ * @@ -28,9 +28,9 @@ PROTOTYPE VOID ialltoallw(BUFFER_ASYNC x1, COUNT_ARRAY sendcounts, COMM comm, REQUEST_OUT request) { MPI_Comm c_comm = PMPI_Comm_f2c(*comm); - MPI_Datatype *c_sendtypes = NULL, *c_recvtypes; + MPI_Datatype *c_sendtypes = NULL, *c_recvtypes = NULL; MPI_Request c_request; - int size, c_ierr; + int size, idx = 0, c_ierr; char *sendbuf = OMPI_CFI_BASE_ADDR(x1), *recvbuf = OMPI_CFI_BASE_ADDR(x2); @COUNT_TYPE@ *tmp_sendcounts = NULL; @DISP_TYPE@ *tmp_sdispls = NULL; @@ -80,14 +80,24 @@ PROTOTYPE VOID ialltoallw(BUFFER_ASYNC x1, COUNT_ARRAY sendcounts, tmp_rdispls, c_recvtypes, c_comm, &c_request); if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); - if (MPI_SUCCESS == c_ierr) *request = PMPI_Request_c2f(c_request); + if (MPI_SUCCESS == c_ierr) { + *request = PMPI_Request_c2f(c_request); + ompi_coll_base_append_array_to_release(c_request, c_recvtypes); + if (NULL != c_sendtypes) { + ompi_coll_base_append_array_to_release(c_request, c_sendtypes); + } + } else { + free(c_recvtypes); + if (NULL != c_sendtypes) { + free(c_sendtypes); + } + } - OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP(sendcounts, tmp_sendcounts); - OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP(sdispls, tmp_sdispls); - OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP(recvcounts, tmp_recvcounts); - OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP(rdispls, tmp_rdispls); - if (NULL != c_sendtypes) { - free(c_sendtypes); + OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(sendcounts, tmp_sendcounts, c_request, c_ierr, idx); + OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(sdispls, tmp_sdispls, c_request, c_ierr, idx); + OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(recvcounts, tmp_recvcounts, c_request, c_ierr, idx); + OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(rdispls, tmp_rdispls, c_request, c_ierr, idx); + if (idx > 0) { + ompi_coll_base_add_release_arrays_cb(c_request); } - free(c_recvtypes); } diff --git a/ompi/mpi/fortran/use-mpi-f08/igatherv_ts.c.in b/ompi/mpi/fortran/use-mpi-f08/igatherv_ts.c.in index f5f51bbd023..ea156532277 100644 --- a/ompi/mpi/fortran/use-mpi-f08/igatherv_ts.c.in +++ b/ompi/mpi/fortran/use-mpi-f08/igatherv_ts.c.in @@ -101,5 +101,8 @@ PROTOTYPE VOID igatherv(BUFFER_ASYNC x1, COUNT sendcount, DATATYPE sendtype, OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(recvcounts, tmp_recvcounts, c_request, c_ierr, idx); OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(displs, tmp_displs, c_request, c_ierr, idx); + if (idx > 0) { + ompi_coll_base_add_release_arrays_cb(c_request); + } } diff --git a/ompi/mpi/fortran/use-mpi-f08/ineighbor_allgatherv_ts.c.in b/ompi/mpi/fortran/use-mpi-f08/ineighbor_allgatherv_ts.c.in index 6cffe2c3007..13c1e80361a 100644 --- a/ompi/mpi/fortran/use-mpi-f08/ineighbor_allgatherv_ts.c.in +++ b/ompi/mpi/fortran/use-mpi-f08/ineighbor_allgatherv_ts.c.in @@ -15,7 +15,7 @@ * reserved. * Copyright (c) 2015-2019 Research Organization for Information Science * and Technology (RIST). All rights reserved. - * Copyright (c) 2024 Triad National Security, LLC. All rights + * Copyright (c) 2024-2025 Triad National Security, LLC. All rights * reserved. * $COPYRIGHT$ * @@ -35,7 +35,7 @@ PROTOTYPE VOID ineighbor_allgatherv(BUFFER_ASYNC x1, COUNT sendcount, DATATYPE s @COUNT_TYPE@ c_sendcount = (@COUNT_TYPE@) *sendcount; MPI_Datatype c_recvtype = PMPI_Type_f2c(*recvtype); MPI_Request c_request; - int size, c_ierr; + int size, c_ierr, idx = 0; @COUNT_TYPE@ *tmp_recvcounts = NULL; @DISP_TYPE@ *tmp_displs = NULL; @@ -73,6 +73,9 @@ PROTOTYPE VOID ineighbor_allgatherv(BUFFER_ASYNC x1, COUNT sendcount, DATATYPE s if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); if (MPI_SUCCESS == c_ierr) *request = PMPI_Request_c2f(c_request); - OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP(recvcounts, tmp_recvcounts); - OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP(displs, tmp_displs); + OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(recvcounts, tmp_recvcounts, c_request, c_ierr, idx); + OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(displs, tmp_displs, c_request, c_ierr, idx); + if (idx > 0) { + ompi_coll_base_add_release_arrays_cb(c_request); + } } diff --git a/ompi/mpi/fortran/use-mpi-f08/ineighbor_alltoallv_ts.c.in b/ompi/mpi/fortran/use-mpi-f08/ineighbor_alltoallv_ts.c.in index 1de86c01d45..27897ceaaab 100644 --- a/ompi/mpi/fortran/use-mpi-f08/ineighbor_alltoallv_ts.c.in +++ b/ompi/mpi/fortran/use-mpi-f08/ineighbor_alltoallv_ts.c.in @@ -15,7 +15,7 @@ * reserved. * Copyright (c) 2015-2019 Research Organization for Information Science * and Technology (RIST). All rights reserved. - * Copyright (c) 2024 Triad National Security, LLC. All rights + * Copyright (c) 2024-2025 Triad National Security, LLC. All rights * reserved. * $COPYRIGHT$ * @@ -32,7 +32,7 @@ PROTOTYPE VOID ineighbor_alltoallv(BUFFER_ASYNC x1, COUNT_ARRAY sendcounts, DISP MPI_Comm c_comm = PMPI_Comm_f2c(*comm); MPI_Datatype c_sendtype, c_recvtype; MPI_Request c_request; - int size, c_ierr; + int size, c_ierr, idx = 0; char *sendbuf = OMPI_CFI_BASE_ADDR(x1), *recvbuf = OMPI_CFI_BASE_ADDR(x2); @COUNT_TYPE@ *tmp_sendcounts = NULL; @DISP_TYPE@ *tmp_sdispls = NULL; @@ -76,8 +76,11 @@ PROTOTYPE VOID ineighbor_alltoallv(BUFFER_ASYNC x1, COUNT_ARRAY sendcounts, DISP if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); if (MPI_SUCCESS == c_ierr) *request = PMPI_Request_c2f(c_request); - OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP(sendcounts, tmp_sendcounts); - OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP(sdispls, tmp_sdispls); - OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP(recvcounts, tmp_recvcounts); - OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP(rdispls, tmp_rdispls); + OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(sendcounts, tmp_sendcounts, c_request, c_ierr, idx); + OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(sdispls, tmp_sdispls, c_request, c_ierr, idx); + OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(recvcounts, tmp_recvcounts, c_request, c_ierr, idx); + OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(rdispls, tmp_rdispls, c_request, c_ierr, idx); + if (idx > 0) { + ompi_coll_base_add_release_arrays_cb(c_request); + } } diff --git a/ompi/mpi/fortran/use-mpi-f08/ineighbor_alltoallw_ts.c.in b/ompi/mpi/fortran/use-mpi-f08/ineighbor_alltoallw_ts.c.in index 4c387b3dcde..89806b150f3 100644 --- a/ompi/mpi/fortran/use-mpi-f08/ineighbor_alltoallw_ts.c.in +++ b/ompi/mpi/fortran/use-mpi-f08/ineighbor_alltoallw_ts.c.in @@ -15,7 +15,7 @@ * reserved. * Copyright (c) 2015-2019 Research Organization for Information Science * and Technology (RIST). All rights reserved. - * Copyright (c) 2024 Triad National Security, LLC. All rights + * Copyright (c) 2024-2025 Triad National Security, LLC. All rights * reserved. * $COPYRIGHT$ * @@ -33,7 +33,7 @@ PROTOTYPE VOID ineighbor_alltoallw(BUFFER_ASYNC x1, COUNT_ARRAY sendcounts, MPI_Comm c_comm = PMPI_Comm_f2c(*comm); MPI_Datatype *c_sendtypes, *c_recvtypes; MPI_Request c_request; - int size, c_ierr; + int size, idx = 0, c_ierr; char *sendbuf = OMPI_CFI_BASE_ADDR(x1), *recvbuf = OMPI_CFI_BASE_ADDR(x2); @COUNT_TYPE@ *tmp_sendcounts = NULL; @COUNT_TYPE@ *tmp_recvcounts = NULL; @@ -77,10 +77,15 @@ PROTOTYPE VOID ineighbor_alltoallw(BUFFER_ASYNC x1, COUNT_ARRAY sendcounts, rdispls, c_recvtypes, c_comm, &c_request); if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); - if (MPI_SUCCESS == c_ierr) *request = PMPI_Request_c2f(c_request); - - OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP(sendcounts, tmp_sendcounts); - OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP(recvcounts, tmp_recvcounts); - free(c_sendtypes); - free(c_recvtypes); + if (MPI_SUCCESS == c_ierr) { + *request = PMPI_Request_c2f(c_request); + OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(sendcounts, tmp_sendcounts, c_request, c_ierr, idx); + OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(recvcounts, tmp_recvcounts, c_request, c_ierr, idx); + ompi_coll_base_append_array_to_release(c_request, c_sendtypes); + ompi_coll_base_append_array_to_release(c_request, c_recvtypes); + ompi_coll_base_add_release_arrays_cb(c_request); + } else { + free(c_sendtypes); + free(c_recvtypes); + } } diff --git a/ompi/mpi/fortran/use-mpi-f08/ireduce_scatter_ts.c.in b/ompi/mpi/fortran/use-mpi-f08/ireduce_scatter_ts.c.in index e6c319b03e3..ad5a874dab4 100644 --- a/ompi/mpi/fortran/use-mpi-f08/ireduce_scatter_ts.c.in +++ b/ompi/mpi/fortran/use-mpi-f08/ireduce_scatter_ts.c.in @@ -12,7 +12,7 @@ * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015-2019 Research Organization for Information Science * and Technology (RIST). All rights reserved. - * Copyright (c) 2024 Triad National Security, LLC. All rights + * Copyright (c) 2024-2025 Triad National Security, LLC. All rights * reserved. * $COPYRIGHT$ * @@ -62,5 +62,8 @@ PROTOTYPE VOID ireduce_scatter(BUFFER_ASYNC x1, BUFFER_ASYNC_OUT x2, if (MPI_SUCCESS == c_ierr) *request = PMPI_Request_c2f(c_request); OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(recvcounts, tmp_recvcounts, c_request, c_ierr, idx); + if (idx > 0) { + ompi_coll_base_add_release_arrays_cb(c_request); + } } diff --git a/ompi/mpi/fortran/use-mpi-f08/iscatterv_ts.c.in b/ompi/mpi/fortran/use-mpi-f08/iscatterv_ts.c.in index 7f983faed51..90736203310 100644 --- a/ompi/mpi/fortran/use-mpi-f08/iscatterv_ts.c.in +++ b/ompi/mpi/fortran/use-mpi-f08/iscatterv_ts.c.in @@ -13,7 +13,7 @@ * Copyright (c) 2015-2019 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2018 FUJITSU LIMITED. All rights reserved. - * Copyright (c) 2024 Triad National Security, LLC. All rights + * Copyright (c) 2024-2025 Triad National Security, LLC. All rights * reserved. * $COPYRIGHT$ * @@ -106,4 +106,7 @@ PROTOTYPE VOID iscatterv(BUFFER_ASYNC x1, COUNT_ARRAY sendcounts, OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(sendcounts, tmp_sendcounts, c_request, c_ierr, idx); OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(displs, tmp_displs, c_request, c_ierr, idx); + if (idx > 0) { + ompi_coll_base_add_release_arrays_cb(c_request); + } } diff --git a/ompi/mpi/fortran/use-mpi-f08/neighbor_allgatherv_init_ts.c.in b/ompi/mpi/fortran/use-mpi-f08/neighbor_allgatherv_init_ts.c.in index 394debf1c27..2d59884292e 100644 --- a/ompi/mpi/fortran/use-mpi-f08/neighbor_allgatherv_init_ts.c.in +++ b/ompi/mpi/fortran/use-mpi-f08/neighbor_allgatherv_init_ts.c.in @@ -84,4 +84,7 @@ PROTOTYPE VOID neighbor_allgatherv_init(BUFFER x1, COUNT sendcount, DATATYPE sen OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(recvcounts, tmp_recvcounts, c_request, c_ierr, idx); OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(displs, tmp_displs, c_request, c_ierr, idx); + if (idx > 0) { + ompi_coll_base_add_release_arrays_cb(c_request); + } } diff --git a/ompi/mpi/fortran/use-mpi-f08/neighbor_alltoallv_init_ts.c.in b/ompi/mpi/fortran/use-mpi-f08/neighbor_alltoallv_init_ts.c.in index 0a5729ccb03..e84364257e3 100644 --- a/ompi/mpi/fortran/use-mpi-f08/neighbor_alltoallv_init_ts.c.in +++ b/ompi/mpi/fortran/use-mpi-f08/neighbor_alltoallv_init_ts.c.in @@ -89,4 +89,7 @@ PROTOTYPE VOID neighbor_alltoallv_init(BUFFER x1, COUNT_ARRAY sendcounts, DISP_A OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(sendcounts, tmp_sendcounts, c_request, c_ierr, idx); OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(rdispls, tmp_rdispls, c_request, c_ierr, idx); OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(sdispls, tmp_sdispls, c_request, c_ierr, idx); + if (idx > 0) { + ompi_coll_base_add_release_arrays_cb(c_request); + } } diff --git a/ompi/mpi/fortran/use-mpi-f08/neighbor_alltoallw_init_ts.c.in b/ompi/mpi/fortran/use-mpi-f08/neighbor_alltoallw_init_ts.c.in index 8a514759b41..8ffa530b6d9 100644 --- a/ompi/mpi/fortran/use-mpi-f08/neighbor_alltoallw_init_ts.c.in +++ b/ompi/mpi/fortran/use-mpi-f08/neighbor_alltoallw_init_ts.c.in @@ -33,14 +33,14 @@ PROTOTYPE VOID neighbor_alltoallw_init(BUFFER x1, COUNT_ARRAY sendcounts, REQUEST_OUT request) { MPI_Comm c_comm = PMPI_Comm_f2c(*comm); - MPI_Datatype *c_sendtypes, *c_recvtypes; + MPI_Datatype *c_sendtypes = NULL, *c_recvtypes = NULL; MPI_Request c_request; MPI_Info c_info; int size, c_ierr, idx = 0; char *sendbuf = OMPI_CFI_BASE_ADDR(x1), *recvbuf = OMPI_CFI_BASE_ADDR(x2); @COUNT_TYPE@ *tmp_sendcounts = NULL; @COUNT_TYPE@ *tmp_recvcounts = NULL; - MPI_Aint *tmp_sdispls = NULL, *tmp_rdispls; + MPI_Aint *tmp_sdispls = NULL, *tmp_rdispls = NULL; c_info = PMPI_Info_f2c(*info); @@ -90,13 +90,16 @@ PROTOTYPE VOID neighbor_alltoallw_init(BUFFER x1, COUNT_ARRAY sendcounts, if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); if (MPI_SUCCESS == c_ierr) { *request = PMPI_Request_c2f(c_request); + ompi_coll_base_append_array_to_release(c_request, c_sendtypes); + ompi_coll_base_append_array_to_release(c_request, c_recvtypes); + ompi_coll_base_add_release_arrays_cb(c_request); + } else { + free(c_recvtypes); + free(c_sendtypes); } OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(recvcounts, tmp_recvcounts, c_request, c_ierr, idx); OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(sendcounts, tmp_sendcounts, c_request, c_ierr, idx); OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(rdispls, tmp_rdispls, c_request, c_ierr, idx); OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(sdispls, tmp_sdispls, c_request, c_ierr, idx); - - free(c_sendtypes); - free(c_recvtypes); } diff --git a/ompi/mpi/fortran/use-mpi-f08/reduce_scatter_init_ts.c.in b/ompi/mpi/fortran/use-mpi-f08/reduce_scatter_init_ts.c.in index a9a9d02a64b..c39c8ec33e9 100644 --- a/ompi/mpi/fortran/use-mpi-f08/reduce_scatter_init_ts.c.in +++ b/ompi/mpi/fortran/use-mpi-f08/reduce_scatter_init_ts.c.in @@ -12,7 +12,7 @@ * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015-2019 Research Organization for Information Science * and Technology (RIST). All rights reserved. - * Copyright (c) 2024 Triad National Security, LLC. All rights + * Copyright (c) 2024-2025 Triad National Security, LLC. All rights * reserved. * $COPYRIGHT$ * @@ -74,6 +74,9 @@ PROTOTYPE VOID reduce_scatter_init(BUFFER x1, BUFFER_OUT x2, } OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(recvcounts, tmp_recvcounts, c_request, c_ierr, idx); + if (idx > 0) { + ompi_coll_base_add_release_arrays_cb(c_request); + } if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); diff --git a/ompi/mpi/fortran/use-mpi-f08/scatterv_init_ts.c.in b/ompi/mpi/fortran/use-mpi-f08/scatterv_init_ts.c.in index 046f0669336..3f0756dbb7e 100644 --- a/ompi/mpi/fortran/use-mpi-f08/scatterv_init_ts.c.in +++ b/ompi/mpi/fortran/use-mpi-f08/scatterv_init_ts.c.in @@ -12,7 +12,7 @@ * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015-2021 Research Organization for Information Science * and Technology (RIST). All rights reserved. - * Copyright (c) 2024 Triad National Security, LLC. All rights + * Copyright (c) 2024-2025 Triad National Security, LLC. All rights * reserved. * $COPYRIGHT$ * @@ -110,6 +110,9 @@ PROTOTYPE VOID scatterv_init(BUFFER x1, COUNT_ARRAY sendcounts, OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(sendcounts, tmp_sendcounts, c_request, c_ierr, idx); OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP_NONBLOCKING(displs, tmp_displs, c_request, c_ierr, idx); + if (idx > 0) { + ompi_coll_base_add_release_arrays_cb(c_request); + } if ((c_recvdatatype != NULL ) && (c_recvdatatype != c_recvtype)){ ompi_datatype_destroy(&c_recvdatatype);