Skip to content

Commit fa33e32

Browse files
author
Sergey Oblomov
committed
OSC/UCX: code deduplication
Signed-off-by: Sergey Oblomov <sergeyo@mellanox.com>
1 parent 6f0a7a2 commit fa33e32

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

ompi/mca/osc/ucx/osc_ucx_component.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ static int component_query(struct ompi_win_t *win, void **base, size_t size, int
2626
static int component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit,
2727
struct ompi_communicator_t *comm, struct opal_info_t *info,
2828
int flavor, int *model);
29+
static void ompi_osc_ucx_unregister_progress(void);
2930

3031
ompi_osc_ucx_component_t mca_osc_ucx_component = {
3132
{ /* ompi_osc_base_component_t */
@@ -236,6 +237,20 @@ static inline int mem_map(void **base, size_t size, ucp_mem_h *memh_ptr,
236237
return ret;
237238
}
238239

240+
static void ompi_osc_ucx_unregister_progress()
241+
{
242+
int ret;
243+
244+
mca_osc_ucx_component.num_modules--;
245+
OSC_UCX_ASSERT(mca_osc_ucx_component.num_modules >= 0);
246+
if (0 == mca_osc_ucx_component.num_modules) {
247+
ret = opal_progress_unregister(progress_callback);
248+
if (OMPI_SUCCESS != ret) {
249+
OSC_UCX_VERBOSE(1, "opal_progress_unregister failed: %d", ret);
250+
}
251+
}
252+
}
253+
239254
static int component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit,
240255
struct ompi_communicator_t *comm, struct opal_info_t *info,
241256
int flavor, int *model) {
@@ -643,14 +658,7 @@ static int component_select(struct ompi_win_t *win, void **base, size_t size, in
643658
}
644659
if (module) {
645660
free(module);
646-
mca_osc_ucx_component.num_modules--;
647-
OSC_UCX_ASSERT(mca_osc_ucx_component.num_modules >= 0);
648-
if (0 == mca_osc_ucx_component.num_modules) {
649-
ret = opal_progress_unregister(progress_callback);
650-
if (OMPI_SUCCESS != ret) {
651-
OSC_UCX_VERBOSE(1, "opal_progress_unregister failed: %d", ret);
652-
}
653-
}
661+
ompi_osc_ucx_unregister_progress();
654662
}
655663

656664
error_nomem:
@@ -819,14 +827,7 @@ int ompi_osc_ucx_free(struct ompi_win_t *win) {
819827
ompi_comm_free(&module->comm);
820828

821829
free(module);
822-
mca_osc_ucx_component.num_modules--;
823-
OSC_UCX_ASSERT(mca_osc_ucx_component.num_modules >= 0);
824-
if (0 == mca_osc_ucx_component.num_modules) {
825-
ret = opal_progress_unregister(progress_callback);
826-
if (OMPI_SUCCESS != ret) {
827-
OSC_UCX_VERBOSE(1, "opal_progress_unregister failed: %d", ret);
828-
}
829-
}
830+
ompi_osc_ucx_unregister_progress();
830831

831832
return ret;
832833
}

0 commit comments

Comments
 (0)