Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4.0.x: misc Fortran related backports #6838

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions ompi/mpi/fortran/mpif-h/alltoallw_f.c
Original file line number Diff line number Diff line change
Expand Up @@ -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$
*
Expand All @@ -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
Expand Down Expand Up @@ -74,28 +75,30 @@ 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);
OMPI_ARRAY_NAME_DECL(recvcounts);
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<size; i++) {
c_sendtypes[i] = PMPI_Type_f2c(sendtypes[i]);
}
}

OMPI_ARRAY_FINT_2_INT(sendcounts, size);
OMPI_ARRAY_FINT_2_INT(sdispls, size);
c_recvtypes = (MPI_Datatype *) malloc(size * sizeof(MPI_Datatype));
OMPI_ARRAY_FINT_2_INT(recvcounts, size);
OMPI_ARRAY_FINT_2_INT(rdispls, size);

while (size > 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<size; i++) {
c_recvtypes[i] = PMPI_Type_f2c(recvtypes[i]);
}

sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf);
Expand All @@ -116,6 +119,8 @@ 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);
free(c_sendtypes);
if (NULL != c_sendtypes) {
free(c_sendtypes);
}
free(c_recvtypes);
}
14 changes: 7 additions & 7 deletions ompi/mpi/fortran/mpif-h/comm_split_type_f.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
26 changes: 14 additions & 12 deletions ompi/mpi/fortran/mpif-h/dist_graph_create_adjacent_f.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

Expand Down
14 changes: 8 additions & 6 deletions ompi/mpi/fortran/mpif-h/dist_graph_create_f.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}

Expand Down
14 changes: 8 additions & 6 deletions ompi/mpi/fortran/mpif-h/dist_graph_neighbors_count_f.c
Original file line number Diff line number Diff line change
Expand Up @@ -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$
*
Expand Down Expand Up @@ -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);
}
Expand Down
19 changes: 11 additions & 8 deletions ompi/mpi/fortran/mpif-h/dist_graph_neighbors_f.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);

Expand All @@ -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);
Expand Down
33 changes: 19 additions & 14 deletions ompi/mpi/fortran/mpif-h/ialltoallw_f.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -74,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);
Expand All @@ -83,20 +84,22 @@ void ompi_ialltoallw_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<size; i++) {
c_sendtypes[i] = PMPI_Type_f2c(sendtypes[i]);
}
}

OMPI_ARRAY_FINT_2_INT(sendcounts, size);
OMPI_ARRAY_FINT_2_INT(sdispls, size);
c_recvtypes = (MPI_Datatype *) malloc(size * sizeof(MPI_Datatype));
OMPI_ARRAY_FINT_2_INT(recvcounts, size);
OMPI_ARRAY_FINT_2_INT(rdispls, size);

while (size > 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<size; i++) {
c_recvtypes[i] = PMPI_Type_f2c(recvtypes[i]);
}

sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf);
Expand All @@ -118,6 +121,8 @@ void ompi_ialltoallw_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);
free(c_sendtypes);
if (NULL != c_sendtypes) {
free(c_sendtypes);
}
free(c_recvtypes);
}
12 changes: 6 additions & 6 deletions ompi/mpi/fortran/mpif-h/improbe_f.c
Original file line number Diff line number Diff line change
Expand Up @@ -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$
*
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions ompi/mpi/fortran/mpif-h/imrecv_f.c
Original file line number Diff line number Diff line change
Expand Up @@ -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$
*
Expand Down Expand Up @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions ompi/mpi/fortran/mpif-h/mprobe_f.c
Original file line number Diff line number Diff line change
Expand Up @@ -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$
Expand Down Expand Up @@ -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) {
Expand Down
Loading