diff --git a/config/ompi_config_files.m4 b/config/ompi_config_files.m4 index 274b404d75d..24e3143419d 100644 --- a/config/ompi_config_files.m4 +++ b/config/ompi_config_files.m4 @@ -1,8 +1,8 @@ # -*- shell-script -*- # # Copyright (c) 2009-2017 Cisco Systems, Inc. All rights reserved -# Copyright (c) 2017-2018 Research Organization for Information Science -# and Technology (RIST). All rights reserved. +# Copyright (c) 2017-2019 Research Organization for Information Science +# and Technology (RIST). All rights reserved. # Copyright (c) 2018 Los Alamos National Security, LLC. All rights # reserved. # Copyright (c) 2018 FUJITSU LIMITED. All rights reserved. @@ -38,6 +38,7 @@ AC_DEFUN([OMPI_CONFIG_FILES],[ ompi/mpi/fortran/use-mpi-ignore-tkr/mpi-ignore-tkr-file-interfaces.h ompi/mpi/fortran/use-mpi-ignore-tkr/mpi-ignore-tkr-removed-interfaces.h ompi/mpi/fortran/use-mpi-f08/Makefile + ompi/mpi/fortran/use-mpi-f08/profile/Makefile ompi/mpi/fortran/use-mpi-f08/bindings/Makefile ompi/mpi/fortran/use-mpi-f08/mod/Makefile ompi/mpi/fortran/mpiext-use-mpi/Makefile diff --git a/ompi/mpi/fortran/base/fint_2_int.h b/ompi/mpi/fortran/base/fint_2_int.h index 44ce1289567..3583711b428 100644 --- a/ompi/mpi/fortran/base/fint_2_int.h +++ b/ompi/mpi/fortran/base/fint_2_int.h @@ -47,6 +47,7 @@ #define OMPI_SINGLE_FINT_2_INT(in) #define OMPI_SINGLE_INT_2_FINT(in) #define OMPI_ARRAY_INT_2_FINT(in, n) + #define OMPI_COND_STATEMENT(a) #elif OMPI_SIZEOF_FORTRAN_INTEGER > SIZEOF_INT #define OMPI_ARRAY_NAME_DECL(a) int *c_##a @@ -105,6 +106,8 @@ } \ free(OMPI_ARRAY_NAME_CONVERT(in)); \ } while (0) + + #define OMPI_COND_STATEMENT(a) a #else /* int > MPI_Fint */ #define OMPI_ARRAY_NAME_DECL(a) int *c_##a #define OMPI_2_DIM_ARRAY_NAME_DECL(a, dim2) int (*c_##a)[dim2], dim2_index @@ -157,6 +160,7 @@ free(OMPI_ARRAY_NAME_CONVERT(in)); \ } while (0) + #define OMPI_COND_STATEMENT(a) a #endif /* diff --git a/ompi/mpi/fortran/mpif-h/allgather_f.c b/ompi/mpi/fortran/mpif-h/allgather_f.c index 1e9c56caaf9..559df38d485 100644 --- a/ompi/mpi/fortran/mpif-h/allgather_f.c +++ b/ompi/mpi/fortran/mpif-h/allgather_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 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" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -73,13 +74,16 @@ void ompi_allgather_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, { int ierr_c; MPI_Comm c_comm; - MPI_Datatype c_sendtype, c_recvtype; + MPI_Datatype c_sendtype = NULL, c_recvtype; c_comm = PMPI_Comm_f2c(*comm); - c_sendtype = PMPI_Type_f2c(*sendtype); + if (OMPI_COMM_IS_INTER(c_comm) || !OMPI_IS_FORTRAN_IN_PLACE(sendbuf)) { + c_sendtype = PMPI_Type_f2c(*sendtype); + } else { + sendbuf = MPI_IN_PLACE; + } c_recvtype = PMPI_Type_f2c(*recvtype); - sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf); sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf); recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf); diff --git a/ompi/mpi/fortran/mpif-h/allgatherv_f.c b/ompi/mpi/fortran/mpif-h/allgatherv_f.c index 7917136c0f1..c6d611761aa 100644 --- a/ompi/mpi/fortran/mpif-h/allgatherv_f.c +++ b/ompi/mpi/fortran/mpif-h/allgatherv_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 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" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -72,20 +73,28 @@ void ompi_allgatherv_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, MPI_Fint *recvtype, MPI_Fint *comm, MPI_Fint *ierr) { MPI_Comm c_comm; - MPI_Datatype c_sendtype, c_recvtype; - int size, ierr_c; + MPI_Datatype c_sendtype = NULL, c_recvtype; + int ierr_c; + OMPI_COND_STATEMENT(int size); OMPI_ARRAY_NAME_DECL(recvcounts); OMPI_ARRAY_NAME_DECL(displs); c_comm = PMPI_Comm_f2c(*comm); - c_sendtype = PMPI_Type_f2c(*sendtype); + if (OMPI_COMM_IS_INTER(c_comm)) { + OMPI_COND_STATEMENT(size = ompi_comm_remote_size(c_comm)); + } else { + OMPI_COND_STATEMENT(size = ompi_comm_size(c_comm)); + if (OMPI_IS_FORTRAN_IN_PLACE(sendbuf)) { + sendbuf = MPI_IN_PLACE; + } else { + c_sendtype = PMPI_Type_f2c(*sendtype); + } + } c_recvtype = PMPI_Type_f2c(*recvtype); - PMPI_Comm_size(c_comm, &size); OMPI_ARRAY_FINT_2_INT(recvcounts, size); OMPI_ARRAY_FINT_2_INT(displs, size); - sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf); sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf); recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf); diff --git a/ompi/mpi/fortran/mpif-h/alltoall_f.c b/ompi/mpi/fortran/mpif-h/alltoall_f.c index 2934fe97e49..b025d8aebdd 100644 --- a/ompi/mpi/fortran/mpif-h/alltoall_f.c +++ b/ompi/mpi/fortran/mpif-h/alltoall_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 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" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -73,13 +74,18 @@ void ompi_alltoall_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, { int c_ierr; MPI_Comm c_comm; - MPI_Datatype c_sendtype, c_recvtype; + MPI_Datatype c_sendtype = NULL, c_recvtype; c_comm = PMPI_Comm_f2c(*comm); - c_sendtype = PMPI_Type_f2c(*sendtype); + + if (OMPI_IS_FORTRAN_IN_PLACE(sendbuf)) { + sendbuf = MPI_IN_PLACE; + } else { + c_sendtype = PMPI_Type_f2c(*sendtype); + } + c_recvtype = PMPI_Type_f2c(*recvtype); - sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf); sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf); recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf); diff --git a/ompi/mpi/fortran/mpif-h/alltoallv_f.c b/ompi/mpi/fortran/mpif-h/alltoallv_f.c index 3b7b588c5e7..04630d97a37 100644 --- a/ompi/mpi/fortran/mpif-h/alltoallv_f.c +++ b/ompi/mpi/fortran/mpif-h/alltoallv_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 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" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -73,39 +74,45 @@ void ompi_alltoallv_f(char *sendbuf, MPI_Fint *sendcounts, MPI_Fint *sdispls, MPI_Fint *comm, MPI_Fint *ierr) { MPI_Comm c_comm; - MPI_Datatype c_sendtype, c_recvtype; - int size, c_ierr; + MPI_Datatype c_sendtype = NULL, c_recvtype; + int c_ierr; OMPI_ARRAY_NAME_DECL(sendcounts); OMPI_ARRAY_NAME_DECL(sdispls); OMPI_ARRAY_NAME_DECL(recvcounts); OMPI_ARRAY_NAME_DECL(rdispls); c_comm = PMPI_Comm_f2c(*comm); - c_sendtype = PMPI_Type_f2c(*sendtype); - c_recvtype = PMPI_Type_f2c(*recvtype); + OMPI_COND_STATEMENT(int 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)) { + sendbuf = MPI_IN_PLACE; + } else { + c_sendtype = PMPI_Type_f2c(*sendtype); + OMPI_ARRAY_FINT_2_INT(sendcounts, size); + OMPI_ARRAY_FINT_2_INT(sdispls, size); + } - PMPI_Comm_size(c_comm, &size); - OMPI_ARRAY_FINT_2_INT(sendcounts, size); - OMPI_ARRAY_FINT_2_INT(sdispls, size); + c_recvtype = PMPI_Type_f2c(*recvtype); OMPI_ARRAY_FINT_2_INT(recvcounts, size); OMPI_ARRAY_FINT_2_INT(rdispls, size); - sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf); sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf); recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf); c_ierr = PMPI_Alltoallv(sendbuf, - OMPI_ARRAY_NAME_CONVERT(sendcounts), - OMPI_ARRAY_NAME_CONVERT(sdispls), - c_sendtype, - recvbuf, - OMPI_ARRAY_NAME_CONVERT(recvcounts), - OMPI_ARRAY_NAME_CONVERT(rdispls), - c_recvtype, c_comm); + OMPI_ARRAY_NAME_CONVERT(sendcounts), + OMPI_ARRAY_NAME_CONVERT(sdispls), + c_sendtype, + recvbuf, + OMPI_ARRAY_NAME_CONVERT(recvcounts), + OMPI_ARRAY_NAME_CONVERT(rdispls), + c_recvtype, c_comm); if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); - OMPI_ARRAY_FINT_2_INT_CLEANUP(sendcounts); - OMPI_ARRAY_FINT_2_INT_CLEANUP(sdispls); + if (MPI_IN_PLACE != sendbuf) { + OMPI_ARRAY_FINT_2_INT_CLEANUP(sendcounts); + OMPI_ARRAY_FINT_2_INT_CLEANUP(sdispls); + } OMPI_ARRAY_FINT_2_INT_CLEANUP(recvcounts); OMPI_ARRAY_FINT_2_INT_CLEANUP(rdispls); } diff --git a/ompi/mpi/fortran/mpif-h/alltoallw_f.c b/ompi/mpi/fortran/mpif-h/alltoallw_f.c index 55b782a7928..bb7ee99dee6 100644 --- a/ompi/mpi/fortran/mpif-h/alltoallw_f.c +++ b/ompi/mpi/fortran/mpif-h/alltoallw_f.c @@ -11,7 +11,7 @@ * All rights reserved. * 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. + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -85,7 +85,9 @@ void ompi_alltoallw_f(char *sendbuf, MPI_Fint *sendcounts, c_comm = PMPI_Comm_f2c(*comm); 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)) { + if (OMPI_IS_FORTRAN_IN_PLACE(sendbuf)) { + sendbuf = MPI_IN_PLACE; + } else { c_sendtypes = (MPI_Datatype *) malloc(size * sizeof(MPI_Datatype)); OMPI_ARRAY_FINT_2_INT(sendcounts, size); OMPI_ARRAY_FINT_2_INT(sdispls, size); diff --git a/ompi/mpi/fortran/mpif-h/gather_f.c b/ompi/mpi/fortran/mpif-h/gather_f.c index 0019d17d1c9..9fa3947435a 100644 --- a/ompi/mpi/fortran/mpif-h/gather_f.c +++ b/ompi/mpi/fortran/mpif-h/gather_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 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" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -71,15 +72,29 @@ void ompi_gather_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, char *recvbuf, MPI_Fint *recvcount, MPI_Fint *recvtype, MPI_Fint *root, MPI_Fint *comm, MPI_Fint *ierr) { - int c_ierr; + int c_root, c_ierr; MPI_Comm c_comm; - MPI_Datatype c_sendtype, c_recvtype; + MPI_Datatype c_sendtype = NULL, c_recvtype = NULL; c_comm = PMPI_Comm_f2c(*comm); - c_sendtype = PMPI_Type_f2c(*sendtype); - c_recvtype = PMPI_Type_f2c(*recvtype); + c_root = OMPI_FINT_2_INT(*root); + if (OMPI_COMM_IS_INTER(c_comm)) { + if (MPI_ROOT == c_root) { + c_recvtype = PMPI_Type_f2c(*recvtype); + } else if (MPI_PROC_NULL != c_root) { + c_sendtype = PMPI_Type_f2c(*sendtype); + } + } else { + if (OMPI_IS_FORTRAN_IN_PLACE(sendbuf)) { + sendbuf = MPI_IN_PLACE; + } else { + c_sendtype = PMPI_Type_f2c(*sendtype); + } + if (ompi_comm_rank(c_comm) == c_root) { + c_recvtype = PMPI_Type_f2c(*recvtype); + } + } - sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf); sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf); recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf); @@ -87,7 +102,7 @@ void ompi_gather_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, c_sendtype, recvbuf, OMPI_FINT_2_INT(*recvcount), c_recvtype, - OMPI_FINT_2_INT(*root), + c_root, c_comm); if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); } diff --git a/ompi/mpi/fortran/mpif-h/gatherv_f.c b/ompi/mpi/fortran/mpif-h/gatherv_f.c index ef235ebe686..e989dc764f4 100644 --- a/ompi/mpi/fortran/mpif-h/gatherv_f.c +++ b/ompi/mpi/fortran/mpif-h/gatherv_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 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" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -73,20 +74,36 @@ void ompi_gatherv_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, MPI_Fint *ierr) { MPI_Comm c_comm; - MPI_Datatype c_sendtype, c_recvtype; - int size, c_ierr; + MPI_Datatype c_sendtype = NULL, c_recvtype = NULL; + int c_root, c_ierr; OMPI_ARRAY_NAME_DECL(recvcounts); OMPI_ARRAY_NAME_DECL(displs); c_comm = PMPI_Comm_f2c(*comm); - c_sendtype = PMPI_Type_f2c(*sendtype); - c_recvtype = PMPI_Type_f2c(*recvtype); + c_root = OMPI_FINT_2_INT(*root); + if (OMPI_COMM_IS_INTER(c_comm)) { + if (MPI_ROOT == c_root) { + OMPI_COND_STATEMENT(int size = ompi_comm_remote_size(c_comm)); + c_recvtype = PMPI_Type_f2c(*recvtype); + OMPI_ARRAY_FINT_2_INT(recvcounts, size); + OMPI_ARRAY_FINT_2_INT(displs, size); + } else if (MPI_PROC_NULL != c_root) { + c_sendtype = PMPI_Type_f2c(*sendtype); + } + } else { + if (OMPI_IS_FORTRAN_IN_PLACE(sendbuf)) { + sendbuf = MPI_IN_PLACE; + } else { + c_sendtype = PMPI_Type_f2c(*sendtype); + } + if (ompi_comm_rank(c_comm) == c_root) { + OMPI_COND_STATEMENT(int size = ompi_comm_size(c_comm)); + c_recvtype = PMPI_Type_f2c(*recvtype); + OMPI_ARRAY_FINT_2_INT(recvcounts, size); + OMPI_ARRAY_FINT_2_INT(displs, size); + } + } - PMPI_Comm_size(c_comm, &size); - OMPI_ARRAY_FINT_2_INT(recvcounts, size); - OMPI_ARRAY_FINT_2_INT(displs, size); - - sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf); sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf); recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf); diff --git a/ompi/mpi/fortran/mpif-h/iallgather_f.c b/ompi/mpi/fortran/mpif-h/iallgather_f.c index 6b61cc55522..c3532aada3e 100644 --- a/ompi/mpi/fortran/mpif-h/iallgather_f.c +++ b/ompi/mpi/fortran/mpif-h/iallgather_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 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" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -74,13 +75,18 @@ void ompi_iallgather_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, int ierr_c; MPI_Comm c_comm; MPI_Request c_req; - MPI_Datatype c_sendtype, c_recvtype; + MPI_Datatype c_sendtype = NULL, c_recvtype = NULL; c_comm = PMPI_Comm_f2c(*comm); - c_sendtype = PMPI_Type_f2c(*sendtype); + if (!OMPI_COMM_IS_INTER(c_comm)) { + if (OMPI_IS_FORTRAN_IN_PLACE(sendbuf)) { + sendbuf = MPI_IN_PLACE; + } else { + c_sendtype = PMPI_Type_f2c(*sendtype); + } + } c_recvtype = PMPI_Type_f2c(*recvtype); - sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf); sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf); recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf); diff --git a/ompi/mpi/fortran/mpif-h/iallgatherv_f.c b/ompi/mpi/fortran/mpif-h/iallgatherv_f.c index 19671fea103..a834d405053 100644 --- a/ompi/mpi/fortran/mpif-h/iallgatherv_f.c +++ b/ompi/mpi/fortran/mpif-h/iallgatherv_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 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" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -73,21 +74,29 @@ void ompi_iallgatherv_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, MPI_Fint *ierr) { MPI_Comm c_comm; - MPI_Datatype c_sendtype, c_recvtype; + MPI_Datatype c_sendtype = NULL, c_recvtype; MPI_Request c_request; - int size, ierr_c; + int ierr_c; + OMPI_COND_STATEMENT(int size); OMPI_ARRAY_NAME_DECL(recvcounts); OMPI_ARRAY_NAME_DECL(displs); c_comm = PMPI_Comm_f2c(*comm); - c_sendtype = PMPI_Type_f2c(*sendtype); + if (OMPI_COMM_IS_INTER(c_comm)) { + OMPI_COND_STATEMENT(size = ompi_comm_remote_size(c_comm)); + } else { + OMPI_COND_STATEMENT(size = ompi_comm_size(c_comm)); + if (OMPI_IS_FORTRAN_IN_PLACE(sendbuf)) { + sendbuf = MPI_IN_PLACE; + } else { + c_sendtype = PMPI_Type_f2c(*sendtype); + } + } c_recvtype = PMPI_Type_f2c(*recvtype); - PMPI_Comm_size(c_comm, &size); OMPI_ARRAY_FINT_2_INT(recvcounts, size); OMPI_ARRAY_FINT_2_INT(displs, size); - sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf); sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf); recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf); diff --git a/ompi/mpi/fortran/mpif-h/ialltoall_f.c b/ompi/mpi/fortran/mpif-h/ialltoall_f.c index 27b8ca4bd64..59e09c85d83 100644 --- a/ompi/mpi/fortran/mpif-h/ialltoall_f.c +++ b/ompi/mpi/fortran/mpif-h/ialltoall_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 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" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -74,15 +75,17 @@ void ompi_ialltoall_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, int c_ierr; MPI_Comm c_comm; MPI_Request c_req; - MPI_Datatype c_sendtype, c_recvtype; + MPI_Datatype c_sendtype = NULL, c_recvtype; c_comm = PMPI_Comm_f2c(*comm); - c_sendtype = PMPI_Type_f2c(*sendtype); - c_recvtype = PMPI_Type_f2c(*recvtype); + if (OMPI_IS_FORTRAN_IN_PLACE(sendbuf)) { + sendbuf = MPI_IN_PLACE; + } else { + c_sendtype = PMPI_Type_f2c(*sendtype); + } - sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf); - sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf); - recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf); + c_recvtype = PMPI_Type_f2c(*recvtype); + c_sendtype = PMPI_Type_f2c(*sendtype); c_ierr = PMPI_Ialltoall(sendbuf, OMPI_FINT_2_INT(*sendcount), diff --git a/ompi/mpi/fortran/mpif-h/ialltoallv_f.c b/ompi/mpi/fortran/mpif-h/ialltoallv_f.c index 0a447f5d5b6..5c0f9632e73 100644 --- a/ompi/mpi/fortran/mpif-h/ialltoallv_f.c +++ b/ompi/mpi/fortran/mpif-h/ialltoallv_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 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" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -73,41 +74,47 @@ void ompi_ialltoallv_f(char *sendbuf, MPI_Fint *sendcounts, MPI_Fint *sdispls, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *ierr) { MPI_Comm c_comm; - MPI_Datatype c_sendtype, c_recvtype; + MPI_Datatype c_sendtype = NULL, c_recvtype; MPI_Request c_request; - int size, c_ierr; + int c_ierr; OMPI_ARRAY_NAME_DECL(sendcounts); OMPI_ARRAY_NAME_DECL(sdispls); OMPI_ARRAY_NAME_DECL(recvcounts); OMPI_ARRAY_NAME_DECL(rdispls); c_comm = PMPI_Comm_f2c(*comm); - c_sendtype = PMPI_Type_f2c(*sendtype); - c_recvtype = PMPI_Type_f2c(*recvtype); + OMPI_COND_STATEMENT(int 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)) { + sendbuf = MPI_IN_PLACE; + } else { + c_sendtype = PMPI_Type_f2c(*sendtype); + OMPI_ARRAY_FINT_2_INT(sendcounts, size); + OMPI_ARRAY_FINT_2_INT(sdispls, size); + } - PMPI_Comm_size(c_comm, &size); - OMPI_ARRAY_FINT_2_INT(sendcounts, size); - OMPI_ARRAY_FINT_2_INT(sdispls, size); + c_recvtype = PMPI_Type_f2c(*recvtype); OMPI_ARRAY_FINT_2_INT(recvcounts, size); OMPI_ARRAY_FINT_2_INT(rdispls, size); - sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf); sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf); recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf); c_ierr = PMPI_Ialltoallv(sendbuf, - OMPI_ARRAY_NAME_CONVERT(sendcounts), - OMPI_ARRAY_NAME_CONVERT(sdispls), - c_sendtype, - recvbuf, - OMPI_ARRAY_NAME_CONVERT(recvcounts), - OMPI_ARRAY_NAME_CONVERT(rdispls), - c_recvtype, c_comm, &c_request); + OMPI_ARRAY_NAME_CONVERT(sendcounts), + OMPI_ARRAY_NAME_CONVERT(sdispls), + c_sendtype, + recvbuf, + OMPI_ARRAY_NAME_CONVERT(recvcounts), + OMPI_ARRAY_NAME_CONVERT(rdispls), + c_recvtype, 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_ARRAY_FINT_2_INT_CLEANUP(sendcounts); - OMPI_ARRAY_FINT_2_INT_CLEANUP(sdispls); + if (MPI_IN_PLACE != sendbuf) { + OMPI_ARRAY_FINT_2_INT_CLEANUP(sendcounts); + OMPI_ARRAY_FINT_2_INT_CLEANUP(sdispls); + } OMPI_ARRAY_FINT_2_INT_CLEANUP(recvcounts); OMPI_ARRAY_FINT_2_INT_CLEANUP(rdispls); } diff --git a/ompi/mpi/fortran/mpif-h/ialltoallw_f.c b/ompi/mpi/fortran/mpif-h/ialltoallw_f.c index 75f8262bef5..d6bc0a67be0 100644 --- a/ompi/mpi/fortran/mpif-h/ialltoallw_f.c +++ b/ompi/mpi/fortran/mpif-h/ialltoallw_f.c @@ -86,7 +86,9 @@ void ompi_ialltoallw_f(char *sendbuf, MPI_Fint *sendcounts, c_comm = PMPI_Comm_f2c(*comm); 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)) { + if (OMPI_IS_FORTRAN_IN_PLACE(sendbuf)) { + sendbuf = MPI_IN_PLACE; + } else { c_sendtypes = (MPI_Datatype *) malloc(size * sizeof(MPI_Datatype)); OMPI_ARRAY_FINT_2_INT(sendcounts, size); OMPI_ARRAY_FINT_2_INT(sdispls, size); @@ -102,7 +104,6 @@ void ompi_ialltoallw_f(char *sendbuf, MPI_Fint *sendcounts, c_recvtypes[i] = PMPI_Type_f2c(recvtypes[i]); } - sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf); sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf); recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf); diff --git a/ompi/mpi/fortran/mpif-h/igather_f.c b/ompi/mpi/fortran/mpif-h/igather_f.c index f234581d0c3..3c97609cff2 100644 --- a/ompi/mpi/fortran/mpif-h/igather_f.c +++ b/ompi/mpi/fortran/mpif-h/igather_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 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" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -72,16 +73,30 @@ void ompi_igather_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, MPI_Fint *root, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *ierr) { - int c_ierr; + int c_root, c_ierr; MPI_Comm c_comm; - MPI_Datatype c_sendtype, c_recvtype; + MPI_Datatype c_sendtype = NULL, c_recvtype = NULL; MPI_Request c_request; c_comm = PMPI_Comm_f2c(*comm); - c_sendtype = PMPI_Type_f2c(*sendtype); - c_recvtype = PMPI_Type_f2c(*recvtype); + c_root = OMPI_FINT_2_INT(*root); + if (OMPI_COMM_IS_INTER(c_comm)) { + if (MPI_ROOT == c_root) { + c_recvtype = PMPI_Type_f2c(*recvtype); + } else if (MPI_PROC_NULL != c_root) { + c_sendtype = PMPI_Type_f2c(*sendtype); + } + } else { + if (OMPI_IS_FORTRAN_IN_PLACE(sendbuf)) { + sendbuf = MPI_IN_PLACE; + } else { + c_sendtype = PMPI_Type_f2c(*sendtype); + } + if (ompi_comm_rank(c_comm) == c_root) { + c_recvtype = PMPI_Type_f2c(*recvtype); + } + } - sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf); sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf); recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf); diff --git a/ompi/mpi/fortran/mpif-h/igatherv_f.c b/ompi/mpi/fortran/mpif-h/igatherv_f.c index c367c2f4abf..19bb030908f 100644 --- a/ompi/mpi/fortran/mpif-h/igatherv_f.c +++ b/ompi/mpi/fortran/mpif-h/igatherv_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 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" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -73,21 +74,37 @@ void ompi_igatherv_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, MPI_Fint *request, MPI_Fint *ierr) { MPI_Comm c_comm; - MPI_Datatype c_sendtype, c_recvtype; + MPI_Datatype c_sendtype = NULL, c_recvtype = NULL; MPI_Request c_request; - int size, c_ierr; + int c_root, c_ierr; OMPI_ARRAY_NAME_DECL(recvcounts); OMPI_ARRAY_NAME_DECL(displs); c_comm = PMPI_Comm_f2c(*comm); - c_sendtype = PMPI_Type_f2c(*sendtype); - c_recvtype = PMPI_Type_f2c(*recvtype); + c_root = OMPI_FINT_2_INT(*root); + if (OMPI_COMM_IS_INTER(c_comm)) { + if (MPI_ROOT == c_root) { + OMPI_COND_STATEMENT(int size = ompi_comm_remote_size(c_comm)); + c_recvtype = PMPI_Type_f2c(*recvtype); + OMPI_ARRAY_FINT_2_INT(recvcounts, size); + OMPI_ARRAY_FINT_2_INT(displs, size); + } else if (MPI_PROC_NULL != c_root) { + c_sendtype = PMPI_Type_f2c(*sendtype); + } + } else { + if (OMPI_IS_FORTRAN_IN_PLACE(sendbuf)) { + sendbuf = MPI_IN_PLACE; + } else { + c_sendtype = PMPI_Type_f2c(*sendtype); + } + if (ompi_comm_rank(c_comm) == c_root) { + OMPI_COND_STATEMENT(int size = ompi_comm_size(c_comm)); + c_recvtype = PMPI_Type_f2c(*recvtype); + OMPI_ARRAY_FINT_2_INT(recvcounts, size); + OMPI_ARRAY_FINT_2_INT(displs, size); + } + } - PMPI_Comm_size(c_comm, &size); - OMPI_ARRAY_FINT_2_INT(recvcounts, size); - OMPI_ARRAY_FINT_2_INT(displs, size); - - sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf); sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf); recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf); diff --git a/ompi/mpi/fortran/mpif-h/ineighbor_allgather_f.c b/ompi/mpi/fortran/mpif-h/ineighbor_allgather_f.c index ecd0221187a..a00c6c17a6c 100644 --- a/ompi/mpi/fortran/mpif-h/ineighbor_allgather_f.c +++ b/ompi/mpi/fortran/mpif-h/ineighbor_allgather_f.c @@ -13,8 +13,8 @@ * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2013 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 @@ -83,7 +83,7 @@ void ompi_ineighbor_allgather_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *se c_sendtype = PMPI_Type_f2c(*sendtype); c_recvtype = PMPI_Type_f2c(*recvtype); - sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf); + /* Ineighbor_allgather does not support MPI_IN_PLACE */ sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf); recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf); diff --git a/ompi/mpi/fortran/mpif-h/ineighbor_allgatherv_f.c b/ompi/mpi/fortran/mpif-h/ineighbor_allgatherv_f.c index db30c7451a6..7b27e5fad00 100644 --- a/ompi/mpi/fortran/mpif-h/ineighbor_allgatherv_f.c +++ b/ompi/mpi/fortran/mpif-h/ineighbor_allgatherv_f.c @@ -13,8 +13,8 @@ * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2013 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 @@ -26,6 +26,7 @@ #include "ompi/mpi/fortran/mpif-h/bindings.h" #include "ompi/mpi/fortran/base/constants.h" +#include "ompi/mca/topo/base/base.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -78,23 +79,30 @@ 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, ierr_c; + int indegree, outdegree, c_ierr; OMPI_ARRAY_NAME_DECL(recvcounts); OMPI_ARRAY_NAME_DECL(displs); c_comm = PMPI_Comm_f2c(*comm); + c_ierr = mca_topo_base_neighbor_count (c_comm, &indegree, &outdegree); + if (OMPI_SUCCESS != c_ierr) { + if (NULL != ierr) { + *ierr = OMPI_INT_2_FINT(c_ierr); + } + return; + } + c_sendtype = PMPI_Type_f2c(*sendtype); c_recvtype = PMPI_Type_f2c(*recvtype); - PMPI_Comm_size(c_comm, &size); - OMPI_ARRAY_FINT_2_INT(recvcounts, size); - OMPI_ARRAY_FINT_2_INT(displs, size); + OMPI_ARRAY_FINT_2_INT(recvcounts, indegree); + OMPI_ARRAY_FINT_2_INT(displs, indegree); - sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf); + /* Ineighbor_allgatherv does not support MPI_IN_PLACE */ sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf); recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf); - ierr_c = PMPI_Ineighbor_allgatherv(sendbuf, + c_ierr = PMPI_Ineighbor_allgatherv(sendbuf, OMPI_FINT_2_INT(*sendcount), c_sendtype, recvbuf, @@ -102,8 +110,8 @@ void ompi_ineighbor_allgatherv_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *s OMPI_ARRAY_NAME_CONVERT(displs), c_recvtype, c_comm, &c_request); - if (NULL != ierr) *ierr = OMPI_INT_2_FINT(ierr_c); - if (MPI_SUCCESS == ierr_c) *request = PMPI_Request_c2f(c_request); + if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); + if (MPI_SUCCESS == c_ierr) *request = PMPI_Request_c2f(c_request); OMPI_ARRAY_FINT_2_INT_CLEANUP(recvcounts); OMPI_ARRAY_FINT_2_INT_CLEANUP(displs); diff --git a/ompi/mpi/fortran/mpif-h/ineighbor_alltoall_f.c b/ompi/mpi/fortran/mpif-h/ineighbor_alltoall_f.c index b565f1b74ed..07dbf0f335d 100644 --- a/ompi/mpi/fortran/mpif-h/ineighbor_alltoall_f.c +++ b/ompi/mpi/fortran/mpif-h/ineighbor_alltoall_f.c @@ -13,8 +13,8 @@ * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2013 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 @@ -83,7 +83,7 @@ void ompi_ineighbor_alltoall_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sen c_sendtype = PMPI_Type_f2c(*sendtype); c_recvtype = PMPI_Type_f2c(*recvtype); - sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf); + /* Ineighbor_alltoall does not support MPI_IN_PLACE */ sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf); recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf); diff --git a/ompi/mpi/fortran/mpif-h/ineighbor_alltoallv_f.c b/ompi/mpi/fortran/mpif-h/ineighbor_alltoallv_f.c index 89761ace66d..eafbdeeaf4e 100644 --- a/ompi/mpi/fortran/mpif-h/ineighbor_alltoallv_f.c +++ b/ompi/mpi/fortran/mpif-h/ineighbor_alltoallv_f.c @@ -13,8 +13,8 @@ * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2013 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 @@ -26,6 +26,7 @@ #include "ompi/mpi/fortran/mpif-h/bindings.h" #include "ompi/mpi/fortran/base/constants.h" +#include "ompi/mca/topo/base/base.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -78,34 +79,41 @@ 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, c_ierr; + int indegree, outdegree, c_ierr; OMPI_ARRAY_NAME_DECL(sendcounts); OMPI_ARRAY_NAME_DECL(sdispls); OMPI_ARRAY_NAME_DECL(recvcounts); OMPI_ARRAY_NAME_DECL(rdispls); c_comm = PMPI_Comm_f2c(*comm); + c_ierr = mca_topo_base_neighbor_count (c_comm, &indegree, &outdegree); + if (OMPI_SUCCESS != c_ierr) { + if (NULL != ierr) { + *ierr = OMPI_INT_2_FINT(c_ierr); + } + return; + } + c_sendtype = PMPI_Type_f2c(*sendtype); c_recvtype = PMPI_Type_f2c(*recvtype); - PMPI_Comm_size(c_comm, &size); - OMPI_ARRAY_FINT_2_INT(sendcounts, size); - OMPI_ARRAY_FINT_2_INT(sdispls, size); - OMPI_ARRAY_FINT_2_INT(recvcounts, size); - OMPI_ARRAY_FINT_2_INT(rdispls, size); + OMPI_ARRAY_FINT_2_INT(sendcounts, outdegree); + OMPI_ARRAY_FINT_2_INT(sdispls, outdegree); + OMPI_ARRAY_FINT_2_INT(recvcounts, indegree); + OMPI_ARRAY_FINT_2_INT(rdispls, indegree); - sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf); + /* Ineighbor_alltoallv does not support MPI_IN_PLACE */ sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf); recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf); c_ierr = PMPI_Ineighbor_alltoallv(sendbuf, - OMPI_ARRAY_NAME_CONVERT(sendcounts), - OMPI_ARRAY_NAME_CONVERT(sdispls), - c_sendtype, - recvbuf, - OMPI_ARRAY_NAME_CONVERT(recvcounts), - OMPI_ARRAY_NAME_CONVERT(rdispls), - c_recvtype, c_comm, &c_request); + OMPI_ARRAY_NAME_CONVERT(sendcounts), + OMPI_ARRAY_NAME_CONVERT(sdispls), + c_sendtype, + recvbuf, + OMPI_ARRAY_NAME_CONVERT(recvcounts), + OMPI_ARRAY_NAME_CONVERT(rdispls), + c_recvtype, 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); diff --git a/ompi/mpi/fortran/mpif-h/ineighbor_alltoallw_f.c b/ompi/mpi/fortran/mpif-h/ineighbor_alltoallw_f.c index 42116da7a81..43fc36299cb 100644 --- a/ompi/mpi/fortran/mpif-h/ineighbor_alltoallw_f.c +++ b/ompi/mpi/fortran/mpif-h/ineighbor_alltoallw_f.c @@ -13,8 +13,8 @@ * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2013 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 @@ -26,6 +26,7 @@ #include "ompi/mpi/fortran/mpif-h/bindings.h" #include "ompi/mpi/fortran/base/constants.h" +#include "ompi/mca/topo/base/base.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -79,23 +80,30 @@ 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, c_ierr; + int indegree, outdegree, c_ierr; OMPI_ARRAY_NAME_DECL(sendcounts); OMPI_ARRAY_NAME_DECL(recvcounts); c_comm = PMPI_Comm_f2c(*comm); - PMPI_Comm_size(c_comm, &size); + c_ierr = mca_topo_base_neighbor_count (c_comm, &indegree, &outdegree); + if (OMPI_SUCCESS != c_ierr) { + if (NULL != ierr) { + *ierr = OMPI_INT_2_FINT(c_ierr); + } + return; + } - c_sendtypes = (MPI_Datatype *) malloc(size * sizeof(MPI_Datatype)); - c_recvtypes = (MPI_Datatype *) malloc(size * sizeof(MPI_Datatype)); + c_sendtypes = (MPI_Datatype *) malloc(outdegree * sizeof(MPI_Datatype)); + c_recvtypes = (MPI_Datatype *) malloc(indegree * sizeof(MPI_Datatype)); - OMPI_ARRAY_FINT_2_INT(sendcounts, size); - OMPI_ARRAY_FINT_2_INT(recvcounts, size); + OMPI_ARRAY_FINT_2_INT(sendcounts, outdegree); + 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; + OMPI_ARRAY_FINT_2_INT(recvcounts, indegree); + 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; + OMPI_ARRAY_FINT_2_INT(recvcounts, indegree); + 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; + OMPI_ARRAY_FINT_2_INT(recvcounts, indegree); + for (int i=0; i