Skip to content

Commit e8a4be1

Browse files
committed
Add OMPI_BIGCOUNT_ARRAY_* macros for collective calls
Signed-off-by: Jake Tronge <jtronge@lanl.gov>
1 parent 4008ac8 commit e8a4be1

File tree

2 files changed

+68
-4
lines changed

2 files changed

+68
-4
lines changed

ompi/mpi/c/alltoallv.c.in

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ PROTOTYPE ERROR_CLASS alltoallv(BUFFER sendbuf, COUNT_ARRAY sendcounts,
4040
DATATYPE recvtype, COMM comm)
4141
{
4242
int i, size, err;
43+
OMPI_BIGCOUNT_ARRAY_COUNT_IN_DECL(sendcounts);
44+
OMPI_BIGCOUNT_ARRAY_DISPL_IN_DECL(sdispls);
45+
OMPI_BIGCOUNT_ARRAY_COUNT_IN_DECL(recvcounts);
46+
OMPI_BIGCOUNT_ARRAY_DISPL_IN_DECL(rdispls);
4347

48+
size = OMPI_COMM_IS_INTER(comm)?ompi_comm_remote_size(comm):ompi_comm_size(comm);
4449
SPC_RECORD(OMPI_SPC_ALLTOALLV, 1);
4550

4651
MEMCHECKER(
@@ -56,7 +61,6 @@ PROTOTYPE ERROR_CLASS alltoallv(BUFFER sendbuf, COUNT_ARRAY sendcounts,
5661

5762
memchecker_comm(comm);
5863

59-
size = OMPI_COMM_IS_INTER(comm)?ompi_comm_remote_size(comm):ompi_comm_size(comm);
6064
for ( i = 0; i < size; i++ ) {
6165
if (MPI_IN_PLACE != sendbuf) {
6266
/* check if send chunks are defined. */
@@ -125,10 +129,21 @@ PROTOTYPE ERROR_CLASS alltoallv(BUFFER sendbuf, COUNT_ARRAY sendcounts,
125129
}
126130
#endif
127131

132+
/* TODO: MPI_IN_PLACE? */
133+
OMPI_BIGCOUNT_ARRAY_COUNT_IN_PREPARE(sendcounts, size, i);
134+
OMPI_BIGCOUNT_ARRAY_DISPL_IN_PREPARE(sdispls, size, i);
135+
OMPI_BIGCOUNT_ARRAY_COUNT_IN_PREPARE(recvcounts, size, i);
136+
OMPI_BIGCOUNT_ARRAY_DISPL_IN_PREPARE(rdispls, size, i);
128137
/* Invoke the coll component to perform the back-end operation */
129-
err = comm->c_coll->coll_alltoallv(sendbuf, sendcounts, sdispls, sendtype,
130-
recvbuf, recvcounts, rdispls, recvtype,
131-
comm, comm->c_coll->coll_alltoallv_module);
138+
err = comm->c_coll->coll_alltoallv(sendbuf, OMPI_BIGCOUNT_ARRAY_NAME(sendcounts),
139+
OMPI_BIGCOUNT_ARRAY_NAME(sdispls), sendtype,
140+
recvbuf, OMPI_BIGCOUNT_ARRAY_NAME(recvcounts),
141+
OMPI_BIGCOUNT_ARRAY_NAME(rdispls), recvtype,
142+
comm, comm->c_coll->coll_alltoallv_module);
143+
OMPI_BIGCOUNT_ARRAY_COUNT_IN_POST(sendcounts);
144+
OMPI_BIGCOUNT_ARRAY_DISPL_IN_POST(sdispls);
145+
OMPI_BIGCOUNT_ARRAY_COUNT_IN_POST(recvcounts);
146+
OMPI_BIGCOUNT_ARRAY_DISPL_IN_POST(rdispls);
132147
OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
133148
}
134149

ompi/mpi/c/bindings.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,55 @@ BEGIN_C_DECLS
104104
} \
105105
} while (0)
106106

107+
/* Handling of MPI_Count/MPI_Aint and int array conversion */
108+
#define OMPI_BIGCOUNT_ARRAY_NAME(name) tmp_ ## name
109+
110+
#define OMPI_BIGCOUNT_ARRAY_COUNT_IN_DECL(name) int *OMPI_BIGCOUNT_ARRAY_NAME(name)
111+
#define OMPI_BIGCOUNT_ARRAY_DISPL_IN_DECL(name) OMPI_BIGCOUNT_ARRAY_COUNT_IN_DECL(name)
112+
#define OMPI_BIGCOUNT_ARRAY_COUNT_OUT_DECL(name) OMPI_BIGCOUNT_ARRAY_COUNT_IN_DECL(name)
113+
#define OMPI_BIGCOUNT_ARRAY_DISPL_OUT_DECL(name) OMPI_BIGCOUNT_ARRAY_COUNT_IN_DECL(name)
114+
115+
#define OMPI_BIGCOUNT_ARRAY_COUNT_IN_PREPARE(name, size, i) \
116+
do { \
117+
if (sizeof(*name) == sizeof(*OMPI_BIGCOUNT_ARRAY_NAME(name))) { \
118+
OMPI_BIGCOUNT_ARRAY_NAME(name) = (int *) name; \
119+
break; \
120+
} \
121+
OMPI_BIGCOUNT_ARRAY_NAME(name) = malloc(size * sizeof(*OMPI_BIGCOUNT_ARRAY_NAME(name))); \
122+
for (i = 0; i < size; ++i) { \
123+
OMPI_BIGCOUNT_ARRAY_NAME(name)[i] = name[i]; \
124+
} \
125+
} while (0)
126+
#define OMPI_BIGCOUNT_ARRAY_DISPL_IN_PREPARE(name, size, i) OMPI_BIGCOUNT_ARRAY_COUNT_IN_PREPARE(name, size, i)
127+
#define OMPI_BIGCOUNT_ARRAY_COUNT_OUT_PREPARE(name, size) \
128+
do { \
129+
if (sizeof(*name) == sizeof(*OMPI_BIGCOUNT_ARRAY_NAME(name))) { \
130+
OMPI_BIGCOUNT_ARRAY_NAME(name) = (int *) name; \
131+
break; \
132+
} \
133+
OMPI_BIGCOUNT_ARRAY_NAME(name) = malloc(size * sizeof(*OMPI_BIGCOUNT_ARRAY_NAME(name))); \
134+
} while (0)
135+
#define OMPI_BIGCOUNT_ARRAY_DISPL_OUT_PREPARE(name, size) OMPI_BIGCOUNT_ARRAY_COUNT_OUT_PREPARE(name, size)
136+
137+
#define OMPI_BIGCOUNT_ARRAY_COUNT_IN_POST(name) \
138+
do { \
139+
if (sizeof(*name) != sizeof(*OMPI_BIGCOUNT_ARRAY_NAME(name))) { \
140+
free(OMPI_BIGCOUNT_ARRAY_NAME(name)); \
141+
} \
142+
} while (0)
143+
#define OMPI_BIGCOUNT_ARRAY_DISPL_IN_POST(name) OMPI_BIGCOUNT_ARRAY_COUNT_IN_POST(name)
144+
#define OMPI_BIGCOUNT_ARRAY_COUNT_OUT_POST(name, size, i) \
145+
do { \
146+
if (sizeof(*name) == sizeof(*OMPI_BIGCOUNT_ARRAY_NAME(name))) { \
147+
break; \
148+
} \
149+
for (i = 0; i < size; ++i) { \
150+
name[i] = OMPI_BIGCOUNT_ARRAY_NAME(name)[i]; \
151+
} \
152+
free(OMPI_BIGCOUNT_ARRAY_NAME(name)); \
153+
} while (0)
154+
#define OMPI_BIGCOUNT_ARRAY_DISPL_OUT_POST(name, size, i) OMPI_BIGCOUNT_ARRAY_COUNT_OUT_POST(name, size, i)
155+
107156
END_C_DECLS
108157

109158
#endif /* OMPI_C_BINDINGS_H */

0 commit comments

Comments
 (0)