On 27 November 2015 at 19:48, Guillaume Chapron wrote: | Has anyone written a package with a C code that uses R's RNG but in a multi-threaded way (e.g. to parallelize Monte Carlo simulations)? I do not have the knowledge to figure out myself how to solved this and would need to see an example.
To the best of my knowledge you cannot do thatas the RNG writes state back, so you would have interaction between multiple threads and R itself --- which is almost surely going to end in tears. Multithreading is fine with proper mutexes, and/or via OpenMP, but keep your data in non-R data structures and stau away from R while you multithread. Dirk -- http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org ______________________________________________ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel