Skip to content

Commit 1b48506

Browse files
authored
Merge pull request #172 from mcabbott/silence
Remove `println` statements accompanying errors
2 parents b156769 + 0ef644f commit 1b48506

File tree

3 files changed

+30
-14
lines changed

3 files changed

+30
-14
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "LoopVectorization"
22
uuid = "bdcacae8-1622-11e9-2a5c-532679323890"
33
authors = ["Chris Elrod <[email protected]>"]
4-
version = "0.9.6"
4+
version = "0.9.7"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"

src/graphs.jl

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ function register_single_loop!(ls::LoopSet, looprange::Expr)
526526
U = add_loop_bound!(ls, itersym, Expr(:call, lv(:maybestaticlast), N), true)
527527
loop = Loop(itersym, L, U)
528528
else
529-
throw("Unrecognized loop range type: $r.")
529+
throw(LoopError("Unrecognized loop range type: $r."))
530530
end
531531
add_loop!(ls, loop, itersym)
532532
nothing
@@ -621,8 +621,7 @@ function add_operation!(
621621
elseif RHS.head === :block
622622
add_operation!(ls, LHS, strip_op_linenumber_nodes(RHS), elementbytes, position)
623623
else
624-
println(RHS)
625-
throw("Expression not recognized.")
624+
throw(LoopError("Expression not recognized.", RHS))
626625
end
627626
end
628627
add_operation!(ls::LoopSet, RHS::Expr, elementbytes::Int, position::Int) = add_operation!(ls, gensym(:LHS), RHS, elementbytes, position)
@@ -657,8 +656,7 @@ function add_operation!(
657656
elseif RHS.head === :block
658657
add_operation!(ls, LHS, strip_op_linenumber_nodes(RHS), elementbytes, position)
659658
else
660-
println(RHS)
661-
throw("Expression not recognized.")
659+
throw(LoopError("Expression not recognized.", RHS))
662660
end
663661
end
664662

@@ -722,18 +720,15 @@ function Base.push!(ls::LoopSet, ex::Expr, elementbytes::Int, position::Int)
722720
add_compute!(ls, tempunpacksym, f, vparents, elementbytes)
723721
add_store_ref!(ls, tempunpacksym, lhsi, elementbytes)
724722
else
725-
println(lhsi)
726-
throw("Unpacking the above expression in the left hand side was not understood/supported.")
723+
throw(LoopError("Unpacking the above expression in the left hand side was not understood/supported.", lhsi))
727724
end
728725
end
729726
first(vparents)
730727
else
731-
println(LHS)
732-
throw("LHS not understood; only `:ref`s and `:tuple`s are currently supported.")
728+
throw(LoopError("LHS not understood; only `:ref`s and `:tuple`s are currently supported.", LHS))
733729
end
734730
else
735-
println(LHS)
736-
throw("LHS not understood.")
731+
throw(LoopError("LHS not understood.", LHS))
737732
end
738733
elseif ex.head === :block
739734
add_block!(ls, ex, elementbytes, position)
@@ -756,8 +751,7 @@ function Base.push!(ls::LoopSet, ex::Expr, elementbytes::Int, position::Int)
756751
add_compute!(ls, LHS, :identity, [RHS], elementbytes)
757752
end
758753
else
759-
println(ex)
760-
throw("Don't know how to handle expression.")
754+
throw(LoopError("Don't know how to handle expression.", ex))
761755
end
762756
end
763757

@@ -817,3 +811,14 @@ end
817811
# order[u₁loopnum], order[u₂loopnum]
818812
# end
819813

814+
815+
struct LoopError <: Exception
816+
msg
817+
ex
818+
LoopError(msg, ex=nothing) = new(msg, ex)
819+
end
820+
821+
function Base.showerror(io::IO, err::LoopError)
822+
printstyled(io, err.msg; color = :red)
823+
isnothing(err.ex) || printstyled(io, '\n', err.ex)
824+
end

test/miscellaneous.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,5 +1139,16 @@ if Base.libllvm_version ≥ v"8" || LoopVectorization.VectorizationBase.SIMD_NAT
11391139
end
11401140
end
11411141
end
1142+
1143+
@test_throws LoadError @macroexpand begin # pull #172
1144+
@avx for i in eachindex(xs)
1145+
if i in axes(ys,1)
1146+
xs[i] = ys[i]
1147+
else
1148+
xs[i] = zero(eltype(ys))
1149+
end
1150+
end
1151+
end
1152+
11421153
end
11431154

0 commit comments

Comments
 (0)