Skip to content

Commit 90c6024

Browse files
committed
Stores need to push stored op to front of parent list in case of offset; fixes #50.
1 parent fca1d08 commit 90c6024

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

src/add_stores.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function add_copystore!(
2121
ls::LoopSet, parent::Operation, mpref::ArrayReferenceMetaPosition, elementbytes::Int
2222
)
2323
op = add_compute!(ls, gensym(), :identity, [parent], elementbytes)
24-
pushfirst!(mpref.parents, parent)
24+
# pushfirst!(mpref.parents, parent)
2525
add_store!(ls, name(op), mpref, elementbytes, op)
2626
end
2727

@@ -49,7 +49,8 @@ function add_store!(
4949
else
5050
add_pvar = true
5151
end
52-
pushparent!(parents, ldref, reduceddeps, parent)
52+
pushfirst!(parents, parent)
53+
update_deps!(ldref, reduceddeps, parent)
5354
op = Operation( id, name(mpref), elementbytes, :setindex!, memstore, mpref )#loopdependencies, reduceddeps, parents, mpref.mref )
5455
add_store!(ls, op, add_pvar)
5556
end

src/graphs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ function add_operation!(
467467
RHS_ref = array_reference_meta!(ls, array, rawindices, elementbytes)
468468
op = add_load!(ls, gensym(LHS_sym), RHS_ref, elementbytes)
469469
iop = add_compute!(ls, LHS_sym, :identity, [op], elementbytes)
470-
pushfirst!(LHS_ref.parents, iop)
470+
# pushfirst!(LHS_ref.parents, iop)
471471
elseif RHS.head === :call
472472
f = first(RHS.args)
473473
if f === :getindex

test/runtests.jl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,21 @@ end
230230
b[i] = exp(a[i])
231231
end
232232
end
233+
function offset_exp!(A, B)
234+
@avx for i=1:size(A,1), j=1:size(B,2)
235+
A[i,j] = exp(B[i,j])
236+
end
237+
end
238+
function offset_expavx!(A, B)
239+
@avx for i=1:size(A,1), j=1:size(B,2)
240+
A[i,j] = exp(B[i,j])
241+
end
242+
end
243+
function offset_exp_avx!(A, B)
244+
@_avx for i=1:size(A,1), j=1:size(B,2)
245+
A[i,j] = exp(B[i,j])
246+
end
247+
end
233248

234249
vexpsq = :(for i eachindex(a)
235250
s += exp(a[i])
@@ -251,6 +266,19 @@ end
251266
end
252267
s
253268
end
269+
270+
271+
272+
273+
274+
275+
276+
277+
278+
279+
280+
281+
254282
function myvexp_avx(a)
255283
s = zero(eltype(a))
256284
@_avx for i eachindex(a)
@@ -402,6 +430,16 @@ end
402430
@test r1 r2
403431
fill!(r2, NaN); calc_sins_avx!(r2)
404432
@test r1 r2
433+
434+
N,M = 47,53
435+
B = reshape(cumsum(ones(T, 3N)),N,:)
436+
A1 = zeros(T, N, M)
437+
A2 = zeros(T, N, M)
438+
offset_exp!(A1, B)
439+
offset_expavx!(A2, B)
440+
@test A1 A2
441+
fill!(A2, 0); offset_exp_avx!(A2, B)
442+
@test A1 A2
405443
end
406444
end
407445

0 commit comments

Comments
 (0)