@@ -36,6 +36,7 @@ cdef extern from "<dlfcn.h>" nogil:
3636cdef bint __py_nvvm_init = False
3737cdef void * __cuDriverGetVersion = NULL
3838
39+ cdef void * __nvvmGetErrorString = NULL
3940cdef void * __nvvmVersion = NULL
4041cdef void * __nvvmIRVersion = NULL
4142cdef void * __nvvmCreateProgram = NULL
@@ -82,6 +83,13 @@ cdef int _check_or_init_nvvm() except -1 nogil:
8283 handle = NULL
8384
8485 # Load function
86+ global __nvvmGetErrorString
87+ __nvvmGetErrorString = dlsym(RTLD_DEFAULT, ' nvvmGetErrorString' )
88+ if __nvvmGetErrorString == NULL :
89+ if handle == NULL :
90+ handle = load_library(driver_ver)
91+ __nvvmGetErrorString = dlsym(handle, ' nvvmGetErrorString' )
92+
8593 global __nvvmVersion
8694 __nvvmVersion = dlsym(RTLD_DEFAULT, ' nvvmVersion' )
8795 if __nvvmVersion == NULL :
@@ -181,6 +189,9 @@ cpdef dict _inspect_function_pointers():
181189 _check_or_init_nvvm()
182190 cdef dict data = {}
183191
192+ global __nvvmGetErrorString
193+ data[" __nvvmGetErrorString" ] = < intptr_t> __nvvmGetErrorString
194+
184195 global __nvvmVersion
185196 data[" __nvvmVersion" ] = < intptr_t> __nvvmVersion
186197
@@ -232,6 +243,16 @@ cpdef _inspect_function_pointer(str name):
232243# Wrapper functions
233244# ##############################################################################
234245
246+ cdef const char * _nvvmGetErrorString(nvvmResult result) except ?NULL nogil:
247+ global __nvvmGetErrorString
248+ _check_or_init_nvvm()
249+ if __nvvmGetErrorString == NULL :
250+ with gil:
251+ raise FunctionNotFoundError(" function nvvmGetErrorString is not found" )
252+ return (< const char * (* )(nvvmResult) noexcept nogil> __nvvmGetErrorString)(
253+ result)
254+
255+
235256cdef nvvmResult _nvvmVersion(int * major, int * minor) except ?_NVVMRESULT_INTERNAL_LOADING_ERROR nogil:
236257 global __nvvmVersion
237258 _check_or_init_nvvm()
0 commit comments