Skip to content

Commit 4292190

Browse files
authored
Merge branch '12.9.x' into bp_313t_314_314t
2 parents c1f4a95 + e2b9f60 commit 4292190

12 files changed

Lines changed: 399 additions & 396 deletions

cuda_bindings/cuda/bindings/_internal/cufile_linux.pyx

Lines changed: 40 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -74,258 +74,246 @@ cdef void* __cuFileSetParameterString = NULL
7474
cdef void* __cuFileDriverClose = NULL
7575

7676

77-
cdef void* load_library(const int driver_ver) except* with gil:
77+
cdef void* load_library() except* with gil:
7878
cdef uintptr_t handle = load_nvidia_dynamic_lib("cufile")._handle_uint
7979
return <void*>handle
8080

8181

82-
cdef int _check_or_init_cufile() except -1 nogil:
82+
cdef int __check_or_init_cufile() except -1 nogil:
8383
global __py_cufile_init
84-
if __py_cufile_init:
85-
return 0
8684

8785
cdef void* handle = NULL
88-
cdef int err, driver_ver = 0
8986

9087
with gil, __symbol_lock:
91-
# Load driver to check version
92-
handle = dlopen('libcuda.so.1', RTLD_NOW | RTLD_GLOBAL)
93-
if handle == NULL:
94-
err_msg = dlerror()
95-
raise NotSupportedError(f'CUDA driver is not found ({err_msg.decode()})')
96-
global __cuDriverGetVersion
97-
if __cuDriverGetVersion == NULL:
98-
__cuDriverGetVersion = dlsym(handle, "cuDriverGetVersion")
99-
if __cuDriverGetVersion == NULL:
100-
raise RuntimeError('something went wrong')
101-
err = (<int (*)(int*) noexcept nogil>__cuDriverGetVersion)(&driver_ver)
102-
if err != 0:
103-
raise RuntimeError('something went wrong')
104-
#dlclose(handle)
105-
handle = NULL
106-
10788
# Load function
10889
global __cuFileHandleRegister
10990
__cuFileHandleRegister = dlsym(RTLD_DEFAULT, 'cuFileHandleRegister')
11091
if __cuFileHandleRegister == NULL:
11192
if handle == NULL:
112-
handle = load_library(driver_ver)
93+
handle = load_library()
11394
__cuFileHandleRegister = dlsym(handle, 'cuFileHandleRegister')
11495

11596
global __cuFileHandleDeregister
11697
__cuFileHandleDeregister = dlsym(RTLD_DEFAULT, 'cuFileHandleDeregister')
11798
if __cuFileHandleDeregister == NULL:
11899
if handle == NULL:
119-
handle = load_library(driver_ver)
100+
handle = load_library()
120101
__cuFileHandleDeregister = dlsym(handle, 'cuFileHandleDeregister')
121102

122103
global __cuFileBufRegister
123104
__cuFileBufRegister = dlsym(RTLD_DEFAULT, 'cuFileBufRegister')
124105
if __cuFileBufRegister == NULL:
125106
if handle == NULL:
126-
handle = load_library(driver_ver)
107+
handle = load_library()
127108
__cuFileBufRegister = dlsym(handle, 'cuFileBufRegister')
128109

129110
global __cuFileBufDeregister
130111
__cuFileBufDeregister = dlsym(RTLD_DEFAULT, 'cuFileBufDeregister')
131112
if __cuFileBufDeregister == NULL:
132113
if handle == NULL:
133-
handle = load_library(driver_ver)
114+
handle = load_library()
134115
__cuFileBufDeregister = dlsym(handle, 'cuFileBufDeregister')
135116

136117
global __cuFileRead
137118
__cuFileRead = dlsym(RTLD_DEFAULT, 'cuFileRead')
138119
if __cuFileRead == NULL:
139120
if handle == NULL:
140-
handle = load_library(driver_ver)
121+
handle = load_library()
141122
__cuFileRead = dlsym(handle, 'cuFileRead')
142123

143124
global __cuFileWrite
144125
__cuFileWrite = dlsym(RTLD_DEFAULT, 'cuFileWrite')
145126
if __cuFileWrite == NULL:
146127
if handle == NULL:
147-
handle = load_library(driver_ver)
128+
handle = load_library()
148129
__cuFileWrite = dlsym(handle, 'cuFileWrite')
149130

150131
global __cuFileDriverOpen
151132
__cuFileDriverOpen = dlsym(RTLD_DEFAULT, 'cuFileDriverOpen')
152133
if __cuFileDriverOpen == NULL:
153134
if handle == NULL:
154-
handle = load_library(driver_ver)
135+
handle = load_library()
155136
__cuFileDriverOpen = dlsym(handle, 'cuFileDriverOpen')
156137

157138
global __cuFileDriverClose_v2
158139
__cuFileDriverClose_v2 = dlsym(RTLD_DEFAULT, 'cuFileDriverClose_v2')
159140
if __cuFileDriverClose_v2 == NULL:
160141
if handle == NULL:
161-
handle = load_library(driver_ver)
142+
handle = load_library()
162143
__cuFileDriverClose_v2 = dlsym(handle, 'cuFileDriverClose_v2')
163144

164145
global __cuFileUseCount
165146
__cuFileUseCount = dlsym(RTLD_DEFAULT, 'cuFileUseCount')
166147
if __cuFileUseCount == NULL:
167148
if handle == NULL:
168-
handle = load_library(driver_ver)
149+
handle = load_library()
169150
__cuFileUseCount = dlsym(handle, 'cuFileUseCount')
170151

171152
global __cuFileDriverGetProperties
172153
__cuFileDriverGetProperties = dlsym(RTLD_DEFAULT, 'cuFileDriverGetProperties')
173154
if __cuFileDriverGetProperties == NULL:
174155
if handle == NULL:
175-
handle = load_library(driver_ver)
156+
handle = load_library()
176157
__cuFileDriverGetProperties = dlsym(handle, 'cuFileDriverGetProperties')
177158

178159
global __cuFileDriverSetPollMode
179160
__cuFileDriverSetPollMode = dlsym(RTLD_DEFAULT, 'cuFileDriverSetPollMode')
180161
if __cuFileDriverSetPollMode == NULL:
181162
if handle == NULL:
182-
handle = load_library(driver_ver)
163+
handle = load_library()
183164
__cuFileDriverSetPollMode = dlsym(handle, 'cuFileDriverSetPollMode')
184165

185166
global __cuFileDriverSetMaxDirectIOSize
186167
__cuFileDriverSetMaxDirectIOSize = dlsym(RTLD_DEFAULT, 'cuFileDriverSetMaxDirectIOSize')
187168
if __cuFileDriverSetMaxDirectIOSize == NULL:
188169
if handle == NULL:
189-
handle = load_library(driver_ver)
170+
handle = load_library()
190171
__cuFileDriverSetMaxDirectIOSize = dlsym(handle, 'cuFileDriverSetMaxDirectIOSize')
191172

192173
global __cuFileDriverSetMaxCacheSize
193174
__cuFileDriverSetMaxCacheSize = dlsym(RTLD_DEFAULT, 'cuFileDriverSetMaxCacheSize')
194175
if __cuFileDriverSetMaxCacheSize == NULL:
195176
if handle == NULL:
196-
handle = load_library(driver_ver)
177+
handle = load_library()
197178
__cuFileDriverSetMaxCacheSize = dlsym(handle, 'cuFileDriverSetMaxCacheSize')
198179

199180
global __cuFileDriverSetMaxPinnedMemSize
200181
__cuFileDriverSetMaxPinnedMemSize = dlsym(RTLD_DEFAULT, 'cuFileDriverSetMaxPinnedMemSize')
201182
if __cuFileDriverSetMaxPinnedMemSize == NULL:
202183
if handle == NULL:
203-
handle = load_library(driver_ver)
184+
handle = load_library()
204185
__cuFileDriverSetMaxPinnedMemSize = dlsym(handle, 'cuFileDriverSetMaxPinnedMemSize')
205186

206187
global __cuFileBatchIOSetUp
207188
__cuFileBatchIOSetUp = dlsym(RTLD_DEFAULT, 'cuFileBatchIOSetUp')
208189
if __cuFileBatchIOSetUp == NULL:
209190
if handle == NULL:
210-
handle = load_library(driver_ver)
191+
handle = load_library()
211192
__cuFileBatchIOSetUp = dlsym(handle, 'cuFileBatchIOSetUp')
212193

213194
global __cuFileBatchIOSubmit
214195
__cuFileBatchIOSubmit = dlsym(RTLD_DEFAULT, 'cuFileBatchIOSubmit')
215196
if __cuFileBatchIOSubmit == NULL:
216197
if handle == NULL:
217-
handle = load_library(driver_ver)
198+
handle = load_library()
218199
__cuFileBatchIOSubmit = dlsym(handle, 'cuFileBatchIOSubmit')
219200

220201
global __cuFileBatchIOGetStatus
221202
__cuFileBatchIOGetStatus = dlsym(RTLD_DEFAULT, 'cuFileBatchIOGetStatus')
222203
if __cuFileBatchIOGetStatus == NULL:
223204
if handle == NULL:
224-
handle = load_library(driver_ver)
205+
handle = load_library()
225206
__cuFileBatchIOGetStatus = dlsym(handle, 'cuFileBatchIOGetStatus')
226207

227208
global __cuFileBatchIOCancel
228209
__cuFileBatchIOCancel = dlsym(RTLD_DEFAULT, 'cuFileBatchIOCancel')
229210
if __cuFileBatchIOCancel == NULL:
230211
if handle == NULL:
231-
handle = load_library(driver_ver)
212+
handle = load_library()
232213
__cuFileBatchIOCancel = dlsym(handle, 'cuFileBatchIOCancel')
233214

234215
global __cuFileBatchIODestroy
235216
__cuFileBatchIODestroy = dlsym(RTLD_DEFAULT, 'cuFileBatchIODestroy')
236217
if __cuFileBatchIODestroy == NULL:
237218
if handle == NULL:
238-
handle = load_library(driver_ver)
219+
handle = load_library()
239220
__cuFileBatchIODestroy = dlsym(handle, 'cuFileBatchIODestroy')
240221

241222
global __cuFileReadAsync
242223
__cuFileReadAsync = dlsym(RTLD_DEFAULT, 'cuFileReadAsync')
243224
if __cuFileReadAsync == NULL:
244225
if handle == NULL:
245-
handle = load_library(driver_ver)
226+
handle = load_library()
246227
__cuFileReadAsync = dlsym(handle, 'cuFileReadAsync')
247228

248229
global __cuFileWriteAsync
249230
__cuFileWriteAsync = dlsym(RTLD_DEFAULT, 'cuFileWriteAsync')
250231
if __cuFileWriteAsync == NULL:
251232
if handle == NULL:
252-
handle = load_library(driver_ver)
233+
handle = load_library()
253234
__cuFileWriteAsync = dlsym(handle, 'cuFileWriteAsync')
254235

255236
global __cuFileStreamRegister
256237
__cuFileStreamRegister = dlsym(RTLD_DEFAULT, 'cuFileStreamRegister')
257238
if __cuFileStreamRegister == NULL:
258239
if handle == NULL:
259-
handle = load_library(driver_ver)
240+
handle = load_library()
260241
__cuFileStreamRegister = dlsym(handle, 'cuFileStreamRegister')
261242

262243
global __cuFileStreamDeregister
263244
__cuFileStreamDeregister = dlsym(RTLD_DEFAULT, 'cuFileStreamDeregister')
264245
if __cuFileStreamDeregister == NULL:
265246
if handle == NULL:
266-
handle = load_library(driver_ver)
247+
handle = load_library()
267248
__cuFileStreamDeregister = dlsym(handle, 'cuFileStreamDeregister')
268249

269250
global __cuFileGetVersion
270251
__cuFileGetVersion = dlsym(RTLD_DEFAULT, 'cuFileGetVersion')
271252
if __cuFileGetVersion == NULL:
272253
if handle == NULL:
273-
handle = load_library(driver_ver)
254+
handle = load_library()
274255
__cuFileGetVersion = dlsym(handle, 'cuFileGetVersion')
275256

276257
global __cuFileGetParameterSizeT
277258
__cuFileGetParameterSizeT = dlsym(RTLD_DEFAULT, 'cuFileGetParameterSizeT')
278259
if __cuFileGetParameterSizeT == NULL:
279260
if handle == NULL:
280-
handle = load_library(driver_ver)
261+
handle = load_library()
281262
__cuFileGetParameterSizeT = dlsym(handle, 'cuFileGetParameterSizeT')
282263

283264
global __cuFileGetParameterBool
284265
__cuFileGetParameterBool = dlsym(RTLD_DEFAULT, 'cuFileGetParameterBool')
285266
if __cuFileGetParameterBool == NULL:
286267
if handle == NULL:
287-
handle = load_library(driver_ver)
268+
handle = load_library()
288269
__cuFileGetParameterBool = dlsym(handle, 'cuFileGetParameterBool')
289270

290271
global __cuFileGetParameterString
291272
__cuFileGetParameterString = dlsym(RTLD_DEFAULT, 'cuFileGetParameterString')
292273
if __cuFileGetParameterString == NULL:
293274
if handle == NULL:
294-
handle = load_library(driver_ver)
275+
handle = load_library()
295276
__cuFileGetParameterString = dlsym(handle, 'cuFileGetParameterString')
296277

297278
global __cuFileSetParameterSizeT
298279
__cuFileSetParameterSizeT = dlsym(RTLD_DEFAULT, 'cuFileSetParameterSizeT')
299280
if __cuFileSetParameterSizeT == NULL:
300281
if handle == NULL:
301-
handle = load_library(driver_ver)
282+
handle = load_library()
302283
__cuFileSetParameterSizeT = dlsym(handle, 'cuFileSetParameterSizeT')
303284

304285
global __cuFileSetParameterBool
305286
__cuFileSetParameterBool = dlsym(RTLD_DEFAULT, 'cuFileSetParameterBool')
306287
if __cuFileSetParameterBool == NULL:
307288
if handle == NULL:
308-
handle = load_library(driver_ver)
289+
handle = load_library()
309290
__cuFileSetParameterBool = dlsym(handle, 'cuFileSetParameterBool')
310291

311292
global __cuFileSetParameterString
312293
__cuFileSetParameterString = dlsym(RTLD_DEFAULT, 'cuFileSetParameterString')
313294
if __cuFileSetParameterString == NULL:
314295
if handle == NULL:
315-
handle = load_library(driver_ver)
296+
handle = load_library()
316297
__cuFileSetParameterString = dlsym(handle, 'cuFileSetParameterString')
317298

318299
global __cuFileDriverClose
319300
__cuFileDriverClose = dlsym(RTLD_DEFAULT, 'cuFileDriverClose')
320301
if __cuFileDriverClose == NULL:
321302
if handle == NULL:
322-
handle = load_library(driver_ver)
303+
handle = load_library()
323304
__cuFileDriverClose = dlsym(handle, 'cuFileDriverClose')
324305

325306
__py_cufile_init = True
326307
return 0
327308

328309

310+
cdef inline int _check_or_init_cufile() except -1 nogil:
311+
if __py_cufile_init:
312+
return 0
313+
314+
return __check_or_init_cufile()
315+
316+
329317
cdef dict func_ptrs = None
330318

331319

0 commit comments

Comments
 (0)