Skip to content

Commit

Permalink
Merge pull request #63 from bicycle1885/refactor-stage
Browse files Browse the repository at this point in the history
refactor Dagger.stage for AllocateArray
  • Loading branch information
shashi committed Jun 12, 2017
2 parents 9ea3308 + 81a6c21 commit c3e4c38
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/array/alloc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,9 @@ end
Base.@deprecate BlockPartition Blocks

function stage(ctx, a::AllocateArray)
branch = a.domain
dims = ndims(a.domain)
alloc = let eltype = a.eltype, f = a.f
_alloc(idx, sz) = f(idx,eltype, sz)
end

subdomains = a.domainchunks
thunks = similar(subdomains, Thunk)
for i=1:length(subdomains)
thunks[i] = delayed(alloc)(i, size(subdomains[i]))
end
DArray{a.eltype, dims}(a.domain, subdomains, thunks)
alloc(idx, sz) = a.f(idx, a.eltype, sz)
thunks = [delayed(alloc)(i, size(x)) for (i, x) in enumerate(a.domainchunks)]
DArray{a.eltype,ndims(a.domain)}(a.domain, a.domainchunks, thunks)
end

function Base.rand(p::Blocks, eltype::Type, dims)
Expand Down

0 comments on commit c3e4c38

Please sign in to comment.