Repository navigation
Conversation
Converting an array for a launch took its pointer with `pointer`, which, outside an operation that CUDACore submits, takes ownership of the memory for the task's stream and marks it escaped. A launch on another stream (`@cuda backend=cuTile stream=s`, or `cuTile.launch` with `stream=s`) was then not ordered after work on the task's stream that used the array, and later work on the task's stream was not ordered after the launch: both read stale data. Only memory last used on a third stream was ordered, by blocking the host until that stream finished. Do what CUDACore's conversion of a `CuArray` for its own kernels does: `kernel_convert(::TileBackend, x, managed)` converts with a `KernelAdaptor` that records the memory of `CuArray`s and their strided views in `managed` and computes their address without taking ownership, and CUDACore's launch acquires that memory on the launch's stream. `cuTile.launch` now launches through the same pipeline as `@cuda`. `cuTileconvert` and other arrays take their pointer as before. CUDACore's `check_capture`, which the conversion uses as CUDACore's own does, needs CUDACore 6.5.
This was referenced Dec 3, 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.
A cuTile launch on a stream other than the task's wasn't ordered with other work on its arrays. With
awritten by a kernel on the task's stream,@cuda backend=cuTile stream=s copy(b, a)read the old contents ofain every trial; with a copy on a busys, readingbon the task's stream (Array(b)) returned the old contents too. A CUDA.jl@cudalaunch orders both.Converting an array took its pointer with
pointer, which, outside an operation CUDACore submits, takes ownership of the memory for the task's stream and marks it escaped, so CUDACore never synchronizes it with the launch's stream. (Memory last used on a third stream did get ordered, but by blocking the host in the conversion until that stream finished: 350 ms in the test.)The conversion now does what CUDACore's conversion of a
CuArrayfor its own kernels does:kernel_convert(::TileBackend, x, managed)records the memory ofCuArrays and their strided views inmanagedand computes their address without taking ownership, and CUDACore's launch acquires that memory on the launch's stream.cuTile.launch(...; stream=s)had the same problem and now launches through the same pipeline as@cuda.Not covered: arrays that a user's Adapt rule converts by calling
TileArray(x)directly rather thanAdapt.adapt(to, x), and arrays wrapped in something other than a strided view, still take their pointer as before. Tiled broadcast andmapreduceconvert their arrays up front and launch on the task's stream; #394 moves them onto this path.check_capture, which the conversion calls as CUDACore's own does, needs CUDACore 6.5, so this raises the lower bound.