2
2
* Copyright (c) 2015-2020 Intel, Inc. All rights reserved.
3
3
* Copyright (c) 2017 Los Alamos National Security, LLC. All rights
4
4
* reserved.
5
- * Copyright (c) 2020 Triad National Security, LLC. All rights
5
+ * Copyright (c) 2020-2021 Triad National Security, LLC. All rights
6
6
* reserved.
7
7
* Copyright (c) 2020 Cisco Systems, Inc. All rights reserved
8
8
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
@@ -32,6 +32,7 @@ OPAL_DECLSPEC opal_common_ofi_module_t opal_common_ofi = {.prov_include = NULL,
32
32
.verbose = 0 };
33
33
34
34
static const char default_prov_exclude_list [] = "shm,sockets,tcp,udp,rstream" ;
35
+ static opal_mutex_t opal_common_ofi_mutex = OPAL_MUTEX_STATIC_INIT ;
35
36
36
37
OPAL_DECLSPEC int opal_common_ofi_is_in_list (char * * list , char * item )
37
38
{
@@ -54,23 +55,29 @@ OPAL_DECLSPEC int opal_common_ofi_is_in_list(char **list, char *item)
54
55
55
56
OPAL_DECLSPEC int opal_common_ofi_register_mca_variables (const mca_base_component_t * component )
56
57
{
57
- static int registered = 0 ;
58
58
static int include_index ;
59
59
static int exclude_index ;
60
60
static int verbose_index ;
61
+ int param ;
61
62
62
63
if (fi_version () < FI_VERSION (1 , 0 )) {
63
64
return OPAL_ERROR ;
64
65
}
65
66
66
- if (!registered ) {
67
+ OPAL_THREAD_LOCK (& opal_common_ofi_mutex );
68
+
69
+ param = mca_base_var_find ("opal" , "opal_common" , "ofi" , "provider_incude" );
70
+ if (0 > param ) {
67
71
/*
68
72
* this monkey business is needed because of the way the MCA VARs stuff tries to handle
69
73
* pointers to strings when when destructing the MCA var database. If you don't do
70
74
* something like this,the MCA var framework will try to dereference a pointer which itself
71
75
* is no longer a valid address owing to having been previously dlclosed.
72
76
*/
73
- opal_common_ofi .prov_include = (char * * ) malloc (sizeof (char * ));
77
+ if (NULL == opal_common_ofi .prov_include ) {
78
+ opal_common_ofi .prov_include = (char * * ) malloc (sizeof (char * ));
79
+ assert (NULL != opal_common_ofi .prov_include );
80
+ }
74
81
* opal_common_ofi .prov_include = NULL ;
75
82
include_index = mca_base_var_register (
76
83
"opal" , "opal_common" , "ofi" , "provider_include" ,
@@ -79,7 +86,14 @@ OPAL_DECLSPEC int opal_common_ofi_register_mca_variables(const mca_base_componen
79
86
"exclusive with mtl_ofi_provider_exclude." ,
80
87
MCA_BASE_VAR_TYPE_STRING , NULL , 0 , 0 , OPAL_INFO_LVL_1 , MCA_BASE_VAR_SCOPE_READONLY ,
81
88
opal_common_ofi .prov_include );
82
- opal_common_ofi .prov_exclude = (char * * ) malloc (sizeof (char * ));
89
+ }
90
+
91
+ param = mca_base_var_find ("opal" , "opal_common" , "ofi" , "provider_exclude" );
92
+ if (0 > param ) {
93
+ if (NULL == opal_common_ofi .prov_exclude ) {
94
+ opal_common_ofi .prov_exclude = (char * * ) malloc (sizeof (char * ));
95
+ assert (NULL != opal_common_ofi .prov_exclude );
96
+ }
83
97
* opal_common_ofi .prov_exclude = strdup (default_prov_exclude_list );
84
98
exclude_index = mca_base_var_register (
85
99
"opal" , "opal_common" , "ofi" , "provider_exclude" ,
@@ -88,12 +102,16 @@ OPAL_DECLSPEC int opal_common_ofi_register_mca_variables(const mca_base_componen
88
102
"exclusive with mtl_ofi_provider_include." ,
89
103
MCA_BASE_VAR_TYPE_STRING , NULL , 0 , 0 , OPAL_INFO_LVL_1 , MCA_BASE_VAR_SCOPE_READONLY ,
90
104
opal_common_ofi .prov_exclude );
105
+ }
106
+
107
+ param = mca_base_var_find ("opal" , "opal_common" , "ofi" , "verbose" );
108
+ if (0 > param ) {
91
109
verbose_index = mca_base_var_register ("opal" , "opal_common" , "ofi" , "verbose" ,
92
110
"Verbose level of the OFI components" ,
93
111
MCA_BASE_VAR_TYPE_INT , NULL , 0 ,
94
112
MCA_BASE_VAR_FLAG_SETTABLE , OPAL_INFO_LVL_3 ,
95
- MCA_BASE_VAR_SCOPE_LOCAL , & opal_common_ofi . verbose );
96
- registered = 1 ;
113
+ MCA_BASE_VAR_SCOPE_LOCAL ,
114
+ & opal_common_ofi . verbose ) ;
97
115
}
98
116
99
117
if (component ) {
@@ -108,6 +126,8 @@ OPAL_DECLSPEC int opal_common_ofi_register_mca_variables(const mca_base_componen
108
126
"verbose" , 0 );
109
127
}
110
128
129
+ OPAL_THREAD_UNLOCK (& opal_common_ofi_mutex );
130
+
111
131
return OPAL_SUCCESS ;
112
132
}
113
133
0 commit comments