How to make R use all processors?

前端 未结 7 939
小蘑菇
小蘑菇 2020-12-04 06:46

I have a quad-core laptop running Windows XP, but looking at Task Manager R only ever seems to use one processor at a time. How can I make R use all four processors and spee

7条回答
  •  遥遥无期
    2020-12-04 07:16

    On Windows I believe the best way to do this would probably be with foreach and snow as David Smith said.

    However, Unix/Linux based systems can compute using multiple processes with the 'multicore' package. It provides a high-level function, 'mclapply', that performs a list comprehension across multiple cores. An advantage of the 'multicore' package is that each processor gets a private copy of the Global Environment that it may modify. Initially, this copy is just a pointer to the Global Environment, making the sharing of variable extremely quick if the Global Environment is treated as read-only.

    Rmpi requires that the data be explicitly transferred between R processes instead of working with the 'multicore' closure approach.

    -- Dan

提交回复
热议问题