multithreading with R?

后端 未结 5 1267
鱼传尺愫
鱼传尺愫 2020-11-29 22:18

Reading the R-project website, there are some (unclear) references to multithreading with R, but it is unclear how the base product and CRAN libraries are compiled.

5条回答
  •  無奈伤痛
    2020-11-29 22:45

    You are confused.

    The R (and before it, S) internals are single-threaded, and will almost surely remain single-threaded. As I understand it, Duncan Temple Lang's PhD work was about overcoming this, and if he can't do it...

    That said, there are pockets of multi-threadedness:

    • First off, whenever you make external calls, and with proper locking, you can go multi-threaded. That is what the BLAS libraries MKL, Goto/Open BLAS, Atlas (if built multithreaded), ... all offer. Revo R "merely" ships with (Intel's) MKL as Intel happens to be a key Revo investor

    • If you are careful about what you do, you can use OpenMP (a compiler extension for multi-threading). This started with Luke Tierney's work on pnmath and pnmath0 (which used to be experimental / external packages) and has since been coming into R itself, slowly but surely.

    • Next, in a multicore world, and on the right operating system, you can always fork(). That is what package multicore pioneered and which package parallel now carries on.

    • Last but not least there is the network / RPC route with MPI used by packages like Rmpi, snow, parallel, ... and covered in HPC introductions.

提交回复
热议问题