94 #ifndef OPAL_PAFFINITY_H
95 #define OPAL_PAFFINITY_H
97 #include "opal_config.h"
104 #include "opal/mca/base/base.h"
107 typedef uint16_t opal_paffinity_locality_t;
110 #define OPAL_PROC_LOCALITY_UNKNOWN 0x0000
111 #define OPAL_PROC_NON_LOCAL 0x8000
112 #define OPAL_PROC_ON_CLUSTER 0x0400
113 #define OPAL_PROC_ON_CU 0x0200
114 #define OPAL_PROC_ON_NODE 0x0100
115 #define OPAL_PROC_ON_BOARD 0x0080
116 #define OPAL_PROC_ON_NUMA 0x0040
117 #define OPAL_PROC_ON_SOCKET 0x0020
118 #define OPAL_PROC_ON_L3CACHE 0x0010
119 #define OPAL_PROC_ON_L2CACHE 0x0008
120 #define OPAL_PROC_ON_L1CACHE 0x0004
121 #define OPAL_PROC_ON_CORE 0x0002
122 #define OPAL_PROC_ON_HWTHREAD 0x0001
123 #define OPAL_PROC_ALL_LOCAL 0x0fff
126 #define OPAL_PROC_ON_LOCAL_HWTHREAD(n) ((n) & OPAL_PROC_ON_HWTHREAD)
127 #define OPAL_PROC_ON_LOCAL_CORE(n) ((n) & OPAL_PROC_ON_CORE)
128 #define OPAL_PROC_ON_LOCAL_L1CACHE(n) ((n) & OPAL_PROC_ON_L1CACHE)
129 #define OPAL_PROC_ON_LOCAL_L2CACHE(n) ((n) & OPAL_PROC_ON_L2CACHE)
130 #define OPAL_PROC_ON_LOCAL_L3CACHE(n) ((n) & OPAL_PROC_ON_L3CACHE)
131 #define OPAL_PROC_ON_LOCAL_SOCKET(n) ((n) & OPAL_PROC_ON_SOCKET)
132 #define OPAL_PROC_ON_LOCAL_NUMA(n) ((n) & OPAL_PROC_ON_NUMA)
133 #define OPAL_PROC_ON_LOCAL_BOARD(n) ((n) & OPAL_PROC_ON_BOARD)
134 #define OPAL_PROC_ON_LOCAL_NODE(n) ((n) & OPAL_PROC_ON_NODE)
135 #define OPAL_PROC_ON_LOCAL_CU(n) ((n) & OPAL_PROC_ON_CU)
136 #define OPAL_PROC_ON_LOCAL_CLUSTER(n) ((n) & OPAL_PROC_ON_CLUSTER)
139 #define OPAL_PAFFINITY_DO_NOT_BIND 0x01
140 #define OPAL_PAFFINITY_BIND_TO_CORE 0x02
141 #define OPAL_PAFFINITY_BIND_TO_SOCKET 0x04
142 #define OPAL_PAFFINITY_BIND_TO_BOARD 0x08
143 #define OPAL_PAFFINITY_BIND_IF_SUPPORTED 0x80
162 #define OPAL_PAFFINITY_BITMASK_T_NUM_BITS (sizeof(opal_paffinity_base_bitmask_t) * 8)
167 #define OPAL_PAFFINITY_BITMASK_CPU_MAX 1024
172 #define OPAL_PAFFINITY_BITMASK_NUM_ELEMENTS (OPAL_PAFFINITY_BITMASK_CPU_MAX / OPAL_PAFFINITY_BITMASK_T_NUM_BITS)
178 #define OPAL_PAFFINITY_CPU_SET_NUM_BYTES (OPAL_PAFFINITY_BITMASK_NUM_ELEMENTS * sizeof(opal_paffinity_base_bitmask_t))
193 #define OPAL_PAFFINITY_CPU_BYTE(num) ((num) / OPAL_PAFFINITY_BITMASK_T_NUM_BITS)
199 #define OPAL_PAFFINITY_CPU_BIT(num) ((num) % OPAL_PAFFINITY_BITMASK_T_NUM_BITS)
206 #define OPAL_PAFFINITY_CPU_ZERO(cpuset) \
207 memset(&(cpuset), 0, sizeof(opal_paffinity_base_cpu_set_t))
212 #define OPAL_PAFFINITY_CPU_SET(num, cpuset) \
213 (cpuset).bitmask[OPAL_PAFFINITY_CPU_BYTE(num)] |= ((opal_paffinity_base_bitmask_t) 1 << OPAL_PAFFINITY_CPU_BIT(num))
218 #define OPAL_PAFFINITY_CPU_CLR(num, cpuset) \
219 (cpuset).bitmask[OPAL_PAFFINITY_CPU_BYTE(num)] &= ~((opal_paffinity_base_bitmask_t) 1 << OPAL_PAFFINITY_CPU_BIT(num))
224 #define OPAL_PAFFINITY_CPU_ISSET(num, cpuset) \
225 (0 != (((cpuset).bitmask[OPAL_PAFFINITY_CPU_BYTE(num)]) & ((opal_paffinity_base_bitmask_t) 1 << OPAL_PAFFINITY_CPU_BIT(num))))
230 #define OPAL_PAFFINITY_PROCESS_IS_BOUND(cpuset, bound) \
232 int i, num_processors, num_bound; \
234 if (OPAL_SUCCESS == \
235 opal_paffinity_base_get_processor_info(&num_processors)) { \
237 for (i = 0; i < OPAL_PAFFINITY_BITMASK_CPU_MAX; i++) { \
238 if (OPAL_PAFFINITY_CPU_ISSET(i, (cpuset))) { \
242 if (0 < num_bound && (1 == num_processors || \
243 num_bound < num_processors)) { \
280 int *physical_processor_id);
289 int *physical_socket,
414 #define OPAL_PAFFINITY_BASE_VERSION_2_0_1 \
415 MCA_BASE_VERSION_2_0_0, \
opal_paffinity_base_module_get_map_to_socket_core_fn_t paff_get_map_to_socket_core
Map processor ID to socket:core.
Definition: paffinity.h:381
Common type for all MCA components.
Definition: mca.h:250
opal_paffinity_base_module_get_processor_info_fn_t paff_get_processor_info
Return the max processor ID.
Definition: paffinity.h:384
Public processor bitmask type.
Definition: paffinity.h:183
opal_paffinity_base_module_finalize_fn_t paff_module_finalize
Shut down this module.
Definition: paffinity.h:402
int(* opal_paffinity_base_module_get_processor_info_fn_t)(int *num_processors)
Provides number of LOGICAL processors in a host.
Definition: paffinity.h:298
opal_paffinity_base_module_get_fn_t paff_module_get
Get this process' affinity.
Definition: paffinity.h:375
int(* opal_paffinity_base_module_finalize_fn_t)(void)
Module finalize function.
Definition: paffinity.h:345
int(* opal_paffinity_base_module_get_physical_core_id_fn_t)(int physical_socket_id, int logical_core_id, int *physical_core_id)
Provide the PHYSICAL core ID that corresponds to the given LOGICAL core ID on the given PHYSICAL sock...
Definition: paffinity.h:338
mca_base_component_data_t base_data
MCA base data.
Definition: paffinity.h:355
int(* opal_paffinity_base_module_get_physical_processor_id_fn_t)(int logical_processor_id, int *physical_processor_id)
Provide the PHYSICAL processor ID that corresponds to the given LOGICAL processor ID...
Definition: paffinity.h:322
Top-level interface for all MCA components.
int(* opal_paffinity_base_module_get_physical_socket_id_fn_t)(int logical_socket_id, int *physical_socket_id)
Provide the PHYSICAL socket ID that corresponds to the given LOGICAL socket ID.
Definition: paffinity.h:330
int(* opal_paffinity_base_module_get_map_to_socket_core_fn_t)(int physical_processor_id, int *physical_socket, int *physical_core)
Provides mapping of PHYSICAL processor id -> PHYSICAL socket:core.
Definition: paffinity.h:288
opal_paffinity_base_module_init_1_1_0_fn_t paff_module_init
Module initialization function.
Definition: paffinity.h:369
Meta data for MCA v2.0.0 components.
Definition: mca.h:309
opal_paffinity_base_module_get_socket_info_fn_t paff_get_socket_info
Return the max socket number.
Definition: paffinity.h:387
int(* opal_paffinity_base_module_init_1_1_0_fn_t)(void)
Module initialization function.
Definition: paffinity.h:254
int(* opal_paffinity_base_module_get_socket_info_fn_t)(int *num_sockets)
Provides the number of LOGICAL sockets in a host.
Definition: paffinity.h:306
opal_paffinity_base_module_get_map_to_processor_id_fn_t paff_get_map_to_processor_id
Map socket:core to processor ID.
Definition: paffinity.h:378
opal_paffinity_base_module_set_fn_t paff_module_set
Set this process' affinity.
Definition: paffinity.h:372
mca_base_component_t base_version
MCA base component.
Definition: paffinity.h:353
int(* opal_paffinity_base_module_set_fn_t)(opal_paffinity_base_cpu_set_t cpumask)
Module function to set this process' affinity to a specific set of PHYSICAL CPUs. ...
Definition: paffinity.h:260
unsigned long int opal_paffinity_base_bitmask_t
Buffer type for paffinity processor masks.
Definition: paffinity.h:156
opal_paffinity_base_module_get_core_info_fn_t paff_get_core_info
Return the max core number.
Definition: paffinity.h:390
Structure for paffinity modules.
Definition: paffinity.h:367
struct opal_paffinity_base_cpu_set_t opal_paffinity_base_cpu_set_t
Public processor bitmask type.
int(* opal_paffinity_base_module_get_map_to_processor_id_fn_t)(int physical_socket, int physical_core, int *physical_processor_id)
Returns mapping of PHYSICAL socket:core -> PHYSICAL processor id.
Definition: paffinity.h:278
Structure for paffinity components.
Definition: paffinity.h:351
int(* opal_paffinity_base_module_get_fn_t)(opal_paffinity_base_cpu_set_t *cpumask)
Module function to get this process' affinity to a specific set of PHYSICAL CPUs. ...
Definition: paffinity.h:270
int(* opal_paffinity_base_module_get_core_info_fn_t)(int physical_socket, int *num_cores)
Provides the number of LOGICAL cores in a PHYSICAL socket.
Definition: paffinity.h:314