Skip to content

Commit

Permalink
Avoid capturing MArrays in BoundsError
Browse files Browse the repository at this point in the history
This quirk allows bounds checking of `MArray`s on device in more cases.
This is a workaround to address
<JuliaGPU#2313>.
  • Loading branch information
lcw committed Apr 3, 2024
1 parent 7f725c0 commit 45cf38e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ext/StaticArraysExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@ import StaticArrays
@device_override @noinline StaticArrays.dimension_mismatch_fail(::Type{SA}, a::AbstractArray) where {SA<:StaticArrays.StaticArray} =
@print_and_throw("DimensionMismatch while trying to convert to StaticArray: Expected and actual length of input array differ.")

end # extension module
@device_override function Base.checkbounds(A::StaticArrays.MArray, I...)
@inline
checkbounds(Bool, A, I...) || @print_and_throw("BoundsError while indexing an MArray.")
nothing
end

end # extension module

0 comments on commit 45cf38e

Please sign in to comment.