Skip to content

Commit b568584

Browse files
committed
Improve coverage slightly by removing unused code and adding a couple tests.
1 parent 263df7b commit b568584

File tree

4 files changed

+44
-36
lines changed

4 files changed

+44
-36
lines changed

src/graphs.jl

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ function UnrollArgs(ua::UnrollArgs, u::Int)
2222
end
2323
# UnrollSymbols(ua::UnrollArgs) = UnrollSymbols(ua.u₁loopsym, ua.u₂loopsym, ua.vectorized)
2424

25-
isfirst(ua::UnrollArgs{Nothing}) = iszero(ua.u₁)
26-
isfirst(ua::UnrollArgs{Int}) = iszero(ua.u₁) & iszero(ua.suffix)
25+
# isfirst(ua::UnrollArgs{Nothing}) = iszero(ua.u₁)
26+
# isfirst(ua::UnrollArgs{Int}) = iszero(ua.u₁) & iszero(ua.suffix)
2727

2828
struct UnrollSpecification
2929
u₁loopnum::Int
@@ -191,12 +191,12 @@ struct LoopOrder <: AbstractArray{Vector{Operation},5}
191191
loopnames::Vector{Symbol}
192192
bestorder::Vector{Symbol}
193193
end
194-
function LoopOrder(N::Int)
195-
LoopOrder(
196-
[ Operation[] for _ 1:8N ],
197-
Vector{Symbol}(undef, N), Vector{Symbol}(undef, N)
198-
)
199-
end
194+
# function LoopOrder(N::Int)
195+
# LoopOrder(
196+
# [ Operation[] for _ ∈ 1:8N ],
197+
# Vector{Symbol}(undef, N), Vector{Symbol}(undef, N)
198+
# )
199+
# end
200200
LoopOrder() = LoopOrder(Vector{Operation}[],Symbol[],Symbol[])
201201
Base.empty!(lo::LoopOrder) = foreach(empty!, lo.oporder)
202202
function Base.resize!(lo::LoopOrder, N::Int)
@@ -300,18 +300,18 @@ function pushpreamble!(ls::LoopSet, op::Operation, v::Number)
300300
end
301301
end
302302
pushpreamble!(ls::LoopSet, ex::Expr) = push!(ls.preamble.args, ex)
303-
function pushpreamble!(ls::LoopSet, op::Operation, RHS::Expr)
304-
c = gensym(:licmconst)
305-
if RHS.head === :call && first(RHS.args) === :zero
306-
push!(ls.preamble_zeros, (identifier(op), IntOrFloat))
307-
elseif RHS.head === :call && first(RHS.args) === :one
308-
push!(ls.preamble_funcofeltypes, (identifier(op), :one))
309-
else
310-
pushpreamble!(ls, Expr(:(=), c, RHS))
311-
pushpreamble!(ls, op, c)
312-
end
313-
nothing
314-
end
303+
# function pushpreamble!(ls::LoopSet, op::Operation, RHS::Expr)
304+
# c = gensym(:licmconst)
305+
# if RHS.head === :call && first(RHS.args) === :zero
306+
# push!(ls.preamble_zeros, (identifier(op), IntOrFloat))
307+
# elseif RHS.head === :call && first(RHS.args) === :one
308+
# push!(ls.preamble_funcofeltypes, (identifier(op), :one))
309+
# else
310+
# pushpreamble!(ls, Expr(:(=), c, RHS))
311+
# pushpreamble!(ls, op, c)
312+
# end
313+
# nothing
314+
# end
315315
function zerotype(ls::LoopSet, op::Operation)
316316
opid = identifier(op)
317317
for (id,typ) ls.preamble_zeros
@@ -363,9 +363,9 @@ getloop(ls::LoopSet, s::Symbol) = ls.loops[getloopid(ls, s)]
363363
getloopsym(ls::LoopSet, i::Integer) = ls.loopsymbols[i]
364364
Base.length(ls::LoopSet, s::Symbol) = length(getloop(ls, s))
365365

366-
isstaticloop(ls::LoopSet, s::Symbol) = isstaticloop(getloop(ls,s))
367-
looprangehint(ls::LoopSet, s::Symbol) = length(getloop(ls, s))
368-
looprangesym(ls::LoopSet, s::Symbol) = getloop(ls, s).rangesym
366+
# isstaticloop(ls::LoopSet, s::Symbol) = isstaticloop(getloop(ls,s))
367+
# looprangehint(ls::LoopSet, s::Symbol) = length(getloop(ls, s))
368+
# looprangesym(ls::LoopSet, s::Symbol) = getloop(ls, s).rangesym
369369
getop(ls::LoopSet, var::Number, elementbytes) = add_constant!(ls, var, elementbytes)
370370
function getop(ls::LoopSet, var::Symbol, elementbytes::Int)
371371
get!(ls.opdict, var) do
@@ -546,14 +546,13 @@ function maybe_const_compute!(ls::LoopSet, op::Operation, elementbytes::Int, pos
546546
end
547547
end
548548
function strip_op_linenumber_nodes(q::Expr)
549-
non_lnn_ind = 0
550-
for i eachindex(q.args)
551-
if !(q.args[i] isa LineNumberNode)
552-
@assert iszero(non_lnn_ind) "There should only be one non-LineNumberNode in the expression."
553-
non_lnn_ind = i
554-
end
549+
filtered = filter(x -> !isa(x, LineNumberNode), q.args)
550+
if VERSION v"1.4"
551+
only(filtered)
552+
else
553+
@assert isone(length(filtered))
554+
first(filtered)
555555
end
556-
q.args[non_lnn_ind]
557556
end
558557

559558
function add_operation!(

src/operations.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,11 @@ vptr(x::Symbol) = Symbol("##vptr##_", x)
277277
vptr(x::ArrayReference) = vptr(x.array)
278278
vptr(x::ArrayReferenceMeta) = x.ptr
279279
vptr(x::Operation) = x.ref.ptr
280-
vptrbase(x) = Symbol(vptr(x), "##BASE##")
280+
# vptrbase(x) = Symbol(vptr(x), "##BASE##")
281281
name(x::ArrayReference) = x.array
282282
name(x::ArrayReferenceMeta) = x.ref.array
283283
name(op::Operation) = op.variable
284284
instruction(op::Operation) = op.instruction
285-
isreductionzero(op::Operation, instr::Symbol) = op.instruction.mod === REDUCTION_ZERO[instr]
286285
isreductcombineinstr(op::Operation) = iscompute(op) && isreductcombineinstr(instruction(op))
287286
"""
288287
mvar = mangledvar(op)
@@ -327,9 +326,9 @@ mutable struct ArrayReferenceMetaPosition
327326
reduceddeps::Vector{Symbol}
328327
varname::Symbol
329328
end
330-
function ArrayReferenceMetaPosition(parents::Vector{Operation}, ldref::Vector{Symbol}, reduceddeps::Vector{Symbol}, varname::Symbol)
331-
ArrayReferenceMetaPosition( NOTAREFERENCE, parents, ldref, reduceddeps, varname )
332-
end
329+
# function ArrayReferenceMetaPosition(parents::Vector{Operation}, ldref::Vector{Symbol}, reduceddeps::Vector{Symbol}, varname::Symbol)
330+
# ArrayReferenceMetaPosition( NOTAREFERENCE, parents, ldref, reduceddeps, varname )
331+
# end
333332
function Operation(id::Int, var::Symbol, elementbytes::Int, instr, optype::OperationType, mpref::ArrayReferenceMetaPosition)
334333
Operation( id, var, elementbytes, instr, optype, mpref.loopdependencies, mpref.reduceddeps, mpref.parents, mpref.mref )
335334
end

test/dot.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ using Test
2525
function mydot_avx(a, b)
2626
s = zero(eltype(a))
2727
@_avx for i eachindex(a,b)
28-
s += a[i]*b[i]
28+
aᵢ = getindex(a, i)
29+
s += aᵢ*b[i]
2930
end
3031
s
3132
end

test/mapreduce.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
R = T(1):T(100)
2222
x7 = rand(R, 7); y7 = rand(R, 7);
2323
x = rand(R, 127, 7, 7); y = rand(R, 127, 7, 7);
24+
z = rand(R, 3, 3, 3, 3, 3, 3);
2425
else
2526
x7 = rand(T, 7); y7 = rand(T, 7);
2627
x = rand(T, 127, 7, 7); y = rand(T, 127, 7, 7);
@@ -31,9 +32,12 @@
3132
@test vmapreduce(hypot, +, x, y) sum(hypot.(x, y))
3233
@test vmapreduce(^, (a,b) -> a + b, x7, y7) sum(x7 .^ y7)
3334
end
35+
z = rand(T, 3, 3, 3, 3, 3, 3);
3436
end;
3537
@test vreduce(+, x7) sum(x7)
3638
@test vreduce(+, x) sum(x)
39+
@test vmapreduce(abs2, max, x) mapreduce(abs2, max, x)
40+
@test vmapreduce(abs2, min, x) mapreduce(abs2, min, x)
3741
@test_throws AssertionError vmapreduce(hypot, +, x7, x)
3842
if VERSION v"1.4"
3943
@test vmapreduce(a -> 2a, *, x) mapreduce(a -> 2a, *, x)
@@ -55,6 +59,11 @@
5559
@test vreduce(min, x; dims = d) == minimum(x; dims = d)
5660
@test vreduce(+, x; dims = d) sum(x; dims = d)
5761
end
62+
for d in 1:ndims(z)
63+
vreduce(max, z, dims = d) == maximum(z, dims = d)
64+
vreduce(min, z, dims = d) == minimum(z, dims = d)
65+
vreduce(+, z, dims = d) sum(z, dims = d)
66+
end
5867
end
5968

6069
end

0 commit comments

Comments
 (0)