Skip to content

Commit 818a440

Browse files
Andy-Jostclaude
andcommitted
fix(cuda.core): query capture state with cuStreamIsCapturing in the VMM deleter
cuStreamGetCaptureInfo has two slots in the cuda-bindings loader (v2 and v3) and a different arity per CUDA major, which needed a build-major fence and broke the driver-table test that builds a fake table from the first slot per name. cuStreamIsCapturing is the query that cuStreamGetCaptureInfo makes first: same status, including the implicit capture error for the legacy stream, one slot, one signature. Co-Authored-By: Claude Fable 5.1 <[email protected]>
1 parent 012c0ff commit 818a440

3 files changed

Lines changed: 7 additions & 10 deletions

File tree

‎cuda_core/cuda/core/_cpp/rt/VMM_DESIGN.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ size_t mem_allocation_size(...) noexcept; size_t va_reservation_size(...) noexc
7070
Factories return the handle and put the status in thread-local `err`, as the other factories do;
7171
an empty input handle sets `err` too, so an empty result always carries a status.
7272
`create_va_mapping_handle` checks that the range lies inside the reservation, maps, and applies
73-
access; if access fails it unmaps and returns empty. The eight VMM entry points, plus
74-
`cuStreamSynchronize` and `cuStreamGetCaptureInfo`, join the `driver_api` pointer table.
73+
access; if access fails it unmaps and returns empty. The seven VMM entry points, plus
74+
`cuStreamSynchronize`, `cuStreamIsCapturing` and `cuThreadExchangeStreamCaptureMode`, join the
75+
`driver_api` function table.
7576

7677
### The range and the device pointer
7778

‎cuda_core/cuda/core/_cpp/rt/driver_api.hpp‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ namespace cuda_core::rt {
137137
X(cuMemSetAccess, 10020) \
138138
/* cuda-bindings requests 7000 (PTDS) or 2000 (legacy) */ \
139139
X(cuStreamSynchronize, 7000) \
140-
/* cuda.h maps to _v3 (12030) on the CUDA 13 header, _v2 (11030) on CUDA 12 */ \
141-
X(cuStreamGetCaptureInfo, 12030) \
140+
X(cuStreamIsCapturing, 10000) \
142141
X(cuThreadExchangeStreamCaptureMode, 10010)
143142

144143
#define CUDA_CORE_DECLARE_DRIVER_FN(name, introduced) extern decltype(&name) p_##name;

‎cuda_core/cuda/core/_cpp/rt/virtual_memory.cpp‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,11 @@ MemAllocationHandle va_mapping_allocation(const VaMappingHandle& h) noexcept {
167167
// is capturing, or it is the legacy stream while a blocking stream in its
168168
// context is capturing (the query reports that as
169169
// CUDA_ERROR_STREAM_CAPTURE_IMPLICIT). cuStreamSynchronize would invalidate
170-
// such a capture; cuStreamGetCaptureInfo does not.
170+
// such a capture; cuStreamIsCapturing does not. It is the query
171+
// cuStreamGetCaptureInfo makes first, with one signature on every CUDA major.
171172
static bool sync_would_disturb_capture(CUstream stream) noexcept {
172173
CUstreamCaptureStatus status = CU_STREAM_CAPTURE_STATUS_NONE;
173-
#if CUDA_CORE_BUILD_MAJOR >= 13
174-
const CUresult result = DRIVER_CALL(cuStreamGetCaptureInfo, stream, &status, nullptr, nullptr, nullptr, nullptr, nullptr);
175-
#else
176-
const CUresult result = DRIVER_CALL(cuStreamGetCaptureInfo, stream, &status, nullptr, nullptr, nullptr, nullptr);
177-
#endif
174+
const CUresult result = DRIVER_CALL(cuStreamIsCapturing, stream, &status);
178175
if (result == CUDA_ERROR_STREAM_CAPTURE_IMPLICIT) {
179176
return true;
180177
}

0 commit comments

Comments
 (0)