Repository navigation
Conversation
…not array types
`adapt(to, a)` applied only the storage rule of `to` to a `FixedSizeArray` as a
whole. Adaptors which are not array types (e.g. the ones converting the
arguments of a GPU kernel) have storage rules only for the arrays they know, so
they returned the `FixedSizeArray` unchanged, and a `FixedSizeArray` backed by
a `Vector` or a GPU vector could not be passed to a kernel ("passing
non-bitstype argument"). Arrays with static dimensions already adapted the
memory backend and were wrapped again.
Restrict the conversion as a whole to adaptors which are array types, e.g.
`adapt(CuArray, a)` is still a `CuArray`, and adapt the memory backend for all
other adaptors, with and without static dimensions.
Assisted-by: Claude Code (Fable 5.2)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #235 +/- ##
==========================================
+ Coverage 94.73% 95.48% +0.74%
==========================================
Files 8 8
Lines 323 332 +9
==========================================
+ Hits 306 317 +11
+ Misses 17 15 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
giordano
approved these changes
Nov 26, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With Adapt.jl loaded,
adapt(to, a)applies only the storage rule oftoto aFixedSizeArrayaas a whole:That is what we want for array types (
adapt(CuArray, a)is aCuArray), but adaptors which are not array types usually have storage rules only for the arrays they know. In particular, the adaptors that convert the arguments of a GPU kernel turn aVectororCuVectorinto anisbitsdevice array and fall back to the identity for everything else. AFixedSizeArraytherefore reaches the kernel unchanged and compilation fails. This shows up in trixi-framework/Trixi.jl#3357 with the POCL backend of KernelAbstractions.jl:Arrays with static dimensions are not affected, since their rule already adapts the memory backend and wraps it again. In the same kernel call the solution array (static dimensions) is converted correctly.
Change
The conversion as a whole is restricted to adaptors which are array types (
to::Type{<:AbstractArray}). All other adaptors now use the rule ofFixedSizeArrayDims: adapt the memory backend and wrap it again, with and without static dimensions.Unchanged:
adapt(Array, a),adapt(CuArray, a), etc. still convert aFixedSizeArrayas a whole, andadapt(FixedSizeArray, x)behaves as before.Changed: an adaptor that is not an array type but has a storage rule matching a
FixedSizeArrayas a whole (e.g. one forAbstractArray) is now given the memory backend instead, so the result is aFixedSizeArrayover the adapted vector rather than whatever that rule returned for the whole array.Testing
Vector, returning anisbitsdevice vector), for arrays with and without static dimensions and inside aTranspose.The CHANGELOG entry is under a new "Unreleased" heading; I did not bump the version.
This PR was prepared with the assistance of Claude Code.
🤖 Generated with Claude Code