#7254 closed feature request (wontfix)

Parallel processing and the -Nn flag

Reported by: mcandre Owned by:
Priority: normal Milestone:
Component: Runtime System Version: 7.0.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Runtime crash Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

When I follow the Parallel Processing with Haskell tutorial (http://www.yellosoft.us/parallel-processing-with-haskell), it instructs users to run Haskell parallel programs with syntax like:

$ ./maths +RTS -N2

Where the -Nn flag informs the Haskell system that the computer has n cores. Modern video games are able to automatically determine the number of cores on a computer by some method of extracting such details; there's no reason Haskell can't do the same, so that the user doesn't have to specify it manually.

This is important because specifying the wrong number of cores either leads the program to run slowly, or even crash. If Haskell detected the number of cores and the user still specified a manual value, it could correct the user's mistake in much the same way that the Haskell type system does inference and corrects the user's mistake.

Specs at time of this behavior:

  • GHC 7.0.3
  • Haskell Platform 2011.2.0.1
  • Windows 7 Professional x86 and x64
  • Ubuntu 12.04 x86 and x64
  • Mac OS X 10.8.1 Mountain Lion (triple booting with rEFIt)
  • MacBook Pro 2009

Change History (3)

comment:1 Changed 19 months ago by parcs

As of GHC 6.12.1, you can omit the number of processors and pass in -N by itself and GHC will automatically determine the number of processors to use. And as of GHC 7.6.1, you can also adjust the number of processors at runtime via GHC.Conc.getNumProcessors and GHC.Conc.setNumCapabilities.

comment:2 Changed 19 months ago by mcandre

parcs is correct; I just tested -N by itself on Windows. However, specifying too many cores with -N results in the program stalling indefinitely. Perhaps the Haskell runtime can detect this mistake and inform the user before attempting to run the program. The equivalent in Perl would look like:

die "The system does not have that many cores." unless $N <= $cores;
run_program;

comment:3 Changed 19 months ago by simonmar

  • Difficulty set to Unknown
  • Resolution set to wontfix
  • Status changed from new to closed

There are occasionally reasons to want to use a higher -N value than the number of cores, and you can write a test equivalent to the Perl fragment above using GHC.Conc.getNumCapabilities and GHC.Conc.getNumProcessors.

Note: See TracTickets for help on using tickets.