Skip to content

Commit 8b4237c

Browse files
authored
Merge pull request #12504 from edgargabriel/topic/coll-verbose-selection
coll/base: add support for component name in output
2 parents 2bc506b + 3960b69 commit 8b4237c

File tree

1 file changed

+135
-2
lines changed

1 file changed

+135
-2
lines changed

ompi/mca/coll/base/coll_base_comm_select.c

Lines changed: 135 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "opal/util/argv.h"
4343
#include "opal/util/show_help.h"
4444
#include "opal/class/opal_list.h"
45+
#include "opal/class/opal_hash_table.h"
4546
#include "opal/class/opal_object.h"
4647
#include "ompi/mca/mca.h"
4748
#include "opal/mca/base/base.h"
@@ -75,6 +76,135 @@ static int query_2_4_0(const mca_coll_base_component_2_4_0_t *
7576
#define CHECK_NULL(what, comm, func) \
7677
( (what) = # func , NULL == (comm)->c_coll->coll_ ## func)
7778

79+
static void mca_coll_base_get_component_name(ompi_communicator_t *comm, void* module, char** name)
80+
{
81+
mca_coll_base_avail_coll_t *avail;
82+
83+
*name = NULL;
84+
OPAL_LIST_FOREACH(avail, comm->c_coll->module_list, mca_coll_base_avail_coll_t) {
85+
if (avail->ac_module == module) {
86+
*name = (char*) avail->ac_component_name;
87+
break;
88+
}
89+
}
90+
}
91+
92+
#define PRINT_NAME(comm, func, func_name) \
93+
do { \
94+
char *name; \
95+
mca_coll_base_get_component_name(comm, (void*)comm->c_coll->coll_ ## func ## _module, &name); \
96+
opal_output_verbose(10, ompi_coll_base_framework.framework_output, \
97+
"coll:base:comm_select: communicator %s rank %d %s -> %s", comm->c_name, comm->c_my_rank, func_name, name); \
98+
} while (0);
99+
100+
#define PRINT_ALL_BLOCKING(comm) \
101+
do { \
102+
PRINT_NAME(comm, allgather, "allgather"); \
103+
PRINT_NAME(comm, allgatherv, "allgatherv"); \
104+
PRINT_NAME(comm, allreduce, "allreduce"); \
105+
PRINT_NAME(comm, alltoall, "alltoall"); \
106+
PRINT_NAME(comm, alltoallv, "alltoallv"); \
107+
PRINT_NAME(comm, alltoallw, "alltoallw"); \
108+
PRINT_NAME(comm, barrier, "barrier"); \
109+
PRINT_NAME(comm, bcast, "bcast"); \
110+
PRINT_NAME(comm, exscan, "exscan"); \
111+
PRINT_NAME(comm, gather, "gather"); \
112+
PRINT_NAME(comm, gatherv, "gatherv"); \
113+
PRINT_NAME(comm, reduce, "reduce"); \
114+
PRINT_NAME(comm, reduce_scatter_block, "reduce_scatter_block"); \
115+
PRINT_NAME(comm, reduce_scatter, "reduce_scatter"); \
116+
PRINT_NAME(comm, scan, "scan"); \
117+
PRINT_NAME(comm, scatter, "scatter"); \
118+
PRINT_NAME(comm, scatterv, "scatterv"); \
119+
PRINT_NAME(comm, neighbor_allgather, "neighbor_allgather"); \
120+
PRINT_NAME(comm, neighbor_allgatherv, "neighbor_allgatherv"); \
121+
PRINT_NAME(comm, neighbor_alltoall, "neighbor_alltoall"); \
122+
PRINT_NAME(comm, neighbor_alltoallv, "neighbor_alltoallv"); \
123+
PRINT_NAME(comm, neighbor_alltoallw, "neighbor_alltoallw"); \
124+
PRINT_NAME(comm, reduce_local, "reduce_local"); \
125+
} while (0);
126+
127+
#define PRINT_ALL_NB(comm) \
128+
do { \
129+
PRINT_NAME(comm, iallgather, "iallgather"); \
130+
PRINT_NAME(comm, iallgatherv, "iallgatherv");\
131+
PRINT_NAME(comm, iallreduce, "iallreduce"); \
132+
PRINT_NAME(comm, ialltoall, "ialltoall"); \
133+
PRINT_NAME(comm, ialltoallv, "ialltoallv"); \
134+
PRINT_NAME(comm, ialltoallw, "ialltoallw"); \
135+
PRINT_NAME(comm, ibarrier, "ibarrier"); \
136+
PRINT_NAME(comm, ibcast, "ibcast"); \
137+
PRINT_NAME(comm, iexscan, "iexscan"); \
138+
PRINT_NAME(comm, igather, "igather"); \
139+
PRINT_NAME(comm, igatherv, "igatherv"); \
140+
PRINT_NAME(comm, ireduce, "ireduce"); \
141+
PRINT_NAME(comm, ireduce_scatter_block, "ireduce_scatter_block"); \
142+
PRINT_NAME(comm, ireduce_scatter, "ireduce_scatter"); \
143+
PRINT_NAME(comm, iscan, "iscan"); \
144+
PRINT_NAME(comm, iscatter, "iscatter"); \
145+
PRINT_NAME(comm, iscatterv, "iscatterv"); \
146+
PRINT_NAME(comm, ineighbor_allgather, "ineighbor_allgather"); \
147+
PRINT_NAME(comm, ineighbor_allgatherv, "ineighbor_allgatherv"); \
148+
PRINT_NAME(comm, ineighbor_alltoall, "ineighbor_alltoall"); \
149+
PRINT_NAME(comm, ineighbor_alltoallv, "ineighbor_alltoallv"); \
150+
PRINT_NAME(comm, ineighbor_alltoallw, "ineighbor_alltoallw"); \
151+
} while (0);
152+
153+
#define PRINT_ALL_PERSISTENT(comm) \
154+
do { \
155+
PRINT_NAME(comm, allgather_init, "allgather_init"); \
156+
PRINT_NAME(comm, allgatherv_init, "allgatherv_init"); \
157+
PRINT_NAME(comm, allreduce_init, "allreduce_init"); \
158+
PRINT_NAME(comm, alltoall_init, "alltoall_init"); \
159+
PRINT_NAME(comm, alltoallv_init, "alltoallv_init"); \
160+
PRINT_NAME(comm, alltoallw_init, "alltoallw_init"); \
161+
PRINT_NAME(comm, barrier_init, "barrier_init"); \
162+
PRINT_NAME(comm, bcast_init, "bcast_init"); \
163+
PRINT_NAME(comm, exscan_init, "exscan_init"); \
164+
PRINT_NAME(comm, gather_init, "gather_init"); \
165+
PRINT_NAME(comm, gatherv_init, "gatherv_init"); \
166+
PRINT_NAME(comm, reduce_init, "reduce_init"); \
167+
PRINT_NAME(comm, reduce_scatter_block_init, "reduce_scatter_block_init"); \
168+
PRINT_NAME(comm, reduce_scatter_init, "reduce_scatter_init"); \
169+
PRINT_NAME(comm, scan_init, "scan_init"); \
170+
PRINT_NAME(comm, scatter_init, "scatter_init"); \
171+
PRINT_NAME(comm, scatterv_init, "scatterv_init"); \
172+
PRINT_NAME(comm, neighbor_allgather_init, "neighbor_allgather_init"); \
173+
PRINT_NAME(comm, neighbor_allgatherv_init, "neighbor_allgatherv_init"); \
174+
PRINT_NAME(comm, neighbor_alltoall_init, "neighbor_alltoall_init"); \
175+
PRINT_NAME(comm, neighbor_alltoallv_init, "neighbor_alltoallv_init"); \
176+
PRINT_NAME(comm, neighbor_alltoallw_init, "neighbor_alltoallw_init"); \
177+
} while (0);
178+
179+
#define PRINT_ALL_FT(comm) \
180+
do { \
181+
PRINT_NAME(comm, agree, "agree"); \
182+
PRINT_NAME(comm, iagree, "iagree"); \
183+
} while (0);
184+
185+
static void mca_coll_base_print_component_names(ompi_communicator_t *comm)
186+
{
187+
/*
188+
** Verbosity level 1 - 19 will only print the blocking and non-blocking collectives
189+
** assigned to MPI_COMM_WORLD, but not the persistent and ft ones.
190+
**
191+
** Verbosity level 20 will print all blocking and non-blocking collectives for all communicators,
192+
** but not the persistent and ft ones.
193+
**
194+
** Verbosity level > 20 will print all collectives for all communicators.
195+
*/
196+
if ( (MPI_COMM_WORLD == comm) || (ompi_coll_base_framework.framework_verbose >= 20)) {
197+
PRINT_ALL_BLOCKING (comm);
198+
PRINT_ALL_NB (comm);
199+
if (ompi_coll_base_framework.framework_verbose > 20) {
200+
PRINT_ALL_PERSISTENT (comm);
201+
#if OPAL_ENABLE_FT_MPI
202+
PRINT_ALL_FT (comm);
203+
#endif
204+
}
205+
}
206+
}
207+
78208
/*
79209
* This function is called at the initialization time of every
80210
* communicator. It is used to select which coll component will be
@@ -123,7 +253,6 @@ int mca_coll_base_comm_select(ompi_communicator_t * comm)
123253
NULL != item; item = opal_list_remove_first(selectable)) {
124254

125255
mca_coll_base_avail_coll_t *avail = (mca_coll_base_avail_coll_t *) item;
126-
127256
/* initialize the module */
128257
ret = avail->ac_module->coll_module_enable(avail->ac_module, comm);
129258

@@ -142,7 +271,6 @@ int mca_coll_base_comm_select(ompi_communicator_t * comm)
142271
OBJ_RELEASE(avail);
143272
}
144273
}
145-
146274
/* Done with the list from the check_components() call so release it. */
147275
OBJ_RELEASE(selectable);
148276

@@ -212,6 +340,11 @@ int mca_coll_base_comm_select(ompi_communicator_t * comm)
212340
mca_coll_base_comm_unselect(comm);
213341
return OMPI_ERR_NOT_FOUND;
214342
}
343+
344+
if (ompi_coll_base_framework.framework_verbose > 0) {
345+
mca_coll_base_print_component_names(comm);
346+
}
347+
215348
return OMPI_SUCCESS;
216349
}
217350

0 commit comments

Comments
 (0)