makeForkCluster creates a socket cluster on Unix

Advertisements
> 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 :

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

Leave a ReplyCancel reply