Skip to content

Commit cc700c6

Browse files
author
Felipe Tome
committed
Revert to fc1ae09, keep Sch.jl changes
1 parent 4f97dc2 commit cc700c6

13 files changed

Lines changed: 462 additions & 981 deletions

File tree

Project.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
1313
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
1414
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1515
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
16-
MPIPreferences = "3da0fdf6-3ccc-4f1b-acd9-58baa6c99267"
1716
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
1817
MemPool = "f9f48841-c794-520a-933b-121f7ba6ed94"
1918
NextLA = "d37ed344-79c4-486d-9307-6d11355a15a3"
@@ -79,7 +78,6 @@ Graphs = "1"
7978
JSON3 = "1"
8079
KernelAbstractions = "0.9"
8180
MPI = "0.20.22"
82-
MPIPreferences = "0.1.11"
8381
MacroTools = "0.5"
8482
MemPool = "0.4.12"
8583
Metal = "1.1"

src/array/alloc.jl

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ function partition(p::AbstractBlocks, dom::ArrayDomain)
7070
map(_cumlength, map(length, indexes(dom)), p.blocksize))
7171
end
7272

73-
function allocate_array(f, ::Type{T}, idx, sz::NTuple{N,Int})::Array{T,N} where {T,N}
73+
function allocate_array(f, T, idx, sz)
7474
new_f = allocate_array_func(task_processor(), f)
7575
return new_f(idx, T, sz)
7676
end
77-
function allocate_array(f, ::Type{T}, sz::NTuple{N,Int})::Array{T,N} where {T,N}
77+
function allocate_array(f, T, sz)
7878
new_f = allocate_array_func(task_processor(), f)
7979
return new_f(T, sz)
8080
end
@@ -189,15 +189,8 @@ function Base.view(A::AbstractArray{T,N}, p::Blocks{N}; space=default_memory_spa
189189
d = ArrayDomain(Base.index_shape(A))
190190
dc = partition(p, d)
191191
# N.B. We use `tochunk` because we only want to take the view locally, and
192-
# taking views should be very fast.
193-
# Per-chunk space for DArray: use each chunk's owner so tochunk on owner uses
194-
# local_rank == space.rank and registers refs correctly (fixes MPI aliasing).
195-
if A isa DArray && size(A.chunks) == size(dc)
196-
chunks = [@with(MPI_UID => eager_next_id(), tochunk(view(A, x.indexes...),
197-
(c = A.chunks[I]; c isa Chunk ? memory_space(c) : space))) for (I, x) in pairs(IndexCartesian(), dc)]
198-
else
199-
chunks = [@with(MPI_UID => eager_next_id(), tochunk(view(A, x.indexes...), space)) for x in dc]
200-
end
192+
# taking views should be very fast
193+
chunks = [@with(MPI_UID => eager_next_id(), tochunk(view(A, x.indexes...), space)) for x in dc]
201194
return DArray(T, d, dc, chunks, p)
202195
end
203196
Base.view(A::AbstractArray, ::AutoBlocks) =

src/array/copy.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@ function darray_copyto!(B::DArray{TB,NB}, A::DArray{TA,NA}, Binds=parentindices(
8484

8585
Dagger.spawn_datadeps() do
8686
for Bidx in Bci
87-
accel = current_acceleration()
88-
if accel isa MPIAcceleration
89-
service_aliasing_requests(accel.comm)
90-
end
9187
Bpart = B.chunks[Bidx]
9288
Bsd_global_raw = padNmax(Bsd_all[Bidx])
9389
Bsd_global_shifted = shift_ranges(Bsd_global_raw, Binds_offset)

src/array/darray.jl

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -582,29 +582,26 @@ DVector(A::AbstractVector{T}, ::AutoBlocks, assignment::AssignmentType{1} = :arb
582582
DMatrix(A::AbstractMatrix{T}, ::AutoBlocks, assignment::AssignmentType{2} = :arbitrary) where T = DMatrix(A, auto_blocks(A), assignment)
583583
DArray(A::AbstractArray, ::AutoBlocks, assignment::AssignmentType = :arbitrary) = DArray(A, auto_blocks(A), assignment)
584584

585-
struct AllocateUndef{S} end
586-
(::AllocateUndef{S})(T, dims::Dims{N}) where {S,N} = Array{S,N}(undef, dims)
587-
588-
function DArray{T,N}(::UndefInitializer, dist::Blocks{N}, dims::NTuple{N,Int}; assignment::AssignmentType{N} = :arbitrary) where {T,N}
589-
domain = ArrayDomain(map(x->1:x, dims))
585+
@warn "Add assignment to undef initializer" maxlog=1
586+
function DArray{T,N}(::UndefInitializer, dims::NTuple{N,Int}) where {T,N}
587+
dist = auto_blocks(dims)
588+
return DArray{T,N}(undef, dist, dims...)
589+
end
590+
function DArray{T,N}(::UndefInitializer, dist::Blocks{N}, dims::NTuple{N,Int}) where {T,N}
591+
domain = ArrayDomain(ntuple(i->1:dims[i], N))
590592
subdomains = partition(dist, domain)
591-
a = AllocateArray(T, AllocateUndef{T}(), false, domain, subdomains, dist, assignment)
592-
return _to_darray(a)
593-
end
594-
DArray{T,N}(::UndefInitializer, dist::Blocks{N}, dims::Vararg{Int,N}; assignment::AssignmentType{N} = :arbitrary) where {T,N} =
595-
DArray{T,N}(undef, dist, (dims...,); assignment)
596-
DArray{T,N}(::UndefInitializer, dims::NTuple{N,Int}; assignment::AssignmentType{N} = :arbitrary) where {T,N} =
597-
DArray{T,N}(undef, auto_blocks(dims), dims; assignment)
598-
DArray{T,N}(::UndefInitializer, dims::Vararg{Int,N}; assignment::AssignmentType{N} = :arbitrary) where {T,N} =
599-
DArray{T,N}(undef, auto_blocks((dims...,)), (dims...,); assignment)
600-
DArray{T}(::UndefInitializer, dist::Blocks{N}, dims::NTuple{N,Int}; assignment::AssignmentType{N} = :arbitrary) where {T,N} =
601-
DArray{T,N}(undef, dist, dims; assignment)
602-
DArray{T}(::UndefInitializer, dist::Blocks{N}, dims::Vararg{Int,N}; assignment::AssignmentType{N} = :arbitrary) where {T,N} =
603-
DArray{T,N}(undef, dist, (dims...,); assignment)
604-
DArray{T}(::UndefInitializer, dims::NTuple{N,Int}; assignment::AssignmentType{N} = :arbitrary) where {T,N} =
605-
DArray{T,N}(undef, auto_blocks(dims), dims; assignment)
606-
DArray{T}(::UndefInitializer, dims::Vararg{Int,N}; assignment::AssignmentType{N} = :arbitrary) where {T,N} =
607-
DArray{T,N}(undef, auto_blocks((dims...,)), (dims...,); assignment)
593+
tasks = Array{DTask,N}(undef, size(subdomains)...)
594+
Dagger.spawn_datadeps() do
595+
for (i, x) in enumerate(subdomains)
596+
tasks[i] = Dagger.@spawn allocate_array_undef(T, size(x))
597+
end
598+
end
599+
return DArray(T, domain, subdomains, tasks, dist)
600+
end
601+
DArray{T,N}(::UndefInitializer, dims::Vararg{Int,N}) where {T,N} =
602+
DArray{T,N}(undef, auto_blocks((dims...,)), (dims...,))
603+
DArray{T,N}(::UndefInitializer, dist::Blocks{N}, dims::Vararg{Int,N}) where {T,N} =
604+
DArray{T,N}(undef, dist, (dims...,))
608605

609606
function Base.:(==)(x::ArrayOp{T,N}, y::AbstractArray{S,N}) where {T,S,N}
610607
collect(x) == y

0 commit comments

Comments
 (0)