Allowing a DArray to do as standard Array does

Abierto
#202 4 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
julia

Línea de trabajo

Comienza con el MWE y la ruta distribuida de matriz-vector en src/linalg.jl, especialmente con las líneas 107 y 111 indicadas por el stack trace. Reprodúcelo con workers de Julia y compara la operación DArray con el caso de Array local; estará terminado cuando el cálculo personalizado de Foo ya no falle en los workers.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Dear All,

I'm considering the following MWE, which consists of creating a matrix and vector of a struct an doing a calculation on them. I import the relevant mathematical operators from base, and it just works. Next I addprocs and try it with DArray, and the same calculation fails. Is there a way to enable this kind of functionality? It's definitely possible that I'm barking up the wrong tree and there's a much better way of achieving this - please let me know!

using Distributed

import Base.+, Base.*, Base.zero

let
  struct Foo{T<:Number}
    x::T
  end
  Base.:+(a::Foo, b::Foo) = Foo(a.x + b.x)
  Base.:*(a::Foo, b::Foo) = Foo(a.x * b.x)
  Base.:zero(a::Foo{T}) where {T} = Foo(zero(T))
  function runlocal()
    A = [Foo(rand()) for i in 1:3, j in 1:3]
    b = [Foo(rand()) for j in 1:3]
    @show A * b
  end
  runlocal()
end

addprocs(2)
@everywhere using DistributedArrays
@everywhere let
  struct Foo{T<:Number}
    x::T
  end
  Base.:+(a::Foo, b::Foo) = Foo(a.x + b.x)
  Base.:*(a::Foo, b::Foo) = Foo(a.x * b.x)
  Base.:zero(a::Foo{T}) where {T} = Foo(zero(T))
  function rundistributed()
    A = @DArray [Foo(rand()) for i in 1:3, j in 1:3]
    b = @DArray [Foo(rand()) for j in 1:3]
    @show A * b
  end
  rundistributed()
end

Thanks,
James

Output:

ERROR: On worker 2:
MethodError: Cannot `convert` an object of type Int64 to an object of type Foo{Float64}
Closest candidates are:
  convert(::Type{T}, ::T) where T at essentials.jl:154
  Foo{Float64}(::Any) where T<:Number at REPL[6]:3 (method too new to be called from this world context.)
fill! at ./array.jl:283
#253 at /home/cookj/.julia/packages/DistributedArrays/f3HAT/src/linalg.jl:111
run_work_thunk at /home/cookj/builds/julia/usr/share/julia/stdlib/v1.0/Distributed/src/process_messages.jl:56
#remotecall_fetch#148 at /home/cookj/builds/julia/usr/share/julia/stdlib/v1.0/Distributed/src/remotecall.jl:364
remotecall_fetch at /home/cookj/builds/julia/usr/share/julia/stdlib/v1.0/Distributed/src/remotecall.jl:364
#remotecall_fetch#152 at /home/cookj/builds/julia/usr/share/julia/stdlib/v1.0/Distributed/src/remotecall.jl:406
remotecall_fetch at /home/cookj/builds/julia/usr/share/julia/stdlib/v1.0/Distributed/src/remotecall.jl:406 [inlined]
#252 at /home/cookj/.julia/packages/DistributedArrays/f3HAT/src/linalg.jl:107 [inlined]
#672 at ./asyncmap.jl:100
macro expansion at ./asyncmap.jl:235 [inlined]
#688 at ./task.jl:259
#remotecall_wait#154(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Function, ::Distributed.Worker, ::Module, ::Vararg{Any,N} where N) at /home/cookj/builds/julia/usr/share/julia/stdlib/v1.0/Distributed/src/remotecall.jl:421
remotecall_wait(::Function, ::Distributed.Worker, ::Module, ::Vararg{Any,N} where N) at /home/cookj/builds/julia/usr/share/julia/stdlib/v1.0/Distributed/src/remotecall.jl:412
#remotecall_wait#157(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Function, ::Int64, ::Module, ::Vararg{Any,N} where N) at /home/cookj/builds/julia/usr/share/julia/stdlib/v1.0/Distributed/src/remotecall.jl:433
remotecall_wait(::Function, ::Int64, ::Module, ::Vararg{Any,N} where N) at /home/cookj/builds/julia/usr/share/julia/stdlib/v1.0/Distributed/src/remotecall.jl:433
(::getfield(Distributed, Symbol("##163#165")){Module,Expr})() at ./task.jl:259

...and 2 more exception(s).

Stacktrace:
 [1] sync_end(::Array{Any,1}) at ./task.jl:226
 [2] macro expansion at ./task.jl:245 [inlined]
 [3] remotecall_eval(::Module, ::Array{Int64,1}, ::Expr) at /home/cookj/builds/julia/usr/share/julia/stdlib/v1.0/Distributed/src/macros.jl:206
 [4] top-level scope at /home/cookj/builds/julia/usr/share/julia/stdlib/v1.0/Distributed/src/macros.jl:190
Lenguaje dominante
Julia
Estrellas
205
Forks
34
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de JuliaParallel/DistributedArrays.jl

Todos los issues de JuliaParallel/DistributedArrays.jl

Issues similares

Más issues de Julia

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.