|
1 |
| -# using LightGraphs |
2 | 1 |
|
3 | 2 |
|
4 | 3 | isdense(::Type{<:DenseArray}) = true
|
@@ -83,10 +82,9 @@ struct Operation
|
83 | 82 | end
|
84 | 83 | end
|
85 | 84 |
|
86 |
| - |
87 |
| - |
88 | 85 | function isreduction(op::Operation)
|
89 |
| - (op.node_type == memstore) && (length(op.symbolic_metadata) < length(op.dependencies))# && issubset(op.symbolic_metadata, op.dependencies) |
| 86 | + length(op.reduced_deps) > 0 |
| 87 | + # (op.node_type == memstore) && (length(op.symbolic_metadata) < length(op.dependencies))# && issubset(op.symbolic_metadata, op.dependencies) |
90 | 88 | end
|
91 | 89 | isload(op::Operation) = op.node_type == memload
|
92 | 90 | iscompute(op::Operation) = op.node_type == compute
|
@@ -118,37 +116,6 @@ function stride(op::Operation, sym::Symbol)
|
118 | 116 | op.numerical_metadata[symposition(op,sym)]
|
119 | 117 | end
|
120 | 118 | # function
|
121 |
| -function unitstride(op::Operation, sym::Symbol) |
122 |
| - (first(op.symbolic_metadata) === sym) && (first(op.numerical_metadata) == 1) |
123 |
| -end |
124 |
| -function mem_offset(op::Operation, incr::Int = 0)::Union{Symbol,Expr} |
125 |
| - @assert accesses_memory(op) "Computing memory offset only makes sense for operations that access memory." |
126 |
| - @unpack numerical_metadata, symbolic_metadata = op |
127 |
| - if incr == 0 && length(numerical_metadata) == 1 |
128 |
| - firstsym = first(symbolic_metadata) |
129 |
| - if first(numerical_metadata) == 1 |
130 |
| - return firstsym |
131 |
| - elseif first(numerical_metadata) == -1 |
132 |
| - return Expr(:call, :*, Symbol(:stride_, op.variable, :_, firstsym), firstsym) |
133 |
| - else |
134 |
| - return Expr(:call, :*, first(numerical_metadata), firstsym) |
135 |
| - end |
136 |
| - end |
137 |
| - ret = Expr(:call, :+, ) |
138 |
| - for i ∈ eachindex(numerical_metadata) |
139 |
| - sym = symbolic_metadata[i]; num = numerical_metadata[i] |
140 |
| - if num == 1 |
141 |
| - push!(ret.args, sym) |
142 |
| - elseif num == -1 |
143 |
| - push!(ret.args, Expr(:call, :*, Symbol(:stride_, op.variable, :_, firstsym), sym)) |
144 |
| - else |
145 |
| - push!(ret.args, Expr(:call, :*, num, sym)) |
146 |
| - end |
147 |
| - end |
148 |
| - incr == 0 || push!(ret.args, incr) |
149 |
| - ret |
150 |
| -end |
151 |
| - |
152 | 119 |
|
153 | 120 | struct Loop
|
154 | 121 | itersymbol::Symbol
|
@@ -274,12 +241,14 @@ function add_loop!(ls::LoopSet, looprange::Expr)
|
274 | 241 | ls.loops[itersym] = loop
|
275 | 242 | nothing
|
276 | 243 | end
|
277 |
| -function add_load!(ls::LoopSet, indexed::Symbol, indices::AbstractVector) |
| 244 | +function add_load!( |
| 245 | + ls::LoopSet, indexed::Symbol, indices::AbstractVector, nstrides::Vector{Int} = fill(-1, length(indices)) |
| 246 | +) |
278 | 247 | Ninds = length(indices)
|
279 | 248 | inds = ShortVector{Symbol}(indices)
|
280 | 249 | nsets = length(ls.stridesets)
|
281 | 250 | get!(ls.stridesets, inds) do
|
282 |
| - strides = ShortVector{Symbol}(undef, Ninds - 1) |
| 251 | + sstrides = ShortVector{Symbol}(undef, Ninds) |
283 | 252 | @inbounds for i ∈ 2:Ninds
|
284 | 253 | sᵢ = Symbol(:stride_, nsets, :_, inds[i])
|
285 | 254 | strides[i-1] = sᵢ
|
|
0 commit comments