我已经阅读了许多 tutorials on haskell 。但是,我无法让编译的应用程序在 上的多核(我有一个英特尔四核)上运行。 Windows(32 位) .
我尝试了很多事情:
但没有运气。
编译后的应用程序仅在一个内核上运行 100%。
有任何想法吗?
代码:
import Control.Parallel
import Control.Monad
import Text.Printf
fib :: Int -> Int
fib 0 = 0
fib 1 = 1
fib n = l `pseq` r `pseq` l+r
where
l = fib (n-1)
r = fib (n-2)
main = forM_ [0..350] $ \i ->
printf "n=%d => %d\n" i (fib i)
最佳答案
使用 par 而不是 pseq 似乎可以解决它。
关于multithreading - Windows 上的多核 Haskell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/623122/