Skip to content

Commit bc31263

Browse files
committed
Add allowscalar functionality to disable scalar indexing.
Various other fixes
1 parent 76d8be4 commit bc31263

File tree

11 files changed

+248
-231
lines changed

11 files changed

+248
-231
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Distributed Arrays will only work on Julia v0.4.0 or later.
1212
`DArray`s have been removed from Julia Base library in v0.4 so it is now necessary to import the `DistributedArrays` package on all spawned processes.
1313

1414
```julia
15-
@everywhere using DistributedArrays
15+
using DistributedArrays
1616
```
1717

1818
Distributed Arrays
@@ -76,12 +76,12 @@ Indexing via symbols is used for this, specifically symbols `:L`,`:LP`,`:l`,`:lp
7676
are all equivalent. For example, `d[:L]` returns the localpart of `d`
7777
while `d[:L]=v` sets `v` as the localpart of `d`.
7878

79-
* `localindexes(a::DArray)` gives a tuple of the index ranges owned by the
79+
* `localindices(a::DArray)` gives a tuple of the index ranges owned by the
8080
local process.
8181

8282
* `convert(Array, a::DArray)` brings all the data to the local process.
8383

84-
Indexing a `DArray` (square brackets) with ranges of indexes always
84+
Indexing a `DArray` (square brackets) with ranges of indices always
8585
creates a `SubArray`, not copying any data.
8686

8787

@@ -205,7 +205,7 @@ seen in this simple example:
205205
```julia
206206
julia> addprocs(8);
207207

208-
julia> @everywhere using DistributedArrays
208+
julia> using DistributedArrays
209209

210210
julia> A = fill(1.1, (100,100));
211211

@@ -227,7 +227,7 @@ Garbage Collection and DArrays
227227
------------------------------
228228

229229
When a DArray is constructed (typically on the master process), the returned DArray objects stores information on how the
230-
array is distributed, which procesor holds which indexes and so on. When the DArray object
230+
array is distributed, which procesor holds which indices and so on. When the DArray object
231231
on the master process is garbage collected, all particpating workers are notified and
232232
localparts of the DArray freed on each worker.
233233

@@ -317,10 +317,10 @@ Example
317317
This toy example exchanges data with each of its neighbors `n` times.
318318

319319
```
320-
using DistributedArrays
320+
using Distributed
321321
addprocs(8)
322-
@everywhere importall DistributedArrays
323-
@everywhere importall DistributedArrays.SPMD
322+
using DistributedArrays
323+
using DistributedArrays.SPMD
324324
325325
d_in=d=DArray(I->fill(myid(), (map(length,I)...)), (nworkers(), 2), workers(), [nworkers(),1])
326326
d_out=ddata()

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
julia 0.6
1+
julia 0.7-beta
22
Primes

src/DistributedArrays.jl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,20 @@ __precompile__()
22

33
module DistributedArrays
44

5-
importall Base
5+
using Distributed
6+
using Serialization
7+
using LinearAlgebra
8+
9+
import Base: +, -, *, div, mod, rem, &, |, xor
610
import Base.Callable
7-
import Base.BLAS: axpy!
11+
import LinearAlgebra.BLAS: axpy!
812

9-
using Primes
10-
using Primes: factor
13+
import Primes
14+
import Primes: factor
1115

1216
# DArray exports
1317
export DArray, SubDArray, SubOrDArray, @DArray
14-
export dzeros, dones, dfill, drand, drandn, distribute, localpart, localindexes, ppeval
18+
export dzeros, dones, dfill, drand, drandn, distribute, localpart, localindices, ppeval
1519

1620
# non-array distributed data
1721
export ddata, gather

src/core.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ release_localpart(id::Tuple) = (delete!(registry, id); nothing)
1717
release_localpart(d) = release_localpart(d.id)
1818

1919
function close_by_id(id, pids)
20-
# @schedule println("Finalizer for : ", id)
20+
# @async println("Finalizer for : ", id)
2121
global refs
2222
@sync begin
2323
for p in pids
@@ -31,10 +31,10 @@ function close_by_id(id, pids)
3131
nothing
3232
end
3333

34-
function close(d::DArray)
35-
# @schedule println("close : ", d.id, ", object_id : ", object_id(d), ", myid : ", myid() )
34+
function Base.close(d::DArray)
35+
# @async println("close : ", d.id, ", object_id : ", object_id(d), ", myid : ", myid() )
3636
if (myid() == d.id[1]) && d.release
37-
@schedule close_by_id(d.id, d.pids)
37+
@async close_by_id(d.id, d.pids)
3838
d.release = false
3939
end
4040
nothing
@@ -55,7 +55,7 @@ end
5555
5656
Get the vector of processes storing pieces of DArray `d`.
5757
"""
58-
Base.procs(d::DArray) = d.pids
58+
Distributed.procs(d::DArray) = d.pids
5959

6060
"""
6161
localpart(A)

0 commit comments

Comments
 (0)