Is there an efficient way to parallelize mapply?

后端 未结 3 1421
被撕碎了的回忆
被撕碎了的回忆 2021-01-05 12:22

I have many rows and on every row I compute the uniroot of a non-linear function. I have a quad-core Ubuntu machine which hasn\'t stopped running my code for two days now. N

3条回答
  •  鱼传尺愫
    2021-01-05 12:43

    it's an old topic but fyi you now have parallel::mcmapply doc is here. don't forget to set mc.cores in the options. I usually use mc.cores=parallel::detectCores()-1 to let one cpu free for OS operations.

    x4 <- mcmapply(get_uniroot, df$P, df$B0, df$CF1, df$CF2, df$CF3,mc.cores=parallel::detectCores()-1)

提交回复
热议问题