This source file includes following definitions.
- mca_sshmem_base_runtime_query
- mca_sshmem_base_select
1
2
3
4
5
6
7
8
9
10
11 #include "oshmem_config.h"
12
13 #include <string.h>
14
15 #include "opal/constants.h"
16 #include "opal/util/output.h"
17 #include "oshmem/mca/mca.h"
18 #include "opal/mca/base/base.h"
19
20 #include "oshmem/mca/sshmem/sshmem.h"
21 #include "oshmem/mca/sshmem/base/base.h"
22
23
24
25
26 bool mca_sshmem_base_selected = false;
27 const mca_sshmem_base_component_2_0_0_t *mca_sshmem_base_component = NULL;
28 const mca_sshmem_base_module_2_0_0_t *mca_sshmem_base_module = NULL;
29
30
31 static int
32 mca_sshmem_base_runtime_query(mca_base_module_t **best_module,
33 mca_base_component_t **best_component)
34 {
35 mca_base_component_list_item_t *cli = NULL;
36 mca_base_component_t *component = NULL;
37 mca_base_module_t *module = NULL;
38 int priority = 0, best_priority = INT32_MIN;
39
40 *best_module = NULL;
41 *best_component = NULL;
42
43 opal_output_verbose(10, oshmem_sshmem_base_framework.framework_output,
44 "sshmem: base: runtime_query: "
45 "Auto-selecting sshmem components");
46
47
48
49
50
51 OPAL_LIST_FOREACH(cli, &oshmem_sshmem_base_framework.framework_components, mca_base_component_list_item_t) {
52 component = (mca_base_component_t *)cli->cli_component;
53
54
55
56
57 if (NULL == ((mca_sshmem_base_component_2_0_0_t *)
58 component)->runtime_query) {
59 opal_output_verbose(5, oshmem_sshmem_base_framework.framework_output,
60 "sshmem: base: runtime_query: "
61 "(sshmem) Skipping component [%s]. It does not "
62 "implement a run-time query function",
63 component->mca_component_name);
64 continue;
65 }
66
67
68 opal_output_verbose(5, oshmem_sshmem_base_framework.framework_output,
69 "sshmem: base: runtime_query: "
70 "(shmem) Querying component (run-time) [%s]",
71 component->mca_component_name);
72
73 ((mca_sshmem_base_component_2_0_0_t *)
74 component)->runtime_query(&module, &priority, NULL);
75
76
77
78
79
80 if (NULL == module) {
81 opal_output_verbose(5, oshmem_sshmem_base_framework.framework_output,
82 "sshmem: base: runtime_query: "
83 "(sshmem) Skipping component [%s]. Run-time "
84 "Query failed to return a module",
85 component->mca_component_name);
86 continue;
87 }
88
89
90
91
92 opal_output_verbose(5, oshmem_sshmem_base_framework.framework_output,
93 "sshmem: base: runtime_query: "
94 "(%5s) Query of component [%s] set priority to %d",
95 "shmem", component->mca_component_name, priority);
96 if (priority > best_priority) {
97 best_priority = priority;
98 *best_module = module;
99 *best_component = component;
100 }
101 }
102
103
104
105
106 if (NULL == *best_component) {
107 opal_output_verbose(5, oshmem_sshmem_base_framework.framework_output,
108 "sshmem: base: runtime_query: "
109 "(%5s) No component selected!", "shmem");
110 return OSHMEM_ERR_NOT_FOUND;
111 }
112
113 opal_output_verbose(5, oshmem_sshmem_base_framework.framework_output,
114 "sshmem: base: runtime_query: "
115 "(%5s) Selected component [%s]", "shmem",
116 (*best_component)->mca_component_name);
117
118
119 (void) mca_base_framework_components_close (&oshmem_sshmem_base_framework,
120 (mca_base_component_t *)(*best_component));
121
122 return OSHMEM_SUCCESS;
123 }
124
125
126 int
127 mca_sshmem_base_select(void)
128 {
129 mca_sshmem_base_component_2_0_0_t *best_component = NULL;
130 mca_sshmem_base_module_2_0_0_t *best_module = NULL;
131
132 if (OSHMEM_SUCCESS != mca_sshmem_base_runtime_query(
133 (mca_base_module_t **)&best_module,
134 (mca_base_component_t **)&best_component)) {
135
136
137
138 return OSHMEM_ERROR;
139 }
140
141
142 mca_sshmem_base_component = best_component;
143 mca_sshmem_base_module = best_module;
144 mca_sshmem_base_selected = true;
145
146
147 if (NULL != mca_sshmem_base_module) {
148 return mca_sshmem_base_module->module_init();
149 }
150 else {
151 return OSHMEM_ERROR;
152 }
153 }
154