audrey-b / sims

An R package to simulate data from JAGS or R Code
https://poissonconsulting.github.io/sims/
Other
1 stars 2 forks source link

explore options for controlling numbers of parallel cores #10

Closed joethorley closed 5 years ago

audrey-b commented 5 years ago

I would suggest the following:

parallel: An integer specifying the number of CPU cores to use for generating the datasets in parallel. Defaul is 1 (not parallel).

That is because one night not want to use all the cores on a cluster if they have other things running. So I think they should have the option of how many to allocate. They could also specify parallel = detectCores() to use all cores (that's a function from the parallel package).

joethorley commented 5 years ago

Good idea

joethorley commented 5 years ago

I've implemented the following approach because its simple and well tested and the user can control the number of cores through registerDoParallel()

To generate simulations in parallel:

1) Ensure plyr and doParallel are installed using `install.packages(c("plyr", "doParallel"))`.
2) Register a parallel backend using `doParallel::registerDoParallel(n)`
where `n` is the number of cores you want it to use.
3) Set `parallel = TRUE` in the call to `sims_simulate()`.

I've renamed the issue to explore options for controlling numbers of parallel cores.

joethorley commented 5 years ago

I'm closing as I'm happy with the functionality ie the user can control through the cluster size - I'm not just not sure of situations where a user would want to use say half the cores?

joethorley commented 5 years ago

I've switched to the use of the futures package - I think this is an improvement.