Skip to content

Commit 6c559bb

Browse files
committed
Turns COSTS into a Dict{Symbol,InstructionCost} instead of a Dict{Instruction,InstructionCost}.
1 parent 5795539 commit 6c559bb

File tree

6 files changed

+136
-137
lines changed

6 files changed

+136
-137
lines changed

src/add_compute.jl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,11 @@ end
115115

116116
function add_reduction_update_parent!(
117117
vparents::Vector{Operation}, deps::Vector{Symbol}, reduceddeps::Vector{Symbol}, ls::LoopSet,
118-
parent::Operation, instr::Symbol, reduction_ind::Int, elementbytes::Int
118+
parent::Operation, instr::Instruction, reduction_ind::Int, elementbytes::Int
119119
)
120120
var = name(parent)
121121
isouterreduction = parent.instruction === LOOPCONSTANT
122-
Instr = instruction(ls, instr)
123-
instrclass = reduction_instruction_class(Instr) # key allows for faster lookups
122+
instrclass = reduction_instruction_class(instr) # key allows for faster lookups
124123
reduct_zero = reduction_zero(instrclass)
125124
# if parent is not an outer reduction...
126125
# if !isouterreduction && !isreductzero(parent, ls, reduct_zero)
@@ -155,7 +154,7 @@ function add_reduction_update_parent!(
155154
# directdependency && pushparent!(vparents, deps, reduceddeps, reductinit)#parent) # deps and reduced deps will not be disjoint
156155
if reduction_ind > 0 # if is directdependency
157156
insert!(vparents, reduction_ind, reductinit)
158-
if instr (:-, :vsub!, :vsub, :/, :vfdiv!, :vfidiv!)
157+
if instr.instr (:-, :vsub!, :vsub, :/, :vfdiv!, :vfidiv!)
159158
update_deps!(deps, reduceddeps, reductinit)#parent) # deps and reduced deps will not be disjoint
160159
end
161160
# elseif !isouterreduction
@@ -188,9 +187,9 @@ function add_compute!(
188187
)
189188
@assert ex.head === :call
190189
# instr = instruction(first(ex.args))::Symbol
191-
instr = instruction!(ls, first(ex.args))::Symbol
190+
instr = instruction!(ls, first(ex.args))::Instruction
192191
args = @view(ex.args[2:end])
193-
(instr === :(^) && length(args) == 2 && (args[2] isa Number)) && return add_pow!(ls, var, args[1], args[2], elementbytes, position)
192+
(instr.instr === :(^) && length(args) == 2 && (args[2] isa Number)) && return add_pow!(ls, var, args[1], args[2], elementbytes, position)
194193
vparents = Operation[]
195194
deps = Symbol[]
196195
reduceddeps = Symbol[]
@@ -241,13 +240,13 @@ function add_compute!(
241240
if length(reduceddeps) == 0
242241
insert!(vparents, reduction_ind, parent)
243242
mergesetv!(deps, loopdependencies(parent))
244-
op = Operation(length(operations(ls)), var, elementbytes, instruction(ls,instr), compute, deps, reduceddeps, vparents)
243+
op = Operation(length(operations(ls)), var, elementbytes, instr, compute, deps, reduceddeps, vparents)
245244
pushop!(ls, op, var)
246245
else
247246
add_reduction_update_parent!(vparents, deps, reduceddeps, ls, parent, instr, reduction_ind, elementbytes)
248247
end
249248
else
250-
op = Operation(length(operations(ls)), var, elementbytes, instruction(ls,instr), compute, deps, reduceddeps, vparents)
249+
op = Operation(length(operations(ls)), var, elementbytes, instr, compute, deps, reduceddeps, vparents)
251250
pushop!(ls, op, var)
252251
end
253252
end

src/condense_loopset.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,8 @@ function add_external_functions!(q::Expr, ls::LoopSet)
188188
for op operations(ls)
189189
if iscompute(op)
190190
instr = instruction(op)
191-
if instr.mod === :Main
191+
if instr.mod !== :LoopVectorization
192192
push!(q.args, instr.instr)
193-
elseif instr.mod !== :LoopVectorization
194-
push!(q.args, Expr(:(.), instr.mod, QuoteNode(instr.instr)))
195193
end
196194
end
197195
end

src/constructors.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function substitute_broadcast(q::Expr, mod::Symbol)
4646
end
4747

4848

49-
function LoopSet(q::Expr, mod::Symbol = :LoopVectorization)
49+
function LoopSet(q::Expr, mod::Symbol = :Main)
5050
SIMDPirates.contract_pass!(q)
5151
ls = LoopSet(mod)
5252
copyto!(ls, q)

0 commit comments

Comments
 (0)