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

1470 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2025-12-10 01:19 +0000

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

2# 

3# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE 

4# 

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

6  

7cimport cython # NOQA 

8from libc cimport errno 

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

10 nested_resource) 

11from enum import IntEnum as _IntEnum 

12cimport cpython 

13  

14import cython 

15  

16from cuda.bindings.driver import CUresult as pyCUresult 

17  

18from libc.stdlib cimport calloc, free, malloc 

19from cython cimport view 

20cimport cpython.buffer 

21cimport cpython.memoryview 

22from libc.string cimport memcmp, memcpy 

23import numpy as _numpy 

24  

25  

26cdef __from_data(data, dtype_name, expected_dtype, lowpp_type): 

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

28 if isinstance(data, lowpp_type): 

29 return data 

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

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

32 if data.size != 1: 

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

34 if data.dtype != expected_dtype: 

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

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

37  

38############################################################################### 

39# POD 

40############################################################################### 

41  

42_py_anon_pod1_dtype = _numpy.dtype(( 

43 _numpy.dtype((_numpy.void, sizeof((<CUfileDescr_t*>NULL).handle))), 

44 { 

45 "fd": (_numpy.int32, 0), 

46 "handle": (_numpy.intp, 0), 

47 } 

48 )) 

49  

50  

51cdef class _py_anon_pod1: 

52 """Empty-initialize an instance of `_anon_pod1`. 

53  

54  

55 .. seealso:: `_anon_pod1` 

56 """ 

57 cdef: 

58 _anon_pod1 *_ptr 

59 object _owner 

60 bint _owned 

61 bint _readonly 

62  

63 def __init__(self): 

64 self._ptr = <_anon_pod1 *>calloc(1, sizeof((<CUfileDescr_t*>NULL).handle)) 

65 if self._ptr == NULL: 

66 raise MemoryError("Error allocating _py_anon_pod1") 

67 self._owner = None 

68 self._owned = True 

69 self._readonly = False 

70  

71 def __dealloc__(self): 

72 cdef _anon_pod1 *ptr 

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

74 ptr = self._ptr 

75 self._ptr = NULL 

76 free(ptr) 

77  

78 def __repr__(self): 

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

80  

81 @property 

82 def ptr(self): 

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

84 return <intptr_t>(self._ptr) 

85  

86 cdef intptr_t _get_ptr(self): 

87 return <intptr_t>(self._ptr) 

88  

89 def __int__(self): 

90 return <intptr_t>(self._ptr) 

91  

92 def __eq__(self, other): 

93 cdef _py_anon_pod1 other_ 

94 if not isinstance(other, _py_anon_pod1): 

95 return False 

96 other_ = other 

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

98  

99 def __setitem__(self, key, val): 

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

101 self._ptr = <_anon_pod1 *>malloc(sizeof((<CUfileDescr_t*>NULL).handle)) 

102 if self._ptr == NULL: 

103 raise MemoryError("Error allocating _py_anon_pod1") 

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

105 self._owner = None 

106 self._owned = True 

107 self._readonly = not val.flags.writeable 

108 else: 

109 setattr(self, key, val) 

110  

111 @property 

112 def fd(self): 

113 """int: """ 

114 return self._ptr[0].fd 

115  

116 @fd.setter 

117 def fd(self, val): 

118 if self._readonly: 

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

120 self._ptr[0].fd = val 

121  

122 @property 

123 def handle(self): 

124 """int: """ 

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

126  

127 @handle.setter 

128 def handle(self, val): 

129 if self._readonly: 

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

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

132  

133 @staticmethod 

134 def from_data(data): 

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

136  

137 Args: 

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

139 """ 

140 return __from_data(data, "_py_anon_pod1_dtype", _py_anon_pod1_dtype, _py_anon_pod1) 

141  

142 @staticmethod 

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

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

145  

146 Args: 

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

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

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

150 """ 

151 if ptr == 0: 

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

153 cdef _py_anon_pod1 obj = _py_anon_pod1.__new__(_py_anon_pod1) 

154 if owner is None: 

155 obj._ptr = <_anon_pod1 *>malloc(sizeof((<CUfileDescr_t*>NULL).handle)) 

156 if obj._ptr == NULL: 

157 raise MemoryError("Error allocating _py_anon_pod1") 

158 memcpy(<void*>(obj._ptr), <void*>ptr, sizeof((<CUfileDescr_t*>NULL).handle)) 

159 obj._owner = None 

160 obj._owned = True 

161 else: 

162 obj._ptr = <_anon_pod1 *>ptr 

163 obj._owner = owner 

164 obj._owned = False 

165 obj._readonly = readonly 

166 return obj 

167  

168  

169cdef _get__py_anon_pod3_dtype_offsets(): 

170 cdef _anon_pod3 pod = _anon_pod3() 

171 return _numpy.dtype({ 

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

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

174 'offsets': [ 

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

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

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

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

179 ], 

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

181 }) 

182  

183_py_anon_pod3_dtype = _get__py_anon_pod3_dtype_offsets() 

184  

185cdef class _py_anon_pod3: 

186 """Empty-initialize an instance of `_anon_pod3`. 

187  

188  

189 .. seealso:: `_anon_pod3` 

190 """ 

191 cdef: 

192 _anon_pod3 *_ptr 

193 object _owner 

194 bint _owned 

195 bint _readonly 

196  

197 def __init__(self): 

198 self._ptr = <_anon_pod3 *>calloc(1, sizeof((<CUfileIOParams_t*>NULL).u.batch)) 

199 if self._ptr == NULL: 

200 raise MemoryError("Error allocating _py_anon_pod3") 

201 self._owner = None 

202 self._owned = True 

203 self._readonly = False 

204  

205 def __dealloc__(self): 

206 cdef _anon_pod3 *ptr 

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

208 ptr = self._ptr 

209 self._ptr = NULL 

210 free(ptr) 

211  

212 def __repr__(self): 

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

214  

215 @property 

216 def ptr(self): 

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

218 return <intptr_t>(self._ptr) 

219  

220 cdef intptr_t _get_ptr(self): 

221 return <intptr_t>(self._ptr) 

222  

223 def __int__(self): 

224 return <intptr_t>(self._ptr) 

225  

226 def __eq__(self, other): 

227 cdef _py_anon_pod3 other_ 

228 if not isinstance(other, _py_anon_pod3): 

229 return False 

230 other_ = other 

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

232  

233 def __setitem__(self, key, val): 

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

235 self._ptr = <_anon_pod3 *>malloc(sizeof((<CUfileIOParams_t*>NULL).u.batch)) 

236 if self._ptr == NULL: 

237 raise MemoryError("Error allocating _py_anon_pod3") 

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

239 self._owner = None 

240 self._owned = True 

241 self._readonly = not val.flags.writeable 

242 else: 

243 setattr(self, key, val) 

244  

245 @property 

246 def dev_ptr_base(self): 

247 """int: """ 

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

249  

250 @dev_ptr_base.setter 

251 def dev_ptr_base(self, val): 

252 if self._readonly: 

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

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

255  

256 @property 

257 def file_offset(self): 

258 """int: """ 

259 return self._ptr[0].file_offset 

260  

261 @file_offset.setter 

262 def file_offset(self, val): 

263 if self._readonly: 

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

265 self._ptr[0].file_offset = val 

266  

267 @property 

268 def dev_ptr_offset(self): 

269 """int: """ 

270 return self._ptr[0].devPtr_offset 

271  

272 @dev_ptr_offset.setter 

273 def dev_ptr_offset(self, val): 

274 if self._readonly: 

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

276 self._ptr[0].devPtr_offset = val 

277  

278 @property 

279 def size_(self): 

280 """int: """ 

281 return self._ptr[0].size 

282  

283 @size_.setter 

284 def size_(self, val): 

285 if self._readonly: 

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

287 self._ptr[0].size = val 

288  

289 @staticmethod 

290 def from_data(data): 

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

292  

293 Args: 

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

295 """ 

296 return __from_data(data, "_py_anon_pod3_dtype", _py_anon_pod3_dtype, _py_anon_pod3) 

297  

298 @staticmethod 

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

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

301  

302 Args: 

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

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

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

306 """ 

307 if ptr == 0: 

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

309 cdef _py_anon_pod3 obj = _py_anon_pod3.__new__(_py_anon_pod3) 

310 if owner is None: 

311 obj._ptr = <_anon_pod3 *>malloc(sizeof((<CUfileIOParams_t*>NULL).u.batch)) 

312 if obj._ptr == NULL: 

313 raise MemoryError("Error allocating _py_anon_pod3") 

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

315 obj._owner = None 

316 obj._owned = True 

317 else: 

318 obj._ptr = <_anon_pod3 *>ptr 

319 obj._owner = owner 

320 obj._owned = False 

321 obj._readonly = readonly 

322 return obj 

323  

324  

325cdef _get_io_events_dtype_offsets(): 

326 cdef CUfileIOEvents_t pod = CUfileIOEvents_t() 

327 return _numpy.dtype({ 

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

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

330 'offsets': [ 

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

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

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

334 ], 

335 'itemsize': sizeof(CUfileIOEvents_t), 

336 }) 

337  

338io_events_dtype = _get_io_events_dtype_offsets() 

339  

340cdef class IOEvents: 

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

342  

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

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

345  

346 Args: 

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

348  

349  

350 .. seealso:: `CUfileIOEvents_t` 

351 """ 

352 cdef: 

353 readonly object _data 

354  

355  

356  

357 def __init__(self, size=1): 

358 arr = _numpy.empty(size, dtype=io_events_dtype) 

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

360 assert self._data.itemsize == sizeof(CUfileIOEvents_t), \ 

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

362  

363 def __repr__(self): 

364 if self._data.size > 1: 

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

366 else: 

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

368  

369 @property 

370 def ptr(self): 

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

372 return self._data.ctypes.data 

373  

374 cdef intptr_t _get_ptr(self): 

375 return self._data.ctypes.data 

376  

377 def __int__(self): 

378 if self._data.size > 1: 

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

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

381 return self._data.ctypes.data 

382  

383 def __len__(self): 

384 return self._data.size 

385  

386 def __eq__(self, other): 

387 cdef object self_data = self._data 

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

389 return False 

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

391  

392 @property 

393 def cookie(self): 

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

395 if self._data.size == 1: 

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

397 return self._data.cookie 

398  

399 @cookie.setter 

400 def cookie(self, val): 

401 self._data.cookie = val 

402  

403 @property 

404 def status(self): 

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

406 if self._data.size == 1: 

407 return int(self._data.status[0]) 

408 return self._data.status 

409  

410 @status.setter 

411 def status(self, val): 

412 self._data.status = val 

413  

414 @property 

415 def ret(self): 

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

417 if self._data.size == 1: 

418 return int(self._data.ret[0]) 

419 return self._data.ret 

420  

421 @ret.setter 

422 def ret(self, val): 

423 self._data.ret = val 

424  

425 def __getitem__(self, key): 

426 cdef ssize_t key_ 

427 cdef ssize_t size 

428 if isinstance(key, int): 

429 key_ = key 

430 size = self._data.size 

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

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

433 if key_ < 0: 

434 key_ += size 

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

436 out = self._data[key] 

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

438 return IOEvents.from_data(out) 

439 return out 

440  

441 def __setitem__(self, key, val): 

442 self._data[key] = val 

443  

444 @staticmethod 

445 def from_data(data): 

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

447  

448 Args: 

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

450 """ 

451 cdef IOEvents obj = IOEvents.__new__(IOEvents) 

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

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

454 if data.ndim != 1: 

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

456 if data.dtype != io_events_dtype: 

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

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

459  

460 return obj 

461  

462 @staticmethod 

463 def from_ptr(intptr_t ptr, size_t size=1, bint readonly=False): 

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

465  

466 Args: 

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

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

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

470 """ 

471 if ptr == 0: 

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

473 cdef IOEvents obj = IOEvents.__new__(IOEvents) 

474 cdef flag = cpython.buffer.PyBUF_READ if readonly else cpython.buffer.PyBUF_WRITE 

475 cdef object buf = cpython.memoryview.PyMemoryView_FromMemory( 

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

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

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

479  

480 return obj 

481  

482  

483cdef _get_op_counter_dtype_offsets(): 

484 cdef CUfileOpCounter_t pod = CUfileOpCounter_t() 

485 return _numpy.dtype({ 

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

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

488 'offsets': [ 

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

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

491 ], 

492 'itemsize': sizeof(CUfileOpCounter_t), 

493 }) 

494  

495op_counter_dtype = _get_op_counter_dtype_offsets() 

496  

497cdef class OpCounter: 

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

499  

500  

501 .. seealso:: `CUfileOpCounter_t` 

502 """ 

503 cdef: 

504 CUfileOpCounter_t *_ptr 

505 object _owner 

506 bint _owned 

507 bint _readonly 

508  

509 def __init__(self): 

510 self._ptr = <CUfileOpCounter_t *>calloc(1, sizeof(CUfileOpCounter_t)) 

511 if self._ptr == NULL: 

512 raise MemoryError("Error allocating OpCounter") 

513 self._owner = None 

514 self._owned = True 

515 self._readonly = False 

516  

517 def __dealloc__(self): 

518 cdef CUfileOpCounter_t *ptr 

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

520 ptr = self._ptr 

521 self._ptr = NULL 

522 free(ptr) 

523  

524 def __repr__(self): 

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

526  

527 @property 

528 def ptr(self): 

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

530 return <intptr_t>(self._ptr) 

531  

532 cdef intptr_t _get_ptr(self): 

533 return <intptr_t>(self._ptr) 

534  

535 def __int__(self): 

536 return <intptr_t>(self._ptr) 

537  

538 def __eq__(self, other): 

539 cdef OpCounter other_ 

540 if not isinstance(other, OpCounter): 

541 return False 

542 other_ = other 

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

544  

545 def __setitem__(self, key, val): 

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

547 self._ptr = <CUfileOpCounter_t *>malloc(sizeof(CUfileOpCounter_t)) 

548 if self._ptr == NULL: 

549 raise MemoryError("Error allocating OpCounter") 

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

551 self._owner = None 

552 self._owned = True 

553 self._readonly = not val.flags.writeable 

554 else: 

555 setattr(self, key, val) 

556  

557 @property 

558 def ok(self): 

559 """int: """ 

560 return self._ptr[0].ok 

561  

562 @ok.setter 

563 def ok(self, val): 

564 if self._readonly: 

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

566 self._ptr[0].ok = val 

567  

568 @property 

569 def err(self): 

570 """int: """ 

571 return self._ptr[0].err 

572  

573 @err.setter 

574 def err(self, val): 

575 if self._readonly: 

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

577 self._ptr[0].err = val 

578  

579 @staticmethod 

580 def from_data(data): 

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

582  

583 Args: 

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

585 """ 

586 return __from_data(data, "op_counter_dtype", op_counter_dtype, OpCounter) 

587  

588 @staticmethod 

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

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

591  

592 Args: 

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

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

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

596 """ 

597 if ptr == 0: 

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

599 cdef OpCounter obj = OpCounter.__new__(OpCounter) 

600 if owner is None: 

601 obj._ptr = <CUfileOpCounter_t *>malloc(sizeof(CUfileOpCounter_t)) 

602 if obj._ptr == NULL: 

603 raise MemoryError("Error allocating OpCounter") 

604 memcpy(<void*>(obj._ptr), <void*>ptr, sizeof(CUfileOpCounter_t)) 

605 obj._owner = None 

606 obj._owned = True 

607 else: 

608 obj._ptr = <CUfileOpCounter_t *>ptr 

609 obj._owner = owner 

610 obj._owned = False 

611 obj._readonly = readonly 

612 return obj 

613  

614  

615cdef _get_per_gpu_stats_dtype_offsets(): 

616 cdef CUfilePerGpuStats_t pod = CUfilePerGpuStats_t() 

617 return _numpy.dtype({ 

618 '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'], 

619 'formats': [_numpy.int8, _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], 

620 'offsets': [ 

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

651 ], 

652 'itemsize': sizeof(CUfilePerGpuStats_t), 

653 }) 

654  

655per_gpu_stats_dtype = _get_per_gpu_stats_dtype_offsets() 

656  

657cdef class PerGpuStats: 

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

659  

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

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

662  

663 Args: 

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

665  

666  

667 .. seealso:: `CUfilePerGpuStats_t` 

668 """ 

669 cdef: 

670 readonly object _data 

671  

672  

673  

674 def __init__(self, size=1): 

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

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

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

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

679  

680 def __repr__(self): 

681 if self._data.size > 1: 

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

683 else: 

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

685  

686 @property 

687 def ptr(self): 

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

689 return self._data.ctypes.data 

690  

691 cdef intptr_t _get_ptr(self): 

692 return self._data.ctypes.data 

693  

694 def __int__(self): 

695 if self._data.size > 1: 

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

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

698 return self._data.ctypes.data 

699  

700 def __len__(self): 

701 return self._data.size 

702  

703 def __eq__(self, other): 

704 cdef object self_data = self._data 

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

706 return False 

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

708  

709 @property 

710 def uuid(self): 

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

712 return self._data.uuid 

713  

714 @uuid.setter 

715 def uuid(self, val): 

716 self._data.uuid = val 

717  

718 @property 

719 def read_bytes(self): 

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

721 if self._data.size == 1: 

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

723 return self._data.read_bytes 

724  

725 @read_bytes.setter 

726 def read_bytes(self, val): 

727 self._data.read_bytes = val 

728  

729 @property 

730 def read_bw_bytes_per_sec(self): 

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

732 if self._data.size == 1: 

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

734 return self._data.read_bw_bytes_per_sec 

735  

736 @read_bw_bytes_per_sec.setter 

737 def read_bw_bytes_per_sec(self, val): 

738 self._data.read_bw_bytes_per_sec = val 

739  

740 @property 

741 def read_utilization(self): 

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

743 if self._data.size == 1: 

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

745 return self._data.read_utilization 

746  

747 @read_utilization.setter 

748 def read_utilization(self, val): 

749 self._data.read_utilization = val 

750  

751 @property 

752 def read_duration_us(self): 

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

754 if self._data.size == 1: 

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

756 return self._data.read_duration_us 

757  

758 @read_duration_us.setter 

759 def read_duration_us(self, val): 

760 self._data.read_duration_us = val 

761  

762 @property 

763 def n_total_reads(self): 

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

765 if self._data.size == 1: 

766 return int(self._data.n_total_reads[0]) 

767 return self._data.n_total_reads 

768  

769 @n_total_reads.setter 

770 def n_total_reads(self, val): 

771 self._data.n_total_reads = val 

772  

773 @property 

774 def n_p2p_reads(self): 

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

776 if self._data.size == 1: 

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

778 return self._data.n_p2p_reads 

779  

780 @n_p2p_reads.setter 

781 def n_p2p_reads(self, val): 

782 self._data.n_p2p_reads = val 

783  

784 @property 

785 def n_nvfs_reads(self): 

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

787 if self._data.size == 1: 

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

789 return self._data.n_nvfs_reads 

790  

791 @n_nvfs_reads.setter 

792 def n_nvfs_reads(self, val): 

793 self._data.n_nvfs_reads = val 

794  

795 @property 

796 def n_posix_reads(self): 

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

798 if self._data.size == 1: 

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

800 return self._data.n_posix_reads 

801  

802 @n_posix_reads.setter 

803 def n_posix_reads(self, val): 

804 self._data.n_posix_reads = val 

805  

806 @property 

807 def n_unaligned_reads(self): 

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

809 if self._data.size == 1: 

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

811 return self._data.n_unaligned_reads 

812  

813 @n_unaligned_reads.setter 

814 def n_unaligned_reads(self, val): 

815 self._data.n_unaligned_reads = val 

816  

817 @property 

818 def n_dr_reads(self): 

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

820 if self._data.size == 1: 

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

822 return self._data.n_dr_reads 

823  

824 @n_dr_reads.setter 

825 def n_dr_reads(self, val): 

826 self._data.n_dr_reads = val 

827  

828 @property 

829 def n_sparse_regions(self): 

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

831 if self._data.size == 1: 

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

833 return self._data.n_sparse_regions 

834  

835 @n_sparse_regions.setter 

836 def n_sparse_regions(self, val): 

837 self._data.n_sparse_regions = val 

838  

839 @property 

840 def n_inline_regions(self): 

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

842 if self._data.size == 1: 

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

844 return self._data.n_inline_regions 

845  

846 @n_inline_regions.setter 

847 def n_inline_regions(self, val): 

848 self._data.n_inline_regions = val 

849  

850 @property 

851 def n_reads_err(self): 

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

853 if self._data.size == 1: 

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

855 return self._data.n_reads_err 

856  

857 @n_reads_err.setter 

858 def n_reads_err(self, val): 

859 self._data.n_reads_err = val 

860  

861 @property 

862 def writes_bytes(self): 

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

864 if self._data.size == 1: 

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

866 return self._data.writes_bytes 

867  

868 @writes_bytes.setter 

869 def writes_bytes(self, val): 

870 self._data.writes_bytes = val 

871  

872 @property 

873 def write_bw_bytes_per_sec(self): 

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

875 if self._data.size == 1: 

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

877 return self._data.write_bw_bytes_per_sec 

878  

879 @write_bw_bytes_per_sec.setter 

880 def write_bw_bytes_per_sec(self, val): 

881 self._data.write_bw_bytes_per_sec = val 

882  

883 @property 

884 def write_utilization(self): 

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

886 if self._data.size == 1: 

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

888 return self._data.write_utilization 

889  

890 @write_utilization.setter 

891 def write_utilization(self, val): 

892 self._data.write_utilization = val 

893  

894 @property 

895 def write_duration_us(self): 

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

897 if self._data.size == 1: 

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

899 return self._data.write_duration_us 

900  

901 @write_duration_us.setter 

902 def write_duration_us(self, val): 

903 self._data.write_duration_us = val 

904  

905 @property 

906 def n_total_writes(self): 

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

908 if self._data.size == 1: 

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

910 return self._data.n_total_writes 

911  

912 @n_total_writes.setter 

913 def n_total_writes(self, val): 

914 self._data.n_total_writes = val 

915  

916 @property 

917 def n_p2p_writes(self): 

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

919 if self._data.size == 1: 

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

921 return self._data.n_p2p_writes 

922  

923 @n_p2p_writes.setter 

924 def n_p2p_writes(self, val): 

925 self._data.n_p2p_writes = val 

926  

927 @property 

928 def n_nvfs_writes(self): 

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

930 if self._data.size == 1: 

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

932 return self._data.n_nvfs_writes 

933  

934 @n_nvfs_writes.setter 

935 def n_nvfs_writes(self, val): 

936 self._data.n_nvfs_writes = val 

937  

938 @property 

939 def n_posix_writes(self): 

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

941 if self._data.size == 1: 

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

943 return self._data.n_posix_writes 

944  

945 @n_posix_writes.setter 

946 def n_posix_writes(self, val): 

947 self._data.n_posix_writes = val 

948  

949 @property 

950 def n_unaligned_writes(self): 

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

952 if self._data.size == 1: 

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

954 return self._data.n_unaligned_writes 

955  

956 @n_unaligned_writes.setter 

957 def n_unaligned_writes(self, val): 

958 self._data.n_unaligned_writes = val 

959  

960 @property 

961 def n_dr_writes(self): 

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

963 if self._data.size == 1: 

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

965 return self._data.n_dr_writes 

966  

967 @n_dr_writes.setter 

968 def n_dr_writes(self, val): 

969 self._data.n_dr_writes = val 

970  

971 @property 

972 def n_writes_err(self): 

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

974 if self._data.size == 1: 

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

976 return self._data.n_writes_err 

977  

978 @n_writes_err.setter 

979 def n_writes_err(self, val): 

980 self._data.n_writes_err = val 

981  

982 @property 

983 def n_mmap(self): 

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

985 if self._data.size == 1: 

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

987 return self._data.n_mmap 

988  

989 @n_mmap.setter 

990 def n_mmap(self, val): 

991 self._data.n_mmap = val 

992  

993 @property 

994 def n_mmap_ok(self): 

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

996 if self._data.size == 1: 

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

998 return self._data.n_mmap_ok 

999  

1000 @n_mmap_ok.setter 

1001 def n_mmap_ok(self, val): 

1002 self._data.n_mmap_ok = val 

1003  

1004 @property 

1005 def n_mmap_err(self): 

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

1007 if self._data.size == 1: 

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

1009 return self._data.n_mmap_err 

1010  

1011 @n_mmap_err.setter 

1012 def n_mmap_err(self, val): 

1013 self._data.n_mmap_err = val 

1014  

1015 @property 

1016 def n_mmap_free(self): 

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

1018 if self._data.size == 1: 

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

1020 return self._data.n_mmap_free 

1021  

1022 @n_mmap_free.setter 

1023 def n_mmap_free(self, val): 

1024 self._data.n_mmap_free = val 

1025  

1026 @property 

1027 def reg_bytes(self): 

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

1029 if self._data.size == 1: 

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

1031 return self._data.reg_bytes 

1032  

1033 @reg_bytes.setter 

1034 def reg_bytes(self, val): 

1035 self._data.reg_bytes = val 

1036  

1037 def __getitem__(self, key): 

1038 cdef ssize_t key_ 

1039 cdef ssize_t size 

1040 if isinstance(key, int): 

1041 key_ = key 

1042 size = self._data.size 

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

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

1045 if key_ < 0: 

1046 key_ += size 

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

1048 out = self._data[key] 

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

1050 return PerGpuStats.from_data(out) 

1051 return out 

1052  

1053 def __setitem__(self, key, val): 

1054 self._data[key] = val 

1055  

1056 @staticmethod 

1057 def from_data(data): 

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

1059  

1060 Args: 

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

1062 """ 

1063 cdef PerGpuStats obj = PerGpuStats.__new__(PerGpuStats) 

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

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

1066 if data.ndim != 1: 

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

1068 if data.dtype != per_gpu_stats_dtype: 

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

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

1071  

1072 return obj 

1073  

1074 @staticmethod 

1075 def from_ptr(intptr_t ptr, size_t size=1, bint readonly=False): 

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

1077  

1078 Args: 

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

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

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

1082 """ 

1083 if ptr == 0: 

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

1085 cdef PerGpuStats obj = PerGpuStats.__new__(PerGpuStats) 

1086 cdef flag = cpython.buffer.PyBUF_READ if readonly else cpython.buffer.PyBUF_WRITE 

1087 cdef object buf = cpython.memoryview.PyMemoryView_FromMemory( 

1088 <char*>ptr, sizeof(CUfilePerGpuStats_t) * size, flag) 

1089 data = _numpy.ndarray(size, buffer=buf, dtype=per_gpu_stats_dtype) 

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

1091  

1092 return obj 

1093  

1094  

1095cdef _get_descr_dtype_offsets(): 

1096 cdef CUfileDescr_t pod = CUfileDescr_t() 

1097 return _numpy.dtype({ 

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

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

1100 'offsets': [ 

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

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

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

1104 ], 

1105 'itemsize': sizeof(CUfileDescr_t), 

1106 }) 

1107  

1108descr_dtype = _get_descr_dtype_offsets() 

1109  

1110cdef class Descr: 

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

1112  

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

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

1115  

1116 Args: 

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

1118  

1119  

1120 .. seealso:: `CUfileDescr_t` 

1121 """ 

1122 cdef: 

1123 readonly object _data 

1124  

1125  

1126  

1127 def __init__(self, size=1): 

1128 arr = _numpy.empty(size, dtype=descr_dtype) 

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

1130 assert self._data.itemsize == sizeof(CUfileDescr_t), \ 

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

1132  

1133 def __repr__(self): 

1134 if self._data.size > 1: 

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

1136 else: 

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

1138  

1139 @property 

1140 def ptr(self): 

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

1142 return self._data.ctypes.data 

1143  

1144 cdef intptr_t _get_ptr(self): 

1145 return self._data.ctypes.data 

1146  

1147 def __int__(self): 

1148 if self._data.size > 1: 

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

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

1151 return self._data.ctypes.data 

1152  

1153 def __len__(self): 

1154 return self._data.size 

1155  

1156 def __eq__(self, other): 

1157 cdef object self_data = self._data 

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

1159 return False 

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

1161  

1162 @property 

1163 def type(self): 

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

1165 if self._data.size == 1: 

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

1167 return self._data.type 

1168  

1169 @type.setter 

1170 def type(self, val): 

1171 self._data.type = val 

1172  

1173 @property 

1174 def handle(self): 

1175 """_py_anon_pod1_dtype: """ 

1176 return self._data.handle 

1177  

1178 @handle.setter 

1179 def handle(self, val): 

1180 self._data.handle = val 

1181  

1182 @property 

1183 def fs_ops(self): 

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

1185 if self._data.size == 1: 

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

1187 return self._data.fs_ops 

1188  

1189 @fs_ops.setter 

1190 def fs_ops(self, val): 

1191 self._data.fs_ops = val 

1192  

1193 def __getitem__(self, key): 

1194 cdef ssize_t key_ 

1195 cdef ssize_t size 

1196 if isinstance(key, int): 

1197 key_ = key 

1198 size = self._data.size 

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

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

1201 if key_ < 0: 

1202 key_ += size 

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

1204 out = self._data[key] 

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

1206 return Descr.from_data(out) 

1207 return out 

1208  

1209 def __setitem__(self, key, val): 

1210 self._data[key] = val 

1211  

1212 @staticmethod 

1213 def from_data(data): 

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

1215  

1216 Args: 

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

1218 """ 

1219 cdef Descr obj = Descr.__new__(Descr) 

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

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

1222 if data.ndim != 1: 

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

1224 if data.dtype != descr_dtype: 

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

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

1227  

1228 return obj 

1229  

1230 @staticmethod 

1231 def from_ptr(intptr_t ptr, size_t size=1, bint readonly=False): 

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

1233  

1234 Args: 

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

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

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

1238 """ 

1239 if ptr == 0: 

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

1241 cdef Descr obj = Descr.__new__(Descr) 

1242 cdef flag = cpython.buffer.PyBUF_READ if readonly else cpython.buffer.PyBUF_WRITE 

1243 cdef object buf = cpython.memoryview.PyMemoryView_FromMemory( 

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

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

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

1247  

1248 return obj 

1249  

1250  

1251_py_anon_pod2_dtype = _numpy.dtype(( 

1252 _numpy.dtype((_numpy.void, sizeof((<CUfileIOParams_t*>NULL).u))), 

1253 { 

1254 "batch": (_py_anon_pod3_dtype, 0), 

1255 } 

1256 )) 

1257  

1258  

1259cdef class _py_anon_pod2: 

1260 """Empty-initialize an instance of `_anon_pod2`. 

1261  

1262  

1263 .. seealso:: `_anon_pod2` 

1264 """ 

1265 cdef: 

1266 _anon_pod2 *_ptr 

1267 object _owner 

1268 bint _owned 

1269 bint _readonly 

1270  

1271 def __init__(self): 

1272 self._ptr = <_anon_pod2 *>calloc(1, sizeof((<CUfileIOParams_t*>NULL).u)) 

1273 if self._ptr == NULL: 

1274 raise MemoryError("Error allocating _py_anon_pod2") 

1275 self._owner = None 

1276 self._owned = True 

1277 self._readonly = False 

1278  

1279 def __dealloc__(self): 

1280 cdef _anon_pod2 *ptr 

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

1282 ptr = self._ptr 

1283 self._ptr = NULL 

1284 free(ptr) 

1285  

1286 def __repr__(self): 

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

1288  

1289 @property 

1290 def ptr(self): 

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

1292 return <intptr_t>(self._ptr) 

1293  

1294 cdef intptr_t _get_ptr(self): 

1295 return <intptr_t>(self._ptr) 

1296  

1297 def __int__(self): 

1298 return <intptr_t>(self._ptr) 

1299  

1300 def __eq__(self, other): 

1301 cdef _py_anon_pod2 other_ 

1302 if not isinstance(other, _py_anon_pod2): 

1303 return False 

1304 other_ = other 

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

1306  

1307 def __setitem__(self, key, val): 

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

1309 self._ptr = <_anon_pod2 *>malloc(sizeof((<CUfileIOParams_t*>NULL).u)) 

1310 if self._ptr == NULL: 

1311 raise MemoryError("Error allocating _py_anon_pod2") 

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

1313 self._owner = None 

1314 self._owned = True 

1315 self._readonly = not val.flags.writeable 

1316 else: 

1317 setattr(self, key, val) 

1318  

1319 @property 

1320 def batch(self): 

1321 """_py_anon_pod3: """ 

1322 return _py_anon_pod3.from_ptr(<intptr_t>&(self._ptr[0].batch), self._readonly, self) 

1323  

1324 @batch.setter 

1325 def batch(self, val): 

1326 if self._readonly: 

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

1328 cdef _py_anon_pod3 val_ = val 

1329 memcpy(<void *>&(self._ptr[0].batch), <void *>(val_._get_ptr()), sizeof(_anon_pod3) * 1) 

1330  

1331 @staticmethod 

1332 def from_data(data): 

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

1334  

1335 Args: 

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

1337 """ 

1338 return __from_data(data, "_py_anon_pod2_dtype", _py_anon_pod2_dtype, _py_anon_pod2) 

1339  

1340 @staticmethod 

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

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

1343  

1344 Args: 

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

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

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

1348 """ 

1349 if ptr == 0: 

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

1351 cdef _py_anon_pod2 obj = _py_anon_pod2.__new__(_py_anon_pod2) 

1352 if owner is None: 

1353 obj._ptr = <_anon_pod2 *>malloc(sizeof((<CUfileIOParams_t*>NULL).u)) 

1354 if obj._ptr == NULL: 

1355 raise MemoryError("Error allocating _py_anon_pod2") 

1356 memcpy(<void*>(obj._ptr), <void*>ptr, sizeof((<CUfileIOParams_t*>NULL).u)) 

1357 obj._owner = None 

1358 obj._owned = True 

1359 else: 

1360 obj._ptr = <_anon_pod2 *>ptr 

1361 obj._owner = owner 

1362 obj._owned = False 

1363 obj._readonly = readonly 

1364 return obj 

1365  

1366  

1367cdef _get_stats_level1_dtype_offsets(): 

1368 cdef CUfileStatsLevel1_t pod = CUfileStatsLevel1_t() 

1369 return _numpy.dtype({ 

1370 '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'], 

1371 '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], 

1372 'offsets': [ 

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1416 ], 

1417 'itemsize': sizeof(CUfileStatsLevel1_t), 

1418 }) 

1419  

1420stats_level1_dtype = _get_stats_level1_dtype_offsets() 

1421  

1422cdef class StatsLevel1: 

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

1424  

1425  

1426 .. seealso:: `CUfileStatsLevel1_t` 

1427 """ 

1428 cdef: 

1429 CUfileStatsLevel1_t *_ptr 

1430 object _owner 

1431 bint _owned 

1432 bint _readonly 

1433  

1434 def __init__(self): 

1435 self._ptr = <CUfileStatsLevel1_t *>calloc(1, sizeof(CUfileStatsLevel1_t)) 

1436 if self._ptr == NULL: 

1437 raise MemoryError("Error allocating StatsLevel1") 

1438 self._owner = None 

1439 self._owned = True 

1440 self._readonly = False 

1441  

1442 def __dealloc__(self): 

1443 cdef CUfileStatsLevel1_t *ptr 

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

1445 ptr = self._ptr 

1446 self._ptr = NULL 

1447 free(ptr) 

1448  

1449 def __repr__(self): 

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

1451  

1452 @property 

1453 def ptr(self): 

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

1455 return <intptr_t>(self._ptr) 

1456  

1457 cdef intptr_t _get_ptr(self): 

1458 return <intptr_t>(self._ptr) 

1459  

1460 def __int__(self): 

1461 return <intptr_t>(self._ptr) 

1462  

1463 def __eq__(self, other): 

1464 cdef StatsLevel1 other_ 

1465 if not isinstance(other, StatsLevel1): 

1466 return False 

1467 other_ = other 

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

1469  

1470 def __setitem__(self, key, val): 

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

1472 self._ptr = <CUfileStatsLevel1_t *>malloc(sizeof(CUfileStatsLevel1_t)) 

1473 if self._ptr == NULL: 

1474 raise MemoryError("Error allocating StatsLevel1") 

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

1476 self._owner = None 

1477 self._owned = True 

1478 self._readonly = not val.flags.writeable 

1479 else: 

1480 setattr(self, key, val) 

1481  

1482 @property 

1483 def read_ops(self): 

1484 """OpCounter: """ 

1485 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].read_ops), self._readonly, self) 

1486  

1487 @read_ops.setter 

1488 def read_ops(self, val): 

1489 if self._readonly: 

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

1491 cdef OpCounter val_ = val 

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

1493  

1494 @property 

1495 def write_ops(self): 

1496 """OpCounter: """ 

1497 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].write_ops), self._readonly, self) 

1498  

1499 @write_ops.setter 

1500 def write_ops(self, val): 

1501 if self._readonly: 

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

1503 cdef OpCounter val_ = val 

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

1505  

1506 @property 

1507 def hdl_register_ops(self): 

1508 """OpCounter: """ 

1509 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].hdl_register_ops), self._readonly, self) 

1510  

1511 @hdl_register_ops.setter 

1512 def hdl_register_ops(self, val): 

1513 if self._readonly: 

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

1515 cdef OpCounter val_ = val 

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

1517  

1518 @property 

1519 def hdl_deregister_ops(self): 

1520 """OpCounter: """ 

1521 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].hdl_deregister_ops), self._readonly, self) 

1522  

1523 @hdl_deregister_ops.setter 

1524 def hdl_deregister_ops(self, val): 

1525 if self._readonly: 

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

1527 cdef OpCounter val_ = val 

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

1529  

1530 @property 

1531 def buf_register_ops(self): 

1532 """OpCounter: """ 

1533 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].buf_register_ops), self._readonly, self) 

1534  

1535 @buf_register_ops.setter 

1536 def buf_register_ops(self, val): 

1537 if self._readonly: 

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

1539 cdef OpCounter val_ = val 

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

1541  

1542 @property 

1543 def buf_deregister_ops(self): 

1544 """OpCounter: """ 

1545 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].buf_deregister_ops), self._readonly, self) 

1546  

1547 @buf_deregister_ops.setter 

1548 def buf_deregister_ops(self, val): 

1549 if self._readonly: 

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

1551 cdef OpCounter val_ = val 

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

1553  

1554 @property 

1555 def batch_submit_ops(self): 

1556 """OpCounter: """ 

1557 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_submit_ops), self._readonly, self) 

1558  

1559 @batch_submit_ops.setter 

1560 def batch_submit_ops(self, val): 

1561 if self._readonly: 

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

1563 cdef OpCounter val_ = val 

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

1565  

1566 @property 

1567 def batch_complete_ops(self): 

1568 """OpCounter: """ 

1569 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_complete_ops), self._readonly, self) 

1570  

1571 @batch_complete_ops.setter 

1572 def batch_complete_ops(self, val): 

1573 if self._readonly: 

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

1575 cdef OpCounter val_ = val 

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

1577  

1578 @property 

1579 def batch_setup_ops(self): 

1580 """OpCounter: """ 

1581 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_setup_ops), self._readonly, self) 

1582  

1583 @batch_setup_ops.setter 

1584 def batch_setup_ops(self, val): 

1585 if self._readonly: 

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

1587 cdef OpCounter val_ = val 

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

1589  

1590 @property 

1591 def batch_cancel_ops(self): 

1592 """OpCounter: """ 

1593 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_cancel_ops), self._readonly, self) 

1594  

1595 @batch_cancel_ops.setter 

1596 def batch_cancel_ops(self, val): 

1597 if self._readonly: 

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

1599 cdef OpCounter val_ = val 

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

1601  

1602 @property 

1603 def batch_destroy_ops(self): 

1604 """OpCounter: """ 

1605 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_destroy_ops), self._readonly, self) 

1606  

1607 @batch_destroy_ops.setter 

1608 def batch_destroy_ops(self, val): 

1609 if self._readonly: 

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

1611 cdef OpCounter val_ = val 

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

1613  

1614 @property 

1615 def batch_enqueued_ops(self): 

1616 """OpCounter: """ 

1617 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_enqueued_ops), self._readonly, self) 

1618  

1619 @batch_enqueued_ops.setter 

1620 def batch_enqueued_ops(self, val): 

1621 if self._readonly: 

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

1623 cdef OpCounter val_ = val 

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

1625  

1626 @property 

1627 def batch_posix_enqueued_ops(self): 

1628 """OpCounter: """ 

1629 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_posix_enqueued_ops), self._readonly, self) 

1630  

1631 @batch_posix_enqueued_ops.setter 

1632 def batch_posix_enqueued_ops(self, val): 

1633 if self._readonly: 

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

1635 cdef OpCounter val_ = val 

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

1637  

1638 @property 

1639 def batch_processed_ops(self): 

1640 """OpCounter: """ 

1641 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_processed_ops), self._readonly, self) 

1642  

1643 @batch_processed_ops.setter 

1644 def batch_processed_ops(self, val): 

1645 if self._readonly: 

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

1647 cdef OpCounter val_ = val 

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

1649  

1650 @property 

1651 def batch_posix_processed_ops(self): 

1652 """OpCounter: """ 

1653 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_posix_processed_ops), self._readonly, self) 

1654  

1655 @batch_posix_processed_ops.setter 

1656 def batch_posix_processed_ops(self, val): 

1657 if self._readonly: 

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

1659 cdef OpCounter val_ = val 

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

1661  

1662 @property 

1663 def batch_nvfs_submit_ops(self): 

1664 """OpCounter: """ 

1665 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_nvfs_submit_ops), self._readonly, self) 

1666  

1667 @batch_nvfs_submit_ops.setter 

1668 def batch_nvfs_submit_ops(self, val): 

1669 if self._readonly: 

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

1671 cdef OpCounter val_ = val 

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

1673  

1674 @property 

1675 def batch_p2p_submit_ops(self): 

1676 """OpCounter: """ 

1677 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_p2p_submit_ops), self._readonly, self) 

1678  

1679 @batch_p2p_submit_ops.setter 

1680 def batch_p2p_submit_ops(self, val): 

1681 if self._readonly: 

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

1683 cdef OpCounter val_ = val 

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

1685  

1686 @property 

1687 def batch_aio_submit_ops(self): 

1688 """OpCounter: """ 

1689 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_aio_submit_ops), self._readonly, self) 

1690  

1691 @batch_aio_submit_ops.setter 

1692 def batch_aio_submit_ops(self, val): 

1693 if self._readonly: 

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

1695 cdef OpCounter val_ = val 

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

1697  

1698 @property 

1699 def batch_iouring_submit_ops(self): 

1700 """OpCounter: """ 

1701 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_iouring_submit_ops), self._readonly, self) 

1702  

1703 @batch_iouring_submit_ops.setter 

1704 def batch_iouring_submit_ops(self, val): 

1705 if self._readonly: 

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

1707 cdef OpCounter val_ = val 

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

1709  

1710 @property 

1711 def batch_mixed_io_submit_ops(self): 

1712 """OpCounter: """ 

1713 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_mixed_io_submit_ops), self._readonly, self) 

1714  

1715 @batch_mixed_io_submit_ops.setter 

1716 def batch_mixed_io_submit_ops(self, val): 

1717 if self._readonly: 

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

1719 cdef OpCounter val_ = val 

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

1721  

1722 @property 

1723 def batch_total_submit_ops(self): 

1724 """OpCounter: """ 

1725 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_total_submit_ops), self._readonly, self) 

1726  

1727 @batch_total_submit_ops.setter 

1728 def batch_total_submit_ops(self, val): 

1729 if self._readonly: 

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

1731 cdef OpCounter val_ = val 

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

1733  

1734 @property 

1735 def read_bytes(self): 

1736 """int: """ 

1737 return self._ptr[0].read_bytes 

1738  

1739 @read_bytes.setter 

1740 def read_bytes(self, val): 

1741 if self._readonly: 

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

1743 self._ptr[0].read_bytes = val 

1744  

1745 @property 

1746 def write_bytes(self): 

1747 """int: """ 

1748 return self._ptr[0].write_bytes 

1749  

1750 @write_bytes.setter 

1751 def write_bytes(self, val): 

1752 if self._readonly: 

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

1754 self._ptr[0].write_bytes = val 

1755  

1756 @property 

1757 def read_bw_bytes_per_sec(self): 

1758 """int: """ 

1759 return self._ptr[0].read_bw_bytes_per_sec 

1760  

1761 @read_bw_bytes_per_sec.setter 

1762 def read_bw_bytes_per_sec(self, val): 

1763 if self._readonly: 

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

1765 self._ptr[0].read_bw_bytes_per_sec = val 

1766  

1767 @property 

1768 def write_bw_bytes_per_sec(self): 

1769 """int: """ 

1770 return self._ptr[0].write_bw_bytes_per_sec 

1771  

1772 @write_bw_bytes_per_sec.setter 

1773 def write_bw_bytes_per_sec(self, val): 

1774 if self._readonly: 

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

1776 self._ptr[0].write_bw_bytes_per_sec = val 

1777  

1778 @property 

1779 def read_lat_avg_us(self): 

1780 """int: """ 

1781 return self._ptr[0].read_lat_avg_us 

1782  

1783 @read_lat_avg_us.setter 

1784 def read_lat_avg_us(self, val): 

1785 if self._readonly: 

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

1787 self._ptr[0].read_lat_avg_us = val 

1788  

1789 @property 

1790 def write_lat_avg_us(self): 

1791 """int: """ 

1792 return self._ptr[0].write_lat_avg_us 

1793  

1794 @write_lat_avg_us.setter 

1795 def write_lat_avg_us(self, val): 

1796 if self._readonly: 

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

1798 self._ptr[0].write_lat_avg_us = val 

1799  

1800 @property 

1801 def read_ops_per_sec(self): 

1802 """int: """ 

1803 return self._ptr[0].read_ops_per_sec 

1804  

1805 @read_ops_per_sec.setter 

1806 def read_ops_per_sec(self, val): 

1807 if self._readonly: 

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

1809 self._ptr[0].read_ops_per_sec = val 

1810  

1811 @property 

1812 def write_ops_per_sec(self): 

1813 """int: """ 

1814 return self._ptr[0].write_ops_per_sec 

1815  

1816 @write_ops_per_sec.setter 

1817 def write_ops_per_sec(self, val): 

1818 if self._readonly: 

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

1820 self._ptr[0].write_ops_per_sec = val 

1821  

1822 @property 

1823 def read_lat_sum_us(self): 

1824 """int: """ 

1825 return self._ptr[0].read_lat_sum_us 

1826  

1827 @read_lat_sum_us.setter 

1828 def read_lat_sum_us(self, val): 

1829 if self._readonly: 

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

1831 self._ptr[0].read_lat_sum_us = val 

1832  

1833 @property 

1834 def write_lat_sum_us(self): 

1835 """int: """ 

1836 return self._ptr[0].write_lat_sum_us 

1837  

1838 @write_lat_sum_us.setter 

1839 def write_lat_sum_us(self, val): 

1840 if self._readonly: 

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

1842 self._ptr[0].write_lat_sum_us = val 

1843  

1844 @property 

1845 def batch_read_bytes(self): 

1846 """int: """ 

1847 return self._ptr[0].batch_read_bytes 

1848  

1849 @batch_read_bytes.setter 

1850 def batch_read_bytes(self, val): 

1851 if self._readonly: 

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

1853 self._ptr[0].batch_read_bytes = val 

1854  

1855 @property 

1856 def batch_write_bytes(self): 

1857 """int: """ 

1858 return self._ptr[0].batch_write_bytes 

1859  

1860 @batch_write_bytes.setter 

1861 def batch_write_bytes(self, val): 

1862 if self._readonly: 

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

1864 self._ptr[0].batch_write_bytes = val 

1865  

1866 @property 

1867 def batch_read_bw_bytes(self): 

1868 """int: """ 

1869 return self._ptr[0].batch_read_bw_bytes 

1870  

1871 @batch_read_bw_bytes.setter 

1872 def batch_read_bw_bytes(self, val): 

1873 if self._readonly: 

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

1875 self._ptr[0].batch_read_bw_bytes = val 

1876  

1877 @property 

1878 def batch_write_bw_bytes(self): 

1879 """int: """ 

1880 return self._ptr[0].batch_write_bw_bytes 

1881  

1882 @batch_write_bw_bytes.setter 

1883 def batch_write_bw_bytes(self, val): 

1884 if self._readonly: 

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

1886 self._ptr[0].batch_write_bw_bytes = val 

1887  

1888 @property 

1889 def batch_submit_lat_avg_us(self): 

1890 """int: """ 

1891 return self._ptr[0].batch_submit_lat_avg_us 

1892  

1893 @batch_submit_lat_avg_us.setter 

1894 def batch_submit_lat_avg_us(self, val): 

1895 if self._readonly: 

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

1897 self._ptr[0].batch_submit_lat_avg_us = val 

1898  

1899 @property 

1900 def batch_completion_lat_avg_us(self): 

1901 """int: """ 

1902 return self._ptr[0].batch_completion_lat_avg_us 

1903  

1904 @batch_completion_lat_avg_us.setter 

1905 def batch_completion_lat_avg_us(self, val): 

1906 if self._readonly: 

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

1908 self._ptr[0].batch_completion_lat_avg_us = val 

1909  

1910 @property 

1911 def batch_submit_ops_per_sec(self): 

1912 """int: """ 

1913 return self._ptr[0].batch_submit_ops_per_sec 

1914  

1915 @batch_submit_ops_per_sec.setter 

1916 def batch_submit_ops_per_sec(self, val): 

1917 if self._readonly: 

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

1919 self._ptr[0].batch_submit_ops_per_sec = val 

1920  

1921 @property 

1922 def batch_complete_ops_per_sec(self): 

1923 """int: """ 

1924 return self._ptr[0].batch_complete_ops_per_sec 

1925  

1926 @batch_complete_ops_per_sec.setter 

1927 def batch_complete_ops_per_sec(self, val): 

1928 if self._readonly: 

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

1930 self._ptr[0].batch_complete_ops_per_sec = val 

1931  

1932 @property 

1933 def batch_submit_lat_sum_us(self): 

1934 """int: """ 

1935 return self._ptr[0].batch_submit_lat_sum_us 

1936  

1937 @batch_submit_lat_sum_us.setter 

1938 def batch_submit_lat_sum_us(self, val): 

1939 if self._readonly: 

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

1941 self._ptr[0].batch_submit_lat_sum_us = val 

1942  

1943 @property 

1944 def batch_completion_lat_sum_us(self): 

1945 """int: """ 

1946 return self._ptr[0].batch_completion_lat_sum_us 

1947  

1948 @batch_completion_lat_sum_us.setter 

1949 def batch_completion_lat_sum_us(self, val): 

1950 if self._readonly: 

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

1952 self._ptr[0].batch_completion_lat_sum_us = val 

1953  

1954 @property 

1955 def last_batch_read_bytes(self): 

1956 """int: """ 

1957 return self._ptr[0].last_batch_read_bytes 

1958  

1959 @last_batch_read_bytes.setter 

1960 def last_batch_read_bytes(self, val): 

1961 if self._readonly: 

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

1963 self._ptr[0].last_batch_read_bytes = val 

1964  

1965 @property 

1966 def last_batch_write_bytes(self): 

1967 """int: """ 

1968 return self._ptr[0].last_batch_write_bytes 

1969  

1970 @last_batch_write_bytes.setter 

1971 def last_batch_write_bytes(self, val): 

1972 if self._readonly: 

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

1974 self._ptr[0].last_batch_write_bytes = val 

1975  

1976 @staticmethod 

1977 def from_data(data): 

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

1979  

1980 Args: 

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

1982 """ 

1983 return __from_data(data, "stats_level1_dtype", stats_level1_dtype, StatsLevel1) 

1984  

1985 @staticmethod 

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

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

1988  

1989 Args: 

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

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

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

1993 """ 

1994 if ptr == 0: 

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

1996 cdef StatsLevel1 obj = StatsLevel1.__new__(StatsLevel1) 

1997 if owner is None: 

1998 obj._ptr = <CUfileStatsLevel1_t *>malloc(sizeof(CUfileStatsLevel1_t)) 

1999 if obj._ptr == NULL: 

2000 raise MemoryError("Error allocating StatsLevel1") 

2001 memcpy(<void*>(obj._ptr), <void*>ptr, sizeof(CUfileStatsLevel1_t)) 

2002 obj._owner = None 

2003 obj._owned = True 

2004 else: 

2005 obj._ptr = <CUfileStatsLevel1_t *>ptr 

2006 obj._owner = owner 

2007 obj._owned = False 

2008 obj._readonly = readonly 

2009 return obj 

2010  

2011  

2012cdef _get_io_params_dtype_offsets(): 

2013 cdef CUfileIOParams_t pod = CUfileIOParams_t() 

2014 return _numpy.dtype({ 

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

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

2017 'offsets': [ 

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

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

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

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

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

2023 ], 

2024 'itemsize': sizeof(CUfileIOParams_t), 

2025 }) 

2026  

2027io_params_dtype = _get_io_params_dtype_offsets() 

2028  

2029cdef class IOParams: 

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

2031  

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

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

2034  

2035 Args: 

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

2037  

2038  

2039 .. seealso:: `CUfileIOParams_t` 

2040 """ 

2041 cdef: 

2042 readonly object _data 

2043  

2044  

2045  

2046 def __init__(self, size=1): 

2047 arr = _numpy.empty(size, dtype=io_params_dtype) 

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

2049 assert self._data.itemsize == sizeof(CUfileIOParams_t), \ 

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

2051  

2052 def __repr__(self): 

2053 if self._data.size > 1: 

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

2055 else: 

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

2057  

2058 @property 

2059 def ptr(self): 

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

2061 return self._data.ctypes.data 

2062  

2063 cdef intptr_t _get_ptr(self): 

2064 return self._data.ctypes.data 

2065  

2066 def __int__(self): 

2067 if self._data.size > 1: 

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

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

2070 return self._data.ctypes.data 

2071  

2072 def __len__(self): 

2073 return self._data.size 

2074  

2075 def __eq__(self, other): 

2076 cdef object self_data = self._data 

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

2078 return False 

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

2080  

2081 @property 

2082 def mode(self): 

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

2084 if self._data.size == 1: 

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

2086 return self._data.mode 

2087  

2088 @mode.setter 

2089 def mode(self, val): 

2090 self._data.mode = val 

2091  

2092 @property 

2093 def u(self): 

2094 """_py_anon_pod2_dtype: """ 

2095 return self._data.u 

2096  

2097 @u.setter 

2098 def u(self, val): 

2099 self._data.u = val 

2100  

2101 @property 

2102 def fh(self): 

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

2104 if self._data.size == 1: 

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

2106 return self._data.fh 

2107  

2108 @fh.setter 

2109 def fh(self, val): 

2110 self._data.fh = val 

2111  

2112 @property 

2113 def opcode(self): 

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

2115 if self._data.size == 1: 

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

2117 return self._data.opcode 

2118  

2119 @opcode.setter 

2120 def opcode(self, val): 

2121 self._data.opcode = val 

2122  

2123 @property 

2124 def cookie(self): 

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

2126 if self._data.size == 1: 

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

2128 return self._data.cookie 

2129  

2130 @cookie.setter 

2131 def cookie(self, val): 

2132 self._data.cookie = val 

2133  

2134 def __getitem__(self, key): 

2135 cdef ssize_t key_ 

2136 cdef ssize_t size 

2137 if isinstance(key, int): 

2138 key_ = key 

2139 size = self._data.size 

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

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

2142 if key_ < 0: 

2143 key_ += size 

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

2145 out = self._data[key] 

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

2147 return IOParams.from_data(out) 

2148 return out 

2149  

2150 def __setitem__(self, key, val): 

2151 self._data[key] = val 

2152  

2153 @staticmethod 

2154 def from_data(data): 

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

2156  

2157 Args: 

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

2159 """ 

2160 cdef IOParams obj = IOParams.__new__(IOParams) 

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

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

2163 if data.ndim != 1: 

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

2165 if data.dtype != io_params_dtype: 

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

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

2168  

2169 return obj 

2170  

2171 @staticmethod 

2172 def from_ptr(intptr_t ptr, size_t size=1, bint readonly=False): 

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

2174  

2175 Args: 

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

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

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

2179 """ 

2180 if ptr == 0: 

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

2182 cdef IOParams obj = IOParams.__new__(IOParams) 

2183 cdef flag = cpython.buffer.PyBUF_READ if readonly else cpython.buffer.PyBUF_WRITE 

2184 cdef object buf = cpython.memoryview.PyMemoryView_FromMemory( 

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

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

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

2188  

2189 return obj 

2190  

2191  

2192cdef _get_stats_level2_dtype_offsets(): 

2193 cdef CUfileStatsLevel2_t pod = CUfileStatsLevel2_t() 

2194 return _numpy.dtype({ 

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

2196 'formats': [stats_level1_dtype, _numpy.uint64, _numpy.uint64], 

2197 'offsets': [ 

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

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

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

2201 ], 

2202 'itemsize': sizeof(CUfileStatsLevel2_t), 

2203 }) 

2204  

2205stats_level2_dtype = _get_stats_level2_dtype_offsets() 

2206  

2207cdef class StatsLevel2: 

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

2209  

2210  

2211 .. seealso:: `CUfileStatsLevel2_t` 

2212 """ 

2213 cdef: 

2214 CUfileStatsLevel2_t *_ptr 

2215 object _owner 

2216 bint _owned 

2217 bint _readonly 

2218  

2219 def __init__(self): 

2220 self._ptr = <CUfileStatsLevel2_t *>calloc(1, sizeof(CUfileStatsLevel2_t)) 

2221 if self._ptr == NULL: 

2222 raise MemoryError("Error allocating StatsLevel2") 

2223 self._owner = None 

2224 self._owned = True 

2225 self._readonly = False 

2226  

2227 def __dealloc__(self): 

2228 cdef CUfileStatsLevel2_t *ptr 

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

2230 ptr = self._ptr 

2231 self._ptr = NULL 

2232 free(ptr) 

2233  

2234 def __repr__(self): 

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

2236  

2237 @property 

2238 def ptr(self): 

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

2240 return <intptr_t>(self._ptr) 

2241  

2242 cdef intptr_t _get_ptr(self): 

2243 return <intptr_t>(self._ptr) 

2244  

2245 def __int__(self): 

2246 return <intptr_t>(self._ptr) 

2247  

2248 def __eq__(self, other): 

2249 cdef StatsLevel2 other_ 

2250 if not isinstance(other, StatsLevel2): 

2251 return False 

2252 other_ = other 

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

2254  

2255 def __setitem__(self, key, val): 

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

2257 self._ptr = <CUfileStatsLevel2_t *>malloc(sizeof(CUfileStatsLevel2_t)) 

2258 if self._ptr == NULL: 

2259 raise MemoryError("Error allocating StatsLevel2") 

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

2261 self._owner = None 

2262 self._owned = True 

2263 self._readonly = not val.flags.writeable 

2264 else: 

2265 setattr(self, key, val) 

2266  

2267 @property 

2268 def basic(self): 

2269 """StatsLevel1: """ 

2270 return StatsLevel1.from_ptr(<intptr_t>&(self._ptr[0].basic), self._readonly, self) 

2271  

2272 @basic.setter 

2273 def basic(self, val): 

2274 if self._readonly: 

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

2276 cdef StatsLevel1 val_ = val 

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

2278  

2279 @property 

2280 def read_size_kb_hist(self): 

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

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

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

2284 return _numpy.asarray(arr) 

2285  

2286 @read_size_kb_hist.setter 

2287 def read_size_kb_hist(self, val): 

2288 if self._readonly: 

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

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

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

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

2293  

2294 @property 

2295 def write_size_kb_hist(self): 

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

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

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

2299 return _numpy.asarray(arr) 

2300  

2301 @write_size_kb_hist.setter 

2302 def write_size_kb_hist(self, val): 

2303 if self._readonly: 

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

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

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

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

2308  

2309 @staticmethod 

2310 def from_data(data): 

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

2312  

2313 Args: 

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

2315 """ 

2316 return __from_data(data, "stats_level2_dtype", stats_level2_dtype, StatsLevel2) 

2317  

2318 @staticmethod 

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

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

2321  

2322 Args: 

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

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

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

2326 """ 

2327 if ptr == 0: 

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

2329 cdef StatsLevel2 obj = StatsLevel2.__new__(StatsLevel2) 

2330 if owner is None: 

2331 obj._ptr = <CUfileStatsLevel2_t *>malloc(sizeof(CUfileStatsLevel2_t)) 

2332 if obj._ptr == NULL: 

2333 raise MemoryError("Error allocating StatsLevel2") 

2334 memcpy(<void*>(obj._ptr), <void*>ptr, sizeof(CUfileStatsLevel2_t)) 

2335 obj._owner = None 

2336 obj._owned = True 

2337 else: 

2338 obj._ptr = <CUfileStatsLevel2_t *>ptr 

2339 obj._owner = owner 

2340 obj._owned = False 

2341 obj._readonly = readonly 

2342 return obj 

2343  

2344  

2345cdef _get_stats_level3_dtype_offsets(): 

2346 cdef CUfileStatsLevel3_t pod = CUfileStatsLevel3_t() 

2347 return _numpy.dtype({ 

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

2349 'formats': [stats_level2_dtype, _numpy.uint32, per_gpu_stats_dtype], 

2350 'offsets': [ 

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

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

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

2354 ], 

2355 'itemsize': sizeof(CUfileStatsLevel3_t), 

2356 }) 

2357  

2358stats_level3_dtype = _get_stats_level3_dtype_offsets() 

2359  

2360cdef class StatsLevel3: 

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

2362  

2363  

2364 .. seealso:: `CUfileStatsLevel3_t` 

2365 """ 

2366 cdef: 

2367 CUfileStatsLevel3_t *_ptr 

2368 object _owner 

2369 bint _owned 

2370 bint _readonly 

2371  

2372 def __init__(self): 

2373 self._ptr = <CUfileStatsLevel3_t *>calloc(1, sizeof(CUfileStatsLevel3_t)) 

2374 if self._ptr == NULL: 

2375 raise MemoryError("Error allocating StatsLevel3") 

2376 self._owner = None 

2377 self._owned = True 

2378 self._readonly = False 

2379  

2380 def __dealloc__(self): 

2381 cdef CUfileStatsLevel3_t *ptr 

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

2383 ptr = self._ptr 

2384 self._ptr = NULL 

2385 free(ptr) 

2386  

2387 def __repr__(self): 

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

2389  

2390 @property 

2391 def ptr(self): 

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

2393 return <intptr_t>(self._ptr) 

2394  

2395 cdef intptr_t _get_ptr(self): 

2396 return <intptr_t>(self._ptr) 

2397  

2398 def __int__(self): 

2399 return <intptr_t>(self._ptr) 

2400  

2401 def __eq__(self, other): 

2402 cdef StatsLevel3 other_ 

2403 if not isinstance(other, StatsLevel3): 

2404 return False 

2405 other_ = other 

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

2407  

2408 def __setitem__(self, key, val): 

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

2410 self._ptr = <CUfileStatsLevel3_t *>malloc(sizeof(CUfileStatsLevel3_t)) 

2411 if self._ptr == NULL: 

2412 raise MemoryError("Error allocating StatsLevel3") 

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

2414 self._owner = None 

2415 self._owned = True 

2416 self._readonly = not val.flags.writeable 

2417 else: 

2418 setattr(self, key, val) 

2419  

2420 @property 

2421 def detailed(self): 

2422 """StatsLevel2: """ 

2423 return StatsLevel2.from_ptr(<intptr_t>&(self._ptr[0].detailed), self._readonly, self) 

2424  

2425 @detailed.setter 

2426 def detailed(self, val): 

2427 if self._readonly: 

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

2429 cdef StatsLevel2 val_ = val 

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

2431  

2432 @property 

2433 def per_gpu_stats(self): 

2434 """PerGpuStats: """ 

2435 return PerGpuStats.from_ptr(<intptr_t>&(self._ptr[0].per_gpu_stats), 16, self._readonly) 

2436  

2437 @per_gpu_stats.setter 

2438 def per_gpu_stats(self, val): 

2439 if self._readonly: 

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

2441 cdef PerGpuStats val_ = val 

2442 if len(val) != 16: 

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

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

2445  

2446 @property 

2447 def num_gpus(self): 

2448 """int: """ 

2449 return self._ptr[0].num_gpus 

2450  

2451 @num_gpus.setter 

2452 def num_gpus(self, val): 

2453 if self._readonly: 

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

2455 self._ptr[0].num_gpus = val 

2456  

2457 @staticmethod 

2458 def from_data(data): 

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

2460  

2461 Args: 

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

2463 """ 

2464 return __from_data(data, "stats_level3_dtype", stats_level3_dtype, StatsLevel3) 

2465  

2466 @staticmethod 

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

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

2469  

2470 Args: 

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

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

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

2474 """ 

2475 if ptr == 0: 

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

2477 cdef StatsLevel3 obj = StatsLevel3.__new__(StatsLevel3) 

2478 if owner is None: 

2479 obj._ptr = <CUfileStatsLevel3_t *>malloc(sizeof(CUfileStatsLevel3_t)) 

2480 if obj._ptr == NULL: 

2481 raise MemoryError("Error allocating StatsLevel3") 

2482 memcpy(<void*>(obj._ptr), <void*>ptr, sizeof(CUfileStatsLevel3_t)) 

2483 obj._owner = None 

2484 obj._owned = True 

2485 else: 

2486 obj._ptr = <CUfileStatsLevel3_t *>ptr 

2487 obj._owner = owner 

2488 obj._owned = False 

2489 obj._readonly = readonly 

2490 return obj 

2491  

2492  

2493  

2494############################################################################### 

2495# Enum 

2496############################################################################### 

2497  

2498class OpError(_IntEnum): 

2499 """See `CUfileOpError`.""" 

2500 SUCCESS = CU_FILE_SUCCESS 

2501 DRIVER_NOT_INITIALIZED = CU_FILE_DRIVER_NOT_INITIALIZED 

2502 DRIVER_INVALID_PROPS = CU_FILE_DRIVER_INVALID_PROPS 

2503 DRIVER_UNSUPPORTED_LIMIT = CU_FILE_DRIVER_UNSUPPORTED_LIMIT 

2504 DRIVER_VERSION_MISMATCH = CU_FILE_DRIVER_VERSION_MISMATCH 

2505 DRIVER_VERSION_READ_ERROR = CU_FILE_DRIVER_VERSION_READ_ERROR 

2506 DRIVER_CLOSING = CU_FILE_DRIVER_CLOSING 

2507 PLATFORM_NOT_SUPPORTED = CU_FILE_PLATFORM_NOT_SUPPORTED 

2508 IO_NOT_SUPPORTED = CU_FILE_IO_NOT_SUPPORTED 

2509 DEVICE_NOT_SUPPORTED = CU_FILE_DEVICE_NOT_SUPPORTED 

2510 NVFS_DRIVER_ERROR = CU_FILE_NVFS_DRIVER_ERROR 

2511 CUDA_DRIVER_ERROR = CU_FILE_CUDA_DRIVER_ERROR 

2512 CUDA_POINTER_INVALID = CU_FILE_CUDA_POINTER_INVALID 

2513 CUDA_MEMORY_TYPE_INVALID = CU_FILE_CUDA_MEMORY_TYPE_INVALID 

2514 CUDA_POINTER_RANGE_ERROR = CU_FILE_CUDA_POINTER_RANGE_ERROR 

2515 CUDA_CONTEXT_MISMATCH = CU_FILE_CUDA_CONTEXT_MISMATCH 

2516 INVALID_MAPPING_SIZE = CU_FILE_INVALID_MAPPING_SIZE 

2517 INVALID_MAPPING_RANGE = CU_FILE_INVALID_MAPPING_RANGE 

2518 INVALID_FILE_TYPE = CU_FILE_INVALID_FILE_TYPE 

2519 INVALID_FILE_OPEN_FLAG = CU_FILE_INVALID_FILE_OPEN_FLAG 

2520 DIO_NOT_SET = CU_FILE_DIO_NOT_SET 

2521 INVALID_VALUE = CU_FILE_INVALID_VALUE 

2522 MEMORY_ALREADY_REGISTERED = CU_FILE_MEMORY_ALREADY_REGISTERED 

2523 MEMORY_NOT_REGISTERED = CU_FILE_MEMORY_NOT_REGISTERED 

2524 PERMISSION_DENIED = CU_FILE_PERMISSION_DENIED 

2525 DRIVER_ALREADY_OPEN = CU_FILE_DRIVER_ALREADY_OPEN 

2526 HANDLE_NOT_REGISTERED = CU_FILE_HANDLE_NOT_REGISTERED 

2527 HANDLE_ALREADY_REGISTERED = CU_FILE_HANDLE_ALREADY_REGISTERED 

2528 DEVICE_NOT_FOUND = CU_FILE_DEVICE_NOT_FOUND 

2529 INTERNAL_ERROR = CU_FILE_INTERNAL_ERROR 

2530 GETNEWFD_FAILED = CU_FILE_GETNEWFD_FAILED 

2531 NVFS_SETUP_ERROR = CU_FILE_NVFS_SETUP_ERROR 

2532 IO_DISABLED = CU_FILE_IO_DISABLED 

2533 BATCH_SUBMIT_FAILED = CU_FILE_BATCH_SUBMIT_FAILED 

2534 GPU_MEMORY_PINNING_FAILED = CU_FILE_GPU_MEMORY_PINNING_FAILED 

2535 BATCH_FULL = CU_FILE_BATCH_FULL 

2536 ASYNC_NOT_SUPPORTED = CU_FILE_ASYNC_NOT_SUPPORTED 

2537 INTERNAL_BATCH_SETUP_ERROR = CU_FILE_INTERNAL_BATCH_SETUP_ERROR 

2538 INTERNAL_BATCH_SUBMIT_ERROR = CU_FILE_INTERNAL_BATCH_SUBMIT_ERROR 

2539 INTERNAL_BATCH_GETSTATUS_ERROR = CU_FILE_INTERNAL_BATCH_GETSTATUS_ERROR 

2540 INTERNAL_BATCH_CANCEL_ERROR = CU_FILE_INTERNAL_BATCH_CANCEL_ERROR 

2541 NOMEM_ERROR = CU_FILE_NOMEM_ERROR 

2542 IO_ERROR = CU_FILE_IO_ERROR 

2543 INTERNAL_BUF_REGISTER_ERROR = CU_FILE_INTERNAL_BUF_REGISTER_ERROR 

2544 HASH_OPR_ERROR = CU_FILE_HASH_OPR_ERROR 

2545 INVALID_CONTEXT_ERROR = CU_FILE_INVALID_CONTEXT_ERROR 

2546 NVFS_INTERNAL_DRIVER_ERROR = CU_FILE_NVFS_INTERNAL_DRIVER_ERROR 

2547 BATCH_NOCOMPAT_ERROR = CU_FILE_BATCH_NOCOMPAT_ERROR 

2548 IO_MAX_ERROR = CU_FILE_IO_MAX_ERROR 

2549  

2550class DriverStatusFlags(_IntEnum): 

2551 """See `CUfileDriverStatusFlags_t`.""" 

2552 LUSTRE_SUPPORTED = CU_FILE_LUSTRE_SUPPORTED 

2553 WEKAFS_SUPPORTED = CU_FILE_WEKAFS_SUPPORTED 

2554 NFS_SUPPORTED = CU_FILE_NFS_SUPPORTED 

2555 GPFS_SUPPORTED = CU_FILE_GPFS_SUPPORTED 

2556 NVME_SUPPORTED = CU_FILE_NVME_SUPPORTED 

2557 NVMEOF_SUPPORTED = CU_FILE_NVMEOF_SUPPORTED 

2558 SCSI_SUPPORTED = CU_FILE_SCSI_SUPPORTED 

2559 SCALEFLUX_CSD_SUPPORTED = CU_FILE_SCALEFLUX_CSD_SUPPORTED 

2560 NVMESH_SUPPORTED = CU_FILE_NVMESH_SUPPORTED 

2561 BEEGFS_SUPPORTED = CU_FILE_BEEGFS_SUPPORTED 

2562 NVME_P2P_SUPPORTED = CU_FILE_NVME_P2P_SUPPORTED 

2563 SCATEFS_SUPPORTED = CU_FILE_SCATEFS_SUPPORTED 

2564 VIRTIOFS_SUPPORTED = CU_FILE_VIRTIOFS_SUPPORTED 

2565 MAX_TARGET_TYPES = CU_FILE_MAX_TARGET_TYPES 

2566  

2567class DriverControlFlags(_IntEnum): 

2568 """See `CUfileDriverControlFlags_t`.""" 

2569 USE_POLL_MODE = CU_FILE_USE_POLL_MODE 

2570 ALLOW_COMPAT_MODE = CU_FILE_ALLOW_COMPAT_MODE 

2571  

2572class FeatureFlags(_IntEnum): 

2573 """See `CUfileFeatureFlags_t`.""" 

2574 DYN_ROUTING_SUPPORTED = CU_FILE_DYN_ROUTING_SUPPORTED 

2575 BATCH_IO_SUPPORTED = CU_FILE_BATCH_IO_SUPPORTED 

2576 STREAMS_SUPPORTED = CU_FILE_STREAMS_SUPPORTED 

2577 PARALLEL_IO_SUPPORTED = CU_FILE_PARALLEL_IO_SUPPORTED 

2578 P2P_SUPPORTED = CU_FILE_P2P_SUPPORTED 

2579  

2580class FileHandleType(_IntEnum): 

2581 """See `CUfileFileHandleType`.""" 

2582 OPAQUE_FD = CU_FILE_HANDLE_TYPE_OPAQUE_FD 

2583 OPAQUE_WIN32 = CU_FILE_HANDLE_TYPE_OPAQUE_WIN32 

2584 USERSPACE_FS = CU_FILE_HANDLE_TYPE_USERSPACE_FS 

2585  

2586class Opcode(_IntEnum): 

2587 """See `CUfileOpcode_t`.""" 

2588 READ = CUFILE_READ 

2589 WRITE = CUFILE_WRITE 

2590  

2591class Status(_IntEnum): 

2592 """See `CUfileStatus_t`.""" 

2593 WAITING = CUFILE_WAITING 

2594 PENDING = CUFILE_PENDING 

2595 INVALID = CUFILE_INVALID 

2596 CANCELED = CUFILE_CANCELED 

2597 COMPLETE = CUFILE_COMPLETE 

2598 TIMEOUT = CUFILE_TIMEOUT 

2599 FAILED = CUFILE_FAILED 

2600  

2601class BatchMode(_IntEnum): 

2602 """See `CUfileBatchMode_t`.""" 

2603 BATCH = CUFILE_BATCH 

2604  

2605class SizeTConfigParameter(_IntEnum): 

2606 """See `CUFileSizeTConfigParameter_t`.""" 

2607 PROFILE_STATS = CUFILE_PARAM_PROFILE_STATS 

2608 EXECUTION_MAX_IO_QUEUE_DEPTH = CUFILE_PARAM_EXECUTION_MAX_IO_QUEUE_DEPTH 

2609 EXECUTION_MAX_IO_THREADS = CUFILE_PARAM_EXECUTION_MAX_IO_THREADS 

2610 EXECUTION_MIN_IO_THRESHOLD_SIZE_KB = CUFILE_PARAM_EXECUTION_MIN_IO_THRESHOLD_SIZE_KB 

2611 EXECUTION_MAX_REQUEST_PARALLELISM = CUFILE_PARAM_EXECUTION_MAX_REQUEST_PARALLELISM 

2612 PROPERTIES_MAX_DIRECT_IO_SIZE_KB = CUFILE_PARAM_PROPERTIES_MAX_DIRECT_IO_SIZE_KB 

2613 PROPERTIES_MAX_DEVICE_CACHE_SIZE_KB = CUFILE_PARAM_PROPERTIES_MAX_DEVICE_CACHE_SIZE_KB 

2614 PROPERTIES_PER_BUFFER_CACHE_SIZE_KB = CUFILE_PARAM_PROPERTIES_PER_BUFFER_CACHE_SIZE_KB 

2615 PROPERTIES_MAX_DEVICE_PINNED_MEM_SIZE_KB = CUFILE_PARAM_PROPERTIES_MAX_DEVICE_PINNED_MEM_SIZE_KB 

2616 PROPERTIES_IO_BATCHSIZE = CUFILE_PARAM_PROPERTIES_IO_BATCHSIZE 

2617 POLLTHRESHOLD_SIZE_KB = CUFILE_PARAM_POLLTHRESHOLD_SIZE_KB 

2618 PROPERTIES_BATCH_IO_TIMEOUT_MS = CUFILE_PARAM_PROPERTIES_BATCH_IO_TIMEOUT_MS 

2619  

2620class BoolConfigParameter(_IntEnum): 

2621 """See `CUFileBoolConfigParameter_t`.""" 

2622 PROPERTIES_USE_POLL_MODE = CUFILE_PARAM_PROPERTIES_USE_POLL_MODE 

2623 PROPERTIES_ALLOW_COMPAT_MODE = CUFILE_PARAM_PROPERTIES_ALLOW_COMPAT_MODE 

2624 FORCE_COMPAT_MODE = CUFILE_PARAM_FORCE_COMPAT_MODE 

2625 FS_MISC_API_CHECK_AGGRESSIVE = CUFILE_PARAM_FS_MISC_API_CHECK_AGGRESSIVE 

2626 EXECUTION_PARALLEL_IO = CUFILE_PARAM_EXECUTION_PARALLEL_IO 

2627 PROFILE_NVTX = CUFILE_PARAM_PROFILE_NVTX 

2628 PROPERTIES_ALLOW_SYSTEM_MEMORY = CUFILE_PARAM_PROPERTIES_ALLOW_SYSTEM_MEMORY 

2629 USE_PCIP2PDMA = CUFILE_PARAM_USE_PCIP2PDMA 

2630 PREFER_IO_URING = CUFILE_PARAM_PREFER_IO_URING 

2631 FORCE_ODIRECT_MODE = CUFILE_PARAM_FORCE_ODIRECT_MODE 

2632 SKIP_TOPOLOGY_DETECTION = CUFILE_PARAM_SKIP_TOPOLOGY_DETECTION 

2633 STREAM_MEMOPS_BYPASS = CUFILE_PARAM_STREAM_MEMOPS_BYPASS 

2634  

2635class StringConfigParameter(_IntEnum): 

2636 """See `CUFileStringConfigParameter_t`.""" 

2637 LOGGING_LEVEL = CUFILE_PARAM_LOGGING_LEVEL 

2638 ENV_LOGFILE_PATH = CUFILE_PARAM_ENV_LOGFILE_PATH 

2639 LOG_DIR = CUFILE_PARAM_LOG_DIR 

2640  

2641class ArrayConfigParameter(_IntEnum): 

2642 """See `CUFileArrayConfigParameter_t`.""" 

2643 POSIX_POOL_SLAB_SIZE_KB = CUFILE_PARAM_POSIX_POOL_SLAB_SIZE_KB 

2644 POSIX_POOL_SLAB_COUNT = CUFILE_PARAM_POSIX_POOL_SLAB_COUNT 

2645  

2646class P2PFlags(_IntEnum): 

2647 """See `CUfileP2PFlags_t`.""" 

2648 P2PDMA = CUFILE_P2PDMA 

2649 NVFS = CUFILE_NVFS 

2650 DMABUF = CUFILE_DMABUF 

2651 C2C = CUFILE_C2C 

2652 NVIDIA_PEERMEM = CUFILE_NVIDIA_PEERMEM 

2653  

2654  

2655############################################################################### 

2656# Error handling 

2657############################################################################### 

2658  

2659ctypedef fused ReturnT: 

2660 CUfileError_t 

2661 ssize_t 

2662  

2663  

2664class cuFileError(Exception): 

2665  

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

2667 self.status = status 

2668 self.cuda_error = cu_err 

2669 s = OpError(status) 

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

2671 if cu_err is not None: 

2672 e = pyCUresult(cu_err) 

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

2674 super(cuFileError, self).__init__(err) 

2675  

2676 def __reduce__(self): 

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

2678  

2679  

2680@cython.profile(False) 

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

2682 if ReturnT is CUfileError_t: 

2683 if status.err != 0 or status.cu_err != 0: 

2684 with gil: 

2685 raise cuFileError(status.err, status.cu_err) 

2686 elif ReturnT is ssize_t: 

2687 if status == -1: 

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

2689 with gil: 

2690 raise cuFileError(errno.errno) 

2691 return 0 

2692  

2693  

2694############################################################################### 

2695# Wrapper functions 

2696############################################################################### 

2697  

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

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

2700  

2701 Args: 

2702 descr (intptr_t): ``CUfileDescr_t`` file descriptor (OS agnostic). 

2703  

2704 Returns: 

2705 intptr_t: ``CUfileHandle_t`` opaque file handle for IO operations. 

2706  

2707 .. seealso:: `cuFileHandleRegister` 

2708 """ 

2709 cdef Handle fh 

2710 with nogil: 

2711 __status__ = cuFileHandleRegister(&fh, <CUfileDescr_t*>descr) 

2712 check_status(__status__) 

2713 return <intptr_t>fh 

2714  

2715  

2716cpdef void handle_deregister(intptr_t fh) except*: 

2717 """releases a registered filehandle from cuFile. 

2718  

2719 Args: 

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

2721  

2722 .. seealso:: `cuFileHandleDeregister` 

2723 """ 

2724 cuFileHandleDeregister(<Handle>fh) 

2725  

2726  

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

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

2729  

2730 Args: 

2731 buf_ptr_base (intptr_t): buffer pointer allocated. 

2732 length (size_t): size of memory region from the above specified bufPtr. 

2733 flags (int): CU_FILE_RDMA_REGISTER. 

2734  

2735 .. seealso:: `cuFileBufRegister` 

2736 """ 

2737 with nogil: 

2738 __status__ = cuFileBufRegister(<const void*>buf_ptr_base, length, flags) 

2739 check_status(__status__) 

2740  

2741  

2742cpdef buf_deregister(intptr_t buf_ptr_base): 

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

2744  

2745 Args: 

2746 buf_ptr_base (intptr_t): buffer pointer to deregister. 

2747  

2748 .. seealso:: `cuFileBufDeregister` 

2749 """ 

2750 with nogil: 

2751 __status__ = cuFileBufDeregister(<const void*>buf_ptr_base) 

2752 check_status(__status__) 

2753  

2754  

2755cpdef driver_open(): 

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

2757  

2758 .. seealso:: `cuFileDriverOpen` 

2759 """ 

2760 with nogil: 

2761 __status__ = cuFileDriverOpen() 

2762 check_status(__status__) 

2763  

2764  

2765cpdef use_count(): 

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

2767  

2768 .. seealso:: `cuFileUseCount` 

2769 """ 

2770 with nogil: 

2771 __status__ = cuFileUseCount() 

2772 check_status(__status__) 

2773  

2774  

2775cpdef driver_get_properties(intptr_t props): 

2776 """Gets the Driver session properties. 

2777  

2778 Args: 

2779 props (intptr_t): Properties to set. 

2780  

2781 .. seealso:: `cuFileDriverGetProperties` 

2782 """ 

2783 with nogil: 

2784 __status__ = cuFileDriverGetProperties(<CUfileDrvProps_t*>props) 

2785 check_status(__status__) 

2786  

2787  

2788cpdef driver_set_poll_mode(bint poll, size_t poll_threshold_size): 

2789 """Sets whether the Read/Write APIs use polling to do IO operations. 

2790  

2791 Args: 

2792 poll (bint): boolean to indicate whether to use poll mode or not. 

2793 poll_threshold_size (size_t): max IO size to use for POLLING mode in KB. 

2794  

2795 .. seealso:: `cuFileDriverSetPollMode` 

2796 """ 

2797 with nogil: 

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

2799 check_status(__status__) 

2800  

2801  

2802cpdef driver_set_max_direct_io_size(size_t max_direct_io_size): 

2803 """Control parameter to set max IO size(KB) used by the library to talk to nvidia-fs driver. 

2804  

2805 Args: 

2806 max_direct_io_size (size_t): maximum allowed direct io size in KB. 

2807  

2808 .. seealso:: `cuFileDriverSetMaxDirectIOSize` 

2809 """ 

2810 with nogil: 

2811 __status__ = cuFileDriverSetMaxDirectIOSize(max_direct_io_size) 

2812 check_status(__status__) 

2813  

2814  

2815cpdef driver_set_max_cache_size(size_t max_cache_size): 

2816 """Control parameter to set maximum GPU memory reserved per device by the library for internal buffering. 

2817  

2818 Args: 

2819 max_cache_size (size_t): The maximum GPU buffer space per device used for internal use in KB. 

2820  

2821 .. seealso:: `cuFileDriverSetMaxCacheSize` 

2822 """ 

2823 with nogil: 

2824 __status__ = cuFileDriverSetMaxCacheSize(max_cache_size) 

2825 check_status(__status__) 

2826  

2827  

2828cpdef driver_set_max_pinned_mem_size(size_t max_pinned_size): 

2829 """Sets maximum buffer space that is pinned in KB for use by ``cuFileBufRegister``. 

2830  

2831 Args: 

2832 max_pinned_size (size_t): maximum buffer space that is pinned in KB. 

2833  

2834 .. seealso:: `cuFileDriverSetMaxPinnedMemSize` 

2835 """ 

2836 with nogil: 

2837 __status__ = cuFileDriverSetMaxPinnedMemSize(max_pinned_size) 

2838 check_status(__status__) 

2839  

2840  

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

2842 cdef BatchHandle batch_idp 

2843 with nogil: 

2844 __status__ = cuFileBatchIOSetUp(&batch_idp, nr) 

2845 check_status(__status__) 

2846 return <intptr_t>batch_idp 

2847  

2848  

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

2850 with nogil: 

2851 __status__ = cuFileBatchIOSubmit(<BatchHandle>batch_idp, nr, <CUfileIOParams_t*>iocbp, flags) 

2852 check_status(__status__) 

2853  

2854  

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

2856 with nogil: 

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

2858 check_status(__status__) 

2859  

2860  

2861cpdef batch_io_cancel(intptr_t batch_idp): 

2862 with nogil: 

2863 __status__ = cuFileBatchIOCancel(<BatchHandle>batch_idp) 

2864 check_status(__status__) 

2865  

2866  

2867cpdef void batch_io_destroy(intptr_t batch_idp) except*: 

2868 cuFileBatchIODestroy(<BatchHandle>batch_idp) 

2869  

2870  

2871cpdef 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): 

2872 with nogil: 

2873 __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, <void*>stream) 

2874 check_status(__status__) 

2875  

2876  

2877cpdef 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): 

2878 with nogil: 

2879 __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, <void*>stream) 

2880 check_status(__status__) 

2881  

2882  

2883cpdef stream_register(intptr_t stream, unsigned flags): 

2884 with nogil: 

2885 __status__ = cuFileStreamRegister(<void*>stream, flags) 

2886 check_status(__status__) 

2887  

2888  

2889cpdef stream_deregister(intptr_t stream): 

2890 with nogil: 

2891 __status__ = cuFileStreamDeregister(<void*>stream) 

2892 check_status(__status__) 

2893  

2894  

2895cpdef int get_version() except? 0: 

2896 """Get the cuFile library version. 

2897  

2898 Returns: 

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

2900  

2901 .. seealso:: `cuFileGetVersion` 

2902 """ 

2903 cdef int version 

2904 with nogil: 

2905 __status__ = cuFileGetVersion(&version) 

2906 check_status(__status__) 

2907 return version 

2908  

2909  

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

2911 cdef size_t value 

2912 with nogil: 

2913 __status__ = cuFileGetParameterSizeT(<_SizeTConfigParameter>param, &value) 

2914 check_status(__status__) 

2915 return value 

2916  

2917  

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

2919 cdef cpp_bool value 

2920 with nogil: 

2921 __status__ = cuFileGetParameterBool(<_BoolConfigParameter>param, &value) 

2922 check_status(__status__) 

2923 return <bint>value 

2924  

2925  

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

2927 cdef bytes _desc_str_ = bytes(len) 

2928 cdef char* desc_str = _desc_str_ 

2929 with nogil: 

2930 __status__ = cuFileGetParameterString(<_StringConfigParameter>param, desc_str, len) 

2931 check_status(__status__) 

2932 return cpython.PyUnicode_FromString(desc_str) 

2933  

2934  

2935cpdef set_parameter_size_t(int param, size_t value): 

2936 with nogil: 

2937 __status__ = cuFileSetParameterSizeT(<_SizeTConfigParameter>param, value) 

2938 check_status(__status__) 

2939  

2940  

2941cpdef set_parameter_bool(int param, bint value): 

2942 with nogil: 

2943 __status__ = cuFileSetParameterBool(<_BoolConfigParameter>param, <cpp_bool>value) 

2944 check_status(__status__) 

2945  

2946  

2947cpdef set_parameter_string(int param, intptr_t desc_str): 

2948 with nogil: 

2949 __status__ = cuFileSetParameterString(<_StringConfigParameter>param, <const char*>desc_str) 

2950 check_status(__status__) 

2951  

2952  

2953cpdef tuple get_parameter_min_max_value(int param): 

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

2955  

2956 Args: 

2957 param (SizeTConfigParameter): CUfile SizeT configuration parameter. 

2958  

2959 Returns: 

2960 A 2-tuple containing: 

2961  

2962 - size_t: Pointer to store the minimum value. 

2963 - size_t: Pointer to store the maximum value. 

2964  

2965 .. seealso:: `cuFileGetParameterMinMaxValue` 

2966 """ 

2967 cdef size_t min_value 

2968 cdef size_t max_value 

2969 with nogil: 

2970 __status__ = cuFileGetParameterMinMaxValue(<_SizeTConfigParameter>param, &min_value, &max_value) 

2971 check_status(__status__) 

2972 return (min_value, max_value) 

2973  

2974  

2975cpdef set_stats_level(int level): 

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

2977  

2978 Args: 

2979 level (int): Statistics level (0 = disabled, 1 = basic, 2 = detailed, 3 = verbose). 

2980  

2981 .. seealso:: `cuFileSetStatsLevel` 

2982 """ 

2983 with nogil: 

2984 __status__ = cuFileSetStatsLevel(level) 

2985 check_status(__status__) 

2986  

2987  

2988cpdef int get_stats_level() except? 0: 

2989 """Get the current level of statistics collection for cuFile operations. 

2990  

2991 Returns: 

2992 int: Pointer to store the current statistics level. 

2993  

2994 .. seealso:: `cuFileGetStatsLevel` 

2995 """ 

2996 cdef int level 

2997 with nogil: 

2998 __status__ = cuFileGetStatsLevel(&level) 

2999 check_status(__status__) 

3000 return level 

3001  

3002  

3003cpdef stats_start(): 

3004 """Start collecting cuFile statistics. 

3005  

3006 .. seealso:: `cuFileStatsStart` 

3007 """ 

3008 with nogil: 

3009 __status__ = cuFileStatsStart() 

3010 check_status(__status__) 

3011  

3012  

3013cpdef stats_stop(): 

3014 """Stop collecting cuFile statistics. 

3015  

3016 .. seealso:: `cuFileStatsStop` 

3017 """ 

3018 with nogil: 

3019 __status__ = cuFileStatsStop() 

3020 check_status(__status__) 

3021  

3022  

3023cpdef stats_reset(): 

3024 """Reset all cuFile statistics counters. 

3025  

3026 .. seealso:: `cuFileStatsReset` 

3027 """ 

3028 with nogil: 

3029 __status__ = cuFileStatsReset() 

3030 check_status(__status__) 

3031  

3032  

3033cpdef get_stats_l1(intptr_t stats): 

3034 """Get Level 1 cuFile statistics. 

3035  

3036 Args: 

3037 stats (intptr_t): Pointer to CUfileStatsLevel1_t structure to be filled. 

3038  

3039 .. seealso:: `cuFileGetStatsL1` 

3040 """ 

3041 with nogil: 

3042 __status__ = cuFileGetStatsL1(<CUfileStatsLevel1_t*>stats) 

3043 check_status(__status__) 

3044  

3045  

3046cpdef get_stats_l2(intptr_t stats): 

3047 """Get Level 2 cuFile statistics. 

3048  

3049 Args: 

3050 stats (intptr_t): Pointer to CUfileStatsLevel2_t structure to be filled. 

3051  

3052 .. seealso:: `cuFileGetStatsL2` 

3053 """ 

3054 with nogil: 

3055 __status__ = cuFileGetStatsL2(<CUfileStatsLevel2_t*>stats) 

3056 check_status(__status__) 

3057  

3058  

3059cpdef get_stats_l3(intptr_t stats): 

3060 """Get Level 3 cuFile statistics. 

3061  

3062 Args: 

3063 stats (intptr_t): Pointer to CUfileStatsLevel3_t structure to be filled. 

3064  

3065 .. seealso:: `cuFileGetStatsL3` 

3066 """ 

3067 with nogil: 

3068 __status__ = cuFileGetStatsL3(<CUfileStatsLevel3_t*>stats) 

3069 check_status(__status__) 

3070  

3071  

3072cpdef size_t get_bar_size_in_kb(int gpu_ind_ex) except? 0: 

3073 cdef size_t bar_size 

3074 with nogil: 

3075 __status__ = cuFileGetBARSizeInKB(gpu_ind_ex, &bar_size) 

3076 check_status(__status__) 

3077 return bar_size 

3078  

3079  

3080cpdef set_parameter_posix_pool_slab_array(intptr_t size_values, intptr_t count_values, int len): 

3081 """Set both POSIX pool slab size and count parameters as a pair. 

3082  

3083 Args: 

3084 size_values (intptr_t): Array of slab sizes in KB. 

3085 count_values (intptr_t): Array of slab counts. 

3086 len (int): Length of both arrays (must be the same). 

3087  

3088 .. seealso:: `cuFileSetParameterPosixPoolSlabArray` 

3089 """ 

3090 with nogil: 

3091 __status__ = cuFileSetParameterPosixPoolSlabArray(<const size_t*>size_values, <const size_t*>count_values, len) 

3092 check_status(__status__) 

3093  

3094  

3095cpdef get_parameter_posix_pool_slab_array(intptr_t size_values, intptr_t count_values, int len): 

3096 """Get both POSIX pool slab size and count parameters as a pair. 

3097  

3098 Args: 

3099 size_values (intptr_t): Buffer to receive slab sizes in KB. 

3100 count_values (intptr_t): Buffer to receive slab counts. 

3101 len (int): Buffer size (must match the actual parameter length). 

3102  

3103 .. seealso:: `cuFileGetParameterPosixPoolSlabArray` 

3104 """ 

3105 with nogil: 

3106 __status__ = cuFileGetParameterPosixPoolSlabArray(<size_t*>size_values, <size_t*>count_values, len) 

3107 check_status(__status__) 

3108  

3109  

3110cpdef str op_status_error(int status): 

3111 """cufileop status string. 

3112  

3113 Args: 

3114 status (OpError): the error status to query. 

3115  

3116 .. seealso:: `cufileop_status_error` 

3117 """ 

3118 cdef bytes _output_ 

3119 _output_ = cufileop_status_error(<_OpError>status) 

3120 return _output_.decode() 

3121  

3122  

3123cpdef driver_close(): 

3124 """reset the cuFile library and release the nvidia-fs driver 

3125 """ 

3126 with nogil: 

3127 status = cuFileDriverClose_v2() 

3128 check_status(status) 

3129  

3130cpdef read(intptr_t fh, intptr_t buf_ptr_base, size_t size, off_t file_offset, off_t buf_ptr_offset): 

3131 """read data from a registered file handle to a specified device or host memory. 

3132  

3133 Args: 

3134 fh (intptr_t): ``CUfileHandle_t`` opaque file handle. 

3135 buf_ptr_base (intptr_t): base address of buffer in device or host memory. 

3136 size (size_t): size bytes to read. 

3137 file_offset (off_t): file-offset from begining of the file. 

3138 buf_ptr_offset (off_t): offset relative to the buf_ptr_base pointer to read into. 

3139  

3140 Returns: 

3141 ssize_t: number of bytes read on success. 

3142  

3143 .. seealso:: `cuFileRead` 

3144 """ 

3145 with nogil: 

3146 status = cuFileRead(<Handle>fh, <void*>buf_ptr_base, size, file_offset, buf_ptr_offset) 

3147 check_status(status) 

3148 return status 

3149  

3150  

3151cpdef write(intptr_t fh, intptr_t buf_ptr_base, size_t size, off_t file_offset, off_t buf_ptr_offset): 

3152 """write data from a specified device or host memory to a registered file handle. 

3153  

3154 Args: 

3155 fh (intptr_t): ``CUfileHandle_t`` opaque file handle. 

3156 buf_ptr_base (intptr_t): base address of buffer in device or host memory. 

3157 size (size_t): size bytes to write. 

3158 file_offset (off_t): file-offset from begining of the file. 

3159 buf_ptr_offset (off_t): offset relative to the buf_ptr_base pointer to write from. 

3160  

3161 Returns: 

3162 ssize_t: number of bytes written on success. 

3163  

3164 .. seealso:: `cuFileWrite` 

3165 """ 

3166 with nogil: 

3167 status = cuFileWrite(<Handle>fh, <const void*>buf_ptr_base, size, file_offset, buf_ptr_offset) 

3168 check_status(status) 

3169 return status