Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Parallel version of `map()`

I have a function that takes multiple arguments.

my_function <- function(list_of_vectors, list_of_scalars){
 ....
return(list)
}

I want to use map() over my function but using a parallel call that would use multicores. my_function() is very computationally expensive, and I need to call it to create output for over 1000 points. ( list_of_vectors is a list of 1000 vectors and list_of_scalars is a list of 1000 scalars)

Is there a mcmap() equivalent or any other formulation ? I had a look at other threads but none solved my issue.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can use future_map() from the furrr package as a drop-in replacement.

This is a very flexible function; how it distributes your computation will depend on a previous call to future::plan() (furrr is built on top of the future package), e.g.

future::plan(multicore, workers = 4)
future_map(...)

to run your job on 4 cores on the same machine.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading