OpenMPI 0.1.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

base.h
1 /*
2 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3 * University Research and Technology
4 * Corporation. All rights reserved.
5 * Copyright (c) 2004-2006 The University of Tennessee and The University
6 * of Tennessee Research Foundation. All rights
7 * reserved.
8 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9 * University of Stuttgart. All rights reserved.
10 * Copyright (c) 2004-2005 The Regents of the University of California.
11 * All rights reserved.
12 * Copyright (c) 2007-2010 Cisco Systems, Inc. All rights reserved.
13 * Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
14 * $COPYRIGHT$
15 *
16 * Additional copyrights may follow
17 *
18 * $HEADER$
19 */
20
21 #ifndef OPAL_PAFFINITY_BASE_H
22 #define OPAL_PAFFINITY_BASE_H
23
24 #include "opal_config.h"
25
26 #include "opal/mca/paffinity/paffinity.h"
27
28 /*
29 * Global functions for MCA overall paffinity open and close
30 */
31
32 BEGIN_C_DECLS
33
34 /**
35 * Register MCA params for the paffinity base.
36 *
37 * @retval OPAL_SUCCESS Upon success
38 *
39 * This function is invoked by opal_register_params(). It registers
40 * some paffinity-wide MCA parameters.
41 */
42 OPAL_DECLSPEC int opal_paffinity_base_register_params(void);
43
44 /**
45 * Initialize the paffinity MCA framework
46 *
47 * @retval OPAL_SUCCESS Upon success
48 * @retval OPAL_ERROR Upon failure
49 *
50 * This must be the first function invoked in the paffinity MCA
51 * framework. It initializes the paffinity MCA framework, finds
52 * and opens paffinity components, etc.
53 *
54 * This function is invoked during opal_init().
55 *
56 * This function fills in the internal global variable
57 * opal_paffinity_base_components_opened, which is a list of all
58 * paffinity components that were successfully opened. This
59 * variable should \em only be used by other paffinity base
60 * functions -- it is not considered a public interface member --
61 * and is only mentioned here for completeness.
62 */
63 OPAL_DECLSPEC int opal_paffinity_base_open(void);
64
65 /**
66 * Select an available component.
67 *
68 * @return OPAL_SUCCESS Upon success.
69 * @return OPAL_NOT_FOUND If no component can be selected.
70 * @return OPAL_ERROR Upon other failure.
71 *
72 * This function invokes the selection process for paffinity components,
73 * which works as follows:
74 *
75 * - If the \em paffinity MCA parameter is not specified, the
76 * selection set is all available paffinity components.
77 * - If the \em paffinity MCA parameter is specified, the
78 * selection set is just that component.
79 * - All components in the selection set are queried to see if
80 * they want to run. All components that want to run are ranked
81 * by their priority and the highest priority component is
82 * selected. All non-selected components have their "close"
83 * function invoked to let them know that they were not selected.
84 * - The selected component will have its "init" function invoked to
85 * let it know that it was selected.
86 *
87 * If we fall through this entire process and no component is
88 * selected, then return OPAL_NOT_FOUND (this is not a fatal
89 * error).
90 *
91 * At the end of this process, we'll either have a single
92 * component that is selected and initialized, or no component was
93 * selected. If no component was selected, subsequent invocation
94 * of the paffinity wrapper functions will return an error.
95 */
96 OPAL_DECLSPEC int opal_paffinity_base_select(void);
97
98 /**
99 * Set this process' affinity.
100 *
101 * @param cpumask PHYSICAL processor bitmask
102 *
103 * @retval OPAL_SUCCESS upon success
104 * @retval OPAL_NOT_FOUND if no paffinity components are available.
105 * @retval OPAL_ERROR upon other error.
106 *
107 * Set this process' affinity to the PHYSICAL CPU's specified in \em cpumask
108 *
109 * If no paffinity components were available, or if the
110 * opal_paffinity_base_select() was never invoked, OPAL_NOT_FOUND
111 * is returned.
112 */
113 OPAL_DECLSPEC int opal_paffinity_base_set(opal_paffinity_base_cpu_set_t cpumask);
114
115 /**
116 * Get this process' affinity.
117 *
118 * @param cpumask Pointer to PHYSICAL processor bitmask
119 *
120 * @retval OPAL_SUCCESS upon success
121 * @retval OPAL_NOT_FOUND if no paffinity components are available.
122 * @retval OPAL_ERROR upon other error.
123 *
124 * Get this process' CPU affinity PHYSICAL bitmask and assign
125 * it to \em cpumask.
126 *
127 * If no paffinity components were available, or if the
128 * opal_paffinity_base_select() was never invoked, OPAL_NOT_FOUND
129 * is returned and cpumask is zeroed out.
130 */
131 OPAL_DECLSPEC int opal_paffinity_base_get(opal_paffinity_base_cpu_set_t *cpumask);
132
133 /**
134 * Shut down the paffinity MCA framework.
135 *
136 * @retval OPAL_SUCCESS Always
137 *
138 * This function shuts down everything in the paffinity MCA
139 * framework, and is called during opal_finalize().
140 *
141 * It must be the last function invoked on the paffinity MCA
142 * framework.
143 */
144 OPAL_DECLSPEC int opal_paffinity_base_close(void);
145
146 /**
147 * Returns mapping of PHYSICAL socket:core -> PHYSICAL processor id.
148 *
149 * @param physical_socket
150 * @param pyshical_core
151 * @param physical_processor_id
152 *
153 * @return int - OPAL_SUCCESS or OPAL_ERR_NOT_SUPPORTED if not
154 * supported
155 */
156 OPAL_DECLSPEC int opal_paffinity_base_get_map_to_processor_id(int physical_socket, int physical_core, int *physical_processor_id);
157
158 /**
159 * Provides mapping of PHYSICAL processor id -> PHYSICAL socket:core.
160 *
161 * @param physical_processor_id
162 * @param physical_socket
163 * @param physical_core
164 *
165 * @return int - OPAL_SUCCESS or OPAL_ERR_NOT_SUPPORTED if not
166 * supported
167 */
168 OPAL_DECLSPEC int opal_paffinity_base_get_map_to_socket_core(int physical_processor_id, int *physical_socket, int *physical_core);
169
170 /**
171 * Return the number of LOGICAL processors
172 *
173 * @param num_logical_processors
174 *
175 * @return int - OPAL_SUCCESS or OPAL_ERR_NOT_SUPPORTED if not
176 * supported
177 */
178 OPAL_DECLSPEC int opal_paffinity_base_get_processor_info(int *num_logical_processors);
179
180 /**
181 * Return the number of LOGICAL sockets
182 *
183 * @param num_logical_sockets
184 *
185 * @return int - OPAL_SUCCESS or OPAL_ERR_NOT_SUPPORTED if not
186 * supported
187 */
188 OPAL_DECLSPEC int opal_paffinity_base_get_socket_info(int *num_logical_sockets);
189
190 /**
191 * Return the number of LOGICAL cores for a given PHYSICAL socket
192 *
193 * @param physical_socket
194 * @param num_logical_cores
195 *
196 * @return int - OPAL_SUCCESS or OPAL_ERR_NOT_SUPPORTED if not
197 * supported
198 */
199 OPAL_DECLSPEC int opal_paffinity_base_get_core_info(int physical_socket, int *num_logical_cores);
200
201 /**
202 * Return the PHYSICAL processor id that corresponds to the
203 * given LOGICAL processor id
204 *
205 * @param logical_processor_id
206 * @param physical_processor_id
207 *
208 * @return int - OPAL_SUCCESS or OPAL_ERR_*
209 */
210 OPAL_DECLSPEC int opal_paffinity_base_get_physical_processor_id(int logical_processor_id, int *physical_processor_id);
211
212 /**
213 * Return the PHYSICAL socket ID that corresponds to the given
214 * LOGICAL socket ID.
215 *
216 * @param logical_socket_id
217 * @param physical_socket_id
218 *
219 * @return int - OPAL_SUCCESS or OPAL_ERR_*
220 */
221 OPAL_DECLSPEC int opal_paffinity_base_get_physical_socket_id(int logical_socket_id, int *physical_socket_id);
222
223 /**
224 * Return the PHYSICAL core ID that corresponds to the given LOGICAL
225 * core id on the given PHYSICAL socket ID.
226 *
227 * @param physical_socket_id
228 * @param_logical_core_id
229 * @param physical_core_id
230 *
231 * @return int - OPAL_SUCCESS or OPAL_ERR_*
232 */
233 OPAL_DECLSPEC int opal_paffinity_base_get_physical_core_id(int physical_socket_id, int logical_core_id, int *physical_core_id);
234
235 /* Print a char string representation of a cpu set */
236 OPAL_DECLSPEC char *opal_paffinity_base_print_binding(opal_paffinity_base_cpu_set_t cpumask);
237
238 /* Parse the binding string created by above function back into a cpu set */
239 OPAL_DECLSPEC int opal_paffinity_base_parse_binding(char *binding, opal_paffinity_base_cpu_set_t *cpumask);
240
241 /**
242 * Indication of whether a component was successfully selected or
243 * not
244 */
245 OPAL_DECLSPEC extern bool opal_paffinity_base_selected;
246
247 /**
248 * Global component struct for the selected component
249 */
250 OPAL_DECLSPEC extern const opal_paffinity_base_component_2_0_1_t
251 *opal_paffinity_base_component;
252 /**
253 * Global module struct for the selected module
254 */
255 OPAL_DECLSPEC extern const opal_paffinity_base_module_1_1_0_t
256 *opal_paffinity_base_module;
257 /**
258 * Indicator as to whether the list of opened paffinity components
259 * is valid or not.
260 */
261 OPAL_DECLSPEC extern bool opal_paffinity_base_components_opened_valid;
262 /**
263 * List of all opened components; created when the paffinity
264 * framework is initialized and destroyed when we reduce the list
265 * to all available paffinity components.
266 */
267 OPAL_DECLSPEC extern opal_list_t opal_paffinity_base_components_opened;
268 /**
269 * Assigning slot_list to process
270 */
271 OPAL_DECLSPEC int opal_paffinity_base_slot_list_set(long rank, char *slot_str,
272 opal_paffinity_base_cpu_set_t *cpumask);
273
274 /**
275 * Make a prettyprint string for a cset.
276 */
277 OPAL_DECLSPEC int opal_paffinity_base_cset2str(char *str, int len,
278 opal_paffinity_base_cpu_set_t *cset);
279
280 /**
281 * Make a prettyprint string for a cset with a map format.
282 */
283 OPAL_DECLSPEC int opal_paffinity_base_cset2mapstr(char *str, int len,
284 opal_paffinity_base_cpu_set_t *cset);
285
286 /**
287 * Debugging output stream
288 */
289 OPAL_DECLSPEC extern int opal_paffinity_base_output;
290
291 /**
292 * Flag indicating whether or not processor affinity is to be enabled
293 */
294 OPAL_DECLSPEC extern bool opal_paffinity_alone;
295
296 OPAL_DECLSPEC extern char *opal_paffinity_base_slot_list;
297
298 /* Indicator that process affinity has been set for this process - i.e.,
299 * that OPAL set it either directly or when launched
300 */
301 OPAL_DECLSPEC extern bool opal_paffinity_base_bound;
302
303 /* String passed down from launcher that contains applied binding */
304 OPAL_DECLSPEC extern char *opal_paffinity_base_applied_binding;
305
306 END_C_DECLS
307
308 #endif /* OPAL_BASE_PAFFINITY_H */
opal_paffinity_base_cpu_set_t
Public processor bitmask type.
Definition: paffinity.h:183
paffinity.h
paffinity (processor affinity) framework component interface definitions.
opal_list_t
Definition: opal_list.h:147
opal_paffinity_base_module_1_1_0_t
Structure for paffinity modules.
Definition: paffinity.h:367
opal_paffinity_base_component_2_0_1_t
Structure for paffinity components.
Definition: paffinity.h:351