Why do you have to use both a compiler flag and a run-time flag to get multicore-support in Haskell?

前端 未结 3 2022
被撕碎了的回忆
被撕碎了的回忆 2021-02-07 04:46

The Haskell wiki shows that you need to both set a compilation flag and a run-time flag to get multi-core support. Why isn\'t using the library enough to get the correct behavio

3条回答
  •  南方客
    南方客 (楼主)
    2021-02-07 04:50

    While you're developing the program the extra +RTS ... shouldn't be a big deal (though I admit it struck me as odd when I first picked up Haskell). For the final (shipped) binary you can link it with static RTS options (GHC manual) by providing a C file containing char *ghc_rts_opts = "-N";.

    EDIT: Updating this question for GHC 7.x, there is now a way to specify RTS options at compile time:

    ghc -threaded -rtsopts -with-rtsopts=-N
    

    This 1) uses the threaded runtime system 2) Enables the RTS options 3) Sets the RTS option to use as many threads as there are cores available (use -Nx where x is a number to manually control the number of OS threads).

提交回复
热议问题