Skip to content

Detect contiguous views with mixed unit-range indices#704

Merged
maleadt merged 3 commits intomasterfrom
tb/contiguous
Apr 14, 2026
Merged

Detect contiguous views with mixed unit-range indices#704
maleadt merged 3 commits intomasterfrom
tb/contiguous

Conversation

@maleadt
Copy link
Copy Markdown
Member

@maleadt maleadt commented Apr 10, 2026

The static GPUIndexStyle dispatch couldn't recognize index tuples like (1:1, 1:1) or (1:5, 2:3, 1:1) as contiguous because the lengths of UnitRange{Int} aren't visible at the type level. Add a MaybeContiguous tag for (::AbstractUnitRange, ::AbstractUnitRange, ...) patterns and a runtime stride check that decides whether to take the contiguous fast path. Makes things type-unstable, but views being contiguous is much more important, I think.

Fixes JuliaGPU/CUDA.jl#2653. cc @kshyatt

maleadt and others added 3 commits April 14, 2026 14:51
The static `GPUIndexStyle` dispatch couldn't recognize index tuples like
`(1:1, 1:1)` or `(1:5, 2:3, 1:1)` as contiguous because the lengths of
`UnitRange{Int}` aren't visible at the type level. Add a `MaybeContiguous`
tag for `(::AbstractUnitRange, ::AbstractUnitRange, ...)` patterns and a
runtime stride check that decides whether to take the contiguous fast path.

Fixes JuliaGPU/CUDA.jl#2653.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@maleadt maleadt merged commit 99e4e1f into master Apr 14, 2026
20 of 21 checks passed
@maleadt maleadt deleted the tb/contiguous branch April 14, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1-element view not recognized as contiguous

1 participant