File tree Expand file tree Collapse file tree 7 files changed +1048
-652
lines changed
cuda_bindings/cuda/bindings Expand file tree Collapse file tree 7 files changed +1048
-652
lines changed Original file line number Diff line number Diff line change @@ -111,12 +111,15 @@ cdef void* load_library() except* with gil:
111111 return < void * > handle
112112
113113
114- cdef int __check_or_init_cufile () except - 1 nogil:
114+ cdef int _init_cufile () except - 1 nogil:
115115 global __py_cufile_init
116116
117117 cdef void * handle = NULL
118118
119119 with gil, __symbol_lock:
120+ # Recheck the flag after obtaining the locks
121+ if __py_cufile_init:
122+ return 0
120123 # Load function
121124 global __cuFileHandleRegister
122125 __cuFileHandleRegister = dlsym(RTLD_DEFAULT, ' cuFileHandleRegister' )
@@ -427,7 +430,7 @@ cdef inline int _check_or_init_cufile() except -1 nogil:
427430 if __py_cufile_init:
428431 return 0
429432
430- return __check_or_init_cufile ()
433+ return _init_cufile ()
431434
432435
433436cdef dict func_ptrs = None
Original file line number Diff line number Diff line change @@ -80,12 +80,16 @@ cdef void* load_library() except* with gil:
8080 return < void * > handle
8181
8282
83- cdef int __check_or_init_nvjitlink () except - 1 nogil:
83+ cdef int _init_nvjitlink () except - 1 nogil:
8484 global __py_nvjitlink_init
8585
8686 cdef void * handle = NULL
8787
8888 with gil, __symbol_lock:
89+ # Recheck the flag after obtaining the locks
90+ if __py_nvjitlink_init:
91+ return 0
92+
8993 # Load function
9094 global __nvJitLinkCreate
9195 __nvJitLinkCreate = dlsym(RTLD_DEFAULT, ' nvJitLinkCreate' )
@@ -193,7 +197,7 @@ cdef inline int _check_or_init_nvjitlink() except -1 nogil:
193197 if __py_nvjitlink_init:
194198 return 0
195199
196- return __check_or_init_nvjitlink ()
200+ return _init_nvjitlink ()
197201
198202cdef dict func_ptrs = None
199203
Original file line number Diff line number Diff line change @@ -93,10 +93,14 @@ cdef void* __nvJitLinkGetInfoLog = NULL
9393cdef void * __nvJitLinkVersion = NULL
9494
9595
96- cdef int __check_or_init_nvjitlink () except - 1 nogil:
96+ cdef int _init_nvjitlink () except - 1 nogil:
9797 global __py_nvjitlink_init
9898
9999 with gil, __symbol_lock:
100+ # Recheck the flag after obtaining the locks
101+ if __py_nvjitlink_init:
102+ return 0
103+
100104 # Load library
101105 handle = load_nvidia_dynamic_lib(" nvJitLink" )._handle_uint
102106
@@ -151,7 +155,7 @@ cdef inline int _check_or_init_nvjitlink() except -1 nogil:
151155 if __py_nvjitlink_init:
152156 return 0
153157
154- return __check_or_init_nvjitlink ()
158+ return _init_nvjitlink ()
155159
156160
157161cdef dict func_ptrs = None
Original file line number Diff line number Diff line change @@ -79,12 +79,16 @@ cdef void* load_library() except* with gil:
7979 return < void * > handle
8080
8181
82- cdef int __check_or_init_nvvm () except - 1 nogil:
82+ cdef int _init_nvvm () except - 1 nogil:
8383 global __py_nvvm_init
8484
8585 cdef void * handle = NULL
8686
8787 with gil, __symbol_lock:
88+ # Recheck the flag after obtaining the locks
89+ if __py_nvvm_init:
90+ return 0
91+
8892 # Load function
8993 global __nvvmGetErrorString
9094 __nvvmGetErrorString = dlsym(RTLD_DEFAULT, ' nvvmGetErrorString' )
@@ -185,7 +189,7 @@ cdef inline int _check_or_init_nvvm() except -1 nogil:
185189 if __py_nvvm_init:
186190 return 0
187191
188- return __check_or_init_nvvm ()
192+ return _init_nvvm ()
189193
190194
191195cdef dict func_ptrs = None
Original file line number Diff line number Diff line change @@ -92,10 +92,14 @@ cdef void* __nvvmGetProgramLogSize = NULL
9292cdef void * __nvvmGetProgramLog = NULL
9393
9494
95- cdef int __check_or_init_nvvm () except - 1 nogil:
95+ cdef int _init_nvvm () except - 1 nogil:
9696 global __py_nvvm_init
9797
9898 with gil, __symbol_lock:
99+ # Recheck the flag after obtaining the locks
100+ if __py_nvvm_init:
101+ return 0
102+
99103 # Load library
100104 handle = load_nvidia_dynamic_lib(" nvvm" )._handle_uint
101105
@@ -147,7 +151,7 @@ cdef inline int _check_or_init_nvvm() except -1 nogil:
147151 if __py_nvvm_init:
148152 return 0
149153
150- return __check_or_init_nvvm ()
154+ return _init_nvvm ()
151155
152156
153157cdef dict func_ptrs = None
You can’t perform that action at this time.
0 commit comments