I’d like to be able to get the local part via global indexing (without resorting to :L
) in order to facilitate portability with SharedArrays.
How can I fix the following:
using Test,Distributed,DistributedArrays
nwork = 5
while length(workers()) < nwork
addprocs(1)
end
@everywhere using DistributedArrays
@testset "explicit local part" begin
a = @DArray [i+j for i = 1:5, j = 1:5]
@test all(@fetchfrom 2 a[1:5] .== @fetchfrom 2 a[:L])
@test all(@fetchfrom 2 a[:L][1:3] .== @fetchfrom 2 a[1:5][1:3])
end
Output:
julia> @testset "explicit local part" begin
a = @DArray [i+j for i = 1:5, j = 1:5]
@test all(@fetchfrom 2 a[1:5] .== @fetchfrom 2 a[:L])
@test all(@fetchfrom 2 a[:L][1:3] .== @fetchfrom 2 a[1:5][1:3])
end
explicit local part: Error During Test at REPL[53]:4
Test threw exception
Expression: all(#= REPL[53]:4 =# @fetchfrom(2, (a[:L])[1:3] .== #= REPL[53]:4 =# @fetchfrom(2, (a[1:5])[1:3])))
On worker 2:
setindex! not defined for DArray{Int64,1,Array{Int64,1}}
error at ./error.jl:42
error_if_canonical_setindex at ./abstractarray.jl:1163
setindex! at ./abstractarray.jl:1152 [inlined]
macro expansion at ./multidimensional.jl:772 [inlined]
macro expansion at ./cartesian.jl:64 [inlined]
macro expansion at ./multidimensional.jl:767 [inlined]
_unsafe_getindex! at ./multidimensional.jl:762
_unsafe_getindex at ./multidimensional.jl:757
_getindex at ./multidimensional.jl:743
getindex at ./abstractarray.jl:1060 [inlined]
#88 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Distributed/src/macros.jl:149 [inlined]
run_work_thunk at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Distributed/src/process_messages.jl:79
#remotecall_fetch#142 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Distributed/src/remotecall.jl:379 [inlined]
remotecall_fetch at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Distributed/src/remotecall.jl:379 [inlined]
#remotecall_fetch#146 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Distributed/src/remotecall.jl:421 [inlined]
remotecall_fetch at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Distributed/src/remotecall.jl:421 [inlined]
#87 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Distributed/src/macros.jl:149
#106 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Distributed/src/process_messages.jl:294
run_work_thunk at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Distributed/src/process_messages.jl:79
macro expansion at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Distributed/src/process_messages.jl:294 [inlined]
#105 at ./task.jl:356
Stacktrace:
[1] #remotecall_fetch#143 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Distributed/src/remotecall.jl:394 [inlined]
[2] remotecall_fetch(::Function, ::Distributed.Worker) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Distributed/src/remotecall.jl:386
[3] remotecall_fetch(::Function, ::Int64; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Distributed/src/remotecall.jl:421
[4] remotecall_fetch(::Function, ::Int64) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Distributed/src/remotecall.jl:421
[5] top-level scope at REPL[53]:4
[6] top-level scope at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Test/src/Test.jl:1115
[7] top-level scope at REPL[53]:2
Test Summary: | Pass Error Total
explicit local part | 1 1 2
ERROR: Some tests did not pass: 1 passed, 0 failed, 1 errored, 0 broken.