From fa33e322e70412f01cdf0f0f96cb62578b0786d1 Mon Sep 17 00:00:00 2001 From: Sergey Oblomov Date: Thu, 19 Jul 2018 12:39:15 +0300 Subject: [PATCH] OSC/UCX: code deduplication Signed-off-by: Sergey Oblomov --- ompi/mca/osc/ucx/osc_ucx_component.c | 33 ++++++++++++++-------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/ompi/mca/osc/ucx/osc_ucx_component.c b/ompi/mca/osc/ucx/osc_ucx_component.c index a0bd7be80a..ad604fb873 100644 --- a/ompi/mca/osc/ucx/osc_ucx_component.c +++ b/ompi/mca/osc/ucx/osc_ucx_component.c @@ -26,6 +26,7 @@ static int component_query(struct ompi_win_t *win, void **base, size_t size, int static int component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit, struct ompi_communicator_t *comm, struct opal_info_t *info, int flavor, int *model); +static void ompi_osc_ucx_unregister_progress(void); ompi_osc_ucx_component_t mca_osc_ucx_component = { { /* ompi_osc_base_component_t */ @@ -236,6 +237,20 @@ static inline int mem_map(void **base, size_t size, ucp_mem_h *memh_ptr, return ret; } +static void ompi_osc_ucx_unregister_progress() +{ + int ret; + + mca_osc_ucx_component.num_modules--; + OSC_UCX_ASSERT(mca_osc_ucx_component.num_modules >= 0); + if (0 == mca_osc_ucx_component.num_modules) { + ret = opal_progress_unregister(progress_callback); + if (OMPI_SUCCESS != ret) { + OSC_UCX_VERBOSE(1, "opal_progress_unregister failed: %d", ret); + } + } +} + static int component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit, struct ompi_communicator_t *comm, struct opal_info_t *info, int flavor, int *model) { @@ -643,14 +658,7 @@ static int component_select(struct ompi_win_t *win, void **base, size_t size, in } if (module) { free(module); - mca_osc_ucx_component.num_modules--; - OSC_UCX_ASSERT(mca_osc_ucx_component.num_modules >= 0); - if (0 == mca_osc_ucx_component.num_modules) { - ret = opal_progress_unregister(progress_callback); - if (OMPI_SUCCESS != ret) { - OSC_UCX_VERBOSE(1, "opal_progress_unregister failed: %d", ret); - } - } + ompi_osc_ucx_unregister_progress(); } error_nomem: @@ -819,14 +827,7 @@ int ompi_osc_ucx_free(struct ompi_win_t *win) { ompi_comm_free(&module->comm); free(module); - mca_osc_ucx_component.num_modules--; - OSC_UCX_ASSERT(mca_osc_ucx_component.num_modules >= 0); - if (0 == mca_osc_ucx_component.num_modules) { - ret = opal_progress_unregister(progress_callback); - if (OMPI_SUCCESS != ret) { - OSC_UCX_VERBOSE(1, "opal_progress_unregister failed: %d", ret); - } - } + ompi_osc_ucx_unregister_progress(); return ret; }