Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ cuda_bindings/cuda/bindings/_bindings/cynvrtc.pxd
cuda_bindings/cuda/bindings/_bindings/cynvrtc.pyx
cuda_bindings/cuda/bindings/_internal/nvjitlink.pyx
cuda_bindings/cuda/bindings/_internal/nvvm.pyx
cuda_bindings/cuda/bindings/_lib/cyruntime/cyruntime.pxd
cuda_bindings/cuda/bindings/_lib/cyruntime/cyruntime.pyx
cuda_bindings/cuda/bindings/_lib/cyruntime/utils.pxd
cuda_bindings/cuda/bindings/_lib/cyruntime/utils.pyx
cuda_bindings/cuda/bindings/_lib/utils.pxd
cuda_bindings/cuda/bindings/_lib/utils.pyx
cuda_bindings/cuda/bindings/cydriver.pxd
Expand Down Expand Up @@ -115,6 +111,7 @@ instance/

# Sphinx documentation
docs_src/_build/
*/docs/source/generated/

# PyBuilder
.pybuilder/
Expand Down
11 changes: 8 additions & 3 deletions cuda_bindings/cuda/bindings/_bindings/cydriver.pyx.in
Original file line number Diff line number Diff line change
Expand Up @@ -495,10 +495,8 @@ cdef bint __cuPythonInit = False
ctypedef CUresult (*__cuGetProcAddress_v2_T)(const char*, void**, int, cuuint64_t, CUdriverProcAddressQueryResult*) except?CUDA_ERROR_NOT_FOUND nogil
cdef __cuGetProcAddress_v2_T _F_cuGetProcAddress_v2 = NULL

cdef int cuPythonInit() except -1 nogil:
cdef int _cuPythonInit() except -1 nogil:
global __cuPythonInit
if __cuPythonInit:
return 0

cdef bint usePTDS
cdef char libPath[260]
Expand Down Expand Up @@ -8946,6 +8944,13 @@ cdef int cuPythonInit() except -1 nogil:
__cuPythonInit = True
return 0

# Create a very small function to check whether we are init'ed, so the C
# compiler can inline it.
cdef inline int cuPythonInit() except -1 nogil:
if __cuPythonInit:
return 0
return _cuPythonInit()

{{if 'cuGetErrorString' in found_functions}}

cdef CUresult _cuGetErrorString(CUresult error, const char** pStr) except ?CUDA_ERROR_NOT_FOUND nogil:
Expand Down
11 changes: 8 additions & 3 deletions cuda_bindings/cuda/bindings/_bindings/cynvrtc.pyx.in
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ cdef bint __cuPythonInit = False
{{if 'nvrtcGetPCHHeapSizeRequired' in found_functions}}cdef void *__nvrtcGetPCHHeapSizeRequired = NULL{{endif}}
{{if 'nvrtcSetFlowCallback' in found_functions}}cdef void *__nvrtcSetFlowCallback = NULL{{endif}}

cdef int cuPythonInit() except -1 nogil:
cdef int _cuPythonInit() except -1 nogil:
global __cuPythonInit
if __cuPythonInit:
return 0

# Load library
with gil, __symbol_lock:
Expand Down Expand Up @@ -349,6 +347,13 @@ cdef int cuPythonInit() except -1 nogil:
__cuPythonInit = True
return 0

# Create a very small function to check whether we are init'ed, so the C
# compiler can inline it.
cdef inline int cuPythonInit() except -1 nogil:
if __cuPythonInit:
return 0
return _cuPythonInit()

{{if 'nvrtcGetErrorString' in found_functions}}

cdef const char* _nvrtcGetErrorString(nvrtcResult result) except ?NULL nogil:
Expand Down
2 changes: 2 additions & 0 deletions cuda_bindings/cuda/bindings/_bindings/cyruntime.pxd.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# This code was automatically generated with version 12.9.0. Do not modify it directly.
include "../cyruntime_types.pxi"

include "../_lib/cyruntime/cyruntime.pxd"

{{if 'cudaDeviceReset' in found_functions}}

cdef cudaError_t _cudaDeviceReset() except ?cudaErrorCallRequiresNewerDriver nogil
Expand Down
15 changes: 12 additions & 3 deletions cuda_bindings/cuda/bindings/_bindings/cyruntime.pyx.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@ cimport cython

cdef bint __cudaPythonInit = False
cdef bint __usePTDS = False
cdef int cudaPythonInit() except -1 nogil:
cdef int _cudaPythonInit() except -1 nogil:
global __cudaPythonInit
global __usePTDS
if __cudaPythonInit:
return __usePTDS

with gil:
__usePTDS = os.getenv('CUDA_PYTHON_CUDA_PER_THREAD_DEFAULT_STREAM', default=False)
__cudaPythonInit = True
return __usePTDS

# Create a very small function to check whether we are init'ed, so the C
# compiler can inline it.
cdef inline int cudaPythonInit() except -1 nogil:
if __cudaPythonInit:
return __usePTDS
return _cudaPythonInit()

{{if 'cudaDeviceReset' in found_functions}}

cdef cudaError_t _cudaDeviceReset() except ?cudaErrorCallRequiresNewerDriver nogil:
Expand Down Expand Up @@ -2647,3 +2653,6 @@ cdef cudaError_t _cudaProfilerStop() except ?cudaErrorCallRequiresNewerDriver no
return ptds._cudaProfilerStop()
return cudaProfilerStop()
{{endif}}


include "../_lib/cyruntime/cyruntime.pxi"
43 changes: 43 additions & 0 deletions cuda_bindings/cuda/bindings/_lib/cyruntime/cyruntime.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# SPDX-FileCopyrightText: Copyright (c) 2021-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE

cimport cuda.bindings.cyruntime as cyruntime
cimport cuda.bindings._bindings.cydriver as _cydriver

# These graphics API are the reimplemented version of what's supported by CUDA Runtime.
# Issue https://github.com/NVIDIA/cuda-python/issues/488 will remove them by letting us
# use call into the static library directly.
#
# This is an ABI breaking change which can only happen in a major version bump.

# This file is included from cuda/bindings/_bindings/cyruntime.pxd.in but kept in a
# separate file to keep it separated from the auto-generated code there.

# Prior to https://github.com/NVIDIA/cuda-python/pull/914, this was two
# independent modules (c.b._lib.cyruntime.cyruntime and
# c.b._lib.cyruntime.utils), but was merged into one.

cdef cudaError_t _cudaEGLStreamProducerPresentFrame(cyruntime.cudaEglStreamConnection* conn, cyruntime.cudaEglFrame eglframe, cudaStream_t* pStream) except ?cudaErrorCallRequiresNewerDriver nogil
cdef cudaError_t _cudaEGLStreamProducerReturnFrame(cyruntime.cudaEglStreamConnection* conn, cyruntime.cudaEglFrame* eglframe, cudaStream_t* pStream) except ?cudaErrorCallRequiresNewerDriver nogil
cdef cudaError_t _cudaGraphicsResourceGetMappedEglFrame(cyruntime.cudaEglFrame* eglFrame, cudaGraphicsResource_t resource, unsigned int index, unsigned int mipLevel) except ?cudaErrorCallRequiresNewerDriver nogil
cdef cudaError_t _cudaVDPAUSetVDPAUDevice(int device, cyruntime.VdpDevice vdpDevice, cyruntime.VdpGetProcAddress* vdpGetProcAddress) except ?cudaErrorCallRequiresNewerDriver nogil
cdef cudaError_t _cudaVDPAUGetDevice(int* device, cyruntime.VdpDevice vdpDevice, cyruntime.VdpGetProcAddress* vdpGetProcAddress) except ?cudaErrorCallRequiresNewerDriver nogil
cdef cudaError_t _cudaGraphicsVDPAURegisterVideoSurface(cudaGraphicsResource** resource, cyruntime.VdpVideoSurface vdpSurface, unsigned int flags) except ?cudaErrorCallRequiresNewerDriver nogil
cdef cudaError_t _cudaGraphicsVDPAURegisterOutputSurface(cudaGraphicsResource** resource, cyruntime.VdpOutputSurface vdpSurface, unsigned int flags) except ?cudaErrorCallRequiresNewerDriver nogil
cdef cudaError_t _cudaGLGetDevices(unsigned int* pCudaDeviceCount, int* pCudaDevices, unsigned int cudaDeviceCount, cyruntime.cudaGLDeviceList deviceList) except ?cudaErrorCallRequiresNewerDriver nogil
cdef cudaError_t _cudaGraphicsGLRegisterImage(cudaGraphicsResource** resource, cyruntime.GLuint image, cyruntime.GLenum target, unsigned int flags) except ?cudaErrorCallRequiresNewerDriver nogil
cdef cudaError_t _cudaGraphicsGLRegisterBuffer(cudaGraphicsResource** resource, cyruntime.GLuint buffer, unsigned int flags) except ?cudaErrorCallRequiresNewerDriver nogil
cdef cudaError_t _cudaGraphicsEGLRegisterImage(cudaGraphicsResource_t* pCudaResource, cyruntime.EGLImageKHR image, unsigned int flags) except ?cudaErrorCallRequiresNewerDriver nogil
cdef cudaError_t _cudaEGLStreamConsumerConnect(cyruntime.cudaEglStreamConnection* conn, cyruntime.EGLStreamKHR eglStream) except ?cudaErrorCallRequiresNewerDriver nogil
cdef cudaError_t _cudaEGLStreamConsumerConnectWithFlags(cyruntime.cudaEglStreamConnection* conn, cyruntime.EGLStreamKHR eglStream, unsigned int flags) except ?cudaErrorCallRequiresNewerDriver nogil
cdef cudaError_t _cudaEGLStreamConsumerDisconnect(cyruntime.cudaEglStreamConnection* conn) except ?cudaErrorCallRequiresNewerDriver nogil
cdef cudaError_t _cudaEGLStreamConsumerAcquireFrame(cyruntime.cudaEglStreamConnection* conn, cudaGraphicsResource_t* pCudaResource, cudaStream_t* pStream, unsigned int timeout) except ?cudaErrorCallRequiresNewerDriver nogil
cdef cudaError_t _cudaEGLStreamConsumerReleaseFrame(cyruntime.cudaEglStreamConnection* conn, cudaGraphicsResource_t pCudaResource, cudaStream_t* pStream) except ?cudaErrorCallRequiresNewerDriver nogil
cdef cudaError_t _cudaEGLStreamProducerConnect(cyruntime.cudaEglStreamConnection* conn, cyruntime.EGLStreamKHR eglStream, cyruntime.EGLint width, cyruntime.EGLint height) except ?cudaErrorCallRequiresNewerDriver nogil
cdef cudaError_t _cudaEGLStreamProducerDisconnect(cyruntime.cudaEglStreamConnection* conn) except ?cudaErrorCallRequiresNewerDriver nogil
cdef cudaError_t _cudaEventCreateFromEGLSync(cudaEvent_t* phEvent, cyruntime.EGLSyncKHR eglSync, unsigned int flags) except ?cudaErrorCallRequiresNewerDriver nogil

# utility functions

cdef cudaError_t getDriverEglFrame(_cydriver.CUeglFrame *cuEglFrame, cyruntime.cudaEglFrame eglFrame) except ?cudaErrorCallRequiresNewerDriver nogil
cdef cudaError_t getRuntimeEglFrame(cyruntime.cudaEglFrame *eglFrame, _cydriver.CUeglFrame cueglFrame) except ?cudaErrorCallRequiresNewerDriver nogil
29 changes: 0 additions & 29 deletions cuda_bindings/cuda/bindings/_lib/cyruntime/cyruntime.pxd.in

This file was deleted.

Loading
Loading