20#if KMP_AFFINITY_SUPPORTED
22class KMPHwlocAffinity :
public KMPAffinity {
24 class Mask :
public KMPAffinity::Mask {
29 mask = hwloc_bitmap_alloc();
32 Mask(
const Mask &other) =
delete;
33 Mask &operator=(
const Mask &other) =
delete;
34 ~Mask() { hwloc_bitmap_free(
mask); }
35 void set(
int i)
override { hwloc_bitmap_set(
mask,
i); }
36 bool is_set(
int i)
const override {
return hwloc_bitmap_isset(
mask,
i); }
37 void clear(
int i)
override { hwloc_bitmap_clr(
mask,
i); }
38 void zero()
override { hwloc_bitmap_zero(
mask); }
39 bool empty()
const override {
return hwloc_bitmap_iszero(
mask); }
40 void copy(
const KMPAffinity::Mask *src)
override {
41 const Mask *convert =
static_cast<const Mask *
>(src);
42 hwloc_bitmap_copy(
mask, convert->mask);
44 void bitwise_and(
const KMPAffinity::Mask *rhs)
override {
45 const Mask *convert =
static_cast<const Mask *
>(rhs);
46 hwloc_bitmap_and(
mask,
mask, convert->mask);
48 void bitwise_or(
const KMPAffinity::Mask *rhs)
override {
49 const Mask *convert =
static_cast<const Mask *
>(rhs);
50 hwloc_bitmap_or(
mask,
mask, convert->mask);
52 void bitwise_not()
override { hwloc_bitmap_not(
mask,
mask); }
53 bool is_equal(
const KMPAffinity::Mask *rhs)
const override {
54 const Mask *convert =
static_cast<const Mask *
>(rhs);
55 return hwloc_bitmap_isequal(
mask, convert->mask);
57 int begin()
const override {
return hwloc_bitmap_first(
mask); }
58 int end()
const override {
return -1; }
59 int next(
int previous)
const override {
60 return hwloc_bitmap_next(
mask, previous);
62 int get_system_affinity(
bool abort_on_error)
override {
64 "Illegal get affinity operation when not capable");
66 hwloc_get_cpubind(__kmp_hwloc_topology,
mask, HWLOC_CPUBIND_THREAD);
77 int set_system_affinity(
bool abort_on_error)
const override {
79 "Illegal set affinity operation when not capable");
81 hwloc_set_cpubind(__kmp_hwloc_topology,
mask, HWLOC_CPUBIND_THREAD);
93 int set_process_affinity(
bool abort_on_error)
const override {
95 "Illegal set process affinity operation when not capable");
97 const hwloc_topology_support *support =
98 hwloc_topology_get_support(__kmp_hwloc_topology);
99 if (support->cpubind->set_proc_cpubind) {
101 retval = hwloc_set_cpubind(__kmp_hwloc_topology,
mask,
102 HWLOC_CPUBIND_PROCESS);
113 int get_proc_group()
const override {
116 if (__kmp_num_proc_groups == 1) {
119 for (
int i = 0;
i < __kmp_num_proc_groups;
i++) {
121 unsigned long first_32_bits = hwloc_bitmap_to_ith_ulong(
mask,
i * 2);
122 unsigned long second_32_bits =
123 hwloc_bitmap_to_ith_ulong(
mask,
i * 2 + 1);
124 if (first_32_bits == 0 && second_32_bits == 0) {
136 void determine_capable(
const char *var)
override {
137 const hwloc_topology_support *topology_support;
138 if (__kmp_hwloc_topology == NULL) {
139 if (hwloc_topology_init(&__kmp_hwloc_topology) < 0) {
140 __kmp_hwloc_error =
TRUE;
141 if (__kmp_affinity.flags.verbose) {
142 KMP_WARNING(AffHwlocErrorOccurred, var,
"hwloc_topology_init()");
145 if (hwloc_topology_load(__kmp_hwloc_topology) < 0) {
146 __kmp_hwloc_error =
TRUE;
147 if (__kmp_affinity.flags.verbose) {
148 KMP_WARNING(AffHwlocErrorOccurred, var,
"hwloc_topology_load()");
152 topology_support = hwloc_topology_get_support(__kmp_hwloc_topology);
157 if (topology_support && topology_support->cpubind->set_thisthread_cpubind &&
158 topology_support->cpubind->get_thisthread_cpubind &&
159 topology_support->discovery->pu && !__kmp_hwloc_error) {
161 KMP_AFFINITY_ENABLE(
TRUE);
164 __kmp_hwloc_error =
TRUE;
165 KMP_AFFINITY_DISABLE();
168 void bind_thread(
int which)
override {
170 "Illegal set affinity operation when not capable");
171 KMPAffinity::Mask *
mask;
172 KMP_CPU_ALLOC_ON_STACK(
mask);
174 KMP_CPU_SET(which,
mask);
175 __kmp_set_system_affinity(
mask,
TRUE);
176 KMP_CPU_FREE_FROM_STACK(
mask);
178 KMPAffinity::Mask *allocate_mask()
override {
return new Mask(); }
179 void deallocate_mask(KMPAffinity::Mask *m)
override {
delete m; }
180 KMPAffinity::Mask *allocate_mask_array(
int num)
override {
181 return new Mask[num];
183 void deallocate_mask_array(KMPAffinity::Mask *array)
override {
184 Mask *hwloc_array =
static_cast<Mask *
>(array);
185 delete[] hwloc_array;
187 KMPAffinity::Mask *index_mask_array(KMPAffinity::Mask *array,
188 int index)
override {
189 Mask *hwloc_array =
static_cast<Mask *
>(array);
190 return &(hwloc_array[index]);
192 api_type get_api_type()
const override {
return HWLOC; }
196#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_DRAGONFLY || \
203#include <sys/syscall.h>
204#if KMP_ARCH_X86 || KMP_ARCH_ARM
205#ifndef __NR_sched_setaffinity
206#define __NR_sched_setaffinity 241
207#elif __NR_sched_setaffinity != 241
208#error Wrong code for setaffinity system call.
210#ifndef __NR_sched_getaffinity
211#define __NR_sched_getaffinity 242
212#elif __NR_sched_getaffinity != 242
213#error Wrong code for getaffinity system call.
215#elif KMP_ARCH_AARCH64
216#ifndef __NR_sched_setaffinity
217#define __NR_sched_setaffinity 122
218#elif __NR_sched_setaffinity != 122
219#error Wrong code for setaffinity system call.
221#ifndef __NR_sched_getaffinity
222#define __NR_sched_getaffinity 123
223#elif __NR_sched_getaffinity != 123
224#error Wrong code for getaffinity system call.
227#ifndef __NR_sched_setaffinity
228#define __NR_sched_setaffinity 203
229#elif __NR_sched_setaffinity != 203
230#error Wrong code for setaffinity system call.
232#ifndef __NR_sched_getaffinity
233#define __NR_sched_getaffinity 204
234#elif __NR_sched_getaffinity != 204
235#error Wrong code for getaffinity system call.
238#ifndef __NR_sched_setaffinity
239#define __NR_sched_setaffinity 222
240#elif __NR_sched_setaffinity != 222
241#error Wrong code for setaffinity system call.
243#ifndef __NR_sched_getaffinity
244#define __NR_sched_getaffinity 223
245#elif __NR_sched_getaffinity != 223
246#error Wrong code for getaffinity system call.
249#ifndef __NR_sched_setaffinity
250#define __NR_sched_setaffinity 4239
251#elif __NR_sched_setaffinity != 4239
252#error Wrong code for setaffinity system call.
254#ifndef __NR_sched_getaffinity
255#define __NR_sched_getaffinity 4240
256#elif __NR_sched_getaffinity != 4240
257#error Wrong code for getaffinity system call.
260#ifndef __NR_sched_setaffinity
261#define __NR_sched_setaffinity 5195
262#elif __NR_sched_setaffinity != 5195
263#error Wrong code for setaffinity system call.
265#ifndef __NR_sched_getaffinity
266#define __NR_sched_getaffinity 5196
267#elif __NR_sched_getaffinity != 5196
268#error Wrong code for getaffinity system call.
270#elif KMP_ARCH_LOONGARCH64
271#ifndef __NR_sched_setaffinity
272#define __NR_sched_setaffinity 122
273#elif __NR_sched_setaffinity != 122
274#error Wrong code for setaffinity system call.
276#ifndef __NR_sched_getaffinity
277#define __NR_sched_getaffinity 123
278#elif __NR_sched_getaffinity != 123
279#error Wrong code for getaffinity system call.
281#elif KMP_ARCH_RISCV64
282#ifndef __NR_sched_setaffinity
283#define __NR_sched_setaffinity 122
284#elif __NR_sched_setaffinity != 122
285#error Wrong code for setaffinity system call.
287#ifndef __NR_sched_getaffinity
288#define __NR_sched_getaffinity 123
289#elif __NR_sched_getaffinity != 123
290#error Wrong code for getaffinity system call.
293#ifndef __NR_sched_setaffinity
294#define __NR_sched_setaffinity 203
295#elif __NR_sched_setaffinity != 203
296#error Wrong code for setaffinity system call.
298#ifndef __NR_sched_getaffinity
299#define __NR_sched_getaffinity 204
300#elif __NR_sched_getaffinity != 204
301#error Wrong code for getaffinity system call.
304#ifndef __NR_sched_setaffinity
305#define __NR_sched_setaffinity 239
306#elif __NR_sched_setaffinity != 239
307#error Wrong code for setaffinity system call.
309#ifndef __NR_sched_getaffinity
310#define __NR_sched_getaffinity 240
311#elif __NR_sched_getaffinity != 240
312#error Wrong code for getaffinity system call.
315#error Unknown or unsupported architecture
317#elif KMP_OS_FREEBSD || KMP_OS_DRAGONFLY
319#include <pthread_np.h>
326#define VMI_MAXRADS 64
327#define GET_NUMBER_SMT_SETS 0x0004
328extern "C" int syssmt(
int flags,
int,
int,
int *);
330class KMPNativeAffinity :
public KMPAffinity {
331 class Mask :
public KMPAffinity::Mask {
332 typedef unsigned long mask_t;
333 typedef decltype(__kmp_affin_mask_size) mask_size_type;
334 static const unsigned int BITS_PER_MASK_T =
sizeof(mask_t) * CHAR_BIT;
335 static const mask_t ONE = 1;
336 mask_size_type get_num_mask_types()
const {
337 return __kmp_affin_mask_size /
sizeof(mask_t);
347 void set(
int i)
override {
348 mask[
i / BITS_PER_MASK_T] |= (ONE << (
i % BITS_PER_MASK_T));
350 bool is_set(
int i)
const override {
351 return (
mask[
i / BITS_PER_MASK_T] & (ONE << (
i % BITS_PER_MASK_T)));
353 void clear(
int i)
override {
354 mask[
i / BITS_PER_MASK_T] &= ~(ONE << (
i % BITS_PER_MASK_T));
356 void zero()
override {
357 mask_size_type e = get_num_mask_types();
358 for (mask_size_type
i = 0;
i < e; ++
i)
361 bool empty()
const override {
362 mask_size_type e = get_num_mask_types();
363 for (mask_size_type
i = 0;
i < e; ++
i)
364 if (
mask[
i] != (mask_t)0)
368 void copy(
const KMPAffinity::Mask *src)
override {
369 const Mask *convert =
static_cast<const Mask *
>(src);
370 mask_size_type e = get_num_mask_types();
371 for (mask_size_type
i = 0;
i < e; ++
i)
372 mask[
i] = convert->mask[
i];
374 void bitwise_and(
const KMPAffinity::Mask *rhs)
override {
375 const Mask *convert =
static_cast<const Mask *
>(rhs);
376 mask_size_type e = get_num_mask_types();
377 for (mask_size_type
i = 0;
i < e; ++
i)
378 mask[
i] &= convert->mask[
i];
380 void bitwise_or(
const KMPAffinity::Mask *rhs)
override {
381 const Mask *convert =
static_cast<const Mask *
>(rhs);
382 mask_size_type e = get_num_mask_types();
383 for (mask_size_type
i = 0;
i < e; ++
i)
384 mask[
i] |= convert->mask[
i];
386 void bitwise_not()
override {
387 mask_size_type e = get_num_mask_types();
388 for (mask_size_type
i = 0;
i < e; ++
i)
391 bool is_equal(
const KMPAffinity::Mask *rhs)
const override {
392 const Mask *convert =
static_cast<const Mask *
>(rhs);
393 mask_size_type e = get_num_mask_types();
394 for (mask_size_type
i = 0;
i < e; ++
i)
395 if (
mask[
i] != convert->mask[
i])
399 int begin()
const override {
401 while (retval <
end() && !is_set(retval))
405 int end()
const override {
410 int next(
int previous)
const override {
411 int retval = previous + 1;
412 while (retval <
end() && !is_set(retval))
419 int get_system_affinity(
bool abort_on_error)
override {
421 "Illegal get affinity operation when not capable");
423 (
void)abort_on_error;
427 KMP_CPU_SET(
i,
this);
430 int set_system_affinity(
bool abort_on_error)
const override {
433 "Illegal set affinity operation when not capable");
437 int tid = thread_self();
441 int retval = bindprocessor(BINDTHREAD, tid, PROCESSOR_CLASS_ANY);
445 KMP_CPU_SET_ITERATE(location,
this) {
446 if (KMP_CPU_ISSET(location,
this)) {
447 retval = bindprocessor(BINDTHREAD, tid, location);
448 if (retval == -1 && errno == 1) {
453 rsh = rs_alloc(RS_EMPTY);
454 rsid.at_pid = getpid();
455 if (RS_DEFAULT_RSET != ra_getrset(R_PROCESS, rsid, 0, rsh)) {
456 retval = ra_detachrset(R_PROCESS, rsid, 0);
457 retval = bindprocessor(BINDTHREAD, tid, location);
461 KA_TRACE(10, (
"__kmp_set_system_affinity: Done binding "
467 if (abort_on_error) {
470 KA_TRACE(10, (
"__kmp_set_system_affinity: Error binding "
471 "T#%d to cpu=%d, errno=%d.\n",
472 gtid, location, error));
480 int get_system_affinity(
bool abort_on_error)
override {
482 "Illegal get affinity operation when not capable");
485 syscall(__NR_sched_getaffinity, 0, __kmp_affin_mask_size,
mask);
486#elif KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_DRAGONFLY
487 int r = pthread_getaffinity_np(pthread_self(), __kmp_affin_mask_size,
488 reinterpret_cast<cpuset_t *
>(
mask));
489 int retval = (
r == 0 ? 0 : -1);
495 if (abort_on_error) {
501 int set_system_affinity(
bool abort_on_error)
const override {
503 "Illegal set affinity operation when not capable");
506 syscall(__NR_sched_setaffinity, 0, __kmp_affin_mask_size,
mask);
507#elif KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_DRAGONFLY
508 int r = pthread_setaffinity_np(pthread_self(), __kmp_affin_mask_size,
509 reinterpret_cast<cpuset_t *
>(
mask));
510 int retval = (
r == 0 ? 0 : -1);
516 if (abort_on_error) {
524 void determine_capable(
const char *env_var)
override {
528 KMPAffinity::Mask *allocate_mask()
override {
529 KMPNativeAffinity::Mask *retval =
new Mask();
532 void deallocate_mask(KMPAffinity::Mask *m)
override {
533 KMPNativeAffinity::Mask *native_mask =
534 static_cast<KMPNativeAffinity::Mask *
>(m);
537 KMPAffinity::Mask *allocate_mask_array(
int num)
override {
538 return new Mask[num];
540 void deallocate_mask_array(KMPAffinity::Mask *array)
override {
541 Mask *linux_array =
static_cast<Mask *
>(array);
542 delete[] linux_array;
544 KMPAffinity::Mask *index_mask_array(KMPAffinity::Mask *array,
545 int index)
override {
546 Mask *linux_array =
static_cast<Mask *
>(array);
547 return &(linux_array[index]);
549 api_type get_api_type()
const override {
return NATIVE_OS; }
555class KMPNativeAffinity :
public KMPAffinity {
556 class Mask :
public KMPAffinity::Mask {
557 typedef ULONG_PTR mask_t;
558 static const int BITS_PER_MASK_T =
sizeof(mask_t) * CHAR_BIT;
569 void set(
int i)
override {
570 mask[
i / BITS_PER_MASK_T] |= ((mask_t)1 << (
i % BITS_PER_MASK_T));
572 bool is_set(
int i)
const override {
573 return (
mask[
i / BITS_PER_MASK_T] & ((mask_t)1 << (
i % BITS_PER_MASK_T)));
575 void clear(
int i)
override {
576 mask[
i / BITS_PER_MASK_T] &= ~((mask_t)1 << (
i % BITS_PER_MASK_T));
578 void zero()
override {
579 for (
int i = 0;
i < __kmp_num_proc_groups; ++
i)
582 bool empty()
const override {
583 for (
size_t i = 0;
i < __kmp_num_proc_groups; ++
i)
588 void copy(
const KMPAffinity::Mask *src)
override {
589 const Mask *convert =
static_cast<const Mask *
>(src);
590 for (
int i = 0;
i < __kmp_num_proc_groups; ++
i)
591 mask[
i] = convert->mask[
i];
593 void bitwise_and(
const KMPAffinity::Mask *rhs)
override {
594 const Mask *convert =
static_cast<const Mask *
>(rhs);
595 for (
int i = 0;
i < __kmp_num_proc_groups; ++
i)
596 mask[
i] &= convert->mask[
i];
598 void bitwise_or(
const KMPAffinity::Mask *rhs)
override {
599 const Mask *convert =
static_cast<const Mask *
>(rhs);
600 for (
int i = 0;
i < __kmp_num_proc_groups; ++
i)
601 mask[
i] |= convert->mask[
i];
603 void bitwise_not()
override {
604 for (
int i = 0;
i < __kmp_num_proc_groups; ++
i)
607 bool is_equal(
const KMPAffinity::Mask *rhs)
const override {
608 const Mask *convert =
static_cast<const Mask *
>(rhs);
609 for (
size_t i = 0;
i < __kmp_num_proc_groups; ++
i)
610 if (
mask[
i] != convert->mask[
i])
614 int begin()
const override {
616 while (retval <
end() && !is_set(retval))
620 int end()
const override {
return __kmp_num_proc_groups * BITS_PER_MASK_T; }
621 int next(
int previous)
const override {
622 int retval = previous + 1;
623 while (retval <
end() && !is_set(retval))
627 int set_process_affinity(
bool abort_on_error)
const override {
628 if (__kmp_num_proc_groups <= 1) {
629 if (!SetProcessAffinityMask(GetCurrentProcess(), *
mask)) {
630 DWORD
error = GetLastError();
631 if (abort_on_error) {
640 int set_system_affinity(
bool abort_on_error)
const override {
641 if (__kmp_num_proc_groups > 1) {
644 int group = get_proc_group();
646 if (abort_on_error) {
647 KMP_FATAL(AffinityInvalidMask,
"kmp_set_affinity");
654 ga.Mask =
mask[group];
655 ga.Reserved[0] = ga.Reserved[1] = ga.Reserved[2] = 0;
658 if (__kmp_SetThreadGroupAffinity(GetCurrentThread(), &ga, NULL) == 0) {
659 DWORD
error = GetLastError();
660 if (abort_on_error) {
667 if (!SetThreadAffinityMask(GetCurrentThread(), *
mask)) {
668 DWORD
error = GetLastError();
669 if (abort_on_error) {
678 int get_system_affinity(
bool abort_on_error)
override {
679 if (__kmp_num_proc_groups > 1) {
683 if (__kmp_GetThreadGroupAffinity(GetCurrentThread(), &ga) == 0) {
684 DWORD
error = GetLastError();
685 if (abort_on_error) {
691 if ((ga.Group < 0) || (ga.Group > __kmp_num_proc_groups) ||
695 mask[ga.Group] = ga.Mask;
697 mask_t newMask, sysMask, retval;
698 if (!GetProcessAffinityMask(GetCurrentProcess(), &newMask, &sysMask)) {
699 DWORD
error = GetLastError();
700 if (abort_on_error) {
706 retval = SetThreadAffinityMask(GetCurrentThread(), newMask);
708 DWORD
error = GetLastError();
709 if (abort_on_error) {
715 newMask = SetThreadAffinityMask(GetCurrentThread(), retval);
717 DWORD
error = GetLastError();
718 if (abort_on_error) {
727 int get_proc_group()
const override {
729 if (__kmp_num_proc_groups == 1) {
732 for (
int i = 0;
i < __kmp_num_proc_groups;
i++) {
742 void determine_capable(
const char *env_var)
override {
746 KMPAffinity::Mask *allocate_mask()
override {
return new Mask(); }
747 void deallocate_mask(KMPAffinity::Mask *m)
override {
delete m; }
748 KMPAffinity::Mask *allocate_mask_array(
int num)
override {
749 return new Mask[num];
751 void deallocate_mask_array(KMPAffinity::Mask *array)
override {
752 Mask *windows_array =
static_cast<Mask *
>(array);
753 delete[] windows_array;
755 KMPAffinity::Mask *index_mask_array(KMPAffinity::Mask *array,
756 int index)
override {
757 Mask *windows_array =
static_cast<Mask *
>(array);
758 return &(windows_array[index]);
760 api_type get_api_type()
const override {
return NATIVE_OS; }
815#if KMP_AFFINITY_SUPPORTED
816 bool contains(
const kmp_affinity_attrs_t &attr)
const {
817 if (!
valid && !attr.valid)
819 if (
valid && attr.valid) {
837#if KMP_AFFINITY_SUPPORTED
889 int num_core_efficiencies;
911#if KMP_GROUP_AFFINITY
913 void _insert_windows_proc_groups();
919 void _gather_enumeration_information();
923 void _remove_radix1_layers();
926 void _discover_uniformity();
937 void _set_last_level_cache();
942 int _get_ncores_with_attr(
const kmp_hw_attr_t &attr,
int above,
943 bool find_all =
false)
const;
959 return hw_threads[index];
963 return hw_threads[index];
980 void canonicalize(
int pkgs,
int cores_per_pkg,
int thr_per_core,
int cores);
984#if KMP_AFFINITY_SUPPORTED
986 void set_granularity(kmp_affinity_t &stgs)
const;
987 bool is_close(
int hwt1,
int hwt2,
const kmp_affinity_t &stgs)
const;
988 bool restrict_to_mask(
const kmp_affin_mask_t *
mask);
989 bool filter_hw_subset();
997 return equivalent[
type];
1003 kmp_hw_t real_type2 = equivalent[type2];
1006 equivalent[type1] = real_type2;
1010 if (equivalent[
type] == type1) {
1011 equivalent[
type] = real_type2;
1027 return ratio[
level];
1032 return types[
level];
1036 int eq_type = equivalent[
type];
1039 for (
int i = 0;
i < depth; ++
i)
1040 if (types[
i] == eq_type)
1050 return _get_ncores_with_attr(attr, -1,
true);
1055 return _get_ncores_with_attr(attr, above,
false);
1058#if KMP_AFFINITY_SUPPORTED
1060 void sort_compact(kmp_affinity_t &affinity) {
1061 compact = affinity.compact;
1066 void print(
const char *env_var =
"KMP_AFFINITY")
const;
1084 const static int USE_ALL = (std::numeric_limits<int>::max)();
1096 static int hw_subset_compare(
const void *i1,
const void *i2) {
1101 return level1 - level2;
1113 int initial_capacity = 5;
1117 retval->capacity = initial_capacity;
1119 retval->absolute =
false;
1130 for (
int i = 0;
i < depth; ++
i) {
1135 if ((
size_t)idx >= MAX_ATTRS)
1137 items[
i].
num[idx] = num;
1138 items[
i].
offset[idx] = offset;
1139 items[
i].
attr[idx] = attr;
1143 if (depth == capacity - 1) {
1146 for (
int i = 0;
i < depth; ++
i)
1147 new_items[
i] = items[
i];
1153 items[depth].
num[0] = num;
1154 items[depth].
offset[0] = offset;
1155 items[depth].
attr[0] = attr;
1157 set |= (1ull <<
type);
1162 return items[index];
1166 return items[index];
1170 set &= ~(1ull << items[index].
type);
1171 for (
int j = index + 1;
j < depth; ++
j) {
1172 items[
j - 1] = items[
j];
1178 qsort(items, depth,
sizeof(
item_t), hw_subset_compare);
1226 printf(
"**********************\n");
1227 printf(
"*** kmp_hw_subset: ***\n");
1228 printf(
"* depth: %d\n", depth);
1229 printf(
"* items:\n");
1230 for (
int i = 0;
i < depth; ++
i) {
1233 printf(
" num: %d, offset: %d, attr: ", items[
i].num[
j],
1234 items[
i].offset[
j]);
1235 if (!items[
i].attr[
j]) {
1236 printf(
" (none)\n");
1239 " core_type = %s, core_eff = %d\n",
1241 items[
i].attr[
j].get_core_eff());
1245 printf(
"* set: 0x%llx\n", set);
1246 printf(
"* absolute: %d\n", absolute);
1247 printf(
"**********************\n");
1291 for (
int i = hier_depth - 1,
level = 0;
i >= 0; --
i, ++
level) {
1310 if (bool_result == 0) {
1365 branch = branch >> 1;
1383 while (bool_result == 0) {
1404 if (nproc > old_sz) {
1405 while (nproc > old_sz) {
kmp_uint32 * numPerLevel
Level 0 corresponds to leaves.
static const kmp_uint32 maxLeaves
kmp_uint32 * skipPerLevel
void resize(kmp_uint32 nproc)
kmp_uint32 base_num_threads
volatile kmp_int8 uninitialized
kmp_uint32 maxLevels
Number of levels in the hierarchy.
kmp_uint32 depth
This is specifically the depth of the machine configuration hierarchy, in terms of the number of leve...
volatile kmp_int8 resizing
static const kmp_uint32 minBranch
bool specified(kmp_hw_t type) const
void push_back(int num, kmp_hw_t type, int offset, kmp_hw_attr_t attr)
kmp_hw_subset_t(kmp_hw_subset_t &&t)=delete
void canonicalize(const kmp_topology_t *top)
static kmp_hw_subset_t * allocate()
static void deallocate(kmp_hw_subset_t *subset)
kmp_hw_subset_t(const kmp_hw_subset_t &t)=delete
const item_t & at(int index) const
kmp_hw_subset_t & operator=(kmp_hw_subset_t &&t)=delete
kmp_hw_subset_t & operator=(const kmp_hw_subset_t &t)=delete
static const int UNKNOWN_ID
static int compare_compact(const void *a, const void *b)
static int compare_ids(const void *a, const void *b)
static const int MULTIPLE_ID
kmp_hw_thread_t & at(int index)
int get_level(kmp_hw_t type) const
int get_count(int level) const
int get_ratio(int level) const
static void deallocate(kmp_topology_t *)
kmp_hw_t get_equivalent_type(kmp_hw_t type) const
void set_equivalent_type(kmp_hw_t type1, kmp_hw_t type2)
int get_num_hw_threads() const
int get_ncores_with_attr_per(const kmp_hw_attr_t &attr, int above) const
const kmp_hw_thread_t & at(int index) const
void insert_layer(kmp_hw_t type, const int *ids)
int calculate_ratio(int level1, int level2) const
static kmp_topology_t * allocate(int nproc, int ndepth, const kmp_hw_t *types)
void print(const char *env_var="KMP_AFFINITY") const
kmp_topology_t & operator=(kmp_topology_t &&t)=delete
kmp_topology_t(const kmp_topology_t &t)=delete
kmp_hw_t get_type(int level) const
kmp_topology_t(kmp_topology_t &&t)=delete
kmp_topology_t & operator=(const kmp_topology_t &t)=delete
int get_ncores_with_attr(const kmp_hw_attr_t &attr) const
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int mask
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp end
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp begin
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t count
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle __itt_metadata_type size_t void ITT_FORMAT p const __itt_domain __itt_id __itt_string_handle const wchar_t size_t ITT_FORMAT lu const __itt_domain __itt_id __itt_relation __itt_id ITT_FORMAT p const wchar_t int ITT_FORMAT __itt_group_mark d int
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle __itt_metadata_type type
#define KMP_HW_MAX_NUM_CORE_EFFS
#define KMP_FOREACH_HW_TYPE(type)
#define __kmp_entry_gtid()
const char * __kmp_hw_get_keyword(kmp_hw_t type, bool plural=false)
#define __kmp_allocate(size)
const char * __kmp_hw_get_core_type_string(kmp_hw_core_type_t type)
@ KMP_HW_MAX_NUM_CORE_TYPES
@ KMP_HW_CORE_TYPE_UNKNOWN
static void __kmp_type_convert(T1 src, T2 *dest)
#define KMP_DEBUG_ASSERT_VALID_HW_TYPE(type)
kmp_hw_subset_t * __kmp_hw_subset
kmp_topology_t * __kmp_topology
KMP_ARCH_X86 KMP_ARCH_X86 KMP_ARCH_X86 kmp_int8
#define KMP_BUILD_ASSERT(expr)
#define KMP_DEBUG_ASSERT(cond)
#define KMP_ASSERT2(cond, msg)
unsigned long long kmp_uint64
void __kmp_fatal(kmp_msg_t message,...)
#define KMP_COMPARE_AND_STORE_ACQ8(p, cv, sv)
bool contains(const kmp_hw_attr_t &other) const
bool is_core_type_valid() const
kmp_hw_core_type_t get_core_type() const
void set_core_type(kmp_hw_core_type_t type)
static const int UNKNOWN_CORE_EFF
void set_core_eff(int eff)
bool operator==(const kmp_hw_attr_t &rhs) const
bool is_core_eff_valid() const
bool operator!=(const kmp_hw_attr_t &rhs) const
kmp_hw_attr_t attr[MAX_ATTRS]
void __kmp_affinity_determine_capable(const char *env_var)
void __kmp_affinity_bind_thread(int proc)