title: How to run permutations using mclapply in a reproducible way regardless of number of threads and OS?
body: <p>Is is possible to run some permutation-based function using mclapply in a reproducible way regardless of number of threads and OS?<br>
  Below is a toy example.  Hashing of the resulting list of permutated vectors is just for convenience of comparing the results.  I tried different <code>RNGkind</code> ("L'Ecuyer-CMRG"), different settings for <code>mc.preschedule</code> and <code>mc.set.seed</code>. So far no luck to make them all identical.</p>
  
  <pre><code>library("parallel")
  library("digest")
  
  set.seed(1)
  m &lt;- mclapply(1:10, function(x) sample(1:10),
                mc.cores=2, mc.set.seed = F)
  digest(m, 'crc32')
  
  set.seed(1)
  m &lt;- mclapply(1:10, function(x) sample(1:10),
                mc.cores=4, mc.set.seed = F)
  digest(m, 'crc32')
  
  set.seed(1)
  m &lt;- mclapply(1:10, function(x) sample(1:10),
                mc.cores=2, mc.set.seed = F)
  digest(m, 'crc32')
  
  set.seed(1)
  m &lt;- mclapply(1:10, function(x) sample(1:10),
                mc.cores=1, mc.set.seed = F)
  digest(m, 'crc32')
  
  set.seed(1)
  m &lt;- lapply(1:10, function(x) sample(1:10))
  digest(m, 'crc32') # this is equivalent to what I get on Windows.
  </code></pre>
  
  <p><code>sessionInfo()</code> just in case:</p>
  
  <pre><code>&gt; sessionInfo()
  R version 3.2.0 (2015-04-16)
  Platform: x86_64-apple-darwin13.4.0 (64-bit)
  Running under: OS X 10.9.5 (Mavericks)
  
  locale:
  [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
  
  attached base packages:
  [1] parallel  stats     graphics  grDevices utils     datasets  methods   base     
  
  other attached packages:
  [1] digest_0.6.8
  
  loaded via a namespace (and not attached):
  [1] tools_3.2.0
  </code></pre>