Skip to content

distribute that takes procs #6

Closed
@denizyuret

Description

@denizyuret

I recommend making the interface for distribute more consistent with DArray by adding an optional procs argument. This will allow for an array distributed to a subset of the workers. A common use case is testing the performance of different numbers of workers on a task.

function distribute(a::AbstractArray, procs=workers()[1:min(nworkers(), maximum(size(a)))])
    owner = myid()
    rr = RemoteRef()
    put!(rr, a)
    d = DArray(size(a), procs) do I
        remotecall_fetch(owner, ()->fetch(rr)[I...])
    end
    # Ensure that all workers have fetched their localparts.                                                               
    # Else a gc in between can recover the RemoteRef rr                                                                    
    for chunk in d.chunks
        wait(chunk)
    end
    d
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions