@inbounds is missing in these loops which shaves off about 2x of benchmarks
julia> @btime round(A,5);
11.977 ms (2 allocations: 38.15 MiB)
julia> @btime round2(A,5);
5.447 ms (2 allocations: 38.15 MiB)
with round2 being
function round2(X::AbstractArray{Float32},nsb::Integer)
semask = setmask32(nsb)
s = shift32(nsb)
shmask = ~mask32(nsb)
Y = similar(X) # preallocate
@inbounds for i in eachindex(X)
Y[i] = round(X[i],semask,s,shmask)
end
return Y
end
https://github.com/milankl/BitInformation.jl/blob/b335571f5d56c12df579c39ccca1bc29b681f61e/src/round.jl#L48
@inbounds is missing in these loops which shaves off about 2x of benchmarks
with
round2
being