1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2 /*
3 * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
4 * University Research and Technology
5 * Corporation. All rights reserved.
6 * Copyright (c) 2004-2006 The University of Tennessee and The University
7 * of Tennessee Research Foundation. All rights
8 * reserved.
9 * Copyright (c) 2004-2007 High Performance Computing Center Stuttgart,
10 * University of Stuttgart. All rights reserved.
11 * Copyright (c) 2004-2006 The Regents of the University of California.
12 * All rights reserved.
13 * Copyright (c) 2015 Research Organization for Information Science
14 * and Technology (RIST). All rights reserved.
15 * Copyright (c) 2016 Los Alamos National Security, LLC. All rights
16 * reserved.
17 * $COPYRIGHT$
18 *
19 * Additional copyrights may follow
20 *
21 * $HEADER$
22 */
23
24 #include "ompi_config.h"
25 #include "ompi/mca/bml/base/base.h"
26 #include "opal/mca/base/base.h"
27
28 #include "ompi/mca/mca.h"
29 #include "opal/runtime/opal.h"
30
31 mca_bml_base_module_t mca_bml = {
32 NULL, /* bml_component */
33 NULL, /* bml_add_procs */
34 NULL, /* bml_del_procs */
35 NULL, /* bml_add_btl */
36 NULL, /* bml_del_btl */
37 NULL, /* bml_del_proc_btl */
38 NULL, /* bml_register */
39 NULL, /* bml_register_error */
40 NULL, /* bml_finalize*/
41 NULL /* FT event */
42 };
43 mca_bml_base_component_t mca_bml_component = {{0}};
44
45 static bool init_called = false;
46
47 bool
48 mca_bml_base_inited(void)
49 {
50 return init_called;
51 }
52
53 int mca_bml_base_init( bool enable_progress_threads,
54 bool enable_mpi_threads) {
55 mca_bml_base_component_t *component = NULL, *best_component = NULL;
56 mca_bml_base_module_t *module = NULL, *best_module = NULL;
57 int priority = 0, best_priority = -1;
58 mca_base_component_list_item_t *cli = NULL;
59
60 if (init_called) {
61 return OPAL_SUCCESS;
62 }
63
64 init_called = true;
65
66 OPAL_LIST_FOREACH(cli, &ompi_bml_base_framework.framework_components, mca_base_component_list_item_t) {
67 component = (mca_bml_base_component_t*) cli->cli_component;
68 if(NULL == component->bml_init) {
69 opal_output_verbose( 10, ompi_bml_base_framework.framework_output,
70 "select: no init function; ignoring component %s",
71 component->bml_version.mca_component_name );
72 continue;
73 }
74 module = component->bml_init(&priority,
75 enable_progress_threads,
76 enable_mpi_threads);
77
78 if(NULL == module) {
79 continue;
80 }
81 if(priority > best_priority) {
82 best_priority = priority;
83 best_component = component;
84 best_module = module;
85 }
86
87 }
88 if(NULL == best_module) {
89 return OMPI_SUCCESS;
90 }
91
92 mca_bml_component = *best_component;
93 mca_bml = *best_module;
94 return mca_base_framework_components_close(&ompi_bml_base_framework,
95 (mca_base_component_t*) best_component);
96 }