What is the state of OCaml's parallelization abilities?

后端 未结 3 1716
我寻月下人不归
我寻月下人不归 2021-01-31 15:04

I\'m interested in using OCaml for a project, however I\'m not sure about where its parallelization capabilities are anymore. Is there a message passing ability in OCaml? Is O

3条回答
  •  名媛妹妹
    2021-01-31 16:00

    At present, the OCaml runtime does not support running across multiple cores in parallel, so a single OCaml process cannot take advantage of multiple cores. This is unlikely to change directly; the direction the OCaml developers are most interested in taking for increased parallelism seems to be allowing multiple OCaml runtimes to run in parallel in a single process; this will allow for very fast message passing, but will not allow multiple threads to run in parallel in a shared-memory configuration. The major hangup is the garbage collector; some years ago, the team experimented with a concurrent GC, but it introduced unacceptable slowdowns in the single-threaded case.

    There are a couple of projects, namely Functory and OCamlnet, which provide multicore-happy parallelism by using multiple processes.

    In general, the OCaml community tends to favor message passing approaches, which can be done across process boundaries (like OCamlnet does), over single-process shared-memory multithreading. If your program can be split into multiple processes (many can!), then yes, you can efficiently use multiple CPUs.

提交回复
热议问题