Skip to content

Commit 70d6dfa

Browse files
committed
Only keep a generated argv-style array
Following Jeff's advice, the configure.m4 file generate a simple array of module variables to be iterated over to find the proper module. Signed-off-by: Clement Foyer <[email protected]>
1 parent d250c46 commit 70d6dfa

File tree

2 files changed

+30
-17
lines changed

2 files changed

+30
-17
lines changed

ompi/mca/osc/monitoring/configure.m4

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ AC_DEFUN(
4848
#include <ompi/mca/osc/osc.h>
4949
#include <ompi/mca/osc/monitoring/osc_monitoring_template.h>
5050

51-
/***************************************/
52-
/* Include template generating macros */
51+
/************************************************************/
52+
/* Include template generating macros and inlined functions */
5353

5454
EOF
5555
# Generate each case in order to register the proper template functions
@@ -59,37 +59,36 @@ EOF
5959
done
6060
cat <<EOF >>$filename
6161

62-
/***************************************/
62+
/************************************************************/
6363

64-
static inline int
65-
ompi_mca_osc_monitoring_set_template(ompi_osc_base_component_t *best_component,
66-
ompi_osc_base_module_t *module)
67-
{
68-
/* Sorry for the lack on indentation, but the portability won over the cleanliness */
64+
typedef struct {
65+
const char * name;
66+
ompi_osc_base_module_t * (*fct) (ompi_osc_base_module_t *);
67+
} osc_monitoring_components_list_t;
68+
69+
static const osc_monitoring_components_list_t osc_monitoring_components_list[[]] = {
6970
EOF
7071
for comp in $components
7172
do
72-
echo "if ( 0 == strcmp(\"${comp}\", best_component->osc_version.mca_component_name) ) {" >>$filename
73-
echo " OSC_MONITORING_SET_TEMPLATE_FCT_NAME(${comp}) (module);" >>$filename
74-
echo " } else " >>$filename
73+
echo " { .name = \"${comp}\", .fct = OSC_MONITORING_SET_TEMPLATE_FCT_NAME(${comp}) }," >>$filename
7574
done
7675
cat <<EOF >>$filename
77-
return OMPI_ERR_NOT_SUPPORTED;
78-
return OMPI_SUCCESS;
79-
}
76+
{ .name = NULL, .fct = NULL }
77+
};
8078
8179
#endif /* MCA_OSC_MONITORING_GEN_TEMPLATE_H */
8280
EOF
83-
unset filename components])
81+
unset filename components
82+
])
8483
])dnl
85-
])dnl
84+
])dnl
8685

8786
# MCA_ompi_osc_monitoring_CONFIG()
8887
# ------------------------------------------------
8988
AC_DEFUN(
9089
[MCA_ompi_osc_monitoring_CONFIG],
9190
[AC_CONFIG_FILES([ompi/mca/osc/monitoring/Makefile])
92-
91+
9392
AS_IF([test "$MCA_BUILD_ompi_common_monitoring_DSO_TRUE" = ''],
9493
[$1],
9594
[$2])

ompi/mca/osc/monitoring/osc_monitoring_component.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,20 @@ static int mca_osc_monitoring_component_query(struct ompi_win_t *win, void **bas
5252
return mca_osc_monitoring_component.priority;
5353
}
5454

55+
static inline int
56+
ompi_mca_osc_monitoring_set_template(ompi_osc_base_component_t *best_component,
57+
ompi_osc_base_module_t *module)
58+
{
59+
osc_monitoring_components_list_t comp = osc_monitoring_components_list[0];
60+
for (unsigned i = 0; NULL != comp.name; comp = osc_monitoring_components_list[++i]) {
61+
if ( 0 == strcmp(comp.name, best_component->osc_version.mca_component_name) ) {
62+
comp.fct(module);
63+
return OMPI_SUCCESS;
64+
}
65+
}
66+
return OMPI_ERR_NOT_SUPPORTED;
67+
}
68+
5569
static int mca_osc_monitoring_component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit,
5670
struct ompi_communicator_t *comm, struct opal_info_t *info,
5771
int flavor, int *model)

0 commit comments

Comments
 (0)