Skip to content

Commit c95a010

Browse files
committed
Add index-parents when splitting loops along store/load
1 parent 45d281e commit c95a010

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/broadcast.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,8 @@ end
404404
loopsyms = [gensym!(ls, "n") for n 1:N]
405405
add_broadcast_loops!(ls, loopsyms, :dest)
406406
elementbytes = sizeof(T)
407-
add_broadcast!(ls, :dest, :bc, loopsyms, BC, elementbytes)
408-
storeop = add_simple_store!(ls, :dest, ArrayReference(:dest, loopsyms), elementbytes)
407+
add_broadcast!(ls, :destination, :bc, loopsyms, BC, elementbytes)
408+
storeop = add_simple_store!(ls, :destination, ArrayReference(:dest, loopsyms), elementbytes)
409409
doaddref!(ls, storeop)
410410
resize!(ls.loop_order, num_loops(ls)) # num_loops may be greater than N, eg Product
411411
# return ls
@@ -426,8 +426,8 @@ end
426426
pushprepreamble!(ls, Expr(:(=), :dest, Expr(:call, :parent, :dest′)))
427427
add_broadcast_loops!(ls, loopsyms, :dest′)
428428
elementbytes = sizeof(T)
429-
add_broadcast!(ls, :dest, :bc, loopsyms, BC, elementbytes)
430-
storeop = add_simple_store!(ls, :dest, ArrayReference(:dest, reverse(loopsyms)), elementbytes)
429+
add_broadcast!(ls, :destination, :bc, loopsyms, BC, elementbytes)
430+
storeop = add_simple_store!(ls, :destination, ArrayReference(:dest, reverse(loopsyms)), elementbytes)
431431
doaddref!(ls, storeop)
432432
resize!(ls.loop_order, num_loops(ls)) # num_loops may be greater than N, eg Product
433433
Expr(:block, Expr(:meta,:inline), setup_call(ls, :(Base.Broadcast.materialize!(dest′, bc)), LineNumberNode(0), inline, false, u₁, u₂, v, threads%Int, warncheckarg), :dest′)

src/codegen/split_loops.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,18 @@ function add_operation!(ls_new::LoopSet, included::Vector{Int}, ls::LoopSet, op:
1313
if isstore(opc) && identifier(opc) ids
1414
# @show opp opc op
1515
# replace opp with a load from opc
16+
parentsopc = parents(opc)
17+
parentsnew = length(parentsopc) > 1 ? Operation[] : NOPARENTS
1618
opnew = Operation(
1719
length(operations(ls_new)), name(opp), opc.elementbytes, instruction(:getindex), memload,
18-
loopdependencies(opc), reduceddependencies(opc), NOPARENTS, opc.ref, reducedchildren(opc)
20+
loopdependencies(opc), reduceddependencies(opc), parentsnew, opc.ref, reducedchildren(opc)
1921
)
2022
addsetv!(ls_new.includedactualarrays, vptr(opc.ref))
2123
push!(operations(ls_new), opnew)
2224
push!(vparents, opnew)
25+
for i 2:length(parentsopc)
26+
push!(parentsnew, add_operation!(ls_new, included, ls, parentsopc[i], ids, issecond))
27+
end
2328
included[identifier(opp)] = identifier(opnew)
2429
found = true
2530
break

0 commit comments

Comments
 (0)