#1741: Threaded RTS must use processor affinity and processor information
-----------------------+----------------------------------------------------
Reporter: guest | Owner:
Type: task | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 6.6.1
Severity: normal | Keywords:
Difficulty: Unknown | Os: Multiple
Testcase: | Architecture: Multiple
-----------------------+----------------------------------------------------
Threaded RTS must use processor affinity and processor information
I think current GHC's SMP parallelism support has 2 problems.
1. We must specify -Nx option if we want to use multiple CPU or cores.
1. Threaded RTS doesn't set processor affinity even if OS API support
that.
----
1 is bad. Because this is complex for Application user and developper.
If user want to take full advantage of multiple core processor, user must
know how
many his computer's cpu cores, and specify RTS option in runtime. Or
application developper
must guess how many users' computer use cpu cores, and set guessed good
enough RTS option.
* http://www.haskell.org/ghc/docs/latest/html/users_guide/runtime-
control.html#rts-hooks
If OS doesn't provide CPU information, it's real solution. But we can get
CPU information
by OS's API, so it's just bad way.
We can get number of processors (cores) by sysconf(_SC_NPROCESSORS_CONF)
under unix (includes Mac OS X)
platform, and by GetSystemInfo function under Windows platform.
*
http://developer.apple.com/documentation/Darwin/Reference/ManPages/man3/sysconf.3.html
* http://msdn2.microsoft.com/en-us/library/ms724381.aspx
So I think threaded RTS must specify -Nx's default x by using these API.
----
2 is related to good parallel program's behavior. Current mainstream OS
scheduler assigns thread to CPU implicitly by default.
And if two thread are assigned to same CPU, then a thead must wait when
another thread is running, even if other CPU
is idle. This is not good.
* http://www.haskell.org/pipermail/cvs-ghc/2007-August/037534.html
And RTS -Nx option specifies number of thread running simultaneously.
* http://www.haskell.org/ghc/docs/latest/html/users_guide/sec-using-
smp.html
So I think threaded RTS must assigning thread to CPU instead of leaving
work for OS scheduler.
This is not difficult work on Linux and Windows. Because we just need to
set processor affinity by OS's API.
Linux has sched_setaffinity, so we must just set bitmask on Linux.
* http://linux.die.net/man/2/sched_setaffinity
* http://www-128.ibm.com/developerworks/linux/library/l-affinity.html
Windows has many API, e.g. SetThreadAffinityMask and
SetThreadIdealProcessor ....
So we must just set bitmask by SetThreadAffinityMask, or set preferred
processor by SetThreadIdealProcessor on Windows.
* http://msdn2.microsoft.com/en-us/library/ms684251.aspx
But I don't get other OS's API information soonly, and I think this is
difficult point of this task.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1741>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs