Shared publicly  - 
Changing the amount of parallelism dynamically

Here's something I got working today. setNumCapabilities can now reduce the number of active capabilities as well as increase it. The ThreadScope screenshot below shows a program with two threads - one thread is calculating nqueens in parallel, while the other thread is periodically calling setNumCapabilities to change the amount of available parallelism between 1 and 6 cores.

The use case I have in mind for this is to dynamically reduce the number of cores used by the runtime when other processes start up on the machine. Normally when that happens performance drops off a cliff due to the rapid synchronisation we do between all cores, but we should be able to degrade more gracefully and be friendly to other processes on the machine while still making use of all the cores when they're free. That's the idea, anyway.
Lyndon Maydwell's profile photoRyan Newton's profile photo
I remember one of the first things I thought when trying out Haskell was "I wish there was a way to manage the number of cores used at runtime" and here it is. This is wonderful. Thank you!
Another good motivation for this is energy management, say, in a data center.

For example, the HPX / ParalleX runtime does this and can produce a nice graph of energy use of the machine falling off as the worker threads contract. (Not sure how this compares to just disabling cores at the OS level with /sys/devices.)
Add a comment...