-
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added ddata and spmd modes #112
Conversation
Some quick questions and comments:
This definitely seems easier than doing remotecalls for doing the same bit of work. |
Yes.
It will need to be
I don't see how. Even in regular MPI programs the
I would rather not. It makes it clear that the |
Why not put all the spmd calls in an SPMD submodule in that case, and say |
That is a good suggestion. |
Maybe this is only for experimentation, but this package is a strange place to have the SPMD mode and messaging API. |
SPMD mode is not very useful without DArray / DData. In regular MPI the entire program runs in SPMD mode. Here only a function / code block runs SPMD while modifying distributed data created previously. If folks see value in this I would rather rename DistributedArrays.jl to Distributed.jl and work towards making it the default way to do parallel programming in Julia. |
Using a different name for the whole thing is a good idea - but I do not like Distributed.jl. Maybe Parallel.jl, since we do expect this to become a standard way to do parallel computing in julia. |
As we spoke, we should put some thought into composability of nested spmd mode. While not necessary to be super fancy, it should do something reasonable. |
Nice, I like it!
|
The key difference Amit explained was doing slightly different things with indexing and assignment, specifically but that could easily have been something like |
Otherwise it is close enough to a distributed vector. |
Cool, I've been working on something similar. In my case, I wanted an spmd style interface for distributing a bunch of
I'll note that I don't really like the naming conventions, but a |
To clarify: in this code or in the example code you posted? |
Sorry, in the example code I posted. |
743e131
to
646dde8
Compare
Updated.
from the README.
Implementation changes:
|
646dde8
to
fbd7778
Compare
fbd7778
to
4212abe
Compare
I'll merge this in a day or two. Can refine it further over the next few weeks. Docstrings can be added once the API is more or less stable. |
Introduces
DData
and support for SPMD modes. I have just copied the README changes below. Please also take a look attest/ddata.jl
andtest/spmd.jl
for more examples on usage.DData (Distributed non-array data)
Sometimes we just want to distribute non-array type items across workers. This is where a
DData
comes in handy.Like
DArrays
s, but without the array operations and assumptions. ADData
object can be constructed in a variety of waysDData{T}(init::Function, pids=workers()
- executesinit(pididx)
on all specified workers. The typeT
must be specifiedand must match the return type of
init
.pididx
is the index of the worker pid into thepids
array.DData{T}(data::Array, pids=workers(); mode=:copy|:distribute)
- distributesdata
onto specified workers.- Default
mode
is:copy
, which copies the entiredata
onto allpids
.- With
mode=:distribute
,data
is partitioned across allpids
.data
must be an array type, andlength(data)
must be a multiple of
length(pids)
. Iflength(data)
equalslength(pids)
andT
is a non-array type,individual items are distributed, else the localparts are appropriate array segments of
data
.A couple of helper functions are
gather{T}(d::DData{T})
returns an Array{T} consisting of all distributed elements ofd
Given a
DData
objectd
,d[]
returns the localpart on a worker.d[i]
returns thelocalpart
on the ith worker that
d
is distributed over.SPMD Mode (An MPI Style SPMD mode with MPI like primitives)
We can easily run the same block of code on all workers in an SPMD mode using the
@everywhere
macro orthe
spmd
function.For example:
or
The following primitives can be used in SPMD mode.
s_sendto(pid, data; tag=nothing)
- sendsdata
topid
s_recvfrom(pid; tag=nothing)
- receives data frompid
s_recvfrom_any(; tag=nothing)
- receives data from anypid
s_barrier(;pids=procs(), tag=nothing)
- all tasks wait and then proceeeds_bcast(data, pid; tag=nothing, pids=procs())
- broadcasts the same data overpids
frompid
s_scatter(x, pid; tag=nothing, pids=procs())
- distributesx
overpids
frompid
s_gather(x, pid; tag=nothing, pids=procs())
- collects data frompids
onto workerpid
spmd(f, args...; pids=procs())
- Executesf(args...)
on allpids
Tag
tag
should be used to differentiate between consecutive calls of the same type, consecutives_bcast
calls.NOTE: Instantiating
DArray
orDData
within an SPMD function/block will result inN
copies of thethe object. Similarly calling
@everywhere
orspmd
from within a an SPMD function/block will result inN*N
parallelruns. In SPMD mode the function/block is executed concurrently on all workers.
Using DData, SPMD mode and DArrays together
An example: