Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reporting a bug when Tullio being included with LoopVectorization #160

Open
zxm403089989 opened this issue Nov 15, 2022 · 1 comment
Open

Comments

@zxm403089989
Copy link

In this simple example, if just including Tullio, everythings works well.

using Tullio,BenchmarkTools
t=collect(range(start=-3,step=0.01,stop=3));
nb(e)::Float64=inv(expm1(e/1e-4))
@btime @tullio test1[n]:=nb(t[n])
1.800 μs (1 allocation: 4.88 KiB)
601-element Vector{Float64}:

However if I include LoopVectorization and TensorCast next:

using LoopVectorization,TensorCast
@btime @tullio test2[n]:=nb(t[n])
7.850 μs (49 allocations: 7.62 KiB)
┌ Warning: #= C:\Users\.julia\packages\Tullio\NGyNM\src\macro.jl:1093 =#:
│ `LoopVectorization.check_args` on your inputs failed; running fallback `@inbounds @fastmath` loop instead.
│ Use `warn_check_args=false`, e.g. `@turbo warn_check_args=false ...`, to disable this warning.
└ @ Main C:\Users\.julia\packages\LoopVectorization\FMfT8\src\condense_loopset.jl:1049
601-element Vector{Float64}:

After I several times tries, I found this error is related with function type declear. When I define function, no matter declear argument type of return type, with the coexistence with LoopVectorization and TensorCast, LoopVectorization would throw this error.

@mcabbott
Copy link
Owner

I think the issue is the ::Float64 annotation with LoopVectorization:

julia> using Tullio, LoopVectorization

julia> t=collect(range(start=-3,step=0.01,stop=3));

julia> nb(e)::Float64 = inv(expm1(e/1e-4));

julia> @tullio test1[n] := nb(t[n]);
┌ Warning: #= /Users/me/.julia/packages/Tullio/NGyNM/src/macro.jl:1093 =#:
│ `LoopVectorization.check_args` on your inputs failed; running fallback `@inbounds @fastmath` loop instead.
│ Use `warn_check_args=false`, e.g. `@turbo warn_check_args=false ...`, to disable this warning.
└ @ Main ~/.julia/packages/LoopVectorization/7xFHi/src/condense_loopset.jl:1053

julia> nb_any(e) = inv(expm1(e/1e-4));  # the same, without ::Float64

julia> @tullio test1[n] := nb_any(t[n]);

LoopVectorization works by sending special Vec types contianing several floats through your code, and I presume the above warning comes from noticing that this will fail:

julia> x = LoopVectorization.VectorizationBase.Vec{4,Float64}(1,2,3,4) * 1e-6
VectorizationBase.Vec{4, Float64}<1.0e-6, 2.0e-6, 3.0e-6, 4.0e-6>

julia> nb_any(x)
VectorizationBase.Vec{4, Float64}<99.50083333194446, 49.50166665555567, 32.835833295834135, 24.503333244447838>

julia> nb(x)
ERROR: TypeError: in typeassert, expected Float64, got a value of type VectorizationBase.Vec{4, Float64}

BenchmarkTools and TensorCast are uninvolved.

@mcabbott mcabbott changed the title Reporting a bug when Tullio being included with TensorCast and LoopVectorization together Reporting a bug when Tullio being included with LoopVectorization Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants