Validate fails for HEAD on OS X
Manuel M T Chakravarty
chak at cse.unsw.edu.au
Fri Mar 20 01:52:13 EDT 2009
I am fixing that for Mac OS right now.
The comment above setThreadAffinity() says,
> // Schedules the thread to run on CPU n of m. m may be less than the
> // number of physical CPUs, in which case, the thread will be allowed
> // to run on CPU n, n+m, n+2m etc.
I am not convinced that this is a good plan. If m is less than n,
some threads can hop between CPUs and so invalidate their L2 cache
repeatedly. The man page for sched_setaffinity() says,
> Restricting a process to run on a single CPU also prevents the
> performance cost caused by the cache invalidation that occurs when a
> process ceases to execute on one CPU and then recommences execution
> on a different CPU.
Besides, you call this function with
> setThreadAffinity(cap->no, n_capabilities);
So, m is the number of capabilities, not the number of CPUs. The way
I understand the man page of sched_setaffinity(), if I run a Haskell
program with +RTS -N4 on an 8 core machine, it can only ever use the
first four cores of the system when thread affinity is used.
The above specification of setThreadAddinity() is also rather specific
to the Linux API. On OS X, the idea is not to nail a given thread to
a fixed CPU, but to express constraints for the scheduling of a set of
threads (eg, requiring that all threads should run on different cores
without fixing the identity of the cores on which they run). This is
much more what you really want on a multi-user system. Hence, I
suggest to change the specification of setThreadAffinity().
Manuel M T Chakravarty:
>> /Users/chak/Code/ghc-test/ghc/stage1-inplace/ghc -optc-Werror -optc-
>> Wall -optc-W -optc-Wstrict-prototypes -optc-Wmissing-prototypes -
>> optc-Wmissing-declarations -optc-Winline -optc-Waggregate-return -
>> optc-I../includes -optc-I. -optc-Iparallel -optc-Ism -optc-
>> Ieventlog -optc-DCOMPILING_RTS -optc-fomit-frame-pointer -optc-I../
>> gmp/gmpbuild -optc-I../libffi/build/include -optc-fno-strict-
>> aliasing -Werror -H64m -O0 -fasm -optc-O2 -I../includes -I. -
>> Iparallel -Ism -Ieventlog -DCOMPILING_RTS -package-name rts -
>> static -I../gmp/gmpbuild -I../libffi/build/include -I. -dcmm-lint
>> -hisuf thr_hi -hcsuf thr_hc -osuf thr_o -optc-DTHREADED_RTS -c
>> posix/OSThreads.c -o posix/OSThreads.thr_o
>> posix/OSThreads.c: In function 'setThreadAffinity':
>> posix/OSThreads.c:213:0: warning: unused parameter 'n'
>> posix/OSThreads.c:213:0: warning: unused parameter 'm'
> Do you guys need a box to run validate runs on OS X? I can offer one.
More information about the Cvs-ghc