Exercise

SOCK vs. FORK

In addition to the code in the previous exercise, we also created a FORK cluster for you.

cl.fork <- makeCluster(2, type = "FORK")

Your job is to register the two cluster objects with the preloaded doParallel package and compare results obtained with parallel foreach. How do the results differ in terms of reproducibility?

Instructions 1/3

undefined XP
    1
    2
    3
  • Register the SOCK cluster, cl.sock.
  • Replicate the following twice.
    • Set the RNG seed to 100.
    • Run a foreach() with two iterations, combining the results in a matrix by row. Run the iterations in parallel, each time calculating rnorm(3).
  • Look at the output!