Skip to content

Commit f7803dd

Browse files
committed
smcuda: fixes when using enable-mca-dso
related to #11354 Signed-off-by: Howard Pritchard <howardp@lanl.gov>
1 parent da6cb6b commit f7803dd

File tree

3 files changed

+34
-16
lines changed

3 files changed

+34
-16
lines changed

opal/mca/btl/smcuda/btl_smcuda_accelerator.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/*
22
* Copyright (c) 2022 Amazon.com, Inc. or its affiliates. All Rights reserved.
33
* Copyright (c) 2022 IBM Corporation. All rights reserved.
4+
* Copyright (c) 2023 Triad National Security, LLC. All rights
5+
* reserved.
46
* $COPYRIGHT$
57
*
68
* Additional copyrights may follow
@@ -35,6 +37,8 @@ static int accelerator_event_max = 400;
3537
static int accelerator_event_ipc_most = 0;
3638
static bool smcuda_accelerator_initialized = false;
3739

40+
static void mca_btl_smcuda_accelerator_fini(void);
41+
3842
int mca_btl_smcuda_accelerator_init(void)
3943
{
4044
int rc = OPAL_SUCCESS;
@@ -79,6 +83,14 @@ int mca_btl_smcuda_accelerator_init(void)
7983
goto cleanup_and_error;
8084
}
8185

86+
/*
87+
* add smcuda acclerator fini code to opal's list of cleanup functions.
88+
* Cleanups are called before all the MCA frameworks are closed, so by
89+
* adding this function to the callback list, we avoid issues with ordering
90+
* of the closing of the BTL framework with the accelerator framework, etc. etc.
91+
*/
92+
opal_finalize_register_cleanup(mca_btl_smcuda_accelerator_fini);
93+
8294
smcuda_accelerator_initialized = true;
8395

8496
cleanup_and_error:
@@ -103,7 +115,7 @@ int mca_btl_smcuda_accelerator_init(void)
103115
return rc;
104116
}
105117

106-
void mca_btl_smcuda_accelerator_fini(void)
118+
static void mca_btl_smcuda_accelerator_fini(void)
107119
{
108120
int i;
109121

opal/mca/btl/smcuda/btl_smcuda_accelerator.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/*
22
* Copyright (c) 2022 Amazon.com, Inc. or its affiliates. All Rights
33
* reserved.
4+
* Copyright (c) 2023 Triad National Security, LLC. All rights
5+
* reserved.
46
* $COPYRIGHT$
57
*
68
* Additional copyrights may follow
@@ -17,7 +19,6 @@
1719
#include "opal/mca/btl/btl.h"
1820

1921
OPAL_DECLSPEC int mca_btl_smcuda_accelerator_init(void);
20-
OPAL_DECLSPEC void mca_btl_smcuda_accelerator_fini(void);
2122
OPAL_DECLSPEC int mca_btl_smcuda_progress_one_ipc_event(struct mca_btl_base_descriptor_t **frag);
2223
OPAL_DECLSPEC int mca_btl_smcuda_memcpy(void *dst, void *src, size_t amount, char *msg,
2324
struct mca_btl_base_descriptor_t *frag);

opal/mca/btl/smcuda/btl_smcuda_component.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* Copyright (c) 2014 Intel, Inc. All rights reserved.
1919
* Copyright (c) 2018-2022 Amazon.com, Inc. or its affiliates. All Rights reserved.
2020
* Copyright (c) 2022 IBM Corporation. All rights reserved.
21+
* Copyright (c) 2023 Triad National Security, LLC. All rights
22+
* reserved.
2123
* $COPYRIGHT$
2224
*
2325
* Additional copyrights may follow
@@ -69,6 +71,8 @@ static int smcuda_register(void);
6971
static mca_btl_base_module_t **
7072
mca_btl_smcuda_component_init(int *num_btls, bool enable_progress_threads, bool enable_mpi_threads);
7173

74+
static void mca_btl_smcuda_component_fini(void);
75+
7276
typedef enum {
7377
MCA_BTL_SM_RNDV_MOD_SM = 0,
7478
MCA_BTL_SM_RNDV_MOD_MPOOL
@@ -214,7 +218,7 @@ static int smcuda_register(void)
214218
if (0 == mca_btl_smcuda.super.btl_accelerator_eager_limit) {
215219
mca_btl_smcuda.super.btl_accelerator_eager_limit = SIZE_MAX; /* magic number */
216220
}
217-
#endif
221+
#endif /* OPAL_CUDA_SUPPORT */
218222
return mca_btl_smcuda_component_verify();
219223
}
220224

@@ -260,16 +264,24 @@ static int mca_btl_smcuda_component_open(void)
260264
OBJ_CONSTRUCT(&mca_btl_smcuda_component.sm_frags_max, opal_free_list_t);
261265
OBJ_CONSTRUCT(&mca_btl_smcuda_component.sm_frags_user, opal_free_list_t);
262266
OBJ_CONSTRUCT(&mca_btl_smcuda_component.pending_send_fl, opal_free_list_t);
267+
268+
opal_finalize_register_cleanup(mca_btl_smcuda_component_fini);
269+
270+
return OPAL_SUCCESS;
271+
}
272+
273+
static int mca_btl_smcuda_component_close(void)
274+
{
263275
return OPAL_SUCCESS;
264276
}
265277

266278
/*
267279
* component cleanup - sanity checking of queue lengths
268280
*/
269281

270-
static int mca_btl_smcuda_component_close(void)
282+
static void mca_btl_smcuda_component_fini(void)
271283
{
272-
int return_value = OPAL_SUCCESS;
284+
int rc;
273285

274286
OBJ_DESTRUCT(&mca_btl_smcuda_component.sm_lock);
275287
/**
@@ -282,11 +294,10 @@ static int mca_btl_smcuda_component_close(void)
282294

283295
/* unmap the shared memory control structure */
284296
if (mca_btl_smcuda_component.sm_seg != NULL) {
285-
return_value = mca_common_sm_fini(mca_btl_smcuda_component.sm_seg);
286-
if (OPAL_SUCCESS != return_value) {
287-
return_value = OPAL_ERROR;
297+
rc = mca_common_sm_fini(mca_btl_smcuda_component.sm_seg);
298+
if (OPAL_SUCCESS != rc) {
288299
opal_output(0, " mca_common_sm_fini failed\n");
289-
goto CLEANUP;
300+
return;
290301
}
291302

292303
/* unlink file, so that it will be deleted when all references
@@ -310,13 +321,7 @@ static int mca_btl_smcuda_component_close(void)
310321
unlink(mca_btl_smcuda_component.sm_fifo_path);
311322
}
312323
#endif
313-
314-
CLEANUP:
315-
316-
mca_btl_smcuda_accelerator_fini();
317-
318-
/* return */
319-
return return_value;
324+
return;
320325
}
321326

322327
/*

0 commit comments

Comments
 (0)