2

How do I get the number of threads / HECs (the -N parameter) of a Haskell program that was compiled with -threaded during its runtime?

[Edit] My question is about the number of HECs, not about the number of cores (even though the answer is related) - so the question is not a duplicate.

muffel
  • 7,004
  • 8
  • 57
  • 98
  • possible duplicate of [How to find the number of cores at runtime in Haskell](http://stackoverflow.com/questions/8041813/how-to-find-the-number-of-cores-at-runtime-in-haskell) – jberryman Jun 05 '15 at 21:39
  • @jberryman please see my edit above – muffel Jun 07 '15 at 07:57

1 Answers1

4

Use getNumCapabilities. It also has a counterpart setNumCapabilities for changing the number of threads programmatically.

Daniel Wagner
  • 145,880
  • 9
  • 220
  • 380
  • Whilst this may theoretically answer the question, [it would be preferable](//meta.stackoverflow.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – Rohit Gupta Jun 22 '15 at 00:55
  • @RohitGupta This is the complete answer. What more are you hoping to see? – Daniel Wagner Jun 22 '15 at 01:38
  • You have a high enough rep to know that this is a low quality answer. You could for instance give a one line explanation for each of them. I know what they are, but others may not. If you want to get carried away, you could explain their arguments and the result they return. – Rohit Gupta Jun 22 '15 at 02:03
  • 3
    @RohitGupta It has no arguments, and returns the answer asked for in the question. It would be stupid to say that. The other sentence is only there to flesh the thing out to the 30-character minimum. It's not a low-quality answer; it's just a very specific question for which the best answer is simple and short. – Daniel Wagner Jun 22 '15 at 04:33