makeForkCluster 在 Unix 上创建一个套接字集群。

huangapple go评论60阅读模式
英文:

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"
英文:
> 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?

答案1

得分: 0

parallel::makeForkCluster() 设置分叉并行进程:

> 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"

以及

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

[[2]]
[1] TRUE
英文:

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

&gt; cluster &lt;- parallel::makeForkCluster(2L)
&gt; cluster
socket cluster with 2 nodes on host &#39;localhost&#39;
&gt; str(cluster)
List of 2
 $ :List of 3
  ..$ con : &#39;sockconn&#39; int 4
  .. ..- attr(*, &quot;conn_id&quot;)=&lt;externalptr&gt; 
  ..$ host: chr &quot;localhost&quot;
  ..$ rank: int 1
  ..- attr(*, &quot;class&quot;)= chr [1:2] &quot;forknode&quot; &quot;SOCK0node&quot;
 $ :List of 3
  ..$ con : &#39;sockconn&#39; int 5
  .. ..- attr(*, &quot;conn_id&quot;)=&lt;externalptr&gt; 
  ..$ host: chr &quot;localhost&quot;
  ..$ rank: int 2
  ..- attr(*, &quot;class&quot;)= chr [1:2] &quot;forknode&quot; &quot;SOCK0node&quot;
 - attr(*, &quot;class&quot;)= chr [1:2] &quot;SOCKcluster&quot; &quot;cluster&quot;

and

&gt; parallel::clusterEvalQ(cluster, { parallelly::isForkedChild() })
[[1]]
[1] TRUE

[[2]]
[1] TRUE

huangapple
  • 本文由 发表于 2023年5月11日 00:08:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/76220577.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定