Skip to content

Commit

Permalink
Rebase to CTK 12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vzhurba01 committed Dec 8, 2022
1 parent 451a19e commit 41b7762
Show file tree
Hide file tree
Showing 88 changed files with 45,609 additions and 26,637 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Dependencies of the CUDA-Python bindings and some versions that are known to
work are as follows:

* Driver: Linux (450.80.02 or later) Windows(456.38 or later)
* CUDA Toolkit 11.0 to 11.8
* CUDA Toolkit 12.0
* Cython - e.g. 0.29.21

### Installing
Expand Down
258 changes: 157 additions & 101 deletions cuda/_cuda/ccuda.pxd.in

Large diffs are not rendered by default.

2,506 changes: 1,377 additions & 1,129 deletions cuda/_cuda/ccuda.pyx.in

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions cuda/_cuda/cnvrtc.pxd.in
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,26 @@ cdef nvrtcResult _nvrtcGetNVVMSize(nvrtcProgram prog, size_t* nvvmSizeRet) nogil
cdef nvrtcResult _nvrtcGetNVVM(nvrtcProgram prog, char* nvvm) nogil except ?NVRTC_ERROR_INVALID_INPUT
{{endif}}

{{if 'nvrtcGetLTOIRSize' in found_functions}}

cdef nvrtcResult _nvrtcGetLTOIRSize(nvrtcProgram prog, size_t* LTOIRSizeRet) nogil except ?NVRTC_ERROR_INVALID_INPUT
{{endif}}

{{if 'nvrtcGetLTOIR' in found_functions}}

cdef nvrtcResult _nvrtcGetLTOIR(nvrtcProgram prog, char* LTOIR) nogil except ?NVRTC_ERROR_INVALID_INPUT
{{endif}}

{{if 'nvrtcGetOptiXIRSize' in found_functions}}

cdef nvrtcResult _nvrtcGetOptiXIRSize(nvrtcProgram prog, size_t* optixirSizeRet) nogil except ?NVRTC_ERROR_INVALID_INPUT
{{endif}}

{{if 'nvrtcGetOptiXIR' in found_functions}}

cdef nvrtcResult _nvrtcGetOptiXIR(nvrtcProgram prog, char* optixir) nogil except ?NVRTC_ERROR_INVALID_INPUT
{{endif}}

{{if 'nvrtcGetProgramLogSize' in found_functions}}

cdef nvrtcResult _nvrtcGetProgramLogSize(nvrtcProgram prog, size_t* logSizeRet) nogil except ?NVRTC_ERROR_INVALID_INPUT
Expand All @@ -91,3 +111,4 @@ cdef nvrtcResult _nvrtcAddNameExpression(nvrtcProgram prog, const char* name_exp

cdef nvrtcResult _nvrtcGetLoweredName(nvrtcProgram prog, const char* name_expression, const char** lowered_name) nogil except ?NVRTC_ERROR_INVALID_INPUT
{{endif}}

114 changes: 100 additions & 14 deletions cuda/_cuda/cnvrtc.pyx.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ cdef bint __cuPythonInit = False
{{if 'nvrtcGetCUBIN' in found_functions}}cdef void *__nvrtcGetCUBIN = NULL{{endif}}
{{if 'nvrtcGetNVVMSize' in found_functions}}cdef void *__nvrtcGetNVVMSize = NULL{{endif}}
{{if 'nvrtcGetNVVM' in found_functions}}cdef void *__nvrtcGetNVVM = NULL{{endif}}
{{if 'nvrtcGetLTOIRSize' in found_functions}}cdef void *__nvrtcGetLTOIRSize = NULL{{endif}}
{{if 'nvrtcGetLTOIR' in found_functions}}cdef void *__nvrtcGetLTOIR = NULL{{endif}}
{{if 'nvrtcGetOptiXIRSize' in found_functions}}cdef void *__nvrtcGetOptiXIRSize = NULL{{endif}}
{{if 'nvrtcGetOptiXIR' in found_functions}}cdef void *__nvrtcGetOptiXIR = NULL{{endif}}
{{if 'nvrtcGetProgramLogSize' in found_functions}}cdef void *__nvrtcGetProgramLogSize = NULL{{endif}}
{{if 'nvrtcGetProgramLog' in found_functions}}cdef void *__nvrtcGetProgramLog = NULL{{endif}}
{{if 'nvrtcAddNameExpression' in found_functions}}cdef void *__nvrtcAddNameExpression = NULL{{endif}}
Expand All @@ -43,26 +47,16 @@ cdef int cuPythonInit() nogil except -1:
LOAD_LIBRARY_SAFE_CURRENT_DIRS = 0x00002000
with gil:
try:
handle = win32api.LoadLibraryEx("nvrtc64_112_0.dll", 0, LOAD_LIBRARY_SAFE_CURRENT_DIRS)
handle = win32api.LoadLibraryEx("nvrtc64_120_0.dll", 0, LOAD_LIBRARY_SAFE_CURRENT_DIRS)
except:
try:
handle = win32api.LoadLibraryEx("nvrtc64_111_0.dll", 0, LOAD_LIBRARY_SAFE_CURRENT_DIRS)
except:
try:
handle = win32api.LoadLibraryEx("nvrtc64_110_0.dll", 0, LOAD_LIBRARY_SAFE_CURRENT_DIRS)
except:
raise RuntimeError('Failed to LoadLibraryEx nvrtc64_112_0.dll, or nvrtc64_111_0.dll, or nvrtc64_110_0.dll')
raise RuntimeError('Failed to LoadLibraryEx nvrtc64_120_0.dll')
{{else}}
handle = NULL
if handle == NULL:
handle = dlfcn.dlopen('libnvrtc.so.11.2', dlfcn.RTLD_NOW)
if handle == NULL:
handle = dlfcn.dlopen('libnvrtc.so.11.1', dlfcn.RTLD_NOW)
if handle == NULL:
handle = dlfcn.dlopen('libnvrtc.so.11.0', dlfcn.RTLD_NOW)
handle = dlfcn.dlopen('libnvrtc.so.12', dlfcn.RTLD_NOW)
if handle == NULL:
with gil:
raise RuntimeError('Failed to dlopen libnvrtc.so.11.2, or libnvrtc.so.11.1, or libnvrtc.so.11.0')
raise RuntimeError('Failed to dlopen libnvrtc.so.12')
{{endif}}


Expand Down Expand Up @@ -160,6 +154,34 @@ cdef int cuPythonInit() nogil except -1:
except:
pass
{{endif}}
{{if 'nvrtcGetLTOIRSize' in found_functions}}
try:
global __nvrtcGetLTOIRSize
__nvrtcGetLTOIRSize = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcGetLTOIRSize')
except:
pass
{{endif}}
{{if 'nvrtcGetLTOIR' in found_functions}}
try:
global __nvrtcGetLTOIR
__nvrtcGetLTOIR = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcGetLTOIR')
except:
pass
{{endif}}
{{if 'nvrtcGetOptiXIRSize' in found_functions}}
try:
global __nvrtcGetOptiXIRSize
__nvrtcGetOptiXIRSize = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcGetOptiXIRSize')
except:
pass
{{endif}}
{{if 'nvrtcGetOptiXIR' in found_functions}}
try:
global __nvrtcGetOptiXIR
__nvrtcGetOptiXIR = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcGetOptiXIR')
except:
pass
{{endif}}
{{if 'nvrtcGetProgramLogSize' in found_functions}}
try:
global __nvrtcGetProgramLogSize
Expand Down Expand Up @@ -242,6 +264,22 @@ cdef int cuPythonInit() nogil except -1:
global __nvrtcGetNVVM
__nvrtcGetNVVM = dlfcn.dlsym(handle, 'nvrtcGetNVVM')
{{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')
Expand Down Expand Up @@ -417,6 +455,54 @@ cdef nvrtcResult _nvrtcGetNVVM(nvrtcProgram prog, char* nvvm) nogil except ?NVRT
return err
{{endif}}

{{if 'nvrtcGetLTOIRSize' in found_functions}}

cdef nvrtcResult _nvrtcGetLTOIRSize(nvrtcProgram prog, size_t* LTOIRSizeRet) nogil except ?NVRTC_ERROR_INVALID_INPUT:
global __nvrtcGetLTOIRSize
cuPythonInit()
if __nvrtcGetLTOIRSize == NULL:
with gil:
raise RuntimeError('Function "nvrtcGetLTOIRSize" not found')
err = (<nvrtcResult (*)(nvrtcProgram, size_t*) nogil> __nvrtcGetLTOIRSize)(prog, LTOIRSizeRet)
return err
{{endif}}

{{if 'nvrtcGetLTOIR' in found_functions}}

cdef nvrtcResult _nvrtcGetLTOIR(nvrtcProgram prog, char* LTOIR) nogil except ?NVRTC_ERROR_INVALID_INPUT:
global __nvrtcGetLTOIR
cuPythonInit()
if __nvrtcGetLTOIR == NULL:
with gil:
raise RuntimeError('Function "nvrtcGetLTOIR" not found')
err = (<nvrtcResult (*)(nvrtcProgram, char*) nogil> __nvrtcGetLTOIR)(prog, LTOIR)
return err
{{endif}}

{{if 'nvrtcGetOptiXIRSize' in found_functions}}

cdef nvrtcResult _nvrtcGetOptiXIRSize(nvrtcProgram prog, size_t* optixirSizeRet) nogil except ?NVRTC_ERROR_INVALID_INPUT:
global __nvrtcGetOptiXIRSize
cuPythonInit()
if __nvrtcGetOptiXIRSize == NULL:
with gil:
raise RuntimeError('Function "nvrtcGetOptiXIRSize" not found')
err = (<nvrtcResult (*)(nvrtcProgram, size_t*) nogil> __nvrtcGetOptiXIRSize)(prog, optixirSizeRet)
return err
{{endif}}

{{if 'nvrtcGetOptiXIR' in found_functions}}

cdef nvrtcResult _nvrtcGetOptiXIR(nvrtcProgram prog, char* optixir) nogil except ?NVRTC_ERROR_INVALID_INPUT:
global __nvrtcGetOptiXIR
cuPythonInit()
if __nvrtcGetOptiXIR == NULL:
with gil:
raise RuntimeError('Function "nvrtcGetOptiXIR" not found')
err = (<nvrtcResult (*)(nvrtcProgram, char*) nogil> __nvrtcGetOptiXIR)(prog, optixir)
return err
{{endif}}

{{if 'nvrtcGetProgramLogSize' in found_functions}}

cdef nvrtcResult _nvrtcGetProgramLogSize(nvrtcProgram prog, size_t* logSizeRet) nogil except ?NVRTC_ERROR_INVALID_INPUT:
Expand Down
Loading

0 comments on commit 41b7762

Please sign in to comment.