|
8 | 8 | */ |
9 | 9 |
|
10 | 10 | #include <ompi_config.h> |
| 11 | +#include <string.h> |
11 | 12 | #include "osc_monitoring.h" |
12 | 13 | #include <ompi/constants.h> |
13 | 14 | #include <ompi/communicator/communicator.h> |
|
18 | 19 | #include <ompi/mca/osc/base/base.h> |
19 | 20 | #include <opal/mca/base/mca_base_component_repository.h> |
20 | 21 |
|
21 | | -/***************************************/ |
22 | | -/* Include template generating macros */ |
23 | | -#include "osc_monitoring_template.h" |
| 22 | +/**************************************************/ |
| 23 | +/* Include templated macros and inlined functions */ |
24 | 24 |
|
25 | | -#include <ompi/mca/osc/rdma/osc_rdma.h> |
26 | | -OSC_MONITORING_MODULE_TEMPLATE_GENERATE(rdma, ompi_osc_rdma_module_t, comm) |
27 | | -#undef GET_MODULE |
| 25 | +#include "osc_monitoring_template_gen.h" |
28 | 26 |
|
29 | | -#include <ompi/mca/osc/sm/osc_sm.h> |
30 | | -OSC_MONITORING_MODULE_TEMPLATE_GENERATE(sm, ompi_osc_sm_module_t, comm) |
31 | | -#undef GET_MODULE |
32 | | - |
33 | | -#include <ompi/mca/osc/pt2pt/osc_pt2pt.h> |
34 | | -OSC_MONITORING_MODULE_TEMPLATE_GENERATE(pt2pt, ompi_osc_pt2pt_module_t, comm) |
35 | | -#undef GET_MODULE |
36 | | - |
37 | | -#ifdef OMPI_WITH_OSC_PORTALS4 |
38 | | -#include <ompi/mca/osc/portals4/osc_portals4.h> |
39 | | -OSC_MONITORING_MODULE_TEMPLATE_GENERATE(portals4, ompi_osc_portals4_module_t, comm) |
40 | | -#undef GET_MODULE |
41 | | -#endif /* OMPI_WITH_OSC_PORTALS4 */ |
42 | | - |
43 | | -/***************************************/ |
| 27 | +/**************************************************/ |
44 | 28 |
|
45 | 29 | static int mca_osc_monitoring_component_init(bool enable_progress_threads, |
46 | 30 | bool enable_mpi_threads) |
@@ -69,6 +53,20 @@ static int mca_osc_monitoring_component_query(struct ompi_win_t *win, void **bas |
69 | 53 | return mca_osc_monitoring_component.priority; |
70 | 54 | } |
71 | 55 |
|
| 56 | +static inline int |
| 57 | +ompi_mca_osc_monitoring_set_template(ompi_osc_base_component_t *best_component, |
| 58 | + ompi_osc_base_module_t *module) |
| 59 | +{ |
| 60 | + osc_monitoring_components_list_t comp = osc_monitoring_components_list[0]; |
| 61 | + for (unsigned i = 0; NULL != comp.name; comp = osc_monitoring_components_list[++i]) { |
| 62 | + if ( 0 == strcmp(comp.name, best_component->osc_version.mca_component_name) ) { |
| 63 | + comp.fct(module); |
| 64 | + return OMPI_SUCCESS; |
| 65 | + } |
| 66 | + } |
| 67 | + return OMPI_ERR_NOT_SUPPORTED; |
| 68 | +} |
| 69 | + |
72 | 70 | static int mca_osc_monitoring_component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit, |
73 | 71 | struct ompi_communicator_t *comm, struct opal_info_t *info, |
74 | 72 | int flavor, int *model) |
@@ -108,20 +106,11 @@ static int mca_osc_monitoring_component_select(struct ompi_win_t *win, void **ba |
108 | 106 | ret = best_component->osc_select(win, base, size, disp_unit, comm, info, flavor, model); |
109 | 107 | if( OMPI_SUCCESS == ret ) { |
110 | 108 | /* Intercept module functions with ours, based on selected component */ |
111 | | - if( 0 == strcmp("rdma", best_component->osc_version.mca_component_name) ) { |
112 | | - OSC_MONITORING_SET_TEMPLATE(rdma, win->w_osc_module); |
113 | | - } else if( 0 == strcmp("sm", best_component->osc_version.mca_component_name) ) { |
114 | | - OSC_MONITORING_SET_TEMPLATE(sm, win->w_osc_module); |
115 | | - } else if( 0 == strcmp("pt2pt", best_component->osc_version.mca_component_name) ) { |
116 | | - OSC_MONITORING_SET_TEMPLATE(pt2pt, win->w_osc_module); |
117 | | -#ifdef OMPI_WITH_OSC_PORTALS4 |
118 | | - } else if( 0 == strcmp("portals4", best_component->osc_version.mca_component_name) ) { |
119 | | - OSC_MONITORING_SET_TEMPLATE(portals4, win->w_osc_module); |
120 | | -#endif /* OMPI_WITH_OSC_PORTALS4 */ |
121 | | - } else { |
| 109 | + ret = ompi_mca_osc_monitoring_set_template(best_component, win->w_osc_module); |
| 110 | + if (OMPI_ERR_NOT_SUPPORTED == ret) { |
122 | 111 | OPAL_MONITORING_PRINT_WARN("osc: monitoring disabled: no module for this component " |
123 | 112 | "(%s)", best_component->osc_version.mca_component_name); |
124 | | - return ret; |
| 113 | + return OMPI_SUCCESS; |
125 | 114 | } |
126 | 115 | } |
127 | 116 | return ret; |
@@ -150,4 +139,3 @@ ompi_osc_monitoring_component_t mca_osc_monitoring_component = { |
150 | 139 | }, |
151 | 140 | .priority = INT_MAX |
152 | 141 | }; |
153 | | - |
0 commit comments