Coverage for cuda/bindings/cufile.pyx: 38.92%
1994 statements
« prev ^ index » next coverage.py v7.18.0, created at 2026-12-03 01:06 +0000
« prev ^ index » next coverage.py v7.18.0, created at 2026-12-03 01:06 +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.5.0. Do not modify it directly.
6# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=d33ef737bf2d5ef2c79553ea842dbbaa16d6dc024d99ed76962c5596907b983e
9# <<<< PREAMBLE CONTENT >>>>
11cimport cpython as _cyb_cpython
12cimport cpython.buffer as _cyb_cpython_buffer
13from cpython.buffer cimport (
14 PyBUF_SIMPLE as _cyb_PyBUF_SIMPLE,
15 PyBuffer_Release as _cyb_PyBuffer_Release,
16 PyObject_GetBuffer as _cyb_PyObject_GetBuffer,
17 Py_buffer as _cyb_Py_buffer,
18)
19cimport cpython.memoryview as _cyb_cpython_memoryview
20from cython cimport view as _cyb_view
21from libc.stdint cimport (
22 intptr_t,
23 uint64_t,
24)
25from libc.stdlib cimport (
26 calloc as _cyb_calloc,
27 free as _cyb_free,
28 malloc as _cyb_malloc,
29)
30from libc.string cimport (
31 memcmp as _cyb_memcmp,
32 memcpy as _cyb_memcpy,
33 memmove as _cyb_memmove,
34)
35from libcpp cimport bool as _cyb_bool
37from cuda.bindings._internal._fast_enum import FastEnum as _cyb_FastEnum
39import numpy as _numpy
41cdef _cyb___getbuffer(object self, _cyb_cpython.Py_buffer *buffer, void *ptr, int size, bint readonly):
42 buffer.buf = <char *>ptr
43 buffer.format = 'b'
44 buffer.internal = NULL
45 buffer.itemsize = 1
46 buffer.len = size
47 buffer.ndim = 1
48 buffer.obj = self
49 buffer.readonly = readonly
50 buffer.shape = &buffer.len
51 buffer.strides = &buffer.itemsize
52 buffer.suboffsets = NULL
54cdef inline intptr_t _cyb_array_ptr(object arr) except? 0:
55 cdef _cyb_cpython.Py_buffer view
56 cdef intptr_t ptr
57 _cyb_cpython.PyObject_GetBuffer(arr, &view, _cyb_cpython_buffer.PyBUF_STRIDES) 1hljnpqrstfbdBimkouvwxygceC
58 ptr = <intptr_t>view.buf 1hljnpqrstfbdBimkouvwxygceC
59 _cyb_cpython.PyBuffer_Release(&view) 1hljnpqrstfbdBimkouvwxygceC
60 return ptr 1hljnpqrstfbdBimkouvwxygceC
62cdef _cyb_from_buffer(buffer, size, lowpp_type):
63 cdef _cyb_cpython.Py_buffer view
64 if _cyb_cpython.PyObject_GetBuffer(buffer, &view, _cyb_cpython_buffer.PyBUF_SIMPLE) != 0:
65 raise TypeError("buffer argument does not support the buffer protocol")
66 try:
67 if view.itemsize != 1:
68 raise ValueError("buffer itemsize must be 1 byte")
69 if view.len != size:
70 raise ValueError(f"buffer length must be {size} bytes")
71 return lowpp_type.from_ptr(<intptr_t><void *>view.buf, view.readonly != 0, buffer)
72 finally:
73 _cyb_cpython.PyBuffer_Release(&view)
75cdef _cyb_from_data(data, dtype_name, expected_dtype, lowpp_type):
76 # _numpy.recarray is a subclass of _numpy.ndarray, so implicitly handled here.
77 if isinstance(data, lowpp_type): 1fbdgce
78 return data 1fbdgce
79 if not isinstance(data, _numpy.ndarray):
80 raise TypeError("data argument must be a NumPy ndarray")
81 if data.size != 1:
82 raise ValueError("data array must have a size of 1")
83 if data.dtype != expected_dtype:
84 raise ValueError(f"data array must be of dtype {dtype_name}")
85 return lowpp_type.from_ptr(data.ctypes.data, not data.flags.writeable, data)
88# <<<< END OF PREAMBLE CONTENT >>>>
90cimport cython # NOQA
91from libc cimport errno
92from ._internal.utils cimport (get_nested_resource_ptr,
93 nested_resource)
95import cython
97from cuda.bindings.driver import CUresult as pyCUresult
99###############################################################################
100# POD
101###############################################################################
103cdef _get__py_anon_pod1_dtype_offsets():
104 cdef cuda_bindings_cufile__anon_pod1 *pod = <cuda_bindings_cufile__anon_pod1 *>_cyb_calloc(1, sizeof(cuda_bindings_cufile__anon_pod1))
105 if pod == NULL:
106 raise MemoryError("Error allocating cuda_bindings_cufile__anon_pod1")
107 try:
108 return _numpy.dtype({
109 'names': ['fd', 'handle'],
110 'formats': [_numpy.int32, _numpy.intp],
111 'offsets': [
112 (<intptr_t>&(pod.fd)) - (<intptr_t>pod),
113 (<intptr_t>&(pod.handle)) - (<intptr_t>pod),
114 ],
115 'itemsize': sizeof(cuda_bindings_cufile__anon_pod1),
116 })
117 finally:
118 _cyb_free(pod)
120_py_anon_pod1_dtype = _get__py_anon_pod1_dtype_offsets()
122cdef class _py_anon_pod1:
123 """Empty-initialize an instance of `cuda_bindings_cufile__anon_pod1`.
126 .. seealso:: `cuda_bindings_cufile__anon_pod1`
127 """
128 cdef:
129 cuda_bindings_cufile__anon_pod1 *_ptr
130 object _owner
131 bint _owns_ptr
132 bint _readonly
134 def __init__(self):
135 self._ptr = <cuda_bindings_cufile__anon_pod1 *>_cyb_calloc(1, sizeof(cuda_bindings_cufile__anon_pod1))
136 if self._ptr == NULL:
137 raise MemoryError("Error allocating _py_anon_pod1")
138 self._owns_ptr = True
139 self._owner = None
140 self._readonly = False
142 def __dealloc__(self):
143 cdef cuda_bindings_cufile__anon_pod1 *ptr
144 if self._owns_ptr and self._ptr != NULL:
145 ptr = self._ptr
146 self._ptr = NULL
147 _cyb_free(ptr)
149 def __repr__(self):
150 return f"<{__name__}._py_anon_pod1 object at {hex(id(self))}>"
152 @property
153 def ptr(self):
154 """Get the pointer address to the data as Python :class:`int`."""
155 return <intptr_t>(self._ptr)
157 cdef intptr_t _get_ptr(self):
158 return <intptr_t>(self._ptr)
160 def __int__(self):
161 return <intptr_t>(self._ptr)
163 def __eq__(self, other):
164 cdef _py_anon_pod1 other_
165 if not isinstance(other, _py_anon_pod1):
166 return False
167 other_ = other
168 return (_cyb_memcmp(<void *><intptr_t>(self._ptr), <void *><intptr_t>(other_._ptr), sizeof(cuda_bindings_cufile__anon_pod1)) == 0)
170 def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags):
171 _cyb___getbuffer(self, buffer, <void *>self._ptr, sizeof(cuda_bindings_cufile__anon_pod1), self._readonly)
173 def __releasebuffer__(self, Py_buffer *buffer):
174 pass
176 def __setitem__(self, key, val):
177 cdef _cyb_Py_buffer view
178 if key == 0:
179 if self._readonly:
180 raise ValueError("This _py_anon_pod1 instance is read-only")
181 _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE)
182 try:
183 if <size_t>view.len < sizeof(cuda_bindings_cufile__anon_pod1):
184 raise ValueError(
185 "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_cufile__anon_pod1), view.len)
186 )
187 _cyb_memmove(<void*>self._ptr, view.buf, sizeof(cuda_bindings_cufile__anon_pod1))
188 self._readonly = view.readonly != 0
189 finally:
190 _cyb_PyBuffer_Release(&view)
191 else:
192 setattr(self, key, val)
194 @property
195 def fd(self):
196 """int: """
197 return self._ptr[0].fd
199 @fd.setter
200 def fd(self, val):
201 if self._readonly:
202 raise ValueError("This _py_anon_pod1 instance is read-only")
203 self._ptr[0].fd = val
205 @property
206 def handle(self):
207 """int: """
208 return <intptr_t>(self._ptr[0].handle)
210 @handle.setter
211 def handle(self, val):
212 if self._readonly:
213 raise ValueError("This _py_anon_pod1 instance is read-only")
214 self._ptr[0].handle = <void *><intptr_t>val
216 @staticmethod
217 def from_buffer(buffer):
218 """Create an _py_anon_pod1 instance with the memory from the given buffer."""
219 return _cyb_from_buffer(buffer, sizeof(cuda_bindings_cufile__anon_pod1), _py_anon_pod1)
221 @staticmethod
222 def from_data(data):
223 """Create an _py_anon_pod1 instance wrapping the given NumPy array.
225 Args:
226 data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod1_dtype` holding the data.
227 """
228 return _cyb_from_data(data, "_py_anon_pod1_dtype", _py_anon_pod1_dtype, _py_anon_pod1)
230 @staticmethod
231 def from_ptr(intptr_t ptr, bint readonly=False, object owner=None):
232 """Create an _py_anon_pod1 instance wrapping the given pointer.
234 Args:
235 ptr (intptr_t): pointer address as Python :class:`int` to the data.
236 owner (object): The Python object that owns the pointer. If not provided, data will be copied.
237 readonly (bool): whether the data is read-only (to the user). default is `False`.
238 """
239 if ptr == 0:
240 raise ValueError("ptr must not be null (0)")
241 cdef _py_anon_pod1 obj = _py_anon_pod1.__new__(_py_anon_pod1)
242 if owner is None:
243 obj._ptr = <cuda_bindings_cufile__anon_pod1 *>_cyb_malloc(sizeof(cuda_bindings_cufile__anon_pod1))
244 if obj._ptr == NULL:
245 raise MemoryError("Error allocating _py_anon_pod1")
246 _cyb_memcpy(<void*>(obj._ptr), <void*>ptr, sizeof(cuda_bindings_cufile__anon_pod1))
247 obj._owns_ptr = True
248 obj._owner = None
249 else:
250 obj._ptr = <cuda_bindings_cufile__anon_pod1 *>ptr
251 obj._owns_ptr = False
252 obj._owner = owner
253 obj._readonly = readonly
254 return obj
257cdef _get__py_anon_pod3_dtype_offsets():
258 cdef cuda_bindings_cufile__anon_pod3 *pod = <cuda_bindings_cufile__anon_pod3 *>_cyb_calloc(1, sizeof(cuda_bindings_cufile__anon_pod3))
259 if pod == NULL:
260 raise MemoryError("Error allocating cuda_bindings_cufile__anon_pod3")
261 try:
262 return _numpy.dtype({
263 'names': ['dev_ptr_base', 'file_offset', 'dev_ptr_offset', 'size_'],
264 'formats': [_numpy.intp, _numpy.int64, _numpy.int64, _numpy.uint64],
265 'offsets': [
266 (<intptr_t>&(pod.devPtr_base)) - (<intptr_t>pod),
267 (<intptr_t>&(pod.file_offset)) - (<intptr_t>pod),
268 (<intptr_t>&(pod.devPtr_offset)) - (<intptr_t>pod),
269 (<intptr_t>&(pod.size)) - (<intptr_t>pod),
270 ],
271 'itemsize': sizeof(cuda_bindings_cufile__anon_pod3),
272 })
273 finally:
274 _cyb_free(pod)
276_py_anon_pod3_dtype = _get__py_anon_pod3_dtype_offsets()
278cdef class _py_anon_pod3:
279 """Empty-initialize an instance of `cuda_bindings_cufile__anon_pod3`.
282 .. seealso:: `cuda_bindings_cufile__anon_pod3`
283 """
284 cdef:
285 cuda_bindings_cufile__anon_pod3 *_ptr
286 object _owner
287 bint _owns_ptr
288 bint _readonly
290 def __init__(self):
291 self._ptr = <cuda_bindings_cufile__anon_pod3 *>_cyb_calloc(1, sizeof(cuda_bindings_cufile__anon_pod3))
292 if self._ptr == NULL:
293 raise MemoryError("Error allocating _py_anon_pod3")
294 self._owns_ptr = True
295 self._owner = None
296 self._readonly = False
298 def __dealloc__(self):
299 cdef cuda_bindings_cufile__anon_pod3 *ptr
300 if self._owns_ptr and self._ptr != NULL:
301 ptr = self._ptr
302 self._ptr = NULL
303 _cyb_free(ptr)
305 def __repr__(self):
306 return f"<{__name__}._py_anon_pod3 object at {hex(id(self))}>"
308 @property
309 def ptr(self):
310 """Get the pointer address to the data as Python :class:`int`."""
311 return <intptr_t>(self._ptr)
313 cdef intptr_t _get_ptr(self):
314 return <intptr_t>(self._ptr)
316 def __int__(self):
317 return <intptr_t>(self._ptr)
319 def __eq__(self, other):
320 cdef _py_anon_pod3 other_
321 if not isinstance(other, _py_anon_pod3):
322 return False
323 other_ = other
324 return (_cyb_memcmp(<void *><intptr_t>(self._ptr), <void *><intptr_t>(other_._ptr), sizeof(cuda_bindings_cufile__anon_pod3)) == 0)
326 def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags):
327 _cyb___getbuffer(self, buffer, <void *>self._ptr, sizeof(cuda_bindings_cufile__anon_pod3), self._readonly)
329 def __releasebuffer__(self, Py_buffer *buffer):
330 pass
332 def __setitem__(self, key, val):
333 cdef _cyb_Py_buffer view
334 if key == 0:
335 if self._readonly:
336 raise ValueError("This _py_anon_pod3 instance is read-only")
337 _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE)
338 try:
339 if <size_t>view.len < sizeof(cuda_bindings_cufile__anon_pod3):
340 raise ValueError(
341 "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_cufile__anon_pod3), view.len)
342 )
343 _cyb_memmove(<void*>self._ptr, view.buf, sizeof(cuda_bindings_cufile__anon_pod3))
344 self._readonly = view.readonly != 0
345 finally:
346 _cyb_PyBuffer_Release(&view)
347 else:
348 setattr(self, key, val)
350 @property
351 def dev_ptr_base(self):
352 """int: """
353 return <intptr_t>(self._ptr[0].devPtr_base)
355 @dev_ptr_base.setter
356 def dev_ptr_base(self, val):
357 if self._readonly:
358 raise ValueError("This _py_anon_pod3 instance is read-only")
359 self._ptr[0].devPtr_base = <void *><intptr_t>val
361 @property
362 def file_offset(self):
363 """int: """
364 return self._ptr[0].file_offset
366 @file_offset.setter
367 def file_offset(self, val):
368 if self._readonly:
369 raise ValueError("This _py_anon_pod3 instance is read-only")
370 self._ptr[0].file_offset = val
372 @property
373 def dev_ptr_offset(self):
374 """int: """
375 return self._ptr[0].devPtr_offset
377 @dev_ptr_offset.setter
378 def dev_ptr_offset(self, val):
379 if self._readonly:
380 raise ValueError("This _py_anon_pod3 instance is read-only")
381 self._ptr[0].devPtr_offset = val
383 @property
384 def size_(self):
385 """int: """
386 return self._ptr[0].size
388 @size_.setter
389 def size_(self, val):
390 if self._readonly:
391 raise ValueError("This _py_anon_pod3 instance is read-only")
392 self._ptr[0].size = val
394 @staticmethod
395 def from_buffer(buffer):
396 """Create an _py_anon_pod3 instance with the memory from the given buffer."""
397 return _cyb_from_buffer(buffer, sizeof(cuda_bindings_cufile__anon_pod3), _py_anon_pod3)
399 @staticmethod
400 def from_data(data):
401 """Create an _py_anon_pod3 instance wrapping the given NumPy array.
403 Args:
404 data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod3_dtype` holding the data.
405 """
406 return _cyb_from_data(data, "_py_anon_pod3_dtype", _py_anon_pod3_dtype, _py_anon_pod3)
408 @staticmethod
409 def from_ptr(intptr_t ptr, bint readonly=False, object owner=None):
410 """Create an _py_anon_pod3 instance wrapping the given pointer.
412 Args:
413 ptr (intptr_t): pointer address as Python :class:`int` to the data.
414 owner (object): The Python object that owns the pointer. If not provided, data will be copied.
415 readonly (bool): whether the data is read-only (to the user). default is `False`.
416 """
417 if ptr == 0:
418 raise ValueError("ptr must not be null (0)")
419 cdef _py_anon_pod3 obj = _py_anon_pod3.__new__(_py_anon_pod3)
420 if owner is None:
421 obj._ptr = <cuda_bindings_cufile__anon_pod3 *>_cyb_malloc(sizeof(cuda_bindings_cufile__anon_pod3))
422 if obj._ptr == NULL:
423 raise MemoryError("Error allocating _py_anon_pod3")
424 _cyb_memcpy(<void*>(obj._ptr), <void*>ptr, sizeof(cuda_bindings_cufile__anon_pod3))
425 obj._owns_ptr = True
426 obj._owner = None
427 else:
428 obj._ptr = <cuda_bindings_cufile__anon_pod3 *>ptr
429 obj._owns_ptr = False
430 obj._owner = owner
431 obj._readonly = readonly
432 return obj
435cdef _get_io_events_dtype_offsets():
436 cdef CUfileIOEvents_t *pod = <CUfileIOEvents_t *>_cyb_calloc(1, sizeof(CUfileIOEvents_t))
437 if pod == NULL:
438 raise MemoryError("Error allocating CUfileIOEvents_t")
439 try:
440 return _numpy.dtype({
441 'names': ['cookie', 'status', 'ret'],
442 'formats': [_numpy.intp, _numpy.int32, _numpy.uint64],
443 'offsets': [
444 (<intptr_t>&(pod.cookie)) - (<intptr_t>pod),
445 (<intptr_t>&(pod.status)) - (<intptr_t>pod),
446 (<intptr_t>&(pod.ret)) - (<intptr_t>pod),
447 ],
448 'itemsize': sizeof(CUfileIOEvents_t),
449 })
450 finally:
451 _cyb_free(pod)
453io_events_dtype = _get_io_events_dtype_offsets()
454cdef object io_events_dtype_record = _numpy.dtype((_numpy.record, io_events_dtype))
456cdef class IOEvents:
457 """Empty-initialize an array of `CUfileIOEvents_t`.
458 The resulting object is of length `size` and of dtype `io_events_dtype`.
459 If default-constructed, the instance represents a single struct.
461 Args:
462 size (int): number of structs, default=1.
464 .. seealso:: `CUfileIOEvents_t`
465 """
466 cdef:
467 readonly object _data
468 object _owner
470 def __init__(self, size=1):
471 self._data = _numpy.zeros(size, dtype=io_events_dtype_record) 1hjik
472 assert self._data.itemsize == sizeof(CUfileIOEvents_t), \ 1hjik
473 f"itemsize {self._data.itemsize} mismatches struct size { sizeof(CUfileIOEvents_t) }"
475 def __repr__(self):
476 if self._data.size > 1:
477 return f"<{__name__}.IOEvents_Array_{self._data.size} object at {hex(id(self))}>"
478 else:
479 return f"<{__name__}.IOEvents object at {hex(id(self))}>"
481 @property
482 def ptr(self):
483 """Get the pointer address to the data as Python :class:`int`."""
484 return _cyb_array_ptr(self._data) 1hjik
486 cdef intptr_t _get_ptr(self):
487 return _cyb_array_ptr(self._data)
489 def __int__(self):
490 if self._data.size > 1 and not self._data.flags["C_CONTIGUOUS"]:
491 raise TypeError("int() argument must be a bytes-like object of size 1, or a "
492 "C-contiguous array. To get the pointer address of a "
493 "non-contiguous array, use .ptr")
494 return _cyb_array_ptr(self._data)
496 def __len__(self):
497 return self._data.size
499 def __eq__(self, other):
500 cdef object self_data = self._data
501 if (not isinstance(other, IOEvents)) or self_data.size != other._data.size or self_data.dtype != other._data.dtype:
502 return False
503 return bool((self_data == other._data).all())
505 def __getbuffer__(self, Py_buffer *buffer, int flags):
506 _cyb_cpython.PyObject_GetBuffer(self._data, buffer, flags)
508 def __releasebuffer__(self, Py_buffer *buffer):
509 _cyb_cpython.PyBuffer_Release(buffer)
511 @property
512 def cookie(self):
513 """Union[~_numpy.intp, int]: """
514 if self._data.size == 1: 1hjik
515 return int(self._data["cookie"][0]) 1hjik
516 return self._data["cookie"]
518 @cookie.setter
519 def cookie(self, val):
520 if not self._data.flags.writeable:
521 raise ValueError("This IOEvents instance is read-only")
522 self._data["cookie"] = val
524 @property
525 def status(self):
526 """Union[~_numpy.int32, int]: """
527 if self._data.size == 1: 1hjik
528 return int(self._data["status"][0]) 1hjik
529 return self._data["status"]
531 @status.setter
532 def status(self, val):
533 if not self._data.flags.writeable:
534 raise ValueError("This IOEvents instance is read-only")
535 self._data["status"] = val
537 @property
538 def ret(self):
539 """Union[~_numpy.uint64, int]: """
540 if self._data.size == 1: 1hi
541 return int(self._data["ret"][0]) 1hi
542 return self._data["ret"]
544 @ret.setter
545 def ret(self, val):
546 if not self._data.flags.writeable:
547 raise ValueError("This IOEvents instance is read-only")
548 self._data["ret"] = val
550 def __getitem__(self, key):
551 cdef ssize_t key_
552 cdef ssize_t size
553 cdef IOEvents obj
554 if isinstance(key, int): 1hjik
555 key_ = key 1hjik
556 size = self._data.size 1hjik
557 if key_ >= size or key_ <= -(size+1): 1hjik
558 raise IndexError("index is out of bounds")
559 if key_ < 0: 1hjik
560 key_ += size
561 obj = IOEvents.__new__(IOEvents) 1hjik
562 obj._data = self._data[key_:key_+1] 1hjik
563 obj._owner = self._owner 1hjik
564 return obj 1hjik
565 out = self._data[key]
566 if isinstance(out, _numpy.ndarray):
567 if out.dtype == io_events_dtype:
568 obj = IOEvents.from_data(out)
569 obj._owner = self._owner
570 return obj
571 if out.dtype.names is not None:
572 return out.view(_numpy.recarray)
573 return out
575 def __setitem__(self, key, val):
576 self._data[key] = val
578 @staticmethod
579 def from_buffer(buffer):
580 """Create an IOEvents instance with the memory from the given buffer."""
581 return IOEvents.from_data(_numpy.frombuffer(buffer, dtype=io_events_dtype))
583 @staticmethod
584 def from_data(data):
585 """Create an IOEvents instance wrapping the given NumPy array.
587 Args:
588 data (_numpy.ndarray): a 1D array of dtype `io_events_dtype` holding the data.
589 """
590 cdef IOEvents obj = IOEvents.__new__(IOEvents)
591 if not isinstance(data, _numpy.ndarray):
592 raise TypeError("data argument must be a NumPy ndarray")
593 if data.ndim != 1:
594 raise ValueError("data array must be 1D")
595 if data.dtype != io_events_dtype:
596 raise ValueError("data array must be of dtype io_events_dtype")
597 obj._data = data.view(dtype=io_events_dtype_record, type=_numpy.ndarray)
598 return obj
600 @staticmethod
601 def from_ptr(intptr_t ptr, size_t size=1, bint readonly=False, object owner=None):
602 """Create an IOEvents instance wrapping the given pointer.
604 Args:
605 ptr (intptr_t): pointer address as Python :class:`int` to the data.
606 size (int): number of structs, default=1.
607 readonly (bool): whether the data is read-only (to the user). default is `False`.
608 owner (object): object that owns the memory at *ptr*. A strong reference is
609 kept so the backing storage outlives this wrapper.
610 """
611 if ptr == 0:
612 raise ValueError("ptr must not be null (0)")
613 cdef IOEvents obj = IOEvents.__new__(IOEvents)
614 cdef flag = _cyb_cpython_buffer.PyBUF_READ if readonly else _cyb_cpython_buffer.PyBUF_WRITE
615 cdef object buf = _cyb_cpython_memoryview.PyMemoryView_FromMemory(
616 <char*>ptr, sizeof(CUfileIOEvents_t) * size, flag)
617 obj._data = _numpy.ndarray(size, buffer=buf, dtype=io_events_dtype_record)
618 obj._owner = owner
619 return obj
622cdef _get_op_counter_dtype_offsets():
623 cdef CUfileOpCounter_t *pod = <CUfileOpCounter_t *>_cyb_calloc(1, sizeof(CUfileOpCounter_t))
624 if pod == NULL:
625 raise MemoryError("Error allocating CUfileOpCounter_t")
626 try:
627 return _numpy.dtype({
628 'names': ['ok', 'err'],
629 'formats': [_numpy.uint64, _numpy.uint64],
630 'offsets': [
631 (<intptr_t>&(pod.ok)) - (<intptr_t>pod),
632 (<intptr_t>&(pod.err)) - (<intptr_t>pod),
633 ],
634 'itemsize': sizeof(CUfileOpCounter_t),
635 })
636 finally:
637 _cyb_free(pod)
639op_counter_dtype = _get_op_counter_dtype_offsets()
641cdef class OpCounter:
642 """Empty-initialize an instance of `CUfileOpCounter_t`.
645 .. seealso:: `CUfileOpCounter_t`
646 """
647 cdef:
648 CUfileOpCounter_t *_ptr
649 object _owner
650 bint _owns_ptr
651 bint _readonly
653 def __init__(self):
654 self._ptr = <CUfileOpCounter_t *>_cyb_calloc(1, sizeof(CUfileOpCounter_t))
655 if self._ptr == NULL:
656 raise MemoryError("Error allocating OpCounter")
657 self._owns_ptr = True
658 self._owner = None
659 self._readonly = False
661 def __dealloc__(self):
662 cdef CUfileOpCounter_t *ptr
663 if self._owns_ptr and self._ptr != NULL: 1fbgc
664 ptr = self._ptr
665 self._ptr = NULL
666 _cyb_free(ptr)
668 def __repr__(self):
669 return f"<{__name__}.OpCounter object at {hex(id(self))}>"
671 @property
672 def ptr(self):
673 """Get the pointer address to the data as Python :class:`int`."""
674 return <intptr_t>(self._ptr)
676 cdef intptr_t _get_ptr(self):
677 return <intptr_t>(self._ptr)
679 def __int__(self):
680 return <intptr_t>(self._ptr)
682 def __eq__(self, other):
683 cdef OpCounter other_
684 if not isinstance(other, OpCounter):
685 return False
686 other_ = other
687 return (_cyb_memcmp(<void *><intptr_t>(self._ptr), <void *><intptr_t>(other_._ptr), sizeof(CUfileOpCounter_t)) == 0)
689 def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags):
690 _cyb___getbuffer(self, buffer, <void *>self._ptr, sizeof(CUfileOpCounter_t), self._readonly)
692 def __releasebuffer__(self, Py_buffer *buffer):
693 pass
695 def __setitem__(self, key, val):
696 cdef _cyb_Py_buffer view
697 if key == 0:
698 if self._readonly:
699 raise ValueError("This OpCounter instance is read-only")
700 _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE)
701 try:
702 if <size_t>view.len < sizeof(CUfileOpCounter_t):
703 raise ValueError(
704 "source buffer too small: expected at least %d bytes, got %d" % (sizeof(CUfileOpCounter_t), view.len)
705 )
706 _cyb_memmove(<void*>self._ptr, view.buf, sizeof(CUfileOpCounter_t))
707 self._readonly = view.readonly != 0
708 finally:
709 _cyb_PyBuffer_Release(&view)
710 else:
711 setattr(self, key, val)
713 @property
714 def ok(self):
715 """int: """
716 return self._ptr[0].ok 1fbgc
718 @ok.setter
719 def ok(self, val):
720 if self._readonly:
721 raise ValueError("This OpCounter instance is read-only")
722 self._ptr[0].ok = val
724 @property
725 def err(self):
726 """int: """
727 return self._ptr[0].err
729 @err.setter
730 def err(self, val):
731 if self._readonly:
732 raise ValueError("This OpCounter instance is read-only")
733 self._ptr[0].err = val
735 @staticmethod
736 def from_buffer(buffer):
737 """Create an OpCounter instance with the memory from the given buffer."""
738 return _cyb_from_buffer(buffer, sizeof(CUfileOpCounter_t), OpCounter)
740 @staticmethod
741 def from_data(data):
742 """Create an OpCounter instance wrapping the given NumPy array.
744 Args:
745 data (_numpy.ndarray): a single-element array of dtype `op_counter_dtype` holding the data.
746 """
747 return _cyb_from_data(data, "op_counter_dtype", op_counter_dtype, OpCounter) 1fbgc
749 @staticmethod
750 def from_ptr(intptr_t ptr, bint readonly=False, object owner=None):
751 """Create an OpCounter instance wrapping the given pointer.
753 Args:
754 ptr (intptr_t): pointer address as Python :class:`int` to the data.
755 owner (object): The Python object that owns the pointer. If not provided, data will be copied.
756 readonly (bool): whether the data is read-only (to the user). default is `False`.
757 """
758 if ptr == 0: 1fbgc
759 raise ValueError("ptr must not be null (0)")
760 cdef OpCounter obj = OpCounter.__new__(OpCounter) 1fbgc
761 if owner is None: 1fbgc
762 obj._ptr = <CUfileOpCounter_t *>_cyb_malloc(sizeof(CUfileOpCounter_t))
763 if obj._ptr == NULL:
764 raise MemoryError("Error allocating OpCounter")
765 _cyb_memcpy(<void*>(obj._ptr), <void*>ptr, sizeof(CUfileOpCounter_t))
766 obj._owns_ptr = True
767 obj._owner = None
768 else:
769 obj._ptr = <CUfileOpCounter_t *>ptr 1fbgc
770 obj._owns_ptr = False 1fbgc
771 obj._owner = owner 1fbgc
772 obj._readonly = readonly 1fbgc
773 return obj 1fbgc
776cdef _get_per_gpu_stats_dtype_offsets():
777 cdef CUfilePerGpuStats_t *pod = <CUfilePerGpuStats_t *>_cyb_calloc(1, sizeof(CUfilePerGpuStats_t))
778 if pod == NULL:
779 raise MemoryError("Error allocating CUfilePerGpuStats_t")
780 try:
781 return _numpy.dtype({
782 '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'],
783 '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],
784 'offsets': [
785 (<intptr_t>&(pod.uuid)) - (<intptr_t>pod),
786 (<intptr_t>&(pod.read_bytes)) - (<intptr_t>pod),
787 (<intptr_t>&(pod.read_bw_bytes_per_sec)) - (<intptr_t>pod),
788 (<intptr_t>&(pod.read_utilization)) - (<intptr_t>pod),
789 (<intptr_t>&(pod.read_duration_us)) - (<intptr_t>pod),
790 (<intptr_t>&(pod.n_total_reads)) - (<intptr_t>pod),
791 (<intptr_t>&(pod.n_p2p_reads)) - (<intptr_t>pod),
792 (<intptr_t>&(pod.n_nvfs_reads)) - (<intptr_t>pod),
793 (<intptr_t>&(pod.n_posix_reads)) - (<intptr_t>pod),
794 (<intptr_t>&(pod.n_unaligned_reads)) - (<intptr_t>pod),
795 (<intptr_t>&(pod.n_dr_reads)) - (<intptr_t>pod),
796 (<intptr_t>&(pod.n_sparse_regions)) - (<intptr_t>pod),
797 (<intptr_t>&(pod.n_inline_regions)) - (<intptr_t>pod),
798 (<intptr_t>&(pod.n_reads_err)) - (<intptr_t>pod),
799 (<intptr_t>&(pod.writes_bytes)) - (<intptr_t>pod),
800 (<intptr_t>&(pod.write_bw_bytes_per_sec)) - (<intptr_t>pod),
801 (<intptr_t>&(pod.write_utilization)) - (<intptr_t>pod),
802 (<intptr_t>&(pod.write_duration_us)) - (<intptr_t>pod),
803 (<intptr_t>&(pod.n_total_writes)) - (<intptr_t>pod),
804 (<intptr_t>&(pod.n_p2p_writes)) - (<intptr_t>pod),
805 (<intptr_t>&(pod.n_nvfs_writes)) - (<intptr_t>pod),
806 (<intptr_t>&(pod.n_posix_writes)) - (<intptr_t>pod),
807 (<intptr_t>&(pod.n_unaligned_writes)) - (<intptr_t>pod),
808 (<intptr_t>&(pod.n_dr_writes)) - (<intptr_t>pod),
809 (<intptr_t>&(pod.n_writes_err)) - (<intptr_t>pod),
810 (<intptr_t>&(pod.n_mmap)) - (<intptr_t>pod),
811 (<intptr_t>&(pod.n_mmap_ok)) - (<intptr_t>pod),
812 (<intptr_t>&(pod.n_mmap_err)) - (<intptr_t>pod),
813 (<intptr_t>&(pod.n_mmap_free)) - (<intptr_t>pod),
814 (<intptr_t>&(pod.reg_bytes)) - (<intptr_t>pod),
815 ],
816 'itemsize': sizeof(CUfilePerGpuStats_t),
817 })
818 finally:
819 _cyb_free(pod)
821per_gpu_stats_dtype = _get_per_gpu_stats_dtype_offsets()
822cdef object per_gpu_stats_dtype_record = _numpy.dtype((_numpy.record, per_gpu_stats_dtype))
824cdef class PerGpuStats:
825 """Empty-initialize an array of `CUfilePerGpuStats_t`.
826 The resulting object is of length `size` and of dtype `per_gpu_stats_dtype`.
827 If default-constructed, the instance represents a single struct.
829 Args:
830 size (int): number of structs, default=1.
832 .. seealso:: `CUfilePerGpuStats_t`
833 """
834 cdef:
835 readonly object _data
836 object _owner
838 def __init__(self, size=1):
839 self._data = _numpy.zeros(size, dtype=per_gpu_stats_dtype_record)
840 assert self._data.itemsize == sizeof(CUfilePerGpuStats_t), \
841 f"itemsize {self._data.itemsize} mismatches struct size { sizeof(CUfilePerGpuStats_t) }"
843 def __repr__(self):
844 if self._data.size > 1:
845 return f"<{__name__}.PerGpuStats_Array_{self._data.size} object at {hex(id(self))}>"
846 else:
847 return f"<{__name__}.PerGpuStats object at {hex(id(self))}>"
849 @property
850 def ptr(self):
851 """Get the pointer address to the data as Python :class:`int`."""
852 return _cyb_array_ptr(self._data)
854 cdef intptr_t _get_ptr(self):
855 return _cyb_array_ptr(self._data)
857 def __int__(self):
858 if self._data.size > 1 and not self._data.flags["C_CONTIGUOUS"]:
859 raise TypeError("int() argument must be a bytes-like object of size 1, or a "
860 "C-contiguous array. To get the pointer address of a "
861 "non-contiguous array, use .ptr")
862 return _cyb_array_ptr(self._data)
864 def __len__(self):
865 return self._data.size
867 def __eq__(self, other):
868 cdef object self_data = self._data
869 if (not isinstance(other, PerGpuStats)) or self_data.size != other._data.size or self_data.dtype != other._data.dtype:
870 return False
871 return bool((self_data == other._data).all())
873 def __getbuffer__(self, Py_buffer *buffer, int flags):
874 _cyb_cpython.PyObject_GetBuffer(self._data, buffer, flags)
876 def __releasebuffer__(self, Py_buffer *buffer):
877 _cyb_cpython.PyBuffer_Release(buffer)
879 @property
880 def uuid(self):
881 """~_numpy.int8: (array of length 16)."""
882 return self._data["uuid"]
884 @uuid.setter
885 def uuid(self, val):
886 if not self._data.flags.writeable:
887 raise ValueError("This PerGpuStats instance is read-only")
888 self._data["uuid"] = val
890 @property
891 def read_bytes(self):
892 """Union[~_numpy.uint64, int]: """
893 if self._data.size == 1:
894 return int(self._data["read_bytes"][0])
895 return self._data["read_bytes"]
897 @read_bytes.setter
898 def read_bytes(self, val):
899 if not self._data.flags.writeable:
900 raise ValueError("This PerGpuStats instance is read-only")
901 self._data["read_bytes"] = val
903 @property
904 def read_bw_bytes_per_sec(self):
905 """Union[~_numpy.uint64, int]: """
906 if self._data.size == 1:
907 return int(self._data["read_bw_bytes_per_sec"][0])
908 return self._data["read_bw_bytes_per_sec"]
910 @read_bw_bytes_per_sec.setter
911 def read_bw_bytes_per_sec(self, val):
912 if not self._data.flags.writeable:
913 raise ValueError("This PerGpuStats instance is read-only")
914 self._data["read_bw_bytes_per_sec"] = val
916 @property
917 def read_utilization(self):
918 """Union[~_numpy.uint64, int]: """
919 if self._data.size == 1:
920 return int(self._data["read_utilization"][0])
921 return self._data["read_utilization"]
923 @read_utilization.setter
924 def read_utilization(self, val):
925 if not self._data.flags.writeable:
926 raise ValueError("This PerGpuStats instance is read-only")
927 self._data["read_utilization"] = val
929 @property
930 def read_duration_us(self):
931 """Union[~_numpy.uint64, int]: """
932 if self._data.size == 1:
933 return int(self._data["read_duration_us"][0])
934 return self._data["read_duration_us"]
936 @read_duration_us.setter
937 def read_duration_us(self, val):
938 if not self._data.flags.writeable:
939 raise ValueError("This PerGpuStats instance is read-only")
940 self._data["read_duration_us"] = val
942 @property
943 def n_total_reads(self):
944 """Union[~_numpy.uint64, int]: """
945 if self._data.size == 1: 1de
946 return int(self._data["n_total_reads"][0]) 1de
947 return self._data["n_total_reads"]
949 @n_total_reads.setter
950 def n_total_reads(self, val):
951 if not self._data.flags.writeable:
952 raise ValueError("This PerGpuStats instance is read-only")
953 self._data["n_total_reads"] = val
955 @property
956 def n_p2p_reads(self):
957 """Union[~_numpy.uint64, int]: """
958 if self._data.size == 1:
959 return int(self._data["n_p2p_reads"][0])
960 return self._data["n_p2p_reads"]
962 @n_p2p_reads.setter
963 def n_p2p_reads(self, val):
964 if not self._data.flags.writeable:
965 raise ValueError("This PerGpuStats instance is read-only")
966 self._data["n_p2p_reads"] = val
968 @property
969 def n_nvfs_reads(self):
970 """Union[~_numpy.uint64, int]: """
971 if self._data.size == 1:
972 return int(self._data["n_nvfs_reads"][0])
973 return self._data["n_nvfs_reads"]
975 @n_nvfs_reads.setter
976 def n_nvfs_reads(self, val):
977 if not self._data.flags.writeable:
978 raise ValueError("This PerGpuStats instance is read-only")
979 self._data["n_nvfs_reads"] = val
981 @property
982 def n_posix_reads(self):
983 """Union[~_numpy.uint64, int]: """
984 if self._data.size == 1:
985 return int(self._data["n_posix_reads"][0])
986 return self._data["n_posix_reads"]
988 @n_posix_reads.setter
989 def n_posix_reads(self, val):
990 if not self._data.flags.writeable:
991 raise ValueError("This PerGpuStats instance is read-only")
992 self._data["n_posix_reads"] = val
994 @property
995 def n_unaligned_reads(self):
996 """Union[~_numpy.uint64, int]: """
997 if self._data.size == 1:
998 return int(self._data["n_unaligned_reads"][0])
999 return self._data["n_unaligned_reads"]
1001 @n_unaligned_reads.setter
1002 def n_unaligned_reads(self, val):
1003 if not self._data.flags.writeable:
1004 raise ValueError("This PerGpuStats instance is read-only")
1005 self._data["n_unaligned_reads"] = val
1007 @property
1008 def n_dr_reads(self):
1009 """Union[~_numpy.uint64, int]: """
1010 if self._data.size == 1:
1011 return int(self._data["n_dr_reads"][0])
1012 return self._data["n_dr_reads"]
1014 @n_dr_reads.setter
1015 def n_dr_reads(self, val):
1016 if not self._data.flags.writeable:
1017 raise ValueError("This PerGpuStats instance is read-only")
1018 self._data["n_dr_reads"] = val
1020 @property
1021 def n_sparse_regions(self):
1022 """Union[~_numpy.uint64, int]: """
1023 if self._data.size == 1:
1024 return int(self._data["n_sparse_regions"][0])
1025 return self._data["n_sparse_regions"]
1027 @n_sparse_regions.setter
1028 def n_sparse_regions(self, val):
1029 if not self._data.flags.writeable:
1030 raise ValueError("This PerGpuStats instance is read-only")
1031 self._data["n_sparse_regions"] = val
1033 @property
1034 def n_inline_regions(self):
1035 """Union[~_numpy.uint64, int]: """
1036 if self._data.size == 1:
1037 return int(self._data["n_inline_regions"][0])
1038 return self._data["n_inline_regions"]
1040 @n_inline_regions.setter
1041 def n_inline_regions(self, val):
1042 if not self._data.flags.writeable:
1043 raise ValueError("This PerGpuStats instance is read-only")
1044 self._data["n_inline_regions"] = val
1046 @property
1047 def n_reads_err(self):
1048 """Union[~_numpy.uint64, int]: """
1049 if self._data.size == 1:
1050 return int(self._data["n_reads_err"][0])
1051 return self._data["n_reads_err"]
1053 @n_reads_err.setter
1054 def n_reads_err(self, val):
1055 if not self._data.flags.writeable:
1056 raise ValueError("This PerGpuStats instance is read-only")
1057 self._data["n_reads_err"] = val
1059 @property
1060 def writes_bytes(self):
1061 """Union[~_numpy.uint64, int]: """
1062 if self._data.size == 1:
1063 return int(self._data["writes_bytes"][0])
1064 return self._data["writes_bytes"]
1066 @writes_bytes.setter
1067 def writes_bytes(self, val):
1068 if not self._data.flags.writeable:
1069 raise ValueError("This PerGpuStats instance is read-only")
1070 self._data["writes_bytes"] = val
1072 @property
1073 def write_bw_bytes_per_sec(self):
1074 """Union[~_numpy.uint64, int]: """
1075 if self._data.size == 1:
1076 return int(self._data["write_bw_bytes_per_sec"][0])
1077 return self._data["write_bw_bytes_per_sec"]
1079 @write_bw_bytes_per_sec.setter
1080 def write_bw_bytes_per_sec(self, val):
1081 if not self._data.flags.writeable:
1082 raise ValueError("This PerGpuStats instance is read-only")
1083 self._data["write_bw_bytes_per_sec"] = val
1085 @property
1086 def write_utilization(self):
1087 """Union[~_numpy.uint64, int]: """
1088 if self._data.size == 1:
1089 return int(self._data["write_utilization"][0])
1090 return self._data["write_utilization"]
1092 @write_utilization.setter
1093 def write_utilization(self, val):
1094 if not self._data.flags.writeable:
1095 raise ValueError("This PerGpuStats instance is read-only")
1096 self._data["write_utilization"] = val
1098 @property
1099 def write_duration_us(self):
1100 """Union[~_numpy.uint64, int]: """
1101 if self._data.size == 1:
1102 return int(self._data["write_duration_us"][0])
1103 return self._data["write_duration_us"]
1105 @write_duration_us.setter
1106 def write_duration_us(self, val):
1107 if not self._data.flags.writeable:
1108 raise ValueError("This PerGpuStats instance is read-only")
1109 self._data["write_duration_us"] = val
1111 @property
1112 def n_total_writes(self):
1113 """Union[~_numpy.uint64, int]: """
1114 if self._data.size == 1:
1115 return int(self._data["n_total_writes"][0])
1116 return self._data["n_total_writes"]
1118 @n_total_writes.setter
1119 def n_total_writes(self, val):
1120 if not self._data.flags.writeable:
1121 raise ValueError("This PerGpuStats instance is read-only")
1122 self._data["n_total_writes"] = val
1124 @property
1125 def n_p2p_writes(self):
1126 """Union[~_numpy.uint64, int]: """
1127 if self._data.size == 1:
1128 return int(self._data["n_p2p_writes"][0])
1129 return self._data["n_p2p_writes"]
1131 @n_p2p_writes.setter
1132 def n_p2p_writes(self, val):
1133 if not self._data.flags.writeable:
1134 raise ValueError("This PerGpuStats instance is read-only")
1135 self._data["n_p2p_writes"] = val
1137 @property
1138 def n_nvfs_writes(self):
1139 """Union[~_numpy.uint64, int]: """
1140 if self._data.size == 1:
1141 return int(self._data["n_nvfs_writes"][0])
1142 return self._data["n_nvfs_writes"]
1144 @n_nvfs_writes.setter
1145 def n_nvfs_writes(self, val):
1146 if not self._data.flags.writeable:
1147 raise ValueError("This PerGpuStats instance is read-only")
1148 self._data["n_nvfs_writes"] = val
1150 @property
1151 def n_posix_writes(self):
1152 """Union[~_numpy.uint64, int]: """
1153 if self._data.size == 1:
1154 return int(self._data["n_posix_writes"][0])
1155 return self._data["n_posix_writes"]
1157 @n_posix_writes.setter
1158 def n_posix_writes(self, val):
1159 if not self._data.flags.writeable:
1160 raise ValueError("This PerGpuStats instance is read-only")
1161 self._data["n_posix_writes"] = val
1163 @property
1164 def n_unaligned_writes(self):
1165 """Union[~_numpy.uint64, int]: """
1166 if self._data.size == 1:
1167 return int(self._data["n_unaligned_writes"][0])
1168 return self._data["n_unaligned_writes"]
1170 @n_unaligned_writes.setter
1171 def n_unaligned_writes(self, val):
1172 if not self._data.flags.writeable:
1173 raise ValueError("This PerGpuStats instance is read-only")
1174 self._data["n_unaligned_writes"] = val
1176 @property
1177 def n_dr_writes(self):
1178 """Union[~_numpy.uint64, int]: """
1179 if self._data.size == 1:
1180 return int(self._data["n_dr_writes"][0])
1181 return self._data["n_dr_writes"]
1183 @n_dr_writes.setter
1184 def n_dr_writes(self, val):
1185 if not self._data.flags.writeable:
1186 raise ValueError("This PerGpuStats instance is read-only")
1187 self._data["n_dr_writes"] = val
1189 @property
1190 def n_writes_err(self):
1191 """Union[~_numpy.uint64, int]: """
1192 if self._data.size == 1:
1193 return int(self._data["n_writes_err"][0])
1194 return self._data["n_writes_err"]
1196 @n_writes_err.setter
1197 def n_writes_err(self, val):
1198 if not self._data.flags.writeable:
1199 raise ValueError("This PerGpuStats instance is read-only")
1200 self._data["n_writes_err"] = val
1202 @property
1203 def n_mmap(self):
1204 """Union[~_numpy.uint64, int]: """
1205 if self._data.size == 1:
1206 return int(self._data["n_mmap"][0])
1207 return self._data["n_mmap"]
1209 @n_mmap.setter
1210 def n_mmap(self, val):
1211 if not self._data.flags.writeable:
1212 raise ValueError("This PerGpuStats instance is read-only")
1213 self._data["n_mmap"] = val
1215 @property
1216 def n_mmap_ok(self):
1217 """Union[~_numpy.uint64, int]: """
1218 if self._data.size == 1:
1219 return int(self._data["n_mmap_ok"][0])
1220 return self._data["n_mmap_ok"]
1222 @n_mmap_ok.setter
1223 def n_mmap_ok(self, val):
1224 if not self._data.flags.writeable:
1225 raise ValueError("This PerGpuStats instance is read-only")
1226 self._data["n_mmap_ok"] = val
1228 @property
1229 def n_mmap_err(self):
1230 """Union[~_numpy.uint64, int]: """
1231 if self._data.size == 1:
1232 return int(self._data["n_mmap_err"][0])
1233 return self._data["n_mmap_err"]
1235 @n_mmap_err.setter
1236 def n_mmap_err(self, val):
1237 if not self._data.flags.writeable:
1238 raise ValueError("This PerGpuStats instance is read-only")
1239 self._data["n_mmap_err"] = val
1241 @property
1242 def n_mmap_free(self):
1243 """Union[~_numpy.uint64, int]: """
1244 if self._data.size == 1:
1245 return int(self._data["n_mmap_free"][0])
1246 return self._data["n_mmap_free"]
1248 @n_mmap_free.setter
1249 def n_mmap_free(self, val):
1250 if not self._data.flags.writeable:
1251 raise ValueError("This PerGpuStats instance is read-only")
1252 self._data["n_mmap_free"] = val
1254 @property
1255 def reg_bytes(self):
1256 """Union[~_numpy.uint64, int]: """
1257 if self._data.size == 1:
1258 return int(self._data["reg_bytes"][0])
1259 return self._data["reg_bytes"]
1261 @reg_bytes.setter
1262 def reg_bytes(self, val):
1263 if not self._data.flags.writeable:
1264 raise ValueError("This PerGpuStats instance is read-only")
1265 self._data["reg_bytes"] = val
1267 def __getitem__(self, key):
1268 cdef ssize_t key_
1269 cdef ssize_t size
1270 cdef PerGpuStats obj
1271 if isinstance(key, int): 1de
1272 key_ = key 1de
1273 size = self._data.size 1de
1274 if key_ >= size or key_ <= -(size+1): 1de
1275 raise IndexError("index is out of bounds")
1276 if key_ < 0: 1de
1277 key_ += size
1278 obj = PerGpuStats.__new__(PerGpuStats) 1de
1279 obj._data = self._data[key_:key_+1] 1de
1280 obj._owner = self._owner 1de
1281 return obj 1de
1282 out = self._data[key]
1283 if isinstance(out, _numpy.ndarray):
1284 if out.dtype == per_gpu_stats_dtype:
1285 obj = PerGpuStats.from_data(out)
1286 obj._owner = self._owner
1287 return obj
1288 if out.dtype.names is not None:
1289 return out.view(_numpy.recarray)
1290 return out
1292 def __setitem__(self, key, val):
1293 self._data[key] = val
1295 @staticmethod
1296 def from_buffer(buffer):
1297 """Create an PerGpuStats instance with the memory from the given buffer."""
1298 return PerGpuStats.from_data(_numpy.frombuffer(buffer, dtype=per_gpu_stats_dtype))
1300 @staticmethod
1301 def from_data(data):
1302 """Create an PerGpuStats instance wrapping the given NumPy array.
1304 Args:
1305 data (_numpy.ndarray): a 1D array of dtype `per_gpu_stats_dtype` holding the data.
1306 """
1307 cdef PerGpuStats obj = PerGpuStats.__new__(PerGpuStats)
1308 if not isinstance(data, _numpy.ndarray):
1309 raise TypeError("data argument must be a NumPy ndarray")
1310 if data.ndim != 1:
1311 raise ValueError("data array must be 1D")
1312 if data.dtype != per_gpu_stats_dtype:
1313 raise ValueError("data array must be of dtype per_gpu_stats_dtype")
1314 obj._data = data.view(dtype=per_gpu_stats_dtype_record, type=_numpy.ndarray)
1315 return obj
1317 @staticmethod
1318 def from_ptr(intptr_t ptr, size_t size=1, bint readonly=False, object owner=None):
1319 """Create an PerGpuStats instance wrapping the given pointer.
1321 Args:
1322 ptr (intptr_t): pointer address as Python :class:`int` to the data.
1323 size (int): number of structs, default=1.
1324 readonly (bool): whether the data is read-only (to the user). default is `False`.
1325 owner (object): object that owns the memory at *ptr*. A strong reference is
1326 kept so the backing storage outlives this wrapper.
1327 """
1328 if ptr == 0: 1de
1329 raise ValueError("ptr must not be null (0)")
1330 cdef PerGpuStats obj = PerGpuStats.__new__(PerGpuStats) 1de
1331 cdef flag = _cyb_cpython_buffer.PyBUF_READ if readonly else _cyb_cpython_buffer.PyBUF_WRITE 1de
1332 cdef object buf = _cyb_cpython_memoryview.PyMemoryView_FromMemory( 1de
1333 <char*>ptr, sizeof(CUfilePerGpuStats_t) * size, flag) 1de
1334 obj._data = _numpy.ndarray(size, buffer=buf, dtype=per_gpu_stats_dtype_record) 1de
1335 obj._owner = owner 1de
1336 return obj 1de
1339cdef _get_io_vec_dtype_offsets():
1340 cdef CUfileIOVec_t *pod = <CUfileIOVec_t *>_cyb_calloc(1, sizeof(CUfileIOVec_t))
1341 if pod == NULL:
1342 raise MemoryError("Error allocating CUfileIOVec_t")
1343 try:
1344 return _numpy.dtype({
1345 'names': ['base_', 'len'],
1346 'formats': [_numpy.intp, _numpy.uint64],
1347 'offsets': [
1348 (<intptr_t>&(pod.base)) - (<intptr_t>pod),
1349 (<intptr_t>&(pod.len)) - (<intptr_t>pod),
1350 ],
1351 'itemsize': sizeof(CUfileIOVec_t),
1352 })
1353 finally:
1354 _cyb_free(pod)
1356io_vec_dtype = _get_io_vec_dtype_offsets()
1357cdef object io_vec_dtype_record = _numpy.dtype((_numpy.record, io_vec_dtype))
1359cdef class IOVec:
1360 """Empty-initialize an array of `CUfileIOVec_t`.
1361 The resulting object is of length `size` and of dtype `io_vec_dtype`.
1362 If default-constructed, the instance represents a single struct.
1364 Args:
1365 size (int): number of structs, default=1.
1367 .. seealso:: `CUfileIOVec_t`
1368 """
1369 cdef:
1370 readonly object _data
1371 object _owner
1373 def __init__(self, size=1):
1374 self._data = _numpy.zeros(size, dtype=io_vec_dtype_record)
1375 assert self._data.itemsize == sizeof(CUfileIOVec_t), \
1376 f"itemsize {self._data.itemsize} mismatches struct size { sizeof(CUfileIOVec_t) }"
1378 def __repr__(self):
1379 if self._data.size > 1:
1380 return f"<{__name__}.IOVec_Array_{self._data.size} object at {hex(id(self))}>"
1381 else:
1382 return f"<{__name__}.IOVec object at {hex(id(self))}>"
1384 @property
1385 def ptr(self):
1386 """Get the pointer address to the data as Python :class:`int`."""
1387 return _cyb_array_ptr(self._data)
1389 cdef intptr_t _get_ptr(self):
1390 return _cyb_array_ptr(self._data)
1392 def __int__(self):
1393 if self._data.size > 1 and not self._data.flags["C_CONTIGUOUS"]:
1394 raise TypeError("int() argument must be a bytes-like object of size 1, or a "
1395 "C-contiguous array. To get the pointer address of a "
1396 "non-contiguous array, use .ptr")
1397 return _cyb_array_ptr(self._data)
1399 def __len__(self):
1400 return self._data.size
1402 def __eq__(self, other):
1403 cdef object self_data = self._data
1404 if (not isinstance(other, IOVec)) or self_data.size != other._data.size or self_data.dtype != other._data.dtype:
1405 return False
1406 return bool((self_data == other._data).all())
1408 def __getbuffer__(self, Py_buffer *buffer, int flags):
1409 _cyb_cpython.PyObject_GetBuffer(self._data, buffer, flags)
1411 def __releasebuffer__(self, Py_buffer *buffer):
1412 _cyb_cpython.PyBuffer_Release(buffer)
1414 @property
1415 def base_(self):
1416 """Union[~_numpy.intp, int]: """
1417 if self._data.size == 1:
1418 return int(self._data["base_"][0])
1419 return self._data["base_"]
1421 @base_.setter
1422 def base_(self, val):
1423 if not self._data.flags.writeable:
1424 raise ValueError("This IOVec instance is read-only")
1425 self._data["base_"] = val
1427 @property
1428 def len(self):
1429 """Union[~_numpy.uint64, int]: """
1430 if self._data.size == 1:
1431 return int(self._data["len"][0])
1432 return self._data["len"]
1434 @len.setter
1435 def len(self, val):
1436 if not self._data.flags.writeable:
1437 raise ValueError("This IOVec instance is read-only")
1438 self._data["len"] = val
1440 def __getitem__(self, key):
1441 cdef ssize_t key_
1442 cdef ssize_t size
1443 cdef IOVec obj
1444 if isinstance(key, int):
1445 key_ = key
1446 size = self._data.size
1447 if key_ >= size or key_ <= -(size+1):
1448 raise IndexError("index is out of bounds")
1449 if key_ < 0:
1450 key_ += size
1451 obj = IOVec.__new__(IOVec)
1452 obj._data = self._data[key_:key_+1]
1453 obj._owner = self._owner
1454 return obj
1455 out = self._data[key]
1456 if isinstance(out, _numpy.ndarray):
1457 if out.dtype == io_vec_dtype:
1458 obj = IOVec.from_data(out)
1459 obj._owner = self._owner
1460 return obj
1461 if out.dtype.names is not None:
1462 return out.view(_numpy.recarray)
1463 return out
1465 def __setitem__(self, key, val):
1466 self._data[key] = val
1468 @staticmethod
1469 def from_buffer(buffer):
1470 """Create an IOVec instance with the memory from the given buffer."""
1471 return IOVec.from_data(_numpy.frombuffer(buffer, dtype=io_vec_dtype))
1473 @staticmethod
1474 def from_data(data):
1475 """Create an IOVec instance wrapping the given NumPy array.
1477 Args:
1478 data (_numpy.ndarray): a 1D array of dtype `io_vec_dtype` holding the data.
1479 """
1480 cdef IOVec obj = IOVec.__new__(IOVec)
1481 if not isinstance(data, _numpy.ndarray):
1482 raise TypeError("data argument must be a NumPy ndarray")
1483 if data.ndim != 1:
1484 raise ValueError("data array must be 1D")
1485 if data.dtype != io_vec_dtype:
1486 raise ValueError("data array must be of dtype io_vec_dtype")
1487 obj._data = data.view(dtype=io_vec_dtype_record, type=_numpy.ndarray)
1488 return obj
1490 @staticmethod
1491 def from_ptr(intptr_t ptr, size_t size=1, bint readonly=False, object owner=None):
1492 """Create an IOVec instance wrapping the given pointer.
1494 Args:
1495 ptr (intptr_t): pointer address as Python :class:`int` to the data.
1496 size (int): number of structs, default=1.
1497 readonly (bool): whether the data is read-only (to the user). default is `False`.
1498 owner (object): object that owns the memory at *ptr*. A strong reference is
1499 kept so the backing storage outlives this wrapper.
1500 """
1501 if ptr == 0:
1502 raise ValueError("ptr must not be null (0)")
1503 cdef IOVec obj = IOVec.__new__(IOVec)
1504 cdef flag = _cyb_cpython_buffer.PyBUF_READ if readonly else _cyb_cpython_buffer.PyBUF_WRITE
1505 cdef object buf = _cyb_cpython_memoryview.PyMemoryView_FromMemory(
1506 <char*>ptr, sizeof(CUfileIOVec_t) * size, flag)
1507 obj._data = _numpy.ndarray(size, buffer=buf, dtype=io_vec_dtype_record)
1508 obj._owner = owner
1509 return obj
1512cdef _get__py_anon_pod2_dtype_offsets():
1513 cdef cuda_bindings_cufile__anon_pod2 *pod = <cuda_bindings_cufile__anon_pod2 *>_cyb_calloc(1, sizeof(cuda_bindings_cufile__anon_pod2))
1514 if pod == NULL:
1515 raise MemoryError("Error allocating cuda_bindings_cufile__anon_pod2")
1516 try:
1517 return _numpy.dtype({
1518 'names': ['batch'],
1519 'formats': [_py_anon_pod3_dtype],
1520 'offsets': [
1521 (<intptr_t>&(pod.batch)) - (<intptr_t>pod),
1522 ],
1523 'itemsize': sizeof(cuda_bindings_cufile__anon_pod2),
1524 })
1525 finally:
1526 _cyb_free(pod)
1528_py_anon_pod2_dtype = _get__py_anon_pod2_dtype_offsets()
1530cdef class _py_anon_pod2:
1531 """Empty-initialize an instance of `cuda_bindings_cufile__anon_pod2`.
1534 .. seealso:: `cuda_bindings_cufile__anon_pod2`
1535 """
1536 cdef:
1537 cuda_bindings_cufile__anon_pod2 *_ptr
1538 object _owner
1539 bint _owns_ptr
1540 bint _readonly
1542 def __init__(self):
1543 self._ptr = <cuda_bindings_cufile__anon_pod2 *>_cyb_calloc(1, sizeof(cuda_bindings_cufile__anon_pod2))
1544 if self._ptr == NULL:
1545 raise MemoryError("Error allocating _py_anon_pod2")
1546 self._owns_ptr = True
1547 self._owner = None
1548 self._readonly = False
1550 def __dealloc__(self):
1551 cdef cuda_bindings_cufile__anon_pod2 *ptr
1552 if self._owns_ptr and self._ptr != NULL:
1553 ptr = self._ptr
1554 self._ptr = NULL
1555 _cyb_free(ptr)
1557 def __repr__(self):
1558 return f"<{__name__}._py_anon_pod2 object at {hex(id(self))}>"
1560 @property
1561 def ptr(self):
1562 """Get the pointer address to the data as Python :class:`int`."""
1563 return <intptr_t>(self._ptr)
1565 cdef intptr_t _get_ptr(self):
1566 return <intptr_t>(self._ptr)
1568 def __int__(self):
1569 return <intptr_t>(self._ptr)
1571 def __eq__(self, other):
1572 cdef _py_anon_pod2 other_
1573 if not isinstance(other, _py_anon_pod2):
1574 return False
1575 other_ = other
1576 return (_cyb_memcmp(<void *><intptr_t>(self._ptr), <void *><intptr_t>(other_._ptr), sizeof(cuda_bindings_cufile__anon_pod2)) == 0)
1578 def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags):
1579 _cyb___getbuffer(self, buffer, <void *>self._ptr, sizeof(cuda_bindings_cufile__anon_pod2), self._readonly)
1581 def __releasebuffer__(self, Py_buffer *buffer):
1582 pass
1584 def __setitem__(self, key, val):
1585 cdef _cyb_Py_buffer view
1586 if key == 0:
1587 if self._readonly:
1588 raise ValueError("This _py_anon_pod2 instance is read-only")
1589 _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE)
1590 try:
1591 if <size_t>view.len < sizeof(cuda_bindings_cufile__anon_pod2):
1592 raise ValueError(
1593 "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_cufile__anon_pod2), view.len)
1594 )
1595 _cyb_memmove(<void*>self._ptr, view.buf, sizeof(cuda_bindings_cufile__anon_pod2))
1596 self._readonly = view.readonly != 0
1597 finally:
1598 _cyb_PyBuffer_Release(&view)
1599 else:
1600 setattr(self, key, val)
1602 @property
1603 def batch(self):
1604 """_py_anon_pod3: """
1605 return _py_anon_pod3.from_ptr(
1606 <intptr_t>&(self._ptr[0].batch),
1607 readonly=self._readonly,
1608 owner=self,
1609 )
1611 @batch.setter
1612 def batch(self, val):
1613 if self._readonly:
1614 raise ValueError("This _py_anon_pod2 instance is read-only")
1615 cdef _py_anon_pod3 val_ = val
1616 _cyb_memcpy(<void *>&(self._ptr[0].batch), <void *>(val_._get_ptr()), sizeof(cuda_bindings_cufile__anon_pod3) * 1)
1618 @staticmethod
1619 def from_buffer(buffer):
1620 """Create an _py_anon_pod2 instance with the memory from the given buffer."""
1621 return _cyb_from_buffer(buffer, sizeof(cuda_bindings_cufile__anon_pod2), _py_anon_pod2)
1623 @staticmethod
1624 def from_data(data):
1625 """Create an _py_anon_pod2 instance wrapping the given NumPy array.
1627 Args:
1628 data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod2_dtype` holding the data.
1629 """
1630 return _cyb_from_data(data, "_py_anon_pod2_dtype", _py_anon_pod2_dtype, _py_anon_pod2)
1632 @staticmethod
1633 def from_ptr(intptr_t ptr, bint readonly=False, object owner=None):
1634 """Create an _py_anon_pod2 instance wrapping the given pointer.
1636 Args:
1637 ptr (intptr_t): pointer address as Python :class:`int` to the data.
1638 owner (object): The Python object that owns the pointer. If not provided, data will be copied.
1639 readonly (bool): whether the data is read-only (to the user). default is `False`.
1640 """
1641 if ptr == 0:
1642 raise ValueError("ptr must not be null (0)")
1643 cdef _py_anon_pod2 obj = _py_anon_pod2.__new__(_py_anon_pod2)
1644 if owner is None:
1645 obj._ptr = <cuda_bindings_cufile__anon_pod2 *>_cyb_malloc(sizeof(cuda_bindings_cufile__anon_pod2))
1646 if obj._ptr == NULL:
1647 raise MemoryError("Error allocating _py_anon_pod2")
1648 _cyb_memcpy(<void*>(obj._ptr), <void*>ptr, sizeof(cuda_bindings_cufile__anon_pod2))
1649 obj._owns_ptr = True
1650 obj._owner = None
1651 else:
1652 obj._ptr = <cuda_bindings_cufile__anon_pod2 *>ptr
1653 obj._owns_ptr = False
1654 obj._owner = owner
1655 obj._readonly = readonly
1656 return obj
1659cdef _get_stats_level1_dtype_offsets():
1660 cdef CUfileStatsLevel1_t *pod = <CUfileStatsLevel1_t *>_cyb_calloc(1, sizeof(CUfileStatsLevel1_t))
1661 if pod == NULL:
1662 raise MemoryError("Error allocating CUfileStatsLevel1_t")
1663 try:
1664 return _numpy.dtype({
1665 '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', 'readv_ops', 'writev_ops', 'readv_bytes', 'writev_bytes', 'readv_bw_bytes_per_sec', 'writev_bw_bytes_per_sec', 'readv_lat_avg_us', 'writev_lat_avg_us', 'readv_ops_per_sec', 'writev_ops_per_sec', 'readv_lat_sum_us', 'writev_lat_sum_us'],
1666 '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, 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],
1667 'offsets': [
1668 (<intptr_t>&(pod.read_ops)) - (<intptr_t>pod),
1669 (<intptr_t>&(pod.write_ops)) - (<intptr_t>pod),
1670 (<intptr_t>&(pod.hdl_register_ops)) - (<intptr_t>pod),
1671 (<intptr_t>&(pod.hdl_deregister_ops)) - (<intptr_t>pod),
1672 (<intptr_t>&(pod.buf_register_ops)) - (<intptr_t>pod),
1673 (<intptr_t>&(pod.buf_deregister_ops)) - (<intptr_t>pod),
1674 (<intptr_t>&(pod.read_bytes)) - (<intptr_t>pod),
1675 (<intptr_t>&(pod.write_bytes)) - (<intptr_t>pod),
1676 (<intptr_t>&(pod.read_bw_bytes_per_sec)) - (<intptr_t>pod),
1677 (<intptr_t>&(pod.write_bw_bytes_per_sec)) - (<intptr_t>pod),
1678 (<intptr_t>&(pod.read_lat_avg_us)) - (<intptr_t>pod),
1679 (<intptr_t>&(pod.write_lat_avg_us)) - (<intptr_t>pod),
1680 (<intptr_t>&(pod.read_ops_per_sec)) - (<intptr_t>pod),
1681 (<intptr_t>&(pod.write_ops_per_sec)) - (<intptr_t>pod),
1682 (<intptr_t>&(pod.read_lat_sum_us)) - (<intptr_t>pod),
1683 (<intptr_t>&(pod.write_lat_sum_us)) - (<intptr_t>pod),
1684 (<intptr_t>&(pod.batch_submit_ops)) - (<intptr_t>pod),
1685 (<intptr_t>&(pod.batch_complete_ops)) - (<intptr_t>pod),
1686 (<intptr_t>&(pod.batch_setup_ops)) - (<intptr_t>pod),
1687 (<intptr_t>&(pod.batch_cancel_ops)) - (<intptr_t>pod),
1688 (<intptr_t>&(pod.batch_destroy_ops)) - (<intptr_t>pod),
1689 (<intptr_t>&(pod.batch_enqueued_ops)) - (<intptr_t>pod),
1690 (<intptr_t>&(pod.batch_posix_enqueued_ops)) - (<intptr_t>pod),
1691 (<intptr_t>&(pod.batch_processed_ops)) - (<intptr_t>pod),
1692 (<intptr_t>&(pod.batch_posix_processed_ops)) - (<intptr_t>pod),
1693 (<intptr_t>&(pod.batch_nvfs_submit_ops)) - (<intptr_t>pod),
1694 (<intptr_t>&(pod.batch_p2p_submit_ops)) - (<intptr_t>pod),
1695 (<intptr_t>&(pod.batch_aio_submit_ops)) - (<intptr_t>pod),
1696 (<intptr_t>&(pod.batch_iouring_submit_ops)) - (<intptr_t>pod),
1697 (<intptr_t>&(pod.batch_mixed_io_submit_ops)) - (<intptr_t>pod),
1698 (<intptr_t>&(pod.batch_total_submit_ops)) - (<intptr_t>pod),
1699 (<intptr_t>&(pod.batch_read_bytes)) - (<intptr_t>pod),
1700 (<intptr_t>&(pod.batch_write_bytes)) - (<intptr_t>pod),
1701 (<intptr_t>&(pod.batch_read_bw_bytes)) - (<intptr_t>pod),
1702 (<intptr_t>&(pod.batch_write_bw_bytes)) - (<intptr_t>pod),
1703 (<intptr_t>&(pod.batch_submit_lat_avg_us)) - (<intptr_t>pod),
1704 (<intptr_t>&(pod.batch_completion_lat_avg_us)) - (<intptr_t>pod),
1705 (<intptr_t>&(pod.batch_submit_ops_per_sec)) - (<intptr_t>pod),
1706 (<intptr_t>&(pod.batch_complete_ops_per_sec)) - (<intptr_t>pod),
1707 (<intptr_t>&(pod.batch_submit_lat_sum_us)) - (<intptr_t>pod),
1708 (<intptr_t>&(pod.batch_completion_lat_sum_us)) - (<intptr_t>pod),
1709 (<intptr_t>&(pod.last_batch_read_bytes)) - (<intptr_t>pod),
1710 (<intptr_t>&(pod.last_batch_write_bytes)) - (<intptr_t>pod),
1711 (<intptr_t>&(pod.readv_ops)) - (<intptr_t>pod),
1712 (<intptr_t>&(pod.writev_ops)) - (<intptr_t>pod),
1713 (<intptr_t>&(pod.readv_bytes)) - (<intptr_t>pod),
1714 (<intptr_t>&(pod.writev_bytes)) - (<intptr_t>pod),
1715 (<intptr_t>&(pod.readv_bw_bytes_per_sec)) - (<intptr_t>pod),
1716 (<intptr_t>&(pod.writev_bw_bytes_per_sec)) - (<intptr_t>pod),
1717 (<intptr_t>&(pod.readv_lat_avg_us)) - (<intptr_t>pod),
1718 (<intptr_t>&(pod.writev_lat_avg_us)) - (<intptr_t>pod),
1719 (<intptr_t>&(pod.readv_ops_per_sec)) - (<intptr_t>pod),
1720 (<intptr_t>&(pod.writev_ops_per_sec)) - (<intptr_t>pod),
1721 (<intptr_t>&(pod.readv_lat_sum_us)) - (<intptr_t>pod),
1722 (<intptr_t>&(pod.writev_lat_sum_us)) - (<intptr_t>pod),
1723 ],
1724 'itemsize': sizeof(CUfileStatsLevel1_t),
1725 })
1726 finally:
1727 _cyb_free(pod)
1729stats_level1_dtype = _get_stats_level1_dtype_offsets()
1731cdef class StatsLevel1:
1732 """Empty-initialize an instance of `CUfileStatsLevel1_t`.
1735 .. seealso:: `CUfileStatsLevel1_t`
1736 """
1737 cdef:
1738 CUfileStatsLevel1_t *_ptr
1739 object _owner
1740 bint _owns_ptr
1741 bint _readonly
1743 def __init__(self):
1744 self._ptr = <CUfileStatsLevel1_t *>_cyb_calloc(1, sizeof(CUfileStatsLevel1_t)) 1fg
1745 if self._ptr == NULL: 1fg
1746 raise MemoryError("Error allocating StatsLevel1")
1747 self._owns_ptr = True 1fg
1748 self._owner = None 1fg
1749 self._readonly = False 1fg
1751 def __dealloc__(self):
1752 cdef CUfileStatsLevel1_t *ptr
1753 if self._owns_ptr and self._ptr != NULL: 1fbgc
1754 ptr = self._ptr 1fg
1755 self._ptr = NULL 1fg
1756 _cyb_free(ptr) 1fg
1758 def __repr__(self):
1759 return f"<{__name__}.StatsLevel1 object at {hex(id(self))}>"
1761 @property
1762 def ptr(self):
1763 """Get the pointer address to the data as Python :class:`int`."""
1764 return <intptr_t>(self._ptr) 1fg
1766 cdef intptr_t _get_ptr(self):
1767 return <intptr_t>(self._ptr)
1769 def __int__(self):
1770 return <intptr_t>(self._ptr)
1772 def __eq__(self, other):
1773 cdef StatsLevel1 other_
1774 if not isinstance(other, StatsLevel1):
1775 return False
1776 other_ = other
1777 return (_cyb_memcmp(<void *><intptr_t>(self._ptr), <void *><intptr_t>(other_._ptr), sizeof(CUfileStatsLevel1_t)) == 0)
1779 def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags):
1780 _cyb___getbuffer(self, buffer, <void *>self._ptr, sizeof(CUfileStatsLevel1_t), self._readonly)
1782 def __releasebuffer__(self, Py_buffer *buffer):
1783 pass
1785 def __setitem__(self, key, val):
1786 cdef _cyb_Py_buffer view
1787 if key == 0:
1788 if self._readonly:
1789 raise ValueError("This StatsLevel1 instance is read-only")
1790 _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE)
1791 try:
1792 if <size_t>view.len < sizeof(CUfileStatsLevel1_t):
1793 raise ValueError(
1794 "source buffer too small: expected at least %d bytes, got %d" % (sizeof(CUfileStatsLevel1_t), view.len)
1795 )
1796 _cyb_memmove(<void*>self._ptr, view.buf, sizeof(CUfileStatsLevel1_t))
1797 self._readonly = view.readonly != 0
1798 finally:
1799 _cyb_PyBuffer_Release(&view)
1800 else:
1801 setattr(self, key, val)
1803 @property
1804 def read_ops(self):
1805 """OpCounter: """
1806 return OpCounter.from_ptr( 1fbgc
1807 <intptr_t>&(self._ptr[0].read_ops), 1fbgc
1808 readonly=self._readonly, 1fbgc
1809 owner=self, 1fbgc
1810 )
1812 @read_ops.setter
1813 def read_ops(self, val):
1814 if self._readonly:
1815 raise ValueError("This StatsLevel1 instance is read-only")
1816 cdef OpCounter val_ = val
1817 _cyb_memcpy(<void *>&(self._ptr[0].read_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1819 @property
1820 def write_ops(self):
1821 """OpCounter: """
1822 return OpCounter.from_ptr( 1fbgc
1823 <intptr_t>&(self._ptr[0].write_ops), 1fbgc
1824 readonly=self._readonly, 1fbgc
1825 owner=self, 1fbgc
1826 )
1828 @write_ops.setter
1829 def write_ops(self, val):
1830 if self._readonly:
1831 raise ValueError("This StatsLevel1 instance is read-only")
1832 cdef OpCounter val_ = val
1833 _cyb_memcpy(<void *>&(self._ptr[0].write_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1835 @property
1836 def hdl_register_ops(self):
1837 """OpCounter: """
1838 return OpCounter.from_ptr(
1839 <intptr_t>&(self._ptr[0].hdl_register_ops),
1840 readonly=self._readonly,
1841 owner=self,
1842 )
1844 @hdl_register_ops.setter
1845 def hdl_register_ops(self, val):
1846 if self._readonly:
1847 raise ValueError("This StatsLevel1 instance is read-only")
1848 cdef OpCounter val_ = val
1849 _cyb_memcpy(<void *>&(self._ptr[0].hdl_register_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1851 @property
1852 def hdl_deregister_ops(self):
1853 """OpCounter: """
1854 return OpCounter.from_ptr(
1855 <intptr_t>&(self._ptr[0].hdl_deregister_ops),
1856 readonly=self._readonly,
1857 owner=self,
1858 )
1860 @hdl_deregister_ops.setter
1861 def hdl_deregister_ops(self, val):
1862 if self._readonly:
1863 raise ValueError("This StatsLevel1 instance is read-only")
1864 cdef OpCounter val_ = val
1865 _cyb_memcpy(<void *>&(self._ptr[0].hdl_deregister_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1867 @property
1868 def buf_register_ops(self):
1869 """OpCounter: """
1870 return OpCounter.from_ptr(
1871 <intptr_t>&(self._ptr[0].buf_register_ops),
1872 readonly=self._readonly,
1873 owner=self,
1874 )
1876 @buf_register_ops.setter
1877 def buf_register_ops(self, val):
1878 if self._readonly:
1879 raise ValueError("This StatsLevel1 instance is read-only")
1880 cdef OpCounter val_ = val
1881 _cyb_memcpy(<void *>&(self._ptr[0].buf_register_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1883 @property
1884 def buf_deregister_ops(self):
1885 """OpCounter: """
1886 return OpCounter.from_ptr(
1887 <intptr_t>&(self._ptr[0].buf_deregister_ops),
1888 readonly=self._readonly,
1889 owner=self,
1890 )
1892 @buf_deregister_ops.setter
1893 def buf_deregister_ops(self, val):
1894 if self._readonly:
1895 raise ValueError("This StatsLevel1 instance is read-only")
1896 cdef OpCounter val_ = val
1897 _cyb_memcpy(<void *>&(self._ptr[0].buf_deregister_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1899 @property
1900 def batch_submit_ops(self):
1901 """OpCounter: """
1902 return OpCounter.from_ptr(
1903 <intptr_t>&(self._ptr[0].batch_submit_ops),
1904 readonly=self._readonly,
1905 owner=self,
1906 )
1908 @batch_submit_ops.setter
1909 def batch_submit_ops(self, val):
1910 if self._readonly:
1911 raise ValueError("This StatsLevel1 instance is read-only")
1912 cdef OpCounter val_ = val
1913 _cyb_memcpy(<void *>&(self._ptr[0].batch_submit_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1915 @property
1916 def batch_complete_ops(self):
1917 """OpCounter: """
1918 return OpCounter.from_ptr(
1919 <intptr_t>&(self._ptr[0].batch_complete_ops),
1920 readonly=self._readonly,
1921 owner=self,
1922 )
1924 @batch_complete_ops.setter
1925 def batch_complete_ops(self, val):
1926 if self._readonly:
1927 raise ValueError("This StatsLevel1 instance is read-only")
1928 cdef OpCounter val_ = val
1929 _cyb_memcpy(<void *>&(self._ptr[0].batch_complete_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1931 @property
1932 def batch_setup_ops(self):
1933 """OpCounter: """
1934 return OpCounter.from_ptr(
1935 <intptr_t>&(self._ptr[0].batch_setup_ops),
1936 readonly=self._readonly,
1937 owner=self,
1938 )
1940 @batch_setup_ops.setter
1941 def batch_setup_ops(self, val):
1942 if self._readonly:
1943 raise ValueError("This StatsLevel1 instance is read-only")
1944 cdef OpCounter val_ = val
1945 _cyb_memcpy(<void *>&(self._ptr[0].batch_setup_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1947 @property
1948 def batch_cancel_ops(self):
1949 """OpCounter: """
1950 return OpCounter.from_ptr(
1951 <intptr_t>&(self._ptr[0].batch_cancel_ops),
1952 readonly=self._readonly,
1953 owner=self,
1954 )
1956 @batch_cancel_ops.setter
1957 def batch_cancel_ops(self, val):
1958 if self._readonly:
1959 raise ValueError("This StatsLevel1 instance is read-only")
1960 cdef OpCounter val_ = val
1961 _cyb_memcpy(<void *>&(self._ptr[0].batch_cancel_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1963 @property
1964 def batch_destroy_ops(self):
1965 """OpCounter: """
1966 return OpCounter.from_ptr(
1967 <intptr_t>&(self._ptr[0].batch_destroy_ops),
1968 readonly=self._readonly,
1969 owner=self,
1970 )
1972 @batch_destroy_ops.setter
1973 def batch_destroy_ops(self, val):
1974 if self._readonly:
1975 raise ValueError("This StatsLevel1 instance is read-only")
1976 cdef OpCounter val_ = val
1977 _cyb_memcpy(<void *>&(self._ptr[0].batch_destroy_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1979 @property
1980 def batch_enqueued_ops(self):
1981 """OpCounter: """
1982 return OpCounter.from_ptr(
1983 <intptr_t>&(self._ptr[0].batch_enqueued_ops),
1984 readonly=self._readonly,
1985 owner=self,
1986 )
1988 @batch_enqueued_ops.setter
1989 def batch_enqueued_ops(self, val):
1990 if self._readonly:
1991 raise ValueError("This StatsLevel1 instance is read-only")
1992 cdef OpCounter val_ = val
1993 _cyb_memcpy(<void *>&(self._ptr[0].batch_enqueued_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1995 @property
1996 def batch_posix_enqueued_ops(self):
1997 """OpCounter: """
1998 return OpCounter.from_ptr(
1999 <intptr_t>&(self._ptr[0].batch_posix_enqueued_ops),
2000 readonly=self._readonly,
2001 owner=self,
2002 )
2004 @batch_posix_enqueued_ops.setter
2005 def batch_posix_enqueued_ops(self, val):
2006 if self._readonly:
2007 raise ValueError("This StatsLevel1 instance is read-only")
2008 cdef OpCounter val_ = val
2009 _cyb_memcpy(<void *>&(self._ptr[0].batch_posix_enqueued_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
2011 @property
2012 def batch_processed_ops(self):
2013 """OpCounter: """
2014 return OpCounter.from_ptr(
2015 <intptr_t>&(self._ptr[0].batch_processed_ops),
2016 readonly=self._readonly,
2017 owner=self,
2018 )
2020 @batch_processed_ops.setter
2021 def batch_processed_ops(self, val):
2022 if self._readonly:
2023 raise ValueError("This StatsLevel1 instance is read-only")
2024 cdef OpCounter val_ = val
2025 _cyb_memcpy(<void *>&(self._ptr[0].batch_processed_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
2027 @property
2028 def batch_posix_processed_ops(self):
2029 """OpCounter: """
2030 return OpCounter.from_ptr(
2031 <intptr_t>&(self._ptr[0].batch_posix_processed_ops),
2032 readonly=self._readonly,
2033 owner=self,
2034 )
2036 @batch_posix_processed_ops.setter
2037 def batch_posix_processed_ops(self, val):
2038 if self._readonly:
2039 raise ValueError("This StatsLevel1 instance is read-only")
2040 cdef OpCounter val_ = val
2041 _cyb_memcpy(<void *>&(self._ptr[0].batch_posix_processed_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
2043 @property
2044 def batch_nvfs_submit_ops(self):
2045 """OpCounter: """
2046 return OpCounter.from_ptr(
2047 <intptr_t>&(self._ptr[0].batch_nvfs_submit_ops),
2048 readonly=self._readonly,
2049 owner=self,
2050 )
2052 @batch_nvfs_submit_ops.setter
2053 def batch_nvfs_submit_ops(self, val):
2054 if self._readonly:
2055 raise ValueError("This StatsLevel1 instance is read-only")
2056 cdef OpCounter val_ = val
2057 _cyb_memcpy(<void *>&(self._ptr[0].batch_nvfs_submit_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
2059 @property
2060 def batch_p2p_submit_ops(self):
2061 """OpCounter: """
2062 return OpCounter.from_ptr(
2063 <intptr_t>&(self._ptr[0].batch_p2p_submit_ops),
2064 readonly=self._readonly,
2065 owner=self,
2066 )
2068 @batch_p2p_submit_ops.setter
2069 def batch_p2p_submit_ops(self, val):
2070 if self._readonly:
2071 raise ValueError("This StatsLevel1 instance is read-only")
2072 cdef OpCounter val_ = val
2073 _cyb_memcpy(<void *>&(self._ptr[0].batch_p2p_submit_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
2075 @property
2076 def batch_aio_submit_ops(self):
2077 """OpCounter: """
2078 return OpCounter.from_ptr(
2079 <intptr_t>&(self._ptr[0].batch_aio_submit_ops),
2080 readonly=self._readonly,
2081 owner=self,
2082 )
2084 @batch_aio_submit_ops.setter
2085 def batch_aio_submit_ops(self, val):
2086 if self._readonly:
2087 raise ValueError("This StatsLevel1 instance is read-only")
2088 cdef OpCounter val_ = val
2089 _cyb_memcpy(<void *>&(self._ptr[0].batch_aio_submit_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
2091 @property
2092 def batch_iouring_submit_ops(self):
2093 """OpCounter: """
2094 return OpCounter.from_ptr(
2095 <intptr_t>&(self._ptr[0].batch_iouring_submit_ops),
2096 readonly=self._readonly,
2097 owner=self,
2098 )
2100 @batch_iouring_submit_ops.setter
2101 def batch_iouring_submit_ops(self, val):
2102 if self._readonly:
2103 raise ValueError("This StatsLevel1 instance is read-only")
2104 cdef OpCounter val_ = val
2105 _cyb_memcpy(<void *>&(self._ptr[0].batch_iouring_submit_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
2107 @property
2108 def batch_mixed_io_submit_ops(self):
2109 """OpCounter: """
2110 return OpCounter.from_ptr(
2111 <intptr_t>&(self._ptr[0].batch_mixed_io_submit_ops),
2112 readonly=self._readonly,
2113 owner=self,
2114 )
2116 @batch_mixed_io_submit_ops.setter
2117 def batch_mixed_io_submit_ops(self, val):
2118 if self._readonly:
2119 raise ValueError("This StatsLevel1 instance is read-only")
2120 cdef OpCounter val_ = val
2121 _cyb_memcpy(<void *>&(self._ptr[0].batch_mixed_io_submit_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
2123 @property
2124 def batch_total_submit_ops(self):
2125 """OpCounter: """
2126 return OpCounter.from_ptr(
2127 <intptr_t>&(self._ptr[0].batch_total_submit_ops),
2128 readonly=self._readonly,
2129 owner=self,
2130 )
2132 @batch_total_submit_ops.setter
2133 def batch_total_submit_ops(self, val):
2134 if self._readonly:
2135 raise ValueError("This StatsLevel1 instance is read-only")
2136 cdef OpCounter val_ = val
2137 _cyb_memcpy(<void *>&(self._ptr[0].batch_total_submit_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
2139 @property
2140 def readv_ops(self):
2141 """OpCounter: """
2142 return OpCounter.from_ptr(
2143 <intptr_t>&(self._ptr[0].readv_ops),
2144 readonly=self._readonly,
2145 owner=self,
2146 )
2148 @readv_ops.setter
2149 def readv_ops(self, val):
2150 if self._readonly:
2151 raise ValueError("This StatsLevel1 instance is read-only")
2152 cdef OpCounter val_ = val
2153 _cyb_memcpy(<void *>&(self._ptr[0].readv_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
2155 @property
2156 def writev_ops(self):
2157 """OpCounter: """
2158 return OpCounter.from_ptr(
2159 <intptr_t>&(self._ptr[0].writev_ops),
2160 readonly=self._readonly,
2161 owner=self,
2162 )
2164 @writev_ops.setter
2165 def writev_ops(self, val):
2166 if self._readonly:
2167 raise ValueError("This StatsLevel1 instance is read-only")
2168 cdef OpCounter val_ = val
2169 _cyb_memcpy(<void *>&(self._ptr[0].writev_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
2171 @property
2172 def read_bytes(self):
2173 """int: """
2174 return self._ptr[0].read_bytes 1fg
2176 @read_bytes.setter
2177 def read_bytes(self, val):
2178 if self._readonly:
2179 raise ValueError("This StatsLevel1 instance is read-only")
2180 self._ptr[0].read_bytes = val
2182 @property
2183 def write_bytes(self):
2184 """int: """
2185 return self._ptr[0].write_bytes 1fg
2187 @write_bytes.setter
2188 def write_bytes(self, val):
2189 if self._readonly:
2190 raise ValueError("This StatsLevel1 instance is read-only")
2191 self._ptr[0].write_bytes = val
2193 @property
2194 def read_bw_bytes_per_sec(self):
2195 """int: """
2196 return self._ptr[0].read_bw_bytes_per_sec
2198 @read_bw_bytes_per_sec.setter
2199 def read_bw_bytes_per_sec(self, val):
2200 if self._readonly:
2201 raise ValueError("This StatsLevel1 instance is read-only")
2202 self._ptr[0].read_bw_bytes_per_sec = val
2204 @property
2205 def write_bw_bytes_per_sec(self):
2206 """int: """
2207 return self._ptr[0].write_bw_bytes_per_sec
2209 @write_bw_bytes_per_sec.setter
2210 def write_bw_bytes_per_sec(self, val):
2211 if self._readonly:
2212 raise ValueError("This StatsLevel1 instance is read-only")
2213 self._ptr[0].write_bw_bytes_per_sec = val
2215 @property
2216 def read_lat_avg_us(self):
2217 """int: """
2218 return self._ptr[0].read_lat_avg_us
2220 @read_lat_avg_us.setter
2221 def read_lat_avg_us(self, val):
2222 if self._readonly:
2223 raise ValueError("This StatsLevel1 instance is read-only")
2224 self._ptr[0].read_lat_avg_us = val
2226 @property
2227 def write_lat_avg_us(self):
2228 """int: """
2229 return self._ptr[0].write_lat_avg_us
2231 @write_lat_avg_us.setter
2232 def write_lat_avg_us(self, val):
2233 if self._readonly:
2234 raise ValueError("This StatsLevel1 instance is read-only")
2235 self._ptr[0].write_lat_avg_us = val
2237 @property
2238 def read_ops_per_sec(self):
2239 """int: """
2240 return self._ptr[0].read_ops_per_sec
2242 @read_ops_per_sec.setter
2243 def read_ops_per_sec(self, val):
2244 if self._readonly:
2245 raise ValueError("This StatsLevel1 instance is read-only")
2246 self._ptr[0].read_ops_per_sec = val
2248 @property
2249 def write_ops_per_sec(self):
2250 """int: """
2251 return self._ptr[0].write_ops_per_sec
2253 @write_ops_per_sec.setter
2254 def write_ops_per_sec(self, val):
2255 if self._readonly:
2256 raise ValueError("This StatsLevel1 instance is read-only")
2257 self._ptr[0].write_ops_per_sec = val
2259 @property
2260 def read_lat_sum_us(self):
2261 """int: """
2262 return self._ptr[0].read_lat_sum_us
2264 @read_lat_sum_us.setter
2265 def read_lat_sum_us(self, val):
2266 if self._readonly:
2267 raise ValueError("This StatsLevel1 instance is read-only")
2268 self._ptr[0].read_lat_sum_us = val
2270 @property
2271 def write_lat_sum_us(self):
2272 """int: """
2273 return self._ptr[0].write_lat_sum_us
2275 @write_lat_sum_us.setter
2276 def write_lat_sum_us(self, val):
2277 if self._readonly:
2278 raise ValueError("This StatsLevel1 instance is read-only")
2279 self._ptr[0].write_lat_sum_us = val
2281 @property
2282 def batch_read_bytes(self):
2283 """int: """
2284 return self._ptr[0].batch_read_bytes
2286 @batch_read_bytes.setter
2287 def batch_read_bytes(self, val):
2288 if self._readonly:
2289 raise ValueError("This StatsLevel1 instance is read-only")
2290 self._ptr[0].batch_read_bytes = val
2292 @property
2293 def batch_write_bytes(self):
2294 """int: """
2295 return self._ptr[0].batch_write_bytes
2297 @batch_write_bytes.setter
2298 def batch_write_bytes(self, val):
2299 if self._readonly:
2300 raise ValueError("This StatsLevel1 instance is read-only")
2301 self._ptr[0].batch_write_bytes = val
2303 @property
2304 def batch_read_bw_bytes(self):
2305 """int: """
2306 return self._ptr[0].batch_read_bw_bytes
2308 @batch_read_bw_bytes.setter
2309 def batch_read_bw_bytes(self, val):
2310 if self._readonly:
2311 raise ValueError("This StatsLevel1 instance is read-only")
2312 self._ptr[0].batch_read_bw_bytes = val
2314 @property
2315 def batch_write_bw_bytes(self):
2316 """int: """
2317 return self._ptr[0].batch_write_bw_bytes
2319 @batch_write_bw_bytes.setter
2320 def batch_write_bw_bytes(self, val):
2321 if self._readonly:
2322 raise ValueError("This StatsLevel1 instance is read-only")
2323 self._ptr[0].batch_write_bw_bytes = val
2325 @property
2326 def batch_submit_lat_avg_us(self):
2327 """int: """
2328 return self._ptr[0].batch_submit_lat_avg_us
2330 @batch_submit_lat_avg_us.setter
2331 def batch_submit_lat_avg_us(self, val):
2332 if self._readonly:
2333 raise ValueError("This StatsLevel1 instance is read-only")
2334 self._ptr[0].batch_submit_lat_avg_us = val
2336 @property
2337 def batch_completion_lat_avg_us(self):
2338 """int: """
2339 return self._ptr[0].batch_completion_lat_avg_us
2341 @batch_completion_lat_avg_us.setter
2342 def batch_completion_lat_avg_us(self, val):
2343 if self._readonly:
2344 raise ValueError("This StatsLevel1 instance is read-only")
2345 self._ptr[0].batch_completion_lat_avg_us = val
2347 @property
2348 def batch_submit_ops_per_sec(self):
2349 """int: """
2350 return self._ptr[0].batch_submit_ops_per_sec
2352 @batch_submit_ops_per_sec.setter
2353 def batch_submit_ops_per_sec(self, val):
2354 if self._readonly:
2355 raise ValueError("This StatsLevel1 instance is read-only")
2356 self._ptr[0].batch_submit_ops_per_sec = val
2358 @property
2359 def batch_complete_ops_per_sec(self):
2360 """int: """
2361 return self._ptr[0].batch_complete_ops_per_sec
2363 @batch_complete_ops_per_sec.setter
2364 def batch_complete_ops_per_sec(self, val):
2365 if self._readonly:
2366 raise ValueError("This StatsLevel1 instance is read-only")
2367 self._ptr[0].batch_complete_ops_per_sec = val
2369 @property
2370 def batch_submit_lat_sum_us(self):
2371 """int: """
2372 return self._ptr[0].batch_submit_lat_sum_us
2374 @batch_submit_lat_sum_us.setter
2375 def batch_submit_lat_sum_us(self, val):
2376 if self._readonly:
2377 raise ValueError("This StatsLevel1 instance is read-only")
2378 self._ptr[0].batch_submit_lat_sum_us = val
2380 @property
2381 def batch_completion_lat_sum_us(self):
2382 """int: """
2383 return self._ptr[0].batch_completion_lat_sum_us
2385 @batch_completion_lat_sum_us.setter
2386 def batch_completion_lat_sum_us(self, val):
2387 if self._readonly:
2388 raise ValueError("This StatsLevel1 instance is read-only")
2389 self._ptr[0].batch_completion_lat_sum_us = val
2391 @property
2392 def last_batch_read_bytes(self):
2393 """int: """
2394 return self._ptr[0].last_batch_read_bytes
2396 @last_batch_read_bytes.setter
2397 def last_batch_read_bytes(self, val):
2398 if self._readonly:
2399 raise ValueError("This StatsLevel1 instance is read-only")
2400 self._ptr[0].last_batch_read_bytes = val
2402 @property
2403 def last_batch_write_bytes(self):
2404 """int: """
2405 return self._ptr[0].last_batch_write_bytes
2407 @last_batch_write_bytes.setter
2408 def last_batch_write_bytes(self, val):
2409 if self._readonly:
2410 raise ValueError("This StatsLevel1 instance is read-only")
2411 self._ptr[0].last_batch_write_bytes = val
2413 @property
2414 def readv_bytes(self):
2415 """int: """
2416 return self._ptr[0].readv_bytes
2418 @readv_bytes.setter
2419 def readv_bytes(self, val):
2420 if self._readonly:
2421 raise ValueError("This StatsLevel1 instance is read-only")
2422 self._ptr[0].readv_bytes = val
2424 @property
2425 def writev_bytes(self):
2426 """int: """
2427 return self._ptr[0].writev_bytes
2429 @writev_bytes.setter
2430 def writev_bytes(self, val):
2431 if self._readonly:
2432 raise ValueError("This StatsLevel1 instance is read-only")
2433 self._ptr[0].writev_bytes = val
2435 @property
2436 def readv_bw_bytes_per_sec(self):
2437 """int: """
2438 return self._ptr[0].readv_bw_bytes_per_sec
2440 @readv_bw_bytes_per_sec.setter
2441 def readv_bw_bytes_per_sec(self, val):
2442 if self._readonly:
2443 raise ValueError("This StatsLevel1 instance is read-only")
2444 self._ptr[0].readv_bw_bytes_per_sec = val
2446 @property
2447 def writev_bw_bytes_per_sec(self):
2448 """int: """
2449 return self._ptr[0].writev_bw_bytes_per_sec
2451 @writev_bw_bytes_per_sec.setter
2452 def writev_bw_bytes_per_sec(self, val):
2453 if self._readonly:
2454 raise ValueError("This StatsLevel1 instance is read-only")
2455 self._ptr[0].writev_bw_bytes_per_sec = val
2457 @property
2458 def readv_lat_avg_us(self):
2459 """int: """
2460 return self._ptr[0].readv_lat_avg_us
2462 @readv_lat_avg_us.setter
2463 def readv_lat_avg_us(self, val):
2464 if self._readonly:
2465 raise ValueError("This StatsLevel1 instance is read-only")
2466 self._ptr[0].readv_lat_avg_us = val
2468 @property
2469 def writev_lat_avg_us(self):
2470 """int: """
2471 return self._ptr[0].writev_lat_avg_us
2473 @writev_lat_avg_us.setter
2474 def writev_lat_avg_us(self, val):
2475 if self._readonly:
2476 raise ValueError("This StatsLevel1 instance is read-only")
2477 self._ptr[0].writev_lat_avg_us = val
2479 @property
2480 def readv_ops_per_sec(self):
2481 """int: """
2482 return self._ptr[0].readv_ops_per_sec
2484 @readv_ops_per_sec.setter
2485 def readv_ops_per_sec(self, val):
2486 if self._readonly:
2487 raise ValueError("This StatsLevel1 instance is read-only")
2488 self._ptr[0].readv_ops_per_sec = val
2490 @property
2491 def writev_ops_per_sec(self):
2492 """int: """
2493 return self._ptr[0].writev_ops_per_sec
2495 @writev_ops_per_sec.setter
2496 def writev_ops_per_sec(self, val):
2497 if self._readonly:
2498 raise ValueError("This StatsLevel1 instance is read-only")
2499 self._ptr[0].writev_ops_per_sec = val
2501 @property
2502 def readv_lat_sum_us(self):
2503 """int: """
2504 return self._ptr[0].readv_lat_sum_us
2506 @readv_lat_sum_us.setter
2507 def readv_lat_sum_us(self, val):
2508 if self._readonly:
2509 raise ValueError("This StatsLevel1 instance is read-only")
2510 self._ptr[0].readv_lat_sum_us = val
2512 @property
2513 def writev_lat_sum_us(self):
2514 """int: """
2515 return self._ptr[0].writev_lat_sum_us
2517 @writev_lat_sum_us.setter
2518 def writev_lat_sum_us(self, val):
2519 if self._readonly:
2520 raise ValueError("This StatsLevel1 instance is read-only")
2521 self._ptr[0].writev_lat_sum_us = val
2523 @staticmethod
2524 def from_buffer(buffer):
2525 """Create an StatsLevel1 instance with the memory from the given buffer."""
2526 return _cyb_from_buffer(buffer, sizeof(CUfileStatsLevel1_t), StatsLevel1)
2528 @staticmethod
2529 def from_data(data):
2530 """Create an StatsLevel1 instance wrapping the given NumPy array.
2532 Args:
2533 data (_numpy.ndarray): a single-element array of dtype `stats_level1_dtype` holding the data.
2534 """
2535 return _cyb_from_data(data, "stats_level1_dtype", stats_level1_dtype, StatsLevel1) 1bc
2537 @staticmethod
2538 def from_ptr(intptr_t ptr, bint readonly=False, object owner=None):
2539 """Create an StatsLevel1 instance wrapping the given pointer.
2541 Args:
2542 ptr (intptr_t): pointer address as Python :class:`int` to the data.
2543 owner (object): The Python object that owns the pointer. If not provided, data will be copied.
2544 readonly (bool): whether the data is read-only (to the user). default is `False`.
2545 """
2546 if ptr == 0: 1bc
2547 raise ValueError("ptr must not be null (0)")
2548 cdef StatsLevel1 obj = StatsLevel1.__new__(StatsLevel1) 1bc
2549 if owner is None: 1bc
2550 obj._ptr = <CUfileStatsLevel1_t *>_cyb_malloc(sizeof(CUfileStatsLevel1_t))
2551 if obj._ptr == NULL:
2552 raise MemoryError("Error allocating StatsLevel1")
2553 _cyb_memcpy(<void*>(obj._ptr), <void*>ptr, sizeof(CUfileStatsLevel1_t))
2554 obj._owns_ptr = True
2555 obj._owner = None
2556 else:
2557 obj._ptr = <CUfileStatsLevel1_t *>ptr 1bc
2558 obj._owns_ptr = False 1bc
2559 obj._owner = owner 1bc
2560 obj._readonly = readonly 1bc
2561 return obj 1bc
2564cdef _get_descr_dtype_offsets():
2565 cdef CUfileDescr_t *pod = <CUfileDescr_t *>_cyb_calloc(1, sizeof(CUfileDescr_t))
2566 if pod == NULL:
2567 raise MemoryError("Error allocating CUfileDescr_t")
2568 try:
2569 return _numpy.dtype({
2570 'names': ['type', 'handle', 'fs_ops'],
2571 'formats': [_numpy.int32, _py_anon_pod1_dtype, _numpy.intp],
2572 'offsets': [
2573 (<intptr_t>&(pod.type)) - (<intptr_t>pod),
2574 (<intptr_t>&(pod.handle)) - (<intptr_t>pod),
2575 (<intptr_t>&(pod.fs_ops)) - (<intptr_t>pod),
2576 ],
2577 'itemsize': sizeof(CUfileDescr_t),
2578 })
2579 finally:
2580 _cyb_free(pod)
2582descr_dtype = _get_descr_dtype_offsets()
2583cdef object descr_dtype_record = _numpy.dtype((_numpy.record, descr_dtype))
2585cdef class Descr:
2586 """Empty-initialize an array of `CUfileDescr_t`.
2587 The resulting object is of length `size` and of dtype `descr_dtype`.
2588 If default-constructed, the instance represents a single struct.
2590 Args:
2591 size (int): number of structs, default=1.
2593 .. seealso:: `CUfileDescr_t`
2594 """
2595 cdef:
2596 readonly object _data
2597 object _owner
2599 def __init__(self, size=1):
2600 self._data = _numpy.zeros(size, dtype=descr_dtype_record) 1hljnpqrstfbdBimkouvwxygceC
2601 assert self._data.itemsize == sizeof(CUfileDescr_t), \ 1hljnpqrstfbdBimkouvwxygceC
2602 f"itemsize {self._data.itemsize} mismatches struct size { sizeof(CUfileDescr_t) }"
2604 def __repr__(self):
2605 if self._data.size > 1:
2606 return f"<{__name__}.Descr_Array_{self._data.size} object at {hex(id(self))}>"
2607 else:
2608 return f"<{__name__}.Descr object at {hex(id(self))}>"
2610 @property
2611 def ptr(self):
2612 """Get the pointer address to the data as Python :class:`int`."""
2613 return _cyb_array_ptr(self._data) 1hljnpqrstfbdBimkouvwxygceC
2615 cdef intptr_t _get_ptr(self):
2616 return _cyb_array_ptr(self._data)
2618 def __int__(self):
2619 if self._data.size > 1 and not self._data.flags["C_CONTIGUOUS"]:
2620 raise TypeError("int() argument must be a bytes-like object of size 1, or a "
2621 "C-contiguous array. To get the pointer address of a "
2622 "non-contiguous array, use .ptr")
2623 return _cyb_array_ptr(self._data)
2625 def __len__(self):
2626 return self._data.size
2628 def __eq__(self, other):
2629 cdef object self_data = self._data
2630 if (not isinstance(other, Descr)) or self_data.size != other._data.size or self_data.dtype != other._data.dtype:
2631 return False
2632 return bool((self_data == other._data).all())
2634 def __getbuffer__(self, Py_buffer *buffer, int flags):
2635 _cyb_cpython.PyObject_GetBuffer(self._data, buffer, flags)
2637 def __releasebuffer__(self, Py_buffer *buffer):
2638 _cyb_cpython.PyBuffer_Release(buffer)
2640 @property
2641 def type(self):
2642 """Union[~_numpy.int32, int]: """
2643 if self._data.size == 1:
2644 return int(self._data["type"][0])
2645 return self._data["type"]
2647 @type.setter
2648 def type(self, val):
2649 if not self._data.flags.writeable: 1hljnpqrstfbdBimkouvwxygceC
2650 raise ValueError("This Descr instance is read-only")
2651 self._data["type"] = val 1hljnpqrstfbdBimkouvwxygceC
2653 @property
2654 def handle(self):
2655 """_py_anon_pod1_dtype: """
2656 return self._data["handle"].view(_numpy.recarray) 1hljnpqrstfbdBimkouvwxygceC
2658 @handle.setter
2659 def handle(self, val):
2660 if not self._data.flags.writeable:
2661 raise ValueError("This Descr instance is read-only")
2662 self._data["handle"] = val
2664 @property
2665 def fs_ops(self):
2666 """Union[~_numpy.intp, int]: """
2667 if self._data.size == 1:
2668 return int(self._data["fs_ops"][0])
2669 return self._data["fs_ops"]
2671 @fs_ops.setter
2672 def fs_ops(self, val):
2673 if not self._data.flags.writeable: 1hljnpqrstfbdBimkouvwxygceC
2674 raise ValueError("This Descr instance is read-only")
2675 self._data["fs_ops"] = val 1hljnpqrstfbdBimkouvwxygceC
2677 def __getitem__(self, key):
2678 cdef ssize_t key_
2679 cdef ssize_t size
2680 cdef Descr obj
2681 if isinstance(key, int):
2682 key_ = key
2683 size = self._data.size
2684 if key_ >= size or key_ <= -(size+1):
2685 raise IndexError("index is out of bounds")
2686 if key_ < 0:
2687 key_ += size
2688 obj = Descr.__new__(Descr)
2689 obj._data = self._data[key_:key_+1]
2690 obj._owner = self._owner
2691 return obj
2692 out = self._data[key]
2693 if isinstance(out, _numpy.ndarray):
2694 if out.dtype == descr_dtype:
2695 obj = Descr.from_data(out)
2696 obj._owner = self._owner
2697 return obj
2698 if out.dtype.names is not None:
2699 return out.view(_numpy.recarray)
2700 return out
2702 def __setitem__(self, key, val):
2703 self._data[key] = val
2705 @staticmethod
2706 def from_buffer(buffer):
2707 """Create an Descr instance with the memory from the given buffer."""
2708 return Descr.from_data(_numpy.frombuffer(buffer, dtype=descr_dtype))
2710 @staticmethod
2711 def from_data(data):
2712 """Create an Descr instance wrapping the given NumPy array.
2714 Args:
2715 data (_numpy.ndarray): a 1D array of dtype `descr_dtype` holding the data.
2716 """
2717 cdef Descr obj = Descr.__new__(Descr)
2718 if not isinstance(data, _numpy.ndarray):
2719 raise TypeError("data argument must be a NumPy ndarray")
2720 if data.ndim != 1:
2721 raise ValueError("data array must be 1D")
2722 if data.dtype != descr_dtype:
2723 raise ValueError("data array must be of dtype descr_dtype")
2724 obj._data = data.view(dtype=descr_dtype_record, type=_numpy.ndarray)
2725 return obj
2727 @staticmethod
2728 def from_ptr(intptr_t ptr, size_t size=1, bint readonly=False, object owner=None):
2729 """Create an Descr instance wrapping the given pointer.
2731 Args:
2732 ptr (intptr_t): pointer address as Python :class:`int` to the data.
2733 size (int): number of structs, default=1.
2734 readonly (bool): whether the data is read-only (to the user). default is `False`.
2735 owner (object): object that owns the memory at *ptr*. A strong reference is
2736 kept so the backing storage outlives this wrapper.
2737 """
2738 if ptr == 0:
2739 raise ValueError("ptr must not be null (0)")
2740 cdef Descr obj = Descr.__new__(Descr)
2741 cdef flag = _cyb_cpython_buffer.PyBUF_READ if readonly else _cyb_cpython_buffer.PyBUF_WRITE
2742 cdef object buf = _cyb_cpython_memoryview.PyMemoryView_FromMemory(
2743 <char*>ptr, sizeof(CUfileDescr_t) * size, flag)
2744 obj._data = _numpy.ndarray(size, buffer=buf, dtype=descr_dtype_record)
2745 obj._owner = owner
2746 return obj
2749cdef _get_io_params_dtype_offsets():
2750 cdef CUfileIOParams_t *pod = <CUfileIOParams_t *>_cyb_calloc(1, sizeof(CUfileIOParams_t))
2751 if pod == NULL:
2752 raise MemoryError("Error allocating CUfileIOParams_t")
2753 try:
2754 return _numpy.dtype({
2755 'names': ['mode', 'u', 'fh', 'opcode', 'cookie'],
2756 'formats': [_numpy.int32, _py_anon_pod2_dtype, _numpy.intp, _numpy.int32, _numpy.intp],
2757 'offsets': [
2758 (<intptr_t>&(pod.mode)) - (<intptr_t>pod),
2759 (<intptr_t>&(pod.u)) - (<intptr_t>pod),
2760 (<intptr_t>&(pod.fh)) - (<intptr_t>pod),
2761 (<intptr_t>&(pod.opcode)) - (<intptr_t>pod),
2762 (<intptr_t>&(pod.cookie)) - (<intptr_t>pod),
2763 ],
2764 'itemsize': sizeof(CUfileIOParams_t),
2765 })
2766 finally:
2767 _cyb_free(pod)
2769io_params_dtype = _get_io_params_dtype_offsets()
2770cdef object io_params_dtype_record = _numpy.dtype((_numpy.record, io_params_dtype))
2772cdef class IOParams:
2773 """Empty-initialize an array of `CUfileIOParams_t`.
2774 The resulting object is of length `size` and of dtype `io_params_dtype`.
2775 If default-constructed, the instance represents a single struct.
2777 Args:
2778 size (int): number of structs, default=1.
2780 .. seealso:: `CUfileIOParams_t`
2781 """
2782 cdef:
2783 readonly object _data
2784 object _owner
2786 def __init__(self, size=1):
2787 self._data = _numpy.zeros(size, dtype=io_params_dtype_record) 1hljimk
2788 assert self._data.itemsize == sizeof(CUfileIOParams_t), \ 1hljimk
2789 f"itemsize {self._data.itemsize} mismatches struct size { sizeof(CUfileIOParams_t) }"
2791 def __repr__(self):
2792 if self._data.size > 1:
2793 return f"<{__name__}.IOParams_Array_{self._data.size} object at {hex(id(self))}>"
2794 else:
2795 return f"<{__name__}.IOParams object at {hex(id(self))}>"
2797 @property
2798 def ptr(self):
2799 """Get the pointer address to the data as Python :class:`int`."""
2800 return _cyb_array_ptr(self._data) 1hljimk
2802 cdef intptr_t _get_ptr(self):
2803 return _cyb_array_ptr(self._data)
2805 def __int__(self):
2806 if self._data.size > 1 and not self._data.flags["C_CONTIGUOUS"]:
2807 raise TypeError("int() argument must be a bytes-like object of size 1, or a "
2808 "C-contiguous array. To get the pointer address of a "
2809 "non-contiguous array, use .ptr")
2810 return _cyb_array_ptr(self._data)
2812 def __len__(self):
2813 return self._data.size
2815 def __eq__(self, other):
2816 cdef object self_data = self._data
2817 if (not isinstance(other, IOParams)) or self_data.size != other._data.size or self_data.dtype != other._data.dtype:
2818 return False
2819 return bool((self_data == other._data).all())
2821 def __getbuffer__(self, Py_buffer *buffer, int flags):
2822 _cyb_cpython.PyObject_GetBuffer(self._data, buffer, flags)
2824 def __releasebuffer__(self, Py_buffer *buffer):
2825 _cyb_cpython.PyBuffer_Release(buffer)
2827 @property
2828 def mode(self):
2829 """Union[~_numpy.int32, int]: """
2830 if self._data.size == 1:
2831 return int(self._data["mode"][0])
2832 return self._data["mode"]
2834 @mode.setter
2835 def mode(self, val):
2836 if not self._data.flags.writeable: 1hljimk
2837 raise ValueError("This IOParams instance is read-only")
2838 self._data["mode"] = val 1hljimk
2840 @property
2841 def u(self):
2842 """_py_anon_pod2_dtype: """
2843 return self._data["u"].view(_numpy.recarray) 1hljimk
2845 @u.setter
2846 def u(self, val):
2847 if not self._data.flags.writeable:
2848 raise ValueError("This IOParams instance is read-only")
2849 self._data["u"] = val
2851 @property
2852 def fh(self):
2853 """Union[~_numpy.intp, int]: """
2854 if self._data.size == 1:
2855 return int(self._data["fh"][0])
2856 return self._data["fh"]
2858 @fh.setter
2859 def fh(self, val):
2860 if not self._data.flags.writeable: 1hljimk
2861 raise ValueError("This IOParams instance is read-only")
2862 self._data["fh"] = val 1hljimk
2864 @property
2865 def opcode(self):
2866 """Union[~_numpy.int32, int]: """
2867 if self._data.size == 1:
2868 return int(self._data["opcode"][0])
2869 return self._data["opcode"]
2871 @opcode.setter
2872 def opcode(self, val):
2873 if not self._data.flags.writeable: 1hljimk
2874 raise ValueError("This IOParams instance is read-only")
2875 self._data["opcode"] = val 1hljimk
2877 @property
2878 def cookie(self):
2879 """Union[~_numpy.intp, int]: """
2880 if self._data.size == 1:
2881 return int(self._data["cookie"][0])
2882 return self._data["cookie"]
2884 @cookie.setter
2885 def cookie(self, val):
2886 if not self._data.flags.writeable: 1hljimk
2887 raise ValueError("This IOParams instance is read-only")
2888 self._data["cookie"] = val 1hljimk
2890 def __getitem__(self, key):
2891 cdef ssize_t key_
2892 cdef ssize_t size
2893 cdef IOParams obj
2894 if isinstance(key, int): 1hljimk
2895 key_ = key 1hljimk
2896 size = self._data.size 1hljimk
2897 if key_ >= size or key_ <= -(size+1): 1hljimk
2898 raise IndexError("index is out of bounds")
2899 if key_ < 0: 1hljimk
2900 key_ += size
2901 obj = IOParams.__new__(IOParams) 1hljimk
2902 obj._data = self._data[key_:key_+1] 1hljimk
2903 obj._owner = self._owner 1hljimk
2904 return obj 1hljimk
2905 out = self._data[key]
2906 if isinstance(out, _numpy.ndarray):
2907 if out.dtype == io_params_dtype:
2908 obj = IOParams.from_data(out)
2909 obj._owner = self._owner
2910 return obj
2911 if out.dtype.names is not None:
2912 return out.view(_numpy.recarray)
2913 return out
2915 def __setitem__(self, key, val):
2916 self._data[key] = val
2918 @staticmethod
2919 def from_buffer(buffer):
2920 """Create an IOParams instance with the memory from the given buffer."""
2921 return IOParams.from_data(_numpy.frombuffer(buffer, dtype=io_params_dtype))
2923 @staticmethod
2924 def from_data(data):
2925 """Create an IOParams instance wrapping the given NumPy array.
2927 Args:
2928 data (_numpy.ndarray): a 1D array of dtype `io_params_dtype` holding the data.
2929 """
2930 cdef IOParams obj = IOParams.__new__(IOParams)
2931 if not isinstance(data, _numpy.ndarray):
2932 raise TypeError("data argument must be a NumPy ndarray")
2933 if data.ndim != 1:
2934 raise ValueError("data array must be 1D")
2935 if data.dtype != io_params_dtype:
2936 raise ValueError("data array must be of dtype io_params_dtype")
2937 obj._data = data.view(dtype=io_params_dtype_record, type=_numpy.ndarray)
2938 return obj
2940 @staticmethod
2941 def from_ptr(intptr_t ptr, size_t size=1, bint readonly=False, object owner=None):
2942 """Create an IOParams instance wrapping the given pointer.
2944 Args:
2945 ptr (intptr_t): pointer address as Python :class:`int` to the data.
2946 size (int): number of structs, default=1.
2947 readonly (bool): whether the data is read-only (to the user). default is `False`.
2948 owner (object): object that owns the memory at *ptr*. A strong reference is
2949 kept so the backing storage outlives this wrapper.
2950 """
2951 if ptr == 0:
2952 raise ValueError("ptr must not be null (0)")
2953 cdef IOParams obj = IOParams.__new__(IOParams)
2954 cdef flag = _cyb_cpython_buffer.PyBUF_READ if readonly else _cyb_cpython_buffer.PyBUF_WRITE
2955 cdef object buf = _cyb_cpython_memoryview.PyMemoryView_FromMemory(
2956 <char*>ptr, sizeof(CUfileIOParams_t) * size, flag)
2957 obj._data = _numpy.ndarray(size, buffer=buf, dtype=io_params_dtype_record)
2958 obj._owner = owner
2959 return obj
2962cdef _get_stats_level2_dtype_offsets():
2963 cdef CUfileStatsLevel2_t *pod = <CUfileStatsLevel2_t *>_cyb_calloc(1, sizeof(CUfileStatsLevel2_t))
2964 if pod == NULL:
2965 raise MemoryError("Error allocating CUfileStatsLevel2_t")
2966 try:
2967 return _numpy.dtype({
2968 'names': ['basic', 'read_size_kb_hist', 'write_size_kb_hist'],
2969 'formats': [stats_level1_dtype, (_numpy.uint64, 32), (_numpy.uint64, 32)],
2970 'offsets': [
2971 (<intptr_t>&(pod.basic)) - (<intptr_t>pod),
2972 (<intptr_t>&(pod.read_size_kb_hist)) - (<intptr_t>pod),
2973 (<intptr_t>&(pod.write_size_kb_hist)) - (<intptr_t>pod),
2974 ],
2975 'itemsize': sizeof(CUfileStatsLevel2_t),
2976 })
2977 finally:
2978 _cyb_free(pod)
2980stats_level2_dtype = _get_stats_level2_dtype_offsets()
2982cdef class StatsLevel2:
2983 """Empty-initialize an instance of `CUfileStatsLevel2_t`.
2986 .. seealso:: `CUfileStatsLevel2_t`
2987 """
2988 cdef:
2989 CUfileStatsLevel2_t *_ptr
2990 object _owner
2991 bint _owns_ptr
2992 bint _readonly
2994 def __init__(self):
2995 self._ptr = <CUfileStatsLevel2_t *>_cyb_calloc(1, sizeof(CUfileStatsLevel2_t)) 1bc
2996 if self._ptr == NULL: 1bc
2997 raise MemoryError("Error allocating StatsLevel2")
2998 self._owns_ptr = True 1bc
2999 self._owner = None 1bc
3000 self._readonly = False 1bc
3002 def __dealloc__(self):
3003 cdef CUfileStatsLevel2_t *ptr
3004 if self._owns_ptr and self._ptr != NULL: 1bdce
3005 ptr = self._ptr 1bc
3006 self._ptr = NULL 1bc
3007 _cyb_free(ptr) 1bc
3009 def __repr__(self):
3010 return f"<{__name__}.StatsLevel2 object at {hex(id(self))}>"
3012 @property
3013 def ptr(self):
3014 """Get the pointer address to the data as Python :class:`int`."""
3015 return <intptr_t>(self._ptr) 1bc
3017 cdef intptr_t _get_ptr(self):
3018 return <intptr_t>(self._ptr)
3020 def __int__(self):
3021 return <intptr_t>(self._ptr)
3023 def __eq__(self, other):
3024 cdef StatsLevel2 other_
3025 if not isinstance(other, StatsLevel2):
3026 return False
3027 other_ = other
3028 return (_cyb_memcmp(<void *><intptr_t>(self._ptr), <void *><intptr_t>(other_._ptr), sizeof(CUfileStatsLevel2_t)) == 0)
3030 def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags):
3031 _cyb___getbuffer(self, buffer, <void *>self._ptr, sizeof(CUfileStatsLevel2_t), self._readonly)
3033 def __releasebuffer__(self, Py_buffer *buffer):
3034 pass
3036 def __setitem__(self, key, val):
3037 cdef _cyb_Py_buffer view
3038 if key == 0:
3039 if self._readonly:
3040 raise ValueError("This StatsLevel2 instance is read-only")
3041 _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE)
3042 try:
3043 if <size_t>view.len < sizeof(CUfileStatsLevel2_t):
3044 raise ValueError(
3045 "source buffer too small: expected at least %d bytes, got %d" % (sizeof(CUfileStatsLevel2_t), view.len)
3046 )
3047 _cyb_memmove(<void*>self._ptr, view.buf, sizeof(CUfileStatsLevel2_t))
3048 self._readonly = view.readonly != 0
3049 finally:
3050 _cyb_PyBuffer_Release(&view)
3051 else:
3052 setattr(self, key, val)
3054 @property
3055 def basic(self):
3056 """StatsLevel1: """
3057 return StatsLevel1.from_ptr( 1bc
3058 <intptr_t>&(self._ptr[0].basic), 1bc
3059 readonly=self._readonly, 1bc
3060 owner=self, 1bc
3061 )
3063 @basic.setter
3064 def basic(self, val):
3065 if self._readonly:
3066 raise ValueError("This StatsLevel2 instance is read-only")
3067 cdef StatsLevel1 val_ = val
3068 _cyb_memcpy(<void *>&(self._ptr[0].basic), <void *>(val_._get_ptr()), sizeof(CUfileStatsLevel1_t) * 1)
3070 @property
3071 def read_size_kb_hist(self):
3072 """~_numpy.uint64: (array of length 32)."""
3073 cdef _cyb_view.array arr = _cyb_view.array(shape=(32,), itemsize=sizeof(uint64_t), format="Q", mode="c", allocate_buffer=False) 1bdce
3074 arr.data = <char *>(&(self._ptr[0].read_size_kb_hist)) 1bdce
3075 return _numpy.asarray(arr) 1bdce
3077 @read_size_kb_hist.setter
3078 def read_size_kb_hist(self, val):
3079 if self._readonly:
3080 raise ValueError("This StatsLevel2 instance is read-only")
3081 if len(val) != 32:
3082 raise ValueError(f"Expected length { 32 } for field read_size_kb_hist, got {len(val)}")
3083 cdef _cyb_view.array arr = _cyb_view.array(shape=(32,), itemsize=sizeof(uint64_t), format="Q", mode="c")
3084 arr[:] = _numpy.asarray(val, dtype=_numpy.uint64)
3085 _cyb_memcpy(<void *>(&(self._ptr[0].read_size_kb_hist)), <void *>(arr.data), sizeof(uint64_t) * len(val))
3087 @property
3088 def write_size_kb_hist(self):
3089 """~_numpy.uint64: (array of length 32)."""
3090 cdef _cyb_view.array arr = _cyb_view.array(shape=(32,), itemsize=sizeof(uint64_t), format="Q", mode="c", allocate_buffer=False) 1bc
3091 arr.data = <char *>(&(self._ptr[0].write_size_kb_hist)) 1bc
3092 return _numpy.asarray(arr) 1bc
3094 @write_size_kb_hist.setter
3095 def write_size_kb_hist(self, val):
3096 if self._readonly:
3097 raise ValueError("This StatsLevel2 instance is read-only")
3098 if len(val) != 32:
3099 raise ValueError(f"Expected length { 32 } for field write_size_kb_hist, got {len(val)}")
3100 cdef _cyb_view.array arr = _cyb_view.array(shape=(32,), itemsize=sizeof(uint64_t), format="Q", mode="c")
3101 arr[:] = _numpy.asarray(val, dtype=_numpy.uint64)
3102 _cyb_memcpy(<void *>(&(self._ptr[0].write_size_kb_hist)), <void *>(arr.data), sizeof(uint64_t) * len(val))
3104 @staticmethod
3105 def from_buffer(buffer):
3106 """Create an StatsLevel2 instance with the memory from the given buffer."""
3107 return _cyb_from_buffer(buffer, sizeof(CUfileStatsLevel2_t), StatsLevel2)
3109 @staticmethod
3110 def from_data(data):
3111 """Create an StatsLevel2 instance wrapping the given NumPy array.
3113 Args:
3114 data (_numpy.ndarray): a single-element array of dtype `stats_level2_dtype` holding the data.
3115 """
3116 return _cyb_from_data(data, "stats_level2_dtype", stats_level2_dtype, StatsLevel2) 1de
3118 @staticmethod
3119 def from_ptr(intptr_t ptr, bint readonly=False, object owner=None):
3120 """Create an StatsLevel2 instance wrapping the given pointer.
3122 Args:
3123 ptr (intptr_t): pointer address as Python :class:`int` to the data.
3124 owner (object): The Python object that owns the pointer. If not provided, data will be copied.
3125 readonly (bool): whether the data is read-only (to the user). default is `False`.
3126 """
3127 if ptr == 0: 1de
3128 raise ValueError("ptr must not be null (0)")
3129 cdef StatsLevel2 obj = StatsLevel2.__new__(StatsLevel2) 1de
3130 if owner is None: 1de
3131 obj._ptr = <CUfileStatsLevel2_t *>_cyb_malloc(sizeof(CUfileStatsLevel2_t))
3132 if obj._ptr == NULL:
3133 raise MemoryError("Error allocating StatsLevel2")
3134 _cyb_memcpy(<void*>(obj._ptr), <void*>ptr, sizeof(CUfileStatsLevel2_t))
3135 obj._owns_ptr = True
3136 obj._owner = None
3137 else:
3138 obj._ptr = <CUfileStatsLevel2_t *>ptr 1de
3139 obj._owns_ptr = False 1de
3140 obj._owner = owner 1de
3141 obj._readonly = readonly 1de
3142 return obj 1de
3145cdef _get_stats_level3_dtype_offsets():
3146 cdef CUfileStatsLevel3_t *pod = <CUfileStatsLevel3_t *>_cyb_calloc(1, sizeof(CUfileStatsLevel3_t))
3147 if pod == NULL:
3148 raise MemoryError("Error allocating CUfileStatsLevel3_t")
3149 try:
3150 return _numpy.dtype({
3151 'names': ['detailed', 'num_gpus', 'per_gpu_stats'],
3152 'formats': [stats_level2_dtype, _numpy.uint32, (per_gpu_stats_dtype, 16)],
3153 'offsets': [
3154 (<intptr_t>&(pod.detailed)) - (<intptr_t>pod),
3155 (<intptr_t>&(pod.num_gpus)) - (<intptr_t>pod),
3156 (<intptr_t>&(pod.per_gpu_stats)) - (<intptr_t>pod),
3157 ],
3158 'itemsize': sizeof(CUfileStatsLevel3_t),
3159 })
3160 finally:
3161 _cyb_free(pod)
3163stats_level3_dtype = _get_stats_level3_dtype_offsets()
3165cdef class StatsLevel3:
3166 """Empty-initialize an instance of `CUfileStatsLevel3_t`.
3169 .. seealso:: `CUfileStatsLevel3_t`
3170 """
3171 cdef:
3172 CUfileStatsLevel3_t _data
3173 CUfileStatsLevel3_t *_ptr
3174 object _owner
3175 bint _readonly
3177 def __init__(self):
3178 self._ptr = &self._data 1de
3179 self._owner = None 1de
3180 self._readonly = False 1de
3182 def __repr__(self):
3183 return f"<{__name__}.StatsLevel3 object at {hex(id(self))}>"
3185 @property
3186 def ptr(self):
3187 """Get the pointer address to the data as Python :class:`int`."""
3188 return <intptr_t>(self._ptr) 1de
3190 cdef intptr_t _get_ptr(self):
3191 return <intptr_t>(self._ptr)
3193 def __int__(self):
3194 return <intptr_t>(self._ptr)
3196 def __eq__(self, other):
3197 cdef StatsLevel3 other_
3198 if not isinstance(other, StatsLevel3):
3199 return False
3200 other_ = other
3201 return (_cyb_memcmp(<void *><intptr_t>(self._ptr), <void *><intptr_t>(other_._ptr), sizeof(CUfileStatsLevel3_t)) == 0)
3203 def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags):
3204 _cyb___getbuffer(self, buffer, <void *>self._ptr, sizeof(CUfileStatsLevel3_t), self._readonly)
3206 def __releasebuffer__(self, Py_buffer *buffer):
3207 pass
3209 def __setitem__(self, key, val):
3210 cdef _cyb_Py_buffer view
3211 if key == 0:
3212 if self._readonly:
3213 raise ValueError("This StatsLevel3 instance is read-only")
3214 _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE)
3215 try:
3216 if <size_t>view.len < sizeof(CUfileStatsLevel3_t):
3217 raise ValueError(
3218 "source buffer too small: expected at least %d bytes, got %d" % (sizeof(CUfileStatsLevel3_t), view.len)
3219 )
3220 _cyb_memmove(<void*>&self._data, view.buf, sizeof(CUfileStatsLevel3_t))
3221 self._ptr = &self._data
3222 self._owner = None
3223 self._readonly = view.readonly != 0
3224 finally:
3225 _cyb_PyBuffer_Release(&view)
3226 else:
3227 setattr(self, key, val)
3229 @property
3230 def detailed(self):
3231 """StatsLevel2: """
3232 return StatsLevel2.from_ptr( 1de
3233 <intptr_t>&(self._ptr[0].detailed), 1de
3234 readonly=self._readonly, 1de
3235 owner=self, 1de
3236 )
3238 @detailed.setter
3239 def detailed(self, val):
3240 if self._readonly:
3241 raise ValueError("This StatsLevel3 instance is read-only")
3242 cdef StatsLevel2 val_ = val
3243 _cyb_memcpy(<void *>&(self._ptr[0].detailed), <void *>(val_._get_ptr()), sizeof(CUfileStatsLevel2_t) * 1)
3245 @property
3246 def per_gpu_stats(self):
3247 """PerGpuStats: """
3248 return PerGpuStats.from_ptr( 1de
3249 <intptr_t>&(self._ptr[0].per_gpu_stats), 1de
3250 16,
3251 readonly=self._readonly, 1de
3252 owner=self, 1de
3253 )
3255 @per_gpu_stats.setter
3256 def per_gpu_stats(self, val):
3257 if self._readonly:
3258 raise ValueError("This StatsLevel3 instance is read-only")
3259 cdef PerGpuStats val_ = val
3260 if len(val) != 16:
3261 raise ValueError(f"Expected length { 16 } for field per_gpu_stats, got {len(val)}")
3262 _cyb_memcpy(<void *>&(self._ptr[0].per_gpu_stats), <void *>(val_._get_ptr()), sizeof(CUfilePerGpuStats_t) * 16)
3264 @property
3265 def num_gpus(self):
3266 """int: """
3267 return self._ptr[0].num_gpus 1de
3269 @num_gpus.setter
3270 def num_gpus(self, val):
3271 if self._readonly:
3272 raise ValueError("This StatsLevel3 instance is read-only")
3273 self._ptr[0].num_gpus = val
3275 @staticmethod
3276 def from_buffer(buffer):
3277 """Create an StatsLevel3 instance with the memory from the given buffer."""
3278 return _cyb_from_buffer(buffer, sizeof(CUfileStatsLevel3_t), StatsLevel3)
3280 @staticmethod
3281 def from_data(data):
3282 """Create an StatsLevel3 instance wrapping the given NumPy array.
3284 Args:
3285 data (_numpy.ndarray): a single-element array of dtype `stats_level3_dtype` holding the data.
3286 """
3287 return _cyb_from_data(data, "stats_level3_dtype", stats_level3_dtype, StatsLevel3)
3289 @staticmethod
3290 def from_ptr(intptr_t ptr, bint readonly=False, object owner=None):
3291 """Create an StatsLevel3 instance wrapping the given pointer.
3293 Args:
3294 ptr (intptr_t): pointer address as Python :class:`int` to the data.
3295 owner (object): The Python object that owns the pointer. If not provided, data will be copied.
3296 readonly (bool): whether the data is read-only (to the user). default is `False`.
3297 """
3298 if ptr == 0:
3299 raise ValueError("ptr must not be null (0)")
3300 cdef StatsLevel3 obj = StatsLevel3.__new__(StatsLevel3)
3301 if owner is None:
3302 _cyb_memcpy(<void*>&obj._data, <void*>ptr, sizeof(CUfileStatsLevel3_t))
3303 obj._ptr = &obj._data
3304 obj._owner = None
3305 else:
3306 obj._ptr = <CUfileStatsLevel3_t *>ptr
3307 obj._owner = owner
3308 obj._readonly = readonly
3309 return obj
3312###############################################################################
3313# Enum
3314###############################################################################
3316class OpError(_cyb_FastEnum):
3317 """
3318 See `CUfileOpError`.
3319 """
3320 SUCCESS = CU_FILE_SUCCESS
3321 DRIVER_NOT_INITIALIZED = CU_FILE_DRIVER_NOT_INITIALIZED
3322 DRIVER_INVALID_PROPS = CU_FILE_DRIVER_INVALID_PROPS
3323 DRIVER_UNSUPPORTED_LIMIT = CU_FILE_DRIVER_UNSUPPORTED_LIMIT
3324 DRIVER_VERSION_MISMATCH = CU_FILE_DRIVER_VERSION_MISMATCH
3325 DRIVER_VERSION_READ_ERROR = CU_FILE_DRIVER_VERSION_READ_ERROR
3326 DRIVER_CLOSING = CU_FILE_DRIVER_CLOSING
3327 PLATFORM_NOT_SUPPORTED = CU_FILE_PLATFORM_NOT_SUPPORTED
3328 IO_NOT_SUPPORTED = CU_FILE_IO_NOT_SUPPORTED
3329 DEVICE_NOT_SUPPORTED = CU_FILE_DEVICE_NOT_SUPPORTED
3330 NVFS_DRIVER_ERROR = CU_FILE_NVFS_DRIVER_ERROR
3331 CUDA_DRIVER_ERROR = CU_FILE_CUDA_DRIVER_ERROR
3332 CUDA_POINTER_INVALID = CU_FILE_CUDA_POINTER_INVALID
3333 CUDA_MEMORY_TYPE_INVALID = CU_FILE_CUDA_MEMORY_TYPE_INVALID
3334 CUDA_POINTER_RANGE_ERROR = CU_FILE_CUDA_POINTER_RANGE_ERROR
3335 CUDA_CONTEXT_MISMATCH = CU_FILE_CUDA_CONTEXT_MISMATCH
3336 INVALID_MAPPING_SIZE = CU_FILE_INVALID_MAPPING_SIZE
3337 INVALID_MAPPING_RANGE = CU_FILE_INVALID_MAPPING_RANGE
3338 INVALID_FILE_TYPE = CU_FILE_INVALID_FILE_TYPE
3339 INVALID_FILE_OPEN_FLAG = CU_FILE_INVALID_FILE_OPEN_FLAG
3340 DIO_NOT_SET = CU_FILE_DIO_NOT_SET
3341 INVALID_VALUE = CU_FILE_INVALID_VALUE
3342 MEMORY_ALREADY_REGISTERED = CU_FILE_MEMORY_ALREADY_REGISTERED
3343 MEMORY_NOT_REGISTERED = CU_FILE_MEMORY_NOT_REGISTERED
3344 PERMISSION_DENIED = CU_FILE_PERMISSION_DENIED
3345 DRIVER_ALREADY_OPEN = CU_FILE_DRIVER_ALREADY_OPEN
3346 HANDLE_NOT_REGISTERED = CU_FILE_HANDLE_NOT_REGISTERED
3347 HANDLE_ALREADY_REGISTERED = CU_FILE_HANDLE_ALREADY_REGISTERED
3348 DEVICE_NOT_FOUND = CU_FILE_DEVICE_NOT_FOUND
3349 INTERNAL_ERROR = CU_FILE_INTERNAL_ERROR
3350 GETNEWFD_FAILED = CU_FILE_GETNEWFD_FAILED
3351 NVFS_SETUP_ERROR = CU_FILE_NVFS_SETUP_ERROR
3352 IO_DISABLED = CU_FILE_IO_DISABLED
3353 BATCH_SUBMIT_FAILED = CU_FILE_BATCH_SUBMIT_FAILED
3354 GPU_MEMORY_PINNING_FAILED = CU_FILE_GPU_MEMORY_PINNING_FAILED
3355 BATCH_FULL = CU_FILE_BATCH_FULL
3356 ASYNC_NOT_SUPPORTED = CU_FILE_ASYNC_NOT_SUPPORTED
3357 INTERNAL_BATCH_SETUP_ERROR = CU_FILE_INTERNAL_BATCH_SETUP_ERROR
3358 INTERNAL_BATCH_SUBMIT_ERROR = CU_FILE_INTERNAL_BATCH_SUBMIT_ERROR
3359 INTERNAL_BATCH_GETSTATUS_ERROR = CU_FILE_INTERNAL_BATCH_GETSTATUS_ERROR
3360 INTERNAL_BATCH_CANCEL_ERROR = CU_FILE_INTERNAL_BATCH_CANCEL_ERROR
3361 NOMEM_ERROR = CU_FILE_NOMEM_ERROR
3362 IO_ERROR = CU_FILE_IO_ERROR
3363 INTERNAL_BUF_REGISTER_ERROR = CU_FILE_INTERNAL_BUF_REGISTER_ERROR
3364 HASH_OPR_ERROR = CU_FILE_HASH_OPR_ERROR
3365 INVALID_CONTEXT_ERROR = CU_FILE_INVALID_CONTEXT_ERROR
3366 NVFS_INTERNAL_DRIVER_ERROR = CU_FILE_NVFS_INTERNAL_DRIVER_ERROR
3367 BATCH_NOCOMPAT_ERROR = CU_FILE_BATCH_NOCOMPAT_ERROR
3368 IO_MAX_ERROR = CU_FILE_IO_MAX_ERROR
3370class DriverStatusFlags(_cyb_FastEnum):
3371 """
3372 See `CUfileDriverStatusFlags_t`.
3373 """
3374 LUSTRE_SUPPORTED = (CU_FILE_LUSTRE_SUPPORTED, 'Support for DDN LUSTRE')
3375 WEKAFS_SUPPORTED = (CU_FILE_WEKAFS_SUPPORTED, 'Support for WEKAFS')
3376 NFS_SUPPORTED = (CU_FILE_NFS_SUPPORTED, 'Support for NFS')
3377 GPFS_SUPPORTED = CU_FILE_GPFS_SUPPORTED
3378 NVME_SUPPORTED = (CU_FILE_NVME_SUPPORTED, '< Support for GPFS Support for NVMe')
3379 NVMEOF_SUPPORTED = (CU_FILE_NVMEOF_SUPPORTED, 'Support for NVMeOF')
3380 SCSI_SUPPORTED = (CU_FILE_SCSI_SUPPORTED, 'Support for SCSI')
3381 SCALEFLUX_CSD_SUPPORTED = (CU_FILE_SCALEFLUX_CSD_SUPPORTED, 'Support for Scaleflux CSD')
3382 NVMESH_SUPPORTED = (CU_FILE_NVMESH_SUPPORTED, 'Support for NVMesh Block Dev')
3383 BEEGFS_SUPPORTED = (CU_FILE_BEEGFS_SUPPORTED, 'Support for BeeGFS')
3384 NVME_P2P_SUPPORTED = (CU_FILE_NVME_P2P_SUPPORTED, 'Do not use this macro. This is deprecated now')
3385 SCATEFS_SUPPORTED = (CU_FILE_SCATEFS_SUPPORTED, 'Support for ScateFS')
3386 VIRTIOFS_SUPPORTED = (CU_FILE_VIRTIOFS_SUPPORTED, 'Support for VirtioFS')
3387 PANFS_SUPPORTED = (CU_FILE_PANFS_SUPPORTED, 'Support for PanFS')
3388 MAX_TARGET_TYPES = (CU_FILE_MAX_TARGET_TYPES, 'Maximum FS supported')
3390class DriverControlFlags(_cyb_FastEnum):
3391 """
3392 See `CUfileDriverControlFlags_t`.
3393 """
3394 USE_POLL_MODE = (CU_FILE_USE_POLL_MODE, 'use POLL mode. properties.use_poll_mode')
3395 ALLOW_COMPAT_MODE = (CU_FILE_ALLOW_COMPAT_MODE, 'allow COMPATIBILITY mode. properties.allow_compat_mode')
3396 VANILLA_POSIX_IO_MODE = (CU_FILE_VANILLA_POSIX_IO_MODE, 'Vanilla posix io mode. properties.vanilla_posix_io_mode')
3397 POSIX_IO_MODE = (CU_FILE_POSIX_IO_MODE, 'alias for backward compatibility')
3398 FALLBACK_IO_MODE = (CU_FILE_FALLBACK_IO_MODE, 'Fallback io mode. properties.gds_fallback_io')
3400class FeatureFlags(_cyb_FastEnum):
3401 """
3402 See `CUfileFeatureFlags_t`.
3403 """
3404 DYN_ROUTING_SUPPORTED = (CU_FILE_DYN_ROUTING_SUPPORTED, 'Support for Dynamic routing to handle devices across the PCIe bridges')
3405 BATCH_IO_SUPPORTED = (CU_FILE_BATCH_IO_SUPPORTED, 'Supported')
3406 STREAMS_SUPPORTED = (CU_FILE_STREAMS_SUPPORTED, 'Supported')
3407 PARALLEL_IO_SUPPORTED = (CU_FILE_PARALLEL_IO_SUPPORTED, 'Supported')
3408 P2P_SUPPORTED = (CU_FILE_P2P_SUPPORTED, 'Support for PCI P2PDMA')
3410class FileHandleType(_cyb_FastEnum):
3411 """
3412 See `CUfileFileHandleType`.
3413 """
3414 OPAQUE_FD = (CU_FILE_HANDLE_TYPE_OPAQUE_FD, 'Linux based fd')
3415 OPAQUE_WIN32 = (CU_FILE_HANDLE_TYPE_OPAQUE_WIN32, 'Windows based handle (unsupported)')
3416 USERSPACE_FS = CU_FILE_HANDLE_TYPE_USERSPACE_FS
3418class Opcode(_cyb_FastEnum):
3419 """
3420 See `CUfileOpcode_t`.
3421 """
3422 READ = CUFILE_READ
3423 WRITE = CUFILE_WRITE
3425class Status(_cyb_FastEnum):
3426 """
3427 See `CUfileStatus_t`.
3428 """
3429 WAITING = CUFILE_WAITING
3430 PENDING = CUFILE_PENDING
3431 INVALID = CUFILE_INVALID
3432 CANCELED = CUFILE_CANCELED
3433 COMPLETE = CUFILE_COMPLETE
3434 TIMEOUT = CUFILE_TIMEOUT
3435 FAILED = CUFILE_FAILED
3437class BatchMode(_cyb_FastEnum):
3438 """
3439 See `CUfileBatchMode_t`.
3440 """
3441 BATCH = CUFILE_BATCH
3443class SizeTConfigParameter(_cyb_FastEnum):
3444 """
3445 See `CUFileSizeTConfigParameter_t`.
3446 """
3447 PROFILE_STATS = CUFILE_PARAM_PROFILE_STATS
3448 EXECUTION_MAX_IO_QUEUE_DEPTH = CUFILE_PARAM_EXECUTION_MAX_IO_QUEUE_DEPTH
3449 EXECUTION_MAX_IO_THREADS = CUFILE_PARAM_EXECUTION_MAX_IO_THREADS
3450 EXECUTION_MIN_IO_THRESHOLD_SIZE_KB = CUFILE_PARAM_EXECUTION_MIN_IO_THRESHOLD_SIZE_KB
3451 EXECUTION_MAX_REQUEST_PARALLELISM = CUFILE_PARAM_EXECUTION_MAX_REQUEST_PARALLELISM
3452 PROPERTIES_MAX_DIRECT_IO_SIZE_KB = CUFILE_PARAM_PROPERTIES_MAX_DIRECT_IO_SIZE_KB
3453 PROPERTIES_MAX_DEVICE_CACHE_SIZE_KB = CUFILE_PARAM_PROPERTIES_MAX_DEVICE_CACHE_SIZE_KB
3454 PROPERTIES_PER_BUFFER_CACHE_SIZE_KB = CUFILE_PARAM_PROPERTIES_PER_BUFFER_CACHE_SIZE_KB
3455 PROPERTIES_MAX_DEVICE_PINNED_MEM_SIZE_KB = CUFILE_PARAM_PROPERTIES_MAX_DEVICE_PINNED_MEM_SIZE_KB
3456 PROPERTIES_IO_BATCHSIZE = CUFILE_PARAM_PROPERTIES_IO_BATCHSIZE
3457 POLLTHRESHOLD_SIZE_KB = CUFILE_PARAM_POLLTHRESHOLD_SIZE_KB
3458 PROPERTIES_BATCH_IO_TIMEOUT_MS = CUFILE_PARAM_PROPERTIES_BATCH_IO_TIMEOUT_MS
3460class BoolConfigParameter(_cyb_FastEnum):
3461 """
3462 See `CUFileBoolConfigParameter_t`.
3463 """
3464 PROPERTIES_USE_POLL_MODE = CUFILE_PARAM_PROPERTIES_USE_POLL_MODE
3465 PROPERTIES_ALLOW_COMPAT_MODE = CUFILE_PARAM_PROPERTIES_ALLOW_COMPAT_MODE
3466 FORCE_COMPAT_MODE = CUFILE_PARAM_FORCE_COMPAT_MODE
3467 FS_MISC_API_CHECK_AGGRESSIVE = CUFILE_PARAM_FS_MISC_API_CHECK_AGGRESSIVE
3468 EXECUTION_PARALLEL_IO = CUFILE_PARAM_EXECUTION_PARALLEL_IO
3469 PROFILE_NVTX = CUFILE_PARAM_PROFILE_NVTX
3470 PROPERTIES_ALLOW_SYSTEM_MEMORY = CUFILE_PARAM_PROPERTIES_ALLOW_SYSTEM_MEMORY
3471 USE_PCIP2PDMA = CUFILE_PARAM_USE_PCIP2PDMA
3472 PREFER_IO_URING = CUFILE_PARAM_PREFER_IO_URING
3473 FORCE_ODIRECT_MODE = CUFILE_PARAM_FORCE_ODIRECT_MODE
3474 SKIP_TOPOLOGY_DETECTION = CUFILE_PARAM_SKIP_TOPOLOGY_DETECTION
3475 STREAM_MEMOPS_BYPASS = CUFILE_PARAM_STREAM_MEMOPS_BYPASS
3476 PROPERTIES_POSIX_IO_MODE = CUFILE_PARAM_PROPERTIES_POSIX_IO_MODE
3477 GDS_FALLBACK_IO = CUFILE_PARAM_GDS_FALLBACK_IO
3479class StringConfigParameter(_cyb_FastEnum):
3480 """
3481 See `CUFileStringConfigParameter_t`.
3482 """
3483 LOGGING_LEVEL = CUFILE_PARAM_LOGGING_LEVEL
3484 ENV_LOGFILE_PATH = CUFILE_PARAM_ENV_LOGFILE_PATH
3485 LOG_DIR = CUFILE_PARAM_LOG_DIR
3486 RDMA_TRANSPORT = CUFILE_PARAM_RDMA_TRANSPORT
3488class ArrayConfigParameter(_cyb_FastEnum):
3489 """
3490 See `CUFileArrayConfigParameter_t`.
3491 """
3492 POSIX_POOL_SLAB_SIZE_KB = CUFILE_PARAM_POSIX_POOL_SLAB_SIZE_KB
3493 POSIX_POOL_SLAB_COUNT = CUFILE_PARAM_POSIX_POOL_SLAB_COUNT
3494 GPU_BOUNCE_BUFFER_SLAB_SIZE_KB = CUFILE_PARAM_GPU_BOUNCE_BUFFER_SLAB_SIZE_KB
3495 GPU_BOUNCE_BUFFER_SLAB_COUNT = CUFILE_PARAM_GPU_BOUNCE_BUFFER_SLAB_COUNT
3497class P2PFlags(_cyb_FastEnum):
3498 """
3499 See `CUfileP2PFlags_t`.
3500 """
3501 P2PDMA = (CUFILE_P2PDMA, 'Support for PCI P2PDMA')
3502 NVFS = (CUFILE_NVFS, 'Support for nvidia-fs')
3503 DMABUF = (CUFILE_DMABUF, 'Support for DMA Buffer')
3504 C2C = (CUFILE_C2C, 'Support for Chip-to-Chip (Grace-based systems)')
3505 NVIDIA_PEERMEM = (CUFILE_NVIDIA_PEERMEM, 'Only for IBM Spectrum Scale and WekaFS')
3508###############################################################################
3509# Error handling
3510###############################################################################
3512ctypedef fused ReturnT:
3513 CUfileError_t
3514 ssize_t
3517class cuFileError(Exception):
3519 def __init__(self, status, cu_err=None):
3520 self.status = status 1HzDIAE
3521 self.cuda_error = cu_err 1HzDIAE
3522 s = OpError(status) 1HzDIAE
3523 cdef str err = f"{s.name} ({s.value}): {op_status_error(status)}" 1HzDIAE
3524 if cu_err is not None: 1HzDIAE
3525 e = pyCUresult(cu_err)
3526 err += f"; CUDA status: {e.name} ({e.value})"
3527 super(cuFileError, self).__init__(err) 1HzDIAE
3529 def __reduce__(self):
3530 return (type(self), (self.status, self.cuda_error))
3533@cython.profile(False)
3534cdef int check_status(ReturnT status) except 1 nogil:
3535 if ReturnT is CUfileError_t:
3536 if IS_CUDA_ERR(status): 2a h @ [ l ] ^ j _ ` H { | 9 } ~ ! abbb# cbdb$ ebfb% gbhbn ibjbp kblbq mbnbr obpbs qbrb' t sbtb: ubvb; wbxbf Z L b 0 M d 1 N B ybzbF J z O ( AbD 2 P Q 3 R i BbCbm ) Dbk EbFbI GbHb* IbJb+ KbLb, MbNb- ObPb. QbRbo SbTbu UbVbv WbXbw YbZbx 0b1by 2b3b= 4b5b? 6b7bg 4 S c 5 T e 6 U C 8b9bG K A V / !bE 7 W X 8 Y
3537 with gil:
3538 raise cuFileError(status.err, status.cu_err)
3539 elif IS_CUFILE_ERR(status.err): 2a h @ [ l ] ^ j _ ` H { | 9 } ~ ! abbb# cbdb$ ebfb% gbhbn ibjbp kblbq mbnbr obpbs qbrb' t sbtb: ubvb; wbxbf Z L b 0 M d 1 N B ybzbF J z O ( AbD 2 P Q 3 R i BbCbm ) Dbk EbFbI GbHb* IbJb+ KbLb, MbNb- ObPb. QbRbo SbTbu UbVbv WbXbw YbZbx 0b1by 2b3b= 4b5b? 6b7bg 4 S c 5 T e 6 U C 8b9bG K A V / !bE 7 W X 8 Y
3540 with gil: 1HzDIAE
3541 raise cuFileError(status.err) 1HzDIAE
3542 elif ReturnT is ssize_t:
3543 if status == -1: 1qrsfbdvwxgce
3544 # note: this assumes cuFile already properly resets errno in each API
3545 with gil:
3546 raise cuFileError(errno.errno)
3547 return 0 2a h @ [ l ] ^ j _ ` H { | 9 } ~ ! abbb# cbdb$ ebfb% gbhbn ibjbp kblbq mbnbr obpbs qbrb' t sbtb: ubvb; wbxbf Z L b 0 M d 1 N B ybzbF J z O ( AbD 2 P Q 3 R i BbCbm ) Dbk EbFbI GbHb* IbJb+ KbLb, MbNb- ObPb. QbRbo SbTbu UbVbv WbXbw YbZbx 0b1by 2b3b= 4b5b? 6b7bg 4 S c 5 T e 6 U C 8b9bG K A V / !bE 7 W X 8 Y
3550###############################################################################
3551# Wrapper functions
3552###############################################################################
3554cpdef intptr_t handle_register(descr) except? 0:
3555 """cuFileHandleRegister is required, and performs extra checking that is memoized to provide increased performance on later cuFile operations.
3557 Description cuFileHandleRegister registers the open file descriptor for use
3558 with cuFile IO operations.
3559 This API will ensure that the file's descriptor is checked for GPUDirect
3560 Storage support and returns a valid file handle on CU_FILE_SUCCESS.
3562 Args:
3563 descr (intptr_t): ``CUfileDescr_t`` file descriptor (OS agnostic).
3565 Returns:
3566 intptr_t: ``CUfileHandle_t`` opaque file handle for IO operations.
3568 .. note::
3569 the file needs to be opened in O_DIRECT mode to support GPUDirect Storage.
3570 .. seealso:: `cuFileHandleRegister`
3571 """
3572 cdef intptr_t _descr_ptr_ = 0 if descr is None else int(descr) 1hljnpqrstfbdBimkouvwxygceC
3573 cdef Handle fh
3574 with nogil: 1hljnpqrstfbdBimkouvwxygceC
3575 __status__ = cuFileHandleRegister(&fh, <CUfileDescr_t*>_descr_ptr_) 1hljnpqrstfbdBimkouvwxygceC
3576 check_status(__status__) 1hljnpqrstfbdBimkouvwxygceC
3577 return <intptr_t>fh 1hljnpqrstfbdBimkouvwxygceC
3580cpdef void handle_deregister(intptr_t fh) except*:
3581 """releases a registered filehandle from cuFile.
3584 Args:
3585 fh (intptr_t): ``CUfileHandle_t`` file handle.
3587 .. seealso:: `cuFileHandleDeregister`
3588 """
3589 with nogil: 1hljnpqrstfbdBimkouvwxygceC
3590 cuFileHandleDeregister(<Handle>fh) 1hljnpqrstfbdBimkouvwxygceC
3593cpdef buf_register(intptr_t buf_ptr_base, size_t length, int flags):
3594 """register an existing cudaMalloced memory with cuFile to pin for GPUDirect Storage access or register host allocated memory with cuFile.
3597 Args:
3598 buf_ptr_base (intptr_t): buffer pointer allocated.
3599 length (size_t): size of memory region from the above specified
3600 bufPtr.
3601 flags (int): CU_FILE_RDMA_REGISTER.
3603 .. note::
3604 This memory will be use to perform GPU direct DMA from the supported storage.
3605 .. note::
3606 This API is intended for usecases where the memory is used as streaming buffer
3607 that is reused across multiple cuFile IO operations before calling
3608 ``cuFileBufDeregister``.
3609 .. seealso:: `cuFileBufRegister`
3610 """
3611 with nogil: 1hljH9!#$%npqrstfbdimkI*+,-.ouvwxygce
3612 __status__ = cuFileBufRegister(<const void*>buf_ptr_base, length, flags) 1hljH9!#$%npqrstfbdimkI*+,-.ouvwxygce
3613 check_status(__status__) 1hljH9!#$%npqrstfbdimkI*+,-.ouvwxygce
3616cpdef buf_deregister(intptr_t buf_ptr_base):
3617 """deregister an already registered device or host memory from cuFile.
3620 Args:
3621 buf_ptr_base (intptr_t): buffer pointer to deregister.
3623 .. seealso:: `cuFileBufDeregister`
3624 """
3625 with nogil: 1hljH9!#$%npqrstfbdimkI*+,-.ouvwxygce
3626 __status__ = cuFileBufDeregister(<const void*>buf_ptr_base) 1hljH9!#$%npqrstfbdimkI*+,-.ouvwxygce
3627 check_status(__status__) 1hljH9!#$%npqrstfbdimkI*+,-.ouvwxygce
3630cpdef driver_open():
3631 """Initialize the cuFile library and open the nvidia-fs driver.
3634 .. seealso:: `cuFileDriverOpen`
3635 """
3636 with nogil: 2@ ] _ { } abcbebgbibkbmbobqb' sbubwbZ 0 1 ybF J z O ( 2 3 Bb) EbGbIbKbMbObQbSbUbWbYb0b2b4b6b4 5 6 8bG K A V / 7 8
3637 __status__ = cuFileDriverOpen() 2@ ] _ { } abcbebgbibkbmbobqb' sbubwbZ 0 1 ybF J z O ( 2 3 Bb) EbGbIbKbMbObQbSbUbWbYb0b2b4b6b4 5 6 8bG K A V / 7 8
3638 check_status(__status__) 2@ ] _ { } abcbebgbibkbmbobqb' sbubwbZ 0 1 ybF J z O ( 2 3 Bb) EbGbIbKbMbObQbSbUbWbYb0b2b4b6b4 5 6 8bG K A V / 7 8
3641cpdef use_count():
3642 """returns use count of cufile drivers at that moment by the process.
3645 .. seealso:: `cuFileUseCount`
3646 """
3647 with nogil:
3648 __status__ = cuFileUseCount()
3649 check_status(__status__)
3652cpdef driver_get_properties(intptr_t props):
3653 """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.
3656 Args:
3657 props (intptr_t): Properties to get.
3659 .. seealso:: `cuFileDriverGetProperties`
3660 """
3661 with nogil:
3662 __status__ = cuFileDriverGetProperties(<CUfileDrvProps_t*>props)
3663 check_status(__status__)
3666cpdef driver_set_poll_mode(bint poll, size_t poll_threshold_size):
3667 """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.
3670 Args:
3671 poll (bint): boolean to indicate whether to use poll mode or not.
3672 poll_threshold_size (size_t): max IO size to use for POLLING mode
3673 in KB.
3675 .. note::
3676 This is an advanced command and should be tuned based on available system
3677 memory.
3678 .. seealso:: `cuFileDriverSetPollMode`
3679 """
3680 with nogil:
3681 __status__ = cuFileDriverSetPollMode(<_cyb_bool>poll, poll_threshold_size)
3682 check_status(__status__)
3685cpdef driver_set_max_direct_io_size(size_t max_direct_io_size):
3686 """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.
3689 Args:
3690 max_direct_io_size (size_t): maximum allowed direct io size in KB.
3692 .. note::
3693 This is an advanced command and should be tuned based on available system
3694 memory.
3695 .. seealso:: `cuFileDriverSetMaxDirectIOSize`
3696 """
3697 with nogil:
3698 __status__ = cuFileDriverSetMaxDirectIOSize(max_direct_io_size)
3699 check_status(__status__)
3702cpdef driver_set_max_cache_size(size_t max_cache_size):
3703 """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.
3706 Args:
3707 max_cache_size (size_t): The maximum GPU buffer space per device
3708 used for internal use in KB.
3710 .. note::
3711 This is an advanced command and should be tuned based on supported GPU memory.
3712 .. seealso:: `cuFileDriverSetMaxCacheSize`
3713 """
3714 with nogil:
3715 __status__ = cuFileDriverSetMaxCacheSize(max_cache_size)
3716 check_status(__status__)
3719cpdef driver_set_max_pinned_mem_size(size_t max_pinned_size):
3720 """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.
3723 Args:
3724 max_pinned_size (size_t): maximum buffer space that is pinned in
3725 KB.
3727 .. note::
3728 This is an advanced command and should be tuned based on supported GPU memory.
3729 .. seealso:: `cuFileDriverSetMaxPinnedMemSize`
3730 """
3731 with nogil:
3732 __status__ = cuFileDriverSetMaxPinnedMemSize(max_pinned_size)
3733 check_status(__status__)
3736cpdef intptr_t batch_io_set_up(unsigned nr) except? 0:
3737 cdef BatchHandle batch_idp
3738 with nogil: 1hljimk
3739 __status__ = cuFileBatchIOSetUp(&batch_idp, nr) 1hljimk
3740 check_status(__status__) 1hljimk
3741 return <intptr_t>batch_idp 1hljimk
3744cpdef batch_io_submit(intptr_t batch_idp, unsigned nr, iocbp, unsigned int flags):
3745 cdef intptr_t _iocbp_ptr_ = 0 if iocbp is None else int(iocbp) 1hljimk
3746 with nogil: 1hljimk
3747 __status__ = cuFileBatchIOSubmit(<BatchHandle>batch_idp, nr, <CUfileIOParams_t*>_iocbp_ptr_, flags) 1hljimk
3748 check_status(__status__) 1hljimk
3751cpdef batch_io_get_status(intptr_t batch_idp, unsigned min_nr, intptr_t nr, iocbp, intptr_t timeout):
3752 cdef intptr_t _iocbp_ptr_ = 0 if iocbp is None else int(iocbp) 1hjik
3753 with nogil: 1hjik
3754 __status__ = cuFileBatchIOGetStatus(<BatchHandle>batch_idp, min_nr, <unsigned*>nr, <CUfileIOEvents_t*>_iocbp_ptr_, <timespec*>timeout) 1hjik
3755 check_status(__status__) 1hjik
3758cpdef batch_io_cancel(intptr_t batch_idp):
3759 with nogil: 1lm
3760 __status__ = cuFileBatchIOCancel(<BatchHandle>batch_idp) 1lm
3761 check_status(__status__) 1lm
3764cpdef void batch_io_destroy(intptr_t batch_idp) except*:
3765 with nogil: 1hljimk
3766 cuFileBatchIODestroy(<BatchHandle>batch_idp) 1hljimk
3769cpdef 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):
3770 with nogil: 1npou
3771 __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) 1npou
3772 check_status(__status__) 1npou
3775cpdef 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):
3776 with nogil: 1ntoy
3777 __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) 1ntoy
3778 check_status(__status__) 1ntoy
3781cpdef stream_register(intptr_t stream, unsigned flags):
3782 with nogil: 1nptouy
3783 __status__ = cuFileStreamRegister(<CUstream>stream, flags) 1nptouy
3784 check_status(__status__) 1nptouy
3787cpdef stream_deregister(intptr_t stream):
3788 with nogil: 1nptouy
3789 __status__ = cuFileStreamDeregister(<CUstream>stream) 1nptouy
3790 check_status(__status__) 1nptouy
3793cpdef int get_version() except? 0:
3794 """Get the cuFile library version.
3796 The version is returned as (1000 major + 10 minor). For example, CUFILE 1.7.0
3797 would be represented by 1070.
3799 Returns:
3800 int: Pointer to an integer where the version will be stored.
3802 .. note::
3803 This is useful for applications that need to inquire the library.
3804 .. seealso:: `cuFileGetVersion`
3805 """
3806 cdef int version
3807 with nogil: 1aFG
3808 __status__ = cuFileGetVersion(&version) 1aFG
3809 check_status(__status__) 1aFG
3810 return version 1aFG
3813cpdef size_t get_parameter_size_t(int param) except? 0:
3814 cdef size_t value
3815 with nogil: 1JK
3816 __status__ = cuFileGetParameterSizeT(<_SizeTConfigParameter>param, &value) 1JK
3817 check_status(__status__) 1JK
3818 return value 1JK
3821cpdef bint get_parameter_bool(int param) except? 0:
3822 cdef _cyb_bool value
3823 with nogil: 1FG
3824 __status__ = cuFileGetParameterBool(<_BoolConfigParameter>param, &value) 1FG
3825 check_status(__status__) 1FG
3826 return <bint>value 1FG
3829cpdef str get_parameter_string(int param, int len):
3830 cdef bytes _desc_str_ = bytes(len) 1zA
3831 cdef char* desc_str = _desc_str_ 1zA
3832 with nogil: 1zA
3833 __status__ = cuFileGetParameterString(<_StringConfigParameter>param, desc_str, len) 1zA
3834 check_status(__status__) 1zA
3835 return _cyb_cpython.PyUnicode_FromString(desc_str) 1zA
3838cpdef set_parameter_size_t(int param, size_t value):
3839 with nogil: 1JK
3840 __status__ = cuFileSetParameterSizeT(<_SizeTConfigParameter>param, value) 1JK
3841 check_status(__status__) 1JK
3844cpdef set_parameter_bool(int param, bint value):
3845 with nogil: 1FG
3846 __status__ = cuFileSetParameterBool(<_BoolConfigParameter>param, <_cyb_bool>value) 1FG
3847 check_status(__status__) 1FG
3850cpdef set_parameter_string(int param, intptr_t desc_str):
3851 with nogil: 1zA
3852 __status__ = cuFileSetParameterString(<_StringConfigParameter>param, <const char*>desc_str) 1zA
3853 check_status(__status__) 1zA
3856cpdef tuple get_parameter_min_max_value(int param):
3857 """Get both the minimum and maximum settable values for a given size_t parameter in a single call.
3860 Args:
3861 param (SizeTConfigParameter): CUfile SizeT configuration
3862 parameter.
3864 Returns:
3865 A 2-tuple containing:
3866 - size_t: Pointer to store the minimum value.
3867 - size_t: Pointer to store the maximum value.
3869 .. seealso:: `cuFileGetParameterMinMaxValue`
3870 """
3871 cdef size_t min_value
3872 cdef size_t max_value
3873 with nogil: 1;?
3874 __status__ = cuFileGetParameterMinMaxValue(<_SizeTConfigParameter>param, &min_value, &max_value) 1;?
3875 check_status(__status__) 1;?
3876 return (min_value, max_value) 1;?
3879cpdef set_stats_level(int level):
3880 """Set the level of statistics collection for cuFile operations. This will override the cufile.json settings for stats.
3883 Args:
3884 level (int): Statistics level (0 = disabled, 1 = basic, 2 =
3885 detailed, 3 = verbose).
3887 .. note::
3888 Higher stats levels may impact performance. Level 0 disables statistics.
3889 .. note::
3890 Changes to stats level take effect for future operations.
3891 .. seealso:: `cuFileSetStatsLevel`
3892 """
3893 with nogil: 1fLbMdNDPQRgScTeUEWXY
3894 __status__ = cuFileSetStatsLevel(level) 1fLbMdNDPQRgScTeUEWXY
3895 check_status(__status__) 1fLbMdNDPQRgScTeUEWXY
3898cpdef int get_stats_level() except? 0:
3899 """Get the current level of statistics collection for cuFile operations.
3902 Returns:
3903 int: Pointer to store the current statistics level.
3905 .. seealso:: `cuFileGetStatsLevel`
3906 """
3907 cdef int level
3908 with nogil: 1Z01D23456E78
3909 __status__ = cuFileGetStatsLevel(&level) 1Z01D23456E78
3910 check_status(__status__) 1Z01D23456E78
3911 return level 1Z01D23456E78
3914cpdef stats_start():
3915 """Start collecting cuFile statistics.
3918 .. note::
3919 Statistics level must be set using cuFileSetStatsLevel before calling this
3920 function.
3921 .. seealso:: `cuFileStatsStart`
3922 """
3923 with nogil: 1fbdQgceX
3924 __status__ = cuFileStatsStart() 1fbdQgceX
3925 check_status(__status__) 1fbdQgceX
3928cpdef stats_stop():
3929 """Stop collecting cuFile statistics.
3932 .. seealso:: `cuFileStatsStop`
3933 """
3934 with nogil: 1fbdQgceX
3935 __status__ = cuFileStatsStop() 1fbdQgceX
3936 check_status(__status__) 1fbdQgceX
3939cpdef stats_reset():
3940 """Reset all cuFile statistics counters.
3943 .. seealso:: `cuFileStatsReset`
3944 """
3945 with nogil: 1LMNPRSTUWY
3946 __status__ = cuFileStatsReset() 1LMNPRSTUWY
3947 check_status(__status__) 1LMNPRSTUWY
3950cpdef get_stats_l1(stats):
3951 """Get Level 1 cuFile statistics.
3954 Args:
3955 stats (intptr_t): Pointer to ``CUfileStatsLevel1_t`` structure to
3956 be filled.
3958 .. seealso:: `cuFileGetStatsL1`
3959 """
3960 cdef intptr_t _stats_ptr_ = 0 if stats is None else int(stats) 1fg
3961 with nogil: 1fg
3962 __status__ = cuFileGetStatsL1(<CUfileStatsLevel1_t*>_stats_ptr_) 1fg
3963 check_status(__status__) 1fg
3966cpdef get_stats_l2(stats):
3967 """Get Level 2 cuFile statistics.
3970 Args:
3971 stats (intptr_t): Pointer to ``CUfileStatsLevel2_t`` structure to
3972 be filled.
3974 .. seealso:: `cuFileGetStatsL2`
3975 """
3976 cdef intptr_t _stats_ptr_ = 0 if stats is None else int(stats) 1bc
3977 with nogil: 1bc
3978 __status__ = cuFileGetStatsL2(<CUfileStatsLevel2_t*>_stats_ptr_) 1bc
3979 check_status(__status__) 1bc
3982cpdef get_stats_l3(stats):
3983 """Get Level 3 cuFile statistics.
3986 Args:
3987 stats (intptr_t): Pointer to ``CUfileStatsLevel3_t`` structure to
3988 be filled.
3990 .. seealso:: `cuFileGetStatsL3`
3991 """
3992 cdef intptr_t _stats_ptr_ = 0 if stats is None else int(stats) 1de
3993 with nogil: 1de
3994 __status__ = cuFileGetStatsL3(<CUfileStatsLevel3_t*>_stats_ptr_) 1de
3995 check_status(__status__) 1de
3998cpdef size_t get_bar_size_in_kb(int gpu_index) except? 0:
3999 cdef size_t bar_size
4000 with nogil: 1:=
4001 __status__ = cuFileGetBARSizeInKB(gpu_index, &bar_size) 1:=
4002 check_status(__status__) 1:=
4003 return bar_size 1:=
4006cpdef set_parameter_posix_pool_slab_array(intptr_t size_values, intptr_t count_values, int len):
4007 """Set both POSIX pool slab size and count parameters as a pair.
4010 Args:
4011 size_values (intptr_t): Array of slab sizes in KB.
4012 count_values (intptr_t): Array of slab counts.
4013 len (int): Length of both arrays (must be the same).
4015 .. seealso:: `cuFileSetParameterPosixPoolSlabArray`
4016 """
4017 with nogil: 1(/
4018 __status__ = cuFileSetParameterPosixPoolSlabArray(<const size_t*>size_values, <const size_t*>count_values, len) 1(/
4019 check_status(__status__) 1(/
4022cpdef get_parameter_posix_pool_slab_array(intptr_t size_values, intptr_t count_values, int len):
4023 """Get both POSIX pool slab size and count parameters as a pair.
4026 Args:
4027 size_values (intptr_t): Buffer to receive slab sizes in KB.
4028 count_values (intptr_t): Buffer to receive slab counts.
4029 len (int): Buffer size (must match the actual parameter length).
4031 .. seealso:: `cuFileGetParameterPosixPoolSlabArray`
4032 """
4033 with nogil: 1OV
4034 __status__ = cuFileGetParameterPosixPoolSlabArray(<size_t*>size_values, <size_t*>count_values, len) 1OV
4035 check_status(__status__) 1OV
4040cpdef str op_status_error(int status):
4041 """cufileop status string.
4043 Args:
4044 status (OpError): the error status to query.
4046 .. seealso:: `cufileop_status_error`
4047 """
4048 cdef bytes _output_
4049 _output_ = cufileop_status_error(<_OpError>status) 1HzDIAE
4050 return _output_.decode() 1HzDIAE
4053cpdef driver_close():
4054 """reset the cuFile library and release the nvidia-fs driver
4055 """
4056 with nogil: 2[ ^ ` | ~ bbdbfbhbjblbnbpbrb' tbvbxbL M N zbF J z O AbP R Cb) DbFbHbJbLbNbPbRbTbVbXbZb1b3b5b7bS T U 9bG K A V !bW Y
4057 status = cuFileDriverClose_v2() 2[ ^ ` | ~ bbdbfbhbjblbnbpbrb' tbvbxbL M N zbF J z O AbP R Cb) DbFbHbJbLbNbPbRbTbVbXbZb1b3b5b7bS T U 9bG K A V !bW Y
4058 check_status(status) 2[ ^ ` | ~ bbdbfbhbjblbnbpbrb' tbvbxbL M N zbF J z O AbP R Cb) DbFbHbJbLbNbPbRbTbVbXbZb1b3b5b7bS T U 9bG K A V !bW Y
4060cpdef read(intptr_t fh, intptr_t buf_ptr_base, size_t size, off_t file_offset, off_t buf_ptr_offset):
4061 """read data from a registered file handle to a specified device or host memory.
4063 Args:
4064 fh (intptr_t): ``CUfileHandle_t`` opaque file handle.
4065 buf_ptr_base (intptr_t): base address of buffer in device or host memory.
4066 size (size_t): size bytes to read.
4067 file_offset (off_t): file-offset from begining of the file.
4068 buf_ptr_offset (off_t): offset relative to the buf_ptr_base pointer to read into.
4070 Returns:
4071 ssize_t: number of bytes read on success.
4073 .. seealso:: `cuFileRead`
4074 """
4075 with nogil: 1qrsfbdvwxgce
4076 status = cuFileRead(<Handle>fh, <void*>buf_ptr_base, size, file_offset, buf_ptr_offset) 1qrsfbdvwxgce
4077 check_status(status) 1qrsfbdvwxgce
4078 return status 1qrsfbdvwxgce
4081cpdef write(intptr_t fh, intptr_t buf_ptr_base, size_t size, off_t file_offset, off_t buf_ptr_offset):
4082 """write data from a specified device or host memory to a registered file handle.
4084 Args:
4085 fh (intptr_t): ``CUfileHandle_t`` opaque file handle.
4086 buf_ptr_base (intptr_t): base address of buffer in device or host memory.
4087 size (size_t): size bytes to write.
4088 file_offset (off_t): file-offset from begining of the file.
4089 buf_ptr_offset (off_t): offset relative to the buf_ptr_base pointer to write from.
4091 Returns:
4092 ssize_t: number of bytes written on success.
4094 .. seealso:: `cuFileWrite`
4095 """
4096 with nogil: 1qrsfbdvwxgce
4097 status = cuFileWrite(<Handle>fh, <const void*>buf_ptr_base, size, file_offset, buf_ptr_offset) 1qrsfbdvwxgce
4098 check_status(status) 1qrsfbdvwxgce
4099 return status 1qrsfbdvwxgce
4102cpdef readv(intptr_t fh, IOVec iov, off_t file_offset, unsigned int flags=0):
4103 """Read data from a registered file handle into a scatter list of device or host buffers.
4105 Args:
4106 fh (intptr_t): ``CUfileHandle_t`` opaque file handle.
4107 iov (IOVec): scatter/gather descriptor array; each element specifies a
4108 base pointer (device or host) and a byte length.
4109 file_offset (off_t): file offset from the beginning of the file.
4110 flags (unsigned int): reserved; must be 0.
4112 Returns:
4113 ssize_t: number of bytes read on success.
4115 .. seealso:: `cuFileReadv`
4116 """
4117 cdef intptr_t iov_ptr = (<IOVec>iov)._get_ptr()
4118 cdef size_t iovcnt = len(iov)
4119 with nogil:
4120 status = cuFileReadv(<Handle>fh, <const CUfileIOVec_t*>iov_ptr, iovcnt, file_offset, flags)
4121 check_status(status)
4122 return status
4125cpdef writev(intptr_t fh, IOVec iov, off_t file_offset, unsigned int flags=0):
4126 """Write data to a registered file handle from a gather list of device or host buffers.
4128 Args:
4129 fh (intptr_t): ``CUfileHandle_t`` opaque file handle.
4130 iov (IOVec): scatter/gather descriptor array; each element specifies a
4131 base pointer (device or host) and a byte length.
4132 file_offset (off_t): file offset from the beginning of the file.
4133 flags (unsigned int): reserved; must be 0.
4135 Returns:
4136 ssize_t: number of bytes written on success.
4138 .. seealso:: `cuFileWritev`
4139 """
4140 cdef intptr_t iov_ptr = (<IOVec>iov)._get_ptr()
4141 cdef size_t iovcnt = len(iov)
4142 with nogil:
4143 status = cuFileWritev(<Handle>fh, <const CUfileIOVec_t*>iov_ptr, iovcnt, file_offset, flags)
4144 check_status(status)
4145 return status
4146del _cyb_FastEnum