Skip to content

Commit 08f438d

Browse files
committed
Check first dim in memory ops for causes of being discontiguous
1 parent 9bd29ab commit 08f438d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/determinestrategy.jl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,25 @@ const CACHELINE_SIZE = something(VectorizationBase.L₁CACHE.linesize, 64)
1616
# factor = instruction(op).instr ∈ (:+, :vadd, :add_fast, :evadd) ? 1 : 10
1717
# newapp * factor
1818
# end
19+
function check_linear_parents(ls::LoopSet, op::Operation, s::Symbol)
20+
(s loopdependencies(op)) || return true
21+
if isload(op) # TODO: handle loading from ranges.
22+
return false
23+
elseif !iscompute(op)
24+
return true
25+
end
26+
op_is_linear = false
27+
instr_op = instruction(op).instr
28+
for instr (:(+), :vadd, :vadd1, :add_fast, :(-), :vsub, :sub_fast)
29+
(op_is_linear = instr === instr_op) && break
30+
end
31+
op_is_linear || return false
32+
for opp parents(op)
33+
check_linear_parents(ls, opp, s) || return false
34+
end
35+
true
36+
end
37+
1938
function findparent(ls::LoopSet, s::Symbol)#opdict isn't filled when reconstructing
2039
id = findfirst(op -> name(op) === s, operations(ls))
2140
id === nothing && throw("$s not found")
@@ -33,6 +52,10 @@ function unitstride(ls::LoopSet, op::Operation, s::Symbol)
3352
# parent = findparent(ls, fi)
3453
# indexappearences(parent, s) > 1 && return false
3554
end
55+
if length(li) > 0 && !first(li)
56+
parent = findparent(ls, first(inds))
57+
check_linear_parents(ls, parent, s) || return false
58+
end
3659
for i 2:length(inds)
3760
if li[i]
3861
s === inds[i] && return false
@@ -164,6 +187,7 @@ function evaluate_cost_unroll(
164187
end
165188
end
166189
included_vars[id] = true
190+
# @show op, cost(ls, op, vectorized, Wshift, size_T)
167191
total_cost += iter * first(cost(ls, op, vectorized, Wshift, size_T))
168192
total_cost > max_cost && return total_cost # abort if more expensive; we only want to know the cheapest
169193
end

0 commit comments

Comments
 (0)