http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57298
Bug ID: 57298 Summary: GOMP_CPU_AFFINITY will not work when system has >1024 cores Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libgomp Assignee: unassigned at gcc dot gnu.org Reporter: sp at numascale dot com CC: jakub at gcc dot gnu.org Using GOMP_CPU_AFFINITY to set processor affinity on OpenMP threads will not work if the system has more than 1024 threads. [root@numa-0 Stream]# OMP_NUM_THREADS=4 GOMP_CPU_AFFINITY=0-3 ./stream.small.x libgomp: could not get CPU affinity set Output from "lscpu" : [root@numa-0 ~]# lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 1272 On-line CPU(s) list: 0-1271 Thread(s) per core: 1 Core(s) per socket: 6 Socket(s): 212 NUMA node(s): 212 Vendor ID: AuthenticAMD CPU family: 16 Model: 9 Stepping: 1 CPU MHz: 2199.900 BogoMIPS: 4406.00 Virtualization: AMD-V L1d cache: 64K L1i cache: 64K L2 cache: 512K L3 cache: 5118K The issue is that cpu_set_t as defined in /usr/include/sched.h only has room for 1024 entries when statically allocated. However, libc has support for allocating dynamic sizes which allows for more than 1024 by using the CPU_ALLOC() and CPU_FREE() macros. These files : libgomp/config/linux/affinity.c libgomp/config/linux/proc.c libgomp/config/linux/proc.h needs to be modified to support systems with > 1024 cores.