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

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

makeForkCluster creates a socket cluster on Unix

问题

  1. > library(parallel)
  2. > cluster = makeForkCluster(2)
  3. > cluster
  4. socket cluster with 2 nodes on host localhost
  5. > rm(cluster)
  6. > .Platform$OS.type
  7. [1] "unix"
英文:
  1. > library(parallel)
  2. > cluster = makeForkCluster(2)
  3. > cluster
  4. socket cluster with 2 nodes on host localhost
  5. > rm(cluster)
  6. > .Platform$OS.type
  7. [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() 设置分叉并行进程:

  1. > cluster <- parallel::makeForkCluster(2L)
  2. > cluster
  3. socket cluster with 2 nodes on host 'localhost'
  4. > str(cluster)
  5. List of 2
  6. $ :List of 3
  7. ..$ con : 'sockconn' int 4
  8. .. ..- attr(*, "conn_id")=<externalptr>
  9. ..$ host: chr "localhost"
  10. ..$ rank: int 1
  11. ..- attr(*, "class")= chr [1:2] "forknode" "SOCK0node"
  12. $ :List of 3
  13. ..$ con : 'sockconn' int 5
  14. .. ..- attr(*, "conn_id")=<externalptr>
  15. ..$ host: chr "localhost"
  16. ..$ rank: int 2
  17. ..- attr(*, "class")= chr [1:2] "forknode" "SOCK0node"
  18. - attr(*, "class")= chr [1:2] "SOCKcluster" "cluster"

以及

  1. > parallel::clusterEvalQ(cluster, { parallelly::isForkedChild() })
  2. [[1]]
  3. [1] TRUE
  4. [[2]]
  5. [1] TRUE
英文:

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

  1. &gt; cluster &lt;- parallel::makeForkCluster(2L)
  2. &gt; cluster
  3. socket cluster with 2 nodes on host &#39;localhost&#39;
  4. &gt; str(cluster)
  5. List of 2
  6. $ :List of 3
  7. ..$ con : &#39;sockconn&#39; int 4
  8. .. ..- attr(*, &quot;conn_id&quot;)=&lt;externalptr&gt;
  9. ..$ host: chr &quot;localhost&quot;
  10. ..$ rank: int 1
  11. ..- attr(*, &quot;class&quot;)= chr [1:2] &quot;forknode&quot; &quot;SOCK0node&quot;
  12. $ :List of 3
  13. ..$ con : &#39;sockconn&#39; int 5
  14. .. ..- attr(*, &quot;conn_id&quot;)=&lt;externalptr&gt;
  15. ..$ host: chr &quot;localhost&quot;
  16. ..$ rank: int 2
  17. ..- attr(*, &quot;class&quot;)= chr [1:2] &quot;forknode&quot; &quot;SOCK0node&quot;
  18. - attr(*, &quot;class&quot;)= chr [1:2] &quot;SOCKcluster&quot; &quot;cluster&quot;

and

  1. &gt; parallel::clusterEvalQ(cluster, { parallelly::isForkedChild() })
  2. [[1]]
  3. [1] TRUE
  4. [[2]]
  5. [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:

确定