
Hi, As a followup to the discussion [1] about the portable way to find the number of CPUs/cores: how is the default value of numCapabilities [2] set when +RTS -N is not on the command line? Does GHC runtime figure out the number of cores itself, or it is by default 1 unless specified on the command line? Thanks. --------------------------- [1] http://haskell.org/pipermail/haskell-cafe/2010-April/076911.html [2] http://hackage.haskell.org/packages/archive/base/latest/doc/html/GHC-Conc.ht... -- Dimitry Golubovsky Anywhere on the Web

On Tue, Apr 27, 2010 at 9:09 AM, Dimitry Golubovsky
how is the default value of numCapabilities [2]
set when +RTS -N is not on the command line?
Does GHC runtime figure out the number of cores itself,
With 6.12.1 and newer, no "-N" argument implies 1 core, "-N*k*" implies *k* cores, and "-N" without an argument means "use all".

Hi,
Interesting: my program is compiled with -threaded, and when I run it
with +RTS -N I get:
<program name>: forking not supported with +RTS -N<n> greater than 1
This is probably about forkProcess rather than forkIO/forkOS, but why
this limitation? rawSystem works fine from within a thread started by
forkIO, but why cannot I use forkProcess?
On Tue, Apr 27, 2010 at 12:35 PM, Bryan O'Sullivan
With 6.12.1 and newer, no "-N" argument implies 1 core, "-Nk" implies k cores, and "-N" without an argument means "use all".
-- Dimitry Golubovsky Anywhere on the Web

On Tue, Apr 27, 2010 at 7:02 PM, Dimitry Golubovsky
This is probably about forkProcess rather than forkIO/forkOS, but why this limitation?
That's a standard Unix limitation. A child process is forked with one thread, so if the parent has multiple threads running, it's overwhelmingly likely that the child will be unable to execute correctly.

On Wed, Apr 28, 2010 at 8:02 AM, Bryan O'Sullivan
On Tue, Apr 27, 2010 at 7:02 PM, Dimitry Golubovsky
wrote: This is probably about forkProcess rather than forkIO/forkOS, but why this limitation?
That's a standard Unix limitation. A child process is forked with one thread, so if the parent has multiple threads running, it's overwhelmingly likely that the child will be unable to execute correctly.
One problem used to be that the I/O manager would get killed but Simon Marlow fixed that. I think we should support forking, with some caveats, so that we can daemonize processes.

On 28/04/2010 03:02, Dimitry Golubovsky wrote:
Hi,
Interesting: my program is compiled with -threaded, and when I run it with +RTS -N I get:
<program name>: forking not supported with +RTS -N<n> greater than 1
This is probably about forkProcess rather than forkIO/forkOS, but why this limitation? rawSystem works fine from within a thread started by forkIO, but why cannot I use forkProcess?
No good reason, other than it's tremendously difficult to implement. Cheers, Simon

Simon,
Can the documentation for forkProcess be fixed then? Instead of
"forkProcess comes with a giant warning..." it could say: "forkProcess
is not supported by GHC in multicore setting".
PS I have created ticket #4027 with more detailed proposal.
On Wed, Apr 28, 2010 at 4:26 AM, Simon Marlow
On 28/04/2010 03:02, Dimitry Golubovsky wrote:
this limitation? rawSystem works fine from within a thread started by forkIO, but why cannot I use forkProcess?
No good reason, other than it's tremendously difficult to implement.
Thank you. -- Dimitry Golubovsky Anywhere on the Web

Hello Dimitry, Tuesday, April 27, 2010, 8:09:49 PM, you wrote: a few months ago i asked SimonM about using all cores by default, but he said that it dramatically reduces performance in some cases
Hi,
As a followup to the discussion [1] about the portable way to find the number of CPUs/cores: how is the default value of numCapabilities [2] set when +RTS -N is not on the command line?
Does GHC runtime figure out the number of cores itself, or it is by default 1 unless specified on the command line?
Thanks.
--------------------------- [1] http://haskell.org/pipermail/haskell-cafe/2010-April/076911.html [2] http://hackage.haskell.org/packages/archive/base/latest/doc/html/GHC-Conc.ht...
-- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

Bulat, All I need is to know how many cores I have. In my program, I can run some actions in parallel, and knowing the number of cores helps set the maximum number of parallel processes. These processes are in fact external programs (CPU-intensive but not memory intensive, so number of cores is main factor) rather than GHC threads. I think I just need to check this experimentally as I have a 4-core (Atom) and 1-core (Via) PCs and see what numCapabilities returns. -- Dimitry Golubovsky Anywhere on the Web
participants (5)
-
Bryan O'Sullivan
-
Bulat Ziganshin
-
Dimitry Golubovsky
-
Johan Tibell
-
Simon Marlow