OpenMPI  0.1.1
hwloc.h
1 /*
2  * Copyright (c) 2011 Cisco Systems, Inc. All rights reserved.
3  *
4  * $COPYRIGHT$
5  *
6  * Additional copyrights may follow
7  */
8 
9 #ifndef OPAL_MCA_HWLOC_H
10 #define OPAL_MCA_HWLOC_H
11 
12 #include "opal_config.h"
13 
14 #ifdef HAVE_SYS_TYPES_H
15 #include <sys/types.h>
16 #endif
17 #ifdef HAVE_SYS_TIME_H
18 #include <sys/time.h>
19 #endif
20 #ifdef HAVE_STDINT_H
21 #include <stdint.h>
22 #endif
23 #ifdef HAVE_STDARG_H
24 #include <stdarg.h>
25 #endif
26 
27 #include "opal/class/opal_list.h"
28 #include "opal/class/opal_value_array.h"
29 
30 #include "opal/mca/mca.h"
31 #include "opal/mca/base/base.h"
32 
33 BEGIN_C_DECLS
34 
35 #ifdef WIN32
36 #define WIN32_LEAN_AND_MEAN
37 #include <windows.h>
38 #undef WIN32_LEAN_AND_MEAN
39 typedef unsigned char u_char;
40 typedef unsigned short u_short;
41 #endif
42 
43 /**
44  * Structure for hwloc components.
45  */
47  /** MCA base component */
49  /** MCA base data */
51 };
52 
53 /**
54  * Convenience typedef
55  */
58 
59 /**
60  * Macro for use in components that are of type hwloc
61  */
62 #define OPAL_HWLOC_BASE_VERSION_2_0_0 \
63  MCA_BASE_VERSION_2_0_0, \
64  "hwloc", 2, 0, 0
65 
66 END_C_DECLS
67 
68 /* Define a hierarchical level value that
69  * helps resolve the hwloc behavior of
70  * treating caches as a single type of
71  * entity - must always be available
72  */
73 typedef enum {
74  OPAL_HWLOC_NODE_LEVEL=0,
75  OPAL_HWLOC_NUMA_LEVEL,
76  OPAL_HWLOC_SOCKET_LEVEL,
77  OPAL_HWLOC_L3CACHE_LEVEL,
78  OPAL_HWLOC_L2CACHE_LEVEL,
79  OPAL_HWLOC_L1CACHE_LEVEL,
80  OPAL_HWLOC_CORE_LEVEL,
81  OPAL_HWLOC_HWTHREAD_LEVEL
82 } opal_hwloc_level_t;
83 #define OPAL_HWLOC_LEVEL_T OPAL_INT
84 
85 /* include implementation to call */
86 #if OPAL_HAVE_HWLOC
87 #include MCA_hwloc_IMPLEMENTATION_HEADER
88 
89 
90 /* define type of processor info requested */
91 typedef uint8_t opal_hwloc_resource_type_t;
92 #define OPAL_HWLOC_PHYSICAL 1
93 #define OPAL_HWLOC_LOGICAL 2
94 #define OPAL_HWLOC_AVAILABLE 3
95 
96 /* structs for storing info on objects */
97 typedef struct {
98  opal_object_t super;
99  hwloc_cpuset_t available;
100  unsigned int npus;
101  unsigned int idx;
102 } opal_hwloc_obj_data_t;
103 OBJ_CLASS_DECLARATION(opal_hwloc_obj_data_t);
104 
105 typedef struct {
106  opal_list_item_t super;
107  hwloc_obj_type_t type;
108  unsigned cache_level;
109  unsigned int num_objs;
110  opal_hwloc_resource_type_t rtype;
111 } opal_hwloc_summary_t;
112 OBJ_CLASS_DECLARATION(opal_hwloc_summary_t);
113 
114 typedef struct {
115  opal_object_t super;
116  hwloc_cpuset_t available;
117  opal_list_t summaries;
118 } opal_hwloc_topo_data_t;
119 OBJ_CLASS_DECLARATION(opal_hwloc_topo_data_t);
120 
121 /* define binding policies */
122 typedef uint16_t opal_binding_policy_t;
123 #define OPAL_BINDING_POLICY OPAL_UINT16
124 
125 /* binding directives */
126 #define OPAL_BIND_IF_SUPPORTED 0x1000
127 #define OPAL_BIND_ALLOW_OVERLOAD 0x2000
128 #define OPAL_BIND_GIVEN 0x4000
129 /* binding policies */
130 #define OPAL_BIND_TO_NONE 1
131 #define OPAL_BIND_TO_BOARD 2
132 #define OPAL_BIND_TO_NUMA 3
133 #define OPAL_BIND_TO_SOCKET 4
134 #define OPAL_BIND_TO_L3CACHE 5
135 #define OPAL_BIND_TO_L2CACHE 6
136 #define OPAL_BIND_TO_L1CACHE 7
137 #define OPAL_BIND_TO_CORE 8
138 #define OPAL_BIND_TO_HWTHREAD 9
139 #define OPAL_BIND_TO_CPUSET 10
140 #define OPAL_GET_BINDING_POLICY(pol) \
141  ((pol) & 0x0fff)
142 #define OPAL_SET_BINDING_POLICY(target, pol) \
143  (target) = (pol) | ((target) & 0xf000)
144 /* check if policy is set */
145 #define OPAL_BINDING_POLICY_IS_SET(pol) \
146  ((pol) & 0x4000)
147 /* macro to detect if binding was qualified */
148 #define OPAL_BINDING_REQUIRED(n) \
149  (!(OPAL_BIND_IF_SUPPORTED & (n)))
150 /* macro to detect if binding is forced */
151 #define OPAL_BIND_OVERLOAD_ALLOWED(n) \
152  (OPAL_BIND_ALLOW_OVERLOAD & (n))
153 
154 /* some global values */
155 OPAL_DECLSPEC extern hwloc_topology_t opal_hwloc_topology;
156 OPAL_DECLSPEC extern opal_binding_policy_t opal_hwloc_binding_policy;
157 OPAL_DECLSPEC extern hwloc_cpuset_t opal_hwloc_my_cpuset;
158 OPAL_DECLSPEC extern bool opal_hwloc_report_bindings;
159 OPAL_DECLSPEC extern hwloc_obj_type_t opal_hwloc_levels[];
160 OPAL_DECLSPEC extern bool opal_hwloc_use_hwthreads_as_cpus;
161 
162 #endif
163 
164 #endif /* OPAL_HWLOC_H_ */
mca_base_component_data_t base_data
MCA base data.
Definition: hwloc.h:50
Common type for all MCA components.
Definition: mca.h:250
mca_base_component_t base_version
MCA base component.
Definition: hwloc.h:48
The opal_list_t interface is used to provide a generic doubly-linked list container for Open MPI...
Top-level interface for all MCA components.
Definition: opal_list.h:98
Structure for hwloc components.
Definition: hwloc.h:46
Base object.
Definition: opal_object.h:182
Meta data for MCA v2.0.0 components.
Definition: mca.h:309
Definition: opal_list.h:147
hwloc_obj_type_t
Type of topology object.
Definition: hwloc.h:164
Definition: private.h:56
Definition: cpuset.c:38
#define OBJ_CLASS_DECLARATION(NAME)
Declaration for class descriptor.
Definition: opal_object.h:236