numCapabilities未显示正确的核心数

时间:2014-03-07 14:07:28

标签: haskell concurrency

我一直关注RWH中的concurrency chapter。我一直在尝试书中提到的示例程序。以下是代码:

test.hs:

import GHC.Conc (numCapabilities)

main = do
    putStrLn $ "number of cores: " ++ show numCapabilities

这就是我执行它们的方式:

$ ghc -c test.hs
$ ghc -threaded -o test test.o
$ ./test -RTS -N4
number of cores: 1

但我似乎有四个核心:

$ nproc
4
$ cat /proc/cpuinfo
Produces a big output. But shows four processors. (0..3).

对我做错了什么的想法?

1 个答案:

答案 0 :(得分:4)

Runtime system options +RTS -RTS之间的括号(尽管后者可以省略)。这在RWH中也是正确的:

$ ./NumCapabilities +RTS -N4 -RTS foo

使用+RTS代替-RTS

./test +RTS -N4