Coverage for cuda/bindings/cufile.pyx: 44.28%
1538 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-19 01:12 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-19 01:12 +0000
1# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2#
3# SPDX-License-Identifier: Apache-2.0
4#
5# This code was automatically generated across versions from 12.9.1 to 13.3.0. Do not modify it directly.
6# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=4567ca64d02631fc8d6ed11af8164d72c86b4686c105fd733d186e6c92512749
9# <<<< PREAMBLE CONTENT >>>>
11cimport cpython as _cyb_cpython
12cimport cpython.buffer as _cyb_cpython_buffer
13cimport cpython.memoryview as _cyb_cpython_memoryview
14from cython cimport view as _cyb_view
15from libc.stdlib cimport (
16 calloc as _cyb_calloc,
17 free as _cyb_free,
18 malloc as _cyb_malloc,
19)
20from libc.string cimport (
21 memcmp as _cyb_memcmp,
22 memcpy as _cyb_memcpy,
23)
25from cuda.bindings._internal._fast_enum import FastEnum as _cyb_FastEnum
27import numpy as _numpy
29cdef _cyb___getbuffer(object self, _cyb_cpython.Py_buffer *buffer, void *ptr, int size, bint readonly):
30 buffer.buf = <char *>ptr
31 buffer.format = 'b'
32 buffer.internal = NULL
33 buffer.itemsize = 1
34 buffer.len = size
35 buffer.ndim = 1
36 buffer.obj = self
37 buffer.readonly = readonly
38 buffer.shape = &buffer.len
39 buffer.strides = &buffer.itemsize
40 buffer.suboffsets = NULL
42cdef _cyb_from_buffer(buffer, size, lowpp_type):
43 cdef _cyb_cpython.Py_buffer view
44 if _cyb_cpython.PyObject_GetBuffer(buffer, &view, _cyb_cpython_buffer.PyBUF_SIMPLE) != 0:
45 raise TypeError("buffer argument does not support the buffer protocol")
46 try:
47 if view.itemsize != 1:
48 raise ValueError("buffer itemsize must be 1 byte")
49 if view.len != size:
50 raise ValueError(f"buffer length must be {size} bytes")
51 return lowpp_type.from_ptr(<intptr_t><void *>view.buf, not view.readonly, buffer)
52 finally:
53 _cyb_cpython.PyBuffer_Release(&view)
55cdef _cyb_from_data(data, dtype_name, expected_dtype, lowpp_type):
56 # _numpy.recarray is a subclass of _numpy.ndarray, so implicitly handled here.
57 if isinstance(data, lowpp_type): 1fcb
58 return data 1fcb
59 if not isinstance(data, _numpy.ndarray):
60 raise TypeError("data argument must be a NumPy ndarray")
61 if data.size != 1:
62 raise ValueError("data array must have a size of 1")
63 if data.dtype != expected_dtype:
64 raise ValueError(f"data array must be of dtype {dtype_name}")
65 return lowpp_type.from_ptr(data.ctypes.data, not data.flags.writeable, data)
68# <<<< END OF PREAMBLE CONTENT >>>>
70cimport cython # NOQA
71from libc cimport errno
72from ._internal.utils cimport (get_buffer_pointer, get_nested_resource_ptr,
73 nested_resource)
75import cython
77from cuda.bindings.driver import CUresult as pyCUresult
79###############################################################################
80# POD
81###############################################################################
83_py_anon_pod1_dtype = _numpy.dtype((
84 _numpy.dtype((_numpy.void, sizeof((<CUfileDescr_t*>NULL).handle))),
85 {
86 "fd": (_numpy.int32, 0),
87 "handle": (_numpy.intp, 0),
88 }
89 ))
91cdef class _py_anon_pod1:
92 """Empty-initialize an instance of `cuda_bindings_cufile__anon_pod1`.
95 .. seealso:: `cuda_bindings_cufile__anon_pod1`
96 """
97 cdef:
98 cuda_bindings_cufile__anon_pod1 *_ptr
99 object _owner
100 bint _owned
101 bint _readonly
103 def __init__(self):
104 self._ptr = <cuda_bindings_cufile__anon_pod1 *>_cyb_calloc(1, sizeof((<CUfileDescr_t*>NULL).handle))
105 if self._ptr == NULL:
106 raise MemoryError("Error allocating _py_anon_pod1")
107 self._owner = None
108 self._owned = True
109 self._readonly = False
111 def __dealloc__(self):
112 cdef cuda_bindings_cufile__anon_pod1 *ptr
113 if self._owned and self._ptr != NULL:
114 ptr = self._ptr
115 self._ptr = NULL
116 _cyb_free(ptr)
118 def __repr__(self):
119 return f"<{__name__}._py_anon_pod1 object at {hex(id(self))}>"
121 @property
122 def ptr(self):
123 """Get the pointer address to the data as Python :class:`int`."""
124 return <intptr_t>(self._ptr)
126 cdef intptr_t _get_ptr(self):
127 return <intptr_t>(self._ptr)
129 def __int__(self):
130 return <intptr_t>(self._ptr)
132 def __eq__(self, other):
133 cdef _py_anon_pod1 other_
134 if not isinstance(other, _py_anon_pod1):
135 return False
136 other_ = other
137 return (_cyb_memcmp(<void *><intptr_t>(self._ptr), <void *><intptr_t>(other_._ptr), sizeof((<CUfileDescr_t*>NULL).handle)) == 0)
139 def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags):
140 _cyb___getbuffer(self, buffer, <void *>self._ptr, sizeof((<CUfileDescr_t*>NULL).handle), self._readonly)
142 def __releasebuffer__(self, Py_buffer *buffer):
143 pass
145 def __setitem__(self, key, val):
146 if key == 0 and isinstance(val, _numpy.ndarray):
147 self._ptr = <cuda_bindings_cufile__anon_pod1 *>_cyb_malloc(sizeof((<CUfileDescr_t*>NULL).handle))
148 if self._ptr == NULL:
149 raise MemoryError("Error allocating _py_anon_pod1")
150 _cyb_memcpy(<void*>self._ptr, <void*><intptr_t>val.ctypes.data, sizeof((<CUfileDescr_t*>NULL).handle))
151 self._owner = None
152 self._owned = True
153 self._readonly = not val.flags.writeable
154 else:
155 setattr(self, key, val)
157 @property
158 def fd(self):
159 """int: """
160 return self._ptr[0].fd
162 @fd.setter
163 def fd(self, val):
164 if self._readonly:
165 raise ValueError("This _py_anon_pod1 instance is read-only")
166 self._ptr[0].fd = val
168 @property
169 def handle(self):
170 """int: """
171 return <intptr_t>(self._ptr[0].handle)
173 @handle.setter
174 def handle(self, val):
175 if self._readonly:
176 raise ValueError("This _py_anon_pod1 instance is read-only")
177 self._ptr[0].handle = <void *><intptr_t>val
179 @staticmethod
180 def from_buffer(buffer):
181 """Create an _py_anon_pod1 instance with the memory from the given buffer."""
182 return _cyb_from_buffer(buffer, sizeof((<CUfileDescr_t*>NULL).handle), _py_anon_pod1)
184 @staticmethod
185 def from_data(data):
186 """Create an _py_anon_pod1 instance wrapping the given NumPy array.
188 Args:
189 data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod1_dtype` holding the data.
190 """
191 return _cyb_from_data(data, "_py_anon_pod1_dtype", _py_anon_pod1_dtype, _py_anon_pod1)
193 @staticmethod
194 def from_ptr(intptr_t ptr, bint readonly=False, object owner=None):
195 """Create an _py_anon_pod1 instance wrapping the given pointer.
197 Args:
198 ptr (intptr_t): pointer address as Python :class:`int` to the data.
199 owner (object): The Python object that owns the pointer. If not provided, data will be copied.
200 readonly (bool): whether the data is read-only (to the user). default is `False`.
201 """
202 if ptr == 0:
203 raise ValueError("ptr must not be null (0)")
204 cdef _py_anon_pod1 obj = _py_anon_pod1.__new__(_py_anon_pod1)
205 if owner is None:
206 obj._ptr = <cuda_bindings_cufile__anon_pod1 *>_cyb_malloc(sizeof((<CUfileDescr_t*>NULL).handle))
207 if obj._ptr == NULL:
208 raise MemoryError("Error allocating _py_anon_pod1")
209 _cyb_memcpy(<void*>(obj._ptr), <void*>ptr, sizeof((<CUfileDescr_t*>NULL).handle))
210 obj._owner = None
211 obj._owned = True
212 else:
213 obj._ptr = <cuda_bindings_cufile__anon_pod1 *>ptr
214 obj._owner = owner
215 obj._owned = False
216 obj._readonly = readonly
217 return obj
220cdef _get__py_anon_pod3_dtype_offsets():
221 cdef cuda_bindings_cufile__anon_pod3 pod
222 return _numpy.dtype({
223 'names': ['dev_ptr_base', 'file_offset', 'dev_ptr_offset', 'size_'],
224 'formats': [_numpy.intp, _numpy.int64, _numpy.int64, _numpy.uint64],
225 'offsets': [
226 (<intptr_t>&(pod.devPtr_base)) - (<intptr_t>&pod),
227 (<intptr_t>&(pod.file_offset)) - (<intptr_t>&pod),
228 (<intptr_t>&(pod.devPtr_offset)) - (<intptr_t>&pod),
229 (<intptr_t>&(pod.size)) - (<intptr_t>&pod),
230 ],
231 'itemsize': sizeof((<CUfileIOParams_t*>NULL).u.batch),
232 })
234_py_anon_pod3_dtype = _get__py_anon_pod3_dtype_offsets()
236cdef class _py_anon_pod3:
237 """Empty-initialize an instance of `cuda_bindings_cufile__anon_pod3`.
240 .. seealso:: `cuda_bindings_cufile__anon_pod3`
241 """
242 cdef:
243 cuda_bindings_cufile__anon_pod3 *_ptr
244 object _owner
245 bint _owned
246 bint _readonly
248 def __init__(self):
249 self._ptr = <cuda_bindings_cufile__anon_pod3 *>_cyb_calloc(1, sizeof((<CUfileIOParams_t*>NULL).u.batch))
250 if self._ptr == NULL:
251 raise MemoryError("Error allocating _py_anon_pod3")
252 self._owner = None
253 self._owned = True
254 self._readonly = False
256 def __dealloc__(self):
257 cdef cuda_bindings_cufile__anon_pod3 *ptr
258 if self._owned and self._ptr != NULL:
259 ptr = self._ptr
260 self._ptr = NULL
261 _cyb_free(ptr)
263 def __repr__(self):
264 return f"<{__name__}._py_anon_pod3 object at {hex(id(self))}>"
266 @property
267 def ptr(self):
268 """Get the pointer address to the data as Python :class:`int`."""
269 return <intptr_t>(self._ptr)
271 cdef intptr_t _get_ptr(self):
272 return <intptr_t>(self._ptr)
274 def __int__(self):
275 return <intptr_t>(self._ptr)
277 def __eq__(self, other):
278 cdef _py_anon_pod3 other_
279 if not isinstance(other, _py_anon_pod3):
280 return False
281 other_ = other
282 return (_cyb_memcmp(<void *><intptr_t>(self._ptr), <void *><intptr_t>(other_._ptr), sizeof((<CUfileIOParams_t*>NULL).u.batch)) == 0)
284 def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags):
285 _cyb___getbuffer(self, buffer, <void *>self._ptr, sizeof((<CUfileIOParams_t*>NULL).u.batch), self._readonly)
287 def __releasebuffer__(self, Py_buffer *buffer):
288 pass
290 def __setitem__(self, key, val):
291 if key == 0 and isinstance(val, _numpy.ndarray):
292 self._ptr = <cuda_bindings_cufile__anon_pod3 *>_cyb_malloc(sizeof((<CUfileIOParams_t*>NULL).u.batch))
293 if self._ptr == NULL:
294 raise MemoryError("Error allocating _py_anon_pod3")
295 _cyb_memcpy(<void*>self._ptr, <void*><intptr_t>val.ctypes.data, sizeof((<CUfileIOParams_t*>NULL).u.batch))
296 self._owner = None
297 self._owned = True
298 self._readonly = not val.flags.writeable
299 else:
300 setattr(self, key, val)
302 @property
303 def dev_ptr_base(self):
304 """int: """
305 return <intptr_t>(self._ptr[0].devPtr_base)
307 @dev_ptr_base.setter
308 def dev_ptr_base(self, val):
309 if self._readonly:
310 raise ValueError("This _py_anon_pod3 instance is read-only")
311 self._ptr[0].devPtr_base = <void *><intptr_t>val
313 @property
314 def file_offset(self):
315 """int: """
316 return self._ptr[0].file_offset
318 @file_offset.setter
319 def file_offset(self, val):
320 if self._readonly:
321 raise ValueError("This _py_anon_pod3 instance is read-only")
322 self._ptr[0].file_offset = val
324 @property
325 def dev_ptr_offset(self):
326 """int: """
327 return self._ptr[0].devPtr_offset
329 @dev_ptr_offset.setter
330 def dev_ptr_offset(self, val):
331 if self._readonly:
332 raise ValueError("This _py_anon_pod3 instance is read-only")
333 self._ptr[0].devPtr_offset = val
335 @property
336 def size_(self):
337 """int: """
338 return self._ptr[0].size
340 @size_.setter
341 def size_(self, val):
342 if self._readonly:
343 raise ValueError("This _py_anon_pod3 instance is read-only")
344 self._ptr[0].size = val
346 @staticmethod
347 def from_buffer(buffer):
348 """Create an _py_anon_pod3 instance with the memory from the given buffer."""
349 return _cyb_from_buffer(buffer, sizeof((<CUfileIOParams_t*>NULL).u.batch), _py_anon_pod3)
351 @staticmethod
352 def from_data(data):
353 """Create an _py_anon_pod3 instance wrapping the given NumPy array.
355 Args:
356 data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod3_dtype` holding the data.
357 """
358 return _cyb_from_data(data, "_py_anon_pod3_dtype", _py_anon_pod3_dtype, _py_anon_pod3)
360 @staticmethod
361 def from_ptr(intptr_t ptr, bint readonly=False, object owner=None):
362 """Create an _py_anon_pod3 instance wrapping the given pointer.
364 Args:
365 ptr (intptr_t): pointer address as Python :class:`int` to the data.
366 owner (object): The Python object that owns the pointer. If not provided, data will be copied.
367 readonly (bool): whether the data is read-only (to the user). default is `False`.
368 """
369 if ptr == 0:
370 raise ValueError("ptr must not be null (0)")
371 cdef _py_anon_pod3 obj = _py_anon_pod3.__new__(_py_anon_pod3)
372 if owner is None:
373 obj._ptr = <cuda_bindings_cufile__anon_pod3 *>_cyb_malloc(sizeof((<CUfileIOParams_t*>NULL).u.batch))
374 if obj._ptr == NULL:
375 raise MemoryError("Error allocating _py_anon_pod3")
376 _cyb_memcpy(<void*>(obj._ptr), <void*>ptr, sizeof((<CUfileIOParams_t*>NULL).u.batch))
377 obj._owner = None
378 obj._owned = True
379 else:
380 obj._ptr = <cuda_bindings_cufile__anon_pod3 *>ptr
381 obj._owner = owner
382 obj._owned = False
383 obj._readonly = readonly
384 return obj
387cdef _get_io_events_dtype_offsets():
388 cdef CUfileIOEvents_t pod
389 return _numpy.dtype({
390 'names': ['cookie', 'status', 'ret'],
391 'formats': [_numpy.intp, _numpy.int32, _numpy.uint64],
392 'offsets': [
393 (<intptr_t>&(pod.cookie)) - (<intptr_t>&pod),
394 (<intptr_t>&(pod.status)) - (<intptr_t>&pod),
395 (<intptr_t>&(pod.ret)) - (<intptr_t>&pod),
396 ],
397 'itemsize': sizeof(CUfileIOEvents_t),
398 })
400io_events_dtype = _get_io_events_dtype_offsets()
402cdef class IOEvents:
403 """Empty-initialize an array of `CUfileIOEvents_t`.
404 The resulting object is of length `size` and of dtype `io_events_dtype`.
405 If default-constructed, the instance represents a single struct.
407 Args:
408 size (int): number of structs, default=1.
410 .. seealso:: `CUfileIOEvents_t`
411 """
412 cdef:
413 readonly object _data
415 def __init__(self, size=1):
416 arr = _numpy.empty(size, dtype=io_events_dtype) 1de
417 self._data = arr.view(_numpy.recarray) 1de
418 assert self._data.itemsize == sizeof(CUfileIOEvents_t), \ 1de
419 f"itemsize {self._data.itemsize} mismatches struct size { sizeof(CUfileIOEvents_t) }"
421 def __repr__(self):
422 if self._data.size > 1:
423 return f"<{__name__}.IOEvents_Array_{self._data.size} object at {hex(id(self))}>"
424 else:
425 return f"<{__name__}.IOEvents object at {hex(id(self))}>"
427 @property
428 def ptr(self):
429 """Get the pointer address to the data as Python :class:`int`."""
430 return self._data.ctypes.data 1de
432 cdef intptr_t _get_ptr(self):
433 return self._data.ctypes.data
435 def __int__(self):
436 if self._data.size > 1:
437 raise TypeError("int() argument must be a bytes-like object of size 1. "
438 "To get the pointer address of an array, use .ptr")
439 return self._data.ctypes.data
441 def __len__(self):
442 return self._data.size
444 def __eq__(self, other):
445 cdef object self_data = self._data
446 if (not isinstance(other, IOEvents)) or self_data.size != other._data.size or self_data.dtype != other._data.dtype:
447 return False
448 return bool((self_data == other._data).all())
450 def __getbuffer__(self, Py_buffer *buffer, int flags):
451 _cyb_cpython.PyObject_GetBuffer(self._data, buffer, flags)
453 def __releasebuffer__(self, Py_buffer *buffer):
454 _cyb_cpython.PyBuffer_Release(buffer)
456 @property
457 def cookie(self):
458 """Union[~_numpy.intp, int]: """
459 if self._data.size == 1: 1de
460 return int(self._data.cookie[0]) 1de
461 return self._data.cookie
463 @cookie.setter
464 def cookie(self, val):
465 self._data.cookie = val
467 @property
468 def status(self):
469 """Union[~_numpy.int32, int]: """
470 if self._data.size == 1: 1de
471 return int(self._data.status[0]) 1de
472 return self._data.status
474 @status.setter
475 def status(self, val):
476 self._data.status = val
478 @property
479 def ret(self):
480 """Union[~_numpy.uint64, int]: """
481 if self._data.size == 1: 1d
482 return int(self._data.ret[0]) 1d
483 return self._data.ret
485 @ret.setter
486 def ret(self, val):
487 self._data.ret = val
489 def __getitem__(self, key):
490 cdef ssize_t key_
491 cdef ssize_t size
492 if isinstance(key, int): 1de
493 key_ = key 1de
494 size = self._data.size 1de
495 if key_ >= size or key_ <= -(size+1): 1de
496 raise IndexError("index is out of bounds")
497 if key_ < 0: 1de
498 key_ += size
499 return IOEvents.from_data(self._data[key_:key_+1]) 1de
500 out = self._data[key]
501 if isinstance(out, _numpy.recarray) and out.dtype == io_events_dtype:
502 return IOEvents.from_data(out)
503 return out
505 def __setitem__(self, key, val):
506 self._data[key] = val
508 @staticmethod
509 def from_buffer(buffer):
510 """Create an IOEvents instance with the memory from the given buffer."""
511 return IOEvents.from_data(_numpy.frombuffer(buffer, dtype=io_events_dtype))
513 @staticmethod
514 def from_data(data):
515 """Create an IOEvents instance wrapping the given NumPy array.
517 Args:
518 data (_numpy.ndarray): a 1D array of dtype `io_events_dtype` holding the data.
519 """
520 cdef IOEvents obj = IOEvents.__new__(IOEvents) 1de
521 if not isinstance(data, _numpy.ndarray): 1de
522 raise TypeError("data argument must be a NumPy ndarray")
523 if data.ndim != 1: 1de
524 raise ValueError("data array must be 1D")
525 if data.dtype != io_events_dtype: 1de
526 raise ValueError("data array must be of dtype io_events_dtype")
527 obj._data = data.view(_numpy.recarray) 1de
529 return obj 1de
531 @staticmethod
532 def from_ptr(intptr_t ptr, size_t size=1, bint readonly=False):
533 """Create an IOEvents instance wrapping the given pointer.
535 Args:
536 ptr (intptr_t): pointer address as Python :class:`int` to the data.
537 size (int): number of structs, default=1.
538 readonly (bool): whether the data is read-only (to the user). default is `False`.
539 """
540 if ptr == 0:
541 raise ValueError("ptr must not be null (0)")
542 cdef IOEvents obj = IOEvents.__new__(IOEvents)
543 cdef flag = _cyb_cpython_buffer.PyBUF_READ if readonly else _cyb_cpython_buffer.PyBUF_WRITE
544 cdef object buf = _cyb_cpython_memoryview.PyMemoryView_FromMemory(
545 <char*>ptr, sizeof(CUfileIOEvents_t) * size, flag)
546 data = _numpy.ndarray(size, buffer=buf, dtype=io_events_dtype)
547 obj._data = data.view(_numpy.recarray)
549 return obj
552cdef _get_op_counter_dtype_offsets():
553 cdef CUfileOpCounter_t pod
554 return _numpy.dtype({
555 'names': ['ok', 'err'],
556 'formats': [_numpy.uint64, _numpy.uint64],
557 'offsets': [
558 (<intptr_t>&(pod.ok)) - (<intptr_t>&pod),
559 (<intptr_t>&(pod.err)) - (<intptr_t>&pod),
560 ],
561 'itemsize': sizeof(CUfileOpCounter_t),
562 })
564op_counter_dtype = _get_op_counter_dtype_offsets()
566cdef class OpCounter:
567 """Empty-initialize an instance of `CUfileOpCounter_t`.
570 .. seealso:: `CUfileOpCounter_t`
571 """
572 cdef:
573 CUfileOpCounter_t *_ptr
574 object _owner
575 bint _owned
576 bint _readonly
578 def __init__(self):
579 self._ptr = <CUfileOpCounter_t *>_cyb_calloc(1, sizeof(CUfileOpCounter_t))
580 if self._ptr == NULL:
581 raise MemoryError("Error allocating OpCounter")
582 self._owner = None
583 self._owned = True
584 self._readonly = False
586 def __dealloc__(self):
587 cdef CUfileOpCounter_t *ptr
588 if self._owned and self._ptr != NULL: 1fc
589 ptr = self._ptr
590 self._ptr = NULL
591 _cyb_free(ptr)
593 def __repr__(self):
594 return f"<{__name__}.OpCounter object at {hex(id(self))}>"
596 @property
597 def ptr(self):
598 """Get the pointer address to the data as Python :class:`int`."""
599 return <intptr_t>(self._ptr)
601 cdef intptr_t _get_ptr(self):
602 return <intptr_t>(self._ptr)
604 def __int__(self):
605 return <intptr_t>(self._ptr)
607 def __eq__(self, other):
608 cdef OpCounter other_
609 if not isinstance(other, OpCounter):
610 return False
611 other_ = other
612 return (_cyb_memcmp(<void *><intptr_t>(self._ptr), <void *><intptr_t>(other_._ptr), sizeof(CUfileOpCounter_t)) == 0)
614 def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags):
615 _cyb___getbuffer(self, buffer, <void *>self._ptr, sizeof(CUfileOpCounter_t), self._readonly)
617 def __releasebuffer__(self, Py_buffer *buffer):
618 pass
620 def __setitem__(self, key, val):
621 if key == 0 and isinstance(val, _numpy.ndarray):
622 self._ptr = <CUfileOpCounter_t *>_cyb_malloc(sizeof(CUfileOpCounter_t))
623 if self._ptr == NULL:
624 raise MemoryError("Error allocating OpCounter")
625 _cyb_memcpy(<void*>self._ptr, <void*><intptr_t>val.ctypes.data, sizeof(CUfileOpCounter_t))
626 self._owner = None
627 self._owned = True
628 self._readonly = not val.flags.writeable
629 else:
630 setattr(self, key, val)
632 @property
633 def ok(self):
634 """int: """
635 return self._ptr[0].ok 1fc
637 @ok.setter
638 def ok(self, val):
639 if self._readonly:
640 raise ValueError("This OpCounter instance is read-only")
641 self._ptr[0].ok = val
643 @property
644 def err(self):
645 """int: """
646 return self._ptr[0].err
648 @err.setter
649 def err(self, val):
650 if self._readonly:
651 raise ValueError("This OpCounter instance is read-only")
652 self._ptr[0].err = val
654 @staticmethod
655 def from_buffer(buffer):
656 """Create an OpCounter instance with the memory from the given buffer."""
657 return _cyb_from_buffer(buffer, sizeof(CUfileOpCounter_t), OpCounter)
659 @staticmethod
660 def from_data(data):
661 """Create an OpCounter instance wrapping the given NumPy array.
663 Args:
664 data (_numpy.ndarray): a single-element array of dtype `op_counter_dtype` holding the data.
665 """
666 return _cyb_from_data(data, "op_counter_dtype", op_counter_dtype, OpCounter) 1fc
668 @staticmethod
669 def from_ptr(intptr_t ptr, bint readonly=False, object owner=None):
670 """Create an OpCounter instance wrapping the given pointer.
672 Args:
673 ptr (intptr_t): pointer address as Python :class:`int` to the data.
674 owner (object): The Python object that owns the pointer. If not provided, data will be copied.
675 readonly (bool): whether the data is read-only (to the user). default is `False`.
676 """
677 if ptr == 0: 1fc
678 raise ValueError("ptr must not be null (0)")
679 cdef OpCounter obj = OpCounter.__new__(OpCounter) 1fc
680 if owner is None: 1fc
681 obj._ptr = <CUfileOpCounter_t *>_cyb_malloc(sizeof(CUfileOpCounter_t))
682 if obj._ptr == NULL:
683 raise MemoryError("Error allocating OpCounter")
684 _cyb_memcpy(<void*>(obj._ptr), <void*>ptr, sizeof(CUfileOpCounter_t))
685 obj._owner = None
686 obj._owned = True
687 else:
688 obj._ptr = <CUfileOpCounter_t *>ptr 1fc
689 obj._owner = owner 1fc
690 obj._owned = False 1fc
691 obj._readonly = readonly 1fc
692 return obj 1fc
695cdef _get_per_gpu_stats_dtype_offsets():
696 cdef CUfilePerGpuStats_t pod
697 return _numpy.dtype({
698 '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'],
699 '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],
700 'offsets': [
701 (<intptr_t>&(pod.uuid)) - (<intptr_t>&pod),
702 (<intptr_t>&(pod.read_bytes)) - (<intptr_t>&pod),
703 (<intptr_t>&(pod.read_bw_bytes_per_sec)) - (<intptr_t>&pod),
704 (<intptr_t>&(pod.read_utilization)) - (<intptr_t>&pod),
705 (<intptr_t>&(pod.read_duration_us)) - (<intptr_t>&pod),
706 (<intptr_t>&(pod.n_total_reads)) - (<intptr_t>&pod),
707 (<intptr_t>&(pod.n_p2p_reads)) - (<intptr_t>&pod),
708 (<intptr_t>&(pod.n_nvfs_reads)) - (<intptr_t>&pod),
709 (<intptr_t>&(pod.n_posix_reads)) - (<intptr_t>&pod),
710 (<intptr_t>&(pod.n_unaligned_reads)) - (<intptr_t>&pod),
711 (<intptr_t>&(pod.n_dr_reads)) - (<intptr_t>&pod),
712 (<intptr_t>&(pod.n_sparse_regions)) - (<intptr_t>&pod),
713 (<intptr_t>&(pod.n_inline_regions)) - (<intptr_t>&pod),
714 (<intptr_t>&(pod.n_reads_err)) - (<intptr_t>&pod),
715 (<intptr_t>&(pod.writes_bytes)) - (<intptr_t>&pod),
716 (<intptr_t>&(pod.write_bw_bytes_per_sec)) - (<intptr_t>&pod),
717 (<intptr_t>&(pod.write_utilization)) - (<intptr_t>&pod),
718 (<intptr_t>&(pod.write_duration_us)) - (<intptr_t>&pod),
719 (<intptr_t>&(pod.n_total_writes)) - (<intptr_t>&pod),
720 (<intptr_t>&(pod.n_p2p_writes)) - (<intptr_t>&pod),
721 (<intptr_t>&(pod.n_nvfs_writes)) - (<intptr_t>&pod),
722 (<intptr_t>&(pod.n_posix_writes)) - (<intptr_t>&pod),
723 (<intptr_t>&(pod.n_unaligned_writes)) - (<intptr_t>&pod),
724 (<intptr_t>&(pod.n_dr_writes)) - (<intptr_t>&pod),
725 (<intptr_t>&(pod.n_writes_err)) - (<intptr_t>&pod),
726 (<intptr_t>&(pod.n_mmap)) - (<intptr_t>&pod),
727 (<intptr_t>&(pod.n_mmap_ok)) - (<intptr_t>&pod),
728 (<intptr_t>&(pod.n_mmap_err)) - (<intptr_t>&pod),
729 (<intptr_t>&(pod.n_mmap_free)) - (<intptr_t>&pod),
730 (<intptr_t>&(pod.reg_bytes)) - (<intptr_t>&pod),
731 ],
732 'itemsize': sizeof(CUfilePerGpuStats_t),
733 })
735per_gpu_stats_dtype = _get_per_gpu_stats_dtype_offsets()
737cdef class PerGpuStats:
738 """Empty-initialize an array of `CUfilePerGpuStats_t`.
739 The resulting object is of length `size` and of dtype `per_gpu_stats_dtype`.
740 If default-constructed, the instance represents a single struct.
742 Args:
743 size (int): number of structs, default=1.
745 .. seealso:: `CUfilePerGpuStats_t`
746 """
747 cdef:
748 readonly object _data
750 def __init__(self, size=1):
751 arr = _numpy.empty(size, dtype=per_gpu_stats_dtype)
752 self._data = arr.view(_numpy.recarray)
753 assert self._data.itemsize == sizeof(CUfilePerGpuStats_t), \
754 f"itemsize {self._data.itemsize} mismatches struct size { sizeof(CUfilePerGpuStats_t) }"
756 def __repr__(self):
757 if self._data.size > 1:
758 return f"<{__name__}.PerGpuStats_Array_{self._data.size} object at {hex(id(self))}>"
759 else:
760 return f"<{__name__}.PerGpuStats object at {hex(id(self))}>"
762 @property
763 def ptr(self):
764 """Get the pointer address to the data as Python :class:`int`."""
765 return self._data.ctypes.data
767 cdef intptr_t _get_ptr(self):
768 return self._data.ctypes.data
770 def __int__(self):
771 if self._data.size > 1:
772 raise TypeError("int() argument must be a bytes-like object of size 1. "
773 "To get the pointer address of an array, use .ptr")
774 return self._data.ctypes.data
776 def __len__(self):
777 return self._data.size
779 def __eq__(self, other):
780 cdef object self_data = self._data
781 if (not isinstance(other, PerGpuStats)) or self_data.size != other._data.size or self_data.dtype != other._data.dtype:
782 return False
783 return bool((self_data == other._data).all())
785 def __getbuffer__(self, Py_buffer *buffer, int flags):
786 _cyb_cpython.PyObject_GetBuffer(self._data, buffer, flags)
788 def __releasebuffer__(self, Py_buffer *buffer):
789 _cyb_cpython.PyBuffer_Release(buffer)
791 @property
792 def uuid(self):
793 """~_numpy.int8: (array of length 16)."""
794 return self._data.uuid
796 @uuid.setter
797 def uuid(self, val):
798 self._data.uuid = val
800 @property
801 def read_bytes(self):
802 """Union[~_numpy.uint64, int]: """
803 if self._data.size == 1:
804 return int(self._data.read_bytes[0])
805 return self._data.read_bytes
807 @read_bytes.setter
808 def read_bytes(self, val):
809 self._data.read_bytes = val
811 @property
812 def read_bw_bytes_per_sec(self):
813 """Union[~_numpy.uint64, int]: """
814 if self._data.size == 1:
815 return int(self._data.read_bw_bytes_per_sec[0])
816 return self._data.read_bw_bytes_per_sec
818 @read_bw_bytes_per_sec.setter
819 def read_bw_bytes_per_sec(self, val):
820 self._data.read_bw_bytes_per_sec = val
822 @property
823 def read_utilization(self):
824 """Union[~_numpy.uint64, int]: """
825 if self._data.size == 1:
826 return int(self._data.read_utilization[0])
827 return self._data.read_utilization
829 @read_utilization.setter
830 def read_utilization(self, val):
831 self._data.read_utilization = val
833 @property
834 def read_duration_us(self):
835 """Union[~_numpy.uint64, int]: """
836 if self._data.size == 1:
837 return int(self._data.read_duration_us[0])
838 return self._data.read_duration_us
840 @read_duration_us.setter
841 def read_duration_us(self, val):
842 self._data.read_duration_us = val
844 @property
845 def n_total_reads(self):
846 """Union[~_numpy.uint64, int]: """
847 if self._data.size == 1: 1b
848 return int(self._data.n_total_reads[0]) 1b
849 return self._data.n_total_reads
851 @n_total_reads.setter
852 def n_total_reads(self, val):
853 self._data.n_total_reads = val
855 @property
856 def n_p2p_reads(self):
857 """Union[~_numpy.uint64, int]: """
858 if self._data.size == 1:
859 return int(self._data.n_p2p_reads[0])
860 return self._data.n_p2p_reads
862 @n_p2p_reads.setter
863 def n_p2p_reads(self, val):
864 self._data.n_p2p_reads = val
866 @property
867 def n_nvfs_reads(self):
868 """Union[~_numpy.uint64, int]: """
869 if self._data.size == 1:
870 return int(self._data.n_nvfs_reads[0])
871 return self._data.n_nvfs_reads
873 @n_nvfs_reads.setter
874 def n_nvfs_reads(self, val):
875 self._data.n_nvfs_reads = val
877 @property
878 def n_posix_reads(self):
879 """Union[~_numpy.uint64, int]: """
880 if self._data.size == 1:
881 return int(self._data.n_posix_reads[0])
882 return self._data.n_posix_reads
884 @n_posix_reads.setter
885 def n_posix_reads(self, val):
886 self._data.n_posix_reads = val
888 @property
889 def n_unaligned_reads(self):
890 """Union[~_numpy.uint64, int]: """
891 if self._data.size == 1:
892 return int(self._data.n_unaligned_reads[0])
893 return self._data.n_unaligned_reads
895 @n_unaligned_reads.setter
896 def n_unaligned_reads(self, val):
897 self._data.n_unaligned_reads = val
899 @property
900 def n_dr_reads(self):
901 """Union[~_numpy.uint64, int]: """
902 if self._data.size == 1:
903 return int(self._data.n_dr_reads[0])
904 return self._data.n_dr_reads
906 @n_dr_reads.setter
907 def n_dr_reads(self, val):
908 self._data.n_dr_reads = val
910 @property
911 def n_sparse_regions(self):
912 """Union[~_numpy.uint64, int]: """
913 if self._data.size == 1:
914 return int(self._data.n_sparse_regions[0])
915 return self._data.n_sparse_regions
917 @n_sparse_regions.setter
918 def n_sparse_regions(self, val):
919 self._data.n_sparse_regions = val
921 @property
922 def n_inline_regions(self):
923 """Union[~_numpy.uint64, int]: """
924 if self._data.size == 1:
925 return int(self._data.n_inline_regions[0])
926 return self._data.n_inline_regions
928 @n_inline_regions.setter
929 def n_inline_regions(self, val):
930 self._data.n_inline_regions = val
932 @property
933 def n_reads_err(self):
934 """Union[~_numpy.uint64, int]: """
935 if self._data.size == 1:
936 return int(self._data.n_reads_err[0])
937 return self._data.n_reads_err
939 @n_reads_err.setter
940 def n_reads_err(self, val):
941 self._data.n_reads_err = val
943 @property
944 def writes_bytes(self):
945 """Union[~_numpy.uint64, int]: """
946 if self._data.size == 1:
947 return int(self._data.writes_bytes[0])
948 return self._data.writes_bytes
950 @writes_bytes.setter
951 def writes_bytes(self, val):
952 self._data.writes_bytes = val
954 @property
955 def write_bw_bytes_per_sec(self):
956 """Union[~_numpy.uint64, int]: """
957 if self._data.size == 1:
958 return int(self._data.write_bw_bytes_per_sec[0])
959 return self._data.write_bw_bytes_per_sec
961 @write_bw_bytes_per_sec.setter
962 def write_bw_bytes_per_sec(self, val):
963 self._data.write_bw_bytes_per_sec = val
965 @property
966 def write_utilization(self):
967 """Union[~_numpy.uint64, int]: """
968 if self._data.size == 1:
969 return int(self._data.write_utilization[0])
970 return self._data.write_utilization
972 @write_utilization.setter
973 def write_utilization(self, val):
974 self._data.write_utilization = val
976 @property
977 def write_duration_us(self):
978 """Union[~_numpy.uint64, int]: """
979 if self._data.size == 1:
980 return int(self._data.write_duration_us[0])
981 return self._data.write_duration_us
983 @write_duration_us.setter
984 def write_duration_us(self, val):
985 self._data.write_duration_us = val
987 @property
988 def n_total_writes(self):
989 """Union[~_numpy.uint64, int]: """
990 if self._data.size == 1:
991 return int(self._data.n_total_writes[0])
992 return self._data.n_total_writes
994 @n_total_writes.setter
995 def n_total_writes(self, val):
996 self._data.n_total_writes = val
998 @property
999 def n_p2p_writes(self):
1000 """Union[~_numpy.uint64, int]: """
1001 if self._data.size == 1:
1002 return int(self._data.n_p2p_writes[0])
1003 return self._data.n_p2p_writes
1005 @n_p2p_writes.setter
1006 def n_p2p_writes(self, val):
1007 self._data.n_p2p_writes = val
1009 @property
1010 def n_nvfs_writes(self):
1011 """Union[~_numpy.uint64, int]: """
1012 if self._data.size == 1:
1013 return int(self._data.n_nvfs_writes[0])
1014 return self._data.n_nvfs_writes
1016 @n_nvfs_writes.setter
1017 def n_nvfs_writes(self, val):
1018 self._data.n_nvfs_writes = val
1020 @property
1021 def n_posix_writes(self):
1022 """Union[~_numpy.uint64, int]: """
1023 if self._data.size == 1:
1024 return int(self._data.n_posix_writes[0])
1025 return self._data.n_posix_writes
1027 @n_posix_writes.setter
1028 def n_posix_writes(self, val):
1029 self._data.n_posix_writes = val
1031 @property
1032 def n_unaligned_writes(self):
1033 """Union[~_numpy.uint64, int]: """
1034 if self._data.size == 1:
1035 return int(self._data.n_unaligned_writes[0])
1036 return self._data.n_unaligned_writes
1038 @n_unaligned_writes.setter
1039 def n_unaligned_writes(self, val):
1040 self._data.n_unaligned_writes = val
1042 @property
1043 def n_dr_writes(self):
1044 """Union[~_numpy.uint64, int]: """
1045 if self._data.size == 1:
1046 return int(self._data.n_dr_writes[0])
1047 return self._data.n_dr_writes
1049 @n_dr_writes.setter
1050 def n_dr_writes(self, val):
1051 self._data.n_dr_writes = val
1053 @property
1054 def n_writes_err(self):
1055 """Union[~_numpy.uint64, int]: """
1056 if self._data.size == 1:
1057 return int(self._data.n_writes_err[0])
1058 return self._data.n_writes_err
1060 @n_writes_err.setter
1061 def n_writes_err(self, val):
1062 self._data.n_writes_err = val
1064 @property
1065 def n_mmap(self):
1066 """Union[~_numpy.uint64, int]: """
1067 if self._data.size == 1:
1068 return int(self._data.n_mmap[0])
1069 return self._data.n_mmap
1071 @n_mmap.setter
1072 def n_mmap(self, val):
1073 self._data.n_mmap = val
1075 @property
1076 def n_mmap_ok(self):
1077 """Union[~_numpy.uint64, int]: """
1078 if self._data.size == 1:
1079 return int(self._data.n_mmap_ok[0])
1080 return self._data.n_mmap_ok
1082 @n_mmap_ok.setter
1083 def n_mmap_ok(self, val):
1084 self._data.n_mmap_ok = val
1086 @property
1087 def n_mmap_err(self):
1088 """Union[~_numpy.uint64, int]: """
1089 if self._data.size == 1:
1090 return int(self._data.n_mmap_err[0])
1091 return self._data.n_mmap_err
1093 @n_mmap_err.setter
1094 def n_mmap_err(self, val):
1095 self._data.n_mmap_err = val
1097 @property
1098 def n_mmap_free(self):
1099 """Union[~_numpy.uint64, int]: """
1100 if self._data.size == 1:
1101 return int(self._data.n_mmap_free[0])
1102 return self._data.n_mmap_free
1104 @n_mmap_free.setter
1105 def n_mmap_free(self, val):
1106 self._data.n_mmap_free = val
1108 @property
1109 def reg_bytes(self):
1110 """Union[~_numpy.uint64, int]: """
1111 if self._data.size == 1:
1112 return int(self._data.reg_bytes[0])
1113 return self._data.reg_bytes
1115 @reg_bytes.setter
1116 def reg_bytes(self, val):
1117 self._data.reg_bytes = val
1119 def __getitem__(self, key):
1120 cdef ssize_t key_
1121 cdef ssize_t size
1122 if isinstance(key, int): 1b
1123 key_ = key 1b
1124 size = self._data.size 1b
1125 if key_ >= size or key_ <= -(size+1): 1b
1126 raise IndexError("index is out of bounds")
1127 if key_ < 0: 1b
1128 key_ += size
1129 return PerGpuStats.from_data(self._data[key_:key_+1]) 1b
1130 out = self._data[key]
1131 if isinstance(out, _numpy.recarray) and out.dtype == per_gpu_stats_dtype:
1132 return PerGpuStats.from_data(out)
1133 return out
1135 def __setitem__(self, key, val):
1136 self._data[key] = val
1138 @staticmethod
1139 def from_buffer(buffer):
1140 """Create an PerGpuStats instance with the memory from the given buffer."""
1141 return PerGpuStats.from_data(_numpy.frombuffer(buffer, dtype=per_gpu_stats_dtype))
1143 @staticmethod
1144 def from_data(data):
1145 """Create an PerGpuStats instance wrapping the given NumPy array.
1147 Args:
1148 data (_numpy.ndarray): a 1D array of dtype `per_gpu_stats_dtype` holding the data.
1149 """
1150 cdef PerGpuStats obj = PerGpuStats.__new__(PerGpuStats) 1b
1151 if not isinstance(data, _numpy.ndarray): 1b
1152 raise TypeError("data argument must be a NumPy ndarray")
1153 if data.ndim != 1: 1b
1154 raise ValueError("data array must be 1D")
1155 if data.dtype != per_gpu_stats_dtype: 1b
1156 raise ValueError("data array must be of dtype per_gpu_stats_dtype")
1157 obj._data = data.view(_numpy.recarray) 1b
1159 return obj 1b
1161 @staticmethod
1162 def from_ptr(intptr_t ptr, size_t size=1, bint readonly=False):
1163 """Create an PerGpuStats instance wrapping the given pointer.
1165 Args:
1166 ptr (intptr_t): pointer address as Python :class:`int` to the data.
1167 size (int): number of structs, default=1.
1168 readonly (bool): whether the data is read-only (to the user). default is `False`.
1169 """
1170 if ptr == 0: 1b
1171 raise ValueError("ptr must not be null (0)")
1172 cdef PerGpuStats obj = PerGpuStats.__new__(PerGpuStats) 1b
1173 cdef flag = _cyb_cpython_buffer.PyBUF_READ if readonly else _cyb_cpython_buffer.PyBUF_WRITE 1b
1174 cdef object buf = _cyb_cpython_memoryview.PyMemoryView_FromMemory( 1b
1175 <char*>ptr, sizeof(CUfilePerGpuStats_t) * size, flag) 1b
1176 data = _numpy.ndarray(size, buffer=buf, dtype=per_gpu_stats_dtype) 1b
1177 obj._data = data.view(_numpy.recarray) 1b
1179 return obj 1b
1182cdef _get_descr_dtype_offsets():
1183 cdef CUfileDescr_t pod
1184 return _numpy.dtype({
1185 'names': ['type', 'handle', 'fs_ops'],
1186 'formats': [_numpy.int32, _py_anon_pod1_dtype, _numpy.intp],
1187 'offsets': [
1188 (<intptr_t>&(pod.type)) - (<intptr_t>&pod),
1189 (<intptr_t>&(pod.handle)) - (<intptr_t>&pod),
1190 (<intptr_t>&(pod.fs_ops)) - (<intptr_t>&pod),
1191 ],
1192 'itemsize': sizeof(CUfileDescr_t),
1193 })
1195descr_dtype = _get_descr_dtype_offsets()
1197cdef class Descr:
1198 """Empty-initialize an array of `CUfileDescr_t`.
1199 The resulting object is of length `size` and of dtype `descr_dtype`.
1200 If default-constructed, the instance represents a single struct.
1202 Args:
1203 size (int): number of structs, default=1.
1205 .. seealso:: `CUfileDescr_t`
1206 """
1207 cdef:
1208 readonly object _data
1210 def __init__(self, size=1):
1211 arr = _numpy.empty(size, dtype=descr_dtype) 1dgehijklmfcbr
1212 self._data = arr.view(_numpy.recarray) 1dgehijklmfcbr
1213 assert self._data.itemsize == sizeof(CUfileDescr_t), \ 1dgehijklmfcbr
1214 f"itemsize {self._data.itemsize} mismatches struct size { sizeof(CUfileDescr_t) }"
1216 def __repr__(self):
1217 if self._data.size > 1:
1218 return f"<{__name__}.Descr_Array_{self._data.size} object at {hex(id(self))}>"
1219 else:
1220 return f"<{__name__}.Descr object at {hex(id(self))}>"
1222 @property
1223 def ptr(self):
1224 """Get the pointer address to the data as Python :class:`int`."""
1225 return self._data.ctypes.data 1dgehijklmfcbr
1227 cdef intptr_t _get_ptr(self):
1228 return self._data.ctypes.data
1230 def __int__(self):
1231 if self._data.size > 1:
1232 raise TypeError("int() argument must be a bytes-like object of size 1. "
1233 "To get the pointer address of an array, use .ptr")
1234 return self._data.ctypes.data
1236 def __len__(self):
1237 return self._data.size
1239 def __eq__(self, other):
1240 cdef object self_data = self._data
1241 if (not isinstance(other, Descr)) or self_data.size != other._data.size or self_data.dtype != other._data.dtype:
1242 return False
1243 return bool((self_data == other._data).all())
1245 def __getbuffer__(self, Py_buffer *buffer, int flags):
1246 _cyb_cpython.PyObject_GetBuffer(self._data, buffer, flags)
1248 def __releasebuffer__(self, Py_buffer *buffer):
1249 _cyb_cpython.PyBuffer_Release(buffer)
1251 @property
1252 def type(self):
1253 """Union[~_numpy.int32, int]: """
1254 if self._data.size == 1:
1255 return int(self._data.type[0])
1256 return self._data.type
1258 @type.setter
1259 def type(self, val):
1260 self._data.type = val 1dgehijklmfcbr
1262 @property
1263 def handle(self):
1264 """_py_anon_pod1_dtype: """
1265 return self._data.handle 1dgehijklmfcbr
1267 @handle.setter
1268 def handle(self, val):
1269 self._data.handle = val
1271 @property
1272 def fs_ops(self):
1273 """Union[~_numpy.intp, int]: """
1274 if self._data.size == 1:
1275 return int(self._data.fs_ops[0])
1276 return self._data.fs_ops
1278 @fs_ops.setter
1279 def fs_ops(self, val):
1280 self._data.fs_ops = val 1dgehijklmfcbr
1282 def __getitem__(self, key):
1283 cdef ssize_t key_
1284 cdef ssize_t size
1285 if isinstance(key, int):
1286 key_ = key
1287 size = self._data.size
1288 if key_ >= size or key_ <= -(size+1):
1289 raise IndexError("index is out of bounds")
1290 if key_ < 0:
1291 key_ += size
1292 return Descr.from_data(self._data[key_:key_+1])
1293 out = self._data[key]
1294 if isinstance(out, _numpy.recarray) and out.dtype == descr_dtype:
1295 return Descr.from_data(out)
1296 return out
1298 def __setitem__(self, key, val):
1299 self._data[key] = val
1301 @staticmethod
1302 def from_buffer(buffer):
1303 """Create an Descr instance with the memory from the given buffer."""
1304 return Descr.from_data(_numpy.frombuffer(buffer, dtype=descr_dtype))
1306 @staticmethod
1307 def from_data(data):
1308 """Create an Descr instance wrapping the given NumPy array.
1310 Args:
1311 data (_numpy.ndarray): a 1D array of dtype `descr_dtype` holding the data.
1312 """
1313 cdef Descr obj = Descr.__new__(Descr)
1314 if not isinstance(data, _numpy.ndarray):
1315 raise TypeError("data argument must be a NumPy ndarray")
1316 if data.ndim != 1:
1317 raise ValueError("data array must be 1D")
1318 if data.dtype != descr_dtype:
1319 raise ValueError("data array must be of dtype descr_dtype")
1320 obj._data = data.view(_numpy.recarray)
1322 return obj
1324 @staticmethod
1325 def from_ptr(intptr_t ptr, size_t size=1, bint readonly=False):
1326 """Create an Descr instance wrapping the given pointer.
1328 Args:
1329 ptr (intptr_t): pointer address as Python :class:`int` to the data.
1330 size (int): number of structs, default=1.
1331 readonly (bool): whether the data is read-only (to the user). default is `False`.
1332 """
1333 if ptr == 0:
1334 raise ValueError("ptr must not be null (0)")
1335 cdef Descr obj = Descr.__new__(Descr)
1336 cdef flag = _cyb_cpython_buffer.PyBUF_READ if readonly else _cyb_cpython_buffer.PyBUF_WRITE
1337 cdef object buf = _cyb_cpython_memoryview.PyMemoryView_FromMemory(
1338 <char*>ptr, sizeof(CUfileDescr_t) * size, flag)
1339 data = _numpy.ndarray(size, buffer=buf, dtype=descr_dtype)
1340 obj._data = data.view(_numpy.recarray)
1342 return obj
1345_py_anon_pod2_dtype = _numpy.dtype((
1346 _numpy.dtype((_numpy.void, sizeof((<CUfileIOParams_t*>NULL).u))),
1347 {
1348 "batch": (_py_anon_pod3_dtype, 0),
1349 }
1350 ))
1352cdef class _py_anon_pod2:
1353 """Empty-initialize an instance of `cuda_bindings_cufile__anon_pod2`.
1356 .. seealso:: `cuda_bindings_cufile__anon_pod2`
1357 """
1358 cdef:
1359 cuda_bindings_cufile__anon_pod2 *_ptr
1360 object _owner
1361 bint _owned
1362 bint _readonly
1364 def __init__(self):
1365 self._ptr = <cuda_bindings_cufile__anon_pod2 *>_cyb_calloc(1, sizeof((<CUfileIOParams_t*>NULL).u))
1366 if self._ptr == NULL:
1367 raise MemoryError("Error allocating _py_anon_pod2")
1368 self._owner = None
1369 self._owned = True
1370 self._readonly = False
1372 def __dealloc__(self):
1373 cdef cuda_bindings_cufile__anon_pod2 *ptr
1374 if self._owned and self._ptr != NULL:
1375 ptr = self._ptr
1376 self._ptr = NULL
1377 _cyb_free(ptr)
1379 def __repr__(self):
1380 return f"<{__name__}._py_anon_pod2 object at {hex(id(self))}>"
1382 @property
1383 def ptr(self):
1384 """Get the pointer address to the data as Python :class:`int`."""
1385 return <intptr_t>(self._ptr)
1387 cdef intptr_t _get_ptr(self):
1388 return <intptr_t>(self._ptr)
1390 def __int__(self):
1391 return <intptr_t>(self._ptr)
1393 def __eq__(self, other):
1394 cdef _py_anon_pod2 other_
1395 if not isinstance(other, _py_anon_pod2):
1396 return False
1397 other_ = other
1398 return (_cyb_memcmp(<void *><intptr_t>(self._ptr), <void *><intptr_t>(other_._ptr), sizeof((<CUfileIOParams_t*>NULL).u)) == 0)
1400 def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags):
1401 _cyb___getbuffer(self, buffer, <void *>self._ptr, sizeof((<CUfileIOParams_t*>NULL).u), self._readonly)
1403 def __releasebuffer__(self, Py_buffer *buffer):
1404 pass
1406 def __setitem__(self, key, val):
1407 if key == 0 and isinstance(val, _numpy.ndarray):
1408 self._ptr = <cuda_bindings_cufile__anon_pod2 *>_cyb_malloc(sizeof((<CUfileIOParams_t*>NULL).u))
1409 if self._ptr == NULL:
1410 raise MemoryError("Error allocating _py_anon_pod2")
1411 _cyb_memcpy(<void*>self._ptr, <void*><intptr_t>val.ctypes.data, sizeof((<CUfileIOParams_t*>NULL).u))
1412 self._owner = None
1413 self._owned = True
1414 self._readonly = not val.flags.writeable
1415 else:
1416 setattr(self, key, val)
1418 @property
1419 def batch(self):
1420 """_py_anon_pod3: """
1421 return _py_anon_pod3.from_ptr(<intptr_t>&(self._ptr[0].batch), self._readonly, self)
1423 @batch.setter
1424 def batch(self, val):
1425 if self._readonly:
1426 raise ValueError("This _py_anon_pod2 instance is read-only")
1427 cdef _py_anon_pod3 val_ = val
1428 _cyb_memcpy(<void *>&(self._ptr[0].batch), <void *>(val_._get_ptr()), sizeof(cuda_bindings_cufile__anon_pod3) * 1)
1430 @staticmethod
1431 def from_buffer(buffer):
1432 """Create an _py_anon_pod2 instance with the memory from the given buffer."""
1433 return _cyb_from_buffer(buffer, sizeof((<CUfileIOParams_t*>NULL).u), _py_anon_pod2)
1435 @staticmethod
1436 def from_data(data):
1437 """Create an _py_anon_pod2 instance wrapping the given NumPy array.
1439 Args:
1440 data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod2_dtype` holding the data.
1441 """
1442 return _cyb_from_data(data, "_py_anon_pod2_dtype", _py_anon_pod2_dtype, _py_anon_pod2)
1444 @staticmethod
1445 def from_ptr(intptr_t ptr, bint readonly=False, object owner=None):
1446 """Create an _py_anon_pod2 instance wrapping the given pointer.
1448 Args:
1449 ptr (intptr_t): pointer address as Python :class:`int` to the data.
1450 owner (object): The Python object that owns the pointer. If not provided, data will be copied.
1451 readonly (bool): whether the data is read-only (to the user). default is `False`.
1452 """
1453 if ptr == 0:
1454 raise ValueError("ptr must not be null (0)")
1455 cdef _py_anon_pod2 obj = _py_anon_pod2.__new__(_py_anon_pod2)
1456 if owner is None:
1457 obj._ptr = <cuda_bindings_cufile__anon_pod2 *>_cyb_malloc(sizeof((<CUfileIOParams_t*>NULL).u))
1458 if obj._ptr == NULL:
1459 raise MemoryError("Error allocating _py_anon_pod2")
1460 _cyb_memcpy(<void*>(obj._ptr), <void*>ptr, sizeof((<CUfileIOParams_t*>NULL).u))
1461 obj._owner = None
1462 obj._owned = True
1463 else:
1464 obj._ptr = <cuda_bindings_cufile__anon_pod2 *>ptr
1465 obj._owner = owner
1466 obj._owned = False
1467 obj._readonly = readonly
1468 return obj
1471cdef _get_stats_level1_dtype_offsets():
1472 cdef CUfileStatsLevel1_t pod
1473 return _numpy.dtype({
1474 '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'],
1475 '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],
1476 'offsets': [
1477 (<intptr_t>&(pod.read_ops)) - (<intptr_t>&pod),
1478 (<intptr_t>&(pod.write_ops)) - (<intptr_t>&pod),
1479 (<intptr_t>&(pod.hdl_register_ops)) - (<intptr_t>&pod),
1480 (<intptr_t>&(pod.hdl_deregister_ops)) - (<intptr_t>&pod),
1481 (<intptr_t>&(pod.buf_register_ops)) - (<intptr_t>&pod),
1482 (<intptr_t>&(pod.buf_deregister_ops)) - (<intptr_t>&pod),
1483 (<intptr_t>&(pod.read_bytes)) - (<intptr_t>&pod),
1484 (<intptr_t>&(pod.write_bytes)) - (<intptr_t>&pod),
1485 (<intptr_t>&(pod.read_bw_bytes_per_sec)) - (<intptr_t>&pod),
1486 (<intptr_t>&(pod.write_bw_bytes_per_sec)) - (<intptr_t>&pod),
1487 (<intptr_t>&(pod.read_lat_avg_us)) - (<intptr_t>&pod),
1488 (<intptr_t>&(pod.write_lat_avg_us)) - (<intptr_t>&pod),
1489 (<intptr_t>&(pod.read_ops_per_sec)) - (<intptr_t>&pod),
1490 (<intptr_t>&(pod.write_ops_per_sec)) - (<intptr_t>&pod),
1491 (<intptr_t>&(pod.read_lat_sum_us)) - (<intptr_t>&pod),
1492 (<intptr_t>&(pod.write_lat_sum_us)) - (<intptr_t>&pod),
1493 (<intptr_t>&(pod.batch_submit_ops)) - (<intptr_t>&pod),
1494 (<intptr_t>&(pod.batch_complete_ops)) - (<intptr_t>&pod),
1495 (<intptr_t>&(pod.batch_setup_ops)) - (<intptr_t>&pod),
1496 (<intptr_t>&(pod.batch_cancel_ops)) - (<intptr_t>&pod),
1497 (<intptr_t>&(pod.batch_destroy_ops)) - (<intptr_t>&pod),
1498 (<intptr_t>&(pod.batch_enqueued_ops)) - (<intptr_t>&pod),
1499 (<intptr_t>&(pod.batch_posix_enqueued_ops)) - (<intptr_t>&pod),
1500 (<intptr_t>&(pod.batch_processed_ops)) - (<intptr_t>&pod),
1501 (<intptr_t>&(pod.batch_posix_processed_ops)) - (<intptr_t>&pod),
1502 (<intptr_t>&(pod.batch_nvfs_submit_ops)) - (<intptr_t>&pod),
1503 (<intptr_t>&(pod.batch_p2p_submit_ops)) - (<intptr_t>&pod),
1504 (<intptr_t>&(pod.batch_aio_submit_ops)) - (<intptr_t>&pod),
1505 (<intptr_t>&(pod.batch_iouring_submit_ops)) - (<intptr_t>&pod),
1506 (<intptr_t>&(pod.batch_mixed_io_submit_ops)) - (<intptr_t>&pod),
1507 (<intptr_t>&(pod.batch_total_submit_ops)) - (<intptr_t>&pod),
1508 (<intptr_t>&(pod.batch_read_bytes)) - (<intptr_t>&pod),
1509 (<intptr_t>&(pod.batch_write_bytes)) - (<intptr_t>&pod),
1510 (<intptr_t>&(pod.batch_read_bw_bytes)) - (<intptr_t>&pod),
1511 (<intptr_t>&(pod.batch_write_bw_bytes)) - (<intptr_t>&pod),
1512 (<intptr_t>&(pod.batch_submit_lat_avg_us)) - (<intptr_t>&pod),
1513 (<intptr_t>&(pod.batch_completion_lat_avg_us)) - (<intptr_t>&pod),
1514 (<intptr_t>&(pod.batch_submit_ops_per_sec)) - (<intptr_t>&pod),
1515 (<intptr_t>&(pod.batch_complete_ops_per_sec)) - (<intptr_t>&pod),
1516 (<intptr_t>&(pod.batch_submit_lat_sum_us)) - (<intptr_t>&pod),
1517 (<intptr_t>&(pod.batch_completion_lat_sum_us)) - (<intptr_t>&pod),
1518 (<intptr_t>&(pod.last_batch_read_bytes)) - (<intptr_t>&pod),
1519 (<intptr_t>&(pod.last_batch_write_bytes)) - (<intptr_t>&pod),
1520 ],
1521 'itemsize': sizeof(CUfileStatsLevel1_t),
1522 })
1524stats_level1_dtype = _get_stats_level1_dtype_offsets()
1526cdef class StatsLevel1:
1527 """Empty-initialize an instance of `CUfileStatsLevel1_t`.
1530 .. seealso:: `CUfileStatsLevel1_t`
1531 """
1532 cdef:
1533 CUfileStatsLevel1_t *_ptr
1534 object _owner
1535 bint _owned
1536 bint _readonly
1538 def __init__(self):
1539 self._ptr = <CUfileStatsLevel1_t *>_cyb_calloc(1, sizeof(CUfileStatsLevel1_t)) 1f
1540 if self._ptr == NULL: 1f
1541 raise MemoryError("Error allocating StatsLevel1")
1542 self._owner = None 1f
1543 self._owned = True 1f
1544 self._readonly = False 1f
1546 def __dealloc__(self):
1547 cdef CUfileStatsLevel1_t *ptr
1548 if self._owned and self._ptr != NULL: 1fc
1549 ptr = self._ptr 1f
1550 self._ptr = NULL 1f
1551 _cyb_free(ptr) 1f
1553 def __repr__(self):
1554 return f"<{__name__}.StatsLevel1 object at {hex(id(self))}>"
1556 @property
1557 def ptr(self):
1558 """Get the pointer address to the data as Python :class:`int`."""
1559 return <intptr_t>(self._ptr) 1f
1561 cdef intptr_t _get_ptr(self):
1562 return <intptr_t>(self._ptr)
1564 def __int__(self):
1565 return <intptr_t>(self._ptr)
1567 def __eq__(self, other):
1568 cdef StatsLevel1 other_
1569 if not isinstance(other, StatsLevel1):
1570 return False
1571 other_ = other
1572 return (_cyb_memcmp(<void *><intptr_t>(self._ptr), <void *><intptr_t>(other_._ptr), sizeof(CUfileStatsLevel1_t)) == 0)
1574 def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags):
1575 _cyb___getbuffer(self, buffer, <void *>self._ptr, sizeof(CUfileStatsLevel1_t), self._readonly)
1577 def __releasebuffer__(self, Py_buffer *buffer):
1578 pass
1580 def __setitem__(self, key, val):
1581 if key == 0 and isinstance(val, _numpy.ndarray):
1582 self._ptr = <CUfileStatsLevel1_t *>_cyb_malloc(sizeof(CUfileStatsLevel1_t))
1583 if self._ptr == NULL:
1584 raise MemoryError("Error allocating StatsLevel1")
1585 _cyb_memcpy(<void*>self._ptr, <void*><intptr_t>val.ctypes.data, sizeof(CUfileStatsLevel1_t))
1586 self._owner = None
1587 self._owned = True
1588 self._readonly = not val.flags.writeable
1589 else:
1590 setattr(self, key, val)
1592 @property
1593 def read_ops(self):
1594 """OpCounter: """
1595 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].read_ops), self._readonly, self) 1fc
1597 @read_ops.setter
1598 def read_ops(self, val):
1599 if self._readonly:
1600 raise ValueError("This StatsLevel1 instance is read-only")
1601 cdef OpCounter val_ = val
1602 _cyb_memcpy(<void *>&(self._ptr[0].read_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1604 @property
1605 def write_ops(self):
1606 """OpCounter: """
1607 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].write_ops), self._readonly, self) 1fc
1609 @write_ops.setter
1610 def write_ops(self, val):
1611 if self._readonly:
1612 raise ValueError("This StatsLevel1 instance is read-only")
1613 cdef OpCounter val_ = val
1614 _cyb_memcpy(<void *>&(self._ptr[0].write_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1616 @property
1617 def hdl_register_ops(self):
1618 """OpCounter: """
1619 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].hdl_register_ops), self._readonly, self)
1621 @hdl_register_ops.setter
1622 def hdl_register_ops(self, val):
1623 if self._readonly:
1624 raise ValueError("This StatsLevel1 instance is read-only")
1625 cdef OpCounter val_ = val
1626 _cyb_memcpy(<void *>&(self._ptr[0].hdl_register_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1628 @property
1629 def hdl_deregister_ops(self):
1630 """OpCounter: """
1631 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].hdl_deregister_ops), self._readonly, self)
1633 @hdl_deregister_ops.setter
1634 def hdl_deregister_ops(self, val):
1635 if self._readonly:
1636 raise ValueError("This StatsLevel1 instance is read-only")
1637 cdef OpCounter val_ = val
1638 _cyb_memcpy(<void *>&(self._ptr[0].hdl_deregister_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1640 @property
1641 def buf_register_ops(self):
1642 """OpCounter: """
1643 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].buf_register_ops), self._readonly, self)
1645 @buf_register_ops.setter
1646 def buf_register_ops(self, val):
1647 if self._readonly:
1648 raise ValueError("This StatsLevel1 instance is read-only")
1649 cdef OpCounter val_ = val
1650 _cyb_memcpy(<void *>&(self._ptr[0].buf_register_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1652 @property
1653 def buf_deregister_ops(self):
1654 """OpCounter: """
1655 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].buf_deregister_ops), self._readonly, self)
1657 @buf_deregister_ops.setter
1658 def buf_deregister_ops(self, val):
1659 if self._readonly:
1660 raise ValueError("This StatsLevel1 instance is read-only")
1661 cdef OpCounter val_ = val
1662 _cyb_memcpy(<void *>&(self._ptr[0].buf_deregister_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1664 @property
1665 def batch_submit_ops(self):
1666 """OpCounter: """
1667 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_submit_ops), self._readonly, self)
1669 @batch_submit_ops.setter
1670 def batch_submit_ops(self, val):
1671 if self._readonly:
1672 raise ValueError("This StatsLevel1 instance is read-only")
1673 cdef OpCounter val_ = val
1674 _cyb_memcpy(<void *>&(self._ptr[0].batch_submit_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1676 @property
1677 def batch_complete_ops(self):
1678 """OpCounter: """
1679 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_complete_ops), self._readonly, self)
1681 @batch_complete_ops.setter
1682 def batch_complete_ops(self, val):
1683 if self._readonly:
1684 raise ValueError("This StatsLevel1 instance is read-only")
1685 cdef OpCounter val_ = val
1686 _cyb_memcpy(<void *>&(self._ptr[0].batch_complete_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1688 @property
1689 def batch_setup_ops(self):
1690 """OpCounter: """
1691 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_setup_ops), self._readonly, self)
1693 @batch_setup_ops.setter
1694 def batch_setup_ops(self, val):
1695 if self._readonly:
1696 raise ValueError("This StatsLevel1 instance is read-only")
1697 cdef OpCounter val_ = val
1698 _cyb_memcpy(<void *>&(self._ptr[0].batch_setup_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1700 @property
1701 def batch_cancel_ops(self):
1702 """OpCounter: """
1703 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_cancel_ops), self._readonly, self)
1705 @batch_cancel_ops.setter
1706 def batch_cancel_ops(self, val):
1707 if self._readonly:
1708 raise ValueError("This StatsLevel1 instance is read-only")
1709 cdef OpCounter val_ = val
1710 _cyb_memcpy(<void *>&(self._ptr[0].batch_cancel_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1712 @property
1713 def batch_destroy_ops(self):
1714 """OpCounter: """
1715 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_destroy_ops), self._readonly, self)
1717 @batch_destroy_ops.setter
1718 def batch_destroy_ops(self, val):
1719 if self._readonly:
1720 raise ValueError("This StatsLevel1 instance is read-only")
1721 cdef OpCounter val_ = val
1722 _cyb_memcpy(<void *>&(self._ptr[0].batch_destroy_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1724 @property
1725 def batch_enqueued_ops(self):
1726 """OpCounter: """
1727 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_enqueued_ops), self._readonly, self)
1729 @batch_enqueued_ops.setter
1730 def batch_enqueued_ops(self, val):
1731 if self._readonly:
1732 raise ValueError("This StatsLevel1 instance is read-only")
1733 cdef OpCounter val_ = val
1734 _cyb_memcpy(<void *>&(self._ptr[0].batch_enqueued_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1736 @property
1737 def batch_posix_enqueued_ops(self):
1738 """OpCounter: """
1739 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_posix_enqueued_ops), self._readonly, self)
1741 @batch_posix_enqueued_ops.setter
1742 def batch_posix_enqueued_ops(self, val):
1743 if self._readonly:
1744 raise ValueError("This StatsLevel1 instance is read-only")
1745 cdef OpCounter val_ = val
1746 _cyb_memcpy(<void *>&(self._ptr[0].batch_posix_enqueued_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1748 @property
1749 def batch_processed_ops(self):
1750 """OpCounter: """
1751 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_processed_ops), self._readonly, self)
1753 @batch_processed_ops.setter
1754 def batch_processed_ops(self, val):
1755 if self._readonly:
1756 raise ValueError("This StatsLevel1 instance is read-only")
1757 cdef OpCounter val_ = val
1758 _cyb_memcpy(<void *>&(self._ptr[0].batch_processed_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1760 @property
1761 def batch_posix_processed_ops(self):
1762 """OpCounter: """
1763 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_posix_processed_ops), self._readonly, self)
1765 @batch_posix_processed_ops.setter
1766 def batch_posix_processed_ops(self, val):
1767 if self._readonly:
1768 raise ValueError("This StatsLevel1 instance is read-only")
1769 cdef OpCounter val_ = val
1770 _cyb_memcpy(<void *>&(self._ptr[0].batch_posix_processed_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1772 @property
1773 def batch_nvfs_submit_ops(self):
1774 """OpCounter: """
1775 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_nvfs_submit_ops), self._readonly, self)
1777 @batch_nvfs_submit_ops.setter
1778 def batch_nvfs_submit_ops(self, val):
1779 if self._readonly:
1780 raise ValueError("This StatsLevel1 instance is read-only")
1781 cdef OpCounter val_ = val
1782 _cyb_memcpy(<void *>&(self._ptr[0].batch_nvfs_submit_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1784 @property
1785 def batch_p2p_submit_ops(self):
1786 """OpCounter: """
1787 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_p2p_submit_ops), self._readonly, self)
1789 @batch_p2p_submit_ops.setter
1790 def batch_p2p_submit_ops(self, val):
1791 if self._readonly:
1792 raise ValueError("This StatsLevel1 instance is read-only")
1793 cdef OpCounter val_ = val
1794 _cyb_memcpy(<void *>&(self._ptr[0].batch_p2p_submit_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1796 @property
1797 def batch_aio_submit_ops(self):
1798 """OpCounter: """
1799 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_aio_submit_ops), self._readonly, self)
1801 @batch_aio_submit_ops.setter
1802 def batch_aio_submit_ops(self, val):
1803 if self._readonly:
1804 raise ValueError("This StatsLevel1 instance is read-only")
1805 cdef OpCounter val_ = val
1806 _cyb_memcpy(<void *>&(self._ptr[0].batch_aio_submit_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1808 @property
1809 def batch_iouring_submit_ops(self):
1810 """OpCounter: """
1811 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_iouring_submit_ops), self._readonly, self)
1813 @batch_iouring_submit_ops.setter
1814 def batch_iouring_submit_ops(self, val):
1815 if self._readonly:
1816 raise ValueError("This StatsLevel1 instance is read-only")
1817 cdef OpCounter val_ = val
1818 _cyb_memcpy(<void *>&(self._ptr[0].batch_iouring_submit_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1820 @property
1821 def batch_mixed_io_submit_ops(self):
1822 """OpCounter: """
1823 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_mixed_io_submit_ops), self._readonly, self)
1825 @batch_mixed_io_submit_ops.setter
1826 def batch_mixed_io_submit_ops(self, val):
1827 if self._readonly:
1828 raise ValueError("This StatsLevel1 instance is read-only")
1829 cdef OpCounter val_ = val
1830 _cyb_memcpy(<void *>&(self._ptr[0].batch_mixed_io_submit_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1832 @property
1833 def batch_total_submit_ops(self):
1834 """OpCounter: """
1835 return OpCounter.from_ptr(<intptr_t>&(self._ptr[0].batch_total_submit_ops), self._readonly, self)
1837 @batch_total_submit_ops.setter
1838 def batch_total_submit_ops(self, val):
1839 if self._readonly:
1840 raise ValueError("This StatsLevel1 instance is read-only")
1841 cdef OpCounter val_ = val
1842 _cyb_memcpy(<void *>&(self._ptr[0].batch_total_submit_ops), <void *>(val_._get_ptr()), sizeof(CUfileOpCounter_t) * 1)
1844 @property
1845 def read_bytes(self):
1846 """int: """
1847 return self._ptr[0].read_bytes 1f
1849 @read_bytes.setter
1850 def read_bytes(self, val):
1851 if self._readonly:
1852 raise ValueError("This StatsLevel1 instance is read-only")
1853 self._ptr[0].read_bytes = val
1855 @property
1856 def write_bytes(self):
1857 """int: """
1858 return self._ptr[0].write_bytes 1f
1860 @write_bytes.setter
1861 def write_bytes(self, val):
1862 if self._readonly:
1863 raise ValueError("This StatsLevel1 instance is read-only")
1864 self._ptr[0].write_bytes = val
1866 @property
1867 def read_bw_bytes_per_sec(self):
1868 """int: """
1869 return self._ptr[0].read_bw_bytes_per_sec
1871 @read_bw_bytes_per_sec.setter
1872 def read_bw_bytes_per_sec(self, val):
1873 if self._readonly:
1874 raise ValueError("This StatsLevel1 instance is read-only")
1875 self._ptr[0].read_bw_bytes_per_sec = val
1877 @property
1878 def write_bw_bytes_per_sec(self):
1879 """int: """
1880 return self._ptr[0].write_bw_bytes_per_sec
1882 @write_bw_bytes_per_sec.setter
1883 def write_bw_bytes_per_sec(self, val):
1884 if self._readonly:
1885 raise ValueError("This StatsLevel1 instance is read-only")
1886 self._ptr[0].write_bw_bytes_per_sec = val
1888 @property
1889 def read_lat_avg_us(self):
1890 """int: """
1891 return self._ptr[0].read_lat_avg_us
1893 @read_lat_avg_us.setter
1894 def read_lat_avg_us(self, val):
1895 if self._readonly:
1896 raise ValueError("This StatsLevel1 instance is read-only")
1897 self._ptr[0].read_lat_avg_us = val
1899 @property
1900 def write_lat_avg_us(self):
1901 """int: """
1902 return self._ptr[0].write_lat_avg_us
1904 @write_lat_avg_us.setter
1905 def write_lat_avg_us(self, val):
1906 if self._readonly:
1907 raise ValueError("This StatsLevel1 instance is read-only")
1908 self._ptr[0].write_lat_avg_us = val
1910 @property
1911 def read_ops_per_sec(self):
1912 """int: """
1913 return self._ptr[0].read_ops_per_sec
1915 @read_ops_per_sec.setter
1916 def read_ops_per_sec(self, val):
1917 if self._readonly:
1918 raise ValueError("This StatsLevel1 instance is read-only")
1919 self._ptr[0].read_ops_per_sec = val
1921 @property
1922 def write_ops_per_sec(self):
1923 """int: """
1924 return self._ptr[0].write_ops_per_sec
1926 @write_ops_per_sec.setter
1927 def write_ops_per_sec(self, val):
1928 if self._readonly:
1929 raise ValueError("This StatsLevel1 instance is read-only")
1930 self._ptr[0].write_ops_per_sec = val
1932 @property
1933 def read_lat_sum_us(self):
1934 """int: """
1935 return self._ptr[0].read_lat_sum_us
1937 @read_lat_sum_us.setter
1938 def read_lat_sum_us(self, val):
1939 if self._readonly:
1940 raise ValueError("This StatsLevel1 instance is read-only")
1941 self._ptr[0].read_lat_sum_us = val
1943 @property
1944 def write_lat_sum_us(self):
1945 """int: """
1946 return self._ptr[0].write_lat_sum_us
1948 @write_lat_sum_us.setter
1949 def write_lat_sum_us(self, val):
1950 if self._readonly:
1951 raise ValueError("This StatsLevel1 instance is read-only")
1952 self._ptr[0].write_lat_sum_us = val
1954 @property
1955 def batch_read_bytes(self):
1956 """int: """
1957 return self._ptr[0].batch_read_bytes
1959 @batch_read_bytes.setter
1960 def batch_read_bytes(self, val):
1961 if self._readonly:
1962 raise ValueError("This StatsLevel1 instance is read-only")
1963 self._ptr[0].batch_read_bytes = val
1965 @property
1966 def batch_write_bytes(self):
1967 """int: """
1968 return self._ptr[0].batch_write_bytes
1970 @batch_write_bytes.setter
1971 def batch_write_bytes(self, val):
1972 if self._readonly:
1973 raise ValueError("This StatsLevel1 instance is read-only")
1974 self._ptr[0].batch_write_bytes = val
1976 @property
1977 def batch_read_bw_bytes(self):
1978 """int: """
1979 return self._ptr[0].batch_read_bw_bytes
1981 @batch_read_bw_bytes.setter
1982 def batch_read_bw_bytes(self, val):
1983 if self._readonly:
1984 raise ValueError("This StatsLevel1 instance is read-only")
1985 self._ptr[0].batch_read_bw_bytes = val
1987 @property
1988 def batch_write_bw_bytes(self):
1989 """int: """
1990 return self._ptr[0].batch_write_bw_bytes
1992 @batch_write_bw_bytes.setter
1993 def batch_write_bw_bytes(self, val):
1994 if self._readonly:
1995 raise ValueError("This StatsLevel1 instance is read-only")
1996 self._ptr[0].batch_write_bw_bytes = val
1998 @property
1999 def batch_submit_lat_avg_us(self):
2000 """int: """
2001 return self._ptr[0].batch_submit_lat_avg_us
2003 @batch_submit_lat_avg_us.setter
2004 def batch_submit_lat_avg_us(self, val):
2005 if self._readonly:
2006 raise ValueError("This StatsLevel1 instance is read-only")
2007 self._ptr[0].batch_submit_lat_avg_us = val
2009 @property
2010 def batch_completion_lat_avg_us(self):
2011 """int: """
2012 return self._ptr[0].batch_completion_lat_avg_us
2014 @batch_completion_lat_avg_us.setter
2015 def batch_completion_lat_avg_us(self, val):
2016 if self._readonly:
2017 raise ValueError("This StatsLevel1 instance is read-only")
2018 self._ptr[0].batch_completion_lat_avg_us = val
2020 @property
2021 def batch_submit_ops_per_sec(self):
2022 """int: """
2023 return self._ptr[0].batch_submit_ops_per_sec
2025 @batch_submit_ops_per_sec.setter
2026 def batch_submit_ops_per_sec(self, val):
2027 if self._readonly:
2028 raise ValueError("This StatsLevel1 instance is read-only")
2029 self._ptr[0].batch_submit_ops_per_sec = val
2031 @property
2032 def batch_complete_ops_per_sec(self):
2033 """int: """
2034 return self._ptr[0].batch_complete_ops_per_sec
2036 @batch_complete_ops_per_sec.setter
2037 def batch_complete_ops_per_sec(self, val):
2038 if self._readonly:
2039 raise ValueError("This StatsLevel1 instance is read-only")
2040 self._ptr[0].batch_complete_ops_per_sec = val
2042 @property
2043 def batch_submit_lat_sum_us(self):
2044 """int: """
2045 return self._ptr[0].batch_submit_lat_sum_us
2047 @batch_submit_lat_sum_us.setter
2048 def batch_submit_lat_sum_us(self, val):
2049 if self._readonly:
2050 raise ValueError("This StatsLevel1 instance is read-only")
2051 self._ptr[0].batch_submit_lat_sum_us = val
2053 @property
2054 def batch_completion_lat_sum_us(self):
2055 """int: """
2056 return self._ptr[0].batch_completion_lat_sum_us
2058 @batch_completion_lat_sum_us.setter
2059 def batch_completion_lat_sum_us(self, val):
2060 if self._readonly:
2061 raise ValueError("This StatsLevel1 instance is read-only")
2062 self._ptr[0].batch_completion_lat_sum_us = val
2064 @property
2065 def last_batch_read_bytes(self):
2066 """int: """
2067 return self._ptr[0].last_batch_read_bytes
2069 @last_batch_read_bytes.setter
2070 def last_batch_read_bytes(self, val):
2071 if self._readonly:
2072 raise ValueError("This StatsLevel1 instance is read-only")
2073 self._ptr[0].last_batch_read_bytes = val
2075 @property
2076 def last_batch_write_bytes(self):
2077 """int: """
2078 return self._ptr[0].last_batch_write_bytes
2080 @last_batch_write_bytes.setter
2081 def last_batch_write_bytes(self, val):
2082 if self._readonly:
2083 raise ValueError("This StatsLevel1 instance is read-only")
2084 self._ptr[0].last_batch_write_bytes = val
2086 @staticmethod
2087 def from_buffer(buffer):
2088 """Create an StatsLevel1 instance with the memory from the given buffer."""
2089 return _cyb_from_buffer(buffer, sizeof(CUfileStatsLevel1_t), StatsLevel1)
2091 @staticmethod
2092 def from_data(data):
2093 """Create an StatsLevel1 instance wrapping the given NumPy array.
2095 Args:
2096 data (_numpy.ndarray): a single-element array of dtype `stats_level1_dtype` holding the data.
2097 """
2098 return _cyb_from_data(data, "stats_level1_dtype", stats_level1_dtype, StatsLevel1) 1c
2100 @staticmethod
2101 def from_ptr(intptr_t ptr, bint readonly=False, object owner=None):
2102 """Create an StatsLevel1 instance wrapping the given pointer.
2104 Args:
2105 ptr (intptr_t): pointer address as Python :class:`int` to the data.
2106 owner (object): The Python object that owns the pointer. If not provided, data will be copied.
2107 readonly (bool): whether the data is read-only (to the user). default is `False`.
2108 """
2109 if ptr == 0: 1c
2110 raise ValueError("ptr must not be null (0)")
2111 cdef StatsLevel1 obj = StatsLevel1.__new__(StatsLevel1) 1c
2112 if owner is None: 1c
2113 obj._ptr = <CUfileStatsLevel1_t *>_cyb_malloc(sizeof(CUfileStatsLevel1_t))
2114 if obj._ptr == NULL:
2115 raise MemoryError("Error allocating StatsLevel1")
2116 _cyb_memcpy(<void*>(obj._ptr), <void*>ptr, sizeof(CUfileStatsLevel1_t))
2117 obj._owner = None
2118 obj._owned = True
2119 else:
2120 obj._ptr = <CUfileStatsLevel1_t *>ptr 1c
2121 obj._owner = owner 1c
2122 obj._owned = False 1c
2123 obj._readonly = readonly 1c
2124 return obj 1c
2127cdef _get_io_params_dtype_offsets():
2128 cdef CUfileIOParams_t pod
2129 return _numpy.dtype({
2130 'names': ['mode', 'u', 'fh', 'opcode', 'cookie'],
2131 'formats': [_numpy.int32, _py_anon_pod2_dtype, _numpy.intp, _numpy.int32, _numpy.intp],
2132 'offsets': [
2133 (<intptr_t>&(pod.mode)) - (<intptr_t>&pod),
2134 (<intptr_t>&(pod.u)) - (<intptr_t>&pod),
2135 (<intptr_t>&(pod.fh)) - (<intptr_t>&pod),
2136 (<intptr_t>&(pod.opcode)) - (<intptr_t>&pod),
2137 (<intptr_t>&(pod.cookie)) - (<intptr_t>&pod),
2138 ],
2139 'itemsize': sizeof(CUfileIOParams_t),
2140 })
2142io_params_dtype = _get_io_params_dtype_offsets()
2144cdef class IOParams:
2145 """Empty-initialize an array of `CUfileIOParams_t`.
2146 The resulting object is of length `size` and of dtype `io_params_dtype`.
2147 If default-constructed, the instance represents a single struct.
2149 Args:
2150 size (int): number of structs, default=1.
2152 .. seealso:: `CUfileIOParams_t`
2153 """
2154 cdef:
2155 readonly object _data
2157 def __init__(self, size=1):
2158 arr = _numpy.empty(size, dtype=io_params_dtype) 1dge
2159 self._data = arr.view(_numpy.recarray) 1dge
2160 assert self._data.itemsize == sizeof(CUfileIOParams_t), \ 1dge
2161 f"itemsize {self._data.itemsize} mismatches struct size { sizeof(CUfileIOParams_t) }"
2163 def __repr__(self):
2164 if self._data.size > 1:
2165 return f"<{__name__}.IOParams_Array_{self._data.size} object at {hex(id(self))}>"
2166 else:
2167 return f"<{__name__}.IOParams object at {hex(id(self))}>"
2169 @property
2170 def ptr(self):
2171 """Get the pointer address to the data as Python :class:`int`."""
2172 return self._data.ctypes.data 1dge
2174 cdef intptr_t _get_ptr(self):
2175 return self._data.ctypes.data
2177 def __int__(self):
2178 if self._data.size > 1:
2179 raise TypeError("int() argument must be a bytes-like object of size 1. "
2180 "To get the pointer address of an array, use .ptr")
2181 return self._data.ctypes.data
2183 def __len__(self):
2184 return self._data.size
2186 def __eq__(self, other):
2187 cdef object self_data = self._data
2188 if (not isinstance(other, IOParams)) or self_data.size != other._data.size or self_data.dtype != other._data.dtype:
2189 return False
2190 return bool((self_data == other._data).all())
2192 def __getbuffer__(self, Py_buffer *buffer, int flags):
2193 _cyb_cpython.PyObject_GetBuffer(self._data, buffer, flags)
2195 def __releasebuffer__(self, Py_buffer *buffer):
2196 _cyb_cpython.PyBuffer_Release(buffer)
2198 @property
2199 def mode(self):
2200 """Union[~_numpy.int32, int]: """
2201 if self._data.size == 1:
2202 return int(self._data.mode[0])
2203 return self._data.mode
2205 @mode.setter
2206 def mode(self, val):
2207 self._data.mode = val 1dge
2209 @property
2210 def u(self):
2211 """_py_anon_pod2_dtype: """
2212 return self._data.u 1dge
2214 @u.setter
2215 def u(self, val):
2216 self._data.u = val
2218 @property
2219 def fh(self):
2220 """Union[~_numpy.intp, int]: """
2221 if self._data.size == 1:
2222 return int(self._data.fh[0])
2223 return self._data.fh
2225 @fh.setter
2226 def fh(self, val):
2227 self._data.fh = val 1dge
2229 @property
2230 def opcode(self):
2231 """Union[~_numpy.int32, int]: """
2232 if self._data.size == 1:
2233 return int(self._data.opcode[0])
2234 return self._data.opcode
2236 @opcode.setter
2237 def opcode(self, val):
2238 self._data.opcode = val 1dge
2240 @property
2241 def cookie(self):
2242 """Union[~_numpy.intp, int]: """
2243 if self._data.size == 1:
2244 return int(self._data.cookie[0])
2245 return self._data.cookie
2247 @cookie.setter
2248 def cookie(self, val):
2249 self._data.cookie = val 1dge
2251 def __getitem__(self, key):
2252 cdef ssize_t key_
2253 cdef ssize_t size
2254 if isinstance(key, int): 1dge
2255 key_ = key 1dge
2256 size = self._data.size 1dge
2257 if key_ >= size or key_ <= -(size+1): 1dge
2258 raise IndexError("index is out of bounds")
2259 if key_ < 0: 1dge
2260 key_ += size
2261 return IOParams.from_data(self._data[key_:key_+1]) 1dge
2262 out = self._data[key]
2263 if isinstance(out, _numpy.recarray) and out.dtype == io_params_dtype:
2264 return IOParams.from_data(out)
2265 return out
2267 def __setitem__(self, key, val):
2268 self._data[key] = val
2270 @staticmethod
2271 def from_buffer(buffer):
2272 """Create an IOParams instance with the memory from the given buffer."""
2273 return IOParams.from_data(_numpy.frombuffer(buffer, dtype=io_params_dtype))
2275 @staticmethod
2276 def from_data(data):
2277 """Create an IOParams instance wrapping the given NumPy array.
2279 Args:
2280 data (_numpy.ndarray): a 1D array of dtype `io_params_dtype` holding the data.
2281 """
2282 cdef IOParams obj = IOParams.__new__(IOParams) 1dge
2283 if not isinstance(data, _numpy.ndarray): 1dge
2284 raise TypeError("data argument must be a NumPy ndarray")
2285 if data.ndim != 1: 1dge
2286 raise ValueError("data array must be 1D")
2287 if data.dtype != io_params_dtype: 1dge
2288 raise ValueError("data array must be of dtype io_params_dtype")
2289 obj._data = data.view(_numpy.recarray) 1dge
2291 return obj 1dge
2293 @staticmethod
2294 def from_ptr(intptr_t ptr, size_t size=1, bint readonly=False):
2295 """Create an IOParams instance wrapping the given pointer.
2297 Args:
2298 ptr (intptr_t): pointer address as Python :class:`int` to the data.
2299 size (int): number of structs, default=1.
2300 readonly (bool): whether the data is read-only (to the user). default is `False`.
2301 """
2302 if ptr == 0:
2303 raise ValueError("ptr must not be null (0)")
2304 cdef IOParams obj = IOParams.__new__(IOParams)
2305 cdef flag = _cyb_cpython_buffer.PyBUF_READ if readonly else _cyb_cpython_buffer.PyBUF_WRITE
2306 cdef object buf = _cyb_cpython_memoryview.PyMemoryView_FromMemory(
2307 <char*>ptr, sizeof(CUfileIOParams_t) * size, flag)
2308 data = _numpy.ndarray(size, buffer=buf, dtype=io_params_dtype)
2309 obj._data = data.view(_numpy.recarray)
2311 return obj
2314cdef _get_stats_level2_dtype_offsets():
2315 cdef CUfileStatsLevel2_t pod
2316 return _numpy.dtype({
2317 'names': ['basic', 'read_size_kb_hist', 'write_size_kb_hist'],
2318 'formats': [stats_level1_dtype, (_numpy.uint64, 32), (_numpy.uint64, 32)],
2319 'offsets': [
2320 (<intptr_t>&(pod.basic)) - (<intptr_t>&pod),
2321 (<intptr_t>&(pod.read_size_kb_hist)) - (<intptr_t>&pod),
2322 (<intptr_t>&(pod.write_size_kb_hist)) - (<intptr_t>&pod),
2323 ],
2324 'itemsize': sizeof(CUfileStatsLevel2_t),
2325 })
2327stats_level2_dtype = _get_stats_level2_dtype_offsets()
2329cdef class StatsLevel2:
2330 """Empty-initialize an instance of `CUfileStatsLevel2_t`.
2333 .. seealso:: `CUfileStatsLevel2_t`
2334 """
2335 cdef:
2336 CUfileStatsLevel2_t *_ptr
2337 object _owner
2338 bint _owned
2339 bint _readonly
2341 def __init__(self):
2342 self._ptr = <CUfileStatsLevel2_t *>_cyb_calloc(1, sizeof(CUfileStatsLevel2_t)) 1c
2343 if self._ptr == NULL: 1c
2344 raise MemoryError("Error allocating StatsLevel2")
2345 self._owner = None 1c
2346 self._owned = True 1c
2347 self._readonly = False 1c
2349 def __dealloc__(self):
2350 cdef CUfileStatsLevel2_t *ptr
2351 if self._owned and self._ptr != NULL: 1cb
2352 ptr = self._ptr 1c
2353 self._ptr = NULL 1c
2354 _cyb_free(ptr) 1c
2356 def __repr__(self):
2357 return f"<{__name__}.StatsLevel2 object at {hex(id(self))}>"
2359 @property
2360 def ptr(self):
2361 """Get the pointer address to the data as Python :class:`int`."""
2362 return <intptr_t>(self._ptr) 1c
2364 cdef intptr_t _get_ptr(self):
2365 return <intptr_t>(self._ptr)
2367 def __int__(self):
2368 return <intptr_t>(self._ptr)
2370 def __eq__(self, other):
2371 cdef StatsLevel2 other_
2372 if not isinstance(other, StatsLevel2):
2373 return False
2374 other_ = other
2375 return (_cyb_memcmp(<void *><intptr_t>(self._ptr), <void *><intptr_t>(other_._ptr), sizeof(CUfileStatsLevel2_t)) == 0)
2377 def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags):
2378 _cyb___getbuffer(self, buffer, <void *>self._ptr, sizeof(CUfileStatsLevel2_t), self._readonly)
2380 def __releasebuffer__(self, Py_buffer *buffer):
2381 pass
2383 def __setitem__(self, key, val):
2384 if key == 0 and isinstance(val, _numpy.ndarray):
2385 self._ptr = <CUfileStatsLevel2_t *>_cyb_malloc(sizeof(CUfileStatsLevel2_t))
2386 if self._ptr == NULL:
2387 raise MemoryError("Error allocating StatsLevel2")
2388 _cyb_memcpy(<void*>self._ptr, <void*><intptr_t>val.ctypes.data, sizeof(CUfileStatsLevel2_t))
2389 self._owner = None
2390 self._owned = True
2391 self._readonly = not val.flags.writeable
2392 else:
2393 setattr(self, key, val)
2395 @property
2396 def basic(self):
2397 """StatsLevel1: """
2398 return StatsLevel1.from_ptr(<intptr_t>&(self._ptr[0].basic), self._readonly, self) 1c
2400 @basic.setter
2401 def basic(self, val):
2402 if self._readonly:
2403 raise ValueError("This StatsLevel2 instance is read-only")
2404 cdef StatsLevel1 val_ = val
2405 _cyb_memcpy(<void *>&(self._ptr[0].basic), <void *>(val_._get_ptr()), sizeof(CUfileStatsLevel1_t) * 1)
2407 @property
2408 def read_size_kb_hist(self):
2409 """~_numpy.uint64: (array of length 32)."""
2410 cdef _cyb_view.array arr = _cyb_view.array(shape=(32,), itemsize=sizeof(uint64_t), format="Q", mode="c", allocate_buffer=False) 1cb
2411 arr.data = <char *>(&(self._ptr[0].read_size_kb_hist)) 1cb
2412 return _numpy.asarray(arr) 1cb
2414 @read_size_kb_hist.setter
2415 def read_size_kb_hist(self, val):
2416 if self._readonly:
2417 raise ValueError("This StatsLevel2 instance is read-only")
2418 if len(val) != 32:
2419 raise ValueError(f"Expected length { 32 } for field read_size_kb_hist, got {len(val)}")
2420 cdef _cyb_view.array arr = _cyb_view.array(shape=(32,), itemsize=sizeof(uint64_t), format="Q", mode="c")
2421 arr[:] = _numpy.asarray(val, dtype=_numpy.uint64)
2422 _cyb_memcpy(<void *>(&(self._ptr[0].read_size_kb_hist)), <void *>(arr.data), sizeof(uint64_t) * len(val))
2424 @property
2425 def write_size_kb_hist(self):
2426 """~_numpy.uint64: (array of length 32)."""
2427 cdef _cyb_view.array arr = _cyb_view.array(shape=(32,), itemsize=sizeof(uint64_t), format="Q", mode="c", allocate_buffer=False) 1c
2428 arr.data = <char *>(&(self._ptr[0].write_size_kb_hist)) 1c
2429 return _numpy.asarray(arr) 1c
2431 @write_size_kb_hist.setter
2432 def write_size_kb_hist(self, val):
2433 if self._readonly:
2434 raise ValueError("This StatsLevel2 instance is read-only")
2435 if len(val) != 32:
2436 raise ValueError(f"Expected length { 32 } for field write_size_kb_hist, got {len(val)}")
2437 cdef _cyb_view.array arr = _cyb_view.array(shape=(32,), itemsize=sizeof(uint64_t), format="Q", mode="c")
2438 arr[:] = _numpy.asarray(val, dtype=_numpy.uint64)
2439 _cyb_memcpy(<void *>(&(self._ptr[0].write_size_kb_hist)), <void *>(arr.data), sizeof(uint64_t) * len(val))
2441 @staticmethod
2442 def from_buffer(buffer):
2443 """Create an StatsLevel2 instance with the memory from the given buffer."""
2444 return _cyb_from_buffer(buffer, sizeof(CUfileStatsLevel2_t), StatsLevel2)
2446 @staticmethod
2447 def from_data(data):
2448 """Create an StatsLevel2 instance wrapping the given NumPy array.
2450 Args:
2451 data (_numpy.ndarray): a single-element array of dtype `stats_level2_dtype` holding the data.
2452 """
2453 return _cyb_from_data(data, "stats_level2_dtype", stats_level2_dtype, StatsLevel2) 1b
2455 @staticmethod
2456 def from_ptr(intptr_t ptr, bint readonly=False, object owner=None):
2457 """Create an StatsLevel2 instance wrapping the given pointer.
2459 Args:
2460 ptr (intptr_t): pointer address as Python :class:`int` to the data.
2461 owner (object): The Python object that owns the pointer. If not provided, data will be copied.
2462 readonly (bool): whether the data is read-only (to the user). default is `False`.
2463 """
2464 if ptr == 0: 1b
2465 raise ValueError("ptr must not be null (0)")
2466 cdef StatsLevel2 obj = StatsLevel2.__new__(StatsLevel2) 1b
2467 if owner is None: 1b
2468 obj._ptr = <CUfileStatsLevel2_t *>_cyb_malloc(sizeof(CUfileStatsLevel2_t))
2469 if obj._ptr == NULL:
2470 raise MemoryError("Error allocating StatsLevel2")
2471 _cyb_memcpy(<void*>(obj._ptr), <void*>ptr, sizeof(CUfileStatsLevel2_t))
2472 obj._owner = None
2473 obj._owned = True
2474 else:
2475 obj._ptr = <CUfileStatsLevel2_t *>ptr 1b
2476 obj._owner = owner 1b
2477 obj._owned = False 1b
2478 obj._readonly = readonly 1b
2479 return obj 1b
2482cdef _get_stats_level3_dtype_offsets():
2483 cdef CUfileStatsLevel3_t pod
2484 return _numpy.dtype({
2485 'names': ['detailed', 'num_gpus', 'per_gpu_stats'],
2486 'formats': [stats_level2_dtype, _numpy.uint32, (per_gpu_stats_dtype, 16)],
2487 'offsets': [
2488 (<intptr_t>&(pod.detailed)) - (<intptr_t>&pod),
2489 (<intptr_t>&(pod.num_gpus)) - (<intptr_t>&pod),
2490 (<intptr_t>&(pod.per_gpu_stats)) - (<intptr_t>&pod),
2491 ],
2492 'itemsize': sizeof(CUfileStatsLevel3_t),
2493 })
2495stats_level3_dtype = _get_stats_level3_dtype_offsets()
2497cdef class StatsLevel3:
2498 """Empty-initialize an instance of `CUfileStatsLevel3_t`.
2501 .. seealso:: `CUfileStatsLevel3_t`
2502 """
2503 cdef:
2504 CUfileStatsLevel3_t *_ptr
2505 object _owner
2506 bint _owned
2507 bint _readonly
2509 def __init__(self):
2510 self._ptr = <CUfileStatsLevel3_t *>_cyb_calloc(1, sizeof(CUfileStatsLevel3_t)) 1b
2511 if self._ptr == NULL: 1b
2512 raise MemoryError("Error allocating StatsLevel3")
2513 self._owner = None 1b
2514 self._owned = True 1b
2515 self._readonly = False 1b
2517 def __dealloc__(self):
2518 cdef CUfileStatsLevel3_t *ptr
2519 if self._owned and self._ptr != NULL: 1b
2520 ptr = self._ptr 1b
2521 self._ptr = NULL 1b
2522 _cyb_free(ptr) 1b
2524 def __repr__(self):
2525 return f"<{__name__}.StatsLevel3 object at {hex(id(self))}>"
2527 @property
2528 def ptr(self):
2529 """Get the pointer address to the data as Python :class:`int`."""
2530 return <intptr_t>(self._ptr) 1b
2532 cdef intptr_t _get_ptr(self):
2533 return <intptr_t>(self._ptr)
2535 def __int__(self):
2536 return <intptr_t>(self._ptr)
2538 def __eq__(self, other):
2539 cdef StatsLevel3 other_
2540 if not isinstance(other, StatsLevel3):
2541 return False
2542 other_ = other
2543 return (_cyb_memcmp(<void *><intptr_t>(self._ptr), <void *><intptr_t>(other_._ptr), sizeof(CUfileStatsLevel3_t)) == 0)
2545 def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags):
2546 _cyb___getbuffer(self, buffer, <void *>self._ptr, sizeof(CUfileStatsLevel3_t), self._readonly)
2548 def __releasebuffer__(self, Py_buffer *buffer):
2549 pass
2551 def __setitem__(self, key, val):
2552 if key == 0 and isinstance(val, _numpy.ndarray):
2553 self._ptr = <CUfileStatsLevel3_t *>_cyb_malloc(sizeof(CUfileStatsLevel3_t))
2554 if self._ptr == NULL:
2555 raise MemoryError("Error allocating StatsLevel3")
2556 _cyb_memcpy(<void*>self._ptr, <void*><intptr_t>val.ctypes.data, sizeof(CUfileStatsLevel3_t))
2557 self._owner = None
2558 self._owned = True
2559 self._readonly = not val.flags.writeable
2560 else:
2561 setattr(self, key, val)
2563 @property
2564 def detailed(self):
2565 """StatsLevel2: """
2566 return StatsLevel2.from_ptr(<intptr_t>&(self._ptr[0].detailed), self._readonly, self) 1b
2568 @detailed.setter
2569 def detailed(self, val):
2570 if self._readonly:
2571 raise ValueError("This StatsLevel3 instance is read-only")
2572 cdef StatsLevel2 val_ = val
2573 _cyb_memcpy(<void *>&(self._ptr[0].detailed), <void *>(val_._get_ptr()), sizeof(CUfileStatsLevel2_t) * 1)
2575 @property
2576 def per_gpu_stats(self):
2577 """PerGpuStats: """
2578 return PerGpuStats.from_ptr(<intptr_t>&(self._ptr[0].per_gpu_stats), 16, self._readonly) 1b
2580 @per_gpu_stats.setter
2581 def per_gpu_stats(self, val):
2582 if self._readonly:
2583 raise ValueError("This StatsLevel3 instance is read-only")
2584 cdef PerGpuStats val_ = val
2585 if len(val) != 16:
2586 raise ValueError(f"Expected length { 16 } for field per_gpu_stats, got {len(val)}")
2587 _cyb_memcpy(<void *>&(self._ptr[0].per_gpu_stats), <void *>(val_._get_ptr()), sizeof(CUfilePerGpuStats_t) * 16)
2589 @property
2590 def num_gpus(self):
2591 """int: """
2592 return self._ptr[0].num_gpus 1b
2594 @num_gpus.setter
2595 def num_gpus(self, val):
2596 if self._readonly:
2597 raise ValueError("This StatsLevel3 instance is read-only")
2598 self._ptr[0].num_gpus = val
2600 @staticmethod
2601 def from_buffer(buffer):
2602 """Create an StatsLevel3 instance with the memory from the given buffer."""
2603 return _cyb_from_buffer(buffer, sizeof(CUfileStatsLevel3_t), StatsLevel3)
2605 @staticmethod
2606 def from_data(data):
2607 """Create an StatsLevel3 instance wrapping the given NumPy array.
2609 Args:
2610 data (_numpy.ndarray): a single-element array of dtype `stats_level3_dtype` holding the data.
2611 """
2612 return _cyb_from_data(data, "stats_level3_dtype", stats_level3_dtype, StatsLevel3)
2614 @staticmethod
2615 def from_ptr(intptr_t ptr, bint readonly=False, object owner=None):
2616 """Create an StatsLevel3 instance wrapping the given pointer.
2618 Args:
2619 ptr (intptr_t): pointer address as Python :class:`int` to the data.
2620 owner (object): The Python object that owns the pointer. If not provided, data will be copied.
2621 readonly (bool): whether the data is read-only (to the user). default is `False`.
2622 """
2623 if ptr == 0:
2624 raise ValueError("ptr must not be null (0)")
2625 cdef StatsLevel3 obj = StatsLevel3.__new__(StatsLevel3)
2626 if owner is None:
2627 obj._ptr = <CUfileStatsLevel3_t *>_cyb_malloc(sizeof(CUfileStatsLevel3_t))
2628 if obj._ptr == NULL:
2629 raise MemoryError("Error allocating StatsLevel3")
2630 _cyb_memcpy(<void*>(obj._ptr), <void*>ptr, sizeof(CUfileStatsLevel3_t))
2631 obj._owner = None
2632 obj._owned = True
2633 else:
2634 obj._ptr = <CUfileStatsLevel3_t *>ptr
2635 obj._owner = owner
2636 obj._owned = False
2637 obj._readonly = readonly
2638 return obj
2641###############################################################################
2642# Enum
2643###############################################################################
2645class OpError(_cyb_FastEnum):
2646 """
2647 See `CUfileOpError`.
2648 """
2649 SUCCESS = CU_FILE_SUCCESS
2650 DRIVER_NOT_INITIALIZED = CU_FILE_DRIVER_NOT_INITIALIZED
2651 DRIVER_INVALID_PROPS = CU_FILE_DRIVER_INVALID_PROPS
2652 DRIVER_UNSUPPORTED_LIMIT = CU_FILE_DRIVER_UNSUPPORTED_LIMIT
2653 DRIVER_VERSION_MISMATCH = CU_FILE_DRIVER_VERSION_MISMATCH
2654 DRIVER_VERSION_READ_ERROR = CU_FILE_DRIVER_VERSION_READ_ERROR
2655 DRIVER_CLOSING = CU_FILE_DRIVER_CLOSING
2656 PLATFORM_NOT_SUPPORTED = CU_FILE_PLATFORM_NOT_SUPPORTED
2657 IO_NOT_SUPPORTED = CU_FILE_IO_NOT_SUPPORTED
2658 DEVICE_NOT_SUPPORTED = CU_FILE_DEVICE_NOT_SUPPORTED
2659 NVFS_DRIVER_ERROR = CU_FILE_NVFS_DRIVER_ERROR
2660 CUDA_DRIVER_ERROR = CU_FILE_CUDA_DRIVER_ERROR
2661 CUDA_POINTER_INVALID = CU_FILE_CUDA_POINTER_INVALID
2662 CUDA_MEMORY_TYPE_INVALID = CU_FILE_CUDA_MEMORY_TYPE_INVALID
2663 CUDA_POINTER_RANGE_ERROR = CU_FILE_CUDA_POINTER_RANGE_ERROR
2664 CUDA_CONTEXT_MISMATCH = CU_FILE_CUDA_CONTEXT_MISMATCH
2665 INVALID_MAPPING_SIZE = CU_FILE_INVALID_MAPPING_SIZE
2666 INVALID_MAPPING_RANGE = CU_FILE_INVALID_MAPPING_RANGE
2667 INVALID_FILE_TYPE = CU_FILE_INVALID_FILE_TYPE
2668 INVALID_FILE_OPEN_FLAG = CU_FILE_INVALID_FILE_OPEN_FLAG
2669 DIO_NOT_SET = CU_FILE_DIO_NOT_SET
2670 INVALID_VALUE = CU_FILE_INVALID_VALUE
2671 MEMORY_ALREADY_REGISTERED = CU_FILE_MEMORY_ALREADY_REGISTERED
2672 MEMORY_NOT_REGISTERED = CU_FILE_MEMORY_NOT_REGISTERED
2673 PERMISSION_DENIED = CU_FILE_PERMISSION_DENIED
2674 DRIVER_ALREADY_OPEN = CU_FILE_DRIVER_ALREADY_OPEN
2675 HANDLE_NOT_REGISTERED = CU_FILE_HANDLE_NOT_REGISTERED
2676 HANDLE_ALREADY_REGISTERED = CU_FILE_HANDLE_ALREADY_REGISTERED
2677 DEVICE_NOT_FOUND = CU_FILE_DEVICE_NOT_FOUND
2678 INTERNAL_ERROR = CU_FILE_INTERNAL_ERROR
2679 GETNEWFD_FAILED = CU_FILE_GETNEWFD_FAILED
2680 NVFS_SETUP_ERROR = CU_FILE_NVFS_SETUP_ERROR
2681 IO_DISABLED = CU_FILE_IO_DISABLED
2682 BATCH_SUBMIT_FAILED = CU_FILE_BATCH_SUBMIT_FAILED
2683 GPU_MEMORY_PINNING_FAILED = CU_FILE_GPU_MEMORY_PINNING_FAILED
2684 BATCH_FULL = CU_FILE_BATCH_FULL
2685 ASYNC_NOT_SUPPORTED = CU_FILE_ASYNC_NOT_SUPPORTED
2686 INTERNAL_BATCH_SETUP_ERROR = CU_FILE_INTERNAL_BATCH_SETUP_ERROR
2687 INTERNAL_BATCH_SUBMIT_ERROR = CU_FILE_INTERNAL_BATCH_SUBMIT_ERROR
2688 INTERNAL_BATCH_GETSTATUS_ERROR = CU_FILE_INTERNAL_BATCH_GETSTATUS_ERROR
2689 INTERNAL_BATCH_CANCEL_ERROR = CU_FILE_INTERNAL_BATCH_CANCEL_ERROR
2690 NOMEM_ERROR = CU_FILE_NOMEM_ERROR
2691 IO_ERROR = CU_FILE_IO_ERROR
2692 INTERNAL_BUF_REGISTER_ERROR = CU_FILE_INTERNAL_BUF_REGISTER_ERROR
2693 HASH_OPR_ERROR = CU_FILE_HASH_OPR_ERROR
2694 INVALID_CONTEXT_ERROR = CU_FILE_INVALID_CONTEXT_ERROR
2695 NVFS_INTERNAL_DRIVER_ERROR = CU_FILE_NVFS_INTERNAL_DRIVER_ERROR
2696 BATCH_NOCOMPAT_ERROR = CU_FILE_BATCH_NOCOMPAT_ERROR
2697 IO_MAX_ERROR = CU_FILE_IO_MAX_ERROR
2699class DriverStatusFlags(_cyb_FastEnum):
2700 """
2701 See `CUfileDriverStatusFlags_t`.
2702 """
2703 LUSTRE_SUPPORTED = (CU_FILE_LUSTRE_SUPPORTED, 'Support for DDN LUSTRE')
2704 WEKAFS_SUPPORTED = (CU_FILE_WEKAFS_SUPPORTED, 'Support for WEKAFS')
2705 NFS_SUPPORTED = (CU_FILE_NFS_SUPPORTED, 'Support for NFS')
2706 GPFS_SUPPORTED = CU_FILE_GPFS_SUPPORTED
2707 NVME_SUPPORTED = (CU_FILE_NVME_SUPPORTED, '< Support for GPFS Support for NVMe')
2708 NVMEOF_SUPPORTED = (CU_FILE_NVMEOF_SUPPORTED, 'Support for NVMeOF')
2709 SCSI_SUPPORTED = (CU_FILE_SCSI_SUPPORTED, 'Support for SCSI')
2710 SCALEFLUX_CSD_SUPPORTED = (CU_FILE_SCALEFLUX_CSD_SUPPORTED, 'Support for Scaleflux CSD')
2711 NVMESH_SUPPORTED = (CU_FILE_NVMESH_SUPPORTED, 'Support for NVMesh Block Dev')
2712 BEEGFS_SUPPORTED = (CU_FILE_BEEGFS_SUPPORTED, 'Support for BeeGFS')
2713 NVME_P2P_SUPPORTED = (CU_FILE_NVME_P2P_SUPPORTED, 'Do not use this macro. This is deprecated now')
2714 SCATEFS_SUPPORTED = (CU_FILE_SCATEFS_SUPPORTED, 'Support for ScateFS')
2715 VIRTIOFS_SUPPORTED = (CU_FILE_VIRTIOFS_SUPPORTED, 'Support for VirtioFS')
2716 MAX_TARGET_TYPES = (CU_FILE_MAX_TARGET_TYPES, 'Maximum FS supported')
2718class DriverControlFlags(_cyb_FastEnum):
2719 """
2720 See `CUfileDriverControlFlags_t`.
2721 """
2722 USE_POLL_MODE = (CU_FILE_USE_POLL_MODE, 'use POLL mode. properties.use_poll_mode')
2723 ALLOW_COMPAT_MODE = (CU_FILE_ALLOW_COMPAT_MODE, 'allow COMPATIBILITY mode. properties.allow_compat_mode')
2724 POSIX_IO_MODE = (CU_FILE_POSIX_IO_MODE, 'Vanilla posix io mode. properties.posix_io_mode')
2725 FALLBACK_IO_MODE = (CU_FILE_FALLBACK_IO_MODE, 'Fallback io mode. properties.gds_fallback_io')
2727class FeatureFlags(_cyb_FastEnum):
2728 """
2729 See `CUfileFeatureFlags_t`.
2730 """
2731 DYN_ROUTING_SUPPORTED = (CU_FILE_DYN_ROUTING_SUPPORTED, 'Support for Dynamic routing to handle devices across the PCIe bridges')
2732 BATCH_IO_SUPPORTED = (CU_FILE_BATCH_IO_SUPPORTED, 'Supported')
2733 STREAMS_SUPPORTED = (CU_FILE_STREAMS_SUPPORTED, 'Supported')
2734 PARALLEL_IO_SUPPORTED = (CU_FILE_PARALLEL_IO_SUPPORTED, 'Supported')
2735 P2P_SUPPORTED = (CU_FILE_P2P_SUPPORTED, 'Support for PCI P2PDMA')
2737class FileHandleType(_cyb_FastEnum):
2738 """
2739 See `CUfileFileHandleType`.
2740 """
2741 OPAQUE_FD = (CU_FILE_HANDLE_TYPE_OPAQUE_FD, 'Linux based fd')
2742 OPAQUE_WIN32 = (CU_FILE_HANDLE_TYPE_OPAQUE_WIN32, 'Windows based handle (unsupported)')
2743 USERSPACE_FS = CU_FILE_HANDLE_TYPE_USERSPACE_FS
2745class Opcode(_cyb_FastEnum):
2746 """
2747 See `CUfileOpcode_t`.
2748 """
2749 READ = CUFILE_READ
2750 WRITE = CUFILE_WRITE
2752class Status(_cyb_FastEnum):
2753 """
2754 See `CUfileStatus_t`.
2755 """
2756 WAITING = CUFILE_WAITING
2757 PENDING = CUFILE_PENDING
2758 INVALID = CUFILE_INVALID
2759 CANCELED = CUFILE_CANCELED
2760 COMPLETE = CUFILE_COMPLETE
2761 TIMEOUT = CUFILE_TIMEOUT
2762 FAILED = CUFILE_FAILED
2764class BatchMode(_cyb_FastEnum):
2765 """
2766 See `CUfileBatchMode_t`.
2767 """
2768 BATCH = CUFILE_BATCH
2770class SizeTConfigParameter(_cyb_FastEnum):
2771 """
2772 See `CUFileSizeTConfigParameter_t`.
2773 """
2774 PROFILE_STATS = CUFILE_PARAM_PROFILE_STATS
2775 EXECUTION_MAX_IO_QUEUE_DEPTH = CUFILE_PARAM_EXECUTION_MAX_IO_QUEUE_DEPTH
2776 EXECUTION_MAX_IO_THREADS = CUFILE_PARAM_EXECUTION_MAX_IO_THREADS
2777 EXECUTION_MIN_IO_THRESHOLD_SIZE_KB = CUFILE_PARAM_EXECUTION_MIN_IO_THRESHOLD_SIZE_KB
2778 EXECUTION_MAX_REQUEST_PARALLELISM = CUFILE_PARAM_EXECUTION_MAX_REQUEST_PARALLELISM
2779 PROPERTIES_MAX_DIRECT_IO_SIZE_KB = CUFILE_PARAM_PROPERTIES_MAX_DIRECT_IO_SIZE_KB
2780 PROPERTIES_MAX_DEVICE_CACHE_SIZE_KB = CUFILE_PARAM_PROPERTIES_MAX_DEVICE_CACHE_SIZE_KB
2781 PROPERTIES_PER_BUFFER_CACHE_SIZE_KB = CUFILE_PARAM_PROPERTIES_PER_BUFFER_CACHE_SIZE_KB
2782 PROPERTIES_MAX_DEVICE_PINNED_MEM_SIZE_KB = CUFILE_PARAM_PROPERTIES_MAX_DEVICE_PINNED_MEM_SIZE_KB
2783 PROPERTIES_IO_BATCHSIZE = CUFILE_PARAM_PROPERTIES_IO_BATCHSIZE
2784 POLLTHRESHOLD_SIZE_KB = CUFILE_PARAM_POLLTHRESHOLD_SIZE_KB
2785 PROPERTIES_BATCH_IO_TIMEOUT_MS = CUFILE_PARAM_PROPERTIES_BATCH_IO_TIMEOUT_MS
2787class BoolConfigParameter(_cyb_FastEnum):
2788 """
2789 See `CUFileBoolConfigParameter_t`.
2790 """
2791 PROPERTIES_USE_POLL_MODE = CUFILE_PARAM_PROPERTIES_USE_POLL_MODE
2792 PROPERTIES_ALLOW_COMPAT_MODE = CUFILE_PARAM_PROPERTIES_ALLOW_COMPAT_MODE
2793 FORCE_COMPAT_MODE = CUFILE_PARAM_FORCE_COMPAT_MODE
2794 FS_MISC_API_CHECK_AGGRESSIVE = CUFILE_PARAM_FS_MISC_API_CHECK_AGGRESSIVE
2795 EXECUTION_PARALLEL_IO = CUFILE_PARAM_EXECUTION_PARALLEL_IO
2796 PROFILE_NVTX = CUFILE_PARAM_PROFILE_NVTX
2797 PROPERTIES_ALLOW_SYSTEM_MEMORY = CUFILE_PARAM_PROPERTIES_ALLOW_SYSTEM_MEMORY
2798 USE_PCIP2PDMA = CUFILE_PARAM_USE_PCIP2PDMA
2799 PREFER_IO_URING = CUFILE_PARAM_PREFER_IO_URING
2800 FORCE_ODIRECT_MODE = CUFILE_PARAM_FORCE_ODIRECT_MODE
2801 SKIP_TOPOLOGY_DETECTION = CUFILE_PARAM_SKIP_TOPOLOGY_DETECTION
2802 STREAM_MEMOPS_BYPASS = CUFILE_PARAM_STREAM_MEMOPS_BYPASS
2804class StringConfigParameter(_cyb_FastEnum):
2805 """
2806 See `CUFileStringConfigParameter_t`.
2807 """
2808 LOGGING_LEVEL = CUFILE_PARAM_LOGGING_LEVEL
2809 ENV_LOGFILE_PATH = CUFILE_PARAM_ENV_LOGFILE_PATH
2810 LOG_DIR = CUFILE_PARAM_LOG_DIR
2812class ArrayConfigParameter(_cyb_FastEnum):
2813 """
2814 See `CUFileArrayConfigParameter_t`.
2815 """
2816 POSIX_POOL_SLAB_SIZE_KB = CUFILE_PARAM_POSIX_POOL_SLAB_SIZE_KB
2817 POSIX_POOL_SLAB_COUNT = CUFILE_PARAM_POSIX_POOL_SLAB_COUNT
2818 GPU_BOUNCE_BUFFER_SLAB_SIZE_KB = CUFILE_PARAM_GPU_BOUNCE_BUFFER_SLAB_SIZE_KB
2819 GPU_BOUNCE_BUFFER_SLAB_COUNT = CUFILE_PARAM_GPU_BOUNCE_BUFFER_SLAB_COUNT
2821class P2PFlags(_cyb_FastEnum):
2822 """
2823 See `CUfileP2PFlags_t`.
2824 """
2825 P2PDMA = (CUFILE_P2PDMA, 'Support for PCI P2PDMA')
2826 NVFS = (CUFILE_NVFS, 'Support for nvidia-fs')
2827 DMABUF = (CUFILE_DMABUF, 'Support for DMA Buffer')
2828 C2C = (CUFILE_C2C, 'Support for Chip-to-Chip (Grace-based systems)')
2829 NVIDIA_PEERMEM = (CUFILE_NVIDIA_PEERMEM, 'Only for IBM Spectrum Scale and WekaFS')
2832###############################################################################
2833# Error handling
2834###############################################################################
2836ctypedef fused ReturnT:
2837 CUfileError_t
2838 ssize_t
2841class cuFileError(Exception):
2843 def __init__(self, status, cu_err=None):
2844 self.status = status 1pno
2845 self.cuda_error = cu_err 1pno
2846 s = OpError(status) 1pno
2847 cdef str err = f"{s.name} ({s.value}): {op_status_error(status)}" 1pno
2848 if cu_err is not None: 1pno
2849 e = pyCUresult(cu_err) 1pno
2850 err += f"; CUDA status: {e.name} ({e.value})" 1pno
2851 super(cuFileError, self).__init__(err) 1pno
2853 def __reduce__(self):
2854 return (type(self), (self.status, self.cuda_error))
2857@cython.profile(False)
2858cdef int check_status(ReturnT status) except 1 nogil:
2859 if ReturnT is CUfileError_t:
2860 if status.err != 0 or status.cu_err != 0: 1adOPgQReSTpUVFWXGYZH01I23J45h67i89j!#k$%l'(m)*M+,N-.fAtcBubCvr/:qKsnwL;oDxyEz
2861 with gil: 1pno
2862 raise cuFileError(status.err, status.cu_err) 1pno
2863 elif ReturnT is ssize_t:
2864 if status == -1: 1jklfcb
2865 # note: this assumes cuFile already properly resets errno in each API
2866 with gil:
2867 raise cuFileError(errno.errno)
2868 return 0 1adOPgQReSTpUVFWXGYZH01I23J45h67i89j!#k$%l'(m)*M+,N-.fAtcBubCvr/:qKsnwL;oDxyEz
2871###############################################################################
2872# Wrapper functions
2873###############################################################################
2875cpdef intptr_t handle_register(intptr_t descr) except? 0:
2876 """cuFileHandleRegister is required, and performs extra checking that is memoized to provide increased performance on later cuFile operations.
2878 Args:
2879 descr (intptr_t): ``CUfileDescr_t`` file descriptor (OS agnostic).
2881 Returns:
2882 intptr_t: ``CUfileHandle_t`` opaque file handle for IO operations.
2884 .. seealso:: `cuFileHandleRegister`
2885 """
2886 cdef Handle fh
2887 with nogil: 1dgehijklmfcbr
2888 __status__ = cuFileHandleRegister(&fh, <CUfileDescr_t*>descr) 1dgehijklmfcbr
2889 check_status(__status__) 1dgehijklmfcbr
2890 return <intptr_t>fh 1dgehijklmfcbr
2893cpdef void handle_deregister(intptr_t fh) except*:
2894 """releases a registered filehandle from cuFile.
2896 Args:
2897 fh (intptr_t): ``CUfileHandle_t`` file handle.
2899 .. seealso:: `cuFileHandleDeregister`
2900 """
2901 with nogil: 1dgehijklmfcbr
2902 cuFileHandleDeregister(<Handle>fh) 1dgehijklmfcbr
2905cpdef buf_register(intptr_t buf_ptr_base, size_t length, int flags):
2906 """register an existing cudaMalloced memory with cuFile to pin for GPUDirect Storage access or register host allocated memory with cuFile.
2908 Args:
2909 buf_ptr_base (intptr_t): buffer pointer allocated.
2910 length (size_t): size of memory region from the above specified bufPtr.
2911 flags (int): CU_FILE_RDMA_REGISTER.
2913 .. seealso:: `cuFileBufRegister`
2914 """
2915 with nogil: 1dgepFGHIJhijklmfcb
2916 __status__ = cuFileBufRegister(<const void*>buf_ptr_base, length, flags) 1dgepFGHIJhijklmfcb
2917 check_status(__status__) 1dgepFGHIJhijklmfcb
2920cpdef buf_deregister(intptr_t buf_ptr_base):
2921 """deregister an already registered device or host memory from cuFile.
2923 Args:
2924 buf_ptr_base (intptr_t): buffer pointer to deregister.
2926 .. seealso:: `cuFileBufDeregister`
2927 """
2928 with nogil: 1dgepFGHIJhijklmfcb
2929 __status__ = cuFileBufDeregister(<const void*>buf_ptr_base) 1dgepFGHIJhijklmfcb
2930 check_status(__status__) 1dgepFGHIJhijklmfcb
2933cpdef driver_open():
2934 """Initialize the cuFile library and open the nvidia-fs driver.
2936 .. seealso:: `cuFileDriverOpen`
2937 """
2938 with nogil: 1OQSUWY02468!$')+-ABC/qKsnwLDE
2939 __status__ = cuFileDriverOpen() 1OQSUWY02468!$')+-ABC/qKsnwLDE
2940 check_status(__status__) 1OQSUWY02468!$')+-ABC/qKsnwLDE
2943cpdef use_count():
2944 """returns use count of cufile drivers at that moment by the process.
2946 .. seealso:: `cuFileUseCount`
2947 """
2948 with nogil:
2949 __status__ = cuFileUseCount()
2950 check_status(__status__)
2953cpdef driver_get_properties(intptr_t props):
2954 """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.
2956 Args:
2957 props (intptr_t): Properties to get.
2959 .. seealso:: `cuFileDriverGetProperties`
2960 """
2961 with nogil:
2962 __status__ = cuFileDriverGetProperties(<CUfileDrvProps_t*>props)
2963 check_status(__status__)
2966cpdef driver_set_poll_mode(bint poll, size_t poll_threshold_size):
2967 """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.
2969 Args:
2970 poll (bint): boolean to indicate whether to use poll mode or not.
2971 poll_threshold_size (size_t): max IO size to use for POLLING mode in KB.
2973 .. seealso:: `cuFileDriverSetPollMode`
2974 """
2975 with nogil:
2976 __status__ = cuFileDriverSetPollMode(<cpp_bool>poll, poll_threshold_size)
2977 check_status(__status__)
2980cpdef driver_set_max_direct_io_size(size_t max_direct_io_size):
2981 """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.
2983 Args:
2984 max_direct_io_size (size_t): maximum allowed direct io size in KB.
2986 .. seealso:: `cuFileDriverSetMaxDirectIOSize`
2987 """
2988 with nogil:
2989 __status__ = cuFileDriverSetMaxDirectIOSize(max_direct_io_size)
2990 check_status(__status__)
2993cpdef driver_set_max_cache_size(size_t max_cache_size):
2994 """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.
2996 Args:
2997 max_cache_size (size_t): The maximum GPU buffer space per device used for internal use in KB.
2999 .. seealso:: `cuFileDriverSetMaxCacheSize`
3000 """
3001 with nogil:
3002 __status__ = cuFileDriverSetMaxCacheSize(max_cache_size)
3003 check_status(__status__)
3006cpdef driver_set_max_pinned_mem_size(size_t max_pinned_size):
3007 """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.
3009 Args:
3010 max_pinned_size (size_t): maximum buffer space that is pinned in KB.
3012 .. seealso:: `cuFileDriverSetMaxPinnedMemSize`
3013 """
3014 with nogil:
3015 __status__ = cuFileDriverSetMaxPinnedMemSize(max_pinned_size)
3016 check_status(__status__)
3019cpdef intptr_t batch_io_set_up(unsigned nr) except? 0:
3020 cdef BatchHandle batch_idp
3021 with nogil: 1dge
3022 __status__ = cuFileBatchIOSetUp(&batch_idp, nr) 1dge
3023 check_status(__status__) 1dge
3024 return <intptr_t>batch_idp 1dge
3027cpdef batch_io_submit(intptr_t batch_idp, unsigned nr, intptr_t iocbp, unsigned int flags):
3028 with nogil: 1dge
3029 __status__ = cuFileBatchIOSubmit(<BatchHandle>batch_idp, nr, <CUfileIOParams_t*>iocbp, flags) 1dge
3030 check_status(__status__) 1dge
3033cpdef batch_io_get_status(intptr_t batch_idp, unsigned min_nr, intptr_t nr, intptr_t iocbp, intptr_t timeout):
3034 with nogil: 1de
3035 __status__ = cuFileBatchIOGetStatus(<BatchHandle>batch_idp, min_nr, <unsigned*>nr, <CUfileIOEvents_t*>iocbp, <timespec*>timeout) 1de
3036 check_status(__status__) 1de
3039cpdef batch_io_cancel(intptr_t batch_idp):
3040 with nogil: 1g
3041 __status__ = cuFileBatchIOCancel(<BatchHandle>batch_idp) 1g
3042 check_status(__status__) 1g
3045cpdef void batch_io_destroy(intptr_t batch_idp) except*:
3046 with nogil: 1dge
3047 cuFileBatchIODestroy(<BatchHandle>batch_idp) 1dge
3050cpdef 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):
3051 with nogil: 1hi
3052 __status__ = cuFileReadAsync(<Handle>fh, <void*>buf_ptr_base, <size_t*>size_p, <off_t*>file_offset_p, <off_t*>buf_ptr_offset_p, <ssize_t*>bytes_read_p, <CUstream>stream) 1hi
3053 check_status(__status__) 1hi
3056cpdef 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):
3057 with nogil: 1hm
3058 __status__ = cuFileWriteAsync(<Handle>fh, <void*>buf_ptr_base, <size_t*>size_p, <off_t*>file_offset_p, <off_t*>buf_ptr_offset_p, <ssize_t*>bytes_written_p, <CUstream>stream) 1hm
3059 check_status(__status__) 1hm
3062cpdef stream_register(intptr_t stream, unsigned flags):
3063 with nogil: 1him
3064 __status__ = cuFileStreamRegister(<CUstream>stream, flags) 1him
3065 check_status(__status__) 1him
3068cpdef stream_deregister(intptr_t stream):
3069 with nogil: 1him
3070 __status__ = cuFileStreamDeregister(<CUstream>stream) 1him
3071 check_status(__status__) 1him
3074cpdef int get_version() except? 0:
3075 """Get the cuFile library version.
3077 Returns:
3078 int: Pointer to an integer where the version will be stored.
3080 .. seealso:: `cuFileGetVersion`
3081 """
3082 cdef int version
3083 with nogil: 1aq
3084 __status__ = cuFileGetVersion(&version) 1aq
3085 check_status(__status__) 1aq
3086 return version 1aq
3089cpdef size_t get_parameter_size_t(int param) except? 0:
3090 cdef size_t value
3091 with nogil: 1s
3092 __status__ = cuFileGetParameterSizeT(<_SizeTConfigParameter>param, &value) 1s
3093 check_status(__status__) 1s
3094 return value 1s
3097cpdef bint get_parameter_bool(int param) except? 0:
3098 cdef cpp_bool value
3099 with nogil: 1q
3100 __status__ = cuFileGetParameterBool(<_BoolConfigParameter>param, &value) 1q
3101 check_status(__status__) 1q
3102 return <bint>value 1q
3105cpdef str get_parameter_string(int param, int len):
3106 cdef bytes _desc_str_ = bytes(len) 1n
3107 cdef char* desc_str = _desc_str_ 1n
3108 with nogil: 1n
3109 __status__ = cuFileGetParameterString(<_StringConfigParameter>param, desc_str, len) 1n
3110 check_status(__status__) 1n
3111 return _cyb_cpython.PyUnicode_FromString(desc_str) 1n
3114cpdef set_parameter_size_t(int param, size_t value):
3115 with nogil: 1s
3116 __status__ = cuFileSetParameterSizeT(<_SizeTConfigParameter>param, value) 1s
3117 check_status(__status__) 1s
3120cpdef set_parameter_bool(int param, bint value):
3121 with nogil: 1q
3122 __status__ = cuFileSetParameterBool(<_BoolConfigParameter>param, <cpp_bool>value) 1q
3123 check_status(__status__) 1q
3126cpdef set_parameter_string(int param, intptr_t desc_str):
3127 with nogil: 1n
3128 __status__ = cuFileSetParameterString(<_StringConfigParameter>param, <const char*>desc_str) 1n
3129 check_status(__status__) 1n
3132cpdef tuple get_parameter_min_max_value(int param):
3133 """Get both the minimum and maximum settable values for a given size_t parameter in a single call.
3135 Args:
3136 param (SizeTConfigParameter): CUfile SizeT configuration parameter.
3138 Returns:
3139 A 2-tuple containing:
3141 - size_t: Pointer to store the minimum value.
3142 - size_t: Pointer to store the maximum value.
3144 .. seealso:: `cuFileGetParameterMinMaxValue`
3145 """
3146 cdef size_t min_value
3147 cdef size_t max_value
3148 with nogil: 1N
3149 __status__ = cuFileGetParameterMinMaxValue(<_SizeTConfigParameter>param, &min_value, &max_value) 1N
3150 check_status(__status__) 1N
3151 return (min_value, max_value) 1N
3154cpdef set_stats_level(int level):
3155 """Set the level of statistics collection for cuFile operations. This will override the cufile.json settings for stats.
3157 Args:
3158 level (int): Statistics level (0 = disabled, 1 = basic, 2 = detailed, 3 = verbose).
3160 .. seealso:: `cuFileSetStatsLevel`
3161 """
3162 with nogil: 1ftcubvoxyz
3163 __status__ = cuFileSetStatsLevel(level) 1ftcubvoxyz
3164 check_status(__status__) 1ftcubvoxyz
3167cpdef int get_stats_level() except? 0:
3168 """Get the current level of statistics collection for cuFile operations.
3170 Returns:
3171 int: Pointer to store the current statistics level.
3173 .. seealso:: `cuFileGetStatsLevel`
3174 """
3175 cdef int level
3176 with nogil: 1ABCoDE
3177 __status__ = cuFileGetStatsLevel(&level) 1ABCoDE
3178 check_status(__status__) 1ABCoDE
3179 return level 1ABCoDE
3182cpdef stats_start():
3183 """Start collecting cuFile statistics.
3185 .. seealso:: `cuFileStatsStart`
3186 """
3187 with nogil: 1fcby
3188 __status__ = cuFileStatsStart() 1fcby
3189 check_status(__status__) 1fcby
3192cpdef stats_stop():
3193 """Stop collecting cuFile statistics.
3195 .. seealso:: `cuFileStatsStop`
3196 """
3197 with nogil: 1fcby
3198 __status__ = cuFileStatsStop() 1fcby
3199 check_status(__status__) 1fcby
3202cpdef stats_reset():
3203 """Reset all cuFile statistics counters.
3205 .. seealso:: `cuFileStatsReset`
3206 """
3207 with nogil: 1tuvxz
3208 __status__ = cuFileStatsReset() 1tuvxz
3209 check_status(__status__) 1tuvxz
3212cpdef get_stats_l1(intptr_t stats):
3213 """Get Level 1 cuFile statistics.
3215 Args:
3216 stats (intptr_t): Pointer to ``CUfileStatsLevel1_t`` structure to be filled.
3218 .. seealso:: `cuFileGetStatsL1`
3219 """
3220 with nogil: 1f
3221 __status__ = cuFileGetStatsL1(<CUfileStatsLevel1_t*>stats) 1f
3222 check_status(__status__) 1f
3225cpdef get_stats_l2(intptr_t stats):
3226 """Get Level 2 cuFile statistics.
3228 Args:
3229 stats (intptr_t): Pointer to ``CUfileStatsLevel2_t`` structure to be filled.
3231 .. seealso:: `cuFileGetStatsL2`
3232 """
3233 with nogil: 1c
3234 __status__ = cuFileGetStatsL2(<CUfileStatsLevel2_t*>stats) 1c
3235 check_status(__status__) 1c
3238cpdef get_stats_l3(intptr_t stats):
3239 """Get Level 3 cuFile statistics.
3241 Args:
3242 stats (intptr_t): Pointer to ``CUfileStatsLevel3_t`` structure to be filled.
3244 .. seealso:: `cuFileGetStatsL3`
3245 """
3246 with nogil: 1b
3247 __status__ = cuFileGetStatsL3(<CUfileStatsLevel3_t*>stats) 1b
3248 check_status(__status__) 1b
3251cpdef size_t get_bar_size_in_kb(int gpu_index) except? 0:
3252 cdef size_t bar_size
3253 with nogil: 1M
3254 __status__ = cuFileGetBARSizeInKB(gpu_index, &bar_size) 1M
3255 check_status(__status__) 1M
3256 return bar_size 1M
3259cpdef set_parameter_posix_pool_slab_array(intptr_t size_values, intptr_t count_values, int len):
3260 """Set both POSIX pool slab size and count parameters as a pair.
3262 Args:
3263 size_values (intptr_t): Array of slab sizes in KB.
3264 count_values (intptr_t): Array of slab counts.
3265 len (int): Length of both arrays (must be the same).
3267 .. seealso:: `cuFileSetParameterPosixPoolSlabArray`
3268 """
3269 with nogil: 1L
3270 __status__ = cuFileSetParameterPosixPoolSlabArray(<const size_t*>size_values, <const size_t*>count_values, len) 1L
3271 check_status(__status__) 1L
3274cpdef get_parameter_posix_pool_slab_array(intptr_t size_values, intptr_t count_values, int len):
3275 """Get both POSIX pool slab size and count parameters as a pair.
3277 Args:
3278 size_values (intptr_t): Buffer to receive slab sizes in KB.
3279 count_values (intptr_t): Buffer to receive slab counts.
3280 len (int): Buffer size (must match the actual parameter length).
3282 .. seealso:: `cuFileGetParameterPosixPoolSlabArray`
3283 """
3284 with nogil: 1w
3285 __status__ = cuFileGetParameterPosixPoolSlabArray(<size_t*>size_values, <size_t*>count_values, len) 1w
3286 check_status(__status__) 1w
3289cpdef str op_status_error(int status):
3290 """cufileop status string.
3292 Args:
3293 status (OpError): the error status to query.
3295 .. seealso:: `cufileop_status_error`
3296 """
3297 cdef bytes _output_
3298 _output_ = cufileop_status_error(<_OpError>status) 1pno
3299 return _output_.decode() 1pno
3302cpdef driver_close():
3303 """reset the cuFile library and release the nvidia-fs driver
3304 """
3305 with nogil: 1PRTVXZ13579#%(*,.tuv:qKsnw;xz
3306 status = cuFileDriverClose_v2() 1PRTVXZ13579#%(*,.tuv:qKsnw;xz
3307 check_status(status) 1PRTVXZ13579#%(*,.tuv:qKsnw;xz
3309cpdef read(intptr_t fh, intptr_t buf_ptr_base, size_t size, off_t file_offset, off_t buf_ptr_offset):
3310 """read data from a registered file handle to a specified device or host memory.
3312 Args:
3313 fh (intptr_t): ``CUfileHandle_t`` opaque file handle.
3314 buf_ptr_base (intptr_t): base address of buffer in device or host memory.
3315 size (size_t): size bytes to read.
3316 file_offset (off_t): file-offset from begining of the file.
3317 buf_ptr_offset (off_t): offset relative to the buf_ptr_base pointer to read into.
3319 Returns:
3320 ssize_t: number of bytes read on success.
3322 .. seealso:: `cuFileRead`
3323 """
3324 with nogil: 1jklfcb
3325 status = cuFileRead(<Handle>fh, <void*>buf_ptr_base, size, file_offset, buf_ptr_offset) 1jklfcb
3326 check_status(status) 1jklfcb
3327 return status 1jklfcb
3330cpdef write(intptr_t fh, intptr_t buf_ptr_base, size_t size, off_t file_offset, off_t buf_ptr_offset):
3331 """write data from a specified device or host memory to a registered file handle.
3333 Args:
3334 fh (intptr_t): ``CUfileHandle_t`` opaque file handle.
3335 buf_ptr_base (intptr_t): base address of buffer in device or host memory.
3336 size (size_t): size bytes to write.
3337 file_offset (off_t): file-offset from begining of the file.
3338 buf_ptr_offset (off_t): offset relative to the buf_ptr_base pointer to write from.
3340 Returns:
3341 ssize_t: number of bytes written on success.
3343 .. seealso:: `cuFileWrite`
3344 """
3345 with nogil: 1jklfcb
3346 status = cuFileWrite(<Handle>fh, <const void*>buf_ptr_base, size, file_offset, buf_ptr_offset) 1jklfcb
3347 check_status(status) 1jklfcb
3348 return status 1jklfcb
3349del _cyb_FastEnum