Skip to content

Commit 24fbc37

Browse files
committed
coll: define fallback algorithms
They are manual "auto" algorithms that selects from a small set of algorithms that are suitable for internal usages, e.g. during init, finalize, and communicator constructions.
1 parent 77c7181 commit 24fbc37

File tree

3 files changed

+91
-10
lines changed

3 files changed

+91
-10
lines changed

src/include/mpir_coll.h

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,26 @@
1111

1212
/* During init, not all algorithms are safe to use. For example, the csel
1313
* may not have been initialized. We define a set of fallback routines that
14-
* are safe to use during init. They are all intra algorithms.
14+
* are safe to use during init.
1515
*/
16-
#define MPIR_Barrier_fallback MPIR_Barrier_intra_dissemination
17-
#define MPIR_Allgather_fallback MPIR_Allgather_intra_brucks
18-
#define MPIR_Allgatherv_fallback MPIR_Allgatherv_intra_brucks
19-
#define MPIR_Allreduce_fallback MPIR_Allreduce_intra_recursive_doubling
20-
#define MPIR_Bcast_fallback MPIR_Bcast_intra_binomial
21-
#define MPIR_Gather_fallback MPIR_Gather_intra_binomial
22-
#define MPIR_Reduce_scatter_block_fallback MPIR_Reduce_scatter_block_intra_recursive_doubling
23-
/* used in MPIR_Comm_split_impl */
24-
#define MPIR_Allgather_inter_fallback MPIR_Allgather_inter_local_gather_remote_bcast
16+
int MPIR_Barrier_fallback(MPIR_Comm * comm_ptr, int coll_attr);
17+
int MPIR_Allgather_fallback(const void *sendbuf, MPI_Aint sendcount, MPI_Datatype sendtype,
18+
void *recvbuf, MPI_Aint recvcount, MPI_Datatype recvtype,
19+
MPIR_Comm * comm_ptr, int coll_attr);
20+
int MPIR_Allgatherv_fallback(const void *sendbuf, MPI_Aint sendcount, MPI_Datatype sendtype,
21+
void *recvbuf, const MPI_Aint * recvcounts, const MPI_Aint * displs,
22+
MPI_Datatype recvtype, MPIR_Comm * comm_ptr, int coll_attr);
23+
int MPIR_Allreduce_fallback(const void *sendbuf, void *recvbuf,
24+
MPI_Aint count, MPI_Datatype datatype,
25+
MPI_Op op, MPIR_Comm * comm_ptr, int coll_attr);
26+
int MPIR_Bcast_fallback(void *buffer, MPI_Aint count, MPI_Datatype datatype, int root,
27+
MPIR_Comm * comm_ptr, int coll_attr);
28+
int MPIR_Gather_fallback(const void *sendbuf, MPI_Aint sendcount, MPI_Datatype sendtype,
29+
void *recvbuf, MPI_Aint recvcount, MPI_Datatype recvtype, int root,
30+
MPIR_Comm * comm_ptr, int coll_attr);
31+
int MPIR_Reduce_scatter_block_fallback(const void *sendbuf, void *recvbuf, MPI_Aint recvcount,
32+
MPI_Datatype datatype, MPI_Op op,
33+
MPIR_Comm * comm_ptr, int coll_attr);
2534

2635

2736
/* Internal point-to-point communication for collectives */

src/mpi/coll/src/Makefile.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
mpi_core_sources += \
1111
src/mpi/coll/src/coll_impl.c \
12+
src/mpi/coll/src/coll_fallback.c \
1213
src/mpi/coll/src/csel.c \
1314
src/mpi/coll/src/csel_container.c \
1415
src/mpi/coll/src/csel_json_autogen.c

src/mpi/coll/src/coll_fallback.c

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright (C) by Argonne National Laboratory
3+
* See COPYRIGHT in top-level directory
4+
*/
5+
6+
#include "mpiimpl.h"
7+
#include "coll_impl.h"
8+
9+
int MPIR_Barrier_fallback(MPIR_Comm * comm_ptr, int coll_attr)
10+
{
11+
MPIR_Assert(comm_ptr->comm_kind == MPIR_COMM_KIND__INTRACOMM);
12+
return MPIR_Barrier_intra_dissemination(comm_ptr, coll_attr);
13+
}
14+
15+
int MPIR_Allgather_fallback(const void *sendbuf, MPI_Aint sendcount, MPI_Datatype sendtype,
16+
void *recvbuf, MPI_Aint recvcount, MPI_Datatype recvtype,
17+
MPIR_Comm * comm_ptr, int coll_attr)
18+
{
19+
if (comm_ptr->comm_kind == MPIR_COMM_KIND__INTRACOMM) {
20+
return MPIR_Allgather_intra_brucks(sendbuf, sendcount, sendtype,
21+
recvbuf, recvcount, recvtype, comm_ptr, coll_attr);
22+
} else {
23+
return MPIR_Allgather_inter_local_gather_remote_bcast(sendbuf, sendcount, sendtype,
24+
recvbuf, recvcount, recvtype,
25+
comm_ptr, coll_attr);
26+
}
27+
}
28+
29+
int MPIR_Allgatherv_fallback(const void *sendbuf, MPI_Aint sendcount, MPI_Datatype sendtype,
30+
void *recvbuf, const MPI_Aint * recvcounts, const MPI_Aint * displs,
31+
MPI_Datatype recvtype, MPIR_Comm * comm_ptr, int coll_attr)
32+
{
33+
MPIR_Assert(comm_ptr->comm_kind == MPIR_COMM_KIND__INTRACOMM);
34+
return MPIR_Allgatherv_intra_brucks(sendbuf, sendcount, sendtype,
35+
recvbuf, recvcounts, displs, recvtype, comm_ptr, coll_attr);
36+
}
37+
38+
int MPIR_Allreduce_fallback(const void *sendbuf, void *recvbuf,
39+
MPI_Aint count, MPI_Datatype datatype,
40+
MPI_Op op, MPIR_Comm * comm_ptr, int coll_attr)
41+
{
42+
MPIR_Assert(comm_ptr->comm_kind == MPIR_COMM_KIND__INTRACOMM);
43+
return MPIR_Allreduce_intra_recursive_doubling(sendbuf, recvbuf, count, datatype, op,
44+
comm_ptr, coll_attr);
45+
}
46+
47+
int MPIR_Bcast_fallback(void *buffer, MPI_Aint count, MPI_Datatype datatype, int root,
48+
MPIR_Comm * comm_ptr, int coll_attr)
49+
{
50+
MPIR_Assert(comm_ptr->comm_kind == MPIR_COMM_KIND__INTRACOMM);
51+
return MPIR_Bcast_intra_binomial(buffer, count, datatype, root, comm_ptr, coll_attr);
52+
}
53+
54+
int MPIR_Gather_fallback(const void *sendbuf, MPI_Aint sendcount, MPI_Datatype sendtype,
55+
void *recvbuf, MPI_Aint recvcount, MPI_Datatype recvtype, int root,
56+
MPIR_Comm * comm_ptr, int coll_attr)
57+
{
58+
MPIR_Assert(comm_ptr->comm_kind == MPIR_COMM_KIND__INTRACOMM);
59+
return MPIR_Gather_intra_binomial(sendbuf, sendcount, sendtype,
60+
recvbuf, recvcount, recvtype, root, comm_ptr, coll_attr);
61+
}
62+
63+
int MPIR_Reduce_scatter_block_fallback(const void *sendbuf, void *recvbuf, MPI_Aint recvcount,
64+
MPI_Datatype datatype, MPI_Op op,
65+
MPIR_Comm * comm_ptr, int coll_attr)
66+
{
67+
MPIR_Assert(comm_ptr->comm_kind == MPIR_COMM_KIND__INTRACOMM);
68+
MPIR_Assert(MPIR_Op_is_commutative(op));
69+
return MPIR_Reduce_scatter_block_intra_recursive_halving(sendbuf, recvbuf, recvcount, datatype,
70+
op, comm_ptr, coll_attr);
71+
}

0 commit comments

Comments
 (0)