Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Guard cuDevSmResourceSplit C++ declarations with CUDA_VERSION >= 13010
The decltype(&cuDevSmResourceSplit) declaration fails to compile when
building against CUDA 12.x headers, which don't have this symbol.
Use a void* placeholder on < 13.1, and guard the wrapper implementation
to return CUDA_ERROR_NOT_SUPPORTED.
  • Loading branch information
leofang committed May 12, 2026
commit cb2cb09d8fd50e67891de6135c27211de4ca9ba8
8 changes: 8 additions & 0 deletions cuda_core/cuda/core/_cpp/resource_handles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ decltype(&cuGraphicsUnmapResources) p_cuGraphicsUnmapResources = nullptr;
decltype(&cuGraphicsUnregisterResource) p_cuGraphicsUnregisterResource = nullptr;

// SM resource split (13.1+ — may be null on older drivers/bindings)
#if CUDA_VERSION >= 13010
decltype(&cuDevSmResourceSplit) p_cuDevSmResourceSplit = nullptr;
#else
void* p_cuDevSmResourceSplit = nullptr;
#endif

// NVRTC function pointers
decltype(&nvrtcDestroyProgram) p_nvrtcDestroyProgram = nullptr;
Expand Down Expand Up @@ -1329,12 +1333,16 @@ FileDescriptorHandle create_fd_handle_ref(int fd) {
CUresult sm_resource_split(CUdevResource* result, unsigned int nbGroups,
const CUdevResource* input, CUdevResource* remainder,
unsigned int flags, void* groupParams) {
#if CUDA_VERSION >= 13010
if (!p_cuDevSmResourceSplit) {
return CUDA_ERROR_NOT_SUPPORTED;
}
return p_cuDevSmResourceSplit(
result, nbGroups, input, remainder, flags,
static_cast<CU_DEV_SM_RESOURCE_GROUP_PARAMS*>(groupParams));
#else
return CUDA_ERROR_NOT_SUPPORTED;
#endif
}

bool has_sm_resource_split() noexcept {
Expand Down
6 changes: 6 additions & 0 deletions cuda_core/cuda/core/_cpp/resource_handles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,13 @@ extern decltype(&cuGraphicsUnmapResources) p_cuGraphicsUnmapResources;
extern decltype(&cuGraphicsUnregisterResource) p_cuGraphicsUnregisterResource;

// SM resource split (13.1+ — may be null on older drivers/bindings)
#if CUDA_VERSION >= 13010
extern decltype(&cuDevSmResourceSplit) p_cuDevSmResourceSplit;
#else
// cuDevSmResourceSplit doesn't exist in CUDA < 13.1 headers, so use a
// void* placeholder. The pointer is always null when built against 12.x.
extern void* p_cuDevSmResourceSplit;
#endif

// ============================================================================
// NVRTC function pointers
Expand Down
Loading