Skip to content

@turbo on loop with sin functions gives error #307

@Chiil

Description

@Chiil

The following code crashes:

using BenchmarkTools
using LoopVectorization

itot = 384 
dx = 1. / itot
x = dx*collect(0:itot-1); y = dx*collect(0:itot-1); z = dx*collect(0:itot-1)
u = zeros(itot+8, itot+8, itot+8)

function assign!(u, x, y, z)
    @turbo for k in 1:length(z)
        for j in 1:length(y)
            for i in 1:length(x)
                u[i, j, k] = sin(x[i]) + sin(y[j]) + sin(z[k])
            end 
        end 
    end 
end

uv = @view u[5:5+itot-1, 5:5+itot-1, 5:5+itot-1]
@btime assign!(uv, x, y, z)

with errors:

  [1] fmap
    @ ~/.julia/packages/VectorizationBase/PFhof/src/vecunroll/fmap.jl:3 [inlined]
  [2] vtrunc
    @ ~/.julia/packages/VectorizationBase/PFhof/src/vecunroll/fmap.jl:54 [inlined]
  [3] trunc
    @ ~/.julia/packages/VectorizationBase/PFhof/src/base_defs.jl:47 [inlined]
  [4] sin_fast
    @ ~/.julia/packages/SLEEFPirates/F4zF8/src/trig.jl:200 [inlined]
  [5] macro expansion
    @ ~/.julia/dev/LoopVectorization/src/reconstruct_loopset.jl:706 [inlined]
  [6] _turbo_!
    @ ~/.julia/dev/LoopVectorization/src/reconstruct_loopset.jl:706 [inlined]
  [7] assign!(u::SubArray{Float64, 3, Array{Float64, 3}, Tuple{UnitRange{Int64}, UnitRange{Int64}, UnitRange{Int64}}, false}, x::Vector{Float64}, y::Vector{Float64}, z::Vector{Float64})
    @ Main ~/devel/stencilbuilder/julia/oink.jl:16
  [8] var"##core#263"()
    @ Main ~/.julia/packages/BenchmarkTools/tGTCy/src/execution.jl:479
  [9] var"##sample#264"(__params::BenchmarkTools.Parameters)
    @ Main ~/.julia/packages/BenchmarkTools/tGTCy/src/execution.jl:485
 [10] _run(b::BenchmarkTools.Benchmark, p::BenchmarkTools.Parameters; verbose::Bool, pad::String, kwargs::Base.Iterators.Pairs{Symbol, Integer, NTuple{4, Symbol}, NamedTuple{(:samples, :evals, :gctrial, :gcsample), Tuple{Int64, Int64, Bool, Bool}}})
    @ BenchmarkTools ~/.julia/packages/BenchmarkTools/tGTCy/src/execution.jl:98
 [11] #invokelatest#2
    @ ./essentials.jl:710 [inlined]
 [12] #run_result#45
    @ ~/.julia/packages/BenchmarkTools/tGTCy/src/execution.jl:33 [inlined]
 [13] run(b::BenchmarkTools.Benchmark, p::BenchmarkTools.Parameters; progressid::Nothing, nleaves::Float64, ndone::Float64, kwargs::Base.Iterators.Pairs{Symbol, Integer, NTuple{5, Symbol}, NamedTuple{(:verbose, :samples, :evals, :gctrial, :gcsample), Tuple{Bool, Int64, Int64, Bool, Bool}}})
    @ BenchmarkTools ~/.julia/packages/BenchmarkTools/tGTCy/src/execution.jl:116
 [14] #warmup#54
    @ ~/.julia/packages/BenchmarkTools/tGTCy/src/execution.jl:168 [inlined]
 [15] warmup(item::BenchmarkTools.Benchmark)
    @ BenchmarkTools ~/.julia/packages/BenchmarkTools/tGTCy/src/execution.jl:168
 [16] top-level scope
    @ ~/.julia/packages/BenchmarkTools/tGTCy/src/execution.jl:565
    ```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions