You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using StrideArrays.jl with Julia v1.11 and --check-bounds=no, PtrArrays will cause a type instability that only manifests when loading StrideArrays.jl, but not when loading StrideArraysCore.jl.
I know all the arguments for and against --check-bounds=no, but this seems to me like it should work (or at least be fixable), which would likely mean that --check-bounds=no becomes usable again for us in Trixi-land...
MWE
For this I used Julia v1.11.3 on a Linux machine.
Install packages first with (only needed once)
julia --project=. --check-bounds=no -e 'using Pkg; Pkg.add(["StrideArrays", "StrideArraysCore"])'
This currently install StrideArrays.jl v0.1.29 with StrideArraysCore.jl v0.5.7.
Then, start the Julia REPL with julia --project=. --check-bounds=no and execute either
using StrideArraysCore: PtrArray, StaticInt
_u =zeros(1)
u =PtrArray(pointer(_u), (StaticInt(1),))
@code_warntype u[1]
or
using StrideArrays: PtrArray, StaticInt
_u =zeros(1)
u =PtrArray(pointer(_u), (StaticInt(1),))
@code_warntype u[1]
The first one (with StrideArraysCore.jl) will give you
Loading StrideArrays.jl makes the final pointer arithmetic in StrideArraysCore.unsafe_getindex(u, 1) type unstable - I guess since some new methods are added and heuristics drop inferring further.
🤦 I guess it would have been sensible to check that first. However, given that I posted this already 1.5 years ago, I really didn't have it on the radar anymore :-/
When using StrideArrays.jl with Julia v1.11 and
--check-bounds=no
,PtrArray
s will cause a type instability that only manifests when loading StrideArrays.jl, but not when loading StrideArraysCore.jl.I know all the arguments for and against
--check-bounds=no
, but this seems to me like it should work (or at least be fixable), which would likely mean that--check-bounds=no
becomes usable again for us in Trixi-land...MWE
For this I used Julia v1.11.3 on a Linux machine.
Install packages first with (only needed once)
julia --project=. --check-bounds=no -e 'using Pkg; Pkg.add(["StrideArrays", "StrideArraysCore"])'
This currently install StrideArrays.jl v0.1.29 with StrideArraysCore.jl v0.5.7.
Then, start the Julia REPL with
julia --project=. --check-bounds=no
and execute eitheror
The first one (with StrideArraysCore.jl) will give you
while the second one will give you
That is, in the second version
StrideArraysCore.unsafe_getindex(A, i)::Any
is type unstable.Note that you need to execute Julia in between, since once you've loaded StrideArrays.jl, there's no going back.
The text was updated successfully, but these errors were encountered: