Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
16,381 changes: 8,192 additions & 8,189 deletions cuda_bindings/cuda/bindings/_bindings/cydriver.pyx.in

Large diffs are not rendered by default.

223 changes: 111 additions & 112 deletions cuda_bindings/cuda/bindings/_bindings/cynvrtc.pyx.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ from libc.stdint cimport uintptr_t
{{endif}}
from cuda.pathfinder import load_nvidia_dynamic_lib
from libc.stdint cimport intptr_t
import threading

cdef object __symbol_lock = threading.Lock()
cdef bint __cuPythonInit = False
{{if 'nvrtcGetErrorString' in found_functions}}cdef void *__nvrtcGetErrorString = NULL{{endif}}
{{if 'nvrtcVersion' in found_functions}}cdef void *__nvrtcVersion = NULL{{endif}}
Expand Down Expand Up @@ -40,23 +42,15 @@ cdef bint __cuPythonInit = False

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

# Load library
{{if 'Windows' == platform.system()}}
with gil:
handle = load_nvidia_dynamic_lib("nvrtc")._handle_uint
{{else}}
with gil:
handle = <void*><uintptr_t>load_nvidia_dynamic_lib("nvrtc")._handle_uint
{{endif}}
with gil, __symbol_lock:
if __cuPythonInit:
return 0

{{if 'Windows' == platform.system()}}
handle = load_nvidia_dynamic_lib("nvrtc")._handle_uint

# Load function
{{if 'Windows' == platform.system()}}
with gil:
# Load function
{{if 'nvrtcGetErrorString' in found_functions}}
try:
global __nvrtcGetErrorString
Expand Down Expand Up @@ -226,105 +220,110 @@ cdef int cuPythonInit() except -1 nogil:
pass
{{endif}}

{{else}}
{{if 'nvrtcGetErrorString' in found_functions}}
global __nvrtcGetErrorString
__nvrtcGetErrorString = dlfcn.dlsym(handle, 'nvrtcGetErrorString')
{{endif}}
{{if 'nvrtcVersion' in found_functions}}
global __nvrtcVersion
__nvrtcVersion = dlfcn.dlsym(handle, 'nvrtcVersion')
{{endif}}
{{if 'nvrtcGetNumSupportedArchs' in found_functions}}
global __nvrtcGetNumSupportedArchs
__nvrtcGetNumSupportedArchs = dlfcn.dlsym(handle, 'nvrtcGetNumSupportedArchs')
{{endif}}
{{if 'nvrtcGetSupportedArchs' in found_functions}}
global __nvrtcGetSupportedArchs
__nvrtcGetSupportedArchs = dlfcn.dlsym(handle, 'nvrtcGetSupportedArchs')
{{endif}}
{{if 'nvrtcCreateProgram' in found_functions}}
global __nvrtcCreateProgram
__nvrtcCreateProgram = dlfcn.dlsym(handle, 'nvrtcCreateProgram')
{{endif}}
{{if 'nvrtcDestroyProgram' in found_functions}}
global __nvrtcDestroyProgram
__nvrtcDestroyProgram = dlfcn.dlsym(handle, 'nvrtcDestroyProgram')
{{endif}}
{{if 'nvrtcCompileProgram' in found_functions}}
global __nvrtcCompileProgram
__nvrtcCompileProgram = dlfcn.dlsym(handle, 'nvrtcCompileProgram')
{{endif}}
{{if 'nvrtcGetPTXSize' in found_functions}}
global __nvrtcGetPTXSize
__nvrtcGetPTXSize = dlfcn.dlsym(handle, 'nvrtcGetPTXSize')
{{endif}}
{{if 'nvrtcGetPTX' in found_functions}}
global __nvrtcGetPTX
__nvrtcGetPTX = dlfcn.dlsym(handle, 'nvrtcGetPTX')
{{endif}}
{{if 'nvrtcGetCUBINSize' in found_functions}}
global __nvrtcGetCUBINSize
__nvrtcGetCUBINSize = dlfcn.dlsym(handle, 'nvrtcGetCUBINSize')
{{endif}}
{{if 'nvrtcGetCUBIN' in found_functions}}
global __nvrtcGetCUBIN
__nvrtcGetCUBIN = dlfcn.dlsym(handle, 'nvrtcGetCUBIN')
{{endif}}
{{if 'nvrtcGetLTOIRSize' in found_functions}}
global __nvrtcGetLTOIRSize
__nvrtcGetLTOIRSize = dlfcn.dlsym(handle, 'nvrtcGetLTOIRSize')
{{endif}}
{{if 'nvrtcGetLTOIR' in found_functions}}
global __nvrtcGetLTOIR
__nvrtcGetLTOIR = dlfcn.dlsym(handle, 'nvrtcGetLTOIR')
{{endif}}
{{if 'nvrtcGetOptiXIRSize' in found_functions}}
global __nvrtcGetOptiXIRSize
__nvrtcGetOptiXIRSize = dlfcn.dlsym(handle, 'nvrtcGetOptiXIRSize')
{{endif}}
{{if 'nvrtcGetOptiXIR' in found_functions}}
global __nvrtcGetOptiXIR
__nvrtcGetOptiXIR = dlfcn.dlsym(handle, 'nvrtcGetOptiXIR')
{{endif}}
{{if 'nvrtcGetProgramLogSize' in found_functions}}
global __nvrtcGetProgramLogSize
__nvrtcGetProgramLogSize = dlfcn.dlsym(handle, 'nvrtcGetProgramLogSize')
{{endif}}
{{if 'nvrtcGetProgramLog' in found_functions}}
global __nvrtcGetProgramLog
__nvrtcGetProgramLog = dlfcn.dlsym(handle, 'nvrtcGetProgramLog')
{{endif}}
{{if 'nvrtcAddNameExpression' in found_functions}}
global __nvrtcAddNameExpression
__nvrtcAddNameExpression = dlfcn.dlsym(handle, 'nvrtcAddNameExpression')
{{endif}}
{{if 'nvrtcGetLoweredName' in found_functions}}
global __nvrtcGetLoweredName
__nvrtcGetLoweredName = dlfcn.dlsym(handle, 'nvrtcGetLoweredName')
{{endif}}
{{if 'nvrtcGetPCHHeapSize' in found_functions}}
global __nvrtcGetPCHHeapSize
__nvrtcGetPCHHeapSize = dlfcn.dlsym(handle, 'nvrtcGetPCHHeapSize')
{{endif}}
{{if 'nvrtcSetPCHHeapSize' in found_functions}}
global __nvrtcSetPCHHeapSize
__nvrtcSetPCHHeapSize = dlfcn.dlsym(handle, 'nvrtcSetPCHHeapSize')
{{endif}}
{{if 'nvrtcGetPCHCreateStatus' in found_functions}}
global __nvrtcGetPCHCreateStatus
__nvrtcGetPCHCreateStatus = dlfcn.dlsym(handle, 'nvrtcGetPCHCreateStatus')
{{endif}}
{{if 'nvrtcGetPCHHeapSizeRequired' in found_functions}}
global __nvrtcGetPCHHeapSizeRequired
__nvrtcGetPCHHeapSizeRequired = dlfcn.dlsym(handle, 'nvrtcGetPCHHeapSizeRequired')
{{endif}}
{{if 'nvrtcSetFlowCallback' in found_functions}}
global __nvrtcSetFlowCallback
__nvrtcSetFlowCallback = dlfcn.dlsym(handle, 'nvrtcSetFlowCallback')
{{endif}}
{{else}}
handle = <void*><uintptr_t>load_nvidia_dynamic_lib("nvrtc")._handle_uint

{{endif}}
# Load function
{{if 'nvrtcGetErrorString' in found_functions}}
global __nvrtcGetErrorString
__nvrtcGetErrorString = dlfcn.dlsym(handle, 'nvrtcGetErrorString')
{{endif}}
{{if 'nvrtcVersion' in found_functions}}
global __nvrtcVersion
__nvrtcVersion = dlfcn.dlsym(handle, 'nvrtcVersion')
{{endif}}
{{if 'nvrtcGetNumSupportedArchs' in found_functions}}
global __nvrtcGetNumSupportedArchs
__nvrtcGetNumSupportedArchs = dlfcn.dlsym(handle, 'nvrtcGetNumSupportedArchs')
{{endif}}
{{if 'nvrtcGetSupportedArchs' in found_functions}}
global __nvrtcGetSupportedArchs
__nvrtcGetSupportedArchs = dlfcn.dlsym(handle, 'nvrtcGetSupportedArchs')
{{endif}}
{{if 'nvrtcCreateProgram' in found_functions}}
global __nvrtcCreateProgram
__nvrtcCreateProgram = dlfcn.dlsym(handle, 'nvrtcCreateProgram')
{{endif}}
{{if 'nvrtcDestroyProgram' in found_functions}}
global __nvrtcDestroyProgram
__nvrtcDestroyProgram = dlfcn.dlsym(handle, 'nvrtcDestroyProgram')
{{endif}}
{{if 'nvrtcCompileProgram' in found_functions}}
global __nvrtcCompileProgram
__nvrtcCompileProgram = dlfcn.dlsym(handle, 'nvrtcCompileProgram')
{{endif}}
{{if 'nvrtcGetPTXSize' in found_functions}}
global __nvrtcGetPTXSize
__nvrtcGetPTXSize = dlfcn.dlsym(handle, 'nvrtcGetPTXSize')
{{endif}}
{{if 'nvrtcGetPTX' in found_functions}}
global __nvrtcGetPTX
__nvrtcGetPTX = dlfcn.dlsym(handle, 'nvrtcGetPTX')
{{endif}}
{{if 'nvrtcGetCUBINSize' in found_functions}}
global __nvrtcGetCUBINSize
__nvrtcGetCUBINSize = dlfcn.dlsym(handle, 'nvrtcGetCUBINSize')
{{endif}}
{{if 'nvrtcGetCUBIN' in found_functions}}
global __nvrtcGetCUBIN
__nvrtcGetCUBIN = dlfcn.dlsym(handle, 'nvrtcGetCUBIN')
{{endif}}
{{if 'nvrtcGetLTOIRSize' in found_functions}}
global __nvrtcGetLTOIRSize
__nvrtcGetLTOIRSize = dlfcn.dlsym(handle, 'nvrtcGetLTOIRSize')
{{endif}}
{{if 'nvrtcGetLTOIR' in found_functions}}
global __nvrtcGetLTOIR
__nvrtcGetLTOIR = dlfcn.dlsym(handle, 'nvrtcGetLTOIR')
{{endif}}
{{if 'nvrtcGetOptiXIRSize' in found_functions}}
global __nvrtcGetOptiXIRSize
__nvrtcGetOptiXIRSize = dlfcn.dlsym(handle, 'nvrtcGetOptiXIRSize')
{{endif}}
{{if 'nvrtcGetOptiXIR' in found_functions}}
global __nvrtcGetOptiXIR
__nvrtcGetOptiXIR = dlfcn.dlsym(handle, 'nvrtcGetOptiXIR')
{{endif}}
{{if 'nvrtcGetProgramLogSize' in found_functions}}
global __nvrtcGetProgramLogSize
__nvrtcGetProgramLogSize = dlfcn.dlsym(handle, 'nvrtcGetProgramLogSize')
{{endif}}
{{if 'nvrtcGetProgramLog' in found_functions}}
global __nvrtcGetProgramLog
__nvrtcGetProgramLog = dlfcn.dlsym(handle, 'nvrtcGetProgramLog')
{{endif}}
{{if 'nvrtcAddNameExpression' in found_functions}}
global __nvrtcAddNameExpression
__nvrtcAddNameExpression = dlfcn.dlsym(handle, 'nvrtcAddNameExpression')
{{endif}}
{{if 'nvrtcGetLoweredName' in found_functions}}
global __nvrtcGetLoweredName
__nvrtcGetLoweredName = dlfcn.dlsym(handle, 'nvrtcGetLoweredName')
{{endif}}
{{if 'nvrtcGetPCHHeapSize' in found_functions}}
global __nvrtcGetPCHHeapSize
__nvrtcGetPCHHeapSize = dlfcn.dlsym(handle, 'nvrtcGetPCHHeapSize')
{{endif}}
{{if 'nvrtcSetPCHHeapSize' in found_functions}}
global __nvrtcSetPCHHeapSize
__nvrtcSetPCHHeapSize = dlfcn.dlsym(handle, 'nvrtcSetPCHHeapSize')
{{endif}}
{{if 'nvrtcGetPCHCreateStatus' in found_functions}}
global __nvrtcGetPCHCreateStatus
__nvrtcGetPCHCreateStatus = dlfcn.dlsym(handle, 'nvrtcGetPCHCreateStatus')
{{endif}}
{{if 'nvrtcGetPCHHeapSizeRequired' in found_functions}}
global __nvrtcGetPCHHeapSizeRequired
__nvrtcGetPCHHeapSizeRequired = dlfcn.dlsym(handle, 'nvrtcGetPCHHeapSizeRequired')
{{endif}}
{{if 'nvrtcSetFlowCallback' in found_functions}}
global __nvrtcSetFlowCallback
__nvrtcSetFlowCallback = dlfcn.dlsym(handle, 'nvrtcSetFlowCallback')
{{endif}}
{{endif}}

__cuPythonInit = True
return 0

{{if 'nvrtcGetErrorString' in found_functions}}

Expand Down
Loading
Loading