Adding vs multiplying matrices with DistributedArrays

The key are the dots. The operation (+ or *) doesn’t matter. For example, even addition leads to the wrong distribution if I replace + with .+:

julia> C = A .+ A
       @fetchfrom 2 localpart(C)
2×3 Matrix{Int64}:
 4  4  4
 6  6  6

On the other hand, multiplication works fine if I preallocate and add all the dots:

julia> B .= A.*A
       @fetchfrom 2 localpart(B)
1×5 Matrix{Int64}:
 4  4  4  4  4
2 Likes