This source file includes following definitions.
- posix_register
- posix_open
- posix_runtime_query
- posix_query
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 #include "opal_config.h"
32
33
34 #include <errno.h>
35 #include <string.h>
36 #ifdef HAVE_SYS_MMAN_H
37 #include <sys/mman.h>
38 #endif
39 #ifdef HAVE_UNISTD_H
40 #include <unistd.h>
41 #endif
42 #ifdef HAVE_NETDB_H
43 #include <netdb.h>
44 #endif
45
46 #include "opal/constants.h"
47 #include "opal/util/show_help.h"
48 #include "opal/util/output.h"
49 #include "opal/mca/shmem/base/base.h"
50 #include "opal/mca/shmem/shmem.h"
51 #include "shmem_posix.h"
52 #include "shmem_posix_common_utils.h"
53
54
55 const char *opal_shmem_posix_component_version_string =
56 "OPAL posix shmem MCA component version " OPAL_VERSION;
57
58
59 static int posix_register (void);
60 static int posix_open(void);
61 static int posix_query(mca_base_module_t **module, int *priority);
62 static int posix_runtime_query(mca_base_module_t **module,
63 int *priority,
64 const char *hint);
65
66
67 static bool rt_successful = false;
68
69
70
71
72 opal_shmem_posix_component_t mca_shmem_posix_component = {
73 .super = {
74 .base_version = {
75 OPAL_SHMEM_BASE_VERSION_2_0_0,
76
77
78 .mca_component_name = "posix",
79 MCA_BASE_MAKE_VERSION(component, OPAL_MAJOR_VERSION, OPAL_MINOR_VERSION,
80 OPAL_RELEASE_VERSION),
81
82 .mca_open_component = posix_open,
83 .mca_query_component = posix_query,
84 .mca_register_component_params = posix_register
85 },
86
87 .base_data = {
88
89 MCA_BASE_METADATA_PARAM_CHECKPOINT
90 },
91 .runtime_query = posix_runtime_query,
92 },
93 };
94
95
96
97 static int
98 posix_register(void)
99 {
100
101
102 mca_shmem_posix_component.priority = 40;
103 (void) mca_base_component_var_register(&mca_shmem_posix_component.super.base_version,
104 "priority", "Priority for the shmem posix "
105 "component (default: 40)", MCA_BASE_VAR_TYPE_INT,
106 NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE,
107 OPAL_INFO_LVL_3,
108 MCA_BASE_VAR_SCOPE_ALL_EQ,
109 &mca_shmem_posix_component.priority);
110
111 return OPAL_SUCCESS;
112 }
113
114
115
116 static int
117 posix_open(void)
118 {
119 return OPAL_SUCCESS;
120 }
121
122
123
124
125
126
127
128
129
130 static int
131 posix_runtime_query(mca_base_module_t **module,
132 int *priority,
133 const char *hint)
134 {
135 char tmp_buff[OPAL_SHMEM_POSIX_FILE_LEN_MAX];
136 int fd = -1;
137
138 *priority = 0;
139 *module = NULL;
140
141
142
143
144
145 if (NULL != hint) {
146 OPAL_OUTPUT_VERBOSE(
147 (70, opal_shmem_base_framework.framework_output,
148 "shmem: posix: runtime_query: "
149 "attempting to use runtime hint (%s)\n", hint)
150 );
151
152
153
154 if (0 == strcasecmp(hint,
155 mca_shmem_posix_component.super.base_version.mca_component_name)) {
156 *priority = mca_shmem_posix_component.priority;
157 *module = (mca_base_module_t *)&opal_shmem_posix_module.super;
158 return OPAL_SUCCESS;
159 }
160 else {
161 *priority = 0;
162 *module = NULL;
163 return OPAL_SUCCESS;
164 }
165 }
166
167
168
169
170 OPAL_OUTPUT_VERBOSE(
171 (70, opal_shmem_base_framework.framework_output,
172 "shmem: posix: runtime_query: NO HINT PROVIDED:"
173 "starting run-time test...\n")
174 );
175
176 if (-1 != (fd = shmem_posix_shm_open(tmp_buff,
177 OPAL_SHMEM_POSIX_FILE_LEN_MAX -1))) {
178
179 if (0 != shm_unlink(tmp_buff)) {
180 int err = errno;
181 char hn[OPAL_MAXHOSTNAMELEN];
182 gethostname(hn, sizeof(hn));
183 opal_show_help("help-opal-shmem-posix.txt", "sys call fail", 1,
184 hn, "shm_unlink(2)", "", strerror(err), err);
185
186
187 }
188
189 else {
190 *priority = mca_shmem_posix_component.priority;
191 *module = (mca_base_module_t *)&opal_shmem_posix_module.super;
192 rt_successful = true;
193 }
194 }
195
196 return OPAL_SUCCESS;
197 }
198
199
200 static int
201 posix_query(mca_base_module_t **module, int *priority)
202 {
203 *priority = mca_shmem_posix_component.priority;
204 *module = (mca_base_module_t *)&opal_shmem_posix_module.super;
205 return OPAL_SUCCESS;
206 }
207