1616#include "ompi/mca/coll/coll.h"
1717#include "coll_acoll.h"
1818
19+
20+ static int acoll_module_enable (mca_coll_base_module_t * module , struct ompi_communicator_t * comm );
21+ static int acoll_module_disable (mca_coll_base_module_t * module , struct ompi_communicator_t * comm );
22+
1923/*
2024 * Initial query function that is invoked during MPI_INIT, allowing
2125 * this component to disqualify itself if it doesn't support the
@@ -27,6 +31,26 @@ int mca_coll_acoll_init_query(bool enable_progress_threads, bool enable_mpi_thre
2731 return OMPI_SUCCESS ;
2832}
2933
34+
35+
36+ #define ACOLL_INSTALL_COLL_API (__comm , __module , __api ) \
37+ do \
38+ { \
39+ if (__module->super.coll_##__api) \
40+ { \
41+ MCA_COLL_INSTALL_API(__comm, __api, __module->super.coll_##__api, &__module->super, "acoll"); \
42+ } \
43+ } while (0)
44+
45+ #define ACOLL_UNINSTALL_COLL_API (__comm , __module , __api ) \
46+ do \
47+ { \
48+ if (__comm->c_coll->coll_##__api##_module == &__module->super) \
49+ { \
50+ MCA_COLL_INSTALL_API(__comm, __api, NULL, NULL, "acoll"); \
51+ } \
52+ } while (0)
53+
3054/*
3155 * Invoked when there's a new communicator that has been created.
3256 * Look at the communicator and decide which set of functions and
@@ -124,49 +148,53 @@ mca_coll_base_module_t *mca_coll_acoll_comm_query(struct ompi_communicator_t *co
124148
125149 /* Choose whether to use [intra|inter], and [subgroup|normal]-based
126150 * algorithms. */
127- acoll_module -> super .coll_module_enable = mca_coll_acoll_module_enable ;
151+ acoll_module -> super .coll_module_enable = acoll_module_enable ;
152+ acoll_module -> super .coll_module_disable = acoll_module_disable ;
128153
129154 acoll_module -> super .coll_allgather = mca_coll_acoll_allgather ;
130- acoll_module -> super .coll_allgatherv = NULL ;
131155 acoll_module -> super .coll_allreduce = mca_coll_acoll_allreduce_intra ;
132- acoll_module -> super .coll_alltoall = NULL ;
133- acoll_module -> super .coll_alltoallv = NULL ;
134- acoll_module -> super .coll_alltoallw = NULL ;
135156 acoll_module -> super .coll_barrier = mca_coll_acoll_barrier_intra ;
136157 acoll_module -> super .coll_bcast = mca_coll_acoll_bcast ;
137- acoll_module -> super .coll_exscan = NULL ;
138158 acoll_module -> super .coll_gather = mca_coll_acoll_gather_intra ;
139- acoll_module -> super .coll_gatherv = NULL ;
140159 acoll_module -> super .coll_reduce = mca_coll_acoll_reduce_intra ;
141- acoll_module -> super .coll_reduce_scatter_block = NULL ;
142- acoll_module -> super .coll_reduce_scatter = NULL ;
143- acoll_module -> super .coll_scan = NULL ;
144- acoll_module -> super .coll_scatter = NULL ;
145- acoll_module -> super .coll_scatterv = NULL ;
146-
147- acoll_module -> super .coll_neighbor_allgather = NULL ;
148- acoll_module -> super .coll_neighbor_allgatherv = NULL ;
149- acoll_module -> super .coll_neighbor_alltoall = NULL ;
150- acoll_module -> super .coll_neighbor_alltoallv = NULL ;
151- acoll_module -> super .coll_neighbor_alltoallw = NULL ;
152-
153- acoll_module -> super .coll_reduce_local = NULL ;
154160
155161 return & (acoll_module -> super );
156162}
157163
158164/*
159165 * Init module on the communicator
160166 */
161- int mca_coll_acoll_module_enable (mca_coll_base_module_t * module , struct ompi_communicator_t * comm )
167+ static int acoll_module_enable (mca_coll_base_module_t * module , struct ompi_communicator_t * comm )
162168{
169+ mca_coll_acoll_module_t * acoll_module = (mca_coll_acoll_module_t * ) module ;
170+
163171 /* prepare the placeholder for the array of request* */
164172 module -> base_data = OBJ_NEW (mca_coll_base_comm_t );
165173 if (NULL == module -> base_data ) {
166174 return OMPI_ERROR ;
167175 }
168176
177+ ACOLL_INSTALL_COLL_API (comm , acoll_module , allgather );
178+ ACOLL_INSTALL_COLL_API (comm , acoll_module , allreduce );
179+ ACOLL_INSTALL_COLL_API (comm , acoll_module , barrier );
180+ ACOLL_INSTALL_COLL_API (comm , acoll_module , bcast );
181+ ACOLL_INSTALL_COLL_API (comm , acoll_module , gather );
182+ ACOLL_INSTALL_COLL_API (comm , acoll_module , reduce );
183+
169184 /* All done */
170185 return OMPI_SUCCESS ;
171186}
172187
188+ static int acoll_module_disable (mca_coll_base_module_t * module , struct ompi_communicator_t * comm )
189+ {
190+ mca_coll_acoll_module_t * acoll_module = (mca_coll_acoll_module_t * ) module ;
191+
192+ ACOLL_UNINSTALL_COLL_API (comm , acoll_module , allgather );
193+ ACOLL_UNINSTALL_COLL_API (comm , acoll_module , allreduce );
194+ ACOLL_UNINSTALL_COLL_API (comm , acoll_module , barrier );
195+ ACOLL_UNINSTALL_COLL_API (comm , acoll_module , bcast );
196+ ACOLL_UNINSTALL_COLL_API (comm , acoll_module , gather );
197+ ACOLL_UNINSTALL_COLL_API (comm , acoll_module , reduce );
198+
199+ return OMPI_SUCCESS ;
200+ }
0 commit comments