From aae73d9cf7517693cfc7b9280f1687d30178b4d9 Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Sat, 13 Jul 2019 18:36:12 +0900 Subject: [PATCH 1/5] fortran/mpif-h: fix C to Fortran error code conversion - remove incorrect use of OMPI_INT_2_FINT() - use homogenous syntax (e.g. c_ierr = PMPI_...()) Signed-off-by: Gilles Gouaillardet (cherry picked from commit open-mpi/ompi@223e6cc5377f968d135a44f0470a6de38740315c) --- ompi/mpi/fortran/mpif-h/comm_split_type_f.c | 14 +++++----- .../mpif-h/dist_graph_create_adjacent_f.c | 26 ++++++++++--------- ompi/mpi/fortran/mpif-h/dist_graph_create_f.c | 14 +++++----- .../mpif-h/dist_graph_neighbors_count_f.c | 14 +++++----- .../fortran/mpif-h/dist_graph_neighbors_f.c | 19 ++++++++------ ompi/mpi/fortran/mpif-h/improbe_f.c | 12 ++++----- ompi/mpi/fortran/mpif-h/imrecv_f.c | 8 +++--- ompi/mpi/fortran/mpif-h/mprobe_f.c | 10 +++---- ompi/mpi/fortran/mpif-h/mrecv_f.c | 8 +++--- 9 files changed, 67 insertions(+), 58 deletions(-) diff --git a/ompi/mpi/fortran/mpif-h/comm_split_type_f.c b/ompi/mpi/fortran/mpif-h/comm_split_type_f.c index c6eb7306a37..b35d45ac06f 100644 --- a/ompi/mpi/fortran/mpif-h/comm_split_type_f.c +++ b/ompi/mpi/fortran/mpif-h/comm_split_type_f.c @@ -11,8 +11,8 @@ * All rights reserved. * Copyright (c) 2012 Sandia National Laboratories. All rights reserved. * Copyright (c) 2012 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2015 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2015-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -77,11 +77,11 @@ void ompi_comm_split_type_f(MPI_Fint *comm, MPI_Fint *split_type, MPI_Fint *key, c_info = PMPI_Info_f2c(*info); - c_ierr = OMPI_INT_2_FINT(PMPI_Comm_split_type(c_comm, - OMPI_FINT_2_INT(*split_type), - OMPI_FINT_2_INT(*key), - c_info, - &c_newcomm )); + c_ierr = PMPI_Comm_split_type(c_comm, + OMPI_FINT_2_INT(*split_type), + OMPI_FINT_2_INT(*key), + c_info, + &c_newcomm); if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); if (MPI_SUCCESS == c_ierr) { diff --git a/ompi/mpi/fortran/mpif-h/dist_graph_create_adjacent_f.c b/ompi/mpi/fortran/mpif-h/dist_graph_create_adjacent_f.c index f9668b379a8..1f2e6bc795a 100644 --- a/ompi/mpi/fortran/mpif-h/dist_graph_create_adjacent_f.c +++ b/ompi/mpi/fortran/mpif-h/dist_graph_create_adjacent_f.c @@ -8,8 +8,8 @@ * Copyright (c) 2013-2014 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2014 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2015 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2015-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -78,6 +78,7 @@ void ompi_dist_graph_create_adjacent_f(MPI_Fint *comm_old, MPI_Fint *indegree, MPI_Info c_info; MPI_Comm c_comm_old, c_comm_graph; int *c_destweights, *c_sourceweights; + int c_ierr; OMPI_ARRAY_NAME_DECL(sources); OMPI_ARRAY_NAME_DECL(destinations); @@ -105,16 +106,17 @@ void ompi_dist_graph_create_adjacent_f(MPI_Fint *comm_old, MPI_Fint *indegree, c_destweights = OMPI_ARRAY_NAME_CONVERT(destweights); } - *ierr = OMPI_INT_2_FINT(PMPI_Dist_graph_create_adjacent(c_comm_old, OMPI_FINT_2_INT(*indegree), - OMPI_ARRAY_NAME_CONVERT(sources), - c_sourceweights, - OMPI_FINT_2_INT(*outdegree), - OMPI_ARRAY_NAME_CONVERT(destinations), - c_destweights, - c_info, - OMPI_LOGICAL_2_INT(*reorder), - &c_comm_graph)); - if (OMPI_SUCCESS == OMPI_FINT_2_INT(*ierr)) { + c_ierr = PMPI_Dist_graph_create_adjacent(c_comm_old, OMPI_FINT_2_INT(*indegree), + OMPI_ARRAY_NAME_CONVERT(sources), + c_sourceweights, + OMPI_FINT_2_INT(*outdegree), + OMPI_ARRAY_NAME_CONVERT(destinations), + c_destweights, + c_info, + OMPI_LOGICAL_2_INT(*reorder), + &c_comm_graph); + if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); + if (OMPI_SUCCESS == c_ierr) { *comm_graph = PMPI_Comm_c2f(c_comm_graph); } diff --git a/ompi/mpi/fortran/mpif-h/dist_graph_create_f.c b/ompi/mpi/fortran/mpif-h/dist_graph_create_f.c index 2692f9b7d06..3380be8a537 100644 --- a/ompi/mpi/fortran/mpif-h/dist_graph_create_f.c +++ b/ompi/mpi/fortran/mpif-h/dist_graph_create_f.c @@ -7,8 +7,8 @@ * Copyright (c) 2011-2013 Université Bordeaux 1 * Copyright (c) 2014 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2015 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2015-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -75,6 +75,7 @@ void ompi_dist_graph_create_f(MPI_Fint *comm_old, MPI_Fint *n, MPI_Fint *sources int count = 0, i; MPI_Info c_info; int *c_weights; + int c_ierr; OMPI_ARRAY_NAME_DECL(sources); OMPI_ARRAY_NAME_DECL(degrees); @@ -98,10 +99,11 @@ void ompi_dist_graph_create_f(MPI_Fint *comm_old, MPI_Fint *n, MPI_Fint *sources } - *ierr = OMPI_INT_2_FINT(PMPI_Dist_graph_create(c_comm_old, OMPI_FINT_2_INT(*n), OMPI_ARRAY_NAME_CONVERT(sources), - OMPI_ARRAY_NAME_CONVERT(degrees), OMPI_ARRAY_NAME_CONVERT(destinations), - c_weights, c_info, OMPI_LOGICAL_2_INT(*reorder), &c_comm_graph)); - if (OMPI_SUCCESS == OMPI_FINT_2_INT(*ierr)) { + c_ierr = PMPI_Dist_graph_create(c_comm_old, OMPI_FINT_2_INT(*n), OMPI_ARRAY_NAME_CONVERT(sources), + OMPI_ARRAY_NAME_CONVERT(degrees), OMPI_ARRAY_NAME_CONVERT(destinations), + c_weights, c_info, OMPI_LOGICAL_2_INT(*reorder), &c_comm_graph); + if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); + if (OMPI_SUCCESS == c_ierr) { *comm_graph = PMPI_Comm_c2f(c_comm_graph); } diff --git a/ompi/mpi/fortran/mpif-h/dist_graph_neighbors_count_f.c b/ompi/mpi/fortran/mpif-h/dist_graph_neighbors_count_f.c index 4f8611e783a..aad5aac5f80 100644 --- a/ompi/mpi/fortran/mpif-h/dist_graph_neighbors_count_f.c +++ b/ompi/mpi/fortran/mpif-h/dist_graph_neighbors_count_f.c @@ -4,7 +4,7 @@ * reserved. * Copyright (c) 2011-2013 Inria. All rights reserved. * Copyright (c) 2011-2013 Université Bordeaux 1 - * Copyright (c) 2015 Research Organization for Information Science + * Copyright (c) 2015-2019 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * @@ -69,15 +69,17 @@ void ompi_dist_graph_neighbors_count_f(MPI_Fint *comm, MPI_Fint *inneighbors, OMPI_SINGLE_NAME_DECL(inneighbors); OMPI_SINGLE_NAME_DECL(outneighbors); OMPI_LOGICAL_NAME_DECL(weighted); + int c_ierr; c_comm = PMPI_Comm_f2c(*comm); - *ierr = OMPI_INT_2_FINT(PMPI_Dist_graph_neighbors_count(c_comm, - OMPI_SINGLE_NAME_CONVERT(inneighbors), - OMPI_SINGLE_NAME_CONVERT(outneighbors), - OMPI_LOGICAL_SINGLE_NAME_CONVERT(weighted))); + c_ierr = PMPI_Dist_graph_neighbors_count(c_comm, + OMPI_SINGLE_NAME_CONVERT(inneighbors), + OMPI_SINGLE_NAME_CONVERT(outneighbors), + OMPI_LOGICAL_SINGLE_NAME_CONVERT(weighted)); + if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); OMPI_SINGLE_INT_2_LOGICAL(weighted); - if (OMPI_SUCCESS == OMPI_FINT_2_INT(*ierr)) { + if (OMPI_SUCCESS == c_ierr) { OMPI_SINGLE_INT_2_FINT(inneighbors); OMPI_SINGLE_INT_2_FINT(outneighbors); } diff --git a/ompi/mpi/fortran/mpif-h/dist_graph_neighbors_f.c b/ompi/mpi/fortran/mpif-h/dist_graph_neighbors_f.c index 5309b322c35..556d909ad1d 100644 --- a/ompi/mpi/fortran/mpif-h/dist_graph_neighbors_f.c +++ b/ompi/mpi/fortran/mpif-h/dist_graph_neighbors_f.c @@ -4,8 +4,8 @@ * reserved. * Copyright (c) 2011-2013 Inria. All rights reserved. * Copyright (c) 2011-2013 Université Bordeaux 1 - * Copyright (c) 2015 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2015-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -74,6 +74,7 @@ void ompi_dist_graph_neighbors_f(MPI_Fint* comm, MPI_Fint* maxindegree, OMPI_ARRAY_NAME_DECL(sourceweights); OMPI_ARRAY_NAME_DECL(destinations); OMPI_ARRAY_NAME_DECL(destweights); + int c_ierr; c_comm = PMPI_Comm_f2c(*comm); @@ -86,12 +87,14 @@ void ompi_dist_graph_neighbors_f(MPI_Fint* comm, MPI_Fint* maxindegree, OMPI_ARRAY_FINT_2_INT_ALLOC(destweights, *maxoutdegree); } - *ierr = OMPI_INT_2_FINT(PMPI_Dist_graph_neighbors(c_comm, OMPI_FINT_2_INT(*maxindegree), - OMPI_ARRAY_NAME_CONVERT(sources), - OMPI_IS_FORTRAN_UNWEIGHTED(sourceweights) ? MPI_UNWEIGHTED : OMPI_ARRAY_NAME_CONVERT(sourceweights), - OMPI_FINT_2_INT(*maxoutdegree), OMPI_ARRAY_NAME_CONVERT(destinations), - OMPI_IS_FORTRAN_UNWEIGHTED(destweights) ? MPI_UNWEIGHTED : OMPI_ARRAY_NAME_CONVERT(destweights))); - if (OMPI_SUCCESS == OMPI_FINT_2_INT(*ierr)) { + c_ierr = PMPI_Dist_graph_neighbors(c_comm, OMPI_FINT_2_INT(*maxindegree), + OMPI_ARRAY_NAME_CONVERT(sources), + OMPI_IS_FORTRAN_UNWEIGHTED(sourceweights) ? MPI_UNWEIGHTED : OMPI_ARRAY_NAME_CONVERT(sourceweights), + OMPI_FINT_2_INT(*maxoutdegree), OMPI_ARRAY_NAME_CONVERT(destinations), + OMPI_IS_FORTRAN_UNWEIGHTED(destweights) ? MPI_UNWEIGHTED : OMPI_ARRAY_NAME_CONVERT(destweights)); + if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); + + if (OMPI_SUCCESS == c_ierr) { OMPI_ARRAY_INT_2_FINT(sources, *maxindegree); if( !OMPI_IS_FORTRAN_UNWEIGHTED(sourceweights) ) { OMPI_ARRAY_INT_2_FINT(sourceweights, *maxindegree); diff --git a/ompi/mpi/fortran/mpif-h/improbe_f.c b/ompi/mpi/fortran/mpif-h/improbe_f.c index 8d7764fffd1..936cc4e399c 100644 --- a/ompi/mpi/fortran/mpif-h/improbe_f.c +++ b/ompi/mpi/fortran/mpif-h/improbe_f.c @@ -11,8 +11,8 @@ * All rights reserved. * Copyright (c) 2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2015 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2015-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * Copyright (c) 2015 FUJITSU LIMITED. All rights reserved. * $COPYRIGHT$ * @@ -87,10 +87,10 @@ void ompi_improbe_f(MPI_Fint *source, MPI_Fint *tag, MPI_Fint *comm, OMPI_FORTRAN_STATUS_SET_POINTER(c_status,c_status2,status) - c_ierr = OMPI_INT_2_FINT(PMPI_Improbe(OMPI_FINT_2_INT(*source), - OMPI_FINT_2_INT(*tag), - c_comm, OMPI_LOGICAL_SINGLE_NAME_CONVERT(flag), - &c_message, c_status)); + c_ierr = PMPI_Improbe(OMPI_FINT_2_INT(*source), + OMPI_FINT_2_INT(*tag), + c_comm, OMPI_LOGICAL_SINGLE_NAME_CONVERT(flag), + &c_message, c_status); if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); if (MPI_SUCCESS == c_ierr) { diff --git a/ompi/mpi/fortran/mpif-h/imrecv_f.c b/ompi/mpi/fortran/mpif-h/imrecv_f.c index 4ba7a13a2ad..2f706d941c1 100644 --- a/ompi/mpi/fortran/mpif-h/imrecv_f.c +++ b/ompi/mpi/fortran/mpif-h/imrecv_f.c @@ -10,8 +10,8 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2012 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2015 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2015-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * Copyright (c) 2015 FUJITSU LIMITED. All rights reserved. * $COPYRIGHT$ * @@ -80,8 +80,8 @@ void ompi_imrecv_f(char *buf, MPI_Fint *count, MPI_Fint *datatype, c_message = PMPI_Message_f2c(*message); - c_ierr = OMPI_INT_2_FINT(PMPI_Imrecv(OMPI_F2C_BOTTOM(buf), OMPI_FINT_2_INT(*count), - c_type, &c_message, &c_req)); + c_ierr = PMPI_Imrecv(OMPI_F2C_BOTTOM(buf), OMPI_FINT_2_INT(*count), + c_type, &c_message, &c_req); if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); if (MPI_SUCCESS == c_ierr) { diff --git a/ompi/mpi/fortran/mpif-h/mprobe_f.c b/ompi/mpi/fortran/mpif-h/mprobe_f.c index db39bce941c..0558e9543f8 100644 --- a/ompi/mpi/fortran/mpif-h/mprobe_f.c +++ b/ompi/mpi/fortran/mpif-h/mprobe_f.c @@ -12,7 +12,7 @@ * Copyright (c) 2011 Sandia National Laboratories. All rights reserved. * Copyright (c) 2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2015 Research Organization for Information Science + * Copyright (c) 2015-2019 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2015 FUJITSU LIMITED. All rights reserved. * $COPYRIGHT$ @@ -86,10 +86,10 @@ void ompi_mprobe_f(MPI_Fint *source, MPI_Fint *tag, MPI_Fint *comm, OMPI_FORTRAN_STATUS_SET_POINTER(c_status,c_status2,status) - c_ierr = OMPI_INT_2_FINT(PMPI_Mprobe(OMPI_FINT_2_INT(*source), - OMPI_FINT_2_INT(*tag), - c_comm, &c_message, - c_status)); + c_ierr = PMPI_Mprobe(OMPI_FINT_2_INT(*source), + OMPI_FINT_2_INT(*tag), + c_comm, &c_message, + c_status); if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); if (MPI_SUCCESS == c_ierr) { diff --git a/ompi/mpi/fortran/mpif-h/mrecv_f.c b/ompi/mpi/fortran/mpif-h/mrecv_f.c index 33a122510cd..8a898ce7f5d 100644 --- a/ompi/mpi/fortran/mpif-h/mrecv_f.c +++ b/ompi/mpi/fortran/mpif-h/mrecv_f.c @@ -77,16 +77,16 @@ void ompi_mrecv_f(char *buf, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *message, MPI_Fint *status, MPI_Fint *ierr) { int c_ierr; - OMPI_FORTRAN_STATUS_DECLARATION(c_status,c_status2) + OMPI_FORTRAN_STATUS_DECLARATION(c_status,c_status2) MPI_Message c_message = PMPI_Message_f2c(*message); MPI_Datatype c_type = PMPI_Type_f2c(*datatype); OMPI_FORTRAN_STATUS_SET_POINTER(c_status,c_status2,status) /* Call the C function */ - c_ierr = OMPI_INT_2_FINT(PMPI_Mrecv(OMPI_F2C_BOTTOM(buf), OMPI_FINT_2_INT(*count), - c_type, &c_message, - c_status)); + c_ierr = PMPI_Mrecv(OMPI_F2C_BOTTOM(buf), OMPI_FINT_2_INT(*count), + c_type, &c_message, + c_status); if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); if (MPI_SUCCESS == c_ierr) { From fbf7d31fd18e09ee5acfebcb03414920ada0cc17 Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Sat, 13 Jul 2019 22:08:11 +0900 Subject: [PATCH 2/5] fortran/mpif-h: fix MPI_[I]Alltoallw() binding - ignore sendcounts, sendispls and sendtypes arguments when MPI_IN_PLACE is used - use the right size when an inter-communicator is used. Thanks Markus Geimer for reporting this. Refs. open-mpi/ompi#5459 Signed-off-by: Gilles Gouaillardet (cherry picked from commit open-mpi/ompi@cdaed89d0481e8352a6c1a6cb8f71a250ea9352b) --- ompi/mpi/fortran/mpif-h/alltoallw_f.c | 29 +++++++++++++---------- ompi/mpi/fortran/mpif-h/ialltoallw_f.c | 32 +++++++++++++++----------- 2 files changed, 36 insertions(+), 25 deletions(-) diff --git a/ompi/mpi/fortran/mpif-h/alltoallw_f.c b/ompi/mpi/fortran/mpif-h/alltoallw_f.c index cb2328cf972..581eb7288e1 100644 --- a/ompi/mpi/fortran/mpif-h/alltoallw_f.c +++ b/ompi/mpi/fortran/mpif-h/alltoallw_f.c @@ -10,7 +10,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2015 Research Organization for Information Science + * Copyright (c) 2015-2019 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * @@ -23,6 +23,7 @@ #include "ompi/mpi/fortran/mpif-h/bindings.h" #include "ompi/mpi/fortran/base/constants.h" +#include "ompi/communicator/communicator.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -82,20 +83,22 @@ void ompi_alltoallw_f(char *sendbuf, MPI_Fint *sendcounts, OMPI_ARRAY_NAME_DECL(rdispls); c_comm = PMPI_Comm_f2c(*comm); - PMPI_Comm_size(c_comm, &size); + size = OMPI_COMM_IS_INTER(c_comm)?ompi_comm_remote_size(c_comm):ompi_comm_size(c_comm); - c_sendtypes = (MPI_Datatype *) malloc(size * sizeof(MPI_Datatype)); - c_recvtypes = (MPI_Datatype *) malloc(size * sizeof(MPI_Datatype)); + if (!OMPI_IS_FORTRAN_IN_PLACE(sendbuf)) { + c_sendtypes = (MPI_Datatype *) malloc(size * sizeof(MPI_Datatype)); + OMPI_ARRAY_FINT_2_INT(sendcounts, size); + OMPI_ARRAY_FINT_2_INT(sdispls, size); + for (int i=0; i 0) { - c_sendtypes[size - 1] = PMPI_Type_f2c(sendtypes[size - 1]); - c_recvtypes[size - 1] = PMPI_Type_f2c(recvtypes[size - 1]); - --size; + for (int i=0; i 0) { - c_sendtypes[size - 1] = PMPI_Type_f2c(sendtypes[size - 1]); - c_recvtypes[size - 1] = PMPI_Type_f2c(recvtypes[size - 1]); - --size; + for (int i=0; i Date: Wed, 17 Jul 2019 09:28:43 +0900 Subject: [PATCH 3/5] fortran/mpif-h: fix [i]alltoallw bindings Fix a regression introduced in open-mpi/ompi@cdaed89d0481e8352a6c1a6cb8f71a250ea9352b Fixes CID 1451610, 1451611 and 1451612 Signed-off-by: Gilles Gouaillardet (cherry picked from commit open-mpi/ompi@ed703bec1bcfc5425598ccc197a3735e6cef19d8) --- ompi/mpi/fortran/mpif-h/alltoallw_f.c | 4 ++-- ompi/mpi/fortran/mpif-h/ialltoallw_f.c | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/ompi/mpi/fortran/mpif-h/alltoallw_f.c b/ompi/mpi/fortran/mpif-h/alltoallw_f.c index 581eb7288e1..55b782a7928 100644 --- a/ompi/mpi/fortran/mpif-h/alltoallw_f.c +++ b/ompi/mpi/fortran/mpif-h/alltoallw_f.c @@ -75,7 +75,7 @@ void ompi_alltoallw_f(char *sendbuf, MPI_Fint *sendcounts, MPI_Fint *comm, MPI_Fint *ierr) { MPI_Comm c_comm; - MPI_Datatype *c_sendtypes, *c_recvtypes; + MPI_Datatype *c_sendtypes = NULL, *c_recvtypes; int size, c_ierr; OMPI_ARRAY_NAME_DECL(sendcounts); OMPI_ARRAY_NAME_DECL(sdispls); @@ -119,7 +119,7 @@ void ompi_alltoallw_f(char *sendbuf, MPI_Fint *sendcounts, OMPI_ARRAY_FINT_2_INT_CLEANUP(sdispls); OMPI_ARRAY_FINT_2_INT_CLEANUP(recvcounts); OMPI_ARRAY_FINT_2_INT_CLEANUP(rdispls); - if (MPI_IN_PLACE != sendbuf) { + if (NULL != c_sendtypes) { free(c_sendtypes); } free(c_recvtypes); diff --git a/ompi/mpi/fortran/mpif-h/ialltoallw_f.c b/ompi/mpi/fortran/mpif-h/ialltoallw_f.c index 2aed76900e8..75f8262bef5 100644 --- a/ompi/mpi/fortran/mpif-h/ialltoallw_f.c +++ b/ompi/mpi/fortran/mpif-h/ialltoallw_f.c @@ -75,7 +75,7 @@ void ompi_ialltoallw_f(char *sendbuf, MPI_Fint *sendcounts, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *ierr) { MPI_Comm c_comm; - MPI_Datatype *c_sendtypes, *c_recvtypes; + MPI_Datatype *c_sendtypes = NULL, *c_recvtypes; MPI_Request c_request; int size, c_ierr; OMPI_ARRAY_NAME_DECL(sendcounts); @@ -101,7 +101,6 @@ void ompi_ialltoallw_f(char *sendbuf, MPI_Fint *sendcounts, for (int i=0; i Date: Wed, 17 Jul 2019 09:30:09 +0900 Subject: [PATCH 4/5] pcollreq/mpif-h: fix MPIX_Alltoallw_init() binding Signed-off-by: Gilles Gouaillardet (cherry picked from commit open-mpi/ompi@b71af0eca0ed8b5acf2bdddc720e163cf491422a) --- .../mpiext/pcollreq/mpif-h/alltoallw_init_f.c | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/ompi/mpiext/pcollreq/mpif-h/alltoallw_init_f.c b/ompi/mpiext/pcollreq/mpif-h/alltoallw_init_f.c index 183d739f797..a90047c093f 100644 --- a/ompi/mpiext/pcollreq/mpif-h/alltoallw_init_f.c +++ b/ompi/mpiext/pcollreq/mpif-h/alltoallw_init_f.c @@ -10,8 +10,8 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2015-2018 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2015-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -23,6 +23,7 @@ #include "ompi/mpi/fortran/mpif-h/bindings.h" #include "ompi/mpi/fortran/base/constants.h" +#include "ompi/communicator/communicator.h" #include "ompi/mpiext/pcollreq/mpif-h/mpiext_pcollreq_prototypes.h" #if OMPI_BUILD_MPI_PROFILING @@ -85,22 +86,22 @@ void ompix_alltoallw_init_f(char *sendbuf, MPI_Fint *sendcounts, OMPI_ARRAY_NAME_DECL(rdispls); c_comm = PMPI_Comm_f2c(*comm); - PMPI_Comm_size(c_comm, &size); + size = OMPI_COMM_IS_INTER(c_comm)?ompi_comm_remote_size(c_comm):ompi_comm_size(c_comm); + + if (!OMPI_IS_FORTRAN_IN_PLACE(sendbuf)) { + c_sendtypes = (MPI_Datatype *) malloc(size * sizeof(MPI_Datatype)); + OMPI_ARRAY_FINT_2_INT(sendcounts, size); + OMPI_ARRAY_FINT_2_INT(sdispls, size); + for (int i=0; i 0) { - c_sendtypes[size - 1] = PMPI_Type_f2c(sendtypes[size - 1]); - c_recvtypes[size - 1] = PMPI_Type_f2c(recvtypes[size - 1]); - --size; + for (int i=0; i Date: Tue, 23 Jul 2019 08:45:17 +0900 Subject: [PATCH 5/5] pcollreq/mpif-h: fix MPIX_Alltoallw_init() binding These issues were introduced in the recent commit b71af0eca0. This commit fixes Coverity CID 1451661 and 1451660. Though `c_info` part was an actual bug, the `c_sendtypes` part was not. Signed-off-by: KAWASHIMA Takahiro (cherry picked from commit open-mpi/ompi@facf8c5e98b22a615d50a56f0a2ae94515ef0bad) --- ompi/mpiext/pcollreq/mpif-h/alltoallw_init_f.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ompi/mpiext/pcollreq/mpif-h/alltoallw_init_f.c b/ompi/mpiext/pcollreq/mpif-h/alltoallw_init_f.c index a90047c093f..0fae1e194db 100644 --- a/ompi/mpiext/pcollreq/mpif-h/alltoallw_init_f.c +++ b/ompi/mpiext/pcollreq/mpif-h/alltoallw_init_f.c @@ -76,7 +76,7 @@ void ompix_alltoallw_init_f(char *sendbuf, MPI_Fint *sendcounts, MPI_Fint *comm, MPI_Fint *info, MPI_Fint *request, MPI_Fint *ierr) { MPI_Comm c_comm; - MPI_Datatype *c_sendtypes, *c_recvtypes; + MPI_Datatype *c_sendtypes = NULL, *c_recvtypes; MPI_Info c_info; MPI_Request c_request; int size, c_ierr; @@ -86,6 +86,7 @@ void ompix_alltoallw_init_f(char *sendbuf, MPI_Fint *sendcounts, OMPI_ARRAY_NAME_DECL(rdispls); c_comm = PMPI_Comm_f2c(*comm); + c_info = PMPI_Info_f2c(*info); size = OMPI_COMM_IS_INTER(c_comm)?ompi_comm_remote_size(c_comm):ompi_comm_size(c_comm); if (!OMPI_IS_FORTRAN_IN_PLACE(sendbuf)) {