OpenMPI  0.1.1
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) 2011 Cisco Systems, Inc. All rights reserved.
13  * $COPYRIGHT$
14  *
15  * Additional copyrights may follow
16  *
17  * $HEADER$
18  *
19  */
20 
21 #ifndef OPAL_MAFFINITY_BASE_H
22 #define OPAL_MAFFINITY_BASE_H
23 
24 #include "opal_config.h"
25 
27 
28 
29 /*
30  * Global functions for MCA overall maffinity open and close
31  */
32 
33 BEGIN_C_DECLS
34 
35 /**
36  * Initialize the maffinity MCA framework
37  *
38  * @retval OPAL_SUCCESS Upon success
39  * @retval OPAL_ERROR Upon failure
40  *
41  * This must be the first function invoked in the maffinity MCA
42  * framework. It initializes the maffinity MCA framework, finds
43  * and opens maffinity components, etc.
44  *
45  * This function fills in the internal global variable
46  * opal_maffinity_base_components_opened, which is a list of all
47  * maffinity components that were successfully opened. This
48  * variable should \em only be used by other maffinity base
49  * functions -- it is not considered a public interface member --
50  * and is only mentioned here for completeness.
51  */
52 OPAL_DECLSPEC int opal_maffinity_base_open(void);
53 
54 /**
55  * Select an available component.
56  *
57  * @return OPAL_SUCCESS Upon success.
58  * @return OPAL_NOT_FOUND If no component can be selected.
59  * @return OPAL_ERROR Upon other failure.
60  *
61  * This function invokes the selection process for maffinity
62  * components, which works as follows:
63  *
64  * - If the \em maffinity MCA parameter is not specified, the
65  * selection set is all available maffinity components.
66  * - If the \em maffinity MCA parameter is specified, the
67  * selection set is just that component.
68  * - All components in the selection set are queried to see if
69  * they want to run. All components that want to run are ranked
70  * by their priority and the highest priority component is
71  * selected. All non-selected components have their "close"
72  * function invoked to let them know that they were not selected.
73  * - The selected component will have its "init" function invoked to
74  * let it know that it was selected.
75  *
76  * If we fall through this entire process and no component is
77  * selected, then return OPAL_NOT_FOUND (this is not a fatal
78  * error).
79  *
80  * At the end of this process, we'll either have a single
81  * component that is selected and initialized, or no component was
82  * selected. If no component was selected, subsequent invocation
83  * of the maffinity wrapper functions will return an error.
84  */
85 OPAL_DECLSPEC int opal_maffinity_base_select(void);
86 
87 /**
88  * Set memory affinity.
89  *
90  * @param segments Array describing segments and what process they
91  * belong to
92  * @param num_segments Length of the segments array
93  * @param am_allocator True if this process created the shared
94  * memory block
95  *
96  * @retval OPAL_SUCCESS upon success
97  * @retval OPAL_NOT_FOUND if no maffinity components are available.
98  * @retval OPAL_ERROR upon other error.
99  *
100  * Set the affinity of the memory segments described in the \em
101  * segments array.
102  *
103  * If no maffinity components were available, or if the
104  * opal_maffinity_base_select() was never invoked, OPAL_NOT_FOUND
105  * is returned.
106  */
107 OPAL_DECLSPEC int opal_maffinity_base_set(opal_maffinity_base_segment_t *segments, size_t num_segments);
108 
109 OPAL_DECLSPEC int opal_maffinity_base_node_name_to_id(char *, int *);
110 OPAL_DECLSPEC int opal_maffinity_base_bind(opal_maffinity_base_segment_t *, size_t, int);
111 
112 /**
113  * Shut down the maffinity MCA framework.
114  *
115  * @retval OPAL_SUCCESS Always
116  *
117  * This function shuts down everything in the maffinity MCA
118  * framework.
119  *
120  * It must be the last function invoked on the maffinity MCA
121  * framework.
122  */
123 OPAL_DECLSPEC int opal_maffinity_base_close(void);
124 
125 /**
126  * Indication of whether a component was successfully selected or
127  * not
128  */
129 extern bool opal_maffinity_base_selected;
130 
131 /**
132  * Global component struct for the selected component
133  */
134 OPAL_DECLSPEC extern const opal_maffinity_base_component_2_0_0_t
135 *opal_maffinity_base_component;
136 /**
137  * Global module struct for the selected module
138  */
139 OPAL_DECLSPEC extern const opal_maffinity_base_module_1_0_0_t
140 *opal_maffinity_base_module;
141 
142 /**
143  * Indicator as to whether the list of opened maffinity components
144  * is valid or not.
145  */
146 extern bool opal_maffinity_base_components_opened_valid;
147 /**
148  * List of all opened components; created when the maffinity
149  * framework is initialized and destroyed when we reduce the list
150  * to all available maffinity components.
151  */
152 OPAL_DECLSPEC extern opal_list_t opal_maffinity_base_components_opened;
153 
154 /**
155  * Debugging output stream
156  */
157 extern int opal_maffinity_base_output;
158 
159 /**
160  * Flag to indicate whether or not maffinity was setup
161  */
162 OPAL_DECLSPEC extern bool opal_maffinity_setup;
163 
164 END_C_DECLS
165 
166 #endif /* OPAL_MAFFINITY_BASE_H */
Structure for maffinity components.
Definition: maffinity.h:100
maffinity (memory affinity) framework component interface definitions.
Definition: opal_list.h:147
Struct used with opal_maffinity_base_module_set_fn_t.
Definition: maffinity_types.h:46
Structure for maffinity modules.
Definition: maffinity.h:115