Issue with OffsetArrays

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

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
julia

调研方向

先从失败的 OffsetArray 和 SparseArrays 复现开始,然后阅读 DistributedArrays/src/darray.jl 中 empty_localpart 附近的代码,以及堆栈跟踪中显示的 DArray 构造函数。确定这种交互应当受到支持,还是应记录为不兼容,并添加一个能够记录预期行为的回归测试或文档。

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

描述

I was getting nervous about the communication costs of being imprecise with communications outside of the localpart of the array, so I figured I'd build a halo exchange system by combining OffsetArrays and DistributedArrays.

I intended for that to look like the following, where each array has a 4x4 block of purely local data and a surrounding 1-cell halo to cache remote data pulled using DistributedArrays.

@everywhere using DistributedArrays
@everywhere using OffsetArrays

r1  = @spawnat 2 OffsetArray(zeros(6,6), 0:5, 0:5)
r2  = @spawnat 3 OffsetArray(zeros(6,6), 0:5, 0:5)
r3  = @spawnat 4 OffsetArray(zeros(6,6), 0:5, 0:5)
r4  = @spawnat 5 OffsetArray(zeros(6,6), 0:5, 0:5)
ras = [r1 r2; r3 r4]
D   = DArray(ras)

Unfortunately, when I try to run this, I get:

julia> D   = DArray(ras)
ERROR: MethodError: no method matching OffsetArray{Float64,2,Array{Float64,2}}(::Array{Float64,2})
Closest candidates are:
  OffsetArray{Float64,2,Array{Float64,2}}(::Any, ::Any) where {T, N, AA<:AbstractArray} at /home/rick/.julia/packages/OffsetArrays/ICRTb/src/OffsetArrays.jl:10
Stacktrace:
 [1] empty_localpart(::Type, ::Int64, ::Type) at /home/rick/.julia/packages/DistributedArrays/XV7NS/src/darray.jl:66
 [2] macro expansion at ./task.jl:264 [inlined]
 [3] macro expansion at /home/rick/.julia/packages/DistributedArrays/XV7NS/src/darray.jl:84 [inlined]
 [4] macro expansion at ./task.jl:244 [inlined]
 [5] DArray(::Tuple{Int64,Int64}, ::Array{Future,2}, ::Tuple{Int64,Int64}, ::Array{Int64,2}, ::Array{Tuple{UnitRange{Int64},UnitRange{Int64}},2}, ::Array{Array{Int64,1},1}) at /home/rick/.julia/packages/DistributedArrays/XV7NS/src/darray.jl:82
 [6] macro expansion at ./task.jl:266 [inlined]
 [7] macro expansion at /home/rick/.julia/packages/DistributedArrays/XV7NS/src/darray.jl:194 [inlined]
 [8] macro expansion at ./task.jl:244 [inlined]
 [9] DArray(::Array{Future,2}) at /home/rick/.julia/packages/DistributedArrays/XV7NS/src/darray.jl:192
 [10] top-level scope at none:0

which doesn't seem like an issue with OffsetArrays because using SparseArrays in an analogous way produces no problems:

@everywhere using DistributedArrays
@everywhere using SparseArrays

r1  = @spawnat 2 sparse(zeros(6,6))
r2  = @spawnat 3 sparse(zeros(6,6))
r3  = @spawnat 4 sparse(zeros(6,6))
r4  = @spawnat 5 sparse(zeros(6,6))
ras = [r1 r2; r3 r4]
D   = DArray(ras)

Sadly, I'm not familiar enough with Julia to know why the interaction of OffsetArrays and DistributedArrays is problematic.

I've got:

  [aaf54ef3] DistributedArrays v0.5.1
  [6fe1bfb0] OffsetArrays v0.8.1
主要语言
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 摘要。