Skip to content

Commit ea76af4

Browse files
committed
Ensure refs alias stores on new lines
1 parent 0b4ef95 commit ea76af4

File tree

4 files changed

+53
-11
lines changed

4 files changed

+53
-11
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "LoopVectorization"
22
uuid = "bdcacae8-1622-11e9-2a5c-532679323890"
33
authors = ["Chris Elrod <[email protected]>"]
4-
version = "0.12.58"
4+
version = "0.12.59"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"

src/modeling/graphs.jl

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,16 +1128,18 @@ function add_operation!(
11281128
end
11291129
end
11301130

1131-
function prepare_rhs_for_storage!(ls::LoopSet, RHS::Union{Symbol,Expr}, array, rawindices, elementbytes::Int, position::Int)
1132-
RHS isa Symbol && return add_store!(ls, RHS, array, rawindices, elementbytes)
1133-
mpref = array_reference_meta!(ls, array, rawindices, elementbytes)
1134-
cachedparents = copy(mpref.parents)
1135-
ref = mpref.mref.ref
1136-
lrhs = gensym!(ls, "RHS")
1137-
mpref.varname = lrhs
1138-
add_operation!(ls, lrhs, RHS, mpref, elementbytes, position)
1139-
mpref.parents = cachedparents
1140-
add_store!(ls, mpref, elementbytes)
1131+
function prepare_rhs_for_storage!(ls::LoopSet, RHS::Union{Symbol,Expr}, array, rawindices, elementbytes::Int, position::Int)::Operation
1132+
RHS isa Symbol && return add_store!(ls, RHS, array, rawindices, elementbytes)
1133+
mpref = array_reference_meta!(ls, array, rawindices, elementbytes)
1134+
cachedparents = copy(mpref.parents)
1135+
ref = mpref.mref.ref
1136+
lrhs = gensym!(ls, "RHS")
1137+
mpref.varname = lrhs
1138+
add_operation!(ls, lrhs, RHS, mpref, elementbytes, position)
1139+
mpref.parents = cachedparents
1140+
op = add_store!(ls, mpref, elementbytes)
1141+
ls.syms_aliasing_refs[findfirst(==(mpref.mref), ls.refs_aliasing_syms)] = lrhs
1142+
return op
11411143
end
11421144

11431145
function add_assignment!(ls::LoopSet, LHS, RHS, elementbytes::Int, position::Int)

test/convolutions.jl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
function compute_update0!(H2, dHdtau, H, min_dxy2, _dx, _dy, dx, dy)
3+
@inbounds @fastmath for iy=1:size(dHdtau,2)
4+
for ix=1:size(dHdtau,1)
5+
dHdtau[ix, iy] = (-((-((H[(ix + 1) + 1, iy + 1] - H[ix + 1, iy + 1])) * _dx - -((H[ix + 1, iy + 1] - H[ix, iy + 1])) * _dx)) * _dx - (-((H[ix + 1, (iy + 1) + 1] - H[ix + 1, iy + 1])) * _dy - -((H[ix + 1, iy + 1] - H[ix + 1, iy])) * _dy) * _dy) + 0.6 * dHdtau[ix, iy]
6+
H2[ix+1,iy+1] = H[ix+1,iy+1] + min_dxy2/4.1*dHdtau[ix,iy] # sets the BC as H[1]=H[end]=0
7+
end
8+
end
9+
return
10+
end
11+
function compute_update1!(H2, dHdtau, H, min_dxy2, _dx, _dy, dx, dy)
12+
@turbo for iy=1:size(dHdtau,2)
13+
for ix=1:size(dHdtau,1)
14+
dHdtau[ix, iy] = (-((-((H[(ix + 1) + 1, iy + 1] - H[ix + 1, iy + 1])) * _dx - -((H[ix + 1, iy + 1] - H[ix, iy + 1])) * _dx)) * _dx - (-((H[ix + 1, (iy + 1) + 1] - H[ix + 1, iy + 1])) * _dy - -((H[ix + 1, iy + 1] - H[ix + 1, iy])) * _dy) * _dy) + 0.6 * dHdtau[ix, iy]
15+
H2[ix+1,iy+1] = H[ix+1,iy+1] + min_dxy2/4.1*dHdtau[ix,iy] # sets the BC as H[1]=H[end]=0
16+
end
17+
end
18+
return
19+
end
20+
21+
@testset "conv" begin
22+
lx, ly = 10.0, 10.0 # domain size
23+
nx, ny = 12, 12 # number of grid points
24+
nt = 1e3 # max number of iterations
25+
dx, dy = lx/nx, ly/ny
26+
xc, yc = LinRange(dx/2, lx-dx/2, nx), LinRange(dy/2, ly-dy/2, ny)
27+
dHdtau = zeros(nx-2, ny-2)
28+
dHdtau2 = zeros(nx-2, ny-2)
29+
H = exp.(.-(xc.-lx/2).^2 .-(yc.-ly/2)'.^2)
30+
H1 = copy(H)
31+
H2 = copy(H)
32+
min_dxy2 = min(dx,dy)^2
33+
_dx, _dy = 1.0/dx, 1.0/dy
34+
compute_update0!(H1, dHdtau, H, min_dxy2, _dx, _dy, dx, dy)
35+
compute_update1!(H2, dHdtau2, H, min_dxy2, _dx, _dy, dx, dy)
36+
@test H1 H2
37+
@test dHdtau dHdtau2
38+
end

test/grouptests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ const START_TIME = time()
4747
@time include("manyloopreductions.jl")
4848

4949
@time include("simplemisc.jl")
50+
51+
@time include("convolutions.jl")
5052
end
5153

5254
@time if LOOPVECTORIZATION_TEST == "all" || LOOPVECTORIZATION_TEST == "part3"

0 commit comments

Comments
 (0)