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

makeForkCluster creates a socket cluster on Unix

> library(parallel)
> cluster = makeForkCluster(2)
> cluster
socket cluster with 2 nodes on host ‘localhost’
> rm(cluster)
> .Platform$OS.type
[1] "unix"

This behavior is the same on a Ubuntu 22 box and on a Mac. How come I can’t create a fork cluster?

>Solution :

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

parallel::makeForkCluster() does setup forked parallel processes:

> cluster <- parallel::makeForkCluster(2L)
> cluster
socket cluster with 2 nodes on host 'localhost'
> str(cluster)
List of 2
 $ :List of 3
  ..$ con : 'sockconn' int 4
  .. ..- attr(*, "conn_id")=<externalptr> 
  ..$ host: chr "localhost"
  ..$ rank: int 1
  ..- attr(*, "class")= chr [1:2] "forknode" "SOCK0node"
 $ :List of 3
  ..$ con : 'sockconn' int 5
  .. ..- attr(*, "conn_id")=<externalptr> 
  ..$ host: chr "localhost"
  ..$ rank: int 2
  ..- attr(*, "class")= chr [1:2] "forknode" "SOCK0node"
 - attr(*, "class")= chr [1:2] "SOCKcluster" "cluster"

and

> parallel::clusterEvalQ(cluster, { parallelly::isForkedChild() })
[[1]]
[1] TRUE

[[2]]
[1] TRUE
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