Matrix-vector multiplication fails when DArray is unevenly distributed

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

还没有人认领这个 Issue。

评估

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

调研方向

使用 julia -p 2 重现 test.jl 中的示例,然后检查 /src/linalg.jl:279 附近的输出数组构造,以及 /src/linalg.jl:209 附近失败的验证。跟踪不均匀的第一维分块是如何表示的,并验证在 2x4 和 3x4 分布下 A*x 能够成功完成。

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

描述

The following example creates DArrays A and x, then attempts A*x. The only unusual bit is that A is distributed unevenly.

# test.jl

using Distributed, DistributedArrays
@everywhere using Distributed, DistributedArrays

A2 = @spawnat 2 ones((2,4))           # 2x4 array
A3 = @spawnat 3 ones((3,4))           # 3x4 array
A = DArray(reshape([A2,A3], (2,1)))   # 5x4 array

x = dones((4,1))                      # 4x1 array

A*x

Launching the REPL with julia -p 2 including test.jl yields

julia> include("test.jl")
ERROR: LoadError: ArgumentError: cuts of the first dimension of the output matrix must match cuts of dimension 1 of the first input matrix
Stacktrace:
 [1] _matmatmul!(C::DArray{Float64, 2, Matrix{Float64}}, A::DArray{Float64, 2, Matrix{Float64}}, B::DArray{Float64, 2, Matrix{Float64}}, α::Int64, β::Int64, tA::Char)
   @ DistributedArrays ~/.julia/packages/DistributedArrays/fEM6l/src/linalg.jl:209
 [2] mul! (repeats 2 times)
   @ ~/.julia/packages/DistributedArrays/fEM6l/src/linalg.jl:262 [inlined]
 [3] *(A::DArray{Float64, 2, Matrix{Float64}}, B::DArray{Float64, 2, Matrix{Float64}})
   @ DistributedArrays ~/.julia/packages/DistributedArrays/fEM6l/src/linalg.jl:279

Looking at the source around /src/linalg.jl:279,

function Base.:*(A::DMatrix, B::AbstractMatrix)
    T = Base.promote_op(_matmul_op, eltype(A), eltype(B))
    C = DArray(I -> Array{T}(undef, map(length, I)),
            (size(A, 1), size(B, 2)),
            procs(A)[:,1:min(size(procs(A), 2), size(procs(B), 2))],
            (size(procs(A), 1), min(size(procs(A), 2), size(procs(B), 2))))
    return mul!(C, A, B)
end

I think the issue may be that creation of the output array C doesn't account for the (admittedly unusual) possibility that A is distributed in uneven chunks.

主要语言
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 摘要。