Skip to content

Commit 96e0c8d

Browse files
committed
print file number check_args warning is coming from, fixes #333
1 parent 588ea17 commit 96e0c8d

File tree

4 files changed

+45
-41
lines changed

4 files changed

+45
-41
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.12.67"
4+
version = "0.12.68"
55

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

src/condense_loopset.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,8 @@ function setup_call(
818818
call = check_empty ? check_if_empty(ls, call) : call
819819
argfailure = make_crashy(make_fast(q))
820820
if warncheckarg 0
821-
warning = :(@warn "`LoopVectorization.check_args` on your inputs failed; running fallback `@inbounds @fastmath` loop instead.\nUse `warn_check_args=false`, e.g. `@turbo warn_check_args=false ...`, to disable this warning.")
821+
warnstring = "$(first(lnns)):\n`LoopVectorization.check_args` on your inputs failed; running fallback `@inbounds @fastmath` loop instead.\nUse `warn_check_args=false`, e.g. `@turbo warn_check_args=false ...`, to disable this warning."
822+
warning = :(@warn $warnstring)
822823
warncheckarg > 0 && push!(warning.args, :(maxlog=$warncheckarg))
823824
argfailure = Expr(:block, warning, argfailure)
824825
end

src/reconstruct_loopset.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ Execute an `@turbo` block. The block's code is represented via the arguments:
713713
@generated function _turbo_!(
714714
::Val{var"#UNROLL#"}, ::Val{var"#OPS#"}, ::Val{var"#ARF#"}, ::Val{var"#AM#"}, ::Val{var"#LPSYM#"}, ::Val{Tuple{var"#LB#",var"#V#"}}, var"#flattened#var#arguments#"::Vararg{Any,var"#num#vargs#"}
715715
) where {var"#UNROLL#", var"#OPS#", var"#ARF#", var"#AM#", var"#LPSYM#", var"#LB#", var"#V#", var"#num#vargs#"}
716-
1 + 1 # Irrelevant line you can comment out/in to force recompilation...
716+
# 1 + 1 # Irrelevant line you can comment out/in to force recompilation...
717717
ls = _turbo_loopset(var"#OPS#", var"#ARF#", var"#AM#", var"#LPSYM#", var"#LB#".parameters, var"#V#".parameters, var"#UNROLL#")
718718
pushfirst!(ls.preamble.args, :(var"#lv#tuple#args#" = reassemble_tuple(Tuple{var"#LB#",var"#V#"}, var"#flattened#var#arguments#")))
719719
# return @show avx_body(ls, var"#UNROLL#")

test/fallback.jl

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,49 @@
11

22
@testset "Fall back behavior" begin
33

4-
@show Float64, @__LINE__
5-
function msd(x)
6-
s = zero(eltype(x))
7-
for i in eachindex(x)
8-
s += x[i] * x[i]
9-
end
10-
s
4+
@show Float64, @__LINE__
5+
function msd(x)
6+
s = zero(eltype(x))
7+
for i in eachindex(x)
8+
s += x[i] * x[i]
119
end
12-
function msdavx(x)
13-
s = zero(eltype(x))
14-
@turbo warn_check_args=true for i in eachindex(x)
15-
s = muladd(x[i], x[i], s) # Avoids fastmath in fallback loop.
16-
end
17-
s
10+
s
11+
end
12+
function msdavx(x)
13+
s = zero(eltype(x))
14+
@turbo warn_check_args=true for i in eachindex(x)
15+
s = muladd(x[i], x[i], s) # Avoids fastmath in fallback loop.
1816
end
17+
s
18+
end
1919

20-
x = fill(8.0, 128);
21-
x[1] = 1e9
22-
23-
@test @inferred LoopVectorization.check_args(x)
24-
@test @inferred LoopVectorization.check_args(x, x)
25-
@test @inferred LoopVectorization.check_args(x, x, x)
26-
@test @inferred !LoopVectorization.check_args(view(x, [1,3,4,18]))
27-
@test @inferred !LoopVectorization.check_args(FallbackArrayWrapper(x))
28-
@test @inferred !LoopVectorization.check_args(FallbackArrayWrapper(x), x, x)
29-
@test @inferred !LoopVectorization.check_args(x, FallbackArrayWrapper(x))
30-
@test @inferred !LoopVectorization.check_args(x, FallbackArrayWrapper(x), x)
31-
@test @inferred !LoopVectorization.check_args(x, x, FallbackArrayWrapper(x))
32-
@test @inferred !LoopVectorization.check_args(x, x, FallbackArrayWrapper(x), FallbackArrayWrapper(x))
33-
@test @inferred !LoopVectorization.check_args(['a'])
34-
@test @inferred !LoopVectorization.check_args(Diagonal(x))
35-
36-
@test_nowarn msdavx(x)
37-
@test_logs (:warn,"`LoopVectorization.check_args` on your inputs failed; running fallback `@inbounds @fastmath` loop instead.\nUse `warn_check_args=false`, e.g. `@turbo warn_check_args=false ...`, to disable this warning.") msdavx(FallbackArrayWrapper(x))
38-
@test msdavx(FallbackArrayWrapper(x)) == 1e18
39-
@test msd(x) == msdavx(FallbackArrayWrapper(x))
40-
@test msdavx(x) != msdavx(FallbackArrayWrapper(x))
41-
42-
x = rand(1000); # should be long enough to make zero differences incredibly unlikely
43-
@test exp.(x) != (@turbo exp.(x))
44-
@test exp.(x) == (@turbo exp.(FallbackArrayWrapper(x)))
20+
x = fill(8.0, 128);
21+
x[1] = 1e9
22+
23+
@test @inferred LoopVectorization.check_args(x)
24+
@test @inferred LoopVectorization.check_args(x, x)
25+
@test @inferred LoopVectorization.check_args(x, x, x)
26+
@test @inferred !LoopVectorization.check_args(view(x, [1,3,4,18]))
27+
@test @inferred !LoopVectorization.check_args(FallbackArrayWrapper(x))
28+
@test @inferred !LoopVectorization.check_args(FallbackArrayWrapper(x), x, x)
29+
@test @inferred !LoopVectorization.check_args(x, FallbackArrayWrapper(x))
30+
@test @inferred !LoopVectorization.check_args(x, FallbackArrayWrapper(x), x)
31+
@test @inferred !LoopVectorization.check_args(x, x, FallbackArrayWrapper(x))
32+
@test @inferred !LoopVectorization.check_args(x, x, FallbackArrayWrapper(x), FallbackArrayWrapper(x))
33+
@test @inferred !LoopVectorization.check_args(['a'])
34+
@test @inferred !LoopVectorization.check_args(Diagonal(x))
35+
36+
@test_nowarn msdavx(x)
37+
lnn = LineNumberNode(14, joinpath(pkgdir(LoopVectorization),"test","fallback.jl"))
38+
warnstring = "$(lnn):\n`LoopVectorization.check_args` on your inputs failed; running fallback `@inbounds @fastmath` loop instead.\nUse `warn_check_args=false`, e.g. `@turbo warn_check_args=false ...`, to disable this warning."
39+
40+
@test_logs (:warn,warnstring) msdavx(FallbackArrayWrapper(x))
41+
@test msdavx(FallbackArrayWrapper(x)) == 1e18
42+
@test msd(x) == msdavx(FallbackArrayWrapper(x))
43+
@test msdavx(x) != msdavx(FallbackArrayWrapper(x))
44+
45+
x = rand(1000); # should be long enough to make zero differences incredibly unlikely
46+
@test exp.(x) != (@turbo exp.(x))
47+
@test exp.(x) == (@turbo exp.(FallbackArrayWrapper(x)))
4548
end
4649

0 commit comments

Comments
 (0)