Skip to content
Snippets Groups Projects
Commit 671c2dff authored by Stephan Hilb's avatar Stephan Hilb
Browse files

issue work in nworkers()-sized batches

parent bc76b4ef
No related branches found
No related tags found
No related merge requests found
...@@ -143,37 +143,39 @@ function step!(ctx::DualTVDDState) ...@@ -143,37 +143,39 @@ function step!(ctx::DualTVDDState)
cids = alg.parallel ? [eachindex(ctx.subax)] : cids = alg.parallel ? [eachindex(ctx.subax)] :
chessboard_coloring(size(ctx.subax)) chessboard_coloring(size(ctx.subax))
for (color, ids) in enumerate(cids) for (color, ids) in enumerate(cids)
for i in ids for pids in Iterators.partition(ids, length(alg.workers))
sax = ctx.subax[i] for i in pids
sax = ctx.subax[i]
# update remaining old contribution
view(p_rem, sax...) .-= # update remaining old contribution
theta.(Ref(ax), Ref(sax), Ref(overlap), CartesianIndices(sax)) .* view(ctx.p, sax...) view(p_rem, sax...) .-=
theta.(Ref(ax), Ref(sax), Ref(overlap), CartesianIndices(sax)) .* view(ctx.p, sax...)
# data: g - Λ(p_don + p_rem)
sg = copy(view(alg.problem.g, sax...)) # data: g - Λ(p_don + p_rem)
sp = extend(similar(ctx.p, length.(sax)), StaticKernels.ExtensionNothing()) sg = copy(view(alg.problem.g, sax...))
if alg.parallel sp = extend(similar(ctx.p, length.(sax)), StaticKernels.ExtensionNothing())
sp .= (1. .- theta.(Ref(ax), Ref(sax), Ref(overlap), CartesianIndices(sax))) .* view(ctx.p, sax...) if alg.parallel
else sp .= (1. .- theta.(Ref(ax), Ref(sax), Ref(overlap), CartesianIndices(sax))) .* view(ctx.p, sax...)
sp .= view(p_don, sax...) .+ view(p_rem, sax...) else
sp .= view(p_don, sax...) .+ view(p_rem, sax...)
end
@inline kf(spw) = @inbounds sg[spw.position] + divergence(spw)
kern = Kernel{ntuple(_->-1:1, d)}(kf)
map!(kern, sg, sp)
# start computation
put!(ctx.cons[i], sg)
end
for i in pids
sax = ctx.subax[i]
sp = take!(ctx.cons[i])
# reshape(reinterpret(SVector{d,eltype(alg.problem.g)}, ctx.subp[i]), size(ctx.subalg[i].problem.g))
# weighted update for new contribution
view(p_don, sax...) .+=
(1 .- σ) .* theta.(Ref(ax), Ref(sax), Ref(overlap), CartesianIndices(sax)) .* view(ctx.p, sax...) .+ σ .* sp
end end
@inline kf(spw) = @inbounds sg[spw.position] + divergence(spw)
kern = Kernel{ntuple(_->-1:1, d)}(kf)
map!(kern, sg, sp)
# start computation
put!(ctx.cons[i], sg)
end
for i in ids
sax = ctx.subax[i]
sp = take!(ctx.cons[i])
# reshape(reinterpret(SVector{d,eltype(alg.problem.g)}, ctx.subp[i]), size(ctx.subalg[i].problem.g))
# weighted update for new contribution
view(p_don, sax...) .+=
(1 .- σ) .* theta.(Ref(ax), Ref(sax), Ref(overlap), CartesianIndices(sax)) .* view(ctx.p, sax...) .+ σ .* sp
end end
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment