http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58642

--- Comment #3 from vincenzo Innocente <vincenzo.innocente at cern dot ch> ---
strange indeed

rhel6: so is 2.12
or my own version
GNU C Library stable release version 2.13,

I build gcc by myself
c++ -v
Using built-in specs.
COLLECT_GCC=c++
COLLECT_LTO_WRAPPER=/afs/cern.ch/user/i/innocent/w2/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-gomp4/configure
--prefix=/afs/cern.ch/user/i/innocent/w2 --enable-languages=c,c++,lto,fortran
-enable-gold=yes --enable-lto --with-build-config=bootstrap-lto
--with-gmp-lib=/usr/local/lib64 --with-mpfr-lib=/usr/local/lib64
-with-mpc-lib=/usr/local/lib64 --enable-cloog-backend=isl
--with-cloog=/usr/local --with-ppl-lib=/usr/local/lib64 CFLAGS='-O2
-ftree-vectorize -fPIC' -enable-libitm -disable-multilib -disable-werror
--disable-libsanitizer

same since long time
behavior changed yestarday when finally got gomp4 compiling…
I get

on one machine
uname -a
Linux vinavx0.cern.ch 2.6.32-358.18.1.el6.x86_64 #1 SMP Wed Aug 28 09:02:47
CEST 2013 x86_64 x86_64 x86_64 GNU/Linux
innocent@vinavx0 parallel]$ taskset -c 0-3 strace ./a.out | & grep affinity
sched_getaffinity(17895, 8,  { f })     = 8
sched_getaffinity(17895, 128,  { f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}) = 128
sched_setaffinity(17895, 8,  { 1 })     = 0
[innocent@vinavx0 parallel]$ taskset -c 0-7 strace ./a.out | & grep affinity
sched_getaffinity(17898, 8,  { ff })    = 8
sched_getaffinity(17898, 128,  { ff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0 }) = 128
sched_setaffinity(17898, 8,  { 1 })     = 0
[innocent@vinavx0 parallel]$ taskset -c 0-3 ./a.out
max thread 4
[innocent@vinavx0 parallel]$ taskset -c 0-7 ./a.out
max thread 8
and indeed on this works


on the Xeon where I'm doing all tests (identical software stack: it's on shared
disks)

uname -a
Linux olsnba03 2.6.32-358.2.1.el6.x86_64 #1 SMP Wed Mar 13 08:24:06 CET 2013
x86_64 x86_64 x86_64 GNU/Linux

taskset -c 0-3 strace ./a.out | & grep affinity
sched_getaffinity(80664, 8, 0x1a69010)  = -1 EINVAL (Invalid argument)


some with a different kernel
[innocent@olsnba04 parallel]$ uname -a
Linux olsnba04 3.10.2-1.el6.elrepo.x86_64 #1 SMP Mon Jul 22 12:18:13 EDT 2013
x86_64 x86_64 x86_64 GNU/Linux
[innocent@olsnba04 parallel]$ strace ./a.out | & grep affinity
sched_getaffinity(55293, 8, 0x225b010)  = -1 EINVAL (Invalid argument)
[innocent@olsnba04 parallel]$ taskset -c 0-3 strace ./a.out | & grep affinity
sched_getaffinity(55297, 8, 0xbca010)   = -1 EINVAL (Invalid argument)
[innocent@olsnba04 parallel]$ 

libgc always 2.13


on this very same machine tried the test program in man page
cat affTest.cpp 
#define _GNU_SOURCE

#include <sched.h>
#include <stdio.h>
#include <errno.h>

          int main(void)
          {
               cpu_set_t *mask;
               size_t size;
               int i;
               int nrcpus = 1024;

       realloc:
               mask = CPU_ALLOC(nrcpus);
               size = CPU_ALLOC_SIZE(nrcpus);
               CPU_ZERO_S(size, mask);
               if ( sched_getaffinity(0, size, mask) == -1 ) {
                       CPU_FREE(mask);
                       if (errno == EINVAL &&
                           nrcpus < (1024 << 8)) {
                              nrcpus = nrcpus << 2;
                              goto realloc;
                       }
                       perror("sched_getaffinity");
                       return -1;
               }

               for ( i = 0; i < nrcpus; i++ ) {
                       if ( CPU_ISSET_S(i, size, mask) ) {
                               printf("CPU %d is set\n", (i+1));
                       }
               }

               CPU_FREE(mask);

               return 0;
          }
gcc affTest.cpp 
./a.out
CPU 1 is set
CPU 2 is set
CPU 3 is set
CPU 4 is set
CPU 5 is set
CPU 6 is set
CPU 7 is set
CPU 8 is set
CPU 9 is set
CPU 10 is set
CPU 11 is set
CPU 12 is set
CPU 13 is set
CPU 14 is set
CPU 15 is set
CPU 16 is set
CPU 17 is set
CPU 18 is set
CPU 19 is set
CPU 20 is set
CPU 21 is set
CPU 22 is set
CPU 23 is set
CPU 24 is set
CPU 25 is set
CPU 26 is set
CPU 27 is set
CPU 28 is set
CPU 29 is set
CPU 30 is set
CPU 31 is set
CPU 32 is set
[innocent@olsnba04 parallel]$ taskset -c 0-3 ./a.out
CPU 1 is set
CPU 2 is set
CPU 3 is set
CPU 4 is set
[innocent@olsnba04 parallel]$ taskset -c 0-3 strace ./a.out  |& grep aff
sched_getaffinity(0, 128,  { f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 })
= 128
[innocent@olsnba04 parallel]$ strace ./a.out | & grep aff
sched_getaffinity(0, 128,  { ffffffff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0 }) = 128


BUT
c++ -Ofast -fopenmp -std=c++11 affTest.cpp
affTest.cpp:1:0: warning: "_GNU_SOURCE" redefined [enabled by default]
 #define _GNU_SOURCE
 ^
<command-line>:0:0: note: this is the location of the previous definition
[innocent@olsnba04 parallel]$ strace ./a.out | & grep aff
sched_getaffinity(55390, 8, 0x1709010)  = -1 EINVAL (Invalid argument)
sched_getaffinity(0, 128,  { ffffffff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0 }) = 128

Reply via email to