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

1630 statements  

« prev     ^ index     » next       coverage.py v7.16.0, created at 2026-09-03 02:41 +0000

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

2# 

3# SPDX-License-Identifier: Apache-2.0 

4# 

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

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

7  

8  

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

10  

11cimport cpython as _cyb_cpython 

12cimport cpython.buffer as _cyb_cpython_buffer 

13cimport cpython.memoryview as _cyb_cpython_memoryview 

14from cython cimport view as _cyb_view 

15from libc.stdint cimport ( 

16 intptr_t, 

17 uint64_t, 

18) 

19from libc.stdlib cimport ( 

20 calloc as _cyb_calloc, 

21 free as _cyb_free, 

22 malloc as _cyb_malloc, 

23) 

24from libc.string cimport ( 

25 memcmp as _cyb_memcmp, 

26 memcpy as _cyb_memcpy, 

27) 

28from libcpp cimport bool as _cyb_bool 

29  

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

31  

32import numpy as _numpy 

33  

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

35 buffer.buf = <char *>ptr 

36 buffer.format = 'b' 

37 buffer.internal = NULL 

38 buffer.itemsize = 1 

39 buffer.len = size 

40 buffer.ndim = 1 

41 buffer.obj = self 

42 buffer.readonly = readonly 

43 buffer.shape = &buffer.len 

44 buffer.strides = &buffer.itemsize 

45 buffer.suboffsets = NULL 

46  

47cdef _cyb_from_buffer(buffer, size, lowpp_type): 

48 cdef _cyb_cpython.Py_buffer view 

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

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

51 try: 

52 if view.itemsize != 1: 

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

54 if view.len != size: 

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

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

57 finally: 

58 _cyb_cpython.PyBuffer_Release(&view) 

59  

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

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

62 if isinstance(data, lowpp_type): 1ecb

63 return data 1ecb

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

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

66 if data.size != 1: 

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

68 if data.dtype != expected_dtype: 

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

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

71  

72  

73# <<<< END OF PREAMBLE CONTENT >>>> 

74  

75cimport cython # NOQA 

76from libc cimport errno 

77from ._internal.utils cimport (get_nested_resource_ptr, 

78 nested_resource) 

79  

80import cython 

81  

82from cuda.bindings.driver import CUresult as pyCUresult 

83  

84############################################################################### 

85# POD 

86############################################################################### 

87  

88cdef _get__py_anon_pod1_dtype_offsets(): 

89 cdef cuda_bindings_cufile__anon_pod1 pod 

90 return _numpy.dtype({ 

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

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

93 'offsets': [ 

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

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

96 ], 

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

98 }) 

99  

100_py_anon_pod1_dtype = _get__py_anon_pod1_dtype_offsets() 

101  

102cdef class _py_anon_pod1: 

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

104  

105  

106 .. seealso:: `cuda_bindings_cufile__anon_pod1` 

107 """ 

108 cdef: 

109 cuda_bindings_cufile__anon_pod1 *_ptr 

110 object _owner 

111 bint _owned 

112 bint _readonly 

113  

114 def __init__(self): 

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

116 if self._ptr == NULL: 

117 raise MemoryError("Error allocating _py_anon_pod1") 

118 self._owner = None 

119 self._owned = True 

120 self._readonly = False 

121  

122 def __dealloc__(self): 

123 cdef cuda_bindings_cufile__anon_pod1 *ptr 

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

125 ptr = self._ptr 

126 self._ptr = NULL 

127 _cyb_free(ptr) 

128  

129 def __repr__(self): 

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

131  

132 @property 

133 def ptr(self): 

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

135 return <intptr_t>(self._ptr) 

136  

137 cdef intptr_t _get_ptr(self): 

138 return <intptr_t>(self._ptr) 

139  

140 def __int__(self): 

141 return <intptr_t>(self._ptr) 

142  

143 def __eq__(self, other): 

144 cdef _py_anon_pod1 other_ 

145 if not isinstance(other, _py_anon_pod1): 

146 return False 

147 other_ = other 

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

149  

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

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

152  

153 def __releasebuffer__(self, Py_buffer *buffer): 

154 pass 

155  

156 def __setitem__(self, key, val): 

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

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

159 if self._ptr == NULL: 

160 raise MemoryError("Error allocating _py_anon_pod1") 

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

162 self._owner = None 

163 self._owned = True 

164 self._readonly = not val.flags.writeable 

165 else: 

166 setattr(self, key, val) 

167  

168 @property 

169 def fd(self): 

170 """int: """ 

171 return self._ptr[0].fd 

172  

173 @fd.setter 

174 def fd(self, val): 

175 if self._readonly: 

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

177 self._ptr[0].fd = val 

178  

179 @property 

180 def handle(self): 

181 """int: """ 

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

183  

184 @handle.setter 

185 def handle(self, val): 

186 if self._readonly: 

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

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

189  

190 @staticmethod 

191 def from_buffer(buffer): 

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

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

194  

195 @staticmethod 

196 def from_data(data): 

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

198  

199 Args: 

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

201 """ 

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

203  

204 @staticmethod 

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

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

207  

208 Args: 

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

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

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

212 """ 

213 if ptr == 0: 

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

215 cdef _py_anon_pod1 obj = _py_anon_pod1.__new__(_py_anon_pod1) 

216 if owner is None: 

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

218 if obj._ptr == NULL: 

219 raise MemoryError("Error allocating _py_anon_pod1") 

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

221 obj._owner = None 

222 obj._owned = True 

223 else: 

224 obj._ptr = <cuda_bindings_cufile__anon_pod1 *>ptr 

225 obj._owner = owner 

226 obj._owned = False 

227 obj._readonly = readonly 

228 return obj 

229  

230  

231cdef _get__py_anon_pod3_dtype_offsets(): 

232 cdef cuda_bindings_cufile__anon_pod3 pod 

233 return _numpy.dtype({ 

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

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

236 'offsets': [ 

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

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

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

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

241 ], 

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

243 }) 

244  

245_py_anon_pod3_dtype = _get__py_anon_pod3_dtype_offsets() 

246  

247cdef class _py_anon_pod3: 

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

249  

250  

251 .. seealso:: `cuda_bindings_cufile__anon_pod3` 

252 """ 

253 cdef: 

254 cuda_bindings_cufile__anon_pod3 *_ptr 

255 object _owner 

256 bint _owned 

257 bint _readonly 

258  

259 def __init__(self): 

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

261 if self._ptr == NULL: 

262 raise MemoryError("Error allocating _py_anon_pod3") 

263 self._owner = None 

264 self._owned = True 

265 self._readonly = False 

266  

267 def __dealloc__(self): 

268 cdef cuda_bindings_cufile__anon_pod3 *ptr 

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

270 ptr = self._ptr 

271 self._ptr = NULL 

272 _cyb_free(ptr) 

273  

274 def __repr__(self): 

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

276  

277 @property 

278 def ptr(self): 

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

280 return <intptr_t>(self._ptr) 

281  

282 cdef intptr_t _get_ptr(self): 

283 return <intptr_t>(self._ptr) 

284  

285 def __int__(self): 

286 return <intptr_t>(self._ptr) 

287  

288 def __eq__(self, other): 

289 cdef _py_anon_pod3 other_ 

290 if not isinstance(other, _py_anon_pod3): 

291 return False 

292 other_ = other 

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

294  

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

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

297  

298 def __releasebuffer__(self, Py_buffer *buffer): 

299 pass 

300  

301 def __setitem__(self, key, val): 

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

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

304 if self._ptr == NULL: 

305 raise MemoryError("Error allocating _py_anon_pod3") 

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

307 self._owner = None 

308 self._owned = True 

309 self._readonly = not val.flags.writeable 

310 else: 

311 setattr(self, key, val) 

312  

313 @property 

314 def dev_ptr_base(self): 

315 """int: """ 

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

317  

318 @dev_ptr_base.setter 

319 def dev_ptr_base(self, val): 

320 if self._readonly: 

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

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

323  

324 @property 

325 def file_offset(self): 

326 """int: """ 

327 return self._ptr[0].file_offset 

328  

329 @file_offset.setter 

330 def file_offset(self, val): 

331 if self._readonly: 

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

333 self._ptr[0].file_offset = val 

334  

335 @property 

336 def dev_ptr_offset(self): 

337 """int: """ 

338 return self._ptr[0].devPtr_offset 

339  

340 @dev_ptr_offset.setter 

341 def dev_ptr_offset(self, val): 

342 if self._readonly: 

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

344 self._ptr[0].devPtr_offset = val 

345  

346 @property 

347 def size_(self): 

348 """int: """ 

349 return self._ptr[0].size 

350  

351 @size_.setter 

352 def size_(self, val): 

353 if self._readonly: 

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

355 self._ptr[0].size = val 

356  

357 @staticmethod 

358 def from_buffer(buffer): 

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

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

361  

362 @staticmethod 

363 def from_data(data): 

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

365  

366 Args: 

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

368 """ 

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

370  

371 @staticmethod 

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

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

374  

375 Args: 

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

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

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

379 """ 

380 if ptr == 0: 

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

382 cdef _py_anon_pod3 obj = _py_anon_pod3.__new__(_py_anon_pod3) 

383 if owner is None: 

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

385 if obj._ptr == NULL: 

386 raise MemoryError("Error allocating _py_anon_pod3") 

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

388 obj._owner = None 

389 obj._owned = True 

390 else: 

391 obj._ptr = <cuda_bindings_cufile__anon_pod3 *>ptr 

392 obj._owner = owner 

393 obj._owned = False 

394 obj._readonly = readonly 

395 return obj 

396  

397  

398cdef _get_io_events_dtype_offsets(): 

399 cdef CUfileIOEvents_t pod 

400 return _numpy.dtype({ 

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

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

403 'offsets': [ 

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

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

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

407 ], 

408 'itemsize': sizeof(CUfileIOEvents_t), 

409 }) 

410  

411io_events_dtype = _get_io_events_dtype_offsets() 

412  

413cdef class IOEvents: 

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

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

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

417  

418 Args: 

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

420  

421 .. seealso:: `CUfileIOEvents_t` 

422 """ 

423 cdef: 

424 readonly object _data 

425 object _owner 

426  

427 def __init__(self, size=1): 

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

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

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

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

432  

433 def __repr__(self): 

434 if self._data.size > 1: 

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

436 else: 

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

438  

439 @property 

440 def ptr(self): 

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

442 return self._data.ctypes.data 1df

443  

444 cdef intptr_t _get_ptr(self): 

445 return self._data.ctypes.data 

446  

447 def __int__(self): 

448 if self._data.size > 1: 

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

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

451 return self._data.ctypes.data 

452  

453 def __len__(self): 

454 return self._data.size 

455  

456 def __eq__(self, other): 

457 cdef object self_data = self._data 

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

459 return False 

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

461  

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

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

464  

465 def __releasebuffer__(self, Py_buffer *buffer): 

466 _cyb_cpython.PyBuffer_Release(buffer) 

467  

468 @property 

469 def cookie(self): 

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

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

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

473 return self._data.cookie 

474  

475 @cookie.setter 

476 def cookie(self, val): 

477 self._data.cookie = val 

478  

479 @property 

480 def status(self): 

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

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

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

484 return self._data.status 

485  

486 @status.setter 

487 def status(self, val): 

488 self._data.status = val 

489  

490 @property 

491 def ret(self): 

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

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

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

495 return self._data.ret 

496  

497 @ret.setter 

498 def ret(self, val): 

499 self._data.ret = val 

500  

501 def __getitem__(self, key): 

502 cdef ssize_t key_ 

503 cdef ssize_t size 

504 if isinstance(key, int): 1df

505 key_ = key 1df

506 size = self._data.size 1df

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

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

509 if key_ < 0: 1df

510 key_ += size 

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

512 out = self._data[key] 

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

514 return IOEvents.from_data(out) 

515 return out 

516  

517 def __setitem__(self, key, val): 

518 self._data[key] = val 

519  

520 @staticmethod 

521 def from_buffer(buffer): 

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

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

524  

525 @staticmethod 

526 def from_data(data): 

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

528  

529 Args: 

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

531 """ 

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

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

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

535 if data.ndim != 1: 1df

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

537 if data.dtype != io_events_dtype: 1df

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

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

540  

541 return obj 1df

542  

543 @staticmethod 

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

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

546  

547 Args: 

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

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

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

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

552 kept so the backing storage outlives this wrapper. 

553 """ 

554 if ptr == 0: 

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

556 cdef IOEvents obj = IOEvents.__new__(IOEvents) 

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

558 cdef object buf = _cyb_cpython_memoryview.PyMemoryView_FromMemory( 

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

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

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

562 obj._owner = owner 

563  

564 return obj 

565  

566  

567cdef _get_op_counter_dtype_offsets(): 

568 cdef CUfileOpCounter_t pod 

569 return _numpy.dtype({ 

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

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

572 'offsets': [ 

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

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

575 ], 

576 'itemsize': sizeof(CUfileOpCounter_t), 

577 }) 

578  

579op_counter_dtype = _get_op_counter_dtype_offsets() 

580  

581cdef class OpCounter: 

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

583  

584  

585 .. seealso:: `CUfileOpCounter_t` 

586 """ 

587 cdef: 

588 CUfileOpCounter_t *_ptr 

589 object _owner 

590 bint _owned 

591 bint _readonly 

592  

593 def __init__(self): 

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

595 if self._ptr == NULL: 

596 raise MemoryError("Error allocating OpCounter") 

597 self._owner = None 

598 self._owned = True 

599 self._readonly = False 

600  

601 def __dealloc__(self): 

602 cdef CUfileOpCounter_t *ptr 

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

604 ptr = self._ptr 

605 self._ptr = NULL 

606 _cyb_free(ptr) 

607  

608 def __repr__(self): 

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

610  

611 @property 

612 def ptr(self): 

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

614 return <intptr_t>(self._ptr) 

615  

616 cdef intptr_t _get_ptr(self): 

617 return <intptr_t>(self._ptr) 

618  

619 def __int__(self): 

620 return <intptr_t>(self._ptr) 

621  

622 def __eq__(self, other): 

623 cdef OpCounter other_ 

624 if not isinstance(other, OpCounter): 

625 return False 

626 other_ = other 

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

628  

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

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

631  

632 def __releasebuffer__(self, Py_buffer *buffer): 

633 pass 

634  

635 def __setitem__(self, key, val): 

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

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

638 if self._ptr == NULL: 

639 raise MemoryError("Error allocating OpCounter") 

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

641 self._owner = None 

642 self._owned = True 

643 self._readonly = not val.flags.writeable 

644 else: 

645 setattr(self, key, val) 

646  

647 @property 

648 def ok(self): 

649 """int: """ 

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

651  

652 @ok.setter 

653 def ok(self, val): 

654 if self._readonly: 

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

656 self._ptr[0].ok = val 

657  

658 @property 

659 def err(self): 

660 """int: """ 

661 return self._ptr[0].err 

662  

663 @err.setter 

664 def err(self, val): 

665 if self._readonly: 

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

667 self._ptr[0].err = val 

668  

669 @staticmethod 

670 def from_buffer(buffer): 

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

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

673  

674 @staticmethod 

675 def from_data(data): 

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

677  

678 Args: 

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

680 """ 

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

682  

683 @staticmethod 

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

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

686  

687 Args: 

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

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

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

691 """ 

692 if ptr == 0: 1ec

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

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

695 if owner is None: 1ec

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

697 if obj._ptr == NULL: 

698 raise MemoryError("Error allocating OpCounter") 

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

700 obj._owner = None 

701 obj._owned = True 

702 else: 

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

704 obj._owner = owner 1ec

705 obj._owned = False 1ec

706 obj._readonly = readonly 1ec

707 return obj 1ec

708  

709  

710cdef _get_per_gpu_stats_dtype_offsets(): 

711 cdef CUfilePerGpuStats_t pod 

712 return _numpy.dtype({ 

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

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

715 'offsets': [ 

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

746 ], 

747 'itemsize': sizeof(CUfilePerGpuStats_t), 

748 }) 

749  

750per_gpu_stats_dtype = _get_per_gpu_stats_dtype_offsets() 

751  

752cdef class PerGpuStats: 

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

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

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

756  

757 Args: 

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

759  

760 .. seealso:: `CUfilePerGpuStats_t` 

761 """ 

762 cdef: 

763 readonly object _data 

764 object _owner 

765  

766 def __init__(self, size=1): 

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

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

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

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

771  

772 def __repr__(self): 

773 if self._data.size > 1: 

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

775 else: 

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

777  

778 @property 

779 def ptr(self): 

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

781 return self._data.ctypes.data 

782  

783 cdef intptr_t _get_ptr(self): 

784 return self._data.ctypes.data 

785  

786 def __int__(self): 

787 if self._data.size > 1: 

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

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

790 return self._data.ctypes.data 

791  

792 def __len__(self): 

793 return self._data.size 

794  

795 def __eq__(self, other): 

796 cdef object self_data = self._data 

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

798 return False 

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

800  

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

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

803  

804 def __releasebuffer__(self, Py_buffer *buffer): 

805 _cyb_cpython.PyBuffer_Release(buffer) 

806  

807 @property 

808 def uuid(self): 

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

810 return self._data.uuid 

811  

812 @uuid.setter 

813 def uuid(self, val): 

814 self._data.uuid = val 

815  

816 @property 

817 def read_bytes(self): 

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

819 if self._data.size == 1: 

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

821 return self._data.read_bytes 

822  

823 @read_bytes.setter 

824 def read_bytes(self, val): 

825 self._data.read_bytes = val 

826  

827 @property 

828 def read_bw_bytes_per_sec(self): 

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

830 if self._data.size == 1: 

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

832 return self._data.read_bw_bytes_per_sec 

833  

834 @read_bw_bytes_per_sec.setter 

835 def read_bw_bytes_per_sec(self, val): 

836 self._data.read_bw_bytes_per_sec = val 

837  

838 @property 

839 def read_utilization(self): 

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

841 if self._data.size == 1: 

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

843 return self._data.read_utilization 

844  

845 @read_utilization.setter 

846 def read_utilization(self, val): 

847 self._data.read_utilization = val 

848  

849 @property 

850 def read_duration_us(self): 

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

852 if self._data.size == 1: 

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

854 return self._data.read_duration_us 

855  

856 @read_duration_us.setter 

857 def read_duration_us(self, val): 

858 self._data.read_duration_us = val 

859  

860 @property 

861 def n_total_reads(self): 

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

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

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

865 return self._data.n_total_reads 

866  

867 @n_total_reads.setter 

868 def n_total_reads(self, val): 

869 self._data.n_total_reads = val 

870  

871 @property 

872 def n_p2p_reads(self): 

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

874 if self._data.size == 1: 

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

876 return self._data.n_p2p_reads 

877  

878 @n_p2p_reads.setter 

879 def n_p2p_reads(self, val): 

880 self._data.n_p2p_reads = val 

881  

882 @property 

883 def n_nvfs_reads(self): 

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

885 if self._data.size == 1: 

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

887 return self._data.n_nvfs_reads 

888  

889 @n_nvfs_reads.setter 

890 def n_nvfs_reads(self, val): 

891 self._data.n_nvfs_reads = val 

892  

893 @property 

894 def n_posix_reads(self): 

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

896 if self._data.size == 1: 

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

898 return self._data.n_posix_reads 

899  

900 @n_posix_reads.setter 

901 def n_posix_reads(self, val): 

902 self._data.n_posix_reads = val 

903  

904 @property 

905 def n_unaligned_reads(self): 

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

907 if self._data.size == 1: 

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

909 return self._data.n_unaligned_reads 

910  

911 @n_unaligned_reads.setter 

912 def n_unaligned_reads(self, val): 

913 self._data.n_unaligned_reads = val 

914  

915 @property 

916 def n_dr_reads(self): 

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

918 if self._data.size == 1: 

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

920 return self._data.n_dr_reads 

921  

922 @n_dr_reads.setter 

923 def n_dr_reads(self, val): 

924 self._data.n_dr_reads = val 

925  

926 @property 

927 def n_sparse_regions(self): 

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

929 if self._data.size == 1: 

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

931 return self._data.n_sparse_regions 

932  

933 @n_sparse_regions.setter 

934 def n_sparse_regions(self, val): 

935 self._data.n_sparse_regions = val 

936  

937 @property 

938 def n_inline_regions(self): 

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

940 if self._data.size == 1: 

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

942 return self._data.n_inline_regions 

943  

944 @n_inline_regions.setter 

945 def n_inline_regions(self, val): 

946 self._data.n_inline_regions = val 

947  

948 @property 

949 def n_reads_err(self): 

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

951 if self._data.size == 1: 

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

953 return self._data.n_reads_err 

954  

955 @n_reads_err.setter 

956 def n_reads_err(self, val): 

957 self._data.n_reads_err = val 

958  

959 @property 

960 def writes_bytes(self): 

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

962 if self._data.size == 1: 

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

964 return self._data.writes_bytes 

965  

966 @writes_bytes.setter 

967 def writes_bytes(self, val): 

968 self._data.writes_bytes = val 

969  

970 @property 

971 def write_bw_bytes_per_sec(self): 

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

973 if self._data.size == 1: 

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

975 return self._data.write_bw_bytes_per_sec 

976  

977 @write_bw_bytes_per_sec.setter 

978 def write_bw_bytes_per_sec(self, val): 

979 self._data.write_bw_bytes_per_sec = val 

980  

981 @property 

982 def write_utilization(self): 

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

984 if self._data.size == 1: 

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

986 return self._data.write_utilization 

987  

988 @write_utilization.setter 

989 def write_utilization(self, val): 

990 self._data.write_utilization = val 

991  

992 @property 

993 def write_duration_us(self): 

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

995 if self._data.size == 1: 

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

997 return self._data.write_duration_us 

998  

999 @write_duration_us.setter 

1000 def write_duration_us(self, val): 

1001 self._data.write_duration_us = val 

1002  

1003 @property 

1004 def n_total_writes(self): 

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

1006 if self._data.size == 1: 

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

1008 return self._data.n_total_writes 

1009  

1010 @n_total_writes.setter 

1011 def n_total_writes(self, val): 

1012 self._data.n_total_writes = val 

1013  

1014 @property 

1015 def n_p2p_writes(self): 

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

1017 if self._data.size == 1: 

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

1019 return self._data.n_p2p_writes 

1020  

1021 @n_p2p_writes.setter 

1022 def n_p2p_writes(self, val): 

1023 self._data.n_p2p_writes = val 

1024  

1025 @property 

1026 def n_nvfs_writes(self): 

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

1028 if self._data.size == 1: 

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

1030 return self._data.n_nvfs_writes 

1031  

1032 @n_nvfs_writes.setter 

1033 def n_nvfs_writes(self, val): 

1034 self._data.n_nvfs_writes = val 

1035  

1036 @property 

1037 def n_posix_writes(self): 

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

1039 if self._data.size == 1: 

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

1041 return self._data.n_posix_writes 

1042  

1043 @n_posix_writes.setter 

1044 def n_posix_writes(self, val): 

1045 self._data.n_posix_writes = val 

1046  

1047 @property 

1048 def n_unaligned_writes(self): 

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

1050 if self._data.size == 1: 

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

1052 return self._data.n_unaligned_writes 

1053  

1054 @n_unaligned_writes.setter 

1055 def n_unaligned_writes(self, val): 

1056 self._data.n_unaligned_writes = val 

1057  

1058 @property 

1059 def n_dr_writes(self): 

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

1061 if self._data.size == 1: 

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

1063 return self._data.n_dr_writes 

1064  

1065 @n_dr_writes.setter 

1066 def n_dr_writes(self, val): 

1067 self._data.n_dr_writes = val 

1068  

1069 @property 

1070 def n_writes_err(self): 

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

1072 if self._data.size == 1: 

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

1074 return self._data.n_writes_err 

1075  

1076 @n_writes_err.setter 

1077 def n_writes_err(self, val): 

1078 self._data.n_writes_err = val 

1079  

1080 @property 

1081 def n_mmap(self): 

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

1083 if self._data.size == 1: 

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

1085 return self._data.n_mmap 

1086  

1087 @n_mmap.setter 

1088 def n_mmap(self, val): 

1089 self._data.n_mmap = val 

1090  

1091 @property 

1092 def n_mmap_ok(self): 

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

1094 if self._data.size == 1: 

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

1096 return self._data.n_mmap_ok 

1097  

1098 @n_mmap_ok.setter 

1099 def n_mmap_ok(self, val): 

1100 self._data.n_mmap_ok = val 

1101  

1102 @property 

1103 def n_mmap_err(self): 

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

1105 if self._data.size == 1: 

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

1107 return self._data.n_mmap_err 

1108  

1109 @n_mmap_err.setter 

1110 def n_mmap_err(self, val): 

1111 self._data.n_mmap_err = val 

1112  

1113 @property 

1114 def n_mmap_free(self): 

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

1116 if self._data.size == 1: 

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

1118 return self._data.n_mmap_free 

1119  

1120 @n_mmap_free.setter 

1121 def n_mmap_free(self, val): 

1122 self._data.n_mmap_free = val 

1123  

1124 @property 

1125 def reg_bytes(self): 

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

1127 if self._data.size == 1: 

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

1129 return self._data.reg_bytes 

1130  

1131 @reg_bytes.setter 

1132 def reg_bytes(self, val): 

1133 self._data.reg_bytes = val 

1134  

1135 def __getitem__(self, key): 

1136 cdef ssize_t key_ 

1137 cdef ssize_t size 

1138 if isinstance(key, int): 1b

1139 key_ = key 1b

1140 size = self._data.size 1b

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

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

1143 if key_ < 0: 1b

1144 key_ += size 

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

1146 out = self._data[key] 

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

1148 return PerGpuStats.from_data(out) 

1149 return out 

1150  

1151 def __setitem__(self, key, val): 

1152 self._data[key] = val 

1153  

1154 @staticmethod 

1155 def from_buffer(buffer): 

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

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

1158  

1159 @staticmethod 

1160 def from_data(data): 

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

1162  

1163 Args: 

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

1165 """ 

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

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

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

1169 if data.ndim != 1: 1b

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

1171 if data.dtype != per_gpu_stats_dtype: 1b

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

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

1174  

1175 return obj 1b

1176  

1177 @staticmethod 

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

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

1180  

1181 Args: 

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

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

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

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

1186 kept so the backing storage outlives this wrapper. 

1187 """ 

1188 if ptr == 0: 1b

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

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

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

1192 cdef object buf = _cyb_cpython_memoryview.PyMemoryView_FromMemory( 1b

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

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

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

1196 obj._owner = owner 1b

1197  

1198 return obj 1b

1199  

1200  

1201cdef _get_descr_dtype_offsets(): 

1202 cdef CUfileDescr_t pod 

1203 return _numpy.dtype({ 

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

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

1206 'offsets': [ 

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

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

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

1210 ], 

1211 'itemsize': sizeof(CUfileDescr_t), 

1212 }) 

1213  

1214descr_dtype = _get_descr_dtype_offsets() 

1215  

1216cdef class Descr: 

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

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

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

1220  

1221 Args: 

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

1223  

1224 .. seealso:: `CUfileDescr_t` 

1225 """ 

1226 cdef: 

1227 readonly object _data 

1228 object _owner 

1229  

1230 def __init__(self, size=1): 

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

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

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

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

1235  

1236 def __repr__(self): 

1237 if self._data.size > 1: 

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

1239 else: 

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

1241  

1242 @property 

1243 def ptr(self): 

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

1245 return self._data.ctypes.data 1dgfhijklmecbr

1246  

1247 cdef intptr_t _get_ptr(self): 

1248 return self._data.ctypes.data 

1249  

1250 def __int__(self): 

1251 if self._data.size > 1: 

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

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

1254 return self._data.ctypes.data 

1255  

1256 def __len__(self): 

1257 return self._data.size 

1258  

1259 def __eq__(self, other): 

1260 cdef object self_data = self._data 

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

1262 return False 

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

1264  

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

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

1267  

1268 def __releasebuffer__(self, Py_buffer *buffer): 

1269 _cyb_cpython.PyBuffer_Release(buffer) 

1270  

1271 @property 

1272 def type(self): 

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

1274 if self._data.size == 1: 

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

1276 return self._data.type 

1277  

1278 @type.setter 

1279 def type(self, val): 

1280 self._data.type = val 1dgfhijklmecbr

1281  

1282 @property 

1283 def handle(self): 

1284 """_py_anon_pod1_dtype: """ 

1285 return self._data.handle 1dgfhijklmecbr

1286  

1287 @handle.setter 

1288 def handle(self, val): 

1289 self._data.handle = val 

1290  

1291 @property 

1292 def fs_ops(self): 

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

1294 if self._data.size == 1: 

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

1296 return self._data.fs_ops 

1297  

1298 @fs_ops.setter 

1299 def fs_ops(self, val): 

1300 self._data.fs_ops = val 1dgfhijklmecbr

1301  

1302 def __getitem__(self, key): 

1303 cdef ssize_t key_ 

1304 cdef ssize_t size 

1305 if isinstance(key, int): 

1306 key_ = key 

1307 size = self._data.size 

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

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

1310 if key_ < 0: 

1311 key_ += size 

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

1313 out = self._data[key] 

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

1315 return Descr.from_data(out) 

1316 return out 

1317  

1318 def __setitem__(self, key, val): 

1319 self._data[key] = val 

1320  

1321 @staticmethod 

1322 def from_buffer(buffer): 

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

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

1325  

1326 @staticmethod 

1327 def from_data(data): 

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

1329  

1330 Args: 

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

1332 """ 

1333 cdef Descr obj = Descr.__new__(Descr) 

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

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

1336 if data.ndim != 1: 

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

1338 if data.dtype != descr_dtype: 

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

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

1341  

1342 return obj 

1343  

1344 @staticmethod 

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

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

1347  

1348 Args: 

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

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

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

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

1353 kept so the backing storage outlives this wrapper. 

1354 """ 

1355 if ptr == 0: 

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

1357 cdef Descr obj = Descr.__new__(Descr) 

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

1359 cdef object buf = _cyb_cpython_memoryview.PyMemoryView_FromMemory( 

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

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

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

1363 obj._owner = owner 

1364  

1365 return obj 

1366  

1367  

1368cdef _get__py_anon_pod2_dtype_offsets(): 

1369 cdef cuda_bindings_cufile__anon_pod2 pod 

1370 return _numpy.dtype({ 

1371 'names': ['batch'], 

1372 'formats': [_py_anon_pod3_dtype], 

1373 'offsets': [ 

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

1375 ], 

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

1377 }) 

1378  

1379_py_anon_pod2_dtype = _get__py_anon_pod2_dtype_offsets() 

1380  

1381cdef class _py_anon_pod2: 

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

1383  

1384  

1385 .. seealso:: `cuda_bindings_cufile__anon_pod2` 

1386 """ 

1387 cdef: 

1388 cuda_bindings_cufile__anon_pod2 *_ptr 

1389 object _owner 

1390 bint _owned 

1391 bint _readonly 

1392  

1393 def __init__(self): 

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

1395 if self._ptr == NULL: 

1396 raise MemoryError("Error allocating _py_anon_pod2") 

1397 self._owner = None 

1398 self._owned = True 

1399 self._readonly = False 

1400  

1401 def __dealloc__(self): 

1402 cdef cuda_bindings_cufile__anon_pod2 *ptr 

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

1404 ptr = self._ptr 

1405 self._ptr = NULL 

1406 _cyb_free(ptr) 

1407  

1408 def __repr__(self): 

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

1410  

1411 @property 

1412 def ptr(self): 

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

1414 return <intptr_t>(self._ptr) 

1415  

1416 cdef intptr_t _get_ptr(self): 

1417 return <intptr_t>(self._ptr) 

1418  

1419 def __int__(self): 

1420 return <intptr_t>(self._ptr) 

1421  

1422 def __eq__(self, other): 

1423 cdef _py_anon_pod2 other_ 

1424 if not isinstance(other, _py_anon_pod2): 

1425 return False 

1426 other_ = other 

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

1428  

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

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

1431  

1432 def __releasebuffer__(self, Py_buffer *buffer): 

1433 pass 

1434  

1435 def __setitem__(self, key, val): 

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

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

1438 if self._ptr == NULL: 

1439 raise MemoryError("Error allocating _py_anon_pod2") 

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

1441 self._owner = None 

1442 self._owned = True 

1443 self._readonly = not val.flags.writeable 

1444 else: 

1445 setattr(self, key, val) 

1446  

1447 @property 

1448 def batch(self): 

1449 """_py_anon_pod3: """ 

1450 return _py_anon_pod3.from_ptr( 

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

1452 readonly=self._readonly, 

1453 owner=self, 

1454 ) 

1455  

1456 @batch.setter 

1457 def batch(self, val): 

1458 if self._readonly: 

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

1460 cdef _py_anon_pod3 val_ = val 

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

1462  

1463 @staticmethod 

1464 def from_buffer(buffer): 

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

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

1467  

1468 @staticmethod 

1469 def from_data(data): 

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

1471  

1472 Args: 

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

1474 """ 

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

1476  

1477 @staticmethod 

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

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

1480  

1481 Args: 

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

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

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

1485 """ 

1486 if ptr == 0: 

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

1488 cdef _py_anon_pod2 obj = _py_anon_pod2.__new__(_py_anon_pod2) 

1489 if owner is None: 

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

1491 if obj._ptr == NULL: 

1492 raise MemoryError("Error allocating _py_anon_pod2") 

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

1494 obj._owner = None 

1495 obj._owned = True 

1496 else: 

1497 obj._ptr = <cuda_bindings_cufile__anon_pod2 *>ptr 

1498 obj._owner = owner 

1499 obj._owned = False 

1500 obj._readonly = readonly 

1501 return obj 

1502  

1503  

1504cdef _get_stats_level1_dtype_offsets(): 

1505 cdef CUfileStatsLevel1_t pod 

1506 return _numpy.dtype({ 

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

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

1509 'offsets': [ 

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1553 ], 

1554 'itemsize': sizeof(CUfileStatsLevel1_t), 

1555 }) 

1556  

1557stats_level1_dtype = _get_stats_level1_dtype_offsets() 

1558  

1559cdef class StatsLevel1: 

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

1561  

1562  

1563 .. seealso:: `CUfileStatsLevel1_t` 

1564 """ 

1565 cdef: 

1566 CUfileStatsLevel1_t *_ptr 

1567 object _owner 

1568 bint _owned 

1569 bint _readonly 

1570  

1571 def __init__(self): 

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

1573 if self._ptr == NULL: 1e

1574 raise MemoryError("Error allocating StatsLevel1") 

1575 self._owner = None 1e

1576 self._owned = True 1e

1577 self._readonly = False 1e

1578  

1579 def __dealloc__(self): 

1580 cdef CUfileStatsLevel1_t *ptr 

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

1582 ptr = self._ptr 1e

1583 self._ptr = NULL 1e

1584 _cyb_free(ptr) 1e

1585  

1586 def __repr__(self): 

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

1588  

1589 @property 

1590 def ptr(self): 

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

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

1593  

1594 cdef intptr_t _get_ptr(self): 

1595 return <intptr_t>(self._ptr) 

1596  

1597 def __int__(self): 

1598 return <intptr_t>(self._ptr) 

1599  

1600 def __eq__(self, other): 

1601 cdef StatsLevel1 other_ 

1602 if not isinstance(other, StatsLevel1): 

1603 return False 

1604 other_ = other 

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

1606  

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

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

1609  

1610 def __releasebuffer__(self, Py_buffer *buffer): 

1611 pass 

1612  

1613 def __setitem__(self, key, val): 

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

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

1616 if self._ptr == NULL: 

1617 raise MemoryError("Error allocating StatsLevel1") 

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

1619 self._owner = None 

1620 self._owned = True 

1621 self._readonly = not val.flags.writeable 

1622 else: 

1623 setattr(self, key, val) 

1624  

1625 @property 

1626 def read_ops(self): 

1627 """OpCounter: """ 

1628 return OpCounter.from_ptr( 1ec

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

1630 readonly=self._readonly, 1ec

1631 owner=self, 1ec

1632 ) 

1633  

1634 @read_ops.setter 

1635 def read_ops(self, val): 

1636 if self._readonly: 

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

1638 cdef OpCounter val_ = val 

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

1640  

1641 @property 

1642 def write_ops(self): 

1643 """OpCounter: """ 

1644 return OpCounter.from_ptr( 1ec

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

1646 readonly=self._readonly, 1ec

1647 owner=self, 1ec

1648 ) 

1649  

1650 @write_ops.setter 

1651 def write_ops(self, val): 

1652 if self._readonly: 

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

1654 cdef OpCounter val_ = val 

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

1656  

1657 @property 

1658 def hdl_register_ops(self): 

1659 """OpCounter: """ 

1660 return OpCounter.from_ptr( 

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

1662 readonly=self._readonly, 

1663 owner=self, 

1664 ) 

1665  

1666 @hdl_register_ops.setter 

1667 def hdl_register_ops(self, val): 

1668 if self._readonly: 

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

1670 cdef OpCounter val_ = val 

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

1672  

1673 @property 

1674 def hdl_deregister_ops(self): 

1675 """OpCounter: """ 

1676 return OpCounter.from_ptr( 

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

1678 readonly=self._readonly, 

1679 owner=self, 

1680 ) 

1681  

1682 @hdl_deregister_ops.setter 

1683 def hdl_deregister_ops(self, val): 

1684 if self._readonly: 

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

1686 cdef OpCounter val_ = val 

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

1688  

1689 @property 

1690 def buf_register_ops(self): 

1691 """OpCounter: """ 

1692 return OpCounter.from_ptr( 

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

1694 readonly=self._readonly, 

1695 owner=self, 

1696 ) 

1697  

1698 @buf_register_ops.setter 

1699 def buf_register_ops(self, val): 

1700 if self._readonly: 

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

1702 cdef OpCounter val_ = val 

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

1704  

1705 @property 

1706 def buf_deregister_ops(self): 

1707 """OpCounter: """ 

1708 return OpCounter.from_ptr( 

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

1710 readonly=self._readonly, 

1711 owner=self, 

1712 ) 

1713  

1714 @buf_deregister_ops.setter 

1715 def buf_deregister_ops(self, val): 

1716 if self._readonly: 

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

1718 cdef OpCounter val_ = val 

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

1720  

1721 @property 

1722 def batch_submit_ops(self): 

1723 """OpCounter: """ 

1724 return OpCounter.from_ptr( 

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

1726 readonly=self._readonly, 

1727 owner=self, 

1728 ) 

1729  

1730 @batch_submit_ops.setter 

1731 def batch_submit_ops(self, val): 

1732 if self._readonly: 

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

1734 cdef OpCounter val_ = val 

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

1736  

1737 @property 

1738 def batch_complete_ops(self): 

1739 """OpCounter: """ 

1740 return OpCounter.from_ptr( 

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

1742 readonly=self._readonly, 

1743 owner=self, 

1744 ) 

1745  

1746 @batch_complete_ops.setter 

1747 def batch_complete_ops(self, val): 

1748 if self._readonly: 

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

1750 cdef OpCounter val_ = val 

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

1752  

1753 @property 

1754 def batch_setup_ops(self): 

1755 """OpCounter: """ 

1756 return OpCounter.from_ptr( 

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

1758 readonly=self._readonly, 

1759 owner=self, 

1760 ) 

1761  

1762 @batch_setup_ops.setter 

1763 def batch_setup_ops(self, val): 

1764 if self._readonly: 

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

1766 cdef OpCounter val_ = val 

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

1768  

1769 @property 

1770 def batch_cancel_ops(self): 

1771 """OpCounter: """ 

1772 return OpCounter.from_ptr( 

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

1774 readonly=self._readonly, 

1775 owner=self, 

1776 ) 

1777  

1778 @batch_cancel_ops.setter 

1779 def batch_cancel_ops(self, val): 

1780 if self._readonly: 

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

1782 cdef OpCounter val_ = val 

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

1784  

1785 @property 

1786 def batch_destroy_ops(self): 

1787 """OpCounter: """ 

1788 return OpCounter.from_ptr( 

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

1790 readonly=self._readonly, 

1791 owner=self, 

1792 ) 

1793  

1794 @batch_destroy_ops.setter 

1795 def batch_destroy_ops(self, val): 

1796 if self._readonly: 

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

1798 cdef OpCounter val_ = val 

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

1800  

1801 @property 

1802 def batch_enqueued_ops(self): 

1803 """OpCounter: """ 

1804 return OpCounter.from_ptr( 

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

1806 readonly=self._readonly, 

1807 owner=self, 

1808 ) 

1809  

1810 @batch_enqueued_ops.setter 

1811 def batch_enqueued_ops(self, val): 

1812 if self._readonly: 

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

1814 cdef OpCounter val_ = val 

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

1816  

1817 @property 

1818 def batch_posix_enqueued_ops(self): 

1819 """OpCounter: """ 

1820 return OpCounter.from_ptr( 

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

1822 readonly=self._readonly, 

1823 owner=self, 

1824 ) 

1825  

1826 @batch_posix_enqueued_ops.setter 

1827 def batch_posix_enqueued_ops(self, val): 

1828 if self._readonly: 

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

1830 cdef OpCounter val_ = val 

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

1832  

1833 @property 

1834 def batch_processed_ops(self): 

1835 """OpCounter: """ 

1836 return OpCounter.from_ptr( 

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

1838 readonly=self._readonly, 

1839 owner=self, 

1840 ) 

1841  

1842 @batch_processed_ops.setter 

1843 def batch_processed_ops(self, val): 

1844 if self._readonly: 

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

1846 cdef OpCounter val_ = val 

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

1848  

1849 @property 

1850 def batch_posix_processed_ops(self): 

1851 """OpCounter: """ 

1852 return OpCounter.from_ptr( 

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

1854 readonly=self._readonly, 

1855 owner=self, 

1856 ) 

1857  

1858 @batch_posix_processed_ops.setter 

1859 def batch_posix_processed_ops(self, val): 

1860 if self._readonly: 

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

1862 cdef OpCounter val_ = val 

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

1864  

1865 @property 

1866 def batch_nvfs_submit_ops(self): 

1867 """OpCounter: """ 

1868 return OpCounter.from_ptr( 

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

1870 readonly=self._readonly, 

1871 owner=self, 

1872 ) 

1873  

1874 @batch_nvfs_submit_ops.setter 

1875 def batch_nvfs_submit_ops(self, val): 

1876 if self._readonly: 

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

1878 cdef OpCounter val_ = val 

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

1880  

1881 @property 

1882 def batch_p2p_submit_ops(self): 

1883 """OpCounter: """ 

1884 return OpCounter.from_ptr( 

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

1886 readonly=self._readonly, 

1887 owner=self, 

1888 ) 

1889  

1890 @batch_p2p_submit_ops.setter 

1891 def batch_p2p_submit_ops(self, val): 

1892 if self._readonly: 

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

1894 cdef OpCounter val_ = val 

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

1896  

1897 @property 

1898 def batch_aio_submit_ops(self): 

1899 """OpCounter: """ 

1900 return OpCounter.from_ptr( 

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

1902 readonly=self._readonly, 

1903 owner=self, 

1904 ) 

1905  

1906 @batch_aio_submit_ops.setter 

1907 def batch_aio_submit_ops(self, val): 

1908 if self._readonly: 

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

1910 cdef OpCounter val_ = val 

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

1912  

1913 @property 

1914 def batch_iouring_submit_ops(self): 

1915 """OpCounter: """ 

1916 return OpCounter.from_ptr( 

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

1918 readonly=self._readonly, 

1919 owner=self, 

1920 ) 

1921  

1922 @batch_iouring_submit_ops.setter 

1923 def batch_iouring_submit_ops(self, val): 

1924 if self._readonly: 

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

1926 cdef OpCounter val_ = val 

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

1928  

1929 @property 

1930 def batch_mixed_io_submit_ops(self): 

1931 """OpCounter: """ 

1932 return OpCounter.from_ptr( 

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

1934 readonly=self._readonly, 

1935 owner=self, 

1936 ) 

1937  

1938 @batch_mixed_io_submit_ops.setter 

1939 def batch_mixed_io_submit_ops(self, val): 

1940 if self._readonly: 

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

1942 cdef OpCounter val_ = val 

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

1944  

1945 @property 

1946 def batch_total_submit_ops(self): 

1947 """OpCounter: """ 

1948 return OpCounter.from_ptr( 

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

1950 readonly=self._readonly, 

1951 owner=self, 

1952 ) 

1953  

1954 @batch_total_submit_ops.setter 

1955 def batch_total_submit_ops(self, val): 

1956 if self._readonly: 

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

1958 cdef OpCounter val_ = val 

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

1960  

1961 @property 

1962 def read_bytes(self): 

1963 """int: """ 

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

1965  

1966 @read_bytes.setter 

1967 def read_bytes(self, val): 

1968 if self._readonly: 

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

1970 self._ptr[0].read_bytes = val 

1971  

1972 @property 

1973 def write_bytes(self): 

1974 """int: """ 

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

1976  

1977 @write_bytes.setter 

1978 def write_bytes(self, val): 

1979 if self._readonly: 

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

1981 self._ptr[0].write_bytes = val 

1982  

1983 @property 

1984 def read_bw_bytes_per_sec(self): 

1985 """int: """ 

1986 return self._ptr[0].read_bw_bytes_per_sec 

1987  

1988 @read_bw_bytes_per_sec.setter 

1989 def read_bw_bytes_per_sec(self, val): 

1990 if self._readonly: 

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

1992 self._ptr[0].read_bw_bytes_per_sec = val 

1993  

1994 @property 

1995 def write_bw_bytes_per_sec(self): 

1996 """int: """ 

1997 return self._ptr[0].write_bw_bytes_per_sec 

1998  

1999 @write_bw_bytes_per_sec.setter 

2000 def write_bw_bytes_per_sec(self, val): 

2001 if self._readonly: 

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

2003 self._ptr[0].write_bw_bytes_per_sec = val 

2004  

2005 @property 

2006 def read_lat_avg_us(self): 

2007 """int: """ 

2008 return self._ptr[0].read_lat_avg_us 

2009  

2010 @read_lat_avg_us.setter 

2011 def read_lat_avg_us(self, val): 

2012 if self._readonly: 

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

2014 self._ptr[0].read_lat_avg_us = val 

2015  

2016 @property 

2017 def write_lat_avg_us(self): 

2018 """int: """ 

2019 return self._ptr[0].write_lat_avg_us 

2020  

2021 @write_lat_avg_us.setter 

2022 def write_lat_avg_us(self, val): 

2023 if self._readonly: 

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

2025 self._ptr[0].write_lat_avg_us = val 

2026  

2027 @property 

2028 def read_ops_per_sec(self): 

2029 """int: """ 

2030 return self._ptr[0].read_ops_per_sec 

2031  

2032 @read_ops_per_sec.setter 

2033 def read_ops_per_sec(self, val): 

2034 if self._readonly: 

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

2036 self._ptr[0].read_ops_per_sec = val 

2037  

2038 @property 

2039 def write_ops_per_sec(self): 

2040 """int: """ 

2041 return self._ptr[0].write_ops_per_sec 

2042  

2043 @write_ops_per_sec.setter 

2044 def write_ops_per_sec(self, val): 

2045 if self._readonly: 

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

2047 self._ptr[0].write_ops_per_sec = val 

2048  

2049 @property 

2050 def read_lat_sum_us(self): 

2051 """int: """ 

2052 return self._ptr[0].read_lat_sum_us 

2053  

2054 @read_lat_sum_us.setter 

2055 def read_lat_sum_us(self, val): 

2056 if self._readonly: 

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

2058 self._ptr[0].read_lat_sum_us = val 

2059  

2060 @property 

2061 def write_lat_sum_us(self): 

2062 """int: """ 

2063 return self._ptr[0].write_lat_sum_us 

2064  

2065 @write_lat_sum_us.setter 

2066 def write_lat_sum_us(self, val): 

2067 if self._readonly: 

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

2069 self._ptr[0].write_lat_sum_us = val 

2070  

2071 @property 

2072 def batch_read_bytes(self): 

2073 """int: """ 

2074 return self._ptr[0].batch_read_bytes 

2075  

2076 @batch_read_bytes.setter 

2077 def batch_read_bytes(self, val): 

2078 if self._readonly: 

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

2080 self._ptr[0].batch_read_bytes = val 

2081  

2082 @property 

2083 def batch_write_bytes(self): 

2084 """int: """ 

2085 return self._ptr[0].batch_write_bytes 

2086  

2087 @batch_write_bytes.setter 

2088 def batch_write_bytes(self, val): 

2089 if self._readonly: 

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

2091 self._ptr[0].batch_write_bytes = val 

2092  

2093 @property 

2094 def batch_read_bw_bytes(self): 

2095 """int: """ 

2096 return self._ptr[0].batch_read_bw_bytes 

2097  

2098 @batch_read_bw_bytes.setter 

2099 def batch_read_bw_bytes(self, val): 

2100 if self._readonly: 

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

2102 self._ptr[0].batch_read_bw_bytes = val 

2103  

2104 @property 

2105 def batch_write_bw_bytes(self): 

2106 """int: """ 

2107 return self._ptr[0].batch_write_bw_bytes 

2108  

2109 @batch_write_bw_bytes.setter 

2110 def batch_write_bw_bytes(self, val): 

2111 if self._readonly: 

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

2113 self._ptr[0].batch_write_bw_bytes = val 

2114  

2115 @property 

2116 def batch_submit_lat_avg_us(self): 

2117 """int: """ 

2118 return self._ptr[0].batch_submit_lat_avg_us 

2119  

2120 @batch_submit_lat_avg_us.setter 

2121 def batch_submit_lat_avg_us(self, val): 

2122 if self._readonly: 

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

2124 self._ptr[0].batch_submit_lat_avg_us = val 

2125  

2126 @property 

2127 def batch_completion_lat_avg_us(self): 

2128 """int: """ 

2129 return self._ptr[0].batch_completion_lat_avg_us 

2130  

2131 @batch_completion_lat_avg_us.setter 

2132 def batch_completion_lat_avg_us(self, val): 

2133 if self._readonly: 

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

2135 self._ptr[0].batch_completion_lat_avg_us = val 

2136  

2137 @property 

2138 def batch_submit_ops_per_sec(self): 

2139 """int: """ 

2140 return self._ptr[0].batch_submit_ops_per_sec 

2141  

2142 @batch_submit_ops_per_sec.setter 

2143 def batch_submit_ops_per_sec(self, val): 

2144 if self._readonly: 

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

2146 self._ptr[0].batch_submit_ops_per_sec = val 

2147  

2148 @property 

2149 def batch_complete_ops_per_sec(self): 

2150 """int: """ 

2151 return self._ptr[0].batch_complete_ops_per_sec 

2152  

2153 @batch_complete_ops_per_sec.setter 

2154 def batch_complete_ops_per_sec(self, val): 

2155 if self._readonly: 

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

2157 self._ptr[0].batch_complete_ops_per_sec = val 

2158  

2159 @property 

2160 def batch_submit_lat_sum_us(self): 

2161 """int: """ 

2162 return self._ptr[0].batch_submit_lat_sum_us 

2163  

2164 @batch_submit_lat_sum_us.setter 

2165 def batch_submit_lat_sum_us(self, val): 

2166 if self._readonly: 

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

2168 self._ptr[0].batch_submit_lat_sum_us = val 

2169  

2170 @property 

2171 def batch_completion_lat_sum_us(self): 

2172 """int: """ 

2173 return self._ptr[0].batch_completion_lat_sum_us 

2174  

2175 @batch_completion_lat_sum_us.setter 

2176 def batch_completion_lat_sum_us(self, val): 

2177 if self._readonly: 

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

2179 self._ptr[0].batch_completion_lat_sum_us = val 

2180  

2181 @property 

2182 def last_batch_read_bytes(self): 

2183 """int: """ 

2184 return self._ptr[0].last_batch_read_bytes 

2185  

2186 @last_batch_read_bytes.setter 

2187 def last_batch_read_bytes(self, val): 

2188 if self._readonly: 

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

2190 self._ptr[0].last_batch_read_bytes = val 

2191  

2192 @property 

2193 def last_batch_write_bytes(self): 

2194 """int: """ 

2195 return self._ptr[0].last_batch_write_bytes 

2196  

2197 @last_batch_write_bytes.setter 

2198 def last_batch_write_bytes(self, val): 

2199 if self._readonly: 

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

2201 self._ptr[0].last_batch_write_bytes = val 

2202  

2203 @staticmethod 

2204 def from_buffer(buffer): 

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

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

2207  

2208 @staticmethod 

2209 def from_data(data): 

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

2211  

2212 Args: 

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

2214 """ 

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

2216  

2217 @staticmethod 

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

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

2220  

2221 Args: 

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

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

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

2225 """ 

2226 if ptr == 0: 1c

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

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

2229 if owner is None: 1c

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

2231 if obj._ptr == NULL: 

2232 raise MemoryError("Error allocating StatsLevel1") 

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

2234 obj._owner = None 

2235 obj._owned = True 

2236 else: 

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

2238 obj._owner = owner 1c

2239 obj._owned = False 1c

2240 obj._readonly = readonly 1c

2241 return obj 1c

2242  

2243  

2244cdef _get_io_params_dtype_offsets(): 

2245 cdef CUfileIOParams_t pod 

2246 return _numpy.dtype({ 

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

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

2249 'offsets': [ 

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

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

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

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

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

2255 ], 

2256 'itemsize': sizeof(CUfileIOParams_t), 

2257 }) 

2258  

2259io_params_dtype = _get_io_params_dtype_offsets() 

2260  

2261cdef class IOParams: 

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

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

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

2265  

2266 Args: 

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

2268  

2269 .. seealso:: `CUfileIOParams_t` 

2270 """ 

2271 cdef: 

2272 readonly object _data 

2273 object _owner 

2274  

2275 def __init__(self, size=1): 

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

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

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

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

2280  

2281 def __repr__(self): 

2282 if self._data.size > 1: 

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

2284 else: 

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

2286  

2287 @property 

2288 def ptr(self): 

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

2290 return self._data.ctypes.data 1dgf

2291  

2292 cdef intptr_t _get_ptr(self): 

2293 return self._data.ctypes.data 

2294  

2295 def __int__(self): 

2296 if self._data.size > 1: 

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

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

2299 return self._data.ctypes.data 

2300  

2301 def __len__(self): 

2302 return self._data.size 

2303  

2304 def __eq__(self, other): 

2305 cdef object self_data = self._data 

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

2307 return False 

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

2309  

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

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

2312  

2313 def __releasebuffer__(self, Py_buffer *buffer): 

2314 _cyb_cpython.PyBuffer_Release(buffer) 

2315  

2316 @property 

2317 def mode(self): 

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

2319 if self._data.size == 1: 

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

2321 return self._data.mode 

2322  

2323 @mode.setter 

2324 def mode(self, val): 

2325 self._data.mode = val 1dgf

2326  

2327 @property 

2328 def u(self): 

2329 """_py_anon_pod2_dtype: """ 

2330 return self._data.u 1dgf

2331  

2332 @u.setter 

2333 def u(self, val): 

2334 self._data.u = val 

2335  

2336 @property 

2337 def fh(self): 

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

2339 if self._data.size == 1: 

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

2341 return self._data.fh 

2342  

2343 @fh.setter 

2344 def fh(self, val): 

2345 self._data.fh = val 1dgf

2346  

2347 @property 

2348 def opcode(self): 

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

2350 if self._data.size == 1: 

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

2352 return self._data.opcode 

2353  

2354 @opcode.setter 

2355 def opcode(self, val): 

2356 self._data.opcode = val 1dgf

2357  

2358 @property 

2359 def cookie(self): 

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

2361 if self._data.size == 1: 

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

2363 return self._data.cookie 

2364  

2365 @cookie.setter 

2366 def cookie(self, val): 

2367 self._data.cookie = val 1dgf

2368  

2369 def __getitem__(self, key): 

2370 cdef ssize_t key_ 

2371 cdef ssize_t size 

2372 if isinstance(key, int): 1dgf

2373 key_ = key 1dgf

2374 size = self._data.size 1dgf

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

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

2377 if key_ < 0: 1dgf

2378 key_ += size 

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

2380 out = self._data[key] 

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

2382 return IOParams.from_data(out) 

2383 return out 

2384  

2385 def __setitem__(self, key, val): 

2386 self._data[key] = val 

2387  

2388 @staticmethod 

2389 def from_buffer(buffer): 

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

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

2392  

2393 @staticmethod 

2394 def from_data(data): 

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

2396  

2397 Args: 

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

2399 """ 

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

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

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

2403 if data.ndim != 1: 1dgf

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

2405 if data.dtype != io_params_dtype: 1dgf

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

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

2408  

2409 return obj 1dgf

2410  

2411 @staticmethod 

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

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

2414  

2415 Args: 

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

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

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

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

2420 kept so the backing storage outlives this wrapper. 

2421 """ 

2422 if ptr == 0: 

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

2424 cdef IOParams obj = IOParams.__new__(IOParams) 

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

2426 cdef object buf = _cyb_cpython_memoryview.PyMemoryView_FromMemory( 

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

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

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

2430 obj._owner = owner 

2431  

2432 return obj 

2433  

2434  

2435cdef _get_stats_level2_dtype_offsets(): 

2436 cdef CUfileStatsLevel2_t pod 

2437 return _numpy.dtype({ 

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

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

2440 'offsets': [ 

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

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

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

2444 ], 

2445 'itemsize': sizeof(CUfileStatsLevel2_t), 

2446 }) 

2447  

2448stats_level2_dtype = _get_stats_level2_dtype_offsets() 

2449  

2450cdef class StatsLevel2: 

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

2452  

2453  

2454 .. seealso:: `CUfileStatsLevel2_t` 

2455 """ 

2456 cdef: 

2457 CUfileStatsLevel2_t *_ptr 

2458 object _owner 

2459 bint _owned 

2460 bint _readonly 

2461  

2462 def __init__(self): 

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

2464 if self._ptr == NULL: 1c

2465 raise MemoryError("Error allocating StatsLevel2") 

2466 self._owner = None 1c

2467 self._owned = True 1c

2468 self._readonly = False 1c

2469  

2470 def __dealloc__(self): 

2471 cdef CUfileStatsLevel2_t *ptr 

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

2473 ptr = self._ptr 1c

2474 self._ptr = NULL 1c

2475 _cyb_free(ptr) 1c

2476  

2477 def __repr__(self): 

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

2479  

2480 @property 

2481 def ptr(self): 

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

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

2484  

2485 cdef intptr_t _get_ptr(self): 

2486 return <intptr_t>(self._ptr) 

2487  

2488 def __int__(self): 

2489 return <intptr_t>(self._ptr) 

2490  

2491 def __eq__(self, other): 

2492 cdef StatsLevel2 other_ 

2493 if not isinstance(other, StatsLevel2): 

2494 return False 

2495 other_ = other 

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

2497  

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

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

2500  

2501 def __releasebuffer__(self, Py_buffer *buffer): 

2502 pass 

2503  

2504 def __setitem__(self, key, val): 

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

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

2507 if self._ptr == NULL: 

2508 raise MemoryError("Error allocating StatsLevel2") 

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

2510 self._owner = None 

2511 self._owned = True 

2512 self._readonly = not val.flags.writeable 

2513 else: 

2514 setattr(self, key, val) 

2515  

2516 @property 

2517 def basic(self): 

2518 """StatsLevel1: """ 

2519 return StatsLevel1.from_ptr( 1c

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

2521 readonly=self._readonly, 1c

2522 owner=self, 1c

2523 ) 

2524  

2525 @basic.setter 

2526 def basic(self, val): 

2527 if self._readonly: 

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

2529 cdef StatsLevel1 val_ = val 

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

2531  

2532 @property 

2533 def read_size_kb_hist(self): 

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

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

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

2537 return _numpy.asarray(arr) 1cb

2538  

2539 @read_size_kb_hist.setter 

2540 def read_size_kb_hist(self, val): 

2541 if self._readonly: 

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

2543 if len(val) != 32: 

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

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

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

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

2548  

2549 @property 

2550 def write_size_kb_hist(self): 

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

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

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

2554 return _numpy.asarray(arr) 1c

2555  

2556 @write_size_kb_hist.setter 

2557 def write_size_kb_hist(self, val): 

2558 if self._readonly: 

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

2560 if len(val) != 32: 

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

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

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

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

2565  

2566 @staticmethod 

2567 def from_buffer(buffer): 

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

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

2570  

2571 @staticmethod 

2572 def from_data(data): 

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

2574  

2575 Args: 

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

2577 """ 

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

2579  

2580 @staticmethod 

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

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

2583  

2584 Args: 

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

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

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

2588 """ 

2589 if ptr == 0: 1b

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

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

2592 if owner is None: 1b

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

2594 if obj._ptr == NULL: 

2595 raise MemoryError("Error allocating StatsLevel2") 

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

2597 obj._owner = None 

2598 obj._owned = True 

2599 else: 

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

2601 obj._owner = owner 1b

2602 obj._owned = False 1b

2603 obj._readonly = readonly 1b

2604 return obj 1b

2605  

2606  

2607cdef _get_stats_level3_dtype_offsets(): 

2608 cdef CUfileStatsLevel3_t pod 

2609 return _numpy.dtype({ 

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

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

2612 'offsets': [ 

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

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

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

2616 ], 

2617 'itemsize': sizeof(CUfileStatsLevel3_t), 

2618 }) 

2619  

2620stats_level3_dtype = _get_stats_level3_dtype_offsets() 

2621  

2622cdef class StatsLevel3: 

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

2624  

2625  

2626 .. seealso:: `CUfileStatsLevel3_t` 

2627 """ 

2628 cdef: 

2629 CUfileStatsLevel3_t *_ptr 

2630 object _owner 

2631 bint _owned 

2632 bint _readonly 

2633  

2634 def __init__(self): 

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

2636 if self._ptr == NULL: 1b

2637 raise MemoryError("Error allocating StatsLevel3") 

2638 self._owner = None 1b

2639 self._owned = True 1b

2640 self._readonly = False 1b

2641  

2642 def __dealloc__(self): 

2643 cdef CUfileStatsLevel3_t *ptr 

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

2645 ptr = self._ptr 1b

2646 self._ptr = NULL 1b

2647 _cyb_free(ptr) 1b

2648  

2649 def __repr__(self): 

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

2651  

2652 @property 

2653 def ptr(self): 

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

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

2656  

2657 cdef intptr_t _get_ptr(self): 

2658 return <intptr_t>(self._ptr) 

2659  

2660 def __int__(self): 

2661 return <intptr_t>(self._ptr) 

2662  

2663 def __eq__(self, other): 

2664 cdef StatsLevel3 other_ 

2665 if not isinstance(other, StatsLevel3): 

2666 return False 

2667 other_ = other 

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

2669  

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

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

2672  

2673 def __releasebuffer__(self, Py_buffer *buffer): 

2674 pass 

2675  

2676 def __setitem__(self, key, val): 

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

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

2679 if self._ptr == NULL: 

2680 raise MemoryError("Error allocating StatsLevel3") 

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

2682 self._owner = None 

2683 self._owned = True 

2684 self._readonly = not val.flags.writeable 

2685 else: 

2686 setattr(self, key, val) 

2687  

2688 @property 

2689 def detailed(self): 

2690 """StatsLevel2: """ 

2691 return StatsLevel2.from_ptr( 1b

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

2693 readonly=self._readonly, 1b

2694 owner=self, 1b

2695 ) 

2696  

2697 @detailed.setter 

2698 def detailed(self, val): 

2699 if self._readonly: 

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

2701 cdef StatsLevel2 val_ = val 

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

2703  

2704 @property 

2705 def per_gpu_stats(self): 

2706 """PerGpuStats: """ 

2707 return PerGpuStats.from_ptr( 1b

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

2709 16, 

2710 readonly=self._readonly, 1b

2711 owner=self, 1b

2712 ) 

2713  

2714 @per_gpu_stats.setter 

2715 def per_gpu_stats(self, val): 

2716 if self._readonly: 

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

2718 cdef PerGpuStats val_ = val 

2719 if len(val) != 16: 

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

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

2722  

2723 @property 

2724 def num_gpus(self): 

2725 """int: """ 

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

2727  

2728 @num_gpus.setter 

2729 def num_gpus(self, val): 

2730 if self._readonly: 

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

2732 self._ptr[0].num_gpus = val 

2733  

2734 @staticmethod 

2735 def from_buffer(buffer): 

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

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

2738  

2739 @staticmethod 

2740 def from_data(data): 

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

2742  

2743 Args: 

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

2745 """ 

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

2747  

2748 @staticmethod 

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

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

2751  

2752 Args: 

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

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

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

2756 """ 

2757 if ptr == 0: 

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

2759 cdef StatsLevel3 obj = StatsLevel3.__new__(StatsLevel3) 

2760 if owner is None: 

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

2762 if obj._ptr == NULL: 

2763 raise MemoryError("Error allocating StatsLevel3") 

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

2765 obj._owner = None 

2766 obj._owned = True 

2767 else: 

2768 obj._ptr = <CUfileStatsLevel3_t *>ptr 

2769 obj._owner = owner 

2770 obj._owned = False 

2771 obj._readonly = readonly 

2772 return obj 

2773  

2774  

2775############################################################################### 

2776# Enum 

2777############################################################################### 

2778  

2779class OpError(_cyb_FastEnum): 

2780 """ 

2781 See `CUfileOpError`. 

2782 """ 

2783 SUCCESS = CU_FILE_SUCCESS 

2784 DRIVER_NOT_INITIALIZED = CU_FILE_DRIVER_NOT_INITIALIZED 

2785 DRIVER_INVALID_PROPS = CU_FILE_DRIVER_INVALID_PROPS 

2786 DRIVER_UNSUPPORTED_LIMIT = CU_FILE_DRIVER_UNSUPPORTED_LIMIT 

2787 DRIVER_VERSION_MISMATCH = CU_FILE_DRIVER_VERSION_MISMATCH 

2788 DRIVER_VERSION_READ_ERROR = CU_FILE_DRIVER_VERSION_READ_ERROR 

2789 DRIVER_CLOSING = CU_FILE_DRIVER_CLOSING 

2790 PLATFORM_NOT_SUPPORTED = CU_FILE_PLATFORM_NOT_SUPPORTED 

2791 IO_NOT_SUPPORTED = CU_FILE_IO_NOT_SUPPORTED 

2792 DEVICE_NOT_SUPPORTED = CU_FILE_DEVICE_NOT_SUPPORTED 

2793 NVFS_DRIVER_ERROR = CU_FILE_NVFS_DRIVER_ERROR 

2794 CUDA_DRIVER_ERROR = CU_FILE_CUDA_DRIVER_ERROR 

2795 CUDA_POINTER_INVALID = CU_FILE_CUDA_POINTER_INVALID 

2796 CUDA_MEMORY_TYPE_INVALID = CU_FILE_CUDA_MEMORY_TYPE_INVALID 

2797 CUDA_POINTER_RANGE_ERROR = CU_FILE_CUDA_POINTER_RANGE_ERROR 

2798 CUDA_CONTEXT_MISMATCH = CU_FILE_CUDA_CONTEXT_MISMATCH 

2799 INVALID_MAPPING_SIZE = CU_FILE_INVALID_MAPPING_SIZE 

2800 INVALID_MAPPING_RANGE = CU_FILE_INVALID_MAPPING_RANGE 

2801 INVALID_FILE_TYPE = CU_FILE_INVALID_FILE_TYPE 

2802 INVALID_FILE_OPEN_FLAG = CU_FILE_INVALID_FILE_OPEN_FLAG 

2803 DIO_NOT_SET = CU_FILE_DIO_NOT_SET 

2804 INVALID_VALUE = CU_FILE_INVALID_VALUE 

2805 MEMORY_ALREADY_REGISTERED = CU_FILE_MEMORY_ALREADY_REGISTERED 

2806 MEMORY_NOT_REGISTERED = CU_FILE_MEMORY_NOT_REGISTERED 

2807 PERMISSION_DENIED = CU_FILE_PERMISSION_DENIED 

2808 DRIVER_ALREADY_OPEN = CU_FILE_DRIVER_ALREADY_OPEN 

2809 HANDLE_NOT_REGISTERED = CU_FILE_HANDLE_NOT_REGISTERED 

2810 HANDLE_ALREADY_REGISTERED = CU_FILE_HANDLE_ALREADY_REGISTERED 

2811 DEVICE_NOT_FOUND = CU_FILE_DEVICE_NOT_FOUND 

2812 INTERNAL_ERROR = CU_FILE_INTERNAL_ERROR 

2813 GETNEWFD_FAILED = CU_FILE_GETNEWFD_FAILED 

2814 NVFS_SETUP_ERROR = CU_FILE_NVFS_SETUP_ERROR 

2815 IO_DISABLED = CU_FILE_IO_DISABLED 

2816 BATCH_SUBMIT_FAILED = CU_FILE_BATCH_SUBMIT_FAILED 

2817 GPU_MEMORY_PINNING_FAILED = CU_FILE_GPU_MEMORY_PINNING_FAILED 

2818 BATCH_FULL = CU_FILE_BATCH_FULL 

2819 ASYNC_NOT_SUPPORTED = CU_FILE_ASYNC_NOT_SUPPORTED 

2820 INTERNAL_BATCH_SETUP_ERROR = CU_FILE_INTERNAL_BATCH_SETUP_ERROR 

2821 INTERNAL_BATCH_SUBMIT_ERROR = CU_FILE_INTERNAL_BATCH_SUBMIT_ERROR 

2822 INTERNAL_BATCH_GETSTATUS_ERROR = CU_FILE_INTERNAL_BATCH_GETSTATUS_ERROR 

2823 INTERNAL_BATCH_CANCEL_ERROR = CU_FILE_INTERNAL_BATCH_CANCEL_ERROR 

2824 NOMEM_ERROR = CU_FILE_NOMEM_ERROR 

2825 IO_ERROR = CU_FILE_IO_ERROR 

2826 INTERNAL_BUF_REGISTER_ERROR = CU_FILE_INTERNAL_BUF_REGISTER_ERROR 

2827 HASH_OPR_ERROR = CU_FILE_HASH_OPR_ERROR 

2828 INVALID_CONTEXT_ERROR = CU_FILE_INVALID_CONTEXT_ERROR 

2829 NVFS_INTERNAL_DRIVER_ERROR = CU_FILE_NVFS_INTERNAL_DRIVER_ERROR 

2830 BATCH_NOCOMPAT_ERROR = CU_FILE_BATCH_NOCOMPAT_ERROR 

2831 IO_MAX_ERROR = CU_FILE_IO_MAX_ERROR 

2832  

2833class DriverStatusFlags(_cyb_FastEnum): 

2834 """ 

2835 See `CUfileDriverStatusFlags_t`. 

2836 """ 

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

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

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

2840 GPFS_SUPPORTED = CU_FILE_GPFS_SUPPORTED 

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

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

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

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

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

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

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

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

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

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

2851  

2852class DriverControlFlags(_cyb_FastEnum): 

2853 """ 

2854 See `CUfileDriverControlFlags_t`. 

2855 """ 

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

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

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

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

2860  

2861class FeatureFlags(_cyb_FastEnum): 

2862 """ 

2863 See `CUfileFeatureFlags_t`. 

2864 """ 

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

2866 BATCH_IO_SUPPORTED = (CU_FILE_BATCH_IO_SUPPORTED, 'Supported') 

2867 STREAMS_SUPPORTED = (CU_FILE_STREAMS_SUPPORTED, 'Supported') 

2868 PARALLEL_IO_SUPPORTED = (CU_FILE_PARALLEL_IO_SUPPORTED, 'Supported') 

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

2870  

2871class FileHandleType(_cyb_FastEnum): 

2872 """ 

2873 See `CUfileFileHandleType`. 

2874 """ 

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

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

2877 USERSPACE_FS = CU_FILE_HANDLE_TYPE_USERSPACE_FS 

2878  

2879class Opcode(_cyb_FastEnum): 

2880 """ 

2881 See `CUfileOpcode_t`. 

2882 """ 

2883 READ = CUFILE_READ 

2884 WRITE = CUFILE_WRITE 

2885  

2886class Status(_cyb_FastEnum): 

2887 """ 

2888 See `CUfileStatus_t`. 

2889 """ 

2890 WAITING = CUFILE_WAITING 

2891 PENDING = CUFILE_PENDING 

2892 INVALID = CUFILE_INVALID 

2893 CANCELED = CUFILE_CANCELED 

2894 COMPLETE = CUFILE_COMPLETE 

2895 TIMEOUT = CUFILE_TIMEOUT 

2896 FAILED = CUFILE_FAILED 

2897  

2898class BatchMode(_cyb_FastEnum): 

2899 """ 

2900 See `CUfileBatchMode_t`. 

2901 """ 

2902 BATCH = CUFILE_BATCH 

2903  

2904class SizeTConfigParameter(_cyb_FastEnum): 

2905 """ 

2906 See `CUFileSizeTConfigParameter_t`. 

2907 """ 

2908 PROFILE_STATS = CUFILE_PARAM_PROFILE_STATS 

2909 EXECUTION_MAX_IO_QUEUE_DEPTH = CUFILE_PARAM_EXECUTION_MAX_IO_QUEUE_DEPTH 

2910 EXECUTION_MAX_IO_THREADS = CUFILE_PARAM_EXECUTION_MAX_IO_THREADS 

2911 EXECUTION_MIN_IO_THRESHOLD_SIZE_KB = CUFILE_PARAM_EXECUTION_MIN_IO_THRESHOLD_SIZE_KB 

2912 EXECUTION_MAX_REQUEST_PARALLELISM = CUFILE_PARAM_EXECUTION_MAX_REQUEST_PARALLELISM 

2913 PROPERTIES_MAX_DIRECT_IO_SIZE_KB = CUFILE_PARAM_PROPERTIES_MAX_DIRECT_IO_SIZE_KB 

2914 PROPERTIES_MAX_DEVICE_CACHE_SIZE_KB = CUFILE_PARAM_PROPERTIES_MAX_DEVICE_CACHE_SIZE_KB 

2915 PROPERTIES_PER_BUFFER_CACHE_SIZE_KB = CUFILE_PARAM_PROPERTIES_PER_BUFFER_CACHE_SIZE_KB 

2916 PROPERTIES_MAX_DEVICE_PINNED_MEM_SIZE_KB = CUFILE_PARAM_PROPERTIES_MAX_DEVICE_PINNED_MEM_SIZE_KB 

2917 PROPERTIES_IO_BATCHSIZE = CUFILE_PARAM_PROPERTIES_IO_BATCHSIZE 

2918 POLLTHRESHOLD_SIZE_KB = CUFILE_PARAM_POLLTHRESHOLD_SIZE_KB 

2919 PROPERTIES_BATCH_IO_TIMEOUT_MS = CUFILE_PARAM_PROPERTIES_BATCH_IO_TIMEOUT_MS 

2920  

2921class BoolConfigParameter(_cyb_FastEnum): 

2922 """ 

2923 See `CUFileBoolConfigParameter_t`. 

2924 """ 

2925 PROPERTIES_USE_POLL_MODE = CUFILE_PARAM_PROPERTIES_USE_POLL_MODE 

2926 PROPERTIES_ALLOW_COMPAT_MODE = CUFILE_PARAM_PROPERTIES_ALLOW_COMPAT_MODE 

2927 FORCE_COMPAT_MODE = CUFILE_PARAM_FORCE_COMPAT_MODE 

2928 FS_MISC_API_CHECK_AGGRESSIVE = CUFILE_PARAM_FS_MISC_API_CHECK_AGGRESSIVE 

2929 EXECUTION_PARALLEL_IO = CUFILE_PARAM_EXECUTION_PARALLEL_IO 

2930 PROFILE_NVTX = CUFILE_PARAM_PROFILE_NVTX 

2931 PROPERTIES_ALLOW_SYSTEM_MEMORY = CUFILE_PARAM_PROPERTIES_ALLOW_SYSTEM_MEMORY 

2932 USE_PCIP2PDMA = CUFILE_PARAM_USE_PCIP2PDMA 

2933 PREFER_IO_URING = CUFILE_PARAM_PREFER_IO_URING 

2934 FORCE_ODIRECT_MODE = CUFILE_PARAM_FORCE_ODIRECT_MODE 

2935 SKIP_TOPOLOGY_DETECTION = CUFILE_PARAM_SKIP_TOPOLOGY_DETECTION 

2936 STREAM_MEMOPS_BYPASS = CUFILE_PARAM_STREAM_MEMOPS_BYPASS 

2937  

2938class StringConfigParameter(_cyb_FastEnum): 

2939 """ 

2940 See `CUFileStringConfigParameter_t`. 

2941 """ 

2942 LOGGING_LEVEL = CUFILE_PARAM_LOGGING_LEVEL 

2943 ENV_LOGFILE_PATH = CUFILE_PARAM_ENV_LOGFILE_PATH 

2944 LOG_DIR = CUFILE_PARAM_LOG_DIR 

2945  

2946class ArrayConfigParameter(_cyb_FastEnum): 

2947 """ 

2948 See `CUFileArrayConfigParameter_t`. 

2949 """ 

2950 POSIX_POOL_SLAB_SIZE_KB = CUFILE_PARAM_POSIX_POOL_SLAB_SIZE_KB 

2951 POSIX_POOL_SLAB_COUNT = CUFILE_PARAM_POSIX_POOL_SLAB_COUNT 

2952 GPU_BOUNCE_BUFFER_SLAB_SIZE_KB = CUFILE_PARAM_GPU_BOUNCE_BUFFER_SLAB_SIZE_KB 

2953 GPU_BOUNCE_BUFFER_SLAB_COUNT = CUFILE_PARAM_GPU_BOUNCE_BUFFER_SLAB_COUNT 

2954  

2955class P2PFlags(_cyb_FastEnum): 

2956 """ 

2957 See `CUfileP2PFlags_t`. 

2958 """ 

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

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

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

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

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

2964  

2965  

2966############################################################################### 

2967# Error handling 

2968############################################################################### 

2969  

2970ctypedef fused ReturnT: 

2971 CUfileError_t 

2972 ssize_t 

2973  

2974  

2975class cuFileError(Exception): 

2976  

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

2978 self.status = status 1qno

2979 self.cuda_error = cu_err 1qno

2980 s = OpError(status) 1qno

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

2982 if cu_err is not None: 1qno

2983 e = pyCUresult(cu_err) 

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

2985 super(cuFileError, self).__init__(err) 1qno

2986  

2987 def __reduce__(self): 

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

2989  

2990  

2991@cython.profile(False) 

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

2993 if ReturnT is CUfileError_t: 

2994 if IS_CUDA_ERR(status): 1adNOgPQfRSqTUGVWHXYIZ0J12K34h56i78j9!k#$l%'m()L*+M,-eBtcCubDvr./psnwx:oEyzFA

2995 with gil: 

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

2997 elif IS_CUFILE_ERR(status.err): 1adNOgPQfRSqTUGVWHXYIZ0J12K34h56i78j9!k#$l%'m()L*+M,-eBtcCubDvr./psnwx:oEyzFA

2998 with gil: 1qno

2999 raise cuFileError(status.err) 1qno

3000 elif ReturnT is ssize_t: 

3001 if status == -1: 1jklecb

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

3003 with gil: 

3004 raise cuFileError(errno.errno) 

3005 return 0 1adNOgPQfRSqTUGVWHXYIZ0J12K34h56i78j9!k#$l%'m()L*+M,-eBtcCubDvr./psnwx:oEyzFA

3006  

3007  

3008############################################################################### 

3009# Wrapper functions 

3010############################################################################### 

3011  

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

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

3014  

3015 Args: 

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

3017 agnostic). 

3018  

3019 Returns: 

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

3021 operations. 

3022  

3023 .. seealso:: `cuFileHandleRegister` 

3024 """ 

3025 cdef Handle fh 

3026 with nogil: 1dgfhijklmecbr

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

3028 check_status(__status__) 1dgfhijklmecbr

3029 return <intptr_t>fh 1dgfhijklmecbr

3030  

3031  

3032cpdef void handle_deregister(intptr_t fh) except*: 

3033 """releases a registered filehandle from cuFile. 

3034  

3035 Args: 

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

3037  

3038 .. seealso:: `cuFileHandleDeregister` 

3039 """ 

3040 with nogil: 1dgfhijklmecbr

3041 cuFileHandleDeregister(<Handle>fh) 1dgfhijklmecbr

3042  

3043  

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

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

3046  

3047 Args: 

3048 buf_ptr_base (intptr_t): buffer pointer allocated. 

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

3050 specified bufPtr. 

3051 flags (int): CU_FILE_RDMA_REGISTER. 

3052  

3053 .. seealso:: `cuFileBufRegister` 

3054 """ 

3055 with nogil: 1dgfqGHIJKhijklmecb

3056 __status__ = cuFileBufRegister(<const void*>buf_ptr_base, length, flags) 1dgfqGHIJKhijklmecb

3057 check_status(__status__) 1dgfqGHIJKhijklmecb

3058  

3059  

3060cpdef buf_deregister(intptr_t buf_ptr_base): 

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

3062  

3063 Args: 

3064 buf_ptr_base (intptr_t): buffer pointer to deregister. 

3065  

3066 .. seealso:: `cuFileBufDeregister` 

3067 """ 

3068 with nogil: 1dgfqGHIJKhijklmecb

3069 __status__ = cuFileBufDeregister(<const void*>buf_ptr_base) 1dgfqGHIJKhijklmecb

3070 check_status(__status__) 1dgfqGHIJKhijklmecb

3071  

3072  

3073cpdef driver_open(): 

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

3075  

3076 .. seealso:: `cuFileDriverOpen` 

3077 """ 

3078 with nogil: 1NPRTVXZ13579#%(*,BCD.psnwxEF

3079 __status__ = cuFileDriverOpen() 1NPRTVXZ13579#%(*,BCD.psnwxEF

3080 check_status(__status__) 1NPRTVXZ13579#%(*,BCD.psnwxEF

3081  

3082  

3083cpdef use_count(): 

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

3085  

3086 .. seealso:: `cuFileUseCount` 

3087 """ 

3088 with nogil: 

3089 __status__ = cuFileUseCount() 

3090 check_status(__status__) 

3091  

3092  

3093cpdef driver_get_properties(intptr_t props): 

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

3095  

3096 Args: 

3097 props (intptr_t): Properties to get. 

3098  

3099 .. seealso:: `cuFileDriverGetProperties` 

3100 """ 

3101 with nogil: 

3102 __status__ = cuFileDriverGetProperties(<CUfileDrvProps_t*>props) 

3103 check_status(__status__) 

3104  

3105  

3106cpdef driver_set_poll_mode(bint poll, size_t poll_threshold_size): 

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

3108  

3109 Args: 

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

3111 not. 

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

3113 mode in KB. 

3114  

3115 .. seealso:: `cuFileDriverSetPollMode` 

3116 """ 

3117 with nogil: 

3118 __status__ = cuFileDriverSetPollMode(<_cyb_bool>poll, poll_threshold_size) 

3119 check_status(__status__) 

3120  

3121  

3122cpdef driver_set_max_direct_io_size(size_t max_direct_io_size): 

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

3124  

3125 Args: 

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

3127 KB. 

3128  

3129 .. seealso:: `cuFileDriverSetMaxDirectIOSize` 

3130 """ 

3131 with nogil: 

3132 __status__ = cuFileDriverSetMaxDirectIOSize(max_direct_io_size) 

3133 check_status(__status__) 

3134  

3135  

3136cpdef driver_set_max_cache_size(size_t max_cache_size): 

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

3138  

3139 Args: 

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

3141 device used for internal use in KB. 

3142  

3143 .. seealso:: `cuFileDriverSetMaxCacheSize` 

3144 """ 

3145 with nogil: 

3146 __status__ = cuFileDriverSetMaxCacheSize(max_cache_size) 

3147 check_status(__status__) 

3148  

3149  

3150cpdef driver_set_max_pinned_mem_size(size_t max_pinned_size): 

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

3152  

3153 Args: 

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

3155 in KB. 

3156  

3157 .. seealso:: `cuFileDriverSetMaxPinnedMemSize` 

3158 """ 

3159 with nogil: 

3160 __status__ = cuFileDriverSetMaxPinnedMemSize(max_pinned_size) 

3161 check_status(__status__) 

3162  

3163  

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

3165 cdef BatchHandle batch_idp 

3166 with nogil: 1dgf

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

3168 check_status(__status__) 1dgf

3169 return <intptr_t>batch_idp 1dgf

3170  

3171  

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

3173 with nogil: 1dgf

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

3175 check_status(__status__) 1dgf

3176  

3177  

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

3179 with nogil: 1df

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

3181 check_status(__status__) 1df

3182  

3183  

3184cpdef batch_io_cancel(intptr_t batch_idp): 

3185 with nogil: 1g

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

3187 check_status(__status__) 1g

3188  

3189  

3190cpdef void batch_io_destroy(intptr_t batch_idp) except*: 

3191 with nogil: 1dgf

3192 cuFileBatchIODestroy(<BatchHandle>batch_idp) 1dgf

3193  

3194  

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

3196 with nogil: 1hi

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

3198 check_status(__status__) 1hi

3199  

3200  

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

3202 with nogil: 1hm

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

3204 check_status(__status__) 1hm

3205  

3206  

3207cpdef stream_register(intptr_t stream, unsigned flags): 

3208 with nogil: 1him

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

3210 check_status(__status__) 1him

3211  

3212  

3213cpdef stream_deregister(intptr_t stream): 

3214 with nogil: 1him

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

3216 check_status(__status__) 1him

3217  

3218  

3219cpdef int get_version() except? 0: 

3220 """Get the cuFile library version. 

3221  

3222 Returns: 

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

3224  

3225 .. seealso:: `cuFileGetVersion` 

3226 """ 

3227 cdef int version 

3228 with nogil: 1ap

3229 __status__ = cuFileGetVersion(&version) 1ap

3230 check_status(__status__) 1ap

3231 return version 1ap

3232  

3233  

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

3235 cdef size_t value 

3236 with nogil: 1s

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

3238 check_status(__status__) 1s

3239 return value 1s

3240  

3241  

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

3243 cdef _cyb_bool value 

3244 with nogil: 1p

3245 __status__ = cuFileGetParameterBool(<_BoolConfigParameter>param, &value) 1p

3246 check_status(__status__) 1p

3247 return <bint>value 1p

3248  

3249  

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

3251 cdef bytes _desc_str_ = bytes(len) 1n

3252 cdef char* desc_str = _desc_str_ 1n

3253 with nogil: 1n

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

3255 check_status(__status__) 1n

3256 return _cyb_cpython.PyUnicode_FromString(desc_str) 1n

3257  

3258  

3259cpdef set_parameter_size_t(int param, size_t value): 

3260 with nogil: 1s

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

3262 check_status(__status__) 1s

3263  

3264  

3265cpdef set_parameter_bool(int param, bint value): 

3266 with nogil: 1p

3267 __status__ = cuFileSetParameterBool(<_BoolConfigParameter>param, <_cyb_bool>value) 1p

3268 check_status(__status__) 1p

3269  

3270  

3271cpdef set_parameter_string(int param, intptr_t desc_str): 

3272 with nogil: 1n

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

3274 check_status(__status__) 1n

3275  

3276  

3277cpdef tuple get_parameter_min_max_value(int param): 

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

3279  

3280 Args: 

3281 param (SizeTConfigParameter): CUfile SizeT configuration 

3282 parameter. 

3283  

3284 Returns: 

3285 A 2-tuple containing: 

3286  

3287 - size_t: Pointer to store the minimum value. 

3288 - size_t: Pointer to store the maximum value. 

3289  

3290 .. seealso:: `cuFileGetParameterMinMaxValue` 

3291 """ 

3292 cdef size_t min_value 

3293 cdef size_t max_value 

3294 with nogil: 1M

3295 __status__ = cuFileGetParameterMinMaxValue(<_SizeTConfigParameter>param, &min_value, &max_value) 1M

3296 check_status(__status__) 1M

3297 return (min_value, max_value) 1M

3298  

3299  

3300cpdef set_stats_level(int level): 

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

3302  

3303 Args: 

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

3305 detailed, 3 = verbose). 

3306  

3307 .. seealso:: `cuFileSetStatsLevel` 

3308 """ 

3309 with nogil: 1etcubvoyzA

3310 __status__ = cuFileSetStatsLevel(level) 1etcubvoyzA

3311 check_status(__status__) 1etcubvoyzA

3312  

3313  

3314cpdef int get_stats_level() except? 0: 

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

3316  

3317 Returns: 

3318 int: Pointer to store the current statistics level. 

3319  

3320 .. seealso:: `cuFileGetStatsLevel` 

3321 """ 

3322 cdef int level 

3323 with nogil: 1BCDoEF

3324 __status__ = cuFileGetStatsLevel(&level) 1BCDoEF

3325 check_status(__status__) 1BCDoEF

3326 return level 1BCDoEF

3327  

3328  

3329cpdef stats_start(): 

3330 """Start collecting cuFile statistics. 

3331  

3332 .. seealso:: `cuFileStatsStart` 

3333 """ 

3334 with nogil: 1ecbz

3335 __status__ = cuFileStatsStart() 1ecbz

3336 check_status(__status__) 1ecbz

3337  

3338  

3339cpdef stats_stop(): 

3340 """Stop collecting cuFile statistics. 

3341  

3342 .. seealso:: `cuFileStatsStop` 

3343 """ 

3344 with nogil: 1ecbz

3345 __status__ = cuFileStatsStop() 1ecbz

3346 check_status(__status__) 1ecbz

3347  

3348  

3349cpdef stats_reset(): 

3350 """Reset all cuFile statistics counters. 

3351  

3352 .. seealso:: `cuFileStatsReset` 

3353 """ 

3354 with nogil: 1tuvyA

3355 __status__ = cuFileStatsReset() 1tuvyA

3356 check_status(__status__) 1tuvyA

3357  

3358  

3359cpdef get_stats_l1(intptr_t stats): 

3360 """Get Level 1 cuFile statistics. 

3361  

3362 Args: 

3363 stats (intptr_t): Pointer to ``CUfileStatsLevel1_t`` structure 

3364 to be filled. 

3365  

3366 .. seealso:: `cuFileGetStatsL1` 

3367 """ 

3368 with nogil: 1e

3369 __status__ = cuFileGetStatsL1(<CUfileStatsLevel1_t*>stats) 1e

3370 check_status(__status__) 1e

3371  

3372  

3373cpdef get_stats_l2(intptr_t stats): 

3374 """Get Level 2 cuFile statistics. 

3375  

3376 Args: 

3377 stats (intptr_t): Pointer to ``CUfileStatsLevel2_t`` structure 

3378 to be filled. 

3379  

3380 .. seealso:: `cuFileGetStatsL2` 

3381 """ 

3382 with nogil: 1c

3383 __status__ = cuFileGetStatsL2(<CUfileStatsLevel2_t*>stats) 1c

3384 check_status(__status__) 1c

3385  

3386  

3387cpdef get_stats_l3(intptr_t stats): 

3388 """Get Level 3 cuFile statistics. 

3389  

3390 Args: 

3391 stats (intptr_t): Pointer to ``CUfileStatsLevel3_t`` structure 

3392 to be filled. 

3393  

3394 .. seealso:: `cuFileGetStatsL3` 

3395 """ 

3396 with nogil: 1b

3397 __status__ = cuFileGetStatsL3(<CUfileStatsLevel3_t*>stats) 1b

3398 check_status(__status__) 1b

3399  

3400  

3401cpdef size_t get_bar_size_in_kb(int gpu_index) except? 0: 

3402 cdef size_t bar_size 

3403 with nogil: 1L

3404 __status__ = cuFileGetBARSizeInKB(gpu_index, &bar_size) 1L

3405 check_status(__status__) 1L

3406 return bar_size 1L

3407  

3408  

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

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

3411  

3412 Args: 

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

3414 count_values (intptr_t): Array of slab counts. 

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

3416  

3417 .. seealso:: `cuFileSetParameterPosixPoolSlabArray` 

3418 """ 

3419 with nogil: 1x

3420 __status__ = cuFileSetParameterPosixPoolSlabArray(<const size_t*>size_values, <const size_t*>count_values, len) 1x

3421 check_status(__status__) 1x

3422  

3423  

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

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

3426  

3427 Args: 

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

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

3430 len (int): Buffer size (must match the actual parameter 

3431 length). 

3432  

3433 .. seealso:: `cuFileGetParameterPosixPoolSlabArray` 

3434 """ 

3435 with nogil: 1w

3436 __status__ = cuFileGetParameterPosixPoolSlabArray(<size_t*>size_values, <size_t*>count_values, len) 1w

3437 check_status(__status__) 1w

3438  

3439  

3440cpdef str op_status_error(int status): 

3441 """cufileop status string. 

3442  

3443 Args: 

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

3445  

3446 .. seealso:: `cufileop_status_error` 

3447 """ 

3448 cdef bytes _output_ 

3449 _output_ = cufileop_status_error(<_OpError>status) 1qno

3450 return _output_.decode() 1qno

3451  

3452  

3453cpdef driver_close(): 

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

3455 """ 

3456 with nogil: 1OQSUWY02468!$')+-tuv/psnwx:yA

3457 status = cuFileDriverClose_v2() 1OQSUWY02468!$')+-tuv/psnwx:yA

3458 check_status(status) 1OQSUWY02468!$')+-tuv/psnwx:yA

3459  

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

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

3462  

3463 Args: 

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

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

3466 size (size_t): size bytes to read. 

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

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

3469  

3470 Returns: 

3471 ssize_t: number of bytes read on success. 

3472  

3473 .. seealso:: `cuFileRead` 

3474 """ 

3475 with nogil: 1jklecb

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

3477 check_status(status) 1jklecb

3478 return status 1jklecb

3479  

3480  

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

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

3483  

3484 Args: 

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

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

3487 size (size_t): size bytes to write. 

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

3489 buf_ptr_offset (off_t): offset relative to the buf_ptr_base pointer to write from. 

3490  

3491 Returns: 

3492 ssize_t: number of bytes written on success. 

3493  

3494 .. seealso:: `cuFileWrite` 

3495 """ 

3496 with nogil: 1jklecb

3497 status = cuFileWrite(<Handle>fh, <const void*>buf_ptr_base, size, file_offset, buf_ptr_offset) 1jklecb

3498 check_status(status) 1jklecb

3499 return status 1jklecb

3500  

3501  

3502del _cyb_FastEnum