Coverage for cuda/bindings/cufile.pyx: 43.52%

1627 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-07-29 01:38 +0000

1# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. 

2# 

3# SPDX-License-Identifier: Apache-2.0 

4# 

5# This code was automatically generated across versions from 12.9.1 to 13.3.0. Do not modify it directly. 

6# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=f107413ea0012a1a854cd3de77d57f649bebd0f586901d4e6384f37288ac5421 

7  

8  

9# <<<< PREAMBLE CONTENT >>>> 

10  

11cimport cpython as _cyb_cpython 

12cimport cpython.buffer as _cyb_cpython_buffer 

13cimport cpython.memoryview as _cyb_cpython_memoryview 

14from cython cimport view as _cyb_view 

15from libc.stdlib cimport ( 

16 calloc as _cyb_calloc, 

17 free as _cyb_free, 

18 malloc as _cyb_malloc, 

19) 

20from libc.string cimport ( 

21 memcmp as _cyb_memcmp, 

22 memcpy as _cyb_memcpy, 

23) 

24  

25from cuda.bindings._internal._fast_enum import FastEnum as _cyb_FastEnum 

26  

27import numpy as _numpy 

28  

29cdef _cyb___getbuffer(object self, _cyb_cpython.Py_buffer *buffer, void *ptr, int size, bint readonly): 

30 buffer.buf = <char *>ptr 

31 buffer.format = 'b' 

32 buffer.internal = NULL 

33 buffer.itemsize = 1 

34 buffer.len = size 

35 buffer.ndim = 1 

36 buffer.obj = self 

37 buffer.readonly = readonly 

38 buffer.shape = &buffer.len 

39 buffer.strides = &buffer.itemsize 

40 buffer.suboffsets = NULL 

41  

42cdef _cyb_from_buffer(buffer, size, lowpp_type): 

43 cdef _cyb_cpython.Py_buffer view 

44 if _cyb_cpython.PyObject_GetBuffer(buffer, &view, _cyb_cpython_buffer.PyBUF_SIMPLE) != 0: 

45 raise TypeError("buffer argument does not support the buffer protocol") 

46 try: 

47 if view.itemsize != 1: 

48 raise ValueError("buffer itemsize must be 1 byte") 

49 if view.len != size: 

50 raise ValueError(f"buffer length must be {size} bytes") 

51 return lowpp_type.from_ptr(<intptr_t><void *>view.buf, not view.readonly, buffer) 

52 finally: 

53 _cyb_cpython.PyBuffer_Release(&view) 

54  

55cdef _cyb_from_data(data, dtype_name, expected_dtype, lowpp_type): 

56 # _numpy.recarray is a subclass of _numpy.ndarray, so implicitly handled here. 

57 if isinstance(data, lowpp_type): 1ecb

58 return data 1ecb

59 if not isinstance(data, _numpy.ndarray): 

60 raise TypeError("data argument must be a NumPy ndarray") 

61 if data.size != 1: 

62 raise ValueError("data array must have a size of 1") 

63 if data.dtype != expected_dtype: 

64 raise ValueError(f"data array must be of dtype {dtype_name}") 

65 return lowpp_type.from_ptr(data.ctypes.data, not data.flags.writeable, data) 

66  

67  

68# <<<< END OF PREAMBLE CONTENT >>>> 

69  

70cimport cython # NOQA 

71from libc cimport errno 

72from ._internal.utils cimport (get_buffer_pointer, get_nested_resource_ptr, 

73 nested_resource) 

74  

75import cython 

76  

77from cuda.bindings.driver import CUresult as pyCUresult 

78  

79############################################################################### 

80# POD 

81############################################################################### 

82  

83cdef _get__py_anon_pod1_dtype_offsets(): 

84 cdef cuda_bindings_cufile__anon_pod1 pod 

85 return _numpy.dtype({ 

86 'names': ['fd', 'handle'], 

87 'formats': [_numpy.int32, _numpy.intp], 

88 'offsets': [ 

89 (<intptr_t>&(pod.fd)) - (<intptr_t>&pod), 

90 (<intptr_t>&(pod.handle)) - (<intptr_t>&pod), 

91 ], 

92 'itemsize': sizeof((<CUfileDescr_t*>NULL).handle), 

93 }) 

94  

95_py_anon_pod1_dtype = _get__py_anon_pod1_dtype_offsets() 

96  

97cdef class _py_anon_pod1: 

98 """Empty-initialize an instance of `cuda_bindings_cufile__anon_pod1`. 

99  

100  

101 .. seealso:: `cuda_bindings_cufile__anon_pod1` 

102 """ 

103 cdef: 

104 cuda_bindings_cufile__anon_pod1 *_ptr 

105 object _owner 

106 bint _owned 

107 bint _readonly 

108  

109 def __init__(self): 

110 self._ptr = <cuda_bindings_cufile__anon_pod1 *>_cyb_calloc(1, sizeof((<CUfileDescr_t*>NULL).handle)) 

111 if self._ptr == NULL: 

112 raise MemoryError("Error allocating _py_anon_pod1") 

113 self._owner = None 

114 self._owned = True 

115 self._readonly = False 

116  

117 def __dealloc__(self): 

118 cdef cuda_bindings_cufile__anon_pod1 *ptr 

119 if self._owned and self._ptr != NULL: 

120 ptr = self._ptr 

121 self._ptr = NULL 

122 _cyb_free(ptr) 

123  

124 def __repr__(self): 

125 return f"<{__name__}._py_anon_pod1 object at {hex(id(self))}>" 

126  

127 @property 

128 def ptr(self): 

129 """Get the pointer address to the data as Python :class:`int`.""" 

130 return <intptr_t>(self._ptr) 

131  

132 cdef intptr_t _get_ptr(self): 

133 return <intptr_t>(self._ptr) 

134  

135 def __int__(self): 

136 return <intptr_t>(self._ptr) 

137  

138 def __eq__(self, other): 

139 cdef _py_anon_pod1 other_ 

140 if not isinstance(other, _py_anon_pod1): 

141 return False 

142 other_ = other 

143 return (_cyb_memcmp(<void *><intptr_t>(self._ptr), <void *><intptr_t>(other_._ptr), sizeof((<CUfileDescr_t*>NULL).handle)) == 0) 

144  

145 def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): 

146 _cyb___getbuffer(self, buffer, <void *>self._ptr, sizeof((<CUfileDescr_t*>NULL).handle), self._readonly) 

147  

148 def __releasebuffer__(self, Py_buffer *buffer): 

149 pass 

150  

151 def __setitem__(self, key, val): 

152 if key == 0 and isinstance(val, _numpy.ndarray): 

153 self._ptr = <cuda_bindings_cufile__anon_pod1 *>_cyb_malloc(sizeof((<CUfileDescr_t*>NULL).handle)) 

154 if self._ptr == NULL: 

155 raise MemoryError("Error allocating _py_anon_pod1") 

156 _cyb_memcpy(<void*>self._ptr, <void*><intptr_t>val.ctypes.data, sizeof((<CUfileDescr_t*>NULL).handle)) 

157 self._owner = None 

158 self._owned = True 

159 self._readonly = not val.flags.writeable 

160 else: 

161 setattr(self, key, val) 

162  

163 @property 

164 def fd(self): 

165 """int: """ 

166 return self._ptr[0].fd 

167  

168 @fd.setter 

169 def fd(self, val): 

170 if self._readonly: 

171 raise ValueError("This _py_anon_pod1 instance is read-only") 

172 self._ptr[0].fd = val 

173  

174 @property 

175 def handle(self): 

176 """int: """ 

177 return <intptr_t>(self._ptr[0].handle) 

178  

179 @handle.setter 

180 def handle(self, val): 

181 if self._readonly: 

182 raise ValueError("This _py_anon_pod1 instance is read-only") 

183 self._ptr[0].handle = <void *><intptr_t>val 

184  

185 @staticmethod 

186 def from_buffer(buffer): 

187 """Create an _py_anon_pod1 instance with the memory from the given buffer.""" 

188 return _cyb_from_buffer(buffer, sizeof((<CUfileDescr_t*>NULL).handle), _py_anon_pod1) 

189  

190 @staticmethod 

191 def from_data(data): 

192 """Create an _py_anon_pod1 instance wrapping the given NumPy array. 

193  

194 Args: 

195 data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod1_dtype` holding the data. 

196 """ 

197 return _cyb_from_data(data, "_py_anon_pod1_dtype", _py_anon_pod1_dtype, _py_anon_pod1) 

198  

199 @staticmethod 

200 def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): 

201 """Create an _py_anon_pod1 instance wrapping the given pointer. 

202  

203 Args: 

204 ptr (intptr_t): pointer address as Python :class:`int` to the data. 

205 owner (object): The Python object that owns the pointer. If not provided, data will be copied. 

206 readonly (bool): whether the data is read-only (to the user). default is `False`. 

207 """ 

208 if ptr == 0: 

209 raise ValueError("ptr must not be null (0)") 

210 cdef _py_anon_pod1 obj = _py_anon_pod1.__new__(_py_anon_pod1) 

211 if owner is None: 

212 obj._ptr = <cuda_bindings_cufile__anon_pod1 *>_cyb_malloc(sizeof((<CUfileDescr_t*>NULL).handle)) 

213 if obj._ptr == NULL: 

214 raise MemoryError("Error allocating _py_anon_pod1") 

215 _cyb_memcpy(<void*>(obj._ptr), <void*>ptr, sizeof((<CUfileDescr_t*>NULL).handle)) 

216 obj._owner = None 

217 obj._owned = True 

218 else: 

219 obj._ptr = <cuda_bindings_cufile__anon_pod1 *>ptr 

220 obj._owner = owner 

221 obj._owned = False 

222 obj._readonly = readonly 

223 return obj 

224  

225  

226cdef _get__py_anon_pod3_dtype_offsets(): 

227 cdef cuda_bindings_cufile__anon_pod3 pod 

228 return _numpy.dtype({ 

229 'names': ['dev_ptr_base', 'file_offset', 'dev_ptr_offset', 'size_'], 

230 'formats': [_numpy.intp, _numpy.int64, _numpy.int64, _numpy.uint64], 

231 'offsets': [ 

232 (<intptr_t>&(pod.devPtr_base)) - (<intptr_t>&pod), 

233 (<intptr_t>&(pod.file_offset)) - (<intptr_t>&pod), 

234 (<intptr_t>&(pod.devPtr_offset)) - (<intptr_t>&pod), 

235 (<intptr_t>&(pod.size)) - (<intptr_t>&pod), 

236 ], 

237 'itemsize': sizeof((<CUfileIOParams_t*>NULL).u.batch), 

238 }) 

239  

240_py_anon_pod3_dtype = _get__py_anon_pod3_dtype_offsets() 

241  

242cdef class _py_anon_pod3: 

243 """Empty-initialize an instance of `cuda_bindings_cufile__anon_pod3`. 

244  

245  

246 .. seealso:: `cuda_bindings_cufile__anon_pod3` 

247 """ 

248 cdef: 

249 cuda_bindings_cufile__anon_pod3 *_ptr 

250 object _owner 

251 bint _owned 

252 bint _readonly 

253  

254 def __init__(self): 

255 self._ptr = <cuda_bindings_cufile__anon_pod3 *>_cyb_calloc(1, sizeof((<CUfileIOParams_t*>NULL).u.batch)) 

256 if self._ptr == NULL: 

257 raise MemoryError("Error allocating _py_anon_pod3") 

258 self._owner = None 

259 self._owned = True 

260 self._readonly = False 

261  

262 def __dealloc__(self): 

263 cdef cuda_bindings_cufile__anon_pod3 *ptr 

264 if self._owned and self._ptr != NULL: 

265 ptr = self._ptr 

266 self._ptr = NULL 

267 _cyb_free(ptr) 

268  

269 def __repr__(self): 

270 return f"<{__name__}._py_anon_pod3 object at {hex(id(self))}>" 

271  

272 @property 

273 def ptr(self): 

274 """Get the pointer address to the data as Python :class:`int`.""" 

275 return <intptr_t>(self._ptr) 

276  

277 cdef intptr_t _get_ptr(self): 

278 return <intptr_t>(self._ptr) 

279  

280 def __int__(self): 

281 return <intptr_t>(self._ptr) 

282  

283 def __eq__(self, other): 

284 cdef _py_anon_pod3 other_ 

285 if not isinstance(other, _py_anon_pod3): 

286 return False 

287 other_ = other 

288 return (_cyb_memcmp(<void *><intptr_t>(self._ptr), <void *><intptr_t>(other_._ptr), sizeof((<CUfileIOParams_t*>NULL).u.batch)) == 0) 

289  

290 def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): 

291 _cyb___getbuffer(self, buffer, <void *>self._ptr, sizeof((<CUfileIOParams_t*>NULL).u.batch), self._readonly) 

292  

293 def __releasebuffer__(self, Py_buffer *buffer): 

294 pass 

295  

296 def __setitem__(self, key, val): 

297 if key == 0 and isinstance(val, _numpy.ndarray): 

298 self._ptr = <cuda_bindings_cufile__anon_pod3 *>_cyb_malloc(sizeof((<CUfileIOParams_t*>NULL).u.batch)) 

299 if self._ptr == NULL: 

300 raise MemoryError("Error allocating _py_anon_pod3") 

301 _cyb_memcpy(<void*>self._ptr, <void*><intptr_t>val.ctypes.data, sizeof((<CUfileIOParams_t*>NULL).u.batch)) 

302 self._owner = None 

303 self._owned = True 

304 self._readonly = not val.flags.writeable 

305 else: 

306 setattr(self, key, val) 

307  

308 @property 

309 def dev_ptr_base(self): 

310 """int: """ 

311 return <intptr_t>(self._ptr[0].devPtr_base) 

312  

313 @dev_ptr_base.setter 

314 def dev_ptr_base(self, val): 

315 if self._readonly: 

316 raise ValueError("This _py_anon_pod3 instance is read-only") 

317 self._ptr[0].devPtr_base = <void *><intptr_t>val 

318  

319 @property 

320 def file_offset(self): 

321 """int: """ 

322 return self._ptr[0].file_offset 

323  

324 @file_offset.setter 

325 def file_offset(self, val): 

326 if self._readonly: 

327 raise ValueError("This _py_anon_pod3 instance is read-only") 

328 self._ptr[0].file_offset = val 

329  

330 @property 

331 def dev_ptr_offset(self): 

332 """int: """ 

333 return self._ptr[0].devPtr_offset 

334  

335 @dev_ptr_offset.setter 

336 def dev_ptr_offset(self, val): 

337 if self._readonly: 

338 raise ValueError("This _py_anon_pod3 instance is read-only") 

339 self._ptr[0].devPtr_offset = val 

340  

341 @property 

342 def size_(self): 

343 """int: """ 

344 return self._ptr[0].size 

345  

346 @size_.setter 

347 def size_(self, val): 

348 if self._readonly: 

349 raise ValueError("This _py_anon_pod3 instance is read-only") 

350 self._ptr[0].size = val 

351  

352 @staticmethod 

353 def from_buffer(buffer): 

354 """Create an _py_anon_pod3 instance with the memory from the given buffer.""" 

355 return _cyb_from_buffer(buffer, sizeof((<CUfileIOParams_t*>NULL).u.batch), _py_anon_pod3) 

356  

357 @staticmethod 

358 def from_data(data): 

359 """Create an _py_anon_pod3 instance wrapping the given NumPy array. 

360  

361 Args: 

362 data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod3_dtype` holding the data. 

363 """ 

364 return _cyb_from_data(data, "_py_anon_pod3_dtype", _py_anon_pod3_dtype, _py_anon_pod3) 

365  

366 @staticmethod 

367 def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): 

368 """Create an _py_anon_pod3 instance wrapping the given pointer. 

369  

370 Args: 

371 ptr (intptr_t): pointer address as Python :class:`int` to the data. 

372 owner (object): The Python object that owns the pointer. If not provided, data will be copied. 

373 readonly (bool): whether the data is read-only (to the user). default is `False`. 

374 """ 

375 if ptr == 0: 

376 raise ValueError("ptr must not be null (0)") 

377 cdef _py_anon_pod3 obj = _py_anon_pod3.__new__(_py_anon_pod3) 

378 if owner is None: 

379 obj._ptr = <cuda_bindings_cufile__anon_pod3 *>_cyb_malloc(sizeof((<CUfileIOParams_t*>NULL).u.batch)) 

380 if obj._ptr == NULL: 

381 raise MemoryError("Error allocating _py_anon_pod3") 

382 _cyb_memcpy(<void*>(obj._ptr), <void*>ptr, sizeof((<CUfileIOParams_t*>NULL).u.batch)) 

383 obj._owner = None 

384 obj._owned = True 

385 else: 

386 obj._ptr = <cuda_bindings_cufile__anon_pod3 *>ptr 

387 obj._owner = owner 

388 obj._owned = False 

389 obj._readonly = readonly 

390 return obj 

391  

392  

393cdef _get_io_events_dtype_offsets(): 

394 cdef CUfileIOEvents_t pod 

395 return _numpy.dtype({ 

396 'names': ['cookie', 'status', 'ret'], 

397 'formats': [_numpy.intp, _numpy.int32, _numpy.uint64], 

398 'offsets': [ 

399 (<intptr_t>&(pod.cookie)) - (<intptr_t>&pod), 

400 (<intptr_t>&(pod.status)) - (<intptr_t>&pod), 

401 (<intptr_t>&(pod.ret)) - (<intptr_t>&pod), 

402 ], 

403 'itemsize': sizeof(CUfileIOEvents_t), 

404 }) 

405  

406io_events_dtype = _get_io_events_dtype_offsets() 

407  

408cdef class IOEvents: 

409 """Empty-initialize an array of `CUfileIOEvents_t`. 

410 The resulting object is of length `size` and of dtype `io_events_dtype`. 

411 If default-constructed, the instance represents a single struct. 

412  

413 Args: 

414 size (int): number of structs, default=1. 

415  

416 .. seealso:: `CUfileIOEvents_t` 

417 """ 

418 cdef: 

419 readonly object _data 

420 object _owner 

421  

422 def __init__(self, size=1): 

423 arr = _numpy.empty(size, dtype=io_events_dtype) 1df

424 self._data = arr.view(_numpy.recarray) 1df

425 assert self._data.itemsize == sizeof(CUfileIOEvents_t), \ 1df

426 f"itemsize {self._data.itemsize} mismatches struct size { sizeof(CUfileIOEvents_t) }" 

427  

428 def __repr__(self): 

429 if self._data.size > 1: 

430 return f"<{__name__}.IOEvents_Array_{self._data.size} object at {hex(id(self))}>" 

431 else: 

432 return f"<{__name__}.IOEvents object at {hex(id(self))}>" 

433  

434 @property 

435 def ptr(self): 

436 """Get the pointer address to the data as Python :class:`int`.""" 

437 return self._data.ctypes.data 1df

438  

439 cdef intptr_t _get_ptr(self): 

440 return self._data.ctypes.data 

441  

442 def __int__(self): 

443 if self._data.size > 1: 

444 raise TypeError("int() argument must be a bytes-like object of size 1. " 

445 "To get the pointer address of an array, use .ptr") 

446 return self._data.ctypes.data 

447  

448 def __len__(self): 

449 return self._data.size 

450  

451 def __eq__(self, other): 

452 cdef object self_data = self._data 

453 if (not isinstance(other, IOEvents)) or self_data.size != other._data.size or self_data.dtype != other._data.dtype: 

454 return False 

455 return bool((self_data == other._data).all()) 

456  

457 def __getbuffer__(self, Py_buffer *buffer, int flags): 

458 _cyb_cpython.PyObject_GetBuffer(self._data, buffer, flags) 

459  

460 def __releasebuffer__(self, Py_buffer *buffer): 

461 _cyb_cpython.PyBuffer_Release(buffer) 

462  

463 @property 

464 def cookie(self): 

465 """Union[~_numpy.intp, int]: """ 

466 if self._data.size == 1: 1df

467 return int(self._data.cookie[0]) 1df

468 return self._data.cookie 

469  

470 @cookie.setter 

471 def cookie(self, val): 

472 self._data.cookie = val 

473  

474 @property 

475 def status(self): 

476 """Union[~_numpy.int32, int]: """ 

477 if self._data.size == 1: 1df

478 return int(self._data.status[0]) 1df

479 return self._data.status 

480  

481 @status.setter 

482 def status(self, val): 

483 self._data.status = val 

484  

485 @property 

486 def ret(self): 

487 """Union[~_numpy.uint64, int]: """ 

488 if self._data.size == 1: 1d

489 return int(self._data.ret[0]) 1d

490 return self._data.ret 

491  

492 @ret.setter 

493 def ret(self, val): 

494 self._data.ret = val 

495  

496 def __getitem__(self, key): 

497 cdef ssize_t key_ 

498 cdef ssize_t size 

499 if isinstance(key, int): 1df

500 key_ = key 1df

501 size = self._data.size 1df

502 if key_ >= size or key_ <= -(size+1): 1df

503 raise IndexError("index is out of bounds") 

504 if key_ < 0: 1df

505 key_ += size 

506 return IOEvents.from_data(self._data[key_:key_+1]) 1df

507 out = self._data[key] 

508 if isinstance(out, _numpy.recarray) and out.dtype == io_events_dtype: 

509 return IOEvents.from_data(out) 

510 return out 

511  

512 def __setitem__(self, key, val): 

513 self._data[key] = val 

514  

515 @staticmethod 

516 def from_buffer(buffer): 

517 """Create an IOEvents instance with the memory from the given buffer.""" 

518 return IOEvents.from_data(_numpy.frombuffer(buffer, dtype=io_events_dtype)) 

519  

520 @staticmethod 

521 def from_data(data): 

522 """Create an IOEvents instance wrapping the given NumPy array. 

523  

524 Args: 

525 data (_numpy.ndarray): a 1D array of dtype `io_events_dtype` holding the data. 

526 """ 

527 cdef IOEvents obj = IOEvents.__new__(IOEvents) 1df

528 if not isinstance(data, _numpy.ndarray): 1df

529 raise TypeError("data argument must be a NumPy ndarray") 

530 if data.ndim != 1: 1df

531 raise ValueError("data array must be 1D") 

532 if data.dtype != io_events_dtype: 1df

533 raise ValueError("data array must be of dtype io_events_dtype") 

534 obj._data = data.view(_numpy.recarray) 1df

535  

536 return obj 1df

537  

538 @staticmethod 

539 def from_ptr(intptr_t ptr, size_t size=1, bint readonly=False, object owner=None): 

540 """Create an IOEvents instance wrapping the given pointer. 

541  

542 Args: 

543 ptr (intptr_t): pointer address as Python :class:`int` to the data. 

544 size (int): number of structs, default=1. 

545 readonly (bool): whether the data is read-only (to the user). default is `False`. 

546 owner (object): object that owns the memory at *ptr*. A strong reference is 

547 kept so the backing storage outlives this wrapper. 

548 """ 

549 if ptr == 0: 

550 raise ValueError("ptr must not be null (0)") 

551 cdef IOEvents obj = IOEvents.__new__(IOEvents) 

552 cdef flag = _cyb_cpython_buffer.PyBUF_READ if readonly else _cyb_cpython_buffer.PyBUF_WRITE 

553 cdef object buf = _cyb_cpython_memoryview.PyMemoryView_FromMemory( 

554 <char*>ptr, sizeof(CUfileIOEvents_t) * size, flag) 

555 data = _numpy.ndarray(size, buffer=buf, dtype=io_events_dtype) 

556 obj._data = data.view(_numpy.recarray) 

557 obj._owner = owner 

558  

559 return obj 

560  

561  

562cdef _get_op_counter_dtype_offsets(): 

563 cdef CUfileOpCounter_t pod 

564 return _numpy.dtype({ 

565 'names': ['ok', 'err'], 

566 'formats': [_numpy.uint64, _numpy.uint64], 

567 'offsets': [ 

568 (<intptr_t>&(pod.ok)) - (<intptr_t>&pod), 

569 (<intptr_t>&(pod.err)) - (<intptr_t>&pod), 

570 ], 

571 'itemsize': sizeof(CUfileOpCounter_t), 

572 }) 

573  

574op_counter_dtype = _get_op_counter_dtype_offsets() 

575  

576cdef class OpCounter: 

577 """Empty-initialize an instance of `CUfileOpCounter_t`. 

578  

579  

580 .. seealso:: `CUfileOpCounter_t` 

581 """ 

582 cdef: 

583 CUfileOpCounter_t *_ptr 

584 object _owner 

585 bint _owned 

586 bint _readonly 

587  

588 def __init__(self): 

589 self._ptr = <CUfileOpCounter_t *>_cyb_calloc(1, sizeof(CUfileOpCounter_t)) 

590 if self._ptr == NULL: 

591 raise MemoryError("Error allocating OpCounter") 

592 self._owner = None 

593 self._owned = True 

594 self._readonly = False 

595  

596 def __dealloc__(self): 

597 cdef CUfileOpCounter_t *ptr 

598 if self._owned and self._ptr != NULL: 1ec

599 ptr = self._ptr 

600 self._ptr = NULL 

601 _cyb_free(ptr) 

602  

603 def __repr__(self): 

604 return f"<{__name__}.OpCounter object at {hex(id(self))}>" 

605  

606 @property 

607 def ptr(self): 

608 """Get the pointer address to the data as Python :class:`int`.""" 

609 return <intptr_t>(self._ptr) 

610  

611 cdef intptr_t _get_ptr(self): 

612 return <intptr_t>(self._ptr) 

613  

614 def __int__(self): 

615 return <intptr_t>(self._ptr) 

616  

617 def __eq__(self, other): 

618 cdef OpCounter other_ 

619 if not isinstance(other, OpCounter): 

620 return False 

621 other_ = other 

622 return (_cyb_memcmp(<void *><intptr_t>(self._ptr), <void *><intptr_t>(other_._ptr), sizeof(CUfileOpCounter_t)) == 0) 

623  

624 def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): 

625 _cyb___getbuffer(self, buffer, <void *>self._ptr, sizeof(CUfileOpCounter_t), self._readonly) 

626  

627 def __releasebuffer__(self, Py_buffer *buffer): 

628 pass 

629  

630 def __setitem__(self, key, val): 

631 if key == 0 and isinstance(val, _numpy.ndarray): 

632 self._ptr = <CUfileOpCounter_t *>_cyb_malloc(sizeof(CUfileOpCounter_t)) 

633 if self._ptr == NULL: 

634 raise MemoryError("Error allocating OpCounter") 

635 _cyb_memcpy(<void*>self._ptr, <void*><intptr_t>val.ctypes.data, sizeof(CUfileOpCounter_t)) 

636 self._owner = None 

637 self._owned = True 

638 self._readonly = not val.flags.writeable 

639 else: 

640 setattr(self, key, val) 

641  

642 @property 

643 def ok(self): 

644 """int: """ 

645 return self._ptr[0].ok 1ec

646  

647 @ok.setter 

648 def ok(self, val): 

649 if self._readonly: 

650 raise ValueError("This OpCounter instance is read-only") 

651 self._ptr[0].ok = val 

652  

653 @property 

654 def err(self): 

655 """int: """ 

656 return self._ptr[0].err 

657  

658 @err.setter 

659 def err(self, val): 

660 if self._readonly: 

661 raise ValueError("This OpCounter instance is read-only") 

662 self._ptr[0].err = val 

663  

664 @staticmethod 

665 def from_buffer(buffer): 

666 """Create an OpCounter instance with the memory from the given buffer.""" 

667 return _cyb_from_buffer(buffer, sizeof(CUfileOpCounter_t), OpCounter) 

668  

669 @staticmethod 

670 def from_data(data): 

671 """Create an OpCounter instance wrapping the given NumPy array. 

672  

673 Args: 

674 data (_numpy.ndarray): a single-element array of dtype `op_counter_dtype` holding the data. 

675 """ 

676 return _cyb_from_data(data, "op_counter_dtype", op_counter_dtype, OpCounter) 1ec

677  

678 @staticmethod 

679 def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): 

680 """Create an OpCounter instance wrapping the given pointer. 

681  

682 Args: 

683 ptr (intptr_t): pointer address as Python :class:`int` to the data. 

684 owner (object): The Python object that owns the pointer. If not provided, data will be copied. 

685 readonly (bool): whether the data is read-only (to the user). default is `False`. 

686 """ 

687 if ptr == 0: 1ec

688 raise ValueError("ptr must not be null (0)") 

689 cdef OpCounter obj = OpCounter.__new__(OpCounter) 1ec

690 if owner is None: 1ec

691 obj._ptr = <CUfileOpCounter_t *>_cyb_malloc(sizeof(CUfileOpCounter_t)) 

692 if obj._ptr == NULL: 

693 raise MemoryError("Error allocating OpCounter") 

694 _cyb_memcpy(<void*>(obj._ptr), <void*>ptr, sizeof(CUfileOpCounter_t)) 

695 obj._owner = None 

696 obj._owned = True 

697 else: 

698 obj._ptr = <CUfileOpCounter_t *>ptr 1ec

699 obj._owner = owner 1ec

700 obj._owned = False 1ec

701 obj._readonly = readonly 1ec

702 return obj 1ec

703  

704  

705cdef _get_per_gpu_stats_dtype_offsets(): 

706 cdef CUfilePerGpuStats_t pod 

707 return _numpy.dtype({ 

708 'names': ['uuid', 'read_bytes', 'read_bw_bytes_per_sec', 'read_utilization', 'read_duration_us', 'n_total_reads', 'n_p2p_reads', 'n_nvfs_reads', 'n_posix_reads', 'n_unaligned_reads', 'n_dr_reads', 'n_sparse_regions', 'n_inline_regions', 'n_reads_err', 'writes_bytes', 'write_bw_bytes_per_sec', 'write_utilization', 'write_duration_us', 'n_total_writes', 'n_p2p_writes', 'n_nvfs_writes', 'n_posix_writes', 'n_unaligned_writes', 'n_dr_writes', 'n_writes_err', 'n_mmap', 'n_mmap_ok', 'n_mmap_err', 'n_mmap_free', 'reg_bytes'], 

709 'formats': [(_numpy.int8, 16), _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64], 

710 'offsets': [ 

711 (<intptr_t>&(pod.uuid)) - (<intptr_t>&pod), 

712 (<intptr_t>&(pod.read_bytes)) - (<intptr_t>&pod), 

713 (<intptr_t>&(pod.read_bw_bytes_per_sec)) - (<intptr_t>&pod), 

714 (<intptr_t>&(pod.read_utilization)) - (<intptr_t>&pod), 

715 (<intptr_t>&(pod.read_duration_us)) - (<intptr_t>&pod), 

716 (<intptr_t>&(pod.n_total_reads)) - (<intptr_t>&pod), 

717 (<intptr_t>&(pod.n_p2p_reads)) - (<intptr_t>&pod), 

718 (<intptr_t>&(pod.n_nvfs_reads)) - (<intptr_t>&pod), 

719 (<intptr_t>&(pod.n_posix_reads)) - (<intptr_t>&pod), 

720 (<intptr_t>&(pod.n_unaligned_reads)) - (<intptr_t>&pod), 

721 (<intptr_t>&(pod.n_dr_reads)) - (<intptr_t>&pod), 

722 (<intptr_t>&(pod.n_sparse_regions)) - (<intptr_t>&pod), 

723 (<intptr_t>&(pod.n_inline_regions)) - (<intptr_t>&pod), 

724 (<intptr_t>&(pod.n_reads_err)) - (<intptr_t>&pod), 

725 (<intptr_t>&(pod.writes_bytes)) - (<intptr_t>&pod), 

726 (<intptr_t>&(pod.write_bw_bytes_per_sec)) - (<intptr_t>&pod), 

727 (<intptr_t>&(pod.write_utilization)) - (<intptr_t>&pod), 

728 (<intptr_t>&(pod.write_duration_us)) - (<intptr_t>&pod), 

729 (<intptr_t>&(pod.n_total_writes)) - (<intptr_t>&pod), 

730 (<intptr_t>&(pod.n_p2p_writes)) - (<intptr_t>&pod), 

731 (<intptr_t>&(pod.n_nvfs_writes)) - (<intptr_t>&pod), 

732 (<intptr_t>&(pod.n_posix_writes)) - (<intptr_t>&pod), 

733 (<intptr_t>&(pod.n_unaligned_writes)) - (<intptr_t>&pod), 

734 (<intptr_t>&(pod.n_dr_writes)) - (<intptr_t>&pod), 

735 (<intptr_t>&(pod.n_writes_err)) - (<intptr_t>&pod), 

736 (<intptr_t>&(pod.n_mmap)) - (<intptr_t>&pod), 

737 (<intptr_t>&(pod.n_mmap_ok)) - (<intptr_t>&pod), 

738 (<intptr_t>&(pod.n_mmap_err)) - (<intptr_t>&pod), 

739 (<intptr_t>&(pod.n_mmap_free)) - (<intptr_t>&pod), 

740 (<intptr_t>&(pod.reg_bytes)) - (<intptr_t>&pod), 

741 ], 

742 'itemsize': sizeof(CUfilePerGpuStats_t), 

743 }) 

744  

745per_gpu_stats_dtype = _get_per_gpu_stats_dtype_offsets() 

746  

747cdef class PerGpuStats: 

748 """Empty-initialize an array of `CUfilePerGpuStats_t`. 

749 The resulting object is of length `size` and of dtype `per_gpu_stats_dtype`. 

750 If default-constructed, the instance represents a single struct. 

751  

752 Args: 

753 size (int): number of structs, default=1. 

754  

755 .. seealso:: `CUfilePerGpuStats_t` 

756 """ 

757 cdef: 

758 readonly object _data 

759 object _owner 

760  

761 def __init__(self, size=1): 

762 arr = _numpy.empty(size, dtype=per_gpu_stats_dtype) 

763 self._data = arr.view(_numpy.recarray) 

764 assert self._data.itemsize == sizeof(CUfilePerGpuStats_t), \ 

765 f"itemsize {self._data.itemsize} mismatches struct size { sizeof(CUfilePerGpuStats_t) }" 

766  

767 def __repr__(self): 

768 if self._data.size > 1: 

769 return f"<{__name__}.PerGpuStats_Array_{self._data.size} object at {hex(id(self))}>" 

770 else: 

771 return f"<{__name__}.PerGpuStats object at {hex(id(self))}>" 

772  

773 @property 

774 def ptr(self): 

775 """Get the pointer address to the data as Python :class:`int`.""" 

776 return self._data.ctypes.data 

777  

778 cdef intptr_t _get_ptr(self): 

779 return self._data.ctypes.data 

780  

781 def __int__(self): 

782 if self._data.size > 1: 

783 raise TypeError("int() argument must be a bytes-like object of size 1. " 

784 "To get the pointer address of an array, use .ptr") 

785 return self._data.ctypes.data 

786  

787 def __len__(self): 

788 return self._data.size 

789  

790 def __eq__(self, other): 

791 cdef object self_data = self._data 

792 if (not isinstance(other, PerGpuStats)) or self_data.size != other._data.size or self_data.dtype != other._data.dtype: 

793 return False 

794 return bool((self_data == other._data).all()) 

795  

796 def __getbuffer__(self, Py_buffer *buffer, int flags): 

797 _cyb_cpython.PyObject_GetBuffer(self._data, buffer, flags) 

798  

799 def __releasebuffer__(self, Py_buffer *buffer): 

800 _cyb_cpython.PyBuffer_Release(buffer) 

801  

802 @property 

803 def uuid(self): 

804 """~_numpy.int8: (array of length 16).""" 

805 return self._data.uuid 

806  

807 @uuid.setter 

808 def uuid(self, val): 

809 self._data.uuid = val 

810  

811 @property 

812 def read_bytes(self): 

813 """Union[~_numpy.uint64, int]: """ 

814 if self._data.size == 1: 

815 return int(self._data.read_bytes[0]) 

816 return self._data.read_bytes 

817  

818 @read_bytes.setter 

819 def read_bytes(self, val): 

820 self._data.read_bytes = val 

821  

822 @property 

823 def read_bw_bytes_per_sec(self): 

824 """Union[~_numpy.uint64, int]: """ 

825 if self._data.size == 1: 

826 return int(self._data.read_bw_bytes_per_sec[0]) 

827 return self._data.read_bw_bytes_per_sec 

828  

829 @read_bw_bytes_per_sec.setter 

830 def read_bw_bytes_per_sec(self, val): 

831 self._data.read_bw_bytes_per_sec = val 

832  

833 @property 

834 def read_utilization(self): 

835 """Union[~_numpy.uint64, int]: """ 

836 if self._data.size == 1: 

837 return int(self._data.read_utilization[0]) 

838 return self._data.read_utilization 

839  

840 @read_utilization.setter 

841 def read_utilization(self, val): 

842 self._data.read_utilization = val 

843  

844 @property 

845 def read_duration_us(self): 

846 """Union[~_numpy.uint64, int]: """ 

847 if self._data.size == 1: 

848 return int(self._data.read_duration_us[0]) 

849 return self._data.read_duration_us 

850  

851 @read_duration_us.setter 

852 def read_duration_us(self, val): 

853 self._data.read_duration_us = val 

854  

855 @property 

856 def n_total_reads(self): 

857 """Union[~_numpy.uint64, int]: """ 

858 if self._data.size == 1: 1b

859 return int(self._data.n_total_reads[0]) 1b

860 return self._data.n_total_reads 

861  

862 @n_total_reads.setter 

863 def n_total_reads(self, val): 

864 self._data.n_total_reads = val 

865  

866 @property 

867 def n_p2p_reads(self): 

868 """Union[~_numpy.uint64, int]: """ 

869 if self._data.size == 1: 

870 return int(self._data.n_p2p_reads[0]) 

871 return self._data.n_p2p_reads 

872  

873 @n_p2p_reads.setter 

874 def n_p2p_reads(self, val): 

875 self._data.n_p2p_reads = val 

876  

877 @property 

878 def n_nvfs_reads(self): 

879 """Union[~_numpy.uint64, int]: """ 

880 if self._data.size == 1: 

881 return int(self._data.n_nvfs_reads[0]) 

882 return self._data.n_nvfs_reads 

883  

884 @n_nvfs_reads.setter 

885 def n_nvfs_reads(self, val): 

886 self._data.n_nvfs_reads = val 

887  

888 @property 

889 def n_posix_reads(self): 

890 """Union[~_numpy.uint64, int]: """ 

891 if self._data.size == 1: 

892 return int(self._data.n_posix_reads[0]) 

893 return self._data.n_posix_reads 

894  

895 @n_posix_reads.setter 

896 def n_posix_reads(self, val): 

897 self._data.n_posix_reads = val 

898  

899 @property 

900 def n_unaligned_reads(self): 

901 """Union[~_numpy.uint64, int]: """ 

902 if self._data.size == 1: 

903 return int(self._data.n_unaligned_reads[0]) 

904 return self._data.n_unaligned_reads 

905  

906 @n_unaligned_reads.setter 

907 def n_unaligned_reads(self, val): 

908 self._data.n_unaligned_reads = val 

909  

910 @property 

911 def n_dr_reads(self): 

912 """Union[~_numpy.uint64, int]: """ 

913 if self._data.size == 1: 

914 return int(self._data.n_dr_reads[0]) 

915 return self._data.n_dr_reads 

916  

917 @n_dr_reads.setter 

918 def n_dr_reads(self, val): 

919 self._data.n_dr_reads = val 

920  

921 @property 

922 def n_sparse_regions(self): 

923 """Union[~_numpy.uint64, int]: """ 

924 if self._data.size == 1: 

925 return int(self._data.n_sparse_regions[0]) 

926 return self._data.n_sparse_regions 

927  

928 @n_sparse_regions.setter 

929 def n_sparse_regions(self, val): 

930 self._data.n_sparse_regions = val 

931  

932 @property 

933 def n_inline_regions(self): 

934 """Union[~_numpy.uint64, int]: """ 

935 if self._data.size == 1: 

936 return int(self._data.n_inline_regions[0]) 

937 return self._data.n_inline_regions 

938  

939 @n_inline_regions.setter 

940 def n_inline_regions(self, val): 

941 self._data.n_inline_regions = val 

942  

943 @property 

944 def n_reads_err(self): 

945 """Union[~_numpy.uint64, int]: """ 

946 if self._data.size == 1: 

947 return int(self._data.n_reads_err[0]) 

948 return self._data.n_reads_err 

949  

950 @n_reads_err.setter 

951 def n_reads_err(self, val): 

952 self._data.n_reads_err = val 

953  

954 @property 

955 def writes_bytes(self): 

956 """Union[~_numpy.uint64, int]: """ 

957 if self._data.size == 1: 

958 return int(self._data.writes_bytes[0]) 

959 return self._data.writes_bytes 

960  

961 @writes_bytes.setter 

962 def writes_bytes(self, val): 

963 self._data.writes_bytes = val 

964  

965 @property 

966 def write_bw_bytes_per_sec(self): 

967 """Union[~_numpy.uint64, int]: """ 

968 if self._data.size == 1: 

969 return int(self._data.write_bw_bytes_per_sec[0]) 

970 return self._data.write_bw_bytes_per_sec 

971  

972 @write_bw_bytes_per_sec.setter 

973 def write_bw_bytes_per_sec(self, val): 

974 self._data.write_bw_bytes_per_sec = val 

975  

976 @property 

977 def write_utilization(self): 

978 """Union[~_numpy.uint64, int]: """ 

979 if self._data.size == 1: 

980 return int(self._data.write_utilization[0]) 

981 return self._data.write_utilization 

982  

983 @write_utilization.setter 

984 def write_utilization(self, val): 

985 self._data.write_utilization = val 

986  

987 @property 

988 def write_duration_us(self): 

989 """Union[~_numpy.uint64, int]: """ 

990 if self._data.size == 1: 

991 return int(self._data.write_duration_us[0]) 

992 return self._data.write_duration_us 

993  

994 @write_duration_us.setter 

995 def write_duration_us(self, val): 

996 self._data.write_duration_us = val 

997  

998 @property 

999 def n_total_writes(self): 

1000 """Union[~_numpy.uint64, int]: """ 

1001 if self._data.size == 1: 

1002 return int(self._data.n_total_writes[0]) 

1003 return self._data.n_total_writes 

1004  

1005 @n_total_writes.setter 

1006 def n_total_writes(self, val): 

1007 self._data.n_total_writes = val 

1008  

1009 @property 

1010 def n_p2p_writes(self): 

1011 """Union[~_numpy.uint64, int]: """ 

1012 if self._data.size == 1: 

1013 return int(self._data.n_p2p_writes[0]) 

1014 return self._data.n_p2p_writes 

1015  

1016 @n_p2p_writes.setter 

1017 def n_p2p_writes(self, val): 

1018 self._data.n_p2p_writes = val 

1019  

1020 @property 

1021 def n_nvfs_writes(self): 

1022 """Union[~_numpy.uint64, int]: """ 

1023 if self._data.size == 1: 

1024 return int(self._data.n_nvfs_writes[0]) 

1025 return self._data.n_nvfs_writes 

1026  

1027 @n_nvfs_writes.setter 

1028 def n_nvfs_writes(self, val): 

1029 self._data.n_nvfs_writes = val 

1030  

1031 @property 

1032 def n_posix_writes(self): 

1033 """Union[~_numpy.uint64, int]: """ 

1034 if self._data.size == 1: 

1035 return int(self._data.n_posix_writes[0]) 

1036 return self._data.n_posix_writes 

1037  

1038 @n_posix_writes.setter 

1039 def n_posix_writes(self, val): 

1040 self._data.n_posix_writes = val 

1041  

1042 @property 

1043 def n_unaligned_writes(self): 

1044 """Union[~_numpy.uint64, int]: """ 

1045 if self._data.size == 1: 

1046 return int(self._data.n_unaligned_writes[0]) 

1047 return self._data.n_unaligned_writes 

1048  

1049 @n_unaligned_writes.setter 

1050 def n_unaligned_writes(self, val): 

1051 self._data.n_unaligned_writes = val 

1052  

1053 @property 

1054 def n_dr_writes(self): 

1055 """Union[~_numpy.uint64, int]: """ 

1056 if self._data.size == 1: 

1057 return int(self._data.n_dr_writes[0]) 

1058 return self._data.n_dr_writes 

1059  

1060 @n_dr_writes.setter 

1061 def n_dr_writes(self, val): 

1062 self._data.n_dr_writes = val 

1063  

1064 @property 

1065 def n_writes_err(self): 

1066 """Union[~_numpy.uint64, int]: """ 

1067 if self._data.size == 1: 

1068 return int(self._data.n_writes_err[0]) 

1069 return self._data.n_writes_err 

1070  

1071 @n_writes_err.setter 

1072 def n_writes_err(self, val): 

1073 self._data.n_writes_err = val 

1074  

1075 @property 

1076 def n_mmap(self): 

1077 """Union[~_numpy.uint64, int]: """ 

1078 if self._data.size == 1: 

1079 return int(self._data.n_mmap[0]) 

1080 return self._data.n_mmap 

1081  

1082 @n_mmap.setter 

1083 def n_mmap(self, val): 

1084 self._data.n_mmap = val 

1085  

1086 @property 

1087 def n_mmap_ok(self): 

1088 """Union[~_numpy.uint64, int]: """ 

1089 if self._data.size == 1: 

1090 return int(self._data.n_mmap_ok[0]) 

1091 return self._data.n_mmap_ok 

1092  

1093 @n_mmap_ok.setter 

1094 def n_mmap_ok(self, val): 

1095 self._data.n_mmap_ok = val 

1096  

1097 @property 

1098 def n_mmap_err(self): 

1099 """Union[~_numpy.uint64, int]: """ 

1100 if self._data.size == 1: 

1101 return int(self._data.n_mmap_err[0]) 

1102 return self._data.n_mmap_err 

1103  

1104 @n_mmap_err.setter 

1105 def n_mmap_err(self, val): 

1106 self._data.n_mmap_err = val 

1107  

1108 @property 

1109 def n_mmap_free(self): 

1110 """Union[~_numpy.uint64, int]: """ 

1111 if self._data.size == 1: 

1112 return int(self._data.n_mmap_free[0]) 

1113 return self._data.n_mmap_free 

1114  

1115 @n_mmap_free.setter 

1116 def n_mmap_free(self, val): 

1117 self._data.n_mmap_free = val 

1118  

1119 @property 

1120 def reg_bytes(self): 

1121 """Union[~_numpy.uint64, int]: """ 

1122 if self._data.size == 1: 

1123 return int(self._data.reg_bytes[0]) 

1124 return self._data.reg_bytes 

1125  

1126 @reg_bytes.setter 

1127 def reg_bytes(self, val): 

1128 self._data.reg_bytes = val 

1129  

1130 def __getitem__(self, key): 

1131 cdef ssize_t key_ 

1132 cdef ssize_t size 

1133 if isinstance(key, int): 1b

1134 key_ = key 1b

1135 size = self._data.size 1b

1136 if key_ >= size or key_ <= -(size+1): 1b

1137 raise IndexError("index is out of bounds") 

1138 if key_ < 0: 1b

1139 key_ += size 

1140 return PerGpuStats.from_data(self._data[key_:key_+1]) 1b

1141 out = self._data[key] 

1142 if isinstance(out, _numpy.recarray) and out.dtype == per_gpu_stats_dtype: 

1143 return PerGpuStats.from_data(out) 

1144 return out 

1145  

1146 def __setitem__(self, key, val): 

1147 self._data[key] = val 

1148  

1149 @staticmethod 

1150 def from_buffer(buffer): 

1151 """Create an PerGpuStats instance with the memory from the given buffer.""" 

1152 return PerGpuStats.from_data(_numpy.frombuffer(buffer, dtype=per_gpu_stats_dtype)) 

1153  

1154 @staticmethod 

1155 def from_data(data): 

1156 """Create an PerGpuStats instance wrapping the given NumPy array. 

1157  

1158 Args: 

1159 data (_numpy.ndarray): a 1D array of dtype `per_gpu_stats_dtype` holding the data. 

1160 """ 

1161 cdef PerGpuStats obj = PerGpuStats.__new__(PerGpuStats) 1b

1162 if not isinstance(data, _numpy.ndarray): 1b

1163 raise TypeError("data argument must be a NumPy ndarray") 

1164 if data.ndim != 1: 1b

1165 raise ValueError("data array must be 1D") 

1166 if data.dtype != per_gpu_stats_dtype: 1b

1167 raise ValueError("data array must be of dtype per_gpu_stats_dtype") 

1168 obj._data = data.view(_numpy.recarray) 1b

1169  

1170 return obj 1b

1171  

1172 @staticmethod 

1173 def from_ptr(intptr_t ptr, size_t size=1, bint readonly=False, object owner=None): 

1174 """Create an PerGpuStats instance wrapping the given pointer. 

1175  

1176 Args: 

1177 ptr (intptr_t): pointer address as Python :class:`int` to the data. 

1178 size (int): number of structs, default=1. 

1179 readonly (bool): whether the data is read-only (to the user). default is `False`. 

1180 owner (object): object that owns the memory at *ptr*. A strong reference is 

1181 kept so the backing storage outlives this wrapper. 

1182 """ 

1183 if ptr == 0: 1b

1184 raise ValueError("ptr must not be null (0)") 

1185 cdef PerGpuStats obj = PerGpuStats.__new__(PerGpuStats) 1b

1186 cdef flag = _cyb_cpython_buffer.PyBUF_READ if readonly else _cyb_cpython_buffer.PyBUF_WRITE 1b

1187 cdef object buf = _cyb_cpython_memoryview.PyMemoryView_FromMemory( 1b

1188 <char*>ptr, sizeof(CUfilePerGpuStats_t) * size, flag) 1b

1189 data = _numpy.ndarray(size, buffer=buf, dtype=per_gpu_stats_dtype) 1b

1190 obj._data = data.view(_numpy.recarray) 1b

1191 obj._owner = owner 1b

1192  

1193 return obj 1b

1194  

1195  

1196cdef _get_descr_dtype_offsets(): 

1197 cdef CUfileDescr_t pod 

1198 return _numpy.dtype({ 

1199 'names': ['type', 'handle', 'fs_ops'], 

1200 'formats': [_numpy.int32, _py_anon_pod1_dtype, _numpy.intp], 

1201 'offsets': [ 

1202 (<intptr_t>&(pod.type)) - (<intptr_t>&pod), 

1203 (<intptr_t>&(pod.handle)) - (<intptr_t>&pod), 

1204 (<intptr_t>&(pod.fs_ops)) - (<intptr_t>&pod), 

1205 ], 

1206 'itemsize': sizeof(CUfileDescr_t), 

1207 }) 

1208  

1209descr_dtype = _get_descr_dtype_offsets() 

1210  

1211cdef class Descr: 

1212 """Empty-initialize an array of `CUfileDescr_t`. 

1213 The resulting object is of length `size` and of dtype `descr_dtype`. 

1214 If default-constructed, the instance represents a single struct. 

1215  

1216 Args: 

1217 size (int): number of structs, default=1. 

1218  

1219 .. seealso:: `CUfileDescr_t` 

1220 """ 

1221 cdef: 

1222 readonly object _data 

1223 object _owner 

1224  

1225 def __init__(self, size=1): 

1226 arr = _numpy.empty(size, dtype=descr_dtype) 1dgfhijklmecbr

1227 self._data = arr.view(_numpy.recarray) 1dgfhijklmecbr

1228 assert self._data.itemsize == sizeof(CUfileDescr_t), \ 1dgfhijklmecbr

1229 f"itemsize {self._data.itemsize} mismatches struct size { sizeof(CUfileDescr_t) }" 

1230  

1231 def __repr__(self): 

1232 if self._data.size > 1: 

1233 return f"<{__name__}.Descr_Array_{self._data.size} object at {hex(id(self))}>" 

1234 else: 

1235 return f"<{__name__}.Descr object at {hex(id(self))}>" 

1236  

1237 @property 

1238 def ptr(self): 

1239 """Get the pointer address to the data as Python :class:`int`.""" 

1240 return self._data.ctypes.data 1dgfhijklmecbr

1241  

1242 cdef intptr_t _get_ptr(self): 

1243 return self._data.ctypes.data 

1244  

1245 def __int__(self): 

1246 if self._data.size > 1: 

1247 raise TypeError("int() argument must be a bytes-like object of size 1. " 

1248 "To get the pointer address of an array, use .ptr") 

1249 return self._data.ctypes.data 

1250  

1251 def __len__(self): 

1252 return self._data.size 

1253  

1254 def __eq__(self, other): 

1255 cdef object self_data = self._data 

1256 if (not isinstance(other, Descr)) or self_data.size != other._data.size or self_data.dtype != other._data.dtype: 

1257 return False 

1258 return bool((self_data == other._data).all()) 

1259  

1260 def __getbuffer__(self, Py_buffer *buffer, int flags): 

1261 _cyb_cpython.PyObject_GetBuffer(self._data, buffer, flags) 

1262  

1263 def __releasebuffer__(self, Py_buffer *buffer): 

1264 _cyb_cpython.PyBuffer_Release(buffer) 

1265  

1266 @property 

1267 def type(self): 

1268 """Union[~_numpy.int32, int]: """ 

1269 if self._data.size == 1: 

1270 return int(self._data.type[0]) 

1271 return self._data.type 

1272  

1273 @type.setter 

1274 def type(self, val): 

1275 self._data.type = val 1dgfhijklmecbr

1276  

1277 @property 

1278 def handle(self): 

1279 """_py_anon_pod1_dtype: """ 

1280 return self._data.handle 1dgfhijklmecbr

1281  

1282 @handle.setter 

1283 def handle(self, val): 

1284 self._data.handle = val 

1285  

1286 @property 

1287 def fs_ops(self): 

1288 """Union[~_numpy.intp, int]: """ 

1289 if self._data.size == 1: 

1290 return int(self._data.fs_ops[0]) 

1291 return self._data.fs_ops 

1292  

1293 @fs_ops.setter 

1294 def fs_ops(self, val): 

1295 self._data.fs_ops = val 1dgfhijklmecbr

1296  

1297 def __getitem__(self, key): 

1298 cdef ssize_t key_ 

1299 cdef ssize_t size 

1300 if isinstance(key, int): 

1301 key_ = key 

1302 size = self._data.size 

1303 if key_ >= size or key_ <= -(size+1): 

1304 raise IndexError("index is out of bounds") 

1305 if key_ < 0: 

1306 key_ += size 

1307 return Descr.from_data(self._data[key_:key_+1]) 

1308 out = self._data[key] 

1309 if isinstance(out, _numpy.recarray) and out.dtype == descr_dtype: 

1310 return Descr.from_data(out) 

1311 return out 

1312  

1313 def __setitem__(self, key, val): 

1314 self._data[key] = val 

1315  

1316 @staticmethod 

1317 def from_buffer(buffer): 

1318 """Create an Descr instance with the memory from the given buffer.""" 

1319 return Descr.from_data(_numpy.frombuffer(buffer, dtype=descr_dtype)) 

1320  

1321 @staticmethod 

1322 def from_data(data): 

1323 """Create an Descr instance wrapping the given NumPy array. 

1324  

1325 Args: 

1326 data (_numpy.ndarray): a 1D array of dtype `descr_dtype` holding the data. 

1327 """ 

1328 cdef Descr obj = Descr.__new__(Descr) 

1329 if not isinstance(data, _numpy.ndarray): 

1330 raise TypeError("data argument must be a NumPy ndarray") 

1331 if data.ndim != 1: 

1332 raise ValueError("data array must be 1D") 

1333 if data.dtype != descr_dtype: 

1334 raise ValueError("data array must be of dtype descr_dtype") 

1335 obj._data = data.view(_numpy.recarray) 

1336  

1337 return obj 

1338  

1339 @staticmethod 

1340 def from_ptr(intptr_t ptr, size_t size=1, bint readonly=False, object owner=None): 

1341 """Create an Descr instance wrapping the given pointer. 

1342  

1343 Args: 

1344 ptr (intptr_t): pointer address as Python :class:`int` to the data. 

1345 size (int): number of structs, default=1. 

1346 readonly (bool): whether the data is read-only (to the user). default is `False`. 

1347 owner (object): object that owns the memory at *ptr*. A strong reference is 

1348 kept so the backing storage outlives this wrapper. 

1349 """ 

1350 if ptr == 0: 

1351 raise ValueError("ptr must not be null (0)") 

1352 cdef Descr obj = Descr.__new__(Descr) 

1353 cdef flag = _cyb_cpython_buffer.PyBUF_READ if readonly else _cyb_cpython_buffer.PyBUF_WRITE 

1354 cdef object buf = _cyb_cpython_memoryview.PyMemoryView_FromMemory( 

1355 <char*>ptr, sizeof(CUfileDescr_t) * size, flag) 

1356 data = _numpy.ndarray(size, buffer=buf, dtype=descr_dtype) 

1357 obj._data = data.view(_numpy.recarray) 

1358 obj._owner = owner 

1359  

1360 return obj 

1361  

1362  

1363cdef _get__py_anon_pod2_dtype_offsets(): 

1364 cdef cuda_bindings_cufile__anon_pod2 pod 

1365 return _numpy.dtype({ 

1366 'names': ['batch'], 

1367 'formats': [_py_anon_pod3_dtype], 

1368 'offsets': [ 

1369 (<intptr_t>&(pod.batch)) - (<intptr_t>&pod), 

1370 ], 

1371 'itemsize': sizeof((<CUfileIOParams_t*>NULL).u), 

1372 }) 

1373  

1374_py_anon_pod2_dtype = _get__py_anon_pod2_dtype_offsets() 

1375  

1376cdef class _py_anon_pod2: 

1377 """Empty-initialize an instance of `cuda_bindings_cufile__anon_pod2`. 

1378  

1379  

1380 .. seealso:: `cuda_bindings_cufile__anon_pod2` 

1381 """ 

1382 cdef: 

1383 cuda_bindings_cufile__anon_pod2 *_ptr 

1384 object _owner 

1385 bint _owned 

1386 bint _readonly 

1387  

1388 def __init__(self): 

1389 self._ptr = <cuda_bindings_cufile__anon_pod2 *>_cyb_calloc(1, sizeof((<CUfileIOParams_t*>NULL).u)) 

1390 if self._ptr == NULL: 

1391 raise MemoryError("Error allocating _py_anon_pod2") 

1392 self._owner = None 

1393 self._owned = True 

1394 self._readonly = False 

1395  

1396 def __dealloc__(self): 

1397 cdef cuda_bindings_cufile__anon_pod2 *ptr 

1398 if self._owned and self._ptr != NULL: 

1399 ptr = self._ptr 

1400 self._ptr = NULL 

1401 _cyb_free(ptr) 

1402  

1403 def __repr__(self): 

1404 return f"<{__name__}._py_anon_pod2 object at {hex(id(self))}>" 

1405  

1406 @property 

1407 def ptr(self): 

1408 """Get the pointer address to the data as Python :class:`int`.""" 

1409 return <intptr_t>(self._ptr) 

1410  

1411 cdef intptr_t _get_ptr(self): 

1412 return <intptr_t>(self._ptr) 

1413  

1414 def __int__(self): 

1415 return <intptr_t>(self._ptr) 

1416  

1417 def __eq__(self, other): 

1418 cdef _py_anon_pod2 other_ 

1419 if not isinstance(other, _py_anon_pod2): 

1420 return False 

1421 other_ = other 

1422 return (_cyb_memcmp(<void *><intptr_t>(self._ptr), <void *><intptr_t>(other_._ptr), sizeof((<CUfileIOParams_t*>NULL).u)) == 0) 

1423  

1424 def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): 

1425 _cyb___getbuffer(self, buffer, <void *>self._ptr, sizeof((<CUfileIOParams_t*>NULL).u), self._readonly) 

1426  

1427 def __releasebuffer__(self, Py_buffer *buffer): 

1428 pass 

1429  

1430 def __setitem__(self, key, val): 

1431 if key == 0 and isinstance(val, _numpy.ndarray): 

1432 self._ptr = <cuda_bindings_cufile__anon_pod2 *>_cyb_malloc(sizeof((<CUfileIOParams_t*>NULL).u)) 

1433 if self._ptr == NULL: 

1434 raise MemoryError("Error allocating _py_anon_pod2") 

1435 _cyb_memcpy(<void*>self._ptr, <void*><intptr_t>val.ctypes.data, sizeof((<CUfileIOParams_t*>NULL).u)) 

1436 self._owner = None 

1437 self._owned = True 

1438 self._readonly = not val.flags.writeable 

1439 else: 

1440 setattr(self, key, val) 

1441  

1442 @property 

1443 def batch(self): 

1444 """_py_anon_pod3: """ 

1445 return _py_anon_pod3.from_ptr( 

1446 <intptr_t>&(self._ptr[0].batch), 

1447 readonly=self._readonly, 

1448 owner=self, 

1449 ) 

1450  

1451 @batch.setter 

1452 def batch(self, val): 

1453 if self._readonly: 

1454 raise ValueError("This _py_anon_pod2 instance is read-only") 

1455 cdef _py_anon_pod3 val_ = val 

1456 _cyb_memcpy(<void *>&(self._ptr[0].batch), <void *>(val_._get_ptr()), sizeof(cuda_bindings_cufile__anon_pod3) * 1) 

1457  

1458 @staticmethod 

1459 def from_buffer(buffer): 

1460 """Create an _py_anon_pod2 instance with the memory from the given buffer.""" 

1461 return _cyb_from_buffer(buffer, sizeof((<CUfileIOParams_t*>NULL).u), _py_anon_pod2) 

1462  

1463 @staticmethod 

1464 def from_data(data): 

1465 """Create an _py_anon_pod2 instance wrapping the given NumPy array. 

1466  

1467 Args: 

1468 data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod2_dtype` holding the data. 

1469 """ 

1470 return _cyb_from_data(data, "_py_anon_pod2_dtype", _py_anon_pod2_dtype, _py_anon_pod2) 

1471  

1472 @staticmethod 

1473 def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): 

1474 """Create an _py_anon_pod2 instance wrapping the given pointer. 

1475  

1476 Args: 

1477 ptr (intptr_t): pointer address as Python :class:`int` to the data. 

1478 owner (object): The Python object that owns the pointer. If not provided, data will be copied. 

1479 readonly (bool): whether the data is read-only (to the user). default is `False`. 

1480 """ 

1481 if ptr == 0: 

1482 raise ValueError("ptr must not be null (0)") 

1483 cdef _py_anon_pod2 obj = _py_anon_pod2.__new__(_py_anon_pod2) 

1484 if owner is None: 

1485 obj._ptr = <cuda_bindings_cufile__anon_pod2 *>_cyb_malloc(sizeof((<CUfileIOParams_t*>NULL).u)) 

1486 if obj._ptr == NULL: 

1487 raise MemoryError("Error allocating _py_anon_pod2") 

1488 _cyb_memcpy(<void*>(obj._ptr), <void*>ptr, sizeof((<CUfileIOParams_t*>NULL).u)) 

1489 obj._owner = None 

1490 obj._owned = True 

1491 else: 

1492 obj._ptr = <cuda_bindings_cufile__anon_pod2 *>ptr 

1493 obj._owner = owner 

1494 obj._owned = False 

1495 obj._readonly = readonly 

1496 return obj 

1497  

1498  

1499cdef _get_stats_level1_dtype_offsets(): 

1500 cdef CUfileStatsLevel1_t pod 

1501 return _numpy.dtype({ 

1502 'names': ['read_ops', 'write_ops', 'hdl_register_ops', 'hdl_deregister_ops', 'buf_register_ops', 'buf_deregister_ops', 'read_bytes', 'write_bytes', 'read_bw_bytes_per_sec', 'write_bw_bytes_per_sec', 'read_lat_avg_us', 'write_lat_avg_us', 'read_ops_per_sec', 'write_ops_per_sec', 'read_lat_sum_us', 'write_lat_sum_us', 'batch_submit_ops', 'batch_complete_ops', 'batch_setup_ops', 'batch_cancel_ops', 'batch_destroy_ops', 'batch_enqueued_ops', 'batch_posix_enqueued_ops', 'batch_processed_ops', 'batch_posix_processed_ops', 'batch_nvfs_submit_ops', 'batch_p2p_submit_ops', 'batch_aio_submit_ops', 'batch_iouring_submit_ops', 'batch_mixed_io_submit_ops', 'batch_total_submit_ops', 'batch_read_bytes', 'batch_write_bytes', 'batch_read_bw_bytes', 'batch_write_bw_bytes', 'batch_submit_lat_avg_us', 'batch_completion_lat_avg_us', 'batch_submit_ops_per_sec', 'batch_complete_ops_per_sec', 'batch_submit_lat_sum_us', 'batch_completion_lat_sum_us', 'last_batch_read_bytes', 'last_batch_write_bytes'], 

1503 'formats': [op_counter_dtype, op_counter_dtype, op_counter_dtype, op_counter_dtype, op_counter_dtype, op_counter_dtype, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, op_counter_dtype, op_counter_dtype, op_counter_dtype, op_counter_dtype, op_counter_dtype, op_counter_dtype, op_counter_dtype, op_counter_dtype, op_counter_dtype, op_counter_dtype, op_counter_dtype, op_counter_dtype, op_counter_dtype, op_counter_dtype, op_counter_dtype, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint64], 

1504 'offsets': [ 

1505 (<intptr_t>&(pod.read_ops)) - (<intptr_t>&pod), 

1506 (<intptr_t>&(pod.write_ops)) - (<intptr_t>&pod), 

1507 (<intptr_t>&(pod.hdl_register_ops)) - (<intptr_t>&pod), 

1508 (<intptr_t>&(pod.hdl_deregister_ops)) - (<intptr_t>&pod), 

1509 (<intptr_t>&(pod.buf_register_ops)) - (<intptr_t>&pod), 

1510 (<intptr_t>&(pod.buf_deregister_ops)) - (<intptr_t>&pod), 

1511 (<intptr_t>&(pod.read_bytes)) - (<intptr_t>&pod), 

1512 (<intptr_t>&(pod.write_bytes)) - (<intptr_t>&pod), 

1513 (<intptr_t>&(pod.read_bw_bytes_per_sec)) - (<intptr_t>&pod), 

1514 (<intptr_t>&(pod.write_bw_bytes_per_sec)) - (<intptr_t>&pod), 

1515 (<intptr_t>&(pod.read_lat_avg_us)) - (<intptr_t>&pod), 

1516 (<intptr_t>&(pod.write_lat_avg_us)) - (<intptr_t>&pod), 

1517 (<intptr_t>&(pod.read_ops_per_sec)) - (<intptr_t>&pod), 

1518 (<intptr_t>&(pod.write_ops_per_sec)) - (<intptr_t>&pod), 

1519 (<intptr_t>&(pod.read_lat_sum_us)) - (<intptr_t>&pod), 

1520 (<intptr_t>&(pod.write_lat_sum_us)) - (<intptr_t>&pod), 

1521 (<intptr_t>&(pod.batch_submit_ops)) - (<intptr_t>&pod), 

1522 (<intptr_t>&(pod.batch_complete_ops)) - (<intptr_t>&pod), 

1523 (<intptr_t>&(pod.batch_setup_ops)) - (<intptr_t>&pod), 

1524 (<intptr_t>&(pod.batch_cancel_ops)) - (<intptr_t>&pod), 

1525 (<intptr_t>&(pod.batch_destroy_ops)) - (<intptr_t>&pod), 

1526 (<intptr_t>&(pod.batch_enqueued_ops)) - (<intptr_t>&pod), 

1527 (<intptr_t>&(pod.batch_posix_enqueued_ops)) - (<intptr_t>&pod), 

1528 (<intptr_t>&(pod.batch_processed_ops)) - (<intptr_t>&pod), 

1529 (<intptr_t>&(pod.batch_posix_processed_ops)) - (<intptr_t>&pod), 

1530 (<intptr_t>&(pod.batch_nvfs_submit_ops)) - (<intptr_t>&pod), 

1531 (<intptr_t>&(pod.batch_p2p_submit_ops)) - (<intptr_t>&pod), 

1532 (<intptr_t>&(pod.batch_aio_submit_ops)) - (<intptr_t>&pod), 

1533 (<intptr_t>&(pod.batch_iouring_submit_ops)) - (<intptr_t>&pod), 

1534 (<intptr_t>&(pod.batch_mixed_io_submit_ops)) - (<intptr_t>&pod), 

1535 (<intptr_t>&(pod.batch_total_submit_ops)) - (<intptr_t>&pod), 

1536 (<intptr_t>&(pod.batch_read_bytes)) - (<intptr_t>&pod), 

1537 (<intptr_t>&(pod.batch_write_bytes)) - (<intptr_t>&pod), 

1538 (<intptr_t>&(pod.batch_read_bw_bytes)) - (<intptr_t>&pod), 

1539 (<intptr_t>&(pod.batch_write_bw_bytes)) - (<intptr_t>&pod), 

1540 (<intptr_t>&(pod.batch_submit_lat_avg_us)) - (<intptr_t>&pod), 

1541 (<intptr_t>&(pod.batch_completion_lat_avg_us)) - (<intptr_t>&pod), 

1542 (<intptr_t>&(pod.batch_submit_ops_per_sec)) - (<intptr_t>&pod), 

1543 (<intptr_t>&(pod.batch_complete_ops_per_sec)) - (<intptr_t>&pod), 

1544 (<intptr_t>&(pod.batch_submit_lat_sum_us)) - (<intptr_t>&pod), 

1545 (<intptr_t>&(pod.batch_completion_lat_sum_us)) - (<intptr_t>&pod), 

1546 (<intptr_t>&(pod.last_batch_read_bytes)) - (<intptr_t>&pod), 

1547 (<intptr_t>&(pod.last_batch_write_bytes)) - (<intptr_t>&pod), 

1548 ], 

1549 'itemsize': sizeof(CUfileStatsLevel1_t), 

1550 }) 

1551  

1552stats_level1_dtype = _get_stats_level1_dtype_offsets() 

1553  

1554cdef class StatsLevel1: 

1555 """Empty-initialize an instance of `CUfileStatsLevel1_t`. 

1556  

1557  

1558 .. seealso:: `CUfileStatsLevel1_t` 

1559 """ 

1560 cdef: 

1561 CUfileStatsLevel1_t *_ptr 

1562 object _owner 

1563 bint _owned 

1564 bint _readonly 

1565  

1566 def __init__(self): 

1567 self._ptr = <CUfileStatsLevel1_t *>_cyb_calloc(1, sizeof(CUfileStatsLevel1_t)) 1e

1568 if self._ptr == NULL: 1e

1569 raise MemoryError("Error allocating StatsLevel1") 

1570 self._owner = None 1e

1571 self._owned = True 1e

1572 self._readonly = False 1e

1573  

1574 def __dealloc__(self): 

1575 cdef CUfileStatsLevel1_t *ptr 

1576 if self._owned and self._ptr != NULL: 1ec

1577 ptr = self._ptr 1e

1578 self._ptr = NULL 1e

1579 _cyb_free(ptr) 1e

1580  

1581 def __repr__(self): 

1582 return f"<{__name__}.StatsLevel1 object at {hex(id(self))}>" 

1583  

1584 @property 

1585 def ptr(self): 

1586 """Get the pointer address to the data as Python :class:`int`.""" 

1587 return <intptr_t>(self._ptr) 1e

1588  

1589 cdef intptr_t _get_ptr(self): 

1590 return <intptr_t>(self._ptr) 

1591  

1592 def __int__(self): 

1593 return <intptr_t>(self._ptr) 

1594  

1595 def __eq__(self, other): 

1596 cdef StatsLevel1 other_ 

1597 if not isinstance(other, StatsLevel1): 

1598 return False 

1599 other_ = other 

1600 return (_cyb_memcmp(<void *><intptr_t>(self._ptr), <void *><intptr_t>(other_._ptr), sizeof(CUfileStatsLevel1_t)) == 0) 

1601  

1602 def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): 

1603 _cyb___getbuffer(self, buffer, <void *>self._ptr, sizeof(CUfileStatsLevel1_t), self._readonly) 

1604  

1605 def __releasebuffer__(self, Py_buffer *buffer): 

1606 pass 

1607  

1608 def __setitem__(self, key, val): 

1609 if key == 0 and isinstance(val, _numpy.ndarray): 

1610 self._ptr = <CUfileStatsLevel1_t *>_cyb_malloc(sizeof(CUfileStatsLevel1_t)) 

1611 if self._ptr == NULL: 

1612 raise MemoryError("Error allocating StatsLevel1") 

1613 _cyb_memcpy(<void*>self._ptr, <void*><intptr_t>val.ctypes.data, sizeof(CUfileStatsLevel1_t)) 

1614 self._owner = None 

1615 self._owned = True 

1616 self._readonly = not val.flags.writeable 

1617 else: 

1618 setattr(self, key, val) 

1619  

1620 @property 

1621 def read_ops(self): 

1622 """OpCounter: """ 

1623 return OpCounter.from_ptr( 1ec

1624 <intptr_t>&(self._ptr[0].read_ops), 1ec

1625 readonly=self._readonly, 1ec

1626 owner=self, 1ec

1627 ) 

1628  

1629 @read_ops.setter 

1630 def read_ops(self, val): 

1631 if self._readonly: 

1632 raise ValueError("This StatsLevel1 instance is read-only") 

1633 cdef OpCounter val_ = val 

1634 _cyb_memcpy(<void *>&(self._ptr[0].read_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1) 

1635  

1636 @property 

1637 def write_ops(self): 

1638 """OpCounter: """ 

1639 return OpCounter.from_ptr( 1ec

1640 <intptr_t>&(self._ptr[0].write_ops), 1ec

1641 readonly=self._readonly, 1ec

1642 owner=self, 1ec

1643 ) 

1644  

1645 @write_ops.setter 

1646 def write_ops(self, val): 

1647 if self._readonly: 

1648 raise ValueError("This StatsLevel1 instance is read-only") 

1649 cdef OpCounter val_ = val 

1650 _cyb_memcpy(<void *>&(self._ptr[0].write_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1) 

1651  

1652 @property 

1653 def hdl_register_ops(self): 

1654 """OpCounter: """ 

1655 return OpCounter.from_ptr( 

1656 <intptr_t>&(self._ptr[0].hdl_register_ops), 

1657 readonly=self._readonly, 

1658 owner=self, 

1659 ) 

1660  

1661 @hdl_register_ops.setter 

1662 def hdl_register_ops(self, val): 

1663 if self._readonly: 

1664 raise ValueError("This StatsLevel1 instance is read-only") 

1665 cdef OpCounter val_ = val 

1666 _cyb_memcpy(<void *>&(self._ptr[0].hdl_register_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1) 

1667  

1668 @property 

1669 def hdl_deregister_ops(self): 

1670 """OpCounter: """ 

1671 return OpCounter.from_ptr( 

1672 <intptr_t>&(self._ptr[0].hdl_deregister_ops), 

1673 readonly=self._readonly, 

1674 owner=self, 

1675 ) 

1676  

1677 @hdl_deregister_ops.setter 

1678 def hdl_deregister_ops(self, val): 

1679 if self._readonly: 

1680 raise ValueError("This StatsLevel1 instance is read-only") 

1681 cdef OpCounter val_ = val 

1682 _cyb_memcpy(<void *>&(self._ptr[0].hdl_deregister_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1) 

1683  

1684 @property 

1685 def buf_register_ops(self): 

1686 """OpCounter: """ 

1687 return OpCounter.from_ptr( 

1688 <intptr_t>&(self._ptr[0].buf_register_ops), 

1689 readonly=self._readonly, 

1690 owner=self, 

1691 ) 

1692  

1693 @buf_register_ops.setter 

1694 def buf_register_ops(self, val): 

1695 if self._readonly: 

1696 raise ValueError("This StatsLevel1 instance is read-only") 

1697 cdef OpCounter val_ = val 

1698 _cyb_memcpy(<void *>&(self._ptr[0].buf_register_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1) 

1699  

1700 @property 

1701 def buf_deregister_ops(self): 

1702 """OpCounter: """ 

1703 return OpCounter.from_ptr( 

1704 <intptr_t>&(self._ptr[0].buf_deregister_ops), 

1705 readonly=self._readonly, 

1706 owner=self, 

1707 ) 

1708  

1709 @buf_deregister_ops.setter 

1710 def buf_deregister_ops(self, val): 

1711 if self._readonly: 

1712 raise ValueError("This StatsLevel1 instance is read-only") 

1713 cdef OpCounter val_ = val 

1714 _cyb_memcpy(<void *>&(self._ptr[0].buf_deregister_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1) 

1715  

1716 @property 

1717 def batch_submit_ops(self): 

1718 """OpCounter: """ 

1719 return OpCounter.from_ptr( 

1720 <intptr_t>&(self._ptr[0].batch_submit_ops), 

1721 readonly=self._readonly, 

1722 owner=self, 

1723 ) 

1724  

1725 @batch_submit_ops.setter 

1726 def batch_submit_ops(self, val): 

1727 if self._readonly: 

1728 raise ValueError("This StatsLevel1 instance is read-only") 

1729 cdef OpCounter val_ = val 

1730 _cyb_memcpy(<void *>&(self._ptr[0].batch_submit_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1) 

1731  

1732 @property 

1733 def batch_complete_ops(self): 

1734 """OpCounter: """ 

1735 return OpCounter.from_ptr( 

1736 <intptr_t>&(self._ptr[0].batch_complete_ops), 

1737 readonly=self._readonly, 

1738 owner=self, 

1739 ) 

1740  

1741 @batch_complete_ops.setter 

1742 def batch_complete_ops(self, val): 

1743 if self._readonly: 

1744 raise ValueError("This StatsLevel1 instance is read-only") 

1745 cdef OpCounter val_ = val 

1746 _cyb_memcpy(<void *>&(self._ptr[0].batch_complete_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1) 

1747  

1748 @property 

1749 def batch_setup_ops(self): 

1750 """OpCounter: """ 

1751 return OpCounter.from_ptr( 

1752 <intptr_t>&(self._ptr[0].batch_setup_ops), 

1753 readonly=self._readonly, 

1754 owner=self, 

1755 ) 

1756  

1757 @batch_setup_ops.setter 

1758 def batch_setup_ops(self, val): 

1759 if self._readonly: 

1760 raise ValueError("This StatsLevel1 instance is read-only") 

1761 cdef OpCounter val_ = val 

1762 _cyb_memcpy(<void *>&(self._ptr[0].batch_setup_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1) 

1763  

1764 @property 

1765 def batch_cancel_ops(self): 

1766 """OpCounter: """ 

1767 return OpCounter.from_ptr( 

1768 <intptr_t>&(self._ptr[0].batch_cancel_ops), 

1769 readonly=self._readonly, 

1770 owner=self, 

1771 ) 

1772  

1773 @batch_cancel_ops.setter 

1774 def batch_cancel_ops(self, val): 

1775 if self._readonly: 

1776 raise ValueError("This StatsLevel1 instance is read-only") 

1777 cdef OpCounter val_ = val 

1778 _cyb_memcpy(<void *>&(self._ptr[0].batch_cancel_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1) 

1779  

1780 @property 

1781 def batch_destroy_ops(self): 

1782 """OpCounter: """ 

1783 return OpCounter.from_ptr( 

1784 <intptr_t>&(self._ptr[0].batch_destroy_ops), 

1785 readonly=self._readonly, 

1786 owner=self, 

1787 ) 

1788  

1789 @batch_destroy_ops.setter 

1790 def batch_destroy_ops(self, val): 

1791 if self._readonly: 

1792 raise ValueError("This StatsLevel1 instance is read-only") 

1793 cdef OpCounter val_ = val 

1794 _cyb_memcpy(<void *>&(self._ptr[0].batch_destroy_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1) 

1795  

1796 @property 

1797 def batch_enqueued_ops(self): 

1798 """OpCounter: """ 

1799 return OpCounter.from_ptr( 

1800 <intptr_t>&(self._ptr[0].batch_enqueued_ops), 

1801 readonly=self._readonly, 

1802 owner=self, 

1803 ) 

1804  

1805 @batch_enqueued_ops.setter 

1806 def batch_enqueued_ops(self, val): 

1807 if self._readonly: 

1808 raise ValueError("This StatsLevel1 instance is read-only") 

1809 cdef OpCounter val_ = val 

1810 _cyb_memcpy(<void *>&(self._ptr[0].batch_enqueued_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1) 

1811  

1812 @property 

1813 def batch_posix_enqueued_ops(self): 

1814 """OpCounter: """ 

1815 return OpCounter.from_ptr( 

1816 <intptr_t>&(self._ptr[0].batch_posix_enqueued_ops), 

1817 readonly=self._readonly, 

1818 owner=self, 

1819 ) 

1820  

1821 @batch_posix_enqueued_ops.setter 

1822 def batch_posix_enqueued_ops(self, val): 

1823 if self._readonly: 

1824 raise ValueError("This StatsLevel1 instance is read-only") 

1825 cdef OpCounter val_ = val 

1826 _cyb_memcpy(<void *>&(self._ptr[0].batch_posix_enqueued_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1) 

1827  

1828 @property 

1829 def batch_processed_ops(self): 

1830 """OpCounter: """ 

1831 return OpCounter.from_ptr( 

1832 <intptr_t>&(self._ptr[0].batch_processed_ops), 

1833 readonly=self._readonly, 

1834 owner=self, 

1835 ) 

1836  

1837 @batch_processed_ops.setter 

1838 def batch_processed_ops(self, val): 

1839 if self._readonly: 

1840 raise ValueError("This StatsLevel1 instance is read-only") 

1841 cdef OpCounter val_ = val 

1842 _cyb_memcpy(<void *>&(self._ptr[0].batch_processed_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1) 

1843  

1844 @property 

1845 def batch_posix_processed_ops(self): 

1846 """OpCounter: """ 

1847 return OpCounter.from_ptr( 

1848 <intptr_t>&(self._ptr[0].batch_posix_processed_ops), 

1849 readonly=self._readonly, 

1850 owner=self, 

1851 ) 

1852  

1853 @batch_posix_processed_ops.setter 

1854 def batch_posix_processed_ops(self, val): 

1855 if self._readonly: 

1856 raise ValueError("This StatsLevel1 instance is read-only") 

1857 cdef OpCounter val_ = val 

1858 _cyb_memcpy(<void *>&(self._ptr[0].batch_posix_processed_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1) 

1859  

1860 @property 

1861 def batch_nvfs_submit_ops(self): 

1862 """OpCounter: """ 

1863 return OpCounter.from_ptr( 

1864 <intptr_t>&(self._ptr[0].batch_nvfs_submit_ops), 

1865 readonly=self._readonly, 

1866 owner=self, 

1867 ) 

1868  

1869 @batch_nvfs_submit_ops.setter 

1870 def batch_nvfs_submit_ops(self, val): 

1871 if self._readonly: 

1872 raise ValueError("This StatsLevel1 instance is read-only") 

1873 cdef OpCounter val_ = val 

1874 _cyb_memcpy(<void *>&(self._ptr[0].batch_nvfs_submit_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1) 

1875  

1876 @property 

1877 def batch_p2p_submit_ops(self): 

1878 """OpCounter: """ 

1879 return OpCounter.from_ptr( 

1880 <intptr_t>&(self._ptr[0].batch_p2p_submit_ops), 

1881 readonly=self._readonly, 

1882 owner=self, 

1883 ) 

1884  

1885 @batch_p2p_submit_ops.setter 

1886 def batch_p2p_submit_ops(self, val): 

1887 if self._readonly: 

1888 raise ValueError("This StatsLevel1 instance is read-only") 

1889 cdef OpCounter val_ = val 

1890 _cyb_memcpy(<void *>&(self._ptr[0].batch_p2p_submit_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1) 

1891  

1892 @property 

1893 def batch_aio_submit_ops(self): 

1894 """OpCounter: """ 

1895 return OpCounter.from_ptr( 

1896 <intptr_t>&(self._ptr[0].batch_aio_submit_ops), 

1897 readonly=self._readonly, 

1898 owner=self, 

1899 ) 

1900  

1901 @batch_aio_submit_ops.setter 

1902 def batch_aio_submit_ops(self, val): 

1903 if self._readonly: 

1904 raise ValueError("This StatsLevel1 instance is read-only") 

1905 cdef OpCounter val_ = val 

1906 _cyb_memcpy(<void *>&(self._ptr[0].batch_aio_submit_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1) 

1907  

1908 @property 

1909 def batch_iouring_submit_ops(self): 

1910 """OpCounter: """ 

1911 return OpCounter.from_ptr( 

1912 <intptr_t>&(self._ptr[0].batch_iouring_submit_ops), 

1913 readonly=self._readonly, 

1914 owner=self, 

1915 ) 

1916  

1917 @batch_iouring_submit_ops.setter 

1918 def batch_iouring_submit_ops(self, val): 

1919 if self._readonly: 

1920 raise ValueError("This StatsLevel1 instance is read-only") 

1921 cdef OpCounter val_ = val 

1922 _cyb_memcpy(<void *>&(self._ptr[0].batch_iouring_submit_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1) 

1923  

1924 @property 

1925 def batch_mixed_io_submit_ops(self): 

1926 """OpCounter: """ 

1927 return OpCounter.from_ptr( 

1928 <intptr_t>&(self._ptr[0].batch_mixed_io_submit_ops), 

1929 readonly=self._readonly, 

1930 owner=self, 

1931 ) 

1932  

1933 @batch_mixed_io_submit_ops.setter 

1934 def batch_mixed_io_submit_ops(self, val): 

1935 if self._readonly: 

1936 raise ValueError("This StatsLevel1 instance is read-only") 

1937 cdef OpCounter val_ = val 

1938 _cyb_memcpy(<void *>&(self._ptr[0].batch_mixed_io_submit_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1) 

1939  

1940 @property 

1941 def batch_total_submit_ops(self): 

1942 """OpCounter: """ 

1943 return OpCounter.from_ptr( 

1944 <intptr_t>&(self._ptr[0].batch_total_submit_ops), 

1945 readonly=self._readonly, 

1946 owner=self, 

1947 ) 

1948  

1949 @batch_total_submit_ops.setter 

1950 def batch_total_submit_ops(self, val): 

1951 if self._readonly: 

1952 raise ValueError("This StatsLevel1 instance is read-only") 

1953 cdef OpCounter val_ = val 

1954 _cyb_memcpy(<void *>&(self._ptr[0].batch_total_submit_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1) 

1955  

1956 @property 

1957 def read_bytes(self): 

1958 """int: """ 

1959 return self._ptr[0].read_bytes 1e

1960  

1961 @read_bytes.setter 

1962 def read_bytes(self, val): 

1963 if self._readonly: 

1964 raise ValueError("This StatsLevel1 instance is read-only") 

1965 self._ptr[0].read_bytes = val 

1966  

1967 @property 

1968 def write_bytes(self): 

1969 """int: """ 

1970 return self._ptr[0].write_bytes 1e

1971  

1972 @write_bytes.setter 

1973 def write_bytes(self, val): 

1974 if self._readonly: 

1975 raise ValueError("This StatsLevel1 instance is read-only") 

1976 self._ptr[0].write_bytes = val 

1977  

1978 @property 

1979 def read_bw_bytes_per_sec(self): 

1980 """int: """ 

1981 return self._ptr[0].read_bw_bytes_per_sec 

1982  

1983 @read_bw_bytes_per_sec.setter 

1984 def read_bw_bytes_per_sec(self, val): 

1985 if self._readonly: 

1986 raise ValueError("This StatsLevel1 instance is read-only") 

1987 self._ptr[0].read_bw_bytes_per_sec = val 

1988  

1989 @property 

1990 def write_bw_bytes_per_sec(self): 

1991 """int: """ 

1992 return self._ptr[0].write_bw_bytes_per_sec 

1993  

1994 @write_bw_bytes_per_sec.setter 

1995 def write_bw_bytes_per_sec(self, val): 

1996 if self._readonly: 

1997 raise ValueError("This StatsLevel1 instance is read-only") 

1998 self._ptr[0].write_bw_bytes_per_sec = val 

1999  

2000 @property 

2001 def read_lat_avg_us(self): 

2002 """int: """ 

2003 return self._ptr[0].read_lat_avg_us 

2004  

2005 @read_lat_avg_us.setter 

2006 def read_lat_avg_us(self, val): 

2007 if self._readonly: 

2008 raise ValueError("This StatsLevel1 instance is read-only") 

2009 self._ptr[0].read_lat_avg_us = val 

2010  

2011 @property 

2012 def write_lat_avg_us(self): 

2013 """int: """ 

2014 return self._ptr[0].write_lat_avg_us 

2015  

2016 @write_lat_avg_us.setter 

2017 def write_lat_avg_us(self, val): 

2018 if self._readonly: 

2019 raise ValueError("This StatsLevel1 instance is read-only") 

2020 self._ptr[0].write_lat_avg_us = val 

2021  

2022 @property 

2023 def read_ops_per_sec(self): 

2024 """int: """ 

2025 return self._ptr[0].read_ops_per_sec 

2026  

2027 @read_ops_per_sec.setter 

2028 def read_ops_per_sec(self, val): 

2029 if self._readonly: 

2030 raise ValueError("This StatsLevel1 instance is read-only") 

2031 self._ptr[0].read_ops_per_sec = val 

2032  

2033 @property 

2034 def write_ops_per_sec(self): 

2035 """int: """ 

2036 return self._ptr[0].write_ops_per_sec 

2037  

2038 @write_ops_per_sec.setter 

2039 def write_ops_per_sec(self, val): 

2040 if self._readonly: 

2041 raise ValueError("This StatsLevel1 instance is read-only") 

2042 self._ptr[0].write_ops_per_sec = val 

2043  

2044 @property 

2045 def read_lat_sum_us(self): 

2046 """int: """ 

2047 return self._ptr[0].read_lat_sum_us 

2048  

2049 @read_lat_sum_us.setter 

2050 def read_lat_sum_us(self, val): 

2051 if self._readonly: 

2052 raise ValueError("This StatsLevel1 instance is read-only") 

2053 self._ptr[0].read_lat_sum_us = val 

2054  

2055 @property 

2056 def write_lat_sum_us(self): 

2057 """int: """ 

2058 return self._ptr[0].write_lat_sum_us 

2059  

2060 @write_lat_sum_us.setter 

2061 def write_lat_sum_us(self, val): 

2062 if self._readonly: 

2063 raise ValueError("This StatsLevel1 instance is read-only") 

2064 self._ptr[0].write_lat_sum_us = val 

2065  

2066 @property 

2067 def batch_read_bytes(self): 

2068 """int: """ 

2069 return self._ptr[0].batch_read_bytes 

2070  

2071 @batch_read_bytes.setter 

2072 def batch_read_bytes(self, val): 

2073 if self._readonly: 

2074 raise ValueError("This StatsLevel1 instance is read-only") 

2075 self._ptr[0].batch_read_bytes = val 

2076  

2077 @property 

2078 def batch_write_bytes(self): 

2079 """int: """ 

2080 return self._ptr[0].batch_write_bytes 

2081  

2082 @batch_write_bytes.setter 

2083 def batch_write_bytes(self, val): 

2084 if self._readonly: 

2085 raise ValueError("This StatsLevel1 instance is read-only") 

2086 self._ptr[0].batch_write_bytes = val 

2087  

2088 @property 

2089 def batch_read_bw_bytes(self): 

2090 """int: """ 

2091 return self._ptr[0].batch_read_bw_bytes 

2092  

2093 @batch_read_bw_bytes.setter 

2094 def batch_read_bw_bytes(self, val): 

2095 if self._readonly: 

2096 raise ValueError("This StatsLevel1 instance is read-only") 

2097 self._ptr[0].batch_read_bw_bytes = val 

2098  

2099 @property 

2100 def batch_write_bw_bytes(self): 

2101 """int: """ 

2102 return self._ptr[0].batch_write_bw_bytes 

2103  

2104 @batch_write_bw_bytes.setter 

2105 def batch_write_bw_bytes(self, val): 

2106 if self._readonly: 

2107 raise ValueError("This StatsLevel1 instance is read-only") 

2108 self._ptr[0].batch_write_bw_bytes = val 

2109  

2110 @property 

2111 def batch_submit_lat_avg_us(self): 

2112 """int: """ 

2113 return self._ptr[0].batch_submit_lat_avg_us 

2114  

2115 @batch_submit_lat_avg_us.setter 

2116 def batch_submit_lat_avg_us(self, val): 

2117 if self._readonly: 

2118 raise ValueError("This StatsLevel1 instance is read-only") 

2119 self._ptr[0].batch_submit_lat_avg_us = val 

2120  

2121 @property 

2122 def batch_completion_lat_avg_us(self): 

2123 """int: """ 

2124 return self._ptr[0].batch_completion_lat_avg_us 

2125  

2126 @batch_completion_lat_avg_us.setter 

2127 def batch_completion_lat_avg_us(self, val): 

2128 if self._readonly: 

2129 raise ValueError("This StatsLevel1 instance is read-only") 

2130 self._ptr[0].batch_completion_lat_avg_us = val 

2131  

2132 @property 

2133 def batch_submit_ops_per_sec(self): 

2134 """int: """ 

2135 return self._ptr[0].batch_submit_ops_per_sec 

2136  

2137 @batch_submit_ops_per_sec.setter 

2138 def batch_submit_ops_per_sec(self, val): 

2139 if self._readonly: 

2140 raise ValueError("This StatsLevel1 instance is read-only") 

2141 self._ptr[0].batch_submit_ops_per_sec = val 

2142  

2143 @property 

2144 def batch_complete_ops_per_sec(self): 

2145 """int: """ 

2146 return self._ptr[0].batch_complete_ops_per_sec 

2147  

2148 @batch_complete_ops_per_sec.setter 

2149 def batch_complete_ops_per_sec(self, val): 

2150 if self._readonly: 

2151 raise ValueError("This StatsLevel1 instance is read-only") 

2152 self._ptr[0].batch_complete_ops_per_sec = val 

2153  

2154 @property 

2155 def batch_submit_lat_sum_us(self): 

2156 """int: """ 

2157 return self._ptr[0].batch_submit_lat_sum_us 

2158  

2159 @batch_submit_lat_sum_us.setter 

2160 def batch_submit_lat_sum_us(self, val): 

2161 if self._readonly: 

2162 raise ValueError("This StatsLevel1 instance is read-only") 

2163 self._ptr[0].batch_submit_lat_sum_us = val 

2164  

2165 @property 

2166 def batch_completion_lat_sum_us(self): 

2167 """int: """ 

2168 return self._ptr[0].batch_completion_lat_sum_us 

2169  

2170 @batch_completion_lat_sum_us.setter 

2171 def batch_completion_lat_sum_us(self, val): 

2172 if self._readonly: 

2173 raise ValueError("This StatsLevel1 instance is read-only") 

2174 self._ptr[0].batch_completion_lat_sum_us = val 

2175  

2176 @property 

2177 def last_batch_read_bytes(self): 

2178 """int: """ 

2179 return self._ptr[0].last_batch_read_bytes 

2180  

2181 @last_batch_read_bytes.setter 

2182 def last_batch_read_bytes(self, val): 

2183 if self._readonly: 

2184 raise ValueError("This StatsLevel1 instance is read-only") 

2185 self._ptr[0].last_batch_read_bytes = val 

2186  

2187 @property 

2188 def last_batch_write_bytes(self): 

2189 """int: """ 

2190 return self._ptr[0].last_batch_write_bytes 

2191  

2192 @last_batch_write_bytes.setter 

2193 def last_batch_write_bytes(self, val): 

2194 if self._readonly: 

2195 raise ValueError("This StatsLevel1 instance is read-only") 

2196 self._ptr[0].last_batch_write_bytes = val 

2197  

2198 @staticmethod 

2199 def from_buffer(buffer): 

2200 """Create an StatsLevel1 instance with the memory from the given buffer.""" 

2201 return _cyb_from_buffer(buffer, sizeof(CUfileStatsLevel1_t), StatsLevel1) 

2202  

2203 @staticmethod 

2204 def from_data(data): 

2205 """Create an StatsLevel1 instance wrapping the given NumPy array. 

2206  

2207 Args: 

2208 data (_numpy.ndarray): a single-element array of dtype `stats_level1_dtype` holding the data. 

2209 """ 

2210 return _cyb_from_data(data, "stats_level1_dtype", stats_level1_dtype, StatsLevel1) 1c

2211  

2212 @staticmethod 

2213 def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): 

2214 """Create an StatsLevel1 instance wrapping the given pointer. 

2215  

2216 Args: 

2217 ptr (intptr_t): pointer address as Python :class:`int` to the data. 

2218 owner (object): The Python object that owns the pointer. If not provided, data will be copied. 

2219 readonly (bool): whether the data is read-only (to the user). default is `False`. 

2220 """ 

2221 if ptr == 0: 1c

2222 raise ValueError("ptr must not be null (0)") 

2223 cdef StatsLevel1 obj = StatsLevel1.__new__(StatsLevel1) 1c

2224 if owner is None: 1c

2225 obj._ptr = <CUfileStatsLevel1_t *>_cyb_malloc(sizeof(CUfileStatsLevel1_t)) 

2226 if obj._ptr == NULL: 

2227 raise MemoryError("Error allocating StatsLevel1") 

2228 _cyb_memcpy(<void*>(obj._ptr), <void*>ptr, sizeof(CUfileStatsLevel1_t)) 

2229 obj._owner = None 

2230 obj._owned = True 

2231 else: 

2232 obj._ptr = <CUfileStatsLevel1_t *>ptr 1c

2233 obj._owner = owner 1c

2234 obj._owned = False 1c

2235 obj._readonly = readonly 1c

2236 return obj 1c

2237  

2238  

2239cdef _get_io_params_dtype_offsets(): 

2240 cdef CUfileIOParams_t pod 

2241 return _numpy.dtype({ 

2242 'names': ['mode', 'u', 'fh', 'opcode', 'cookie'], 

2243 'formats': [_numpy.int32, _py_anon_pod2_dtype, _numpy.intp, _numpy.int32, _numpy.intp], 

2244 'offsets': [ 

2245 (<intptr_t>&(pod.mode)) - (<intptr_t>&pod), 

2246 (<intptr_t>&(pod.u)) - (<intptr_t>&pod), 

2247 (<intptr_t>&(pod.fh)) - (<intptr_t>&pod), 

2248 (<intptr_t>&(pod.opcode)) - (<intptr_t>&pod), 

2249 (<intptr_t>&(pod.cookie)) - (<intptr_t>&pod), 

2250 ], 

2251 'itemsize': sizeof(CUfileIOParams_t), 

2252 }) 

2253  

2254io_params_dtype = _get_io_params_dtype_offsets() 

2255  

2256cdef class IOParams: 

2257 """Empty-initialize an array of `CUfileIOParams_t`. 

2258 The resulting object is of length `size` and of dtype `io_params_dtype`. 

2259 If default-constructed, the instance represents a single struct. 

2260  

2261 Args: 

2262 size (int): number of structs, default=1. 

2263  

2264 .. seealso:: `CUfileIOParams_t` 

2265 """ 

2266 cdef: 

2267 readonly object _data 

2268 object _owner 

2269  

2270 def __init__(self, size=1): 

2271 arr = _numpy.empty(size, dtype=io_params_dtype) 1dgf

2272 self._data = arr.view(_numpy.recarray) 1dgf

2273 assert self._data.itemsize == sizeof(CUfileIOParams_t), \ 1dgf

2274 f"itemsize {self._data.itemsize} mismatches struct size { sizeof(CUfileIOParams_t) }" 

2275  

2276 def __repr__(self): 

2277 if self._data.size > 1: 

2278 return f"<{__name__}.IOParams_Array_{self._data.size} object at {hex(id(self))}>" 

2279 else: 

2280 return f"<{__name__}.IOParams object at {hex(id(self))}>" 

2281  

2282 @property 

2283 def ptr(self): 

2284 """Get the pointer address to the data as Python :class:`int`.""" 

2285 return self._data.ctypes.data 1dgf

2286  

2287 cdef intptr_t _get_ptr(self): 

2288 return self._data.ctypes.data 

2289  

2290 def __int__(self): 

2291 if self._data.size > 1: 

2292 raise TypeError("int() argument must be a bytes-like object of size 1. " 

2293 "To get the pointer address of an array, use .ptr") 

2294 return self._data.ctypes.data 

2295  

2296 def __len__(self): 

2297 return self._data.size 

2298  

2299 def __eq__(self, other): 

2300 cdef object self_data = self._data 

2301 if (not isinstance(other, IOParams)) or self_data.size != other._data.size or self_data.dtype != other._data.dtype: 

2302 return False 

2303 return bool((self_data == other._data).all()) 

2304  

2305 def __getbuffer__(self, Py_buffer *buffer, int flags): 

2306 _cyb_cpython.PyObject_GetBuffer(self._data, buffer, flags) 

2307  

2308 def __releasebuffer__(self, Py_buffer *buffer): 

2309 _cyb_cpython.PyBuffer_Release(buffer) 

2310  

2311 @property 

2312 def mode(self): 

2313 """Union[~_numpy.int32, int]: """ 

2314 if self._data.size == 1: 

2315 return int(self._data.mode[0]) 

2316 return self._data.mode 

2317  

2318 @mode.setter 

2319 def mode(self, val): 

2320 self._data.mode = val 1dgf

2321  

2322 @property 

2323 def u(self): 

2324 """_py_anon_pod2_dtype: """ 

2325 return self._data.u 1dgf

2326  

2327 @u.setter 

2328 def u(self, val): 

2329 self._data.u = val 

2330  

2331 @property 

2332 def fh(self): 

2333 """Union[~_numpy.intp, int]: """ 

2334 if self._data.size == 1: 

2335 return int(self._data.fh[0]) 

2336 return self._data.fh 

2337  

2338 @fh.setter 

2339 def fh(self, val): 

2340 self._data.fh = val 1dgf

2341  

2342 @property 

2343 def opcode(self): 

2344 """Union[~_numpy.int32, int]: """ 

2345 if self._data.size == 1: 

2346 return int(self._data.opcode[0]) 

2347 return self._data.opcode 

2348  

2349 @opcode.setter 

2350 def opcode(self, val): 

2351 self._data.opcode = val 1dgf

2352  

2353 @property 

2354 def cookie(self): 

2355 """Union[~_numpy.intp, int]: """ 

2356 if self._data.size == 1: 

2357 return int(self._data.cookie[0]) 

2358 return self._data.cookie 

2359  

2360 @cookie.setter 

2361 def cookie(self, val): 

2362 self._data.cookie = val 1dgf

2363  

2364 def __getitem__(self, key): 

2365 cdef ssize_t key_ 

2366 cdef ssize_t size 

2367 if isinstance(key, int): 1dgf

2368 key_ = key 1dgf

2369 size = self._data.size 1dgf

2370 if key_ >= size or key_ <= -(size+1): 1dgf

2371 raise IndexError("index is out of bounds") 

2372 if key_ < 0: 1dgf

2373 key_ += size 

2374 return IOParams.from_data(self._data[key_:key_+1]) 1dgf

2375 out = self._data[key] 

2376 if isinstance(out, _numpy.recarray) and out.dtype == io_params_dtype: 

2377 return IOParams.from_data(out) 

2378 return out 

2379  

2380 def __setitem__(self, key, val): 

2381 self._data[key] = val 

2382  

2383 @staticmethod 

2384 def from_buffer(buffer): 

2385 """Create an IOParams instance with the memory from the given buffer.""" 

2386 return IOParams.from_data(_numpy.frombuffer(buffer, dtype=io_params_dtype)) 

2387  

2388 @staticmethod 

2389 def from_data(data): 

2390 """Create an IOParams instance wrapping the given NumPy array. 

2391  

2392 Args: 

2393 data (_numpy.ndarray): a 1D array of dtype `io_params_dtype` holding the data. 

2394 """ 

2395 cdef IOParams obj = IOParams.__new__(IOParams) 1dgf

2396 if not isinstance(data, _numpy.ndarray): 1dgf

2397 raise TypeError("data argument must be a NumPy ndarray") 

2398 if data.ndim != 1: 1dgf

2399 raise ValueError("data array must be 1D") 

2400 if data.dtype != io_params_dtype: 1dgf

2401 raise ValueError("data array must be of dtype io_params_dtype") 

2402 obj._data = data.view(_numpy.recarray) 1dgf

2403  

2404 return obj 1dgf

2405  

2406 @staticmethod 

2407 def from_ptr(intptr_t ptr, size_t size=1, bint readonly=False, object owner=None): 

2408 """Create an IOParams instance wrapping the given pointer. 

2409  

2410 Args: 

2411 ptr (intptr_t): pointer address as Python :class:`int` to the data. 

2412 size (int): number of structs, default=1. 

2413 readonly (bool): whether the data is read-only (to the user). default is `False`. 

2414 owner (object): object that owns the memory at *ptr*. A strong reference is 

2415 kept so the backing storage outlives this wrapper. 

2416 """ 

2417 if ptr == 0: 

2418 raise ValueError("ptr must not be null (0)") 

2419 cdef IOParams obj = IOParams.__new__(IOParams) 

2420 cdef flag = _cyb_cpython_buffer.PyBUF_READ if readonly else _cyb_cpython_buffer.PyBUF_WRITE 

2421 cdef object buf = _cyb_cpython_memoryview.PyMemoryView_FromMemory( 

2422 <char*>ptr, sizeof(CUfileIOParams_t) * size, flag) 

2423 data = _numpy.ndarray(size, buffer=buf, dtype=io_params_dtype) 

2424 obj._data = data.view(_numpy.recarray) 

2425 obj._owner = owner 

2426  

2427 return obj 

2428  

2429  

2430cdef _get_stats_level2_dtype_offsets(): 

2431 cdef CUfileStatsLevel2_t pod 

2432 return _numpy.dtype({ 

2433 'names': ['basic', 'read_size_kb_hist', 'write_size_kb_hist'], 

2434 'formats': [stats_level1_dtype, (_numpy.uint64, 32), (_numpy.uint64, 32)], 

2435 'offsets': [ 

2436 (<intptr_t>&(pod.basic)) - (<intptr_t>&pod), 

2437 (<intptr_t>&(pod.read_size_kb_hist)) - (<intptr_t>&pod), 

2438 (<intptr_t>&(pod.write_size_kb_hist)) - (<intptr_t>&pod), 

2439 ], 

2440 'itemsize': sizeof(CUfileStatsLevel2_t), 

2441 }) 

2442  

2443stats_level2_dtype = _get_stats_level2_dtype_offsets() 

2444  

2445cdef class StatsLevel2: 

2446 """Empty-initialize an instance of `CUfileStatsLevel2_t`. 

2447  

2448  

2449 .. seealso:: `CUfileStatsLevel2_t` 

2450 """ 

2451 cdef: 

2452 CUfileStatsLevel2_t *_ptr 

2453 object _owner 

2454 bint _owned 

2455 bint _readonly 

2456  

2457 def __init__(self): 

2458 self._ptr = <CUfileStatsLevel2_t *>_cyb_calloc(1, sizeof(CUfileStatsLevel2_t)) 1c

2459 if self._ptr == NULL: 1c

2460 raise MemoryError("Error allocating StatsLevel2") 

2461 self._owner = None 1c

2462 self._owned = True 1c

2463 self._readonly = False 1c

2464  

2465 def __dealloc__(self): 

2466 cdef CUfileStatsLevel2_t *ptr 

2467 if self._owned and self._ptr != NULL: 1cb

2468 ptr = self._ptr 1c

2469 self._ptr = NULL 1c

2470 _cyb_free(ptr) 1c

2471  

2472 def __repr__(self): 

2473 return f"<{__name__}.StatsLevel2 object at {hex(id(self))}>" 

2474  

2475 @property 

2476 def ptr(self): 

2477 """Get the pointer address to the data as Python :class:`int`.""" 

2478 return <intptr_t>(self._ptr) 1c

2479  

2480 cdef intptr_t _get_ptr(self): 

2481 return <intptr_t>(self._ptr) 

2482  

2483 def __int__(self): 

2484 return <intptr_t>(self._ptr) 

2485  

2486 def __eq__(self, other): 

2487 cdef StatsLevel2 other_ 

2488 if not isinstance(other, StatsLevel2): 

2489 return False 

2490 other_ = other 

2491 return (_cyb_memcmp(<void *><intptr_t>(self._ptr), <void *><intptr_t>(other_._ptr), sizeof(CUfileStatsLevel2_t)) == 0) 

2492  

2493 def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): 

2494 _cyb___getbuffer(self, buffer, <void *>self._ptr, sizeof(CUfileStatsLevel2_t), self._readonly) 

2495  

2496 def __releasebuffer__(self, Py_buffer *buffer): 

2497 pass 

2498  

2499 def __setitem__(self, key, val): 

2500 if key == 0 and isinstance(val, _numpy.ndarray): 

2501 self._ptr = <CUfileStatsLevel2_t *>_cyb_malloc(sizeof(CUfileStatsLevel2_t)) 

2502 if self._ptr == NULL: 

2503 raise MemoryError("Error allocating StatsLevel2") 

2504 _cyb_memcpy(<void*>self._ptr, <void*><intptr_t>val.ctypes.data, sizeof(CUfileStatsLevel2_t)) 

2505 self._owner = None 

2506 self._owned = True 

2507 self._readonly = not val.flags.writeable 

2508 else: 

2509 setattr(self, key, val) 

2510  

2511 @property 

2512 def basic(self): 

2513 """StatsLevel1: """ 

2514 return StatsLevel1.from_ptr( 1c

2515 <intptr_t>&(self._ptr[0].basic), 1c

2516 readonly=self._readonly, 1c

2517 owner=self, 1c

2518 ) 

2519  

2520 @basic.setter 

2521 def basic(self, val): 

2522 if self._readonly: 

2523 raise ValueError("This StatsLevel2 instance is read-only") 

2524 cdef StatsLevel1 val_ = val 

2525 _cyb_memcpy(<void *>&(self._ptr[0].basic), <void *>(val_._get_ptr()), sizeof(CUfileStatsLevel1_t) * 1) 

2526  

2527 @property 

2528 def read_size_kb_hist(self): 

2529 """~_numpy.uint64: (array of length 32).""" 

2530 cdef _cyb_view.array arr = _cyb_view.array(shape=(32,), itemsize=sizeof(uint64_t), format="Q", mode="c", allocate_buffer=False) 1cb

2531 arr.data = <char *>(&(self._ptr[0].read_size_kb_hist)) 1cb

2532 return _numpy.asarray(arr) 1cb

2533  

2534 @read_size_kb_hist.setter 

2535 def read_size_kb_hist(self, val): 

2536 if self._readonly: 

2537 raise ValueError("This StatsLevel2 instance is read-only") 

2538 if len(val) != 32: 

2539 raise ValueError(f"Expected length { 32 } for field read_size_kb_hist, got {len(val)}") 

2540 cdef _cyb_view.array arr = _cyb_view.array(shape=(32,), itemsize=sizeof(uint64_t), format="Q", mode="c") 

2541 arr[:] = _numpy.asarray(val, dtype=_numpy.uint64) 

2542 _cyb_memcpy(<void *>(&(self._ptr[0].read_size_kb_hist)), <void *>(arr.data), sizeof(uint64_t) * len(val)) 

2543  

2544 @property 

2545 def write_size_kb_hist(self): 

2546 """~_numpy.uint64: (array of length 32).""" 

2547 cdef _cyb_view.array arr = _cyb_view.array(shape=(32,), itemsize=sizeof(uint64_t), format="Q", mode="c", allocate_buffer=False) 1c

2548 arr.data = <char *>(&(self._ptr[0].write_size_kb_hist)) 1c

2549 return _numpy.asarray(arr) 1c

2550  

2551 @write_size_kb_hist.setter 

2552 def write_size_kb_hist(self, val): 

2553 if self._readonly: 

2554 raise ValueError("This StatsLevel2 instance is read-only") 

2555 if len(val) != 32: 

2556 raise ValueError(f"Expected length { 32 } for field write_size_kb_hist, got {len(val)}") 

2557 cdef _cyb_view.array arr = _cyb_view.array(shape=(32,), itemsize=sizeof(uint64_t), format="Q", mode="c") 

2558 arr[:] = _numpy.asarray(val, dtype=_numpy.uint64) 

2559 _cyb_memcpy(<void *>(&(self._ptr[0].write_size_kb_hist)), <void *>(arr.data), sizeof(uint64_t) * len(val)) 

2560  

2561 @staticmethod 

2562 def from_buffer(buffer): 

2563 """Create an StatsLevel2 instance with the memory from the given buffer.""" 

2564 return _cyb_from_buffer(buffer, sizeof(CUfileStatsLevel2_t), StatsLevel2) 

2565  

2566 @staticmethod 

2567 def from_data(data): 

2568 """Create an StatsLevel2 instance wrapping the given NumPy array. 

2569  

2570 Args: 

2571 data (_numpy.ndarray): a single-element array of dtype `stats_level2_dtype` holding the data. 

2572 """ 

2573 return _cyb_from_data(data, "stats_level2_dtype", stats_level2_dtype, StatsLevel2) 1b

2574  

2575 @staticmethod 

2576 def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): 

2577 """Create an StatsLevel2 instance wrapping the given pointer. 

2578  

2579 Args: 

2580 ptr (intptr_t): pointer address as Python :class:`int` to the data. 

2581 owner (object): The Python object that owns the pointer. If not provided, data will be copied. 

2582 readonly (bool): whether the data is read-only (to the user). default is `False`. 

2583 """ 

2584 if ptr == 0: 1b

2585 raise ValueError("ptr must not be null (0)") 

2586 cdef StatsLevel2 obj = StatsLevel2.__new__(StatsLevel2) 1b

2587 if owner is None: 1b

2588 obj._ptr = <CUfileStatsLevel2_t *>_cyb_malloc(sizeof(CUfileStatsLevel2_t)) 

2589 if obj._ptr == NULL: 

2590 raise MemoryError("Error allocating StatsLevel2") 

2591 _cyb_memcpy(<void*>(obj._ptr), <void*>ptr, sizeof(CUfileStatsLevel2_t)) 

2592 obj._owner = None 

2593 obj._owned = True 

2594 else: 

2595 obj._ptr = <CUfileStatsLevel2_t *>ptr 1b

2596 obj._owner = owner 1b

2597 obj._owned = False 1b

2598 obj._readonly = readonly 1b

2599 return obj 1b

2600  

2601  

2602cdef _get_stats_level3_dtype_offsets(): 

2603 cdef CUfileStatsLevel3_t pod 

2604 return _numpy.dtype({ 

2605 'names': ['detailed', 'num_gpus', 'per_gpu_stats'], 

2606 'formats': [stats_level2_dtype, _numpy.uint32, (per_gpu_stats_dtype, 16)], 

2607 'offsets': [ 

2608 (<intptr_t>&(pod.detailed)) - (<intptr_t>&pod), 

2609 (<intptr_t>&(pod.num_gpus)) - (<intptr_t>&pod), 

2610 (<intptr_t>&(pod.per_gpu_stats)) - (<intptr_t>&pod), 

2611 ], 

2612 'itemsize': sizeof(CUfileStatsLevel3_t), 

2613 }) 

2614  

2615stats_level3_dtype = _get_stats_level3_dtype_offsets() 

2616  

2617cdef class StatsLevel3: 

2618 """Empty-initialize an instance of `CUfileStatsLevel3_t`. 

2619  

2620  

2621 .. seealso:: `CUfileStatsLevel3_t` 

2622 """ 

2623 cdef: 

2624 CUfileStatsLevel3_t *_ptr 

2625 object _owner 

2626 bint _owned 

2627 bint _readonly 

2628  

2629 def __init__(self): 

2630 self._ptr = <CUfileStatsLevel3_t *>_cyb_calloc(1, sizeof(CUfileStatsLevel3_t)) 1b

2631 if self._ptr == NULL: 1b

2632 raise MemoryError("Error allocating StatsLevel3") 

2633 self._owner = None 1b

2634 self._owned = True 1b

2635 self._readonly = False 1b

2636  

2637 def __dealloc__(self): 

2638 cdef CUfileStatsLevel3_t *ptr 

2639 if self._owned and self._ptr != NULL: 1b

2640 ptr = self._ptr 1b

2641 self._ptr = NULL 1b

2642 _cyb_free(ptr) 1b

2643  

2644 def __repr__(self): 

2645 return f"<{__name__}.StatsLevel3 object at {hex(id(self))}>" 

2646  

2647 @property 

2648 def ptr(self): 

2649 """Get the pointer address to the data as Python :class:`int`.""" 

2650 return <intptr_t>(self._ptr) 1b

2651  

2652 cdef intptr_t _get_ptr(self): 

2653 return <intptr_t>(self._ptr) 

2654  

2655 def __int__(self): 

2656 return <intptr_t>(self._ptr) 

2657  

2658 def __eq__(self, other): 

2659 cdef StatsLevel3 other_ 

2660 if not isinstance(other, StatsLevel3): 

2661 return False 

2662 other_ = other 

2663 return (_cyb_memcmp(<void *><intptr_t>(self._ptr), <void *><intptr_t>(other_._ptr), sizeof(CUfileStatsLevel3_t)) == 0) 

2664  

2665 def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): 

2666 _cyb___getbuffer(self, buffer, <void *>self._ptr, sizeof(CUfileStatsLevel3_t), self._readonly) 

2667  

2668 def __releasebuffer__(self, Py_buffer *buffer): 

2669 pass 

2670  

2671 def __setitem__(self, key, val): 

2672 if key == 0 and isinstance(val, _numpy.ndarray): 

2673 self._ptr = <CUfileStatsLevel3_t *>_cyb_malloc(sizeof(CUfileStatsLevel3_t)) 

2674 if self._ptr == NULL: 

2675 raise MemoryError("Error allocating StatsLevel3") 

2676 _cyb_memcpy(<void*>self._ptr, <void*><intptr_t>val.ctypes.data, sizeof(CUfileStatsLevel3_t)) 

2677 self._owner = None 

2678 self._owned = True 

2679 self._readonly = not val.flags.writeable 

2680 else: 

2681 setattr(self, key, val) 

2682  

2683 @property 

2684 def detailed(self): 

2685 """StatsLevel2: """ 

2686 return StatsLevel2.from_ptr( 1b

2687 <intptr_t>&(self._ptr[0].detailed), 1b

2688 readonly=self._readonly, 1b

2689 owner=self, 1b

2690 ) 

2691  

2692 @detailed.setter 

2693 def detailed(self, val): 

2694 if self._readonly: 

2695 raise ValueError("This StatsLevel3 instance is read-only") 

2696 cdef StatsLevel2 val_ = val 

2697 _cyb_memcpy(<void *>&(self._ptr[0].detailed), <void *>(val_._get_ptr()), sizeof(CUfileStatsLevel2_t) * 1) 

2698  

2699 @property 

2700 def per_gpu_stats(self): 

2701 """PerGpuStats: """ 

2702 return PerGpuStats.from_ptr( 1b

2703 <intptr_t>&(self._ptr[0].per_gpu_stats), 1b

2704 16, 

2705 readonly=self._readonly, 1b

2706 owner=self, 1b

2707 ) 

2708  

2709 @per_gpu_stats.setter 

2710 def per_gpu_stats(self, val): 

2711 if self._readonly: 

2712 raise ValueError("This StatsLevel3 instance is read-only") 

2713 cdef PerGpuStats val_ = val 

2714 if len(val) != 16: 

2715 raise ValueError(f"Expected length { 16 } for field per_gpu_stats, got {len(val)}") 

2716 _cyb_memcpy(<void *>&(self._ptr[0].per_gpu_stats), <void *>(val_._get_ptr()), sizeof(CUfilePerGpuStats_t) * 16) 

2717  

2718 @property 

2719 def num_gpus(self): 

2720 """int: """ 

2721 return self._ptr[0].num_gpus 1b

2722  

2723 @num_gpus.setter 

2724 def num_gpus(self, val): 

2725 if self._readonly: 

2726 raise ValueError("This StatsLevel3 instance is read-only") 

2727 self._ptr[0].num_gpus = val 

2728  

2729 @staticmethod 

2730 def from_buffer(buffer): 

2731 """Create an StatsLevel3 instance with the memory from the given buffer.""" 

2732 return _cyb_from_buffer(buffer, sizeof(CUfileStatsLevel3_t), StatsLevel3) 

2733  

2734 @staticmethod 

2735 def from_data(data): 

2736 """Create an StatsLevel3 instance wrapping the given NumPy array. 

2737  

2738 Args: 

2739 data (_numpy.ndarray): a single-element array of dtype `stats_level3_dtype` holding the data. 

2740 """ 

2741 return _cyb_from_data(data, "stats_level3_dtype", stats_level3_dtype, StatsLevel3) 

2742  

2743 @staticmethod 

2744 def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): 

2745 """Create an StatsLevel3 instance wrapping the given pointer. 

2746  

2747 Args: 

2748 ptr (intptr_t): pointer address as Python :class:`int` to the data. 

2749 owner (object): The Python object that owns the pointer. If not provided, data will be copied. 

2750 readonly (bool): whether the data is read-only (to the user). default is `False`. 

2751 """ 

2752 if ptr == 0: 

2753 raise ValueError("ptr must not be null (0)") 

2754 cdef StatsLevel3 obj = StatsLevel3.__new__(StatsLevel3) 

2755 if owner is None: 

2756 obj._ptr = <CUfileStatsLevel3_t *>_cyb_malloc(sizeof(CUfileStatsLevel3_t)) 

2757 if obj._ptr == NULL: 

2758 raise MemoryError("Error allocating StatsLevel3") 

2759 _cyb_memcpy(<void*>(obj._ptr), <void*>ptr, sizeof(CUfileStatsLevel3_t)) 

2760 obj._owner = None 

2761 obj._owned = True 

2762 else: 

2763 obj._ptr = <CUfileStatsLevel3_t *>ptr 

2764 obj._owner = owner 

2765 obj._owned = False 

2766 obj._readonly = readonly 

2767 return obj 

2768  

2769  

2770############################################################################### 

2771# Enum 

2772############################################################################### 

2773  

2774class OpError(_cyb_FastEnum): 

2775 """ 

2776 See `CUfileOpError`. 

2777 """ 

2778 SUCCESS = CU_FILE_SUCCESS 

2779 DRIVER_NOT_INITIALIZED = CU_FILE_DRIVER_NOT_INITIALIZED 

2780 DRIVER_INVALID_PROPS = CU_FILE_DRIVER_INVALID_PROPS 

2781 DRIVER_UNSUPPORTED_LIMIT = CU_FILE_DRIVER_UNSUPPORTED_LIMIT 

2782 DRIVER_VERSION_MISMATCH = CU_FILE_DRIVER_VERSION_MISMATCH 

2783 DRIVER_VERSION_READ_ERROR = CU_FILE_DRIVER_VERSION_READ_ERROR 

2784 DRIVER_CLOSING = CU_FILE_DRIVER_CLOSING 

2785 PLATFORM_NOT_SUPPORTED = CU_FILE_PLATFORM_NOT_SUPPORTED 

2786 IO_NOT_SUPPORTED = CU_FILE_IO_NOT_SUPPORTED 

2787 DEVICE_NOT_SUPPORTED = CU_FILE_DEVICE_NOT_SUPPORTED 

2788 NVFS_DRIVER_ERROR = CU_FILE_NVFS_DRIVER_ERROR 

2789 CUDA_DRIVER_ERROR = CU_FILE_CUDA_DRIVER_ERROR 

2790 CUDA_POINTER_INVALID = CU_FILE_CUDA_POINTER_INVALID 

2791 CUDA_MEMORY_TYPE_INVALID = CU_FILE_CUDA_MEMORY_TYPE_INVALID 

2792 CUDA_POINTER_RANGE_ERROR = CU_FILE_CUDA_POINTER_RANGE_ERROR 

2793 CUDA_CONTEXT_MISMATCH = CU_FILE_CUDA_CONTEXT_MISMATCH 

2794 INVALID_MAPPING_SIZE = CU_FILE_INVALID_MAPPING_SIZE 

2795 INVALID_MAPPING_RANGE = CU_FILE_INVALID_MAPPING_RANGE 

2796 INVALID_FILE_TYPE = CU_FILE_INVALID_FILE_TYPE 

2797 INVALID_FILE_OPEN_FLAG = CU_FILE_INVALID_FILE_OPEN_FLAG 

2798 DIO_NOT_SET = CU_FILE_DIO_NOT_SET 

2799 INVALID_VALUE = CU_FILE_INVALID_VALUE 

2800 MEMORY_ALREADY_REGISTERED = CU_FILE_MEMORY_ALREADY_REGISTERED 

2801 MEMORY_NOT_REGISTERED = CU_FILE_MEMORY_NOT_REGISTERED 

2802 PERMISSION_DENIED = CU_FILE_PERMISSION_DENIED 

2803 DRIVER_ALREADY_OPEN = CU_FILE_DRIVER_ALREADY_OPEN 

2804 HANDLE_NOT_REGISTERED = CU_FILE_HANDLE_NOT_REGISTERED 

2805 HANDLE_ALREADY_REGISTERED = CU_FILE_HANDLE_ALREADY_REGISTERED 

2806 DEVICE_NOT_FOUND = CU_FILE_DEVICE_NOT_FOUND 

2807 INTERNAL_ERROR = CU_FILE_INTERNAL_ERROR 

2808 GETNEWFD_FAILED = CU_FILE_GETNEWFD_FAILED 

2809 NVFS_SETUP_ERROR = CU_FILE_NVFS_SETUP_ERROR 

2810 IO_DISABLED = CU_FILE_IO_DISABLED 

2811 BATCH_SUBMIT_FAILED = CU_FILE_BATCH_SUBMIT_FAILED 

2812 GPU_MEMORY_PINNING_FAILED = CU_FILE_GPU_MEMORY_PINNING_FAILED 

2813 BATCH_FULL = CU_FILE_BATCH_FULL 

2814 ASYNC_NOT_SUPPORTED = CU_FILE_ASYNC_NOT_SUPPORTED 

2815 INTERNAL_BATCH_SETUP_ERROR = CU_FILE_INTERNAL_BATCH_SETUP_ERROR 

2816 INTERNAL_BATCH_SUBMIT_ERROR = CU_FILE_INTERNAL_BATCH_SUBMIT_ERROR 

2817 INTERNAL_BATCH_GETSTATUS_ERROR = CU_FILE_INTERNAL_BATCH_GETSTATUS_ERROR 

2818 INTERNAL_BATCH_CANCEL_ERROR = CU_FILE_INTERNAL_BATCH_CANCEL_ERROR 

2819 NOMEM_ERROR = CU_FILE_NOMEM_ERROR 

2820 IO_ERROR = CU_FILE_IO_ERROR 

2821 INTERNAL_BUF_REGISTER_ERROR = CU_FILE_INTERNAL_BUF_REGISTER_ERROR 

2822 HASH_OPR_ERROR = CU_FILE_HASH_OPR_ERROR 

2823 INVALID_CONTEXT_ERROR = CU_FILE_INVALID_CONTEXT_ERROR 

2824 NVFS_INTERNAL_DRIVER_ERROR = CU_FILE_NVFS_INTERNAL_DRIVER_ERROR 

2825 BATCH_NOCOMPAT_ERROR = CU_FILE_BATCH_NOCOMPAT_ERROR 

2826 IO_MAX_ERROR = CU_FILE_IO_MAX_ERROR 

2827  

2828class DriverStatusFlags(_cyb_FastEnum): 

2829 """ 

2830 See `CUfileDriverStatusFlags_t`. 

2831 """ 

2832 LUSTRE_SUPPORTED = (CU_FILE_LUSTRE_SUPPORTED, 'Support for DDN LUSTRE') 

2833 WEKAFS_SUPPORTED = (CU_FILE_WEKAFS_SUPPORTED, 'Support for WEKAFS') 

2834 NFS_SUPPORTED = (CU_FILE_NFS_SUPPORTED, 'Support for NFS') 

2835 GPFS_SUPPORTED = CU_FILE_GPFS_SUPPORTED 

2836 NVME_SUPPORTED = (CU_FILE_NVME_SUPPORTED, '< Support for GPFS Support for NVMe') 

2837 NVMEOF_SUPPORTED = (CU_FILE_NVMEOF_SUPPORTED, 'Support for NVMeOF') 

2838 SCSI_SUPPORTED = (CU_FILE_SCSI_SUPPORTED, 'Support for SCSI') 

2839 SCALEFLUX_CSD_SUPPORTED = (CU_FILE_SCALEFLUX_CSD_SUPPORTED, 'Support for Scaleflux CSD') 

2840 NVMESH_SUPPORTED = (CU_FILE_NVMESH_SUPPORTED, 'Support for NVMesh Block Dev') 

2841 BEEGFS_SUPPORTED = (CU_FILE_BEEGFS_SUPPORTED, 'Support for BeeGFS') 

2842 NVME_P2P_SUPPORTED = (CU_FILE_NVME_P2P_SUPPORTED, 'Do not use this macro. This is deprecated now') 

2843 SCATEFS_SUPPORTED = (CU_FILE_SCATEFS_SUPPORTED, 'Support for ScateFS') 

2844 VIRTIOFS_SUPPORTED = (CU_FILE_VIRTIOFS_SUPPORTED, 'Support for VirtioFS') 

2845 MAX_TARGET_TYPES = (CU_FILE_MAX_TARGET_TYPES, 'Maximum FS supported') 

2846  

2847class DriverControlFlags(_cyb_FastEnum): 

2848 """ 

2849 See `CUfileDriverControlFlags_t`. 

2850 """ 

2851 USE_POLL_MODE = (CU_FILE_USE_POLL_MODE, 'use POLL mode. properties.use_poll_mode') 

2852 ALLOW_COMPAT_MODE = (CU_FILE_ALLOW_COMPAT_MODE, 'allow COMPATIBILITY mode. properties.allow_compat_mode') 

2853 POSIX_IO_MODE = (CU_FILE_POSIX_IO_MODE, 'Vanilla posix io mode. properties.posix_io_mode') 

2854 FALLBACK_IO_MODE = (CU_FILE_FALLBACK_IO_MODE, 'Fallback io mode. properties.gds_fallback_io') 

2855  

2856class FeatureFlags(_cyb_FastEnum): 

2857 """ 

2858 See `CUfileFeatureFlags_t`. 

2859 """ 

2860 DYN_ROUTING_SUPPORTED = (CU_FILE_DYN_ROUTING_SUPPORTED, 'Support for Dynamic routing to handle devices across the PCIe bridges') 

2861 BATCH_IO_SUPPORTED = (CU_FILE_BATCH_IO_SUPPORTED, 'Supported') 

2862 STREAMS_SUPPORTED = (CU_FILE_STREAMS_SUPPORTED, 'Supported') 

2863 PARALLEL_IO_SUPPORTED = (CU_FILE_PARALLEL_IO_SUPPORTED, 'Supported') 

2864 P2P_SUPPORTED = (CU_FILE_P2P_SUPPORTED, 'Support for PCI P2PDMA') 

2865  

2866class FileHandleType(_cyb_FastEnum): 

2867 """ 

2868 See `CUfileFileHandleType`. 

2869 """ 

2870 OPAQUE_FD = (CU_FILE_HANDLE_TYPE_OPAQUE_FD, 'Linux based fd') 

2871 OPAQUE_WIN32 = (CU_FILE_HANDLE_TYPE_OPAQUE_WIN32, 'Windows based handle (unsupported)') 

2872 USERSPACE_FS = CU_FILE_HANDLE_TYPE_USERSPACE_FS 

2873  

2874class Opcode(_cyb_FastEnum): 

2875 """ 

2876 See `CUfileOpcode_t`. 

2877 """ 

2878 READ = CUFILE_READ 

2879 WRITE = CUFILE_WRITE 

2880  

2881class Status(_cyb_FastEnum): 

2882 """ 

2883 See `CUfileStatus_t`. 

2884 """ 

2885 WAITING = CUFILE_WAITING 

2886 PENDING = CUFILE_PENDING 

2887 INVALID = CUFILE_INVALID 

2888 CANCELED = CUFILE_CANCELED 

2889 COMPLETE = CUFILE_COMPLETE 

2890 TIMEOUT = CUFILE_TIMEOUT 

2891 FAILED = CUFILE_FAILED 

2892  

2893class BatchMode(_cyb_FastEnum): 

2894 """ 

2895 See `CUfileBatchMode_t`. 

2896 """ 

2897 BATCH = CUFILE_BATCH 

2898  

2899class SizeTConfigParameter(_cyb_FastEnum): 

2900 """ 

2901 See `CUFileSizeTConfigParameter_t`. 

2902 """ 

2903 PROFILE_STATS = CUFILE_PARAM_PROFILE_STATS 

2904 EXECUTION_MAX_IO_QUEUE_DEPTH = CUFILE_PARAM_EXECUTION_MAX_IO_QUEUE_DEPTH 

2905 EXECUTION_MAX_IO_THREADS = CUFILE_PARAM_EXECUTION_MAX_IO_THREADS 

2906 EXECUTION_MIN_IO_THRESHOLD_SIZE_KB = CUFILE_PARAM_EXECUTION_MIN_IO_THRESHOLD_SIZE_KB 

2907 EXECUTION_MAX_REQUEST_PARALLELISM = CUFILE_PARAM_EXECUTION_MAX_REQUEST_PARALLELISM 

2908 PROPERTIES_MAX_DIRECT_IO_SIZE_KB = CUFILE_PARAM_PROPERTIES_MAX_DIRECT_IO_SIZE_KB 

2909 PROPERTIES_MAX_DEVICE_CACHE_SIZE_KB = CUFILE_PARAM_PROPERTIES_MAX_DEVICE_CACHE_SIZE_KB 

2910 PROPERTIES_PER_BUFFER_CACHE_SIZE_KB = CUFILE_PARAM_PROPERTIES_PER_BUFFER_CACHE_SIZE_KB 

2911 PROPERTIES_MAX_DEVICE_PINNED_MEM_SIZE_KB = CUFILE_PARAM_PROPERTIES_MAX_DEVICE_PINNED_MEM_SIZE_KB 

2912 PROPERTIES_IO_BATCHSIZE = CUFILE_PARAM_PROPERTIES_IO_BATCHSIZE 

2913 POLLTHRESHOLD_SIZE_KB = CUFILE_PARAM_POLLTHRESHOLD_SIZE_KB 

2914 PROPERTIES_BATCH_IO_TIMEOUT_MS = CUFILE_PARAM_PROPERTIES_BATCH_IO_TIMEOUT_MS 

2915  

2916class BoolConfigParameter(_cyb_FastEnum): 

2917 """ 

2918 See `CUFileBoolConfigParameter_t`. 

2919 """ 

2920 PROPERTIES_USE_POLL_MODE = CUFILE_PARAM_PROPERTIES_USE_POLL_MODE 

2921 PROPERTIES_ALLOW_COMPAT_MODE = CUFILE_PARAM_PROPERTIES_ALLOW_COMPAT_MODE 

2922 FORCE_COMPAT_MODE = CUFILE_PARAM_FORCE_COMPAT_MODE 

2923 FS_MISC_API_CHECK_AGGRESSIVE = CUFILE_PARAM_FS_MISC_API_CHECK_AGGRESSIVE 

2924 EXECUTION_PARALLEL_IO = CUFILE_PARAM_EXECUTION_PARALLEL_IO 

2925 PROFILE_NVTX = CUFILE_PARAM_PROFILE_NVTX 

2926 PROPERTIES_ALLOW_SYSTEM_MEMORY = CUFILE_PARAM_PROPERTIES_ALLOW_SYSTEM_MEMORY 

2927 USE_PCIP2PDMA = CUFILE_PARAM_USE_PCIP2PDMA 

2928 PREFER_IO_URING = CUFILE_PARAM_PREFER_IO_URING 

2929 FORCE_ODIRECT_MODE = CUFILE_PARAM_FORCE_ODIRECT_MODE 

2930 SKIP_TOPOLOGY_DETECTION = CUFILE_PARAM_SKIP_TOPOLOGY_DETECTION 

2931 STREAM_MEMOPS_BYPASS = CUFILE_PARAM_STREAM_MEMOPS_BYPASS 

2932  

2933class StringConfigParameter(_cyb_FastEnum): 

2934 """ 

2935 See `CUFileStringConfigParameter_t`. 

2936 """ 

2937 LOGGING_LEVEL = CUFILE_PARAM_LOGGING_LEVEL 

2938 ENV_LOGFILE_PATH = CUFILE_PARAM_ENV_LOGFILE_PATH 

2939 LOG_DIR = CUFILE_PARAM_LOG_DIR 

2940  

2941class ArrayConfigParameter(_cyb_FastEnum): 

2942 """ 

2943 See `CUFileArrayConfigParameter_t`. 

2944 """ 

2945 POSIX_POOL_SLAB_SIZE_KB = CUFILE_PARAM_POSIX_POOL_SLAB_SIZE_KB 

2946 POSIX_POOL_SLAB_COUNT = CUFILE_PARAM_POSIX_POOL_SLAB_COUNT 

2947 GPU_BOUNCE_BUFFER_SLAB_SIZE_KB = CUFILE_PARAM_GPU_BOUNCE_BUFFER_SLAB_SIZE_KB 

2948 GPU_BOUNCE_BUFFER_SLAB_COUNT = CUFILE_PARAM_GPU_BOUNCE_BUFFER_SLAB_COUNT 

2949  

2950class P2PFlags(_cyb_FastEnum): 

2951 """ 

2952 See `CUfileP2PFlags_t`. 

2953 """ 

2954 P2PDMA = (CUFILE_P2PDMA, 'Support for PCI P2PDMA') 

2955 NVFS = (CUFILE_NVFS, 'Support for nvidia-fs') 

2956 DMABUF = (CUFILE_DMABUF, 'Support for DMA Buffer') 

2957 C2C = (CUFILE_C2C, 'Support for Chip-to-Chip (Grace-based systems)') 

2958 NVIDIA_PEERMEM = (CUFILE_NVIDIA_PEERMEM, 'Only for IBM Spectrum Scale and WekaFS') 

2959  

2960  

2961############################################################################### 

2962# Error handling 

2963############################################################################### 

2964  

2965ctypedef fused ReturnT: 

2966 CUfileError_t 

2967 ssize_t 

2968  

2969  

2970class cuFileError(Exception): 

2971  

2972 def __init__(self, status, cu_err=None): 

2973 self.status = status 1pno

2974 self.cuda_error = cu_err 1pno

2975 s = OpError(status) 1pno

2976 cdef str err = f"{s.name} ({s.value}): {op_status_error(status)}" 1pno

2977 if cu_err is not None: 1pno

2978 e = pyCUresult(cu_err) 1pno

2979 err += f"; CUDA status: {e.name} ({e.value})" 1pno

2980 super(cuFileError, self).__init__(err) 1pno

2981  

2982 def __reduce__(self): 

2983 return (type(self), (self.status, self.cuda_error)) 

2984  

2985  

2986@cython.profile(False) 

2987cdef int check_status(ReturnT status) except 1 nogil: 

2988 if ReturnT is CUfileError_t: 

2989 if status.err != 0 or status.cu_err != 0: 1adOPgQRfSTpUVFWXGYZH01I23J45h67i89j!#k$%l'(m)*MK+N,-eAtcBubCvr./qsnwL:oDxyEz

2990 with gil: 1pno

2991 raise cuFileError(status.err, status.cu_err) 1pno

2992 elif ReturnT is ssize_t: 

2993 if status == -1: 1jklecb

2994 # note: this assumes cuFile already properly resets errno in each API 

2995 with gil: 

2996 raise cuFileError(errno.errno) 

2997 return 0 1adOPgQRfSTpUVFWXGYZH01I23J45h67i89j!#k$%l'(m)*MK+N,-eAtcBubCvr./qsnwL:oDxyEz

2998  

2999  

3000############################################################################### 

3001# Wrapper functions 

3002############################################################################### 

3003  

3004cpdef intptr_t handle_register(intptr_t descr) except? 0: 

3005 """cuFileHandleRegister is required, and performs extra checking that is memoized to provide increased performance on later cuFile operations. 

3006  

3007 Args: 

3008 descr (intptr_t): ``CUfileDescr_t`` file descriptor (OS 

3009 agnostic). 

3010  

3011 Returns: 

3012 intptr_t: ``CUfileHandle_t`` opaque file handle for IO 

3013 operations. 

3014  

3015 .. seealso:: `cuFileHandleRegister` 

3016 """ 

3017 cdef Handle fh 

3018 with nogil: 1dgfhijklmecbr

3019 __status__ = cuFileHandleRegister(&fh, <CUfileDescr_t*>descr) 1dgfhijklmecbr

3020 check_status(__status__) 1dgfhijklmecbr

3021 return <intptr_t>fh 1dgfhijklmecbr

3022  

3023  

3024cpdef void handle_deregister(intptr_t fh) except*: 

3025 """releases a registered filehandle from cuFile. 

3026  

3027 Args: 

3028 fh (intptr_t): ``CUfileHandle_t`` file handle. 

3029  

3030 .. seealso:: `cuFileHandleDeregister` 

3031 """ 

3032 with nogil: 1dgfhijklmecbr

3033 cuFileHandleDeregister(<Handle>fh) 1dgfhijklmecbr

3034  

3035  

3036cpdef buf_register(intptr_t buf_ptr_base, size_t length, int flags): 

3037 """register an existing cudaMalloced memory with cuFile to pin for GPUDirect Storage access or register host allocated memory with cuFile. 

3038  

3039 Args: 

3040 buf_ptr_base (intptr_t): buffer pointer allocated. 

3041 length (size_t): size of memory region from the above 

3042 specified bufPtr. 

3043 flags (int): CU_FILE_RDMA_REGISTER. 

3044  

3045 .. seealso:: `cuFileBufRegister` 

3046 """ 

3047 with nogil: 1dgfpFGHIJhijklmecb

3048 __status__ = cuFileBufRegister(<const void*>buf_ptr_base, length, flags) 1dgfpFGHIJhijklmecb

3049 check_status(__status__) 1dgfpFGHIJhijklmecb

3050  

3051  

3052cpdef buf_deregister(intptr_t buf_ptr_base): 

3053 """deregister an already registered device or host memory from cuFile. 

3054  

3055 Args: 

3056 buf_ptr_base (intptr_t): buffer pointer to deregister. 

3057  

3058 .. seealso:: `cuFileBufDeregister` 

3059 """ 

3060 with nogil: 1dgfpFGHIJhijklmecb

3061 __status__ = cuFileBufDeregister(<const void*>buf_ptr_base) 1dgfpFGHIJhijklmecb

3062 check_status(__status__) 1dgfpFGHIJhijklmecb

3063  

3064  

3065cpdef driver_open(): 

3066 """Initialize the cuFile library and open the nvidia-fs driver. 

3067  

3068 .. seealso:: `cuFileDriverOpen` 

3069 """ 

3070 with nogil: 1OQSUWY02468!$')K,ABC.qsnwLDE

3071 __status__ = cuFileDriverOpen() 1OQSUWY02468!$')K,ABC.qsnwLDE

3072 check_status(__status__) 1OQSUWY02468!$')K,ABC.qsnwLDE

3073  

3074  

3075cpdef use_count(): 

3076 """returns use count of cufile drivers at that moment by the process. 

3077  

3078 .. seealso:: `cuFileUseCount` 

3079 """ 

3080 with nogil: 

3081 __status__ = cuFileUseCount() 

3082 check_status(__status__) 

3083  

3084  

3085cpdef driver_get_properties(intptr_t props): 

3086 """Gets the Driver session properties If the driver is not opened, it will return the staged/default properties If the driver is opened, it will return the current properties. 

3087  

3088 Args: 

3089 props (intptr_t): Properties to get. 

3090  

3091 .. seealso:: `cuFileDriverGetProperties` 

3092 """ 

3093 with nogil: 

3094 __status__ = cuFileDriverGetProperties(<CUfileDrvProps_t*>props) 

3095 check_status(__status__) 

3096  

3097  

3098cpdef driver_set_poll_mode(bint poll, size_t poll_threshold_size): 

3099 """Sets whether the Read/Write APIs use polling to do IO operations This takes place before the driver is opened. No-op if driver is already open. 

3100  

3101 Args: 

3102 poll (bint): boolean to indicate whether to use poll mode or 

3103 not. 

3104 poll_threshold_size (size_t): max IO size to use for POLLING 

3105 mode in KB. 

3106  

3107 .. seealso:: `cuFileDriverSetPollMode` 

3108 """ 

3109 with nogil: 

3110 __status__ = cuFileDriverSetPollMode(<cpp_bool>poll, poll_threshold_size) 

3111 check_status(__status__) 

3112  

3113  

3114cpdef driver_set_max_direct_io_size(size_t max_direct_io_size): 

3115 """Control parameter to set max IO size(KB) used by the library to talk to nvidia-fs driver This takes place before the driver is opened. No-op if driver is already open. 

3116  

3117 Args: 

3118 max_direct_io_size (size_t): maximum allowed direct io size in 

3119 KB. 

3120  

3121 .. seealso:: `cuFileDriverSetMaxDirectIOSize` 

3122 """ 

3123 with nogil: 

3124 __status__ = cuFileDriverSetMaxDirectIOSize(max_direct_io_size) 

3125 check_status(__status__) 

3126  

3127  

3128cpdef driver_set_max_cache_size(size_t max_cache_size): 

3129 """Control parameter to set maximum GPU memory reserved per device by the library for internal buffering This takes place before the driver is opened. No-op if driver is already open. 

3130  

3131 Args: 

3132 max_cache_size (size_t): The maximum GPU buffer space per 

3133 device used for internal use in KB. 

3134  

3135 .. seealso:: `cuFileDriverSetMaxCacheSize` 

3136 """ 

3137 with nogil: 

3138 __status__ = cuFileDriverSetMaxCacheSize(max_cache_size) 

3139 check_status(__status__) 

3140  

3141  

3142cpdef driver_set_max_pinned_mem_size(size_t max_pinned_size): 

3143 """Sets maximum buffer space that is pinned in KB for use by ``cuFileBufRegister`` This takes place before the driver is opened. No-op if driver is already open. 

3144  

3145 Args: 

3146 max_pinned_size (size_t): maximum buffer space that is pinned 

3147 in KB. 

3148  

3149 .. seealso:: `cuFileDriverSetMaxPinnedMemSize` 

3150 """ 

3151 with nogil: 

3152 __status__ = cuFileDriverSetMaxPinnedMemSize(max_pinned_size) 

3153 check_status(__status__) 

3154  

3155  

3156cpdef intptr_t batch_io_set_up(unsigned nr) except? 0: 

3157 cdef BatchHandle batch_idp 

3158 with nogil: 1dgf

3159 __status__ = cuFileBatchIOSetUp(&batch_idp, nr) 1dgf

3160 check_status(__status__) 1dgf

3161 return <intptr_t>batch_idp 1dgf

3162  

3163  

3164cpdef batch_io_submit(intptr_t batch_idp, unsigned nr, intptr_t iocbp, unsigned int flags): 

3165 with nogil: 1dgf

3166 __status__ = cuFileBatchIOSubmit(<BatchHandle>batch_idp, nr, <CUfileIOParams_t*>iocbp, flags) 1dgf

3167 check_status(__status__) 1dgf

3168  

3169  

3170cpdef batch_io_get_status(intptr_t batch_idp, unsigned min_nr, intptr_t nr, intptr_t iocbp, intptr_t timeout): 

3171 with nogil: 1df

3172 __status__ = cuFileBatchIOGetStatus(<BatchHandle>batch_idp, min_nr, <unsigned*>nr, <CUfileIOEvents_t*>iocbp, <timespec*>timeout) 1df

3173 check_status(__status__) 1df

3174  

3175  

3176cpdef batch_io_cancel(intptr_t batch_idp): 

3177 with nogil: 1g

3178 __status__ = cuFileBatchIOCancel(<BatchHandle>batch_idp) 1g

3179 check_status(__status__) 1g

3180  

3181  

3182cpdef void batch_io_destroy(intptr_t batch_idp) except*: 

3183 with nogil: 1dgf

3184 cuFileBatchIODestroy(<BatchHandle>batch_idp) 1dgf

3185  

3186  

3187cpdef read_async(intptr_t fh, intptr_t buf_ptr_base, intptr_t size_p, intptr_t file_offset_p, intptr_t buf_ptr_offset_p, intptr_t bytes_read_p, intptr_t stream): 

3188 with nogil: 1hi

3189 __status__ = cuFileReadAsync(<Handle>fh, <void*>buf_ptr_base, <size_t*>size_p, <off_t*>file_offset_p, <off_t*>buf_ptr_offset_p, <ssize_t*>bytes_read_p, <CUstream>stream) 1hi

3190 check_status(__status__) 1hi

3191  

3192  

3193cpdef write_async(intptr_t fh, intptr_t buf_ptr_base, intptr_t size_p, intptr_t file_offset_p, intptr_t buf_ptr_offset_p, intptr_t bytes_written_p, intptr_t stream): 

3194 with nogil: 1hm

3195 __status__ = cuFileWriteAsync(<Handle>fh, <void*>buf_ptr_base, <size_t*>size_p, <off_t*>file_offset_p, <off_t*>buf_ptr_offset_p, <ssize_t*>bytes_written_p, <CUstream>stream) 1hm

3196 check_status(__status__) 1hm

3197  

3198  

3199cpdef stream_register(intptr_t stream, unsigned flags): 

3200 with nogil: 1him

3201 __status__ = cuFileStreamRegister(<CUstream>stream, flags) 1him

3202 check_status(__status__) 1him

3203  

3204  

3205cpdef stream_deregister(intptr_t stream): 

3206 with nogil: 1him

3207 __status__ = cuFileStreamDeregister(<CUstream>stream) 1him

3208 check_status(__status__) 1him

3209  

3210  

3211cpdef int get_version() except? 0: 

3212 """Get the cuFile library version. 

3213  

3214 Returns: 

3215 int: Pointer to an integer where the version will be stored. 

3216  

3217 .. seealso:: `cuFileGetVersion` 

3218 """ 

3219 cdef int version 

3220 with nogil: 1aq

3221 __status__ = cuFileGetVersion(&version) 1aq

3222 check_status(__status__) 1aq

3223 return version 1aq

3224  

3225  

3226cpdef size_t get_parameter_size_t(int param) except? 0: 

3227 cdef size_t value 

3228 with nogil: 1s

3229 __status__ = cuFileGetParameterSizeT(<_SizeTConfigParameter>param, &value) 1s

3230 check_status(__status__) 1s

3231 return value 1s

3232  

3233  

3234cpdef bint get_parameter_bool(int param) except? 0: 

3235 cdef cpp_bool value 

3236 with nogil: 1q

3237 __status__ = cuFileGetParameterBool(<_BoolConfigParameter>param, &value) 1q

3238 check_status(__status__) 1q

3239 return <bint>value 1q

3240  

3241  

3242cpdef str get_parameter_string(int param, int len): 

3243 cdef bytes _desc_str_ = bytes(len) 1n

3244 cdef char* desc_str = _desc_str_ 1n

3245 with nogil: 1n

3246 __status__ = cuFileGetParameterString(<_StringConfigParameter>param, desc_str, len) 1n

3247 check_status(__status__) 1n

3248 return _cyb_cpython.PyUnicode_FromString(desc_str) 1n

3249  

3250  

3251cpdef set_parameter_size_t(int param, size_t value): 

3252 with nogil: 1s

3253 __status__ = cuFileSetParameterSizeT(<_SizeTConfigParameter>param, value) 1s

3254 check_status(__status__) 1s

3255  

3256  

3257cpdef set_parameter_bool(int param, bint value): 

3258 with nogil: 1q

3259 __status__ = cuFileSetParameterBool(<_BoolConfigParameter>param, <cpp_bool>value) 1q

3260 check_status(__status__) 1q

3261  

3262  

3263cpdef set_parameter_string(int param, intptr_t desc_str): 

3264 with nogil: 1n

3265 __status__ = cuFileSetParameterString(<_StringConfigParameter>param, <const char*>desc_str) 1n

3266 check_status(__status__) 1n

3267  

3268  

3269cpdef tuple get_parameter_min_max_value(int param): 

3270 """Get both the minimum and maximum settable values for a given size_t parameter in a single call. 

3271  

3272 Args: 

3273 param (SizeTConfigParameter): CUfile SizeT configuration 

3274 parameter. 

3275  

3276 Returns: 

3277 A 2-tuple containing: 

3278  

3279 - size_t: Pointer to store the minimum value. 

3280 - size_t: Pointer to store the maximum value. 

3281  

3282 .. seealso:: `cuFileGetParameterMinMaxValue` 

3283 """ 

3284 cdef size_t min_value 

3285 cdef size_t max_value 

3286 with nogil: 1N

3287 __status__ = cuFileGetParameterMinMaxValue(<_SizeTConfigParameter>param, &min_value, &max_value) 1N

3288 check_status(__status__) 1N

3289 return (min_value, max_value) 1N

3290  

3291  

3292cpdef set_stats_level(int level): 

3293 """Set the level of statistics collection for cuFile operations. This will override the cufile.json settings for stats. 

3294  

3295 Args: 

3296 level (int): Statistics level (0 = disabled, 1 = basic, 2 = 

3297 detailed, 3 = verbose). 

3298  

3299 .. seealso:: `cuFileSetStatsLevel` 

3300 """ 

3301 with nogil: 1etcubvoxyz

3302 __status__ = cuFileSetStatsLevel(level) 1etcubvoxyz

3303 check_status(__status__) 1etcubvoxyz

3304  

3305  

3306cpdef int get_stats_level() except? 0: 

3307 """Get the current level of statistics collection for cuFile operations. 

3308  

3309 Returns: 

3310 int: Pointer to store the current statistics level. 

3311  

3312 .. seealso:: `cuFileGetStatsLevel` 

3313 """ 

3314 cdef int level 

3315 with nogil: 1ABCoDE

3316 __status__ = cuFileGetStatsLevel(&level) 1ABCoDE

3317 check_status(__status__) 1ABCoDE

3318 return level 1ABCoDE

3319  

3320  

3321cpdef stats_start(): 

3322 """Start collecting cuFile statistics. 

3323  

3324 .. seealso:: `cuFileStatsStart` 

3325 """ 

3326 with nogil: 1ecby

3327 __status__ = cuFileStatsStart() 1ecby

3328 check_status(__status__) 1ecby

3329  

3330  

3331cpdef stats_stop(): 

3332 """Stop collecting cuFile statistics. 

3333  

3334 .. seealso:: `cuFileStatsStop` 

3335 """ 

3336 with nogil: 1ecby

3337 __status__ = cuFileStatsStop() 1ecby

3338 check_status(__status__) 1ecby

3339  

3340  

3341cpdef stats_reset(): 

3342 """Reset all cuFile statistics counters. 

3343  

3344 .. seealso:: `cuFileStatsReset` 

3345 """ 

3346 with nogil: 1tuvxz

3347 __status__ = cuFileStatsReset() 1tuvxz

3348 check_status(__status__) 1tuvxz

3349  

3350  

3351cpdef get_stats_l1(intptr_t stats): 

3352 """Get Level 1 cuFile statistics. 

3353  

3354 Args: 

3355 stats (intptr_t): Pointer to ``CUfileStatsLevel1_t`` structure 

3356 to be filled. 

3357  

3358 .. seealso:: `cuFileGetStatsL1` 

3359 """ 

3360 with nogil: 1e

3361 __status__ = cuFileGetStatsL1(<CUfileStatsLevel1_t*>stats) 1e

3362 check_status(__status__) 1e

3363  

3364  

3365cpdef get_stats_l2(intptr_t stats): 

3366 """Get Level 2 cuFile statistics. 

3367  

3368 Args: 

3369 stats (intptr_t): Pointer to ``CUfileStatsLevel2_t`` structure 

3370 to be filled. 

3371  

3372 .. seealso:: `cuFileGetStatsL2` 

3373 """ 

3374 with nogil: 1c

3375 __status__ = cuFileGetStatsL2(<CUfileStatsLevel2_t*>stats) 1c

3376 check_status(__status__) 1c

3377  

3378  

3379cpdef get_stats_l3(intptr_t stats): 

3380 """Get Level 3 cuFile statistics. 

3381  

3382 Args: 

3383 stats (intptr_t): Pointer to ``CUfileStatsLevel3_t`` structure 

3384 to be filled. 

3385  

3386 .. seealso:: `cuFileGetStatsL3` 

3387 """ 

3388 with nogil: 1b

3389 __status__ = cuFileGetStatsL3(<CUfileStatsLevel3_t*>stats) 1b

3390 check_status(__status__) 1b

3391  

3392  

3393cpdef size_t get_bar_size_in_kb(int gpu_index) except? 0: 

3394 cdef size_t bar_size 

3395 with nogil: 1M

3396 __status__ = cuFileGetBARSizeInKB(gpu_index, &bar_size) 1M

3397 check_status(__status__) 1M

3398 return bar_size 1M

3399  

3400  

3401cpdef set_parameter_posix_pool_slab_array(intptr_t size_values, intptr_t count_values, int len): 

3402 """Set both POSIX pool slab size and count parameters as a pair. 

3403  

3404 Args: 

3405 size_values (intptr_t): Array of slab sizes in KB. 

3406 count_values (intptr_t): Array of slab counts. 

3407 len (int): Length of both arrays (must be the same). 

3408  

3409 .. seealso:: `cuFileSetParameterPosixPoolSlabArray` 

3410 """ 

3411 with nogil: 1L

3412 __status__ = cuFileSetParameterPosixPoolSlabArray(<const size_t*>size_values, <const size_t*>count_values, len) 1L

3413 check_status(__status__) 1L

3414  

3415  

3416cpdef get_parameter_posix_pool_slab_array(intptr_t size_values, intptr_t count_values, int len): 

3417 """Get both POSIX pool slab size and count parameters as a pair. 

3418  

3419 Args: 

3420 size_values (intptr_t): Buffer to receive slab sizes in KB. 

3421 count_values (intptr_t): Buffer to receive slab counts. 

3422 len (int): Buffer size (must match the actual parameter 

3423 length). 

3424  

3425 .. seealso:: `cuFileGetParameterPosixPoolSlabArray` 

3426 """ 

3427 with nogil: 1w

3428 __status__ = cuFileGetParameterPosixPoolSlabArray(<size_t*>size_values, <size_t*>count_values, len) 1w

3429 check_status(__status__) 1w

3430  

3431  

3432cpdef str op_status_error(int status): 

3433 """cufileop status string. 

3434  

3435 Args: 

3436 status (OpError): the error status to query. 

3437  

3438 .. seealso:: `cufileop_status_error` 

3439 """ 

3440 cdef bytes _output_ 

3441 _output_ = cufileop_status_error(<_OpError>status) 1pno

3442 return _output_.decode() 1pno

3443  

3444  

3445cpdef driver_close(): 

3446 """reset the cuFile library and release the nvidia-fs driver 

3447 """ 

3448 with nogil: 1PRTVXZ13579#%(*K+-tuv/qsnw:xz

3449 status = cuFileDriverClose_v2() 1PRTVXZ13579#%(*K+-tuv/qsnw:xz

3450 check_status(status) 1PRTVXZ13579#%(*K+-tuv/qsnw:xz

3451  

3452cpdef read(intptr_t fh, intptr_t buf_ptr_base, size_t size, off_t file_offset, off_t buf_ptr_offset): 

3453 """read data from a registered file handle to a specified device or host memory. 

3454  

3455 Args: 

3456 fh (intptr_t): ``CUfileHandle_t`` opaque file handle. 

3457 buf_ptr_base (intptr_t): base address of buffer in device or host memory. 

3458 size (size_t): size bytes to read. 

3459 file_offset (off_t): file-offset from begining of the file. 

3460 buf_ptr_offset (off_t): offset relative to the buf_ptr_base pointer to read into. 

3461  

3462 Returns: 

3463 ssize_t: number of bytes read on success. 

3464  

3465 .. seealso:: `cuFileRead` 

3466 """ 

3467 with nogil: 1jklecb

3468 status = cuFileRead(<Handle>fh, <void*>buf_ptr_base, size, file_offset, buf_ptr_offset) 1jklecb

3469 check_status(status) 1jklecb

3470 return status 1jklecb

3471  

3472  

3473cpdef write(intptr_t fh, intptr_t buf_ptr_base, size_t size, off_t file_offset, off_t buf_ptr_offset): 

3474 """write data from a specified device or host memory to a registered file handle. 

3475  

3476 Args: 

3477 fh (intptr_t): ``CUfileHandle_t`` opaque file handle. 

3478 buf_ptr_base (intptr_t): base address of buffer in device or host memory. 

3479 size (size_t): size bytes to write. 

3480 file_offset (off_t): file-offset from begining of the file. 

3481 buf_ptr_offset (off_t): offset relative to the buf_ptr_base pointer to write from. 

3482  

3483 Returns: 

3484 ssize_t: number of bytes written on success. 

3485  

3486 .. seealso:: `cuFileWrite` 

3487 """ 

3488 with nogil: 1jklecb

3489 status = cuFileWrite(<Handle>fh, <const void*>buf_ptr_base, size, file_offset, buf_ptr_offset) 1jklecb

3490 check_status(status) 1jklecb

3491 return status 1jklecb

3492  

3493  

3494del _cyb_FastEnum