Haskell功能强大且纯粹,所以基本上它具有编译器能够处理隐式并行性所需的所有属性.
考虑这个简单的例子:
f = do
a <- Just 1
b <- Just $ Just 2
-- ^ The above line does not utilize an `a` variable, so it can be safely
-- executed in parallel with the preceding line
c <- b
-- ^ The above line references a `b` variable, so it can only be executed
-- sequentially after it
return (a, c)
-- On the exit from a monad scope we wait for all computations to …Run Code Online (Sandbox Code Playgroud) parallel-processing concurrency haskell compiler-optimization
Haskell wiki显示您需要设置编译标志和运行时标志以获得多核支持.为什么不使用足够的库来在编译时获得正确的行为?为什么运行时可执行文件检测不到它是使用-threaded编译并使用系统上的所有核心,除非另有说明?我认为默认情况下打开这些会更好.然后可能会有标志关闭或修改这些功能.
http://www.haskell.org/haskellwiki/GHC/Concurrency#Multicore_GHC说:
让标志必须在编译时和运行时再次设置似乎有些繁琐.这些标志是否是为GHC增加并发性的遗留因素?