@@ -115,6 +115,7 @@ cudaFunctionTable_t cuFunc;
115115static int stage_one_init_ref_count = 0 ;
116116static bool stage_three_init_complete = false;
117117static bool common_cuda_initialized = false;
118+ static bool common_cuda_mca_parames_registered = false;
118119static int mca_common_cuda_verbose ;
119120static int mca_common_cuda_output = 0 ;
120121bool mca_common_cuda_enabled = false;
@@ -223,42 +224,14 @@ static void cuda_dump_memhandle(int, void *, char *) __opal_attribute_unused__ ;
223224
224225#endif /* OPAL_CUDA_SUPPORT_41 */
225226
226-
227- /**
228- * This is the first stage of initialization. This function is
229- * called explicitly by any BTLs that can support CUDA-aware.
230- * It is called during the component open phase of initialization.
231- * This function will register some mca variables and then open
232- * and load the symbols needed from the CUDA driver library. Look for
233- * the SONAME of the library which is libcuda.so.1. In most cases,
234- * this will result in the library found. However, there are some
235- * setups that require the extra steps for searching. Any failure
236- * will result in this initialization failing and status will be set
237- * showing that.
238- */
239- int mca_common_cuda_stage_one_init (void )
227+ /* This is a seperate function so we can see these variables with ompi_info and
228+ * also set them with the tools interface */
229+ void mca_common_cuda_register_mca_variables (void )
240230{
241- int retval , i , j ;
242- char * cudalibs [] = {"libcuda.so.1" , "libcuda.dylib" , NULL };
243- char * searchpaths [] = {"" , "/usr/lib64" , NULL };
244- char * * errmsgs = NULL ;
245- char * errmsg = NULL ;
246- int errsize ;
247- bool stage_one_init_passed = false;
248231
249- stage_one_init_ref_count ++ ;
250- if (stage_one_init_ref_count > 1 ) {
251- opal_output_verbose (10 , mca_common_cuda_output ,
252- "CUDA: stage_one_init_ref_count is now %d, no need to init" ,
253- stage_one_init_ref_count );
254- return OPAL_SUCCESS ;
232+ if (false == common_cuda_mca_parames_registered ) {
233+ common_cuda_mca_parames_registered = true;
255234 }
256-
257- OBJ_CONSTRUCT (& common_cuda_init_lock , opal_mutex_t );
258- OBJ_CONSTRUCT (& common_cuda_htod_lock , opal_mutex_t );
259- OBJ_CONSTRUCT (& common_cuda_dtoh_lock , opal_mutex_t );
260- OBJ_CONSTRUCT (& common_cuda_ipc_lock , opal_mutex_t );
261-
262235 /* Set different levels of verbosity in the cuda related code. */
263236 mca_common_cuda_verbose = 0 ;
264237 (void ) mca_base_var_register ("ompi" , "mpi" , "common_cuda" , "verbose" ,
@@ -327,6 +300,43 @@ int mca_common_cuda_stage_one_init(void)
327300 MCA_BASE_VAR_SCOPE_READONLY ,
328301 & mca_common_cuda_cumemcpy_timing );
329302#endif /* OPAL_ENABLE_DEBUG */
303+ }
304+
305+ /**
306+ * This is the first stage of initialization. This function is called
307+ * explicitly by any BTLs that can support CUDA-aware. It is called during
308+ * the component open phase of initialization. This fuction will look for
309+ * the SONAME of the library which is libcuda.so.1. In most cases, this will
310+ * result in the library found. However, there are some setups that require
311+ * the extra steps for searching. This function will then load the symbols
312+ * needed from the CUDA driver library. Any failure will result in this
313+ * initialization failing and status will be set showing that.
314+ */
315+ int mca_common_cuda_stage_one_init (void )
316+ {
317+ int retval , i , j ;
318+ char * cudalibs [] = {"libcuda.so.1" , "libcuda.dylib" , NULL };
319+ char * searchpaths [] = {"" , "/usr/lib64" , NULL };
320+ char * * errmsgs = NULL ;
321+ char * errmsg = NULL ;
322+ int errsize ;
323+ bool stage_one_init_passed = false;
324+
325+ stage_one_init_ref_count ++ ;
326+ if (stage_one_init_ref_count > 1 ) {
327+ opal_output_verbose (10 , mca_common_cuda_output ,
328+ "CUDA: stage_one_init_ref_count is now %d, no need to init" ,
329+ stage_one_init_ref_count );
330+ return OPAL_SUCCESS ;
331+ }
332+
333+ /* This is a no-op in most cases as the parameters were registered earlier */
334+ mca_common_cuda_register_mca_variables ();
335+
336+ OBJ_CONSTRUCT (& common_cuda_init_lock , opal_mutex_t );
337+ OBJ_CONSTRUCT (& common_cuda_htod_lock , opal_mutex_t );
338+ OBJ_CONSTRUCT (& common_cuda_dtoh_lock , opal_mutex_t );
339+ OBJ_CONSTRUCT (& common_cuda_ipc_lock , opal_mutex_t );
330340
331341 mca_common_cuda_output = opal_output_open (NULL );
332342 opal_output_set_verbosity (mca_common_cuda_output , mca_common_cuda_verbose );
0 commit comments