Skip to content

Commit 0cca17f

Browse files
committed
Ever so slight nudge toward more favorable patterns.
1 parent a3393e7 commit 0cca17f

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

src/determinestrategy.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,11 @@ function evaluate_cost_tile(
696696
u₁, u₂, ucost = solve_unroll(ls, u₁loopsym, u₂loopsym, cost_vec, reg_pressure, W, vectorized)
697697
outer_reduct_penalty = length(ls.outer_reductions) * (u₁ + isodd(u₁))
698698
favor_bigger_u₂ = u₁ - u₂
699-
u₁, u₂, costpenalty * ucost + stride_penalty(ls, order) + outer_reduct_penalty + favor_bigger_u₂, choose_to_inline[]
699+
u₁v = vectorized === u₁loopsym; u₂v = vectorized === u₂loopsym
700+
favor_smaller_vectorized = u₁v ? ( u₁ - u₂ ) : (u₂v ? ( u₂ - u₁ ) : 0 )
701+
favor_u₁_vectorized = -0.2u₁v
702+
favoring_heuristics = favor_bigger_u₂ + 0.5favor_smaller_vectorized + favor_u₁_vectorized
703+
u₁, u₂, costpenalty * ucost + stride_penalty(ls, order) + outer_reduct_penalty + favoring_heuristics, choose_to_inline[]
700704
end
701705

702706
function should_inline(ls::LoopSet, u₁::Int, u₂::Int)

src/lowering.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,9 @@ end
186186
function assume(ex)
187187
Expr(:call, Expr(:(.), Expr(:(.), :LoopVectorization, QuoteNode(:SIMDPirates)), QuoteNode(:assume)), ex)
188188
end
189-
function expect(ex)
190-
Expr(:call, Expr(:(.), Expr(:(.), :LoopVectorization, QuoteNode(:SIMDPirates)), QuoteNode(:expect)), ex)
191-
end
189+
# function expect(ex)
190+
# Expr(:call, Expr(:(.), Expr(:(.), :LoopVectorization, QuoteNode(:SIMDPirates)), QuoteNode(:expect)), ex)
191+
# end
192192
function loopiteratesatleastonce(loop::Loop, as::Bool = true)
193193
comp = if loop.startexact # requires !loop.stopexact
194194
Expr(:call, :>, loop.stopsym, loop.starthint - 1)
@@ -197,7 +197,8 @@ function loopiteratesatleastonce(loop::Loop, as::Bool = true)
197197
else
198198
Expr(:call, :>, loop.stopsym, Expr(:call, :-, loop.stopsym, 1))
199199
end
200-
as ? assume(comp) : expect(comp)
200+
# as ? assume(comp) : expect(comp)
201+
assume(comp)
201202
end
202203
function lower_no_unroll(ls::LoopSet, us::UnrollSpecification, n::Int, inclmask::Bool)
203204
usorig = ls.unrollspecification[]

test/gemm.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# @test LoopVectorization.choose_order(lsAmulBt1) == (Symbol[:n,:m,:k], :n, :m, :m, Unum, Tnum)
1414
@test LoopVectorization.choose_order(lsAmulBt1) == (Symbol[:n,:m,:k], :m, :n, :m, Unum, Tnum)
1515

16-
AmulBq1 = :(for m 1:size(A,1), n 1:size(B,2)
16+
AmulBq1 = :(for n 1:size(B,2), m 1:size(A,1)
1717
C[m,n] = zeroB
1818
for k 1:size(A,2)
1919
C[m,n] += A[m,k] * B[k,n]

0 commit comments

Comments
 (0)