pmap vs map for DArray?

未关闭
#7 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
文档
描述清晰度
基本清楚
活跃度
停滞
技术栈
julia

调研方向

先复现 issue 中的 drand、map 和 pmap 示例,然后在仓库中搜索 DArray、map 和 pmap 的文档或入口点。确定 pmap 在 DArray 上的预期行为,并记录其与 map 的区别,包括一个简洁的示例或限制(如果现有行为支持这一点)。

由索引模型根据 Issue 内容生成。

描述

documentation

Searching through the source for DistributedArray, it seems I'm supposed to use map instead of pmap on a DArray. Indeed, when I try to use pmap, strange things happen:

julia> testa = drand(36)
36-element DistributedArrays.DArray{Float64,1,Array{Float64,1}}:
 0.636737
 0.275769
 0.961624
 0.427848
 0.668537
 0.0215699
 0.292591
 0.487622
 0.54222
 0.579438
 0.299413
 0.0699156
 0.985861
 0.642223
 0.0108336
 0.466572
 0.134984
 0.0718047
 0.600704
 0.367337
 0.722101
 0.96763
 0.427482
 0.963513
 0.467348
 0.987774
 0.773584
 0.531576
 0.0155698
 0.383172
 0.0347603
 0.299581
 0.0226568
 0.687901
 0.22271
 0.238291

julia> testb = drand(36)
36-element DistributedArrays.DArray{Float64,1,Array{Float64,1}}:
 0.933919
 0.445692
 0.0028197
 0.722083
 0.088373
 0.820338
 0.71782
 0.972424
 0.623399
 0.157076
 0.657007
 0.0753378
 0.712683
 0.303925
 0.591726
 0.320129
 0.5457
 0.00830437
 0.0753483
 0.973917
 0.171903
 0.291315
 0.875653
 0.0619788
 0.53868
 0.069952
 0.534305
 0.798335
 0.923633
 0.239445
 0.748613
 0.00554521
 0.650063
 0.770877
 0.237519
 0.414616

julia> pmap( (x) -> (x*x), testa)
175-element Array{Any,1}:
 0.405433
 0.405433
 0.405433
 0.405433
 0.405433
 0.405433
 0.0760486
 0.0760486
 0.0760486
 0.0760486
 0.0760486
 0.0760486
 0.92472
 0.92472
 0.92472
 0.183054
 0.183054
 0.183054
 0.92472
 0.183054
 0.183054
 0.183054
 0.446942
 0.446942
 0.446942
 0.446942
 0.000465259
 0.446942
 ⋮
 0.00120828
 0.00120828
 0.00120828
 0.00120828
 0.00120828
 0.00120828
 0.0897485
 0.0897485
 0.0897485
 0.0897485
 0.0897485
 0.000513332
 0.000513332
 0.473207
 0.000513332
 0.000513332
 0.473207
 0.473207
 0.473207
 0.0495998
 0.473207
 0.0495998
 0.0495998
 0.0495998
 0.0567826
 0.0567826
 0.0567826
 0.0567826

julia> map( (x) -> (x*x), testb)
36-element DistributedArrays.DArray{Float64,1,Array{Float64,1}}:
 0.872205
 0.198641
 7.95072e-6
 0.521403
 0.00780978
 0.672954
 0.515266
 0.945609
 0.388626
 0.0246728
 0.431658
 0.00567578
 0.507917
 0.0923703
 0.35014
 0.102483
 0.297789
 6.89625e-5
 0.00567737
 0.948514
 0.0295506
 0.0848642
 0.766769
 0.00384137
 0.290177
 0.00489328
 0.285482
 0.637339
 0.853098
 0.0573337
 0.560421
 3.07494e-5
 0.422581
 0.594251
 0.0564152
 0.171907

(Sorry for how long that was!)

Yet intuitively, I would have expected pmap to work like map does on a distributed array. I'm fine with my intuition being wrong here, but should there be a note in the documentation to use map, and not pmap? What is the expected behaviour of pmap on a DArray?

主要语言
Julia
星标
205
派生
34
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

JuliaParallel/DistributedArrays.jl 的其他 Issue

查看 JuliaParallel/DistributedArrays.jl 的全部 Issue

相似的 Issue

更多 Julia Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。