Skip to content

Commit b2331a2

Browse files
ggouaillardethppritcha
authored andcommitted
checkpoint
1 parent 0edc5cb commit b2331a2

34 files changed

+708
-408
lines changed

ompi/mca/coll/libnbc/nbc_ialltoall.c

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -77,39 +77,40 @@ static int nbc_alltoall_init(const void* sendbuf, int sendcount, MPI_Datatype se
7777
rank = ompi_comm_rank (comm);
7878
p = ompi_comm_size (comm);
7979

80-
res = ompi_datatype_type_extent(sendtype, &sndext);
81-
if (MPI_SUCCESS != res) {
82-
NBC_Error("MPI Error in ompi_datatype_type_extent() (%i)", res);
83-
return res;
84-
}
85-
8680
res = ompi_datatype_type_extent(recvtype, &rcvext);
8781
if (MPI_SUCCESS != res) {
8882
NBC_Error("MPI Error in ompi_datatype_type_extent() (%i)", res);
8983
return res;
9084
}
9185

92-
res = ompi_datatype_type_size(sendtype, &sndsize);
93-
if (MPI_SUCCESS != res) {
94-
NBC_Error("MPI Error in ompi_datatype_type_size() (%i)", res);
95-
return res;
96-
}
97-
98-
/* algorithm selection */
99-
a2asize = sndsize * sendcount * p;
100-
/* this number is optimized for TCP on odin.cs.indiana.edu */
10186
if (inplace) {
10287
alg = NBC_A2A_INPLACE;
103-
} else if((p <= 8) && ((a2asize < 1<<17) || (sndsize*sendcount < 1<<12))) {
104-
/* just send as fast as we can if we have less than 8 peers, if the
105-
* total communicated size is smaller than 1<<17 *and* if we don't
106-
* have eager messages (msgsize < 1<<13) */
107-
alg = NBC_A2A_LINEAR;
108-
} else if(a2asize < (1<<12)*(unsigned int)p) {
109-
/*alg = NBC_A2A_DISS;*/
110-
alg = NBC_A2A_LINEAR;
111-
} else
112-
alg = NBC_A2A_LINEAR; /*NBC_A2A_PAIRWISE;*/
88+
} else {
89+
/* algorithm selection */
90+
res = ompi_datatype_type_extent(sendtype, &sndext);
91+
if (MPI_SUCCESS != res) {
92+
NBC_Error("MPI Error in ompi_datatype_type_extent() (%i)", res);
93+
return res;
94+
}
95+
res = ompi_datatype_type_size(sendtype, &sndsize);
96+
if (MPI_SUCCESS != res) {
97+
NBC_Error("MPI Error in ompi_datatype_type_size() (%i)", res);
98+
return res;
99+
}
100+
101+
a2asize = sndsize * sendcount * p;
102+
/* this number is optimized for TCP on odin.cs.indiana.edu */
103+
if((p <= 8) && ((a2asize < 1<<17) || (sndsize*sendcount < 1<<12))) {
104+
/* just send as fast as we can if we have less than 8 peers, if the
105+
* total communicated size is smaller than 1<<17 *and* if we don't
106+
* have eager messages (msgsize < 1<<13) */
107+
alg = NBC_A2A_LINEAR;
108+
} else if(a2asize < (1<<12)*(unsigned int)p) {
109+
/*alg = NBC_A2A_DISS;*/
110+
alg = NBC_A2A_LINEAR;
111+
} else
112+
alg = NBC_A2A_LINEAR; /*NBC_A2A_PAIRWISE;*/
113+
}
113114

114115
/* allocate temp buffer if we need one */
115116
if (alg == NBC_A2A_INPLACE) {

ompi/mpi/c/bcast.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,14 @@ int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype,
7676
FUNC_NAME);
7777
}
7878

79-
/* Errors for all ranks */
79+
/* Errors for all involved ranks */
8080

81-
OMPI_CHECK_DATATYPE_FOR_SEND(err, datatype, count);
82-
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
83-
if (MPI_IN_PLACE == buffer) {
81+
if (OMPI_COMM_IS_INTRA(comm) || MPI_PROC_NULL != root) {
82+
OMPI_CHECK_DATATYPE_FOR_SEND(err, datatype, count);
83+
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
84+
if (MPI_IN_PLACE == buffer) {
8485
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
86+
}
8587
}
8688

8789
/* Errors for intracommunicators */

ompi/mpi/c/ibcast.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,14 @@ int MPI_Ibcast(void *buffer, int count, MPI_Datatype datatype,
7070
FUNC_NAME);
7171
}
7272

73-
/* Errors for all ranks */
73+
/* Errors for all involved ranks */
7474

75-
OMPI_CHECK_DATATYPE_FOR_SEND(err, datatype, count);
76-
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
77-
if (MPI_IN_PLACE == buffer) {
75+
if (OMPI_COMM_IS_INTRA(comm) || MPI_PROC_NULL != root) {
76+
OMPI_CHECK_DATATYPE_FOR_SEND(err, datatype, count);
77+
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
78+
if (MPI_IN_PLACE == buffer) {
7879
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
80+
}
7981
}
8082

8183
/* Errors for intracommunicators */

ompi/mpi/fortran/base/fint_2_int.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@
4747
#define OMPI_SINGLE_FINT_2_INT(in)
4848
#define OMPI_SINGLE_INT_2_FINT(in)
4949
#define OMPI_ARRAY_INT_2_FINT(in, n)
50+
#define OMPI_COND_STATEMENT(a)
5051

5152
#elif OMPI_SIZEOF_FORTRAN_INTEGER > SIZEOF_INT
52-
#define OMPI_ARRAY_NAME_DECL(a) int *c_##a
53+
#define OMPI_ARRAY_NAME_DECL(a) int *c_##a = NULL
5354
#define OMPI_2_DIM_ARRAY_NAME_DECL(a, dim2) int (*c_##a)[dim2], dim2_index
5455
#define OMPI_SINGLE_NAME_DECL(a) int c_##a
5556
#define OMPI_ARRAY_NAME_CONVERT(a) c_##a
@@ -86,7 +87,8 @@
8687

8788
/* This is for IN parameters. Does only free */
8889
#define OMPI_ARRAY_FINT_2_INT_CLEANUP(in) \
89-
free(OMPI_ARRAY_NAME_CONVERT(in))
90+
if (NULL != OMPI_ARRAY_NAME_CONVERT(in)) \
91+
free(OMPI_ARRAY_NAME_CONVERT(in))
9092

9193
/* This is for single IN parameter */
9294
#define OMPI_SINGLE_FINT_2_INT(in) \
@@ -105,8 +107,10 @@
105107
} \
106108
free(OMPI_ARRAY_NAME_CONVERT(in)); \
107109
} while (0)
110+
111+
#define OMPI_COND_STATEMENT(a) a
108112
#else /* int > MPI_Fint */
109-
#define OMPI_ARRAY_NAME_DECL(a) int *c_##a
113+
#define OMPI_ARRAY_NAME_DECL(a) int *c_##a = NULL
110114
#define OMPI_2_DIM_ARRAY_NAME_DECL(a, dim2) int (*c_##a)[dim2], dim2_index
111115
#define OMPI_SINGLE_NAME_DECL(a) int c_##a
112116
#define OMPI_ARRAY_NAME_CONVERT(a) c_##a
@@ -140,7 +144,8 @@
140144
} while (0)
141145

142146
#define OMPI_ARRAY_FINT_2_INT_CLEANUP(in) \
143-
free(OMPI_ARRAY_NAME_CONVERT(in))
147+
if (NULL != OMPI_ARRAY_NAME_CONVERT(in)) \
148+
free(OMPI_ARRAY_NAME_CONVERT(in))
144149

145150
#define OMPI_SINGLE_FINT_2_INT(in) \
146151
OMPI_ARRAY_NAME_CONVERT(in) = *(in)
@@ -157,6 +162,7 @@
157162
free(OMPI_ARRAY_NAME_CONVERT(in)); \
158163
} while (0)
159164

165+
#define OMPI_COND_STATEMENT(a) a
160166
#endif
161167

162168
/*

ompi/mpi/fortran/mpif-h/allgather_f.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
1212
* Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved.
13-
* Copyright (c) 2015 Research Organization for Information Science
14-
* and Technology (RIST). All rights reserved.
13+
* Copyright (c) 2015-2019 Research Organization for Information Science
14+
* and Technology (RIST). All rights reserved.
1515
* $COPYRIGHT$
1616
*
1717
* Additional copyrights may follow
@@ -23,6 +23,7 @@
2323

2424
#include "ompi/mpi/fortran/mpif-h/bindings.h"
2525
#include "ompi/mpi/fortran/base/constants.h"
26+
#include "ompi/communicator/communicator.h"
2627

2728
#if OMPI_BUILD_MPI_PROFILING
2829
#if OPAL_HAVE_WEAK_SYMBOLS
@@ -72,19 +73,22 @@ void ompi_allgather_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype,
7273
MPI_Fint *comm, MPI_Fint *ierr)
7374
{
7475
int ierr_c;
75-
MPI_Comm c_comm;
76-
MPI_Datatype c_sendtype, c_recvtype;
76+
MPI_Comm c_comm = PMPI_Comm_f2c(*comm);
77+
int c_sendcount = 0;
78+
MPI_Datatype c_sendtype = NULL, c_recvtype = PMPI_Type_f2c(*recvtype);
7779

78-
c_comm = PMPI_Comm_f2c(*comm);
79-
c_sendtype = PMPI_Type_f2c(*sendtype);
80-
c_recvtype = PMPI_Type_f2c(*recvtype);
80+
if (OMPI_COMM_IS_INTER(c_comm) || !OMPI_IS_FORTRAN_IN_PLACE(sendbuf)) {
81+
c_sendtype = PMPI_Type_f2c(*sendtype);
82+
c_sendcount = OMPI_FINT_2_INT(*sendcount);
83+
} else {
84+
sendbuf = MPI_IN_PLACE;
85+
}
8186

82-
sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf);
8387
sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf);
8488
recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf);
8589

8690
ierr_c = PMPI_Allgather(sendbuf,
87-
OMPI_FINT_2_INT(*sendcount),
91+
c_sendcount,
8892
c_sendtype,
8993
recvbuf,
9094
OMPI_FINT_2_INT(*recvcount),

ompi/mpi/fortran/mpif-h/allgatherv_f.c

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
1212
* Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved.
13-
* Copyright (c) 2015 Research Organization for Information Science
14-
* and Technology (RIST). All rights reserved.
13+
* Copyright (c) 2015-2019 Research Organization for Information Science
14+
* and Technology (RIST). All rights reserved.
1515
* $COPYRIGHT$
1616
*
1717
* Additional copyrights may follow
@@ -23,6 +23,7 @@
2323

2424
#include "ompi/mpi/fortran/mpif-h/bindings.h"
2525
#include "ompi/mpi/fortran/base/constants.h"
26+
#include "ompi/communicator/communicator.h"
2627

2728
#if OMPI_BUILD_MPI_PROFILING
2829
#if OPAL_HAVE_WEAK_SYMBOLS
@@ -71,26 +72,37 @@ void ompi_allgatherv_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype,
7172
char *recvbuf, MPI_Fint *recvcounts, MPI_Fint *displs,
7273
MPI_Fint *recvtype, MPI_Fint *comm, MPI_Fint *ierr)
7374
{
74-
MPI_Comm c_comm;
75-
MPI_Datatype c_sendtype, c_recvtype;
76-
int size, ierr_c;
75+
int ierr_c;
76+
MPI_Comm c_comm = PMPI_Comm_f2c(*comm);
77+
int c_sendcount = 0;
78+
MPI_Datatype c_sendtype = NULL, c_recvtype;
79+
OMPI_COND_STATEMENT(int size);
7780
OMPI_ARRAY_NAME_DECL(recvcounts);
7881
OMPI_ARRAY_NAME_DECL(displs);
7982

80-
c_comm = PMPI_Comm_f2c(*comm);
81-
c_sendtype = PMPI_Type_f2c(*sendtype);
83+
if (OMPI_COMM_IS_INTER(c_comm)) {
84+
OMPI_COND_STATEMENT(size = ompi_comm_remote_size(c_comm));
85+
c_sendtype = PMPI_Type_f2c(*sendtype);
86+
c_sendcount = OMPI_FINT_2_INT(*sendcount);
87+
} else {
88+
OMPI_COND_STATEMENT(size = ompi_comm_size(c_comm));
89+
if (OMPI_IS_FORTRAN_IN_PLACE(sendbuf)) {
90+
sendbuf = MPI_IN_PLACE;
91+
} else {
92+
c_sendtype = PMPI_Type_f2c(*sendtype);
93+
c_sendcount = OMPI_FINT_2_INT(*sendcount);
94+
}
95+
}
8296
c_recvtype = PMPI_Type_f2c(*recvtype);
8397

84-
PMPI_Comm_size(c_comm, &size);
8598
OMPI_ARRAY_FINT_2_INT(recvcounts, size);
8699
OMPI_ARRAY_FINT_2_INT(displs, size);
87100

88-
sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf);
89101
sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf);
90102
recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf);
91103

92104
ierr_c = PMPI_Allgatherv(sendbuf,
93-
OMPI_FINT_2_INT(*sendcount),
105+
c_sendcount,
94106
c_sendtype,
95107
recvbuf,
96108
OMPI_ARRAY_NAME_CONVERT(recvcounts),

ompi/mpi/fortran/mpif-h/alltoall_f.c

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
1212
* Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved.
13-
* Copyright (c) 2015 Research Organization for Information Science
14-
* and Technology (RIST). All rights reserved.
13+
* Copyright (c) 2015-2019 Research Organization for Information Science
14+
* and Technology (RIST). All rights reserved.
1515
* $COPYRIGHT$
1616
*
1717
* Additional copyrights may follow
@@ -23,6 +23,7 @@
2323

2424
#include "ompi/mpi/fortran/mpif-h/bindings.h"
2525
#include "ompi/mpi/fortran/base/constants.h"
26+
#include "ompi/communicator/communicator.h"
2627

2728
#if OMPI_BUILD_MPI_PROFILING
2829
#if OPAL_HAVE_WEAK_SYMBOLS
@@ -72,22 +73,26 @@ void ompi_alltoall_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype,
7273
MPI_Fint *comm, MPI_Fint *ierr)
7374
{
7475
int c_ierr;
75-
MPI_Comm c_comm;
76-
MPI_Datatype c_sendtype, c_recvtype;
76+
MPI_Comm c_comm = PMPI_Comm_f2c(*comm);
77+
int c_sendcount = 0;
78+
MPI_Datatype c_sendtype = NULL, c_recvtype = PMPI_Type_f2c(*recvtype);
7779

78-
c_comm = PMPI_Comm_f2c(*comm);
79-
c_sendtype = PMPI_Type_f2c(*sendtype);
80-
c_recvtype = PMPI_Type_f2c(*recvtype);
80+
if (OMPI_COMM_IS_INTER(c_comm) || !OMPI_IS_FORTRAN_IN_PLACE(sendbuf)) {
81+
c_sendtype = PMPI_Type_f2c(*sendtype);
82+
c_sendcount = OMPI_FINT_2_INT(*sendcount);
83+
} else {
84+
sendbuf = MPI_IN_PLACE;
85+
}
8186

82-
sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf);
8387
sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf);
8488
recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf);
8589

8690
c_ierr = PMPI_Alltoall(sendbuf,
87-
OMPI_FINT_2_INT(*sendcount),
88-
c_sendtype,
89-
recvbuf,
90-
OMPI_FINT_2_INT(*recvcount),
91-
c_recvtype, c_comm);
91+
c_sendcount,
92+
c_sendtype,
93+
recvbuf,
94+
OMPI_FINT_2_INT(*recvcount),
95+
c_recvtype, c_comm);
96+
9297
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
9398
}

0 commit comments

Comments
 (0)