# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # SPDX-License-Identifier: Apache-2.0 # # This code was automatically generated across versions from 12.9.0 to 13.5.0. Do not modify it directly. # CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=e5875e45cad50b678517e305072e0d62b425e06aab682da00c189d24daa3c459 # <<<< PREAMBLE CONTENT >>>> cimport cpython as _cyb_cpython cimport cpython.buffer as _cyb_cpython_buffer from cpython.buffer cimport ( PyBUF_READ as _cyb_PyBUF_READ, PyBUF_SIMPLE as _cyb_PyBUF_SIMPLE, PyBuffer_Release as _cyb_PyBuffer_Release, PyObject_GetBuffer as _cyb_PyObject_GetBuffer, Py_buffer as _cyb_Py_buffer, ) from cpython.memoryview cimport PyMemoryView_FromMemory as _cyb_PyMemoryView_FromMemory from cuda.bindings._internal.utils cimport ( get_resource_ptr as _cyb_get_resource_ptr, get_resource_ptrs as _cyb_get_resource_ptrs, nullable_unique_ptr as _cyb_nullable_unique_ptr, ) from cython cimport view as _cyb_view from libc.stdint cimport intptr_t from libc.stdlib cimport ( calloc as _cyb_calloc, free as _cyb_free, malloc as _cyb_malloc, ) from libc.string cimport ( memcmp as _cyb_memcmp, memcpy as _cyb_memcpy, memmove as _cyb_memmove, ) from libcpp.vector cimport vector as _cyb_vector from cuda.bindings._internal._fast_enum import FastEnum as _cyb_FastEnum import numpy as _numpy cdef class _cyb_BufferGuard: cdef _cyb_cpython.Py_buffer _view cdef bint _held cdef void* ptr cdef Py_ssize_t nbytes def __cinit__(self, buf, size_t size, bint check_size, bint readonly, bint wrap_errors): cdef int flags = _cyb_cpython.PyBUF_ANY_CONTIGUOUS self._held = False self.ptr = NULL self.nbytes = 0 if buf is None: return if isinstance(buf, int): self.ptr = buf return if not readonly: flags |= _cyb_cpython.PyBUF_WRITABLE try: _cyb_cpython.PyObject_GetBuffer(buf, &self._view, flags) self._held = True if check_size and self._view.len != size: raise ValueError("buffer size does not match the expected size") except Exception as e: adj = "" if not readonly: adj = "writable " if wrap_errors: size_msg = "" if check_size: size_msg = f", of size {size}" raise ValueError( "buf must be None, a Python int representing the pointer " f"address to a valid buffer, or a contiguous {adj}" f"buffer (a ctypes object, NumPy array, bytes, ...){size_msg}" ) from e if not isinstance(e, BufferError): raise raise ValueError( f"buf must be a contiguous {adj}buffer (a ctypes object, NumPy array, bytes, ...)" ) from e self.ptr = self._view.buf self.nbytes = self._view.len def __dealloc__(self): if self._held: _cyb_cpython.PyBuffer_Release(&self._view) cdef class _cyb_MemoryHolder: cdef void* _ptr cdef Py_ssize_t _size cdef Py_ssize_t _itemsize cdef bint _readonly cdef object _owner def __cinit__(self, intptr_t ptr, Py_ssize_t size, bint readonly, object owner): self._ptr = ptr self._size = size self._itemsize = 1 self._readonly = readonly self._owner = owner def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): if self._readonly and (flags & _cyb_cpython.PyBUF_WRITABLE) == _cyb_cpython.PyBUF_WRITABLE: raise BufferError("The memory is read-only") buffer.buf = self._ptr buffer.format = 'B' buffer.internal = NULL buffer.itemsize = 1 buffer.len = self._size buffer.ndim = 1 buffer.obj = self buffer.readonly = self._readonly buffer.shape = &self._size buffer.strides = &self._itemsize buffer.suboffsets = NULL def __releasebuffer__(self, _cyb_cpython.Py_buffer *buffer): pass cdef _cyb___getbuffer(object self, _cyb_cpython.Py_buffer *buffer, void *ptr, int size, bint readonly): buffer.buf = ptr buffer.format = 'b' buffer.internal = NULL buffer.itemsize = 1 buffer.len = size buffer.ndim = 1 buffer.obj = self buffer.readonly = readonly buffer.shape = &buffer.len buffer.strides = &buffer.itemsize buffer.suboffsets = NULL cdef inline intptr_t _cyb_array_ptr(object arr) except? 0: cdef _cyb_cpython.Py_buffer view cdef intptr_t ptr _cyb_cpython.PyObject_GetBuffer(arr, &view, _cyb_cpython_buffer.PyBUF_STRIDES) ptr = view.buf _cyb_cpython.PyBuffer_Release(&view) return ptr cdef Py_ssize_t _cyb_check_same_length(bint is_set, Py_ssize_t count, Py_ssize_t length, name, names) except -1: if is_set and length != count: raise ValueError( f"{name} must have the same length as the others of ({names}), " f"which have {count} elements, got {length}" ) return length cdef _cyb_from_buffer(buffer, size, lowpp_type): cdef _cyb_cpython.Py_buffer view if _cyb_cpython.PyObject_GetBuffer(buffer, &view, _cyb_cpython_buffer.PyBUF_SIMPLE) != 0: raise TypeError("buffer argument does not support the buffer protocol") try: if view.itemsize != 1: raise ValueError("buffer itemsize must be 1 byte") if view.len != size: raise ValueError(f"buffer length must be {size} bytes") return lowpp_type.from_ptr(view.buf, view.readonly != 0, buffer) finally: _cyb_cpython.PyBuffer_Release(&view) cdef _cyb_from_data(data, dtype_name, expected_dtype, lowpp_type): # _numpy.recarray is a subclass of _numpy.ndarray, so implicitly handled here. if isinstance(data, lowpp_type): return data if not isinstance(data, _numpy.ndarray): raise TypeError("data argument must be a NumPy ndarray") if data.size != 1: raise ValueError("data array must have a size of 1") if data.dtype != expected_dtype: raise ValueError(f"data array must be of dtype {dtype_name}") return lowpp_type.from_ptr(data.ctypes.data, not data.flags.writeable, data) # <<<< END OF PREAMBLE CONTENT >>>> cimport cython # NOQA from cpython.buffer cimport Py_buffer, PyBuffer_Release from cpython.mem cimport PyMem_Calloc, PyMem_Free from libc.string cimport memset as _c_memset from cuda.bindings._internal.utils cimport acquire_contiguous_buffer from cuda.bindings._internal._fast_enum import FastEnum as _FastEnum import numpy as _numpy ############################################################################### # Enum ############################################################################### class Error(_cyb_FastEnum): """ CUDA error types See `cudaError`. """ SUCCESS = (cyruntime.cudaSuccess, 'The API call returned with no errors. In the case of query calls, this also means that the operation being queried is complete (see `cudaEventQuery()` and `cudaStreamQuery()`).') ERROR_INVALID_VALUE = (cyruntime.cudaErrorInvalidValue, 'This indicates that one or more of the parameters passed to the API call is not within an acceptable range of values.') ERROR_MEMORY_ALLOCATION = (cyruntime.cudaErrorMemoryAllocation, 'The API call failed because it was unable to allocate enough memory or other resources to perform the requested operation.') ERROR_INITIALIZATION_ERROR = (cyruntime.cudaErrorInitializationError, 'The API call failed because the CUDA driver and runtime could not be initialized.') ERROR_CUDART_UNLOADING = (cyruntime.cudaErrorCudartUnloading, 'This indicates that a CUDA Runtime API call cannot be executed because it is being called during process shut down, at a point in time after CUDA driver has been unloaded.') ERROR_PROFILER_DISABLED = (cyruntime.cudaErrorProfilerDisabled, 'This indicates profiler is not initialized for this run. This can happen when the application is running with external profiling tools like visual profiler.') ERROR_PROFILER_NOT_INITIALIZED = (cyruntime.cudaErrorProfilerNotInitialized, '[Deprecated]') ERROR_PROFILER_ALREADY_STARTED = (cyruntime.cudaErrorProfilerAlreadyStarted, '[Deprecated]') ERROR_PROFILER_ALREADY_STOPPED = (cyruntime.cudaErrorProfilerAlreadyStopped, '[Deprecated]') ERROR_INVALID_CONFIGURATION = (cyruntime.cudaErrorInvalidConfiguration, 'This indicates that a kernel launch is requesting resources that can never be satisfied by the current device. Requesting more shared memory per block than the device supports will trigger this error, as will requesting too many threads or blocks. See `cudaDeviceProp` for more device limitations.') ERROR_VERSION_TRANSLATION = (cyruntime.cudaErrorVersionTranslation, 'This indicates that the driver is newer than the runtime version and returned graph node parameter information that the runtime does not understand and is unable to translate.') ERROR_INVALID_PITCH_VALUE = (cyruntime.cudaErrorInvalidPitchValue, 'This indicates that one or more of the pitch-related parameters passed to the API call is not within the acceptable range for pitch.') ERROR_INVALID_SYMBOL = (cyruntime.cudaErrorInvalidSymbol, 'This indicates that the symbol name/identifier passed to the API call is not a valid name or identifier.') ERROR_INVALID_HOST_POINTER = (cyruntime.cudaErrorInvalidHostPointer, 'This indicates that at least one host pointer passed to the API call is not a valid host pointer. [Deprecated]') ERROR_INVALID_DEVICE_POINTER = (cyruntime.cudaErrorInvalidDevicePointer, 'This indicates that at least one device pointer passed to the API call is not a valid device pointer. [Deprecated]') ERROR_INVALID_TEXTURE = (cyruntime.cudaErrorInvalidTexture, 'This indicates that the texture passed to the API call is not a valid texture.') ERROR_INVALID_TEXTURE_BINDING = (cyruntime.cudaErrorInvalidTextureBinding, 'This indicates that the texture binding is not valid. This occurs if you call `cudaGetTextureAlignmentOffset()` with an unbound texture.') ERROR_INVALID_CHANNEL_DESCRIPTOR = (cyruntime.cudaErrorInvalidChannelDescriptor, 'This indicates that the channel descriptor passed to the API call is not valid. This occurs if the format is not one of the formats specified by `cudaChannelFormatKind`, or if one of the dimensions is invalid.') ERROR_INVALID_MEMCPY_DIRECTION = (cyruntime.cudaErrorInvalidMemcpyDirection, 'This indicates that the direction of the memcpy passed to the API call is not one of the types specified by `cudaMemcpyKind`.') ERROR_ADDRESS_OF_CONSTANT = (cyruntime.cudaErrorAddressOfConstant, 'This indicated that the user has taken the address of a constant variable, which was forbidden up until the CUDA 3.1 release. [Deprecated]') ERROR_TEXTURE_FETCH_FAILED = (cyruntime.cudaErrorTextureFetchFailed, 'This indicated that a texture fetch was not able to be performed. This was previously used for device emulation of texture operations. [Deprecated]') ERROR_TEXTURE_NOT_BOUND = (cyruntime.cudaErrorTextureNotBound, 'This indicated that a texture was not bound for access. This was previously used for device emulation of texture operations. [Deprecated]') ERROR_SYNCHRONIZATION_ERROR = (cyruntime.cudaErrorSynchronizationError, 'This indicated that a synchronization operation had failed. This was previously used for some device emulation functions. [Deprecated]') ERROR_INVALID_FILTER_SETTING = (cyruntime.cudaErrorInvalidFilterSetting, 'This indicates that a non-float texture was being accessed with linear filtering. This is not supported by CUDA.') ERROR_INVALID_NORM_SETTING = (cyruntime.cudaErrorInvalidNormSetting, 'This indicates that an attempt was made to read an unsupported data type as a normalized float. This is not supported by CUDA.') ERROR_MIXED_DEVICE_EXECUTION = (cyruntime.cudaErrorMixedDeviceExecution, 'Mixing of device and device emulation code was not allowed. [Deprecated]') ERROR_NOT_YET_IMPLEMENTED = (cyruntime.cudaErrorNotYetImplemented, 'This indicates that the API call is not yet implemented. Production releases of CUDA will never return this error. [Deprecated]') ERROR_MEMORY_VALUE_TOO_LARGE = (cyruntime.cudaErrorMemoryValueTooLarge, 'This indicated that an emulated device pointer exceeded the 32-bit address range. [Deprecated]') ERROR_STUB_LIBRARY = (cyruntime.cudaErrorStubLibrary, 'This indicates that the CUDA driver that the application has loaded is a stub library. Applications that run with the stub rather than a real driver loaded will result in CUDA API returning this error.') ERROR_INSUFFICIENT_DRIVER = (cyruntime.cudaErrorInsufficientDriver, 'This indicates that the installed NVIDIA CUDA driver is older than the CUDA runtime library. This is not a supported configuration. Users should install an updated NVIDIA display driver to allow the application to run.') ERROR_CALL_REQUIRES_NEWER_DRIVER = (cyruntime.cudaErrorCallRequiresNewerDriver, 'This indicates that the API call requires a newer CUDA driver than the one currently installed. Users should install an updated NVIDIA CUDA driver to allow the API call to succeed.') ERROR_INVALID_SURFACE = (cyruntime.cudaErrorInvalidSurface, 'This indicates that the surface passed to the API call is not a valid surface.') ERROR_DUPLICATE_VARIABLE_NAME = (cyruntime.cudaErrorDuplicateVariableName, 'This indicates that multiple global or constant variables (across separate CUDA source files in the application) share the same string name.') ERROR_DUPLICATE_TEXTURE_NAME = (cyruntime.cudaErrorDuplicateTextureName, 'This indicates that multiple textures (across separate CUDA source files in the application) share the same string name.') ERROR_DUPLICATE_SURFACE_NAME = (cyruntime.cudaErrorDuplicateSurfaceName, 'This indicates that multiple surfaces (across separate CUDA source files in the application) share the same string name.') ERROR_DEVICES_UNAVAILABLE = (cyruntime.cudaErrorDevicesUnavailable, 'This indicates that all CUDA devices are busy or unavailable at the current time. Devices are often busy/unavailable due to use of `cudaComputeModeProhibited`, `cudaComputeModeExclusiveProcess`, or when long running CUDA kernels have filled up the GPU and are blocking new work from starting. They can also be unavailable due to memory constraints on a device that already has active CUDA work being performed.') ERROR_INCOMPATIBLE_DRIVER_CONTEXT = (cyruntime.cudaErrorIncompatibleDriverContext, 'This indicates that the current context is not compatible with this the CUDA Runtime. This can only occur if you are using CUDA Runtime/Driver interoperability and have created an existing Driver context using the driver API. The Driver context may be incompatible either because the Driver context was created using an older version of the API, because the Runtime API call expects a primary driver context and the Driver context is not primary, or because the Driver context has been destroyed. Please see `Interactions with the CUDA Driver API` for more information.') ERROR_MISSING_CONFIGURATION = (cyruntime.cudaErrorMissingConfiguration, 'The device function being invoked (usually via `cudaLaunchKernel()`) was not previously configured via the `cudaConfigureCall()` function.') ERROR_PRIOR_LAUNCH_FAILURE = (cyruntime.cudaErrorPriorLaunchFailure, 'This indicated that a previous kernel launch failed. This was previously used for device emulation of kernel launches. [Deprecated]') ERROR_LAUNCH_MAX_DEPTH_EXCEEDED = (cyruntime.cudaErrorLaunchMaxDepthExceeded, 'This error indicates that a device runtime grid launch did not occur because the depth of the child grid would exceed the maximum supported number of nested grid launches.') ERROR_LAUNCH_FILE_SCOPED_TEX = (cyruntime.cudaErrorLaunchFileScopedTex, "This error indicates that a grid launch did not occur because the kernel uses file-scoped textures which are unsupported by the device runtime. Kernels launched via the device runtime only support textures created with the Texture Object API's.") ERROR_LAUNCH_FILE_SCOPED_SURF = (cyruntime.cudaErrorLaunchFileScopedSurf, "This error indicates that a grid launch did not occur because the kernel uses file-scoped surfaces which are unsupported by the device runtime. Kernels launched via the device runtime only support surfaces created with the Surface Object API's.") ERROR_SYNC_DEPTH_EXCEEDED = (cyruntime.cudaErrorSyncDepthExceeded, 'This error indicates that a call to `cudaDeviceSynchronize` made from the device runtime failed because the call was made at grid depth greater than than either the default (2 levels of grids) or user specified device limit `cudaLimitDevRuntimeSyncDepth`. To be able to synchronize on launched grids at a greater depth successfully, the maximum nested depth at which `cudaDeviceSynchronize` will be called must be specified with the `cudaLimitDevRuntimeSyncDepth` limit to the `cudaDeviceSetLimit` api before the host-side launch of a kernel using the device runtime. Keep in mind that additional levels of sync depth require the runtime to reserve large amounts of device memory that cannot be used for user allocations. Note that `cudaDeviceSynchronize` made from device runtime is only supported on devices of compute capability < 9.0.') ERROR_LAUNCH_PENDING_COUNT_EXCEEDED = (cyruntime.cudaErrorLaunchPendingCountExceeded, 'This error indicates that a device runtime grid launch failed because the launch would exceed the limit `cudaLimitDevRuntimePendingLaunchCount`. For this launch to proceed successfully, `cudaDeviceSetLimit` must be called to set the `cudaLimitDevRuntimePendingLaunchCount` to be higher than the upper bound of outstanding launches that can be issued to the device runtime. Keep in mind that raising the limit of pending device runtime launches will require the runtime to reserve device memory that cannot be used for user allocations.') ERROR_INVALID_DEVICE_FUNCTION = (cyruntime.cudaErrorInvalidDeviceFunction, 'The requested device function does not exist or is not compiled for the proper device architecture.') ERROR_NO_DEVICE = (cyruntime.cudaErrorNoDevice, 'This indicates that no CUDA-capable devices were detected by the installed CUDA driver.') ERROR_INVALID_DEVICE = (cyruntime.cudaErrorInvalidDevice, 'This indicates that the device ordinal supplied by the user does not correspond to a valid CUDA device or that the action requested is invalid for the specified device.') ERROR_DEVICE_NOT_LICENSED = (cyruntime.cudaErrorDeviceNotLicensed, "This indicates that the device doesn't have a valid Grid License.") ERROR_SOFTWARE_VALIDITY_NOT_ESTABLISHED = (cyruntime.cudaErrorSoftwareValidityNotEstablished, 'By default, the CUDA runtime may perform a minimal set of self-tests, as well as CUDA driver tests, to establish the validity of both. Introduced in CUDA 11.2, this error return indicates that at least one of these tests has failed and the validity of either the runtime or the driver could not be established.') ERROR_STARTUP_FAILURE = (cyruntime.cudaErrorStartupFailure, 'This indicates an internal startup failure in the CUDA runtime.') ERROR_INVALID_KERNEL_IMAGE = (cyruntime.cudaErrorInvalidKernelImage, 'This indicates that the device kernel image is invalid.') ERROR_DEVICE_UNINITIALIZED = (cyruntime.cudaErrorDeviceUninitialized, 'This most frequently indicates that there is no context bound to the current thread. This can also be returned if the context passed to an API call is not a valid handle (such as a context that has had `cuCtxDestroy()` invoked on it). This can also be returned if a user mixes different API versions (i.e. 3010 context with 3020 API calls). See `cuCtxGetApiVersion()` for more details.') ERROR_MAP_BUFFER_OBJECT_FAILED = (cyruntime.cudaErrorMapBufferObjectFailed, 'This indicates that the buffer object could not be mapped.') ERROR_UNMAP_BUFFER_OBJECT_FAILED = (cyruntime.cudaErrorUnmapBufferObjectFailed, 'This indicates that the buffer object could not be unmapped.') ERROR_ARRAY_IS_MAPPED = (cyruntime.cudaErrorArrayIsMapped, 'This indicates that the specified array is currently mapped and thus cannot be destroyed.') ERROR_ALREADY_MAPPED = (cyruntime.cudaErrorAlreadyMapped, 'This indicates that the resource is already mapped.') ERROR_NO_KERNEL_IMAGE_FOR_DEVICE = (cyruntime.cudaErrorNoKernelImageForDevice, 'This indicates that there is no kernel image available that is suitable for the device. This can occur when a user specifies code generation options for a particular CUDA source file that do not include the corresponding device configuration.') ERROR_ALREADY_ACQUIRED = (cyruntime.cudaErrorAlreadyAcquired, 'This indicates that a resource has already been acquired.') ERROR_NOT_MAPPED = (cyruntime.cudaErrorNotMapped, 'This indicates that a resource is not mapped.') ERROR_NOT_MAPPED_AS_ARRAY = (cyruntime.cudaErrorNotMappedAsArray, 'This indicates that a mapped resource is not available for access as an array.') ERROR_NOT_MAPPED_AS_POINTER = (cyruntime.cudaErrorNotMappedAsPointer, 'This indicates that a mapped resource is not available for access as a pointer.') ERROR_ECC_UNCORRECTABLE = (cyruntime.cudaErrorECCUncorrectable, 'This indicates that an uncorrectable ECC error was detected during execution.') ERROR_UNSUPPORTED_LIMIT = (cyruntime.cudaErrorUnsupportedLimit, 'This indicates that the `cudaLimit` passed to the API call is not supported by the active device.') ERROR_DEVICE_ALREADY_IN_USE = (cyruntime.cudaErrorDeviceAlreadyInUse, 'This indicates that a call tried to access an exclusive-thread device that is already in use by a different thread.') ERROR_PEER_ACCESS_UNSUPPORTED = (cyruntime.cudaErrorPeerAccessUnsupported, 'This error indicates that P2P access is not supported across the given devices.') ERROR_INVALID_PTX = (cyruntime.cudaErrorInvalidPtx, 'A PTX compilation failed. The runtime may fall back to compiling PTX if an application does not contain a suitable binary for the current device.') ERROR_INVALID_GRAPHICS_CONTEXT = (cyruntime.cudaErrorInvalidGraphicsContext, 'This indicates an error with the OpenGL or DirectX context.') ERROR_NVLINK_UNCORRECTABLE = (cyruntime.cudaErrorNvlinkUncorrectable, 'This indicates that an uncorrectable NVLink error was detected during the execution.') ERROR_JIT_COMPILER_NOT_FOUND = (cyruntime.cudaErrorJitCompilerNotFound, 'This indicates that the PTX JIT compiler library was not found. The JIT Compiler library is used for PTX compilation. The runtime may fall back to compiling PTX if an application does not contain a suitable binary for the current device.') ERROR_UNSUPPORTED_PTX_VERSION = (cyruntime.cudaErrorUnsupportedPtxVersion, 'This indicates that the provided PTX was compiled with an unsupported toolchain. The most common reason for this, is the PTX was generated by a compiler newer than what is supported by the CUDA driver and PTX JIT compiler.') ERROR_JIT_COMPILATION_DISABLED = (cyruntime.cudaErrorJitCompilationDisabled, 'This indicates that the JIT compilation was disabled. The JIT compilation compiles PTX. The runtime may fall back to compiling PTX if an application does not contain a suitable binary for the current device.') ERROR_UNSUPPORTED_EXEC_AFFINITY = (cyruntime.cudaErrorUnsupportedExecAffinity, 'This indicates that the provided execution affinity is not supported by the device.') ERROR_UNSUPPORTED_DEV_SIDE_SYNC = (cyruntime.cudaErrorUnsupportedDevSideSync, 'This indicates that the code to be compiled by the PTX JIT contains unsupported call to cudaDeviceSynchronize.') ERROR_CONTAINED = (cyruntime.cudaErrorContained, "This indicates that an exception occurred on the device that is now contained by the GPU's error containment capability. Common causes are - a. Certain types of invalid accesses of peer GPU memory over nvlink b. Certain classes of hardware errors This leaves the process in an inconsistent state and any further CUDA work will return the same error. To continue using CUDA, the process must be terminated and relaunched.") ERROR_INSUFFICIENT_LOADER_VERSION = (cyruntime.cudaErrorInsufficientLoaderVersion, 'This indicates that loader version is insufficient for Fatbin') ERROR_INVALID_SOURCE = (cyruntime.cudaErrorInvalidSource, 'This indicates that the device kernel source is invalid.') ERROR_FILE_NOT_FOUND = (cyruntime.cudaErrorFileNotFound, 'This indicates that the file specified was not found.') ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND = (cyruntime.cudaErrorSharedObjectSymbolNotFound, 'This indicates that a link to a shared object failed to resolve.') ERROR_SHARED_OBJECT_INIT_FAILED = (cyruntime.cudaErrorSharedObjectInitFailed, 'This indicates that initialization of a shared object failed.') ERROR_OPERATING_SYSTEM = (cyruntime.cudaErrorOperatingSystem, 'This error indicates that an OS call failed.') ERROR_INVALID_RESOURCE_HANDLE = (cyruntime.cudaErrorInvalidResourceHandle, 'This indicates that a resource handle passed to the API call was not valid. Resource handles are opaque types like `cudaStream_t` and `cudaEvent_t`.') ERROR_ILLEGAL_STATE = (cyruntime.cudaErrorIllegalState, 'This indicates that a resource required by the API call is not in a valid state to perform the requested operation.') ERROR_LOSSY_QUERY = (cyruntime.cudaErrorLossyQuery, 'This indicates an attempt was made to introspect an object in a way that would discard semantically important information. This is either due to the object using funtionality newer than the API version used to introspect it or omission of optional return arguments.') ERROR_SYMBOL_NOT_FOUND = (cyruntime.cudaErrorSymbolNotFound, 'This indicates that a named symbol was not found. Examples of symbols are global/constant variable names, driver function names, texture names, and surface names.') ERROR_NOT_READY = (cyruntime.cudaErrorNotReady, 'This indicates that asynchronous operations issued previously have not completed yet. This result is not actually an error, but must be indicated differently than `cudaSuccess` (which indicates completion). Calls that may return this value include `cudaEventQuery()` and `cudaStreamQuery()`.') ERROR_ILLEGAL_ADDRESS = (cyruntime.cudaErrorIllegalAddress, 'The device encountered a load or store instruction on an invalid memory address. This leaves the process in an inconsistent state and any further CUDA work will return the same error. To continue using CUDA, the process must be terminated and relaunched.') ERROR_LAUNCH_OUT_OF_RESOURCES = (cyruntime.cudaErrorLaunchOutOfResources, "This indicates that a launch did not occur because it did not have appropriate resources. Although this error is similar to `cudaErrorInvalidConfiguration`, this error usually indicates that the user has attempted to pass too many arguments to the device kernel, or the kernel launch specifies too many threads for the kernel's register count.") ERROR_LAUNCH_TIMEOUT = (cyruntime.cudaErrorLaunchTimeout, 'This indicates that the device kernel took too long to execute. This can only occur if timeouts are enabled - see the device attribute `cudaDevAttrKernelExecTimeout` for more information. This leaves the process in an inconsistent state and any further CUDA work will return the same error. To continue using CUDA, the process must be terminated and relaunched.') ERROR_LAUNCH_INCOMPATIBLE_TEXTURING = (cyruntime.cudaErrorLaunchIncompatibleTexturing, 'This error indicates a kernel launch that uses an incompatible texturing mode.') ERROR_PEER_ACCESS_ALREADY_ENABLED = (cyruntime.cudaErrorPeerAccessAlreadyEnabled, 'This error indicates that a call to `cudaDeviceEnablePeerAccess()` is trying to re-enable peer addressing on from a context which has already had peer addressing enabled.') ERROR_PEER_ACCESS_NOT_ENABLED = (cyruntime.cudaErrorPeerAccessNotEnabled, 'This error indicates that `cudaDeviceDisablePeerAccess()` is trying to disable peer addressing which has not been enabled yet via `cudaDeviceEnablePeerAccess()`.') ERROR_SET_ON_ACTIVE_PROCESS = (cyruntime.cudaErrorSetOnActiveProcess, 'This indicates that the user has called `cudaSetValidDevices()`, `cudaSetDeviceFlags()`, `cudaD3D9SetDirect3DDevice()`, `cudaD3D10SetDirect3DDevice`, `cudaD3D11SetDirect3DDevice()`, or `cudaVDPAUSetVDPAUDevice()` after initializing the CUDA runtime by calling non-device management operations (allocating memory and launching kernels are examples of non-device management operations). This error can also be returned if using runtime/driver interoperability and there is an existing `CUcontext` active on the host thread.') ERROR_CONTEXT_IS_DESTROYED = (cyruntime.cudaErrorContextIsDestroyed, 'This error indicates that the context current to the calling thread has been destroyed using `cuCtxDestroy`, or is a primary context which has not yet been initialized.') ERROR_ASSERT = (cyruntime.cudaErrorAssert, 'An assert triggered in device code during kernel execution. The device cannot be used again. All existing allocations are invalid. To continue using CUDA, the process must be terminated and relaunched.') ERROR_TOO_MANY_PEERS = (cyruntime.cudaErrorTooManyPeers, 'This error indicates that the hardware resources required to enable peer access have been exhausted for one or more of the devices passed to `cudaEnablePeerAccess()`.') ERROR_HOST_MEMORY_ALREADY_REGISTERED = (cyruntime.cudaErrorHostMemoryAlreadyRegistered, 'This error indicates that the memory range passed to `cudaHostRegister()` has already been registered.') ERROR_HOST_MEMORY_NOT_REGISTERED = (cyruntime.cudaErrorHostMemoryNotRegistered, 'This error indicates that the pointer passed to `cudaHostUnregister()` does not correspond to any currently registered memory region.') ERROR_HARDWARE_STACK_ERROR = (cyruntime.cudaErrorHardwareStackError, 'Device encountered an error in the call stack during kernel execution, possibly due to stack corruption or exceeding the stack size limit. This leaves the process in an inconsistent state and any further CUDA work will return the same error. To continue using CUDA, the process must be terminated and relaunched.') ERROR_ILLEGAL_INSTRUCTION = (cyruntime.cudaErrorIllegalInstruction, 'The device encountered an illegal instruction during kernel execution This leaves the process in an inconsistent state and any further CUDA work will return the same error. To continue using CUDA, the process must be terminated and relaunched.') ERROR_MISALIGNED_ADDRESS = (cyruntime.cudaErrorMisalignedAddress, 'The device encountered a load or store instruction on a memory address which is not aligned. This leaves the process in an inconsistent state and any further CUDA work will return the same error. To continue using CUDA, the process must be terminated and relaunched.') ERROR_INVALID_ADDRESS_SPACE = (cyruntime.cudaErrorInvalidAddressSpace, 'While executing a kernel, the device encountered an instruction which can only operate on memory locations in certain address spaces (global, shared, or local), but was supplied a memory address not belonging to an allowed address space. This leaves the process in an inconsistent state and any further CUDA work will return the same error. To continue using CUDA, the process must be terminated and relaunched.') ERROR_INVALID_PC = (cyruntime.cudaErrorInvalidPc, 'The device encountered an invalid program counter. This leaves the process in an inconsistent state and any further CUDA work will return the same error. To continue using CUDA, the process must be terminated and relaunched.') ERROR_LAUNCH_FAILURE = (cyruntime.cudaErrorLaunchFailure, 'An exception occurred on the device while executing a kernel. Common causes include dereferencing an invalid device pointer and accessing out of bounds shared memory. Less common cases can be system specific - more information about these cases can be found in the system specific user guide. This leaves the process in an inconsistent state and any further CUDA work will return the same error. To continue using CUDA, the process must be terminated and relaunched.') ERROR_COOPERATIVE_LAUNCH_TOO_LARGE = (cyruntime.cudaErrorCooperativeLaunchTooLarge, 'This error indicates that the number of blocks launched per grid for a kernel that was launched via either `cudaLaunchCooperativeKernel` exceeds the maximum number of blocks as allowed by `cudaOccupancyMaxActiveBlocksPerMultiprocessor` or `cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags` times the number of multiprocessors as specified by the device attribute `cudaDevAttrMultiProcessorCount`.') ERROR_TENSOR_MEMORY_LEAK = (cyruntime.cudaErrorTensorMemoryLeak, 'An exception occurred on the device while exiting a kernel using tensor memory: the tensor memory was not completely deallocated. This leaves the process in an inconsistent state and any further CUDA work will return the same error. To continue using CUDA, the process must be terminated and relaunched.') ERROR_NOT_PERMITTED = (cyruntime.cudaErrorNotPermitted, 'This error indicates the attempted operation is not permitted.') ERROR_NOT_SUPPORTED = (cyruntime.cudaErrorNotSupported, 'This error indicates the attempted operation is not supported on the current system or device.') ERROR_SYSTEM_NOT_READY = (cyruntime.cudaErrorSystemNotReady, 'This error indicates that the system is not yet ready to start any CUDA work. To continue using CUDA, verify the system configuration is in a valid state and all required driver daemons are actively running. More information about this error can be found in the system specific user guide.') ERROR_SYSTEM_DRIVER_MISMATCH = (cyruntime.cudaErrorSystemDriverMismatch, 'This error indicates that there is a mismatch between the versions of the display driver and the CUDA driver. Refer to the compatibility documentation for supported versions.') ERROR_COMPAT_NOT_SUPPORTED_ON_DEVICE = (cyruntime.cudaErrorCompatNotSupportedOnDevice, 'This error indicates that the system was upgraded to run with forward compatibility but the visible hardware detected by CUDA does not support this configuration. Refer to the compatibility documentation for the supported hardware matrix or ensure that only supported hardware is visible during initialization via the CUDA_VISIBLE_DEVICES environment variable.') ERROR_MPS_CONNECTION_FAILED = (cyruntime.cudaErrorMpsConnectionFailed, 'This error indicates that the MPS client failed to connect to the MPS control daemon or the MPS server.') ERROR_MPS_RPC_FAILURE = (cyruntime.cudaErrorMpsRpcFailure, 'This error indicates that the remote procedural call between the MPS server and the MPS client failed.') ERROR_MPS_SERVER_NOT_READY = (cyruntime.cudaErrorMpsServerNotReady, 'This error indicates that the MPS server is not ready to accept new MPS client requests. This error can be returned when the MPS server is in the process of recovering from a fatal failure.') ERROR_MPS_MAX_CLIENTS_REACHED = (cyruntime.cudaErrorMpsMaxClientsReached, 'This error indicates that the hardware resources required to create MPS client have been exhausted.') ERROR_MPS_MAX_CONNECTIONS_REACHED = (cyruntime.cudaErrorMpsMaxConnectionsReached, 'This error indicates the the hardware resources required to device connections have been exhausted.') ERROR_MPS_CLIENT_TERMINATED = (cyruntime.cudaErrorMpsClientTerminated, 'This error indicates that the MPS client has been terminated by the server. To continue using CUDA, the process must be terminated and relaunched.') ERROR_CDP_NOT_SUPPORTED = (cyruntime.cudaErrorCdpNotSupported, 'This error indicates, that the program is using CUDA Dynamic Parallelism, but the current configuration, like MPS, does not support it.') ERROR_CDP_VERSION_MISMATCH = (cyruntime.cudaErrorCdpVersionMismatch, 'This error indicates, that the program contains an unsupported interaction between different versions of CUDA Dynamic Parallelism.') ERROR_STREAM_CAPTURE_UNSUPPORTED = (cyruntime.cudaErrorStreamCaptureUnsupported, 'The operation is not permitted when the stream is capturing.') ERROR_STREAM_CAPTURE_INVALIDATED = (cyruntime.cudaErrorStreamCaptureInvalidated, 'The current capture sequence on the stream has been invalidated due to a previous error.') ERROR_STREAM_CAPTURE_MERGE = (cyruntime.cudaErrorStreamCaptureMerge, 'The operation would have resulted in a merge of two independent capture sequences.') ERROR_STREAM_CAPTURE_UNMATCHED = (cyruntime.cudaErrorStreamCaptureUnmatched, 'The capture was not initiated in this stream.') ERROR_STREAM_CAPTURE_UNJOINED = (cyruntime.cudaErrorStreamCaptureUnjoined, 'The capture sequence contains a fork that was not joined to the primary stream.') ERROR_STREAM_CAPTURE_ISOLATION = (cyruntime.cudaErrorStreamCaptureIsolation, 'A dependency would have been created which crosses the capture sequence boundary. Only implicit in-stream ordering dependencies are allowed to cross the boundary.') ERROR_STREAM_CAPTURE_IMPLICIT = (cyruntime.cudaErrorStreamCaptureImplicit, 'The operation would have resulted in a disallowed implicit dependency on a current capture sequence from cudaStreamLegacy.') ERROR_CAPTURED_EVENT = (cyruntime.cudaErrorCapturedEvent, 'The operation is not permitted on an event which was last recorded in a capturing stream.') ERROR_STREAM_CAPTURE_WRONG_THREAD = (cyruntime.cudaErrorStreamCaptureWrongThread, 'A stream capture sequence not initiated with the `cudaStreamCaptureModeRelaxed` argument to `cudaStreamBeginCapture` was passed to `cudaStreamEndCapture` in a different thread.') ERROR_TIMEOUT = (cyruntime.cudaErrorTimeout, 'This indicates that the wait operation has timed out.') ERROR_GRAPH_EXEC_UPDATE_FAILURE = (cyruntime.cudaErrorGraphExecUpdateFailure, 'This error indicates that the graph update was not performed because it included changes which violated constraints specific to instantiated graph update.') ERROR_EXTERNAL_DEVICE = (cyruntime.cudaErrorExternalDevice, "This indicates that an error has occurred in a device outside of GPU. It can be a synchronous error w.r.t. CUDA API or an asynchronous error from the external device. In case of asynchronous error, it means that if cuda was waiting for an external device's signal before consuming shared data, the external device signaled an error indicating that the data is not valid for consumption. This leaves the process in an inconsistent state and any further CUDA work will return the same error. To continue using CUDA, the process must be terminated and relaunched. In case of synchronous error, it means that one or more external devices have encountered an error and cannot complete the operation.") ERROR_INVALID_CLUSTER_SIZE = (cyruntime.cudaErrorInvalidClusterSize, 'This indicates that a kernel launch error has occurred due to cluster misconfiguration.') ERROR_FUNCTION_NOT_LOADED = (cyruntime.cudaErrorFunctionNotLoaded, 'Indiciates a function handle is not loaded when calling an API that requires a loaded function.') ERROR_INVALID_RESOURCE_TYPE = (cyruntime.cudaErrorInvalidResourceType, 'This error indicates one or more resources passed in are not valid resource types for the operation.') ERROR_INVALID_RESOURCE_CONFIGURATION = (cyruntime.cudaErrorInvalidResourceConfiguration, 'This error indicates one or more resources are insufficient or non-applicable for the operation.') ERROR_STREAM_DETACHED = (cyruntime.cudaErrorStreamDetached, "This error indicates that the requested operation is not permitted because the stream is in a detached state. This can occur if the green context associated with the stream has been destroyed, limiting the stream's operational capabilities.") ERROR_GRAPH_RECAPTURE_FAILURE = (cyruntime.cudaErrorGraphRecaptureFailure, 'This error indicates that a graph recapture failed and had to be terminated.') ERROR_FABRIC_NOT_READY = (cyruntime.cudaErrorFabricNotReady, 'This error indicates GPU fabric is not ready within the bounded wait while the fabric manager probe is still in progress. Applications may retry after a delay; for the initialization wait budget, see environment variables such as CUDA_FABRIC_INIT_TIMEOUT_MS.') ERROR_UNKNOWN = (cyruntime.cudaErrorUnknown, 'This indicates that an unknown internal error has occurred.') ERROR_API_FAILURE_BASE = cyruntime.cudaErrorApiFailureBase class ChannelFormatKind(_cyb_FastEnum): """ Channel format kind See `cudaChannelFormatKind`. """ SIGNED = (cyruntime.cudaChannelFormatKindSigned, 'Signed channel format') UNSIGNED = (cyruntime.cudaChannelFormatKindUnsigned, 'Unsigned channel format') FLOAT = (cyruntime.cudaChannelFormatKindFloat, 'Float channel format') NONE = (cyruntime.cudaChannelFormatKindNone, 'No channel format') NV12 = (cyruntime.cudaChannelFormatKindNV12, 'Unsigned 8-bit integers, planar 4:2:0 YUV format') UNSIGNED_NORMALIZED8X1 = (cyruntime.cudaChannelFormatKindUnsignedNormalized8X1, '1 channel unsigned 8-bit normalized integer') UNSIGNED_NORMALIZED8X2 = (cyruntime.cudaChannelFormatKindUnsignedNormalized8X2, '2 channel unsigned 8-bit normalized integer') UNSIGNED_NORMALIZED8X4 = (cyruntime.cudaChannelFormatKindUnsignedNormalized8X4, '4 channel unsigned 8-bit normalized integer') UNSIGNED_NORMALIZED16X1 = (cyruntime.cudaChannelFormatKindUnsignedNormalized16X1, '1 channel unsigned 16-bit normalized integer') UNSIGNED_NORMALIZED16X2 = (cyruntime.cudaChannelFormatKindUnsignedNormalized16X2, '2 channel unsigned 16-bit normalized integer') UNSIGNED_NORMALIZED16X4 = (cyruntime.cudaChannelFormatKindUnsignedNormalized16X4, '4 channel unsigned 16-bit normalized integer') SIGNED_NORMALIZED8X1 = (cyruntime.cudaChannelFormatKindSignedNormalized8X1, '1 channel signed 8-bit normalized integer') SIGNED_NORMALIZED8X2 = (cyruntime.cudaChannelFormatKindSignedNormalized8X2, '2 channel signed 8-bit normalized integer') SIGNED_NORMALIZED8X4 = (cyruntime.cudaChannelFormatKindSignedNormalized8X4, '4 channel signed 8-bit normalized integer') SIGNED_NORMALIZED16X1 = (cyruntime.cudaChannelFormatKindSignedNormalized16X1, '1 channel signed 16-bit normalized integer') SIGNED_NORMALIZED16X2 = (cyruntime.cudaChannelFormatKindSignedNormalized16X2, '2 channel signed 16-bit normalized integer') SIGNED_NORMALIZED16X4 = (cyruntime.cudaChannelFormatKindSignedNormalized16X4, '4 channel signed 16-bit normalized integer') UNSIGNED_BLOCK_COMPRESSED1 = (cyruntime.cudaChannelFormatKindUnsignedBlockCompressed1, '4 channel unsigned normalized block-compressed (BC1 compression) format') UNSIGNED_BLOCK_COMPRESSED1SRGB = (cyruntime.cudaChannelFormatKindUnsignedBlockCompressed1SRGB, '4 channel unsigned normalized block-compressed (BC1 compression) format with sRGB encoding') UNSIGNED_BLOCK_COMPRESSED2 = (cyruntime.cudaChannelFormatKindUnsignedBlockCompressed2, '4 channel unsigned normalized block-compressed (BC2 compression) format') UNSIGNED_BLOCK_COMPRESSED2SRGB = (cyruntime.cudaChannelFormatKindUnsignedBlockCompressed2SRGB, '4 channel unsigned normalized block-compressed (BC2 compression) format with sRGB encoding') UNSIGNED_BLOCK_COMPRESSED3 = (cyruntime.cudaChannelFormatKindUnsignedBlockCompressed3, '4 channel unsigned normalized block-compressed (BC3 compression) format') UNSIGNED_BLOCK_COMPRESSED3SRGB = (cyruntime.cudaChannelFormatKindUnsignedBlockCompressed3SRGB, '4 channel unsigned normalized block-compressed (BC3 compression) format with sRGB encoding') UNSIGNED_BLOCK_COMPRESSED4 = (cyruntime.cudaChannelFormatKindUnsignedBlockCompressed4, '1 channel unsigned normalized block-compressed (BC4 compression) format') SIGNED_BLOCK_COMPRESSED4 = (cyruntime.cudaChannelFormatKindSignedBlockCompressed4, '1 channel signed normalized block-compressed (BC4 compression) format') UNSIGNED_BLOCK_COMPRESSED5 = (cyruntime.cudaChannelFormatKindUnsignedBlockCompressed5, '2 channel unsigned normalized block-compressed (BC5 compression) format') SIGNED_BLOCK_COMPRESSED5 = (cyruntime.cudaChannelFormatKindSignedBlockCompressed5, '2 channel signed normalized block-compressed (BC5 compression) format') UNSIGNED_BLOCK_COMPRESSED6H = (cyruntime.cudaChannelFormatKindUnsignedBlockCompressed6H, '3 channel unsigned half-float block-compressed (BC6H compression) format') SIGNED_BLOCK_COMPRESSED6H = (cyruntime.cudaChannelFormatKindSignedBlockCompressed6H, '3 channel signed half-float block-compressed (BC6H compression) format') UNSIGNED_BLOCK_COMPRESSED7 = (cyruntime.cudaChannelFormatKindUnsignedBlockCompressed7, '4 channel unsigned normalized block-compressed (BC7 compression) format') UNSIGNED_BLOCK_COMPRESSED7SRGB = (cyruntime.cudaChannelFormatKindUnsignedBlockCompressed7SRGB, '4 channel unsigned normalized block-compressed (BC7 compression) format with sRGB encoding') UNSIGNED_NORMALIZED1010102 = (cyruntime.cudaChannelFormatKindUnsignedNormalized1010102, '4 channel unsigned normalized (10-bit, 10-bit, 10-bit, 2-bit) format') UNSIGNED8_PACKED422 = (cyruntime.cudaChannelFormatKindUnsigned8Packed422, '4 channel unsigned 8-bit packed format, with 4:2:2 sampling') UNSIGNED8_PACKED444 = (cyruntime.cudaChannelFormatKindUnsigned8Packed444, '4 channel unsigned 8-bit packed format, with 4:4:4 sampling') UNSIGNED8_SEMI_PLANAR420 = (cyruntime.cudaChannelFormatKindUnsigned8SemiPlanar420, '3 channel unsigned 8-bit semi-planar format, with 4:2:0 sampling') UNSIGNED16_SEMI_PLANAR420 = (cyruntime.cudaChannelFormatKindUnsigned16SemiPlanar420, '3 channel unsigned 16-bit semi-planar format, with 4:2:0 sampling') UNSIGNED8_SEMI_PLANAR422 = (cyruntime.cudaChannelFormatKindUnsigned8SemiPlanar422, '3 channel unsigned 8-bit semi-planar format, with 4:2:2 sampling') UNSIGNED16_SEMI_PLANAR422 = (cyruntime.cudaChannelFormatKindUnsigned16SemiPlanar422, '3 channel unsigned 16-bit semi-planar format, with 4:2:2 sampling') UNSIGNED8_SEMI_PLANAR444 = (cyruntime.cudaChannelFormatKindUnsigned8SemiPlanar444, '3 channel unsigned 8-bit semi-planar format, with 4:4:4 sampling') UNSIGNED16_SEMI_PLANAR444 = (cyruntime.cudaChannelFormatKindUnsigned16SemiPlanar444, '3 channel unsigned 16-bit semi-planar format, with 4:4:4 sampling') UNSIGNED8_PLANAR420 = (cyruntime.cudaChannelFormatKindUnsigned8Planar420, '3 channel unsigned 8-bit planar format, with 4:2:0 sampling') UNSIGNED16_PLANAR420 = (cyruntime.cudaChannelFormatKindUnsigned16Planar420, '3 channel unsigned 16-bit planar format, with 4:2:0 sampling') UNSIGNED8_PLANAR422 = (cyruntime.cudaChannelFormatKindUnsigned8Planar422, '3 channel unsigned 8-bit planar format, with 4:2:2 sampling') UNSIGNED16_PLANAR422 = (cyruntime.cudaChannelFormatKindUnsigned16Planar422, '3 channel unsigned 16-bit planar format, with 4:2:2 sampling') UNSIGNED8_PLANAR444 = (cyruntime.cudaChannelFormatKindUnsigned8Planar444, '3 channel unsigned 8-bit planar format, with 4:4:4 sampling') UNSIGNED16_PLANAR444 = (cyruntime.cudaChannelFormatKindUnsigned16Planar444, '3 channel unsigned 16-bit planar format, with 4:4:4 sampling') class MemoryType(_cyb_FastEnum): """ CUDA memory types See `cudaMemoryType`. """ UNREGISTERED = (cyruntime.cudaMemoryTypeUnregistered, 'Unregistered memory') HOST = (cyruntime.cudaMemoryTypeHost, 'Host memory') DEVICE = (cyruntime.cudaMemoryTypeDevice, 'Device memory') MANAGED = (cyruntime.cudaMemoryTypeManaged, 'Managed memory') class MemCpyKind(_cyb_FastEnum): """ CUDA memory copy types See `cudaMemcpyKind`. """ HOST_TO_HOST = (cyruntime.cudaMemcpyHostToHost, 'Host -> Host') HOST_TO_DEVICE = (cyruntime.cudaMemcpyHostToDevice, 'Host -> Device') DEVICE_TO_HOST = (cyruntime.cudaMemcpyDeviceToHost, 'Device -> Host') DEVICE_TO_DEVICE = (cyruntime.cudaMemcpyDeviceToDevice, 'Device -> Device') DEFAULT = (cyruntime.cudaMemcpyDefault, 'Direction of the transfer is inferred from the pointer values. Requires unified virtual addressing') class AccessProperty(_cyb_FastEnum): """ Specifies performance hint with `cudaAccessPolicyWindow` for hitProp and missProp members. See `cudaAccessProperty`. """ NORMAL = (cyruntime.cudaAccessPropertyNormal, 'Normal cache persistence.') STREAMING = (cyruntime.cudaAccessPropertyStreaming, 'Streaming access is less likely to persit from cache.') PERSISTING = (cyruntime.cudaAccessPropertyPersisting, 'Persisting access is more likely to persist in cache.') class StreamCaptureStatus(_cyb_FastEnum): """ Possible stream capture statuses returned by `cudaStreamIsCapturing` See `cudaStreamCaptureStatus`. """ NONE = (cyruntime.cudaStreamCaptureStatusNone, 'Stream is not capturing') ACTIVE = (cyruntime.cudaStreamCaptureStatusActive, 'Stream is actively capturing') INVALIDATED = (cyruntime.cudaStreamCaptureStatusInvalidated, 'Stream is part of a capture sequence that has been invalidated, but not terminated') class StreamCaptureMode(_cyb_FastEnum): """ Possible modes for stream capture thread interactions. For more details see `cudaStreamBeginCapture` and `cudaThreadExchangeStreamCaptureMode` See `cudaStreamCaptureMode`. """ GLOBAL = cyruntime.cudaStreamCaptureModeGlobal THREAD_LOCAL = cyruntime.cudaStreamCaptureModeThreadLocal RELAXED = cyruntime.cudaStreamCaptureModeRelaxed class SynchronizationPolicy(_cyb_FastEnum): """ See `cudaSynchronizationPolicy`. """ AUTO = cyruntime.cudaSyncPolicyAuto SPIN = cyruntime.cudaSyncPolicySpin YIELD = cyruntime.cudaSyncPolicyYield BLOCKING_SYNC = cyruntime.cudaSyncPolicyBlockingSync class ClusterSchedulingPolicy(_cyb_FastEnum): """ Cluster scheduling policies. These may be passed to `cudaFuncSetAttribute` See `cudaClusterSchedulingPolicy`. """ DEFAULT = (cyruntime.cudaClusterSchedulingPolicyDefault, 'the default policy') SPREAD = (cyruntime.cudaClusterSchedulingPolicySpread, 'spread the blocks within a cluster to the SMs') LOAD_BALANCING = (cyruntime.cudaClusterSchedulingPolicyLoadBalancing, 'allow the hardware to load-balance the blocks in a cluster to the SMs') RUBIN_DSMEM_LOCALITY = cyruntime.cudaClusterSchedulingPolicyRubinDsmemLocality class StreamUpdateCaptureDependenciesFlags(_cyb_FastEnum): """ Flags for `cudaStreamUpdateCaptureDependencies` See `cudaStreamUpdateCaptureDependenciesFlags`. """ ADD_CAPTURE_DEPENDENCIES = (cyruntime.cudaStreamAddCaptureDependencies, 'Add new nodes to the dependency set') SET_CAPTURE_DEPENDENCIES = (cyruntime.cudaStreamSetCaptureDependencies, 'Replace the dependency set with the new nodes') class UserObjectFlags(_cyb_FastEnum): """ Flags for user objects for graphs See `cudaUserObjectFlags`. """ NO_DESTRUCTOR_SYNC = (cyruntime.cudaUserObjectNoDestructorSync, 'Indicates the destructor execution is not synchronized by any CUDA handle.') class UserObjectRetainFlags(_cyb_FastEnum): """ Flags for retaining user object references for graphs See `cudaUserObjectRetainFlags`. """ MOVE = (cyruntime.cudaGraphUserObjectMove, 'Transfer references from the caller rather than creating new references.') class GraphicsRegisterFlags(_cyb_FastEnum): """ CUDA graphics interop register flags See `cudaGraphicsRegisterFlags`. """ NONE = (cyruntime.cudaGraphicsRegisterFlagsNone, 'Default') READ_ONLY = (cyruntime.cudaGraphicsRegisterFlagsReadOnly, 'CUDA will not write to this resource') WRITE_DISCARD = (cyruntime.cudaGraphicsRegisterFlagsWriteDiscard, 'CUDA will only write to and will not read from this resource') SURFACE_LOAD_STORE = (cyruntime.cudaGraphicsRegisterFlagsSurfaceLoadStore, 'CUDA will bind this resource to a surface reference') TEXTURE_GATHER = (cyruntime.cudaGraphicsRegisterFlagsTextureGather, 'CUDA will perform texture gather operations on this resource') class GraphicsMapFlags(_cyb_FastEnum): """ CUDA graphics interop map flags See `cudaGraphicsMapFlags`. """ NONE = (cyruntime.cudaGraphicsMapFlagsNone, 'Default; Assume resource can be read/written') READ_ONLY = (cyruntime.cudaGraphicsMapFlagsReadOnly, 'CUDA will not write to this resource') WRITE_DISCARD = (cyruntime.cudaGraphicsMapFlagsWriteDiscard, 'CUDA will only write to and will not read from this resource') class GraphicsCubeFace(_cyb_FastEnum): """ CUDA graphics interop array indices for cube maps See `cudaGraphicsCubeFace`. """ POSITIVE_X = (cyruntime.cudaGraphicsCubeFacePositiveX, 'Positive X face of cubemap') NEGATIVE_X = (cyruntime.cudaGraphicsCubeFaceNegativeX, 'Negative X face of cubemap') POSITIVE_Y = (cyruntime.cudaGraphicsCubeFacePositiveY, 'Positive Y face of cubemap') NEGATIVE_Y = (cyruntime.cudaGraphicsCubeFaceNegativeY, 'Negative Y face of cubemap') POSITIVE_Z = (cyruntime.cudaGraphicsCubeFacePositiveZ, 'Positive Z face of cubemap') NEGATIVE_Z = (cyruntime.cudaGraphicsCubeFaceNegativeZ, 'Negative Z face of cubemap') class ResourceType(_cyb_FastEnum): """ CUDA resource types See `cudaResourceType`. """ ARRAY = (cyruntime.cudaResourceTypeArray, 'Array resource') MIPMAPPED_ARRAY = (cyruntime.cudaResourceTypeMipmappedArray, 'Mipmapped array resource') LINEAR = (cyruntime.cudaResourceTypeLinear, 'Linear resource') PITCH2D = (cyruntime.cudaResourceTypePitch2D, 'Pitch 2D resource') class ResourceViewFormat(_cyb_FastEnum): """ CUDA texture resource view formats See `cudaResourceViewFormat`. """ NONE = (cyruntime.cudaResViewFormatNone, 'No resource view format (use underlying resource format)') UNSIGNED_CHAR1 = (cyruntime.cudaResViewFormatUnsignedChar1, '1 channel unsigned 8-bit integers') UNSIGNED_CHAR2 = (cyruntime.cudaResViewFormatUnsignedChar2, '2 channel unsigned 8-bit integers') UNSIGNED_CHAR4 = (cyruntime.cudaResViewFormatUnsignedChar4, '4 channel unsigned 8-bit integers') SIGNED_CHAR1 = (cyruntime.cudaResViewFormatSignedChar1, '1 channel signed 8-bit integers') SIGNED_CHAR2 = (cyruntime.cudaResViewFormatSignedChar2, '2 channel signed 8-bit integers') SIGNED_CHAR4 = (cyruntime.cudaResViewFormatSignedChar4, '4 channel signed 8-bit integers') UNSIGNED_SHORT1 = (cyruntime.cudaResViewFormatUnsignedShort1, '1 channel unsigned 16-bit integers') UNSIGNED_SHORT2 = (cyruntime.cudaResViewFormatUnsignedShort2, '2 channel unsigned 16-bit integers') UNSIGNED_SHORT4 = (cyruntime.cudaResViewFormatUnsignedShort4, '4 channel unsigned 16-bit integers') SIGNED_SHORT1 = (cyruntime.cudaResViewFormatSignedShort1, '1 channel signed 16-bit integers') SIGNED_SHORT2 = (cyruntime.cudaResViewFormatSignedShort2, '2 channel signed 16-bit integers') SIGNED_SHORT4 = (cyruntime.cudaResViewFormatSignedShort4, '4 channel signed 16-bit integers') UNSIGNED_INT1 = (cyruntime.cudaResViewFormatUnsignedInt1, '1 channel unsigned 32-bit integers') UNSIGNED_INT2 = (cyruntime.cudaResViewFormatUnsignedInt2, '2 channel unsigned 32-bit integers') UNSIGNED_INT4 = (cyruntime.cudaResViewFormatUnsignedInt4, '4 channel unsigned 32-bit integers') SIGNED_INT1 = (cyruntime.cudaResViewFormatSignedInt1, '1 channel signed 32-bit integers') SIGNED_INT2 = (cyruntime.cudaResViewFormatSignedInt2, '2 channel signed 32-bit integers') SIGNED_INT4 = (cyruntime.cudaResViewFormatSignedInt4, '4 channel signed 32-bit integers') HALF1 = (cyruntime.cudaResViewFormatHalf1, '1 channel 16-bit floating point') HALF2 = (cyruntime.cudaResViewFormatHalf2, '2 channel 16-bit floating point') HALF4 = (cyruntime.cudaResViewFormatHalf4, '4 channel 16-bit floating point') FLOAT1 = (cyruntime.cudaResViewFormatFloat1, '1 channel 32-bit floating point') FLOAT2 = (cyruntime.cudaResViewFormatFloat2, '2 channel 32-bit floating point') FLOAT4 = (cyruntime.cudaResViewFormatFloat4, '4 channel 32-bit floating point') UNSIGNED_BLOCK_COMPRESSED1 = (cyruntime.cudaResViewFormatUnsignedBlockCompressed1, 'Block compressed 1') UNSIGNED_BLOCK_COMPRESSED2 = (cyruntime.cudaResViewFormatUnsignedBlockCompressed2, 'Block compressed 2') UNSIGNED_BLOCK_COMPRESSED3 = (cyruntime.cudaResViewFormatUnsignedBlockCompressed3, 'Block compressed 3') UNSIGNED_BLOCK_COMPRESSED4 = (cyruntime.cudaResViewFormatUnsignedBlockCompressed4, 'Block compressed 4 unsigned') SIGNED_BLOCK_COMPRESSED4 = (cyruntime.cudaResViewFormatSignedBlockCompressed4, 'Block compressed 4 signed') UNSIGNED_BLOCK_COMPRESSED5 = (cyruntime.cudaResViewFormatUnsignedBlockCompressed5, 'Block compressed 5 unsigned') SIGNED_BLOCK_COMPRESSED5 = (cyruntime.cudaResViewFormatSignedBlockCompressed5, 'Block compressed 5 signed') UNSIGNED_BLOCK_COMPRESSED6H = (cyruntime.cudaResViewFormatUnsignedBlockCompressed6H, 'Block compressed 6 unsigned half-float') SIGNED_BLOCK_COMPRESSED6H = (cyruntime.cudaResViewFormatSignedBlockCompressed6H, 'Block compressed 6 signed half-float') UNSIGNED_BLOCK_COMPRESSED7 = (cyruntime.cudaResViewFormatUnsignedBlockCompressed7, 'Block compressed 7') class FuncAttribute(_cyb_FastEnum): """ CUDA function attributes that can be set using `cudaFuncSetAttribute` See `cudaFuncAttribute`. """ MAX_DYNAMIC_SHARED_MEMORY_SIZE = (cyruntime.cudaFuncAttributeMaxDynamicSharedMemorySize, 'Maximum dynamic shared memory size') PREFERRED_SHARED_MEMORY_CARVEOUT = (cyruntime.cudaFuncAttributePreferredSharedMemoryCarveout, 'Preferred shared memory-L1 cache split') CLUSTER_DIM_MUST_BE_SET = (cyruntime.cudaFuncAttributeClusterDimMustBeSet, 'Indicator to enforce valid cluster dimension specification on kernel launch') REQUIRED_CLUSTER_WIDTH = (cyruntime.cudaFuncAttributeRequiredClusterWidth, 'Required cluster width') REQUIRED_CLUSTER_HEIGHT = (cyruntime.cudaFuncAttributeRequiredClusterHeight, 'Required cluster height') REQUIRED_CLUSTER_DEPTH = (cyruntime.cudaFuncAttributeRequiredClusterDepth, 'Required cluster depth') NON_PORTABLE_CLUSTER_SIZE_ALLOWED = (cyruntime.cudaFuncAttributeNonPortableClusterSizeAllowed, 'Whether non-portable cluster scheduling policy is supported') CLUSTER_SCHEDULING_POLICY_PREFERENCE = (cyruntime.cudaFuncAttributeClusterSchedulingPolicyPreference, 'Required cluster scheduling policy preference') SHARED_MEMORY_MODE = (cyruntime.cudaFuncAttributeSharedMemoryMode, "Setting that controls a kernel's use of non-portable or oversized shared memory configurations") MAX = cyruntime.cudaFuncAttributeMax class FuncCache(_cyb_FastEnum): """ CUDA function cache configurations See `cudaFuncCache`. """ NONE = (cyruntime.cudaFuncCachePreferNone, 'Default function cache configuration, no preference') SHARED = (cyruntime.cudaFuncCachePreferShared, 'Prefer larger shared memory and smaller L1 cache') L1 = (cyruntime.cudaFuncCachePreferL1, 'Prefer larger L1 cache and smaller shared memory') EQUAL = (cyruntime.cudaFuncCachePreferEqual, 'Prefer equal size L1 cache and shared memory') class SharedMemConfig(_cyb_FastEnum): """ CUDA shared memory configuration [Deprecated] See `cudaSharedMemConfig`. """ DEFAULT = cyruntime.cudaSharedMemBankSizeDefault FOUR_BYTE = cyruntime.cudaSharedMemBankSizeFourByte EIGHT_BYTE = cyruntime.cudaSharedMemBankSizeEightByte class SharedCarveout(_cyb_FastEnum): """ Shared memory carveout configurations. These may be passed to cudaFuncSetAttribute See `cudaSharedCarveout`. """ DEFAULT = (cyruntime.cudaSharedmemCarveoutDefault, 'No preference for shared memory or L1 (default)') MAX_SHARED = (cyruntime.cudaSharedmemCarveoutMaxShared, 'Prefer maximum available shared memory, minimum L1 cache') MAX_L1 = (cyruntime.cudaSharedmemCarveoutMaxL1, 'Prefer maximum available L1 cache, minimum shared memory') class ComputeMode(_cyb_FastEnum): """ CUDA device compute modes See `cudaComputeMode`. """ DEFAULT = (cyruntime.cudaComputeModeDefault, 'Default compute mode (Multiple threads can use `cudaSetDevice()` with this device)') EXCLUSIVE = (cyruntime.cudaComputeModeExclusive, 'Compute-exclusive-thread mode (Only one thread in one process will be able to use `cudaSetDevice()` with this device)') PROHIBITED = (cyruntime.cudaComputeModeProhibited, 'Compute-prohibited mode (No threads can use `cudaSetDevice()` with this device)') EXCLUSIVE_PROCESS = (cyruntime.cudaComputeModeExclusiveProcess, 'Compute-exclusive-process mode (Many threads in one process will be able to use `cudaSetDevice()` with this device)') class Limit(_cyb_FastEnum): """ CUDA Limits See `cudaLimit`. """ STACK_SIZE = (cyruntime.cudaLimitStackSize, 'GPU thread stack size') PRINTF_FIFO_SIZE = (cyruntime.cudaLimitPrintfFifoSize, 'GPU printf FIFO size') MALLOC_HEAP_SIZE = (cyruntime.cudaLimitMallocHeapSize, 'GPU malloc heap size') DEV_RUNTIME_SYNC_DEPTH = (cyruntime.cudaLimitDevRuntimeSyncDepth, 'GPU device runtime synchronize depth') DEV_RUNTIME_PENDING_LAUNCH_COUNT = (cyruntime.cudaLimitDevRuntimePendingLaunchCount, 'GPU device runtime pending launch count') MAX_L2_FETCH_GRANULARITY = (cyruntime.cudaLimitMaxL2FetchGranularity, 'A value between 0 and 128 that indicates the maximum fetch granularity of L2 (in Bytes). This is a hint') PERSISTING_L2_CACHE_SIZE = (cyruntime.cudaLimitPersistingL2CacheSize, 'A size in bytes for L2 persisting lines cache size') PER_BLOCK_MEMORY_SIZE = (cyruntime.cudaLimitPerBlockMemorySize, 'Per-block memory size') class MemoryAdvise(_cyb_FastEnum): """ CUDA Memory Advise values See `cudaMemoryAdvise`. """ SET_READ_MOSTLY = (cyruntime.cudaMemAdviseSetReadMostly, 'Data will mostly be read and only occassionally be written to') UNSET_READ_MOSTLY = (cyruntime.cudaMemAdviseUnsetReadMostly, 'Undo the effect of `cudaMemAdviseSetReadMostly`') SET_PREFERRED_LOCATION = (cyruntime.cudaMemAdviseSetPreferredLocation, 'Set the preferred location for the data as the specified device') UNSET_PREFERRED_LOCATION = (cyruntime.cudaMemAdviseUnsetPreferredLocation, 'Clear the preferred location for the data') SET_ACCESSED_BY = (cyruntime.cudaMemAdviseSetAccessedBy, 'Data will be accessed by the specified device, so prevent page faults as much as possible') UNSET_ACCESSED_BY = (cyruntime.cudaMemAdviseUnsetAccessedBy, 'Let the Unified Memory subsystem decide on the page faulting policy for the specified device') class MemRangeAttribute(_cyb_FastEnum): """ CUDA range attributes See `cudaMemRangeAttribute`. """ READ_MOSTLY = (cyruntime.cudaMemRangeAttributeReadMostly, 'Whether the range will mostly be read and only occassionally be written to') PREFERRED_LOCATION = (cyruntime.cudaMemRangeAttributePreferredLocation, 'The preferred location of the range') ACCESSED_BY = (cyruntime.cudaMemRangeAttributeAccessedBy, 'Memory range has `cudaMemAdviseSetAccessedBy` set for specified device') LAST_PREFETCH_LOCATION = (cyruntime.cudaMemRangeAttributeLastPrefetchLocation, 'The last location to which the range was prefetched') PREFERRED_LOCATION_TYPE = (cyruntime.cudaMemRangeAttributePreferredLocationType, 'The preferred location type of the range') PREFERRED_LOCATION_ID = (cyruntime.cudaMemRangeAttributePreferredLocationId, 'The preferred location id of the range') LAST_PREFETCH_LOCATION_TYPE = (cyruntime.cudaMemRangeAttributeLastPrefetchLocationType, 'The last location type to which the range was prefetched') LAST_PREFETCH_LOCATION_ID = (cyruntime.cudaMemRangeAttributeLastPrefetchLocationId, 'The last location id to which the range was prefetched') class FlushGPUDirectRDMAWritesOptions(_cyb_FastEnum): """ CUDA GPUDirect RDMA flush writes APIs supported on the device See `cudaFlushGPUDirectRDMAWritesOptions`. """ HOST = (cyruntime.cudaFlushGPUDirectRDMAWritesOptionHost, '`cudaDeviceFlushGPUDirectRDMAWrites()` and its CUDA Driver API counterpart are supported on the device.') MEM_OPS = (cyruntime.cudaFlushGPUDirectRDMAWritesOptionMemOps, 'The `CU_STREAM_WAIT_VALUE_FLUSH` flag and the `CU_STREAM_MEM_OP_FLUSH_REMOTE_WRITES` MemOp are supported on the CUDA device.') class GPUDirectRDMAWritesOrdering(_cyb_FastEnum): """ CUDA GPUDirect RDMA flush writes ordering features of the device See `cudaGPUDirectRDMAWritesOrdering`. """ NONE = (cyruntime.cudaGPUDirectRDMAWritesOrderingNone, 'The device does not natively support ordering of GPUDirect RDMA writes. `cudaFlushGPUDirectRDMAWrites()` can be leveraged if supported.') OWNER = (cyruntime.cudaGPUDirectRDMAWritesOrderingOwner, 'Natively, the device can consistently consume GPUDirect RDMA writes, although other CUDA devices may not.') ALL_DEVICES = (cyruntime.cudaGPUDirectRDMAWritesOrderingAllDevices, 'Any CUDA device in the system can consistently consume GPUDirect RDMA writes to this device.') class FlushGPUDirectRDMAWritesScope(_cyb_FastEnum): """ CUDA GPUDirect RDMA flush writes scopes See `cudaFlushGPUDirectRDMAWritesScope`. """ OWNER = (cyruntime.cudaFlushGPUDirectRDMAWritesToOwner, 'Blocks until remote writes are visible to the CUDA device context owning the data.') ALL_DEVICES = (cyruntime.cudaFlushGPUDirectRDMAWritesToAllDevices, 'Blocks until remote writes are visible to all CUDA device contexts.') class FlushGPUDirectRDMAWritesTarget(_cyb_FastEnum): """ CUDA GPUDirect RDMA flush writes targets See `cudaFlushGPUDirectRDMAWritesTarget`. """ CURRENT_DEVICE = (cyruntime.cudaFlushGPUDirectRDMAWritesTargetCurrentDevice, 'Sets the target for `cudaDeviceFlushGPUDirectRDMAWrites()` to the currently active CUDA device context.') class DeviceAttr(_cyb_FastEnum): """ CUDA device attributes See `cudaDeviceAttr`. """ MAX_THREADS_PER_BLOCK = (cyruntime.cudaDevAttrMaxThreadsPerBlock, 'Maximum number of threads per block') MAX_BLOCK_DIM_X = (cyruntime.cudaDevAttrMaxBlockDimX, 'Maximum block dimension X') MAX_BLOCK_DIM_Y = (cyruntime.cudaDevAttrMaxBlockDimY, 'Maximum block dimension Y') MAX_BLOCK_DIM_Z = (cyruntime.cudaDevAttrMaxBlockDimZ, 'Maximum block dimension Z') MAX_GRID_DIM_X = (cyruntime.cudaDevAttrMaxGridDimX, 'Maximum grid dimension X') MAX_GRID_DIM_Y = (cyruntime.cudaDevAttrMaxGridDimY, 'Maximum grid dimension Y') MAX_GRID_DIM_Z = (cyruntime.cudaDevAttrMaxGridDimZ, 'Maximum grid dimension Z') MAX_SHARED_MEMORY_PER_BLOCK = (cyruntime.cudaDevAttrMaxSharedMemoryPerBlock, 'Maximum shared memory available per block in bytes') TOTAL_CONSTANT_MEMORY = (cyruntime.cudaDevAttrTotalConstantMemory, 'Memory available on device for constant variables in a CUDA C kernel in bytes') WARP_SIZE = (cyruntime.cudaDevAttrWarpSize, 'Warp size in threads') MAX_PITCH = (cyruntime.cudaDevAttrMaxPitch, 'Maximum pitch in bytes allowed by memory copies') MAX_REGISTERS_PER_BLOCK = (cyruntime.cudaDevAttrMaxRegistersPerBlock, 'Maximum number of 32-bit registers available per block') CLOCK_RATE = (cyruntime.cudaDevAttrClockRate, 'Peak clock frequency in kilohertz') TEXTURE_ALIGNMENT = (cyruntime.cudaDevAttrTextureAlignment, 'Alignment requirement for textures') GPU_OVERLAP = (cyruntime.cudaDevAttrGpuOverlap, 'Device can possibly copy memory and execute a kernel concurrently') MULTI_PROCESSOR_COUNT = (cyruntime.cudaDevAttrMultiProcessorCount, 'Number of multiprocessors on device') KERNEL_EXEC_TIMEOUT = (cyruntime.cudaDevAttrKernelExecTimeout, 'Specifies whether there is a run time limit on kernels') INTEGRATED = (cyruntime.cudaDevAttrIntegrated, 'Device is integrated with host memory') CAN_MAP_HOST_MEMORY = (cyruntime.cudaDevAttrCanMapHostMemory, 'Device can map host memory into CUDA address space') COMPUTE_MODE = (cyruntime.cudaDevAttrComputeMode, 'Compute mode (See `cudaComputeMode` for details)') MAX_TEXTURE1D_WIDTH = (cyruntime.cudaDevAttrMaxTexture1DWidth, 'Maximum 1D texture width') MAX_TEXTURE2D_WIDTH = (cyruntime.cudaDevAttrMaxTexture2DWidth, 'Maximum 2D texture width') MAX_TEXTURE2D_HEIGHT = (cyruntime.cudaDevAttrMaxTexture2DHeight, 'Maximum 2D texture height') MAX_TEXTURE3D_WIDTH = (cyruntime.cudaDevAttrMaxTexture3DWidth, 'Maximum 3D texture width') MAX_TEXTURE3D_HEIGHT = (cyruntime.cudaDevAttrMaxTexture3DHeight, 'Maximum 3D texture height') MAX_TEXTURE3D_DEPTH = (cyruntime.cudaDevAttrMaxTexture3DDepth, 'Maximum 3D texture depth') MAX_TEXTURE2D_LAYERED_WIDTH = (cyruntime.cudaDevAttrMaxTexture2DLayeredWidth, 'Maximum 2D layered texture width') MAX_TEXTURE2D_LAYERED_HEIGHT = (cyruntime.cudaDevAttrMaxTexture2DLayeredHeight, 'Maximum 2D layered texture height') MAX_TEXTURE2D_LAYERED_LAYERS = (cyruntime.cudaDevAttrMaxTexture2DLayeredLayers, 'Maximum layers in a 2D layered texture') SURFACE_ALIGNMENT = (cyruntime.cudaDevAttrSurfaceAlignment, 'Alignment requirement for surfaces') CONCURRENT_KERNELS = (cyruntime.cudaDevAttrConcurrentKernels, 'Device can possibly execute multiple kernels concurrently') ECC_ENABLED = (cyruntime.cudaDevAttrEccEnabled, 'Device has ECC support enabled') PCI_BUS_ID = (cyruntime.cudaDevAttrPciBusId, 'PCI bus ID of the device') PCI_DEVICE_ID = (cyruntime.cudaDevAttrPciDeviceId, 'PCI device ID of the device') TCC_DRIVER = (cyruntime.cudaDevAttrTccDriver, 'Device is using TCC driver model') MEMORY_CLOCK_RATE = (cyruntime.cudaDevAttrMemoryClockRate, 'Peak memory clock frequency in kilohertz') GLOBAL_MEMORY_BUS_WIDTH = (cyruntime.cudaDevAttrGlobalMemoryBusWidth, 'Global memory bus width in bits') L2_CACHE_SIZE = (cyruntime.cudaDevAttrL2CacheSize, 'Size of L2 cache in bytes') MAX_THREADS_PER_MULTI_PROCESSOR = (cyruntime.cudaDevAttrMaxThreadsPerMultiProcessor, 'Maximum resident threads per multiprocessor') ASYNC_ENGINE_COUNT = (cyruntime.cudaDevAttrAsyncEngineCount, 'Number of asynchronous engines') UNIFIED_ADDRESSING = (cyruntime.cudaDevAttrUnifiedAddressing, 'Device shares a unified address space with the host') MAX_TEXTURE1D_LAYERED_WIDTH = (cyruntime.cudaDevAttrMaxTexture1DLayeredWidth, 'Maximum 1D layered texture width') MAX_TEXTURE1D_LAYERED_LAYERS = (cyruntime.cudaDevAttrMaxTexture1DLayeredLayers, 'Maximum layers in a 1D layered texture') MAX_TEXTURE2D_GATHER_WIDTH = (cyruntime.cudaDevAttrMaxTexture2DGatherWidth, 'Maximum 2D texture width if cudaArrayTextureGather is set') MAX_TEXTURE2D_GATHER_HEIGHT = (cyruntime.cudaDevAttrMaxTexture2DGatherHeight, 'Maximum 2D texture height if cudaArrayTextureGather is set') MAX_TEXTURE3D_WIDTH_ALT = (cyruntime.cudaDevAttrMaxTexture3DWidthAlt, 'Alternate maximum 3D texture width') MAX_TEXTURE3D_HEIGHT_ALT = (cyruntime.cudaDevAttrMaxTexture3DHeightAlt, 'Alternate maximum 3D texture height') MAX_TEXTURE3D_DEPTH_ALT = (cyruntime.cudaDevAttrMaxTexture3DDepthAlt, 'Alternate maximum 3D texture depth') PCI_DOMAIN_ID = (cyruntime.cudaDevAttrPciDomainId, 'PCI domain ID of the device') TEXTURE_PITCH_ALIGNMENT = (cyruntime.cudaDevAttrTexturePitchAlignment, 'Pitch alignment requirement for textures') MAX_TEXTURE_CUBEMAP_WIDTH = (cyruntime.cudaDevAttrMaxTextureCubemapWidth, 'Maximum cubemap texture width/height') MAX_TEXTURE_CUBEMAP_LAYERED_WIDTH = (cyruntime.cudaDevAttrMaxTextureCubemapLayeredWidth, 'Maximum cubemap layered texture width/height') MAX_TEXTURE_CUBEMAP_LAYERED_LAYERS = (cyruntime.cudaDevAttrMaxTextureCubemapLayeredLayers, 'Maximum layers in a cubemap layered texture') MAX_SURFACE1D_WIDTH = (cyruntime.cudaDevAttrMaxSurface1DWidth, 'Maximum 1D surface width') MAX_SURFACE2D_WIDTH = (cyruntime.cudaDevAttrMaxSurface2DWidth, 'Maximum 2D surface width') MAX_SURFACE2D_HEIGHT = (cyruntime.cudaDevAttrMaxSurface2DHeight, 'Maximum 2D surface height') MAX_SURFACE3D_WIDTH = (cyruntime.cudaDevAttrMaxSurface3DWidth, 'Maximum 3D surface width') MAX_SURFACE3D_HEIGHT = (cyruntime.cudaDevAttrMaxSurface3DHeight, 'Maximum 3D surface height') MAX_SURFACE3D_DEPTH = (cyruntime.cudaDevAttrMaxSurface3DDepth, 'Maximum 3D surface depth') MAX_SURFACE1D_LAYERED_WIDTH = (cyruntime.cudaDevAttrMaxSurface1DLayeredWidth, 'Maximum 1D layered surface width') MAX_SURFACE1D_LAYERED_LAYERS = (cyruntime.cudaDevAttrMaxSurface1DLayeredLayers, 'Maximum layers in a 1D layered surface') MAX_SURFACE2D_LAYERED_WIDTH = (cyruntime.cudaDevAttrMaxSurface2DLayeredWidth, 'Maximum 2D layered surface width') MAX_SURFACE2D_LAYERED_HEIGHT = (cyruntime.cudaDevAttrMaxSurface2DLayeredHeight, 'Maximum 2D layered surface height') MAX_SURFACE2D_LAYERED_LAYERS = (cyruntime.cudaDevAttrMaxSurface2DLayeredLayers, 'Maximum layers in a 2D layered surface') MAX_SURFACE_CUBEMAP_WIDTH = (cyruntime.cudaDevAttrMaxSurfaceCubemapWidth, 'Maximum cubemap surface width') MAX_SURFACE_CUBEMAP_LAYERED_WIDTH = (cyruntime.cudaDevAttrMaxSurfaceCubemapLayeredWidth, 'Maximum cubemap layered surface width') MAX_SURFACE_CUBEMAP_LAYERED_LAYERS = (cyruntime.cudaDevAttrMaxSurfaceCubemapLayeredLayers, 'Maximum layers in a cubemap layered surface') MAX_TEXTURE1D_LINEAR_WIDTH = (cyruntime.cudaDevAttrMaxTexture1DLinearWidth, 'Maximum 1D linear texture width') MAX_TEXTURE2D_LINEAR_WIDTH = (cyruntime.cudaDevAttrMaxTexture2DLinearWidth, 'Maximum 2D linear texture width') MAX_TEXTURE2D_LINEAR_HEIGHT = (cyruntime.cudaDevAttrMaxTexture2DLinearHeight, 'Maximum 2D linear texture height') MAX_TEXTURE2D_LINEAR_PITCH = (cyruntime.cudaDevAttrMaxTexture2DLinearPitch, 'Maximum 2D linear texture pitch in bytes') MAX_TEXTURE2D_MIPMAPPED_WIDTH = (cyruntime.cudaDevAttrMaxTexture2DMipmappedWidth, 'Maximum mipmapped 2D texture width') MAX_TEXTURE2D_MIPMAPPED_HEIGHT = (cyruntime.cudaDevAttrMaxTexture2DMipmappedHeight, 'Maximum mipmapped 2D texture height') COMPUTE_CAPABILITY_MAJOR = (cyruntime.cudaDevAttrComputeCapabilityMajor, 'Major compute capability version number') COMPUTE_CAPABILITY_MINOR = (cyruntime.cudaDevAttrComputeCapabilityMinor, 'Minor compute capability version number') MAX_TEXTURE1D_MIPMAPPED_WIDTH = (cyruntime.cudaDevAttrMaxTexture1DMipmappedWidth, 'Maximum mipmapped 1D texture width') STREAM_PRIORITIES_SUPPORTED = (cyruntime.cudaDevAttrStreamPrioritiesSupported, 'Device supports stream priorities') GLOBAL_L1_CACHE_SUPPORTED = (cyruntime.cudaDevAttrGlobalL1CacheSupported, 'Device supports caching globals in L1') LOCAL_L1_CACHE_SUPPORTED = (cyruntime.cudaDevAttrLocalL1CacheSupported, 'Device supports caching locals in L1') MAX_SHARED_MEMORY_PER_MULTIPROCESSOR = (cyruntime.cudaDevAttrMaxSharedMemoryPerMultiprocessor, 'Maximum shared memory available per multiprocessor in bytes') MAX_REGISTERS_PER_MULTIPROCESSOR = (cyruntime.cudaDevAttrMaxRegistersPerMultiprocessor, 'Maximum number of 32-bit registers available per multiprocessor') MANAGED_MEMORY = (cyruntime.cudaDevAttrManagedMemory, 'Device can allocate managed memory on this system') IS_MULTI_GPU_BOARD = (cyruntime.cudaDevAttrIsMultiGpuBoard, 'Device is on a multi-GPU board') MULTI_GPU_BOARD_GROUP_ID = (cyruntime.cudaDevAttrMultiGpuBoardGroupID, 'Unique identifier for a group of devices on the same multi-GPU board') HOST_NATIVE_ATOMIC_SUPPORTED = (cyruntime.cudaDevAttrHostNativeAtomicSupported, 'Link between the device and the host supports native atomic operations') SINGLE_TO_DOUBLE_PRECISION_PERF_RATIO = (cyruntime.cudaDevAttrSingleToDoublePrecisionPerfRatio, 'Ratio of single precision performance (in floating-point operations per second) to double precision performance') PAGEABLE_MEMORY_ACCESS = (cyruntime.cudaDevAttrPageableMemoryAccess, 'Device supports coherently accessing pageable memory without calling cudaHostRegister on it') CONCURRENT_MANAGED_ACCESS = (cyruntime.cudaDevAttrConcurrentManagedAccess, 'Device can coherently access managed memory concurrently with the CPU') COMPUTE_PREEMPTION_SUPPORTED = (cyruntime.cudaDevAttrComputePreemptionSupported, 'Device supports Compute Preemption') CAN_USE_HOST_POINTER_FOR_REGISTERED_MEM = (cyruntime.cudaDevAttrCanUseHostPointerForRegisteredMem, 'Device can access host registered memory at the same virtual address as the CPU') COOPERATIVE_LAUNCH = (cyruntime.cudaDevAttrCooperativeLaunch, 'Device supports launching cooperative kernels via `cudaLaunchCooperativeKernel`') MAX_SHARED_MEMORY_PER_BLOCK_OPTIN = (cyruntime.cudaDevAttrMaxSharedMemoryPerBlockOptin, 'The maximum optin shared memory per block. This value may vary by chip. See `cudaFuncSetAttribute`') CAN_FLUSH_REMOTE_WRITES = (cyruntime.cudaDevAttrCanFlushRemoteWrites, 'Device supports flushing of outstanding remote writes.') HOST_REGISTER_SUPPORTED = (cyruntime.cudaDevAttrHostRegisterSupported, 'Device supports host memory registration via `cudaHostRegister`.') PAGEABLE_MEMORY_ACCESS_USES_HOST_PAGE_TABLES = (cyruntime.cudaDevAttrPageableMemoryAccessUsesHostPageTables, "Device accesses pageable memory via the host's page tables.") DIRECT_MANAGED_MEM_ACCESS_FROM_HOST = (cyruntime.cudaDevAttrDirectManagedMemAccessFromHost, 'Host can directly access managed memory on the device without migration.') MAX_BLOCKS_PER_MULTIPROCESSOR = (cyruntime.cudaDevAttrMaxBlocksPerMultiprocessor, 'Maximum number of blocks per multiprocessor') MAX_PERSISTING_L2_CACHE_SIZE = (cyruntime.cudaDevAttrMaxPersistingL2CacheSize, 'Maximum L2 persisting lines capacity setting in bytes.') MAX_ACCESS_POLICY_WINDOW_SIZE = (cyruntime.cudaDevAttrMaxAccessPolicyWindowSize, 'Maximum value of ``cudaAccessPolicyWindow.num_bytes``.') RESERVED_SHARED_MEMORY_PER_BLOCK = (cyruntime.cudaDevAttrReservedSharedMemoryPerBlock, 'Shared memory reserved by CUDA driver per block in bytes') SPARSE_CUDA_ARRAY_SUPPORTED = (cyruntime.cudaDevAttrSparseCudaArraySupported, 'Device supports sparse CUDA arrays and sparse CUDA mipmapped arrays') HOST_REGISTER_READ_ONLY_SUPPORTED = (cyruntime.cudaDevAttrHostRegisterReadOnlySupported, 'Device supports using the `cudaHostRegister` flag cudaHostRegisterReadOnly to register memory that must be mapped as read-only to the GPU') TIMELINE_SEMAPHORE_INTEROP_SUPPORTED = (cyruntime.cudaDevAttrTimelineSemaphoreInteropSupported, 'External timeline semaphore interop is supported on the device') MEMORY_POOLS_SUPPORTED = (cyruntime.cudaDevAttrMemoryPoolsSupported, 'Device supports using the `cudaMallocAsync` and `cudaMemPool` family of APIs') GPU_DIRECT_RDMA_SUPPORTED = (cyruntime.cudaDevAttrGPUDirectRDMASupported, 'Device supports GPUDirect RDMA APIs, like nvidia_p2p_get_pages (see https://docs.nvidia.com/cuda/gpudirect-rdma for more information)') GPU_DIRECT_RDMA_FLUSH_WRITES_OPTIONS = (cyruntime.cudaDevAttrGPUDirectRDMAFlushWritesOptions, 'The returned attribute shall be interpreted as a bitmask, where the individual bits are listed in the `cudaFlushGPUDirectRDMAWritesOptions` enum') GPU_DIRECT_RDMA_WRITES_ORDERING = (cyruntime.cudaDevAttrGPUDirectRDMAWritesOrdering, 'GPUDirect RDMA writes to the device do not need to be flushed for consumers within the scope indicated by the returned attribute. See `cudaGPUDirectRDMAWritesOrdering` for the numerical values returned here.') MEMORY_POOL_SUPPORTED_HANDLE_TYPES = (cyruntime.cudaDevAttrMemoryPoolSupportedHandleTypes, 'Handle types supported with mempool based IPC') CLUSTER_LAUNCH = (cyruntime.cudaDevAttrClusterLaunch, 'Indicates device supports cluster launch') DEFERRED_MAPPING_CUDA_ARRAY_SUPPORTED = (cyruntime.cudaDevAttrDeferredMappingCudaArraySupported, 'Device supports deferred mapping CUDA arrays and CUDA mipmapped arrays') IPC_EVENT_SUPPORT = (cyruntime.cudaDevAttrIpcEventSupport, 'Device supports IPC Events.') MEM_SYNC_DOMAIN_COUNT = (cyruntime.cudaDevAttrMemSyncDomainCount, 'Number of memory synchronization domains the device supports.') NUMA_CONFIG = (cyruntime.cudaDevAttrNumaConfig, 'NUMA configuration of a device: value is of type `cudaDeviceNumaConfig` enum') NUMA_ID = (cyruntime.cudaDevAttrNumaId, 'NUMA node ID of the GPU memory') MPS_ENABLED = (cyruntime.cudaDevAttrMpsEnabled, 'Contexts created on this device will be shared via MPS') HOST_NUMA_ID = (cyruntime.cudaDevAttrHostNumaId, 'NUMA ID of the host node closest to the device or -1 when system does not support NUMA') D3D12_CIG_SUPPORTED = (cyruntime.cudaDevAttrD3D12CigSupported, 'Device supports CIG with D3D12.') VULKAN_CIG_SUPPORTED = (cyruntime.cudaDevAttrVulkanCigSupported, 'Device supports CIG with Vulkan.') GPU_PCI_DEVICE_ID = (cyruntime.cudaDevAttrGpuPciDeviceId, 'The combined 16-bit PCI device ID and 16-bit PCI vendor ID.') GPU_PCI_SUBSYSTEM_ID = (cyruntime.cudaDevAttrGpuPciSubsystemId, 'The combined 16-bit PCI subsystem ID and 16-bit PCI subsystem vendor ID.') HOST_NUMA_MEMORY_POOLS_SUPPORTED = (cyruntime.cudaDevAttrHostNumaMemoryPoolsSupported, 'Device supports HOST_NUMA location with the `cudaMallocAsync` and `cudaMemPool` family of APIs') HOST_NUMA_MULTINODE_IPC_SUPPORTED = (cyruntime.cudaDevAttrHostNumaMultinodeIpcSupported, 'Device supports HostNuma location IPC between nodes in a multi-node system.') HOST_MEMORY_POOLS_SUPPORTED = (cyruntime.cudaDevAttrHostMemoryPoolsSupported, 'Device suports HOST location with the `cuMemAllocAsync` and `cuMemPool` family of APIs') ONLY_PARTIAL_HOST_NATIVE_ATOMIC_SUPPORTED = (cyruntime.cudaDevAttrOnlyPartialHostNativeAtomicSupported, 'Link between the device and the host supports only some native atomic operations') ATOMIC_REDUCTION_SUPPORTED = (cyruntime.cudaDevAttrAtomicReductionSupported, 'Device supports atomic reduction operations in stream batch memory operations') LOCALITY_DOMAIN_COUNT = (cyruntime.cudaDevAttrLocalityDomainCount, 'Number of locality domains') OVERSIZED_SHARED_MEMORY_PER_BLOCK = (cyruntime.cudaDevAttrOversizedSharedMemoryPerBlock, 'The maximum oversized shared memory per block. This value may vary by chip. See `cudaFuncSetAttribute`') CIG_STREAMS_SUPPORTED = (cyruntime.cudaDevAttrCigStreamsSupported, 'Device supports CIG streams') LOCALITY_DOMAIN_MULTIPROCESSOR_COUNT = (cyruntime.cudaDevAttrLocalityDomainMultiprocessorCount, 'Number of multiprocessors on each locality domain') TENSOR_MAP_LARGE_TENSOR_MIN_SIZE = (cyruntime.cudaDevAttrTensorMapLargeTensorMinSize, 'Smallest tensor size in bytes at which TMA descriptors are treated as "large" (BASE_128KB OOB mode). tensors >= this threshold are eligible for the tensormap.replace.assume_large PTX modifier. Returns INT_MAX on devices without this distinction where assume_large is a no-op.') MAX = cyruntime.cudaDevAttrMax class MemPoolAttr(_cyb_FastEnum): """ CUDA memory pool attributes See `cudaMemPoolAttr`. """ REUSE_FOLLOW_EVENT_DEPENDENCIES = (cyruntime.cudaMemPoolReuseFollowEventDependencies, '(value type = int) Allow cuMemAllocAsync to use memory asynchronously freed in another streams as long as a stream ordering dependency of the allocating stream on the free action exists. Cuda events and null stream interactions can create the required stream ordered dependencies. (default enabled)') REUSE_ALLOW_OPPORTUNISTIC = (cyruntime.cudaMemPoolReuseAllowOpportunistic, '(value type = int) Allow reuse of already completed frees when there is no dependency between the free and allocation. (default enabled)') REUSE_ALLOW_INTERNAL_DEPENDENCIES = (cyruntime.cudaMemPoolReuseAllowInternalDependencies, '(value type = int) Allow cuMemAllocAsync to insert new stream dependencies in order to establish the stream ordering required to reuse a piece of memory released by cuFreeAsync (default enabled).') RELEASE_THRESHOLD = (cyruntime.cudaMemPoolAttrReleaseThreshold, '(value type = cuuint64_t) Amount of reserved memory in bytes to hold onto before trying to release memory back to the OS. When more than the release threshold bytes of memory are held by the memory pool, the allocator will try to release memory back to the OS on the next call to stream, event or context synchronize. (default 0)') RESERVED_MEM_CURRENT = (cyruntime.cudaMemPoolAttrReservedMemCurrent, '(value type = cuuint64_t) Amount of backing memory currently allocated for the mempool.') RESERVED_MEM_HIGH = (cyruntime.cudaMemPoolAttrReservedMemHigh, '(value type = cuuint64_t) High watermark of backing memory allocated for the mempool since the last time it was reset. High watermark can only be reset to zero.') USED_MEM_CURRENT = (cyruntime.cudaMemPoolAttrUsedMemCurrent, '(value type = cuuint64_t) Amount of memory from the pool that is currently in use by the application.') USED_MEM_HIGH = (cyruntime.cudaMemPoolAttrUsedMemHigh, '(value type = cuuint64_t) High watermark of the amount of memory from the pool that was in use by the application since the last time it was reset. High watermark can only be reset to zero.') ALLOCATION_TYPE = (cyruntime.cudaMemPoolAttrAllocationType, '(value type = `cudaMemAllocationType`) The allocation type of the mempool') EXPORT_HANDLE_TYPES = (cyruntime.cudaMemPoolAttrExportHandleTypes, '(value type = `cudaMemAllocationHandleType`) Available export handle types for the mempool. For imported pools this value is always cudaMemHandleTypeNone as an imported pool cannot be re-exported') LOCATION_ID = (cyruntime.cudaMemPoolAttrLocationId, '(value type = int) The location id for the mempool. If the location type for this pool is cudaMemLocationTypeInvisible then ID will be cudaInvalidDeviceId') LOCATION_TYPE = (cyruntime.cudaMemPoolAttrLocationType, '(value type = `cudaMemLocationType`) The location type for the mempool. For imported memory pools where the device is not directly visible to the importing process or pools imported via fabric handles across nodes this will be cudaMemLocationTypeInvisible') MAX_POOL_SIZE = (cyruntime.cudaMemPoolAttrMaxPoolSize, '(value type = cuuint64_t) Maximum size of the pool in bytes, this value may be higher than what was initially passed to cudaMemPoolCreate due to alignment requirements. A value of 0 indicates no maximum size. For cudaMemAllocationTypeManaged and IPC imported pools this value will be system dependent.') HW_DECOMPRESS_ENABLED = (cyruntime.cudaMemPoolAttrHwDecompressEnabled, '(value type = int) Indicates whether the pool has hardware compresssion enabled') LOCALITY_DOMAIN_ID = (cyruntime.cudaMemPoolAttrLocalityDomainId, '(value type = int) The locality domain id for the mempool, if the mempool is localized to a locality domain. A value of -1 indicates that the mempool is not localized to a locality domain.') class MemLocationType(_cyb_FastEnum): """ Specifies the type of location See `cudaMemLocationType`. """ INVALID = cyruntime.cudaMemLocationTypeInvalid NONE = (cyruntime.cudaMemLocationTypeNone, 'Location is unspecified. This is used when creating a managed memory pool to indicate no preferred location for the pool') DEVICE = (cyruntime.cudaMemLocationTypeDevice, 'Location is a device location, thus id is a device ordinal') HOST = (cyruntime.cudaMemLocationTypeHost, 'Location is host, id is ignored') HOST_NUMA = (cyruntime.cudaMemLocationTypeHostNuma, 'Location is a host NUMA node, thus id is a host NUMA node id') HOST_NUMA_CURRENT = (cyruntime.cudaMemLocationTypeHostNumaCurrent, "Location is the host NUMA node closest to the current thread's CPU, id is ignored") INVISIBLE = (cyruntime.cudaMemLocationTypeInvisible, 'Location is not visible but device is accessible, id is always cudaInvalidDeviceId') DEVICE_LOCALITY_DOMAIN = (cyruntime.cudaMemLocationTypeDeviceLocalityDomain, 'Location is a portion of device memory, specified by the locality domain ID') class MemAccessFlags(_cyb_FastEnum): """ Specifies the memory protection flags for mapping. See `cudaMemAccessFlags`. """ NONE = (cyruntime.cudaMemAccessFlagsProtNone, 'Default, make the address range not accessible') READ = (cyruntime.cudaMemAccessFlagsProtRead, 'Make the address range read accessible') READ_WRITE = (cyruntime.cudaMemAccessFlagsProtReadWrite, 'Make the address range read-write accessible') class MemAllocationType(_cyb_FastEnum): """ Defines the allocation types available See `cudaMemAllocationType`. """ INVALID = cyruntime.cudaMemAllocationTypeInvalid PINNED = (cyruntime.cudaMemAllocationTypePinned, "This allocation type is 'pinned', i.e. cannot migrate from its current location while the application is actively using it") MANAGED = (cyruntime.cudaMemAllocationTypeManaged, 'This allocation type is managed memory') MAX = cyruntime.cudaMemAllocationTypeMax class MemAllocationHandleType(_cyb_FastEnum): """ Flags for specifying particular handle types See `cudaMemAllocationHandleType`. """ NONE = (cyruntime.cudaMemHandleTypeNone, 'Does not allow any export mechanism. >') POSIX_FILE_DESCRIPTOR = (cyruntime.cudaMemHandleTypePosixFileDescriptor, 'Allows a file descriptor to be used for exporting. Permitted only on POSIX systems. (int)') WIN32 = (cyruntime.cudaMemHandleTypeWin32, 'Allows a Win32 NT handle to be used for exporting. (HANDLE)') WIN32_KMT = (cyruntime.cudaMemHandleTypeWin32Kmt, 'Allows a Win32 KMT handle to be used for exporting. (D3DKMT_HANDLE)') FABRIC = (cyruntime.cudaMemHandleTypeFabric, 'Allows a fabric handle to be used for exporting. (`cudaMemFabricHandle_t`)') class GraphMemAttributeType(_cyb_FastEnum): """ Graph memory attributes See `cudaGraphMemAttributeType`. """ USED_MEM_CURRENT = (cyruntime.cudaGraphMemAttrUsedMemCurrent, '(value type = cuuint64_t) Amount of memory, in bytes, currently associated with graphs.') USED_MEM_HIGH = (cyruntime.cudaGraphMemAttrUsedMemHigh, '(value type = cuuint64_t) High watermark of memory, in bytes, associated with graphs since the last time it was reset. High watermark can only be reset to zero.') RESERVED_MEM_CURRENT = (cyruntime.cudaGraphMemAttrReservedMemCurrent, '(value type = cuuint64_t) Amount of memory, in bytes, currently allocated for use by the CUDA graphs asynchronous allocator.') RESERVED_MEM_HIGH = (cyruntime.cudaGraphMemAttrReservedMemHigh, '(value type = cuuint64_t) High watermark of memory, in bytes, currently allocated for use by the CUDA graphs asynchronous allocator.') class MemCpyFlags(_cyb_FastEnum): """ Flags to specify for copies within a batch. For more details see `cudaMemcpyBatchAsync`. See `cudaMemcpyFlags`. """ DEFAULT = cyruntime.cudaMemcpyFlagDefault PREFER_OVERLAP_WITH_COMPUTE = (cyruntime.cudaMemcpyFlagPreferOverlapWithCompute, 'Hint to the driver to try and overlap the copy with compute work on the SMs.') class MemCpySrcAccessOrder(_cyb_FastEnum): """ See `cudaMemcpySrcAccessOrder`. """ INVALID = (cyruntime.cudaMemcpySrcAccessOrderInvalid, 'Default invalid.') STREAM = (cyruntime.cudaMemcpySrcAccessOrderStream, 'Indicates that access to the source pointer must be in stream order.') DURING_API_CALL = (cyruntime.cudaMemcpySrcAccessOrderDuringApiCall, "Indicates that access to the source pointer can be out of stream order and all accesses must be complete before the API call returns. This flag is suited for ephemeral sources (ex., stack variables) when it's known that no prior operations in the stream can be accessing the memory and also that the lifetime of the memory is limited to the scope that the source variable was declared in. Specifying this flag allows the driver to optimize the copy and removes the need for the user to synchronize the stream after the API call.") ANY = (cyruntime.cudaMemcpySrcAccessOrderAny, "Indicates that access to the source pointer can be out of stream order and the accesses can happen even after the API call returns. This flag is suited for host pointers allocated outside CUDA (ex., via malloc) when it's known that no prior operations in the stream can be accessing the memory. Specifying this flag allows the driver to optimize the copy on certain platforms.") MAX = cyruntime.cudaMemcpySrcAccessOrderMax class MemCpy3dOperandType(_cyb_FastEnum): """ These flags allow applications to convey the operand type for individual copies specified in `cudaMemcpy3DBatchAsync`. See `cudaMemcpy3DOperandType`. """ POINTER = (cyruntime.cudaMemcpyOperandTypePointer, 'Memcpy operand is a valid pointer.') ARRAY = (cyruntime.cudaMemcpyOperandTypeArray, 'Memcpy operand is a CUarray.') MAX = cyruntime.cudaMemcpyOperandTypeMax class DeviceP2PAttr(_cyb_FastEnum): """ CUDA device P2P attributes See `cudaDeviceP2PAttr`. """ PERFORMANCE_RANK = (cyruntime.cudaDevP2PAttrPerformanceRank, 'A relative value indicating the performance of the link between two devices') ACCESS_SUPPORTED = (cyruntime.cudaDevP2PAttrAccessSupported, 'Peer access is enabled') NATIVE_ATOMIC_SUPPORTED = (cyruntime.cudaDevP2PAttrNativeAtomicSupported, 'Native atomic operation over the link supported') CUDA_ARRAY_ACCESS_SUPPORTED = (cyruntime.cudaDevP2PAttrCudaArrayAccessSupported, 'Accessing CUDA arrays over the link supported') ONLY_PARTIAL_NATIVE_ATOMIC_SUPPORTED = (cyruntime.cudaDevP2PAttrOnlyPartialNativeAtomicSupported, 'Only some CUDA-valid atomic operations over the link are supported.') class ExternalMemoryHandleType(_cyb_FastEnum): """ External memory handle types See `cudaExternalMemoryHandleType`. """ OPAQUE_FD = (cyruntime.cudaExternalMemoryHandleTypeOpaqueFd, 'Handle is an opaque file descriptor') OPAQUE_WIN32 = (cyruntime.cudaExternalMemoryHandleTypeOpaqueWin32, 'Handle is an opaque shared NT handle') OPAQUE_WIN32_KMT = (cyruntime.cudaExternalMemoryHandleTypeOpaqueWin32Kmt, 'Handle is an opaque, globally shared handle') D3D12_HEAP = (cyruntime.cudaExternalMemoryHandleTypeD3D12Heap, 'Handle is a D3D12 heap object') D3D12_RESOURCE = (cyruntime.cudaExternalMemoryHandleTypeD3D12Resource, 'Handle is a D3D12 committed resource') D3D11_RESOURCE = (cyruntime.cudaExternalMemoryHandleTypeD3D11Resource, 'Handle is a shared NT handle to a D3D11 resource') D3D11_RESOURCE_KMT = (cyruntime.cudaExternalMemoryHandleTypeD3D11ResourceKmt, 'Handle is a globally shared handle to a D3D11 resource') NV_SCI_BUF = (cyruntime.cudaExternalMemoryHandleTypeNvSciBuf, 'Handle is an NvSciBuf object') class ExternalSemaphoreHandleType(_cyb_FastEnum): """ External semaphore handle types See `cudaExternalSemaphoreHandleType`. """ OPAQUE_FD = (cyruntime.cudaExternalSemaphoreHandleTypeOpaqueFd, 'Handle is an opaque file descriptor') OPAQUE_WIN32 = (cyruntime.cudaExternalSemaphoreHandleTypeOpaqueWin32, 'Handle is an opaque shared NT handle') OPAQUE_WIN32_KMT = (cyruntime.cudaExternalSemaphoreHandleTypeOpaqueWin32Kmt, 'Handle is an opaque, globally shared handle') D3D12_FENCE = (cyruntime.cudaExternalSemaphoreHandleTypeD3D12Fence, 'Handle is a shared NT handle referencing a D3D12 fence object') D3D11_FENCE = (cyruntime.cudaExternalSemaphoreHandleTypeD3D11Fence, 'Handle is a shared NT handle referencing a D3D11 fence object') NV_SCI_SYNC = (cyruntime.cudaExternalSemaphoreHandleTypeNvSciSync, 'Opaque handle to NvSciSync Object') KEYED_MUTEX = (cyruntime.cudaExternalSemaphoreHandleTypeKeyedMutex, 'Handle is a shared NT handle referencing a D3D11 keyed mutex object') KEYED_MUTEX_KMT = (cyruntime.cudaExternalSemaphoreHandleTypeKeyedMutexKmt, 'Handle is a shared KMT handle referencing a D3D11 keyed mutex object') TIMELINE_SEMAPHORE_FD = (cyruntime.cudaExternalSemaphoreHandleTypeTimelineSemaphoreFd, 'Handle is an opaque handle file descriptor referencing a timeline semaphore') TIMELINE_SEMAPHORE_WIN32 = (cyruntime.cudaExternalSemaphoreHandleTypeTimelineSemaphoreWin32, 'Handle is an opaque handle file descriptor referencing a timeline semaphore') class JitOption(_cyb_FastEnum): """ Online compiler and linker options See `cudaJitOption`. """ MAX_REGISTERS = (cyruntime.cudaJitMaxRegisters, 'Max number of registers that a thread may use. Option type: unsigned int Applies to: compiler only') THREADS_PER_BLOCK = (cyruntime.cudaJitThreadsPerBlock, 'IN: Specifies minimum number of threads per block to target compilation for OUT: Returns the number of threads the compiler actually targeted. This restricts the resource utilization of the compiler (e.g. max registers) such that a block with the given number of threads should be able to launch based on register limitations. Note, this option does not currently take into account any other resource limitations, such as shared memory utilization. Option type: unsigned int Applies to: compiler only') WALL_TIME = (cyruntime.cudaJitWallTime, 'Overwrites the option value with the total wall clock time, in milliseconds, spent in the compiler and linker Option type: float Applies to: compiler and linker') INFO_LOG_BUFFER = (cyruntime.cudaJitInfoLogBuffer, 'Pointer to a buffer in which to print any log messages that are informational in nature (the buffer size is specified via option `cudaJitInfoLogBufferSizeBytes`) Option type: char \\* Applies to: compiler and linker') INFO_LOG_BUFFER_SIZE_BYTES = (cyruntime.cudaJitInfoLogBufferSizeBytes, 'IN: Log buffer size in bytes. Log messages will be capped at this size (including null terminator) OUT: Amount of log buffer filled with messages Option type: unsigned int Applies to: compiler and linker') ERROR_LOG_BUFFER = (cyruntime.cudaJitErrorLogBuffer, 'Pointer to a buffer in which to print any log messages that reflect errors (the buffer size is specified via option `cudaJitErrorLogBufferSizeBytes`) Option type: char \\* Applies to: compiler and linker') ERROR_LOG_BUFFER_SIZE_BYTES = (cyruntime.cudaJitErrorLogBufferSizeBytes, 'IN: Log buffer size in bytes. Log messages will be capped at this size (including null terminator) OUT: Amount of log buffer filled with messages Option type: unsigned int Applies to: compiler and linker') OPTIMIZATION_LEVEL = (cyruntime.cudaJitOptimizationLevel, 'Level of optimizations to apply to generated code (0 - 4), with 4 being the default and highest level of optimizations. Option type: unsigned int Applies to: compiler only') FALLBACK_STRATEGY = (cyruntime.cudaJitFallbackStrategy, 'Specifies choice of fallback strategy if matching cubin is not found. Choice is based on supplied `cudaJit_Fallback`. Option type: unsigned int for enumerated type `cudaJit_Fallback` Applies to: compiler only') GENERATE_DEBUG_INFO = (cyruntime.cudaJitGenerateDebugInfo, 'Specifies whether to create debug information in output (-g) (0: false, default) Option type: int Applies to: compiler and linker') LOG_VERBOSE = (cyruntime.cudaJitLogVerbose, 'Generate verbose log messages (0: false, default) Option type: int Applies to: compiler and linker') GENERATE_LINE_INFO = (cyruntime.cudaJitGenerateLineInfo, 'Generate line number information (-lineinfo) (0: false, default) Option type: int Applies to: compiler only') CACHE_MODE = (cyruntime.cudaJitCacheMode, 'Specifies whether to enable caching explicitly (-dlcm) Choice is based on supplied `cudaJit_CacheMode`. Option type: unsigned int for enumerated type `cudaJit_CacheMode` Applies to: compiler only') POSITION_INDEPENDENT_CODE = (cyruntime.cudaJitPositionIndependentCode, 'Generate position independent code (0: false) Option type: int Applies to: compiler only') MIN_CTA_PER_SM = (cyruntime.cudaJitMinCtaPerSm, 'This option hints to the JIT compiler the minimum number of CTAs from the kernel’s grid to be mapped to a SM. This option is ignored when used together with `cudaJitMaxRegisters` or `cudaJitThreadsPerBlock`. Optimizations based on this option need `cudaJitMaxThreadsPerBlock` to be specified as well. For kernels already using PTX directive .minnctapersm, this option will be ignored by default. Use `cudaJitOverrideDirectiveValues` to let this option take precedence over the PTX directive. Option type: unsigned int Applies to: compiler only') MAX_THREADS_PER_BLOCK = (cyruntime.cudaJitMaxThreadsPerBlock, 'Maximum number threads in a thread block, computed as the product of the maximum extent specifed for each dimension of the block. This limit is guaranteed not to be exeeded in any invocation of the kernel. Exceeding the the maximum number of threads results in runtime error or kernel launch failure. For kernels already using PTX directive .maxntid, this option will be ignored by default. Use `cudaJitOverrideDirectiveValues` to let this option take precedence over the PTX directive. Option type: int Applies to: compiler only') OVERRIDE_DIRECTIVE_VALUES = (cyruntime.cudaJitOverrideDirectiveValues, 'This option lets the values specified using `cudaJitMaxRegisters`, `cudaJitThreadsPerBlock`, `cudaJitMaxThreadsPerBlock` and `cudaJitMinCtaPerSm` take precedence over any PTX directives. (0: Disable, default; 1: Enable) Option type: int Applies to: compiler only') class LibraryOption(_cyb_FastEnum): """ Library options to be specified with `cudaLibraryLoadData()` or `cudaLibraryLoadFromFile()` See `cudaLibraryOption`. """ HOST_UNIVERSAL_FUNCTION_AND_DATA_TABLE = cyruntime.cudaLibraryHostUniversalFunctionAndDataTable BINARY_IS_PRESERVED = (cyruntime.cudaLibraryBinaryIsPreserved, 'Specifes that the argument `code` passed to `cudaLibraryLoadData()` will be preserved. Specifying this option will let the driver know that `code` can be accessed at any point until `cudaLibraryUnload()`. The default behavior is for the driver to allocate and maintain its own copy of `code`. Note that this is only a memory usage optimization hint and the driver can choose to ignore it if required. Specifying this option with `cudaLibraryLoadFromFile()` is invalid and will return `cudaErrorInvalidValue`.') class JitCacheMode(_cyb_FastEnum): """ Caching modes for dlcm See `cudaJit_CacheMode`. """ NONE = (cyruntime.cudaJitCacheOptionNone, 'Compile with no -dlcm flag specified') CG = (cyruntime.cudaJitCacheOptionCG, 'Compile with L1 cache disabled') CA = (cyruntime.cudaJitCacheOptionCA, 'Compile with L1 cache enabled') class JitFallback(_cyb_FastEnum): """ Cubin matching fallback strategies See `cudaJit_Fallback`. """ PTX = (cyruntime.cudaPreferPtx, 'Prefer to compile ptx if exact binary match not found') BINARY = (cyruntime.cudaPreferBinary, 'Prefer to fall back to compatible binary code if exact match not found') class CGScope(_cyb_FastEnum): """ CUDA cooperative group scope See `cudaCGScope`. """ INVALID = (cyruntime.cudaCGScopeInvalid, 'Invalid cooperative group scope') GRID = (cyruntime.cudaCGScopeGrid, 'Scope represented by a grid_group') class GraphConditionalHandleFlags(_cyb_FastEnum): """ See `cudaGraphConditionalHandleFlags`. """ ASSIGN_DEFAULT = (cyruntime.cudaGraphCondAssignDefault, 'Apply default handle value when graph is launched.') class GraphConditionalNodeType(_cyb_FastEnum): """ CUDA conditional node types See `cudaGraphConditionalNodeType`. """ IF_ = (cyruntime.cudaGraphCondTypeIf, "Conditional 'if/else' Node. Body[0] executed if condition is non-zero. If `size` == 2, an optional ELSE graph is created and this is executed if the condition is zero.") WHILE = (cyruntime.cudaGraphCondTypeWhile, "Conditional 'while' Node. Body executed repeatedly while condition value is non-zero.") SWITCH = (cyruntime.cudaGraphCondTypeSwitch, "Conditional 'switch' Node. Body[n] is executed once, where 'n' is the value of the condition. If the condition does not match a body index, no body is launched.") class GraphNodeType(_cyb_FastEnum): """ CUDA Graph node types See `cudaGraphNodeType`. """ KERNEL = (cyruntime.cudaGraphNodeTypeKernel, 'GPU kernel node') MEMCPY = (cyruntime.cudaGraphNodeTypeMemcpy, 'Memcpy node') MEMSET = (cyruntime.cudaGraphNodeTypeMemset, 'Memset node') HOST = (cyruntime.cudaGraphNodeTypeHost, 'Host (executable) node') GRAPH = (cyruntime.cudaGraphNodeTypeGraph, 'Node which executes an embedded graph') EMPTY = (cyruntime.cudaGraphNodeTypeEmpty, 'Empty (no-op) node') WAIT_EVENT = (cyruntime.cudaGraphNodeTypeWaitEvent, 'External event wait node') EVENT_RECORD = (cyruntime.cudaGraphNodeTypeEventRecord, 'External event record node') EXT_SEMAPHORE_SIGNAL = (cyruntime.cudaGraphNodeTypeExtSemaphoreSignal, 'External semaphore signal node') EXT_SEMAPHORE_WAIT = (cyruntime.cudaGraphNodeTypeExtSemaphoreWait, 'External semaphore wait node') MEM_ALLOC = (cyruntime.cudaGraphNodeTypeMemAlloc, 'Memory allocation node') MEM_FREE = (cyruntime.cudaGraphNodeTypeMemFree, 'Memory free node') CONDITIONAL = (cyruntime.cudaGraphNodeTypeConditional, 'Conditional node May be used to implement a conditional execution path or loop inside of a graph. The graph(s) contained within the body of the conditional node can be selectively executed or iterated upon based on the value of a conditional variable. Handles must be created in advance of creating the node using `cudaGraphConditionalHandleCreate`. The following restrictions apply to graphs which contain conditional nodes: The graph cannot be used in a child node. Only one instantiation of the graph may exist at any point in time. The graph cannot be cloned. To set the control value, supply a default value when creating the handle and/or call `cudaGraphSetConditional` from device code.') MEMCPY_BATCH = (cyruntime.cudaGraphNodeTypeMemcpyBatch, 'Batch Memcpy Node') EXTERNAL_ENGINE = (cyruntime.cudaGraphNodeTypeExternalEngine, 'Reserved for External Engine node') COUNT = cyruntime.cudaGraphNodeTypeCount class GraphChildGraphNodeOwnership(_cyb_FastEnum): """ Child graph node ownership See `cudaGraphChildGraphNodeOwnership`. """ CLONE = (cyruntime.cudaGraphChildGraphOwnershipClone, "Default behavior for a child graph node. Child graph is cloned into the parent and memory allocation/free nodes can't be present in the child graph.") MOVE = (cyruntime.cudaGraphChildGraphOwnershipMove, 'The child graph is moved to the parent. The handle to the child graph is owned by the parent and will be destroyed when the parent is destroyed. The following restrictions apply to child graphs after they have been moved: Cannot be independently instantiated or destroyed; Cannot be added as a child graph of a separate parent graph; Cannot be used as an argument to cudaGraphExecUpdate; Cannot have additional memory allocation or free nodes added.') INVALID = (cyruntime.cudaGraphChildGraphOwnershipInvalid, 'Invalid ownership flag. Set when params are queried to prevent accidentally reusing the driver-owned graph object') class GraphDependencyType(_cyb_FastEnum): """ Type annotations that can be applied to graph edges as part of `cudaGraphEdgeData`. See `cudaGraphDependencyType`. """ DEFAULT = (cyruntime.cudaGraphDependencyTypeDefault, 'This is an ordinary dependency.') PROGRAMMATIC = (cyruntime.cudaGraphDependencyTypeProgrammatic, 'This dependency type allows the downstream node to use `cudaGridDependencySynchronize()`. It may only be used between kernel nodes, and must be used with either the `cudaGraphKernelNodePortProgrammatic` or `cudaGraphKernelNodePortLaunchCompletion` outgoing port.') class GraphExecUpdateResult(_cyb_FastEnum): """ CUDA Graph Update error types See `cudaGraphExecUpdateResult`. """ SUCCESS = (cyruntime.cudaGraphExecUpdateSuccess, 'The update succeeded') ERROR = (cyruntime.cudaGraphExecUpdateError, 'The update failed for an unexpected reason which is described in the return value of the function') ERROR_TOPOLOGY_CHANGED = (cyruntime.cudaGraphExecUpdateErrorTopologyChanged, 'The update failed because the topology changed') ERROR_NODE_TYPE_CHANGED = (cyruntime.cudaGraphExecUpdateErrorNodeTypeChanged, 'The update failed because a node type changed') ERROR_FUNCTION_CHANGED = (cyruntime.cudaGraphExecUpdateErrorFunctionChanged, 'The update failed because the function of a kernel node changed (CUDA driver < 11.2)') ERROR_PARAMETERS_CHANGED = (cyruntime.cudaGraphExecUpdateErrorParametersChanged, 'The update failed because the parameters changed in a way that is not supported') ERROR_NOT_SUPPORTED = (cyruntime.cudaGraphExecUpdateErrorNotSupported, 'The update failed because something about the node is not supported') ERROR_UNSUPPORTED_FUNCTION_CHANGE = (cyruntime.cudaGraphExecUpdateErrorUnsupportedFunctionChange, 'The update failed because the function of a kernel node changed in an unsupported way') ERROR_ATTRIBUTES_CHANGED = (cyruntime.cudaGraphExecUpdateErrorAttributesChanged, 'The update failed because the node attributes changed in a way that is not supported') class GraphInstantiateResult(_cyb_FastEnum): """ Graph instantiation results See `cudaGraphInstantiateResult`. """ SUCCESS = (cyruntime.cudaGraphInstantiateSuccess, 'Instantiation succeeded') ERROR = (cyruntime.cudaGraphInstantiateError, 'Instantiation failed for an unexpected reason which is described in the return value of the function') INVALID_STRUCTURE = (cyruntime.cudaGraphInstantiateInvalidStructure, 'Instantiation failed due to invalid structure, such as cycles') NODE_OPERATION_NOT_SUPPORTED = (cyruntime.cudaGraphInstantiateNodeOperationNotSupported, 'Instantiation for device launch failed because the graph contained an unsupported operation') MULTIPLE_DEVICES_NOT_SUPPORTED = (cyruntime.cudaGraphInstantiateMultipleDevicesNotSupported, 'Instantiation for device launch failed due to the nodes belonging to different contexts') CONDITIONAL_HANDLE_UNUSED = (cyruntime.cudaGraphInstantiateConditionalHandleUnused, 'One or more conditional handles are not associated with conditional nodes') class GraphKernelNodeField(_cyb_FastEnum): """ Specifies the field to update when performing multiple node updates from the device See `cudaGraphKernelNodeField`. """ INVALID = (cyruntime.cudaGraphKernelNodeFieldInvalid, 'Invalid field') GRID_DIM = (cyruntime.cudaGraphKernelNodeFieldGridDim, 'Grid dimension update') PARAM = (cyruntime.cudaGraphKernelNodeFieldParam, 'Kernel parameter update') ENABLED = (cyruntime.cudaGraphKernelNodeFieldEnabled, 'Node enable/disable') class GetDriverEntryPointFlags(_cyb_FastEnum): """ Flags to specify search options to be used with `cudaGetDriverEntryPoint` For more details see `cuGetProcAddress` See `cudaGetDriverEntryPointFlags`. """ DEFAULT = (cyruntime.cudaEnableDefault, 'Default search mode for driver symbols.') LEGACY_STREAM = (cyruntime.cudaEnableLegacyStream, 'Search for legacy versions of driver symbols.') PER_THREAD_DEFAULT_STREAM = (cyruntime.cudaEnablePerThreadDefaultStream, 'Search for per-thread versions of driver symbols.') class DriverEntryPointQueryResult(_cyb_FastEnum): """ Enum for status from obtaining driver entry points, used with `cudaApiGetDriverEntryPoint` See `cudaDriverEntryPointQueryResult`. """ SUCCESS = (cyruntime.cudaDriverEntryPointSuccess, 'Search for symbol found a match') SYMBOL_NOT_FOUND = (cyruntime.cudaDriverEntryPointSymbolNotFound, 'Search for symbol was not found') VERSION_NOT_SUFFICENT = (cyruntime.cudaDriverEntryPointVersionNotSufficent, "Search for symbol was found but version wasn't great enough") class GraphDebugDotFlags(_cyb_FastEnum): """ CUDA Graph debug write options See `cudaGraphDebugDotFlags`. """ VERBOSE = (cyruntime.cudaGraphDebugDotFlagsVerbose, 'Output all debug data as if every debug flag is enabled') KERNEL_NODE_PARAMS = (cyruntime.cudaGraphDebugDotFlagsKernelNodeParams, 'Adds `cudaKernelNodeParams` to output') MEMCPY_NODE_PARAMS = (cyruntime.cudaGraphDebugDotFlagsMemcpyNodeParams, 'Adds `cudaMemcpy3DParms` to output') MEMSET_NODE_PARAMS = (cyruntime.cudaGraphDebugDotFlagsMemsetNodeParams, 'Adds `cudaMemsetParams` to output') HOST_NODE_PARAMS = (cyruntime.cudaGraphDebugDotFlagsHostNodeParams, 'Adds `cudaHostNodeParams` to output') EVENT_NODE_PARAMS = (cyruntime.cudaGraphDebugDotFlagsEventNodeParams, 'Adds `cudaEvent_t` handle from record and wait nodes to output') EXT_SEMAS_SIGNAL_NODE_PARAMS = (cyruntime.cudaGraphDebugDotFlagsExtSemasSignalNodeParams, 'Adds `cudaExternalSemaphoreSignalNodeParams` values to output') EXT_SEMAS_WAIT_NODE_PARAMS = (cyruntime.cudaGraphDebugDotFlagsExtSemasWaitNodeParams, 'Adds `cudaExternalSemaphoreWaitNodeParams` to output') KERNEL_NODE_ATTRIBUTES = (cyruntime.cudaGraphDebugDotFlagsKernelNodeAttributes, 'Adds cudaKernelNodeAttrID values to output') HANDLES = (cyruntime.cudaGraphDebugDotFlagsHandles, 'Adds node handles and every kernel function handle to output') CONDITIONAL_NODE_PARAMS = (cyruntime.cudaGraphDebugDotFlagsConditionalNodeParams, 'Adds `cudaConditionalNodeParams` to output') MEMCPY_BATCH_NODE_PARAMS = (cyruntime.cudaGraphDebugDotFlagsMemcpyBatchNodeParams, 'Adds batch memcpy node parameters to the output') class GraphInstantiateFlags(_cyb_FastEnum): """ Flags for instantiating a graph See `cudaGraphInstantiateFlags`. """ AUTO_FREE_ON_LAUNCH = (cyruntime.cudaGraphInstantiateFlagAutoFreeOnLaunch, 'Automatically free memory allocated in a graph before relaunching.') UPLOAD = (cyruntime.cudaGraphInstantiateFlagUpload, 'Automatically upload the graph after instantiation. Only supported by `cudaGraphInstantiateWithParams`. The upload will be performed using the stream provided in `instantiateParams`.') DEVICE_LAUNCH = (cyruntime.cudaGraphInstantiateFlagDeviceLaunch, 'Instantiate the graph to be launchable from the device. This flag can only be used on platforms which support unified addressing. This flag cannot be used in conjunction with cudaGraphInstantiateFlagAutoFreeOnLaunch.') USE_NODE_PRIORITY = (cyruntime.cudaGraphInstantiateFlagUseNodePriority, 'Run the graph using the per-node priority attributes rather than the priority of the stream it is launched into.') class LaunchMemSyncDomain(_cyb_FastEnum): """ Memory Synchronization Domain A kernel can be launched in a specified memory synchronization domain that affects all memory operations issued by that kernel. A memory barrier issued in one domain will only order memory operations in that domain, thus eliminating latency increase from memory barriers ordering unrelated traffic. By default, kernels are launched in domain 0. Kernel launched with `cudaLaunchMemSyncDomainRemote` will have a different domain ID. User may also alter the domain ID with `cudaLaunchMemSyncDomainMap` for a specific stream / graph node / kernel launch. See `cudaLaunchAttributeMemSyncDomain`, `cudaStreamSetAttribute`, `cudaLaunchKernelEx`, `cudaGraphKernelNodeSetAttribute`. Memory operations done in kernels launched in different domains are considered system-scope distanced. In other words, a GPU scoped memory synchronization is not sufficient for memory order to be observed by kernels in another memory synchronization domain even if they are on the same GPU. See `cudaLaunchMemSyncDomain`. """ DEFAULT = (cyruntime.cudaLaunchMemSyncDomainDefault, 'Launch kernels in the default domain') REMOTE = (cyruntime.cudaLaunchMemSyncDomainRemote, 'Launch kernels in the remote domain') class LaunchAttributeID(_cyb_FastEnum): """ Launch attributes enum; used as id field of `cudaLaunchAttribute` See `cudaLaunchAttributeID`. """ IGNORE = (cyruntime.cudaLaunchAttributeIgnore, 'Ignored entry, for convenient composition') ACCESS_POLICY_WINDOW = (cyruntime.cudaLaunchAttributeAccessPolicyWindow, 'Valid for streams, graph nodes, launches. See ``cudaLaunchAttributeValue.accessPolicyWindow``.') COOPERATIVE = (cyruntime.cudaLaunchAttributeCooperative, 'Valid for graph nodes, launches. See ``cudaLaunchAttributeValue.cooperative``.') SYNCHRONIZATION_POLICY = (cyruntime.cudaLaunchAttributeSynchronizationPolicy, 'Valid for streams. See ``cudaLaunchAttributeValue.syncPolicy``.') CLUSTER_DIMENSION = (cyruntime.cudaLaunchAttributeClusterDimension, 'Valid for graph nodes, launches. See ``cudaLaunchAttributeValue.clusterDim``.') CLUSTER_SCHEDULING_POLICY_PREFERENCE = (cyruntime.cudaLaunchAttributeClusterSchedulingPolicyPreference, 'Valid for graph nodes, launches. See ``cudaLaunchAttributeValue.clusterSchedulingPolicyPreference``.') PROGRAMMATIC_STREAM_SERIALIZATION = (cyruntime.cudaLaunchAttributeProgrammaticStreamSerialization, "Valid for launches. Setting ``cudaLaunchAttributeValue.programmaticStreamSerializationAllowed`` to non-0 signals that the kernel will use programmatic means to resolve its stream dependency, so that the CUDA runtime should opportunistically allow the grid's execution to overlap with the previous kernel in the stream, if that kernel requests the overlap. The dependent launches can choose to wait on the dependency using the programmatic sync (cudaGridDependencySynchronize() or equivalent PTX instructions).") PROGRAMMATIC_EVENT = (cyruntime.cudaLaunchAttributeProgrammaticEvent, "Valid for launches. Set ``cudaLaunchAttributeValue.programmaticEvent`` to record the event. Event recorded through this launch attribute is guaranteed to only trigger after all block in the associated kernel trigger the event. A block can trigger the event programmatically in a future CUDA release. A trigger can also be inserted at the beginning of each block's execution if triggerAtBlockStart is set to non-0. The dependent launches can choose to wait on the dependency using the programmatic sync (cudaGridDependencySynchronize() or equivalent PTX instructions). Note that dependents (including the CPU thread calling `cudaEventSynchronize()`) are not guaranteed to observe the release precisely when it is released. For example, `cudaEventSynchronize()` may only observe the event trigger long after the associated kernel has completed. This recording type is primarily meant for establishing programmatic dependency between device tasks. Note also this type of dependency allows, but does not guarantee, concurrent execution of tasks. The event supplied must not be an interprocess or interop event. The event must disable timing (i.e. must be created with the `cudaEventDisableTiming` flag set).") PRIORITY = (cyruntime.cudaLaunchAttributePriority, 'Valid for streams, graph nodes, launches. See ``cudaLaunchAttributeValue.priority``.') MEM_SYNC_DOMAIN_MAP = (cyruntime.cudaLaunchAttributeMemSyncDomainMap, 'Valid for streams, graph nodes, launches. See ``cudaLaunchAttributeValue.memSyncDomainMap``.') MEM_SYNC_DOMAIN = (cyruntime.cudaLaunchAttributeMemSyncDomain, 'Valid for streams, graph nodes, launches. See ``cudaLaunchAttributeValue.memSyncDomain``.') PREFERRED_CLUSTER_DIMENSION = (cyruntime.cudaLaunchAttributePreferredClusterDimension, 'Valid for graph nodes and launches. Set ``cudaLaunchAttributeValue.preferredClusterDim`` to allow the kernel launch to specify a preferred substitute cluster dimension. Blocks may be grouped according to either the dimensions specified with this attribute (grouped into a "preferred substitute cluster"), or the one specified with `cudaLaunchAttributeClusterDimension` attribute (grouped into a "regular cluster"). The cluster dimensions of a "preferred substitute cluster" shall be an integer multiple greater than zero of the regular cluster dimensions. The device will attempt - on a best-effort basis - to group thread blocks into preferred clusters over grouping them into regular clusters. When it deems necessary (primarily when the device temporarily runs out of physical resources to launch the larger preferred clusters), the device may switch to launch the regular clusters instead to attempt to utilize as much of the physical device resources as possible. Each type of cluster will have its enumeration / coordinate setup as if the grid consists solely of its type of cluster. For example, if the preferred substitute cluster dimensions double the regular cluster dimensions, there might be simultaneously a regular cluster indexed at (1,0,0), and a preferred cluster indexed at (1,0,0). In this example, the preferred substitute cluster (1,0,0) replaces regular clusters (2,0,0) and (3,0,0) and groups their blocks. This attribute will only take effect when a regular cluster dimension has been specified. The preferred substitute cluster dimension must be an integer multiple greater than zero of the regular cluster dimension and must divide the grid. It must also be no more than `maxBlocksPerCluster`, if it is set in the kernel\'s `__launch_bounds__`. Otherwise it must be less than the maximum value the driver can support. Otherwise, setting this attribute to a value physically unable to fit on any particular device is permitted.') LAUNCH_COMPLETION_EVENT = (cyruntime.cudaLaunchAttributeLaunchCompletionEvent, 'Valid for launches. Set ``cudaLaunchAttributeValue.launchCompletionEvent`` to record the event. Nominally, the event is triggered once all blocks of the kernel have begun execution. Currently this is a best effort. If a kernel B has a launch completion dependency on a kernel A, B may wait until A is complete. Alternatively, blocks of B may begin before all blocks of A have begun, for example if B can claim execution resources unavailable to A (e.g. they run on different GPUs) or if B is a higher priority than A. Exercise caution if such an ordering inversion could lead to deadlock. A launch completion event is nominally similar to a programmatic event with `triggerAtBlockStart` set except that it is not visible to `cudaGridDependencySynchronize()` and can be used with compute capability less than 9.0. The event supplied must not be an interprocess or interop event. The event must disable timing (i.e. must be created with the `cudaEventDisableTiming` flag set).') DEVICE_UPDATABLE_KERNEL_NODE = (cyruntime.cudaLaunchAttributeDeviceUpdatableKernelNode, "Valid for graph nodes, launches. This attribute is graphs-only, and passing it to a launch in a non-capturing stream will result in an error. ``cudaLaunchAttributeValue.deviceUpdatableKernelNode.deviceUpdatable`` can only be set to 0 or 1. Setting the field to 1 indicates that the corresponding kernel node should be device-updatable. On success, a handle will be returned via ``cudaLaunchAttributeValue.deviceUpdatableKernelNode.devNode`` which can be passed to the various device-side update functions to update the node's kernel parameters from within another kernel. For more information on the types of device updates that can be made, as well as the relevant limitations thereof, see `cudaGraphKernelNodeUpdatesApply`. Nodes which are device-updatable have additional restrictions compared to regular kernel nodes. Firstly, device-updatable nodes cannot be removed from their graph via `cudaGraphDestroyNode`. Additionally, once opted-in to this functionality, a node cannot opt out, and any attempt to set the deviceUpdatable attribute to 0 will result in an error. Device-updatable kernel nodes also cannot have their attributes copied to/from another kernel node via `cudaGraphKernelNodeCopyAttributes`. Graphs containing one or more device-updatable nodes also do not allow multiple instantiation, and neither the graph nor its instantiated version can be passed to `cudaGraphExecUpdate`. If a graph contains device-updatable nodes and updates those nodes from the device from within the graph, the graph must be uploaded with `cuGraphUpload` before it is launched. For such a graph, if host-side executable graph updates are made to the device-updatable nodes, the graph must be uploaded before it is launched again.") PREFERRED_SHARED_MEMORY_CARVEOUT = (cyruntime.cudaLaunchAttributePreferredSharedMemoryCarveout, 'Valid for launches. On devices where the L1 cache and shared memory use the same hardware resources, setting ``cudaLaunchAttributeValue.sharedMemCarveout`` to a percentage between 0-100 signals sets the shared memory carveout preference in percent of the total shared memory for that kernel launch. This attribute takes precedence over `cudaFuncAttributePreferredSharedMemoryCarveout`. This is only a hint, and the driver can choose a different configuration if required for the launch.') NVLINK_UTIL_CENTRIC_SCHEDULING = (cyruntime.cudaLaunchAttributeNvlinkUtilCentricScheduling, "Valid for streams, graph nodes, launches. This attribute is a hint to the CUDA runtime that the launch should attempt to make the kernel maximize its NVLINK utilization. When possible to honor this hint, CUDA will assume each block in the grid launch will carry out an even amount of NVLINK traffic, and make a best-effort attempt to adjust the kernel launch based on that assumption. This attribute is a hint only. CUDA makes no functional or performance guarantee. Its applicability can be affected by many different factors, including driver version (i.e. CUDA doesn't guarantee the performance characteristics will be maintained between driver versions or a driver update could alter or regress previously observed perf characteristics.) It also doesn't guarantee a successful result, i.e. applying the attribute may not improve the performance of either the targeted kernel or the encapsulating application. Valid values for ``cudaLaunchAttributeValue.nvlinkUtilCentricScheduling`` are 0 (disabled) and 1 (enabled).") PORTABLE_CLUSTER_SIZE_MODE = (cyruntime.cudaLaunchAttributePortableClusterSizeMode, 'Valid for graph nodes, launches. This indicates whether the kernel launch is allowed to use a non-portable cluster size. Valid values for ``cudaLaunchAttributeValue.portableClusterSizeMode`` are values for `cudaLaunchAttributePortableClusterMode` Any other value will return `cudaErrorInvalidValue`') SHARED_MEMORY_MODE = (cyruntime.cudaLaunchAttributeSharedMemoryMode, 'Valid for graph nodes, launches. This indicates that the kernel launch is allowed to use a non-portable shared memory mode.') class DeviceNumaConfig(_cyb_FastEnum): """ CUDA device NUMA config See `cudaDeviceNumaConfig`. """ NONE = (cyruntime.cudaDeviceNumaConfigNone, 'The GPU is not a NUMA node') NUMA_NODE = (cyruntime.cudaDeviceNumaConfigNumaNode, 'The GPU is a NUMA node, cudaDevAttrNumaId contains its NUMA ID') class AsyncNotificationType(_cyb_FastEnum): """ Types of async notification that can occur See `cudaAsyncNotificationType`. """ OVER_BUDGET = (cyruntime.cudaAsyncNotificationTypeOverBudget, 'Sent when the process has exceeded its device memory budget') class RoundMode(_cyb_FastEnum): """ See `cudaRoundMode`. """ NEAREST = cyruntime.cudaRoundNearest ZERO = cyruntime.cudaRoundZero POS_INF = cyruntime.cudaRoundPosInf MIN_INF = cyruntime.cudaRoundMinInf class SurfaceBoundaryMode(_cyb_FastEnum): """ CUDA Surface boundary modes See `cudaSurfaceBoundaryMode`. """ ZERO = (cyruntime.cudaBoundaryModeZero, 'Zero boundary mode') CLAMP = (cyruntime.cudaBoundaryModeClamp, 'Clamp boundary mode') TRAP = (cyruntime.cudaBoundaryModeTrap, 'Trap boundary mode') class SurfaceFormatMode(_cyb_FastEnum): """ CUDA Surface format modes See `cudaSurfaceFormatMode`. """ FORCED = (cyruntime.cudaFormatModeForced, 'Forced format mode') AUTO = (cyruntime.cudaFormatModeAuto, 'Auto format mode') class TextureAddressMode(_cyb_FastEnum): """ CUDA texture address modes See `cudaTextureAddressMode`. """ WRAP = (cyruntime.cudaAddressModeWrap, 'Wrapping address mode') CLAMP = (cyruntime.cudaAddressModeClamp, 'Clamp to edge address mode') MIRROR = (cyruntime.cudaAddressModeMirror, 'Mirror address mode') BORDER = (cyruntime.cudaAddressModeBorder, 'Border address mode') class TextureFilterMode(_cyb_FastEnum): """ CUDA texture filter modes See `cudaTextureFilterMode`. """ POINT = (cyruntime.cudaFilterModePoint, 'Point filter mode') LINEAR = (cyruntime.cudaFilterModeLinear, 'Linear filter mode') class TextureReadMode(_cyb_FastEnum): """ CUDA texture read modes See `cudaTextureReadMode`. """ ELEMENT_TYPE = (cyruntime.cudaReadModeElementType, 'Read texture as specified element type') NORMALIZED_FLOAT = (cyruntime.cudaReadModeNormalizedFloat, 'Read texture as normalized float') class DataType(_cyb_FastEnum): """ See `cudaDataType`. """ R_16F = cyruntime.CUDA_R_16F C_16F = cyruntime.CUDA_C_16F R_16BF = cyruntime.CUDA_R_16BF C_16BF = cyruntime.CUDA_C_16BF R_32F = cyruntime.CUDA_R_32F C_32F = cyruntime.CUDA_C_32F R_64F = cyruntime.CUDA_R_64F C_64F = cyruntime.CUDA_C_64F R_4I = cyruntime.CUDA_R_4I C_4I = cyruntime.CUDA_C_4I R_4U = cyruntime.CUDA_R_4U C_4U = cyruntime.CUDA_C_4U R_8I = cyruntime.CUDA_R_8I C_8I = cyruntime.CUDA_C_8I R_8U = cyruntime.CUDA_R_8U C_8U = cyruntime.CUDA_C_8U R_16I = cyruntime.CUDA_R_16I C_16I = cyruntime.CUDA_C_16I R_16U = cyruntime.CUDA_R_16U C_16U = cyruntime.CUDA_C_16U R_32I = cyruntime.CUDA_R_32I C_32I = cyruntime.CUDA_C_32I R_32U = cyruntime.CUDA_R_32U C_32U = cyruntime.CUDA_C_32U R_64I = cyruntime.CUDA_R_64I C_64I = cyruntime.CUDA_C_64I R_64U = cyruntime.CUDA_R_64U C_64U = cyruntime.CUDA_C_64U R_8F_E4M3 = cyruntime.CUDA_R_8F_E4M3 R_8F_UE4M3 = cyruntime.CUDA_R_8F_UE4M3 R_8F_E5M2 = cyruntime.CUDA_R_8F_E5M2 R_8F_UE8M0 = cyruntime.CUDA_R_8F_UE8M0 R_6F_E2M3 = cyruntime.CUDA_R_6F_E2M3 R_6F_E3M2 = cyruntime.CUDA_R_6F_E3M2 R_4F_E2M1 = cyruntime.CUDA_R_4F_E2M1 R_8F_UE5M3 = cyruntime.CUDA_R_8F_UE5M3 class EglFrameType(_cyb_FastEnum): """ CUDA EglFrame type - array or pointer See `cudaEglFrameType`. """ ARRAY = (cyruntime.cudaEglFrameTypeArray, 'Frame type CUDA array') PITCH = (cyruntime.cudaEglFrameTypePitch, 'Frame type CUDA pointer') class EglResourceLocationFlags(_cyb_FastEnum): """ Resource location flags- sysmem or vidmem For CUDA context on iGPU, since video and system memory are equivalent - these flags will not have an effect on the execution. For CUDA context on dGPU, applications can use the flag `cudaEglResourceLocationFlags` to give a hint about the desired location. `cudaEglResourceLocationSysmem` - the frame data is made resident on the system memory to be accessed by CUDA. `cudaEglResourceLocationVidmem` - the frame data is made resident on the dedicated video memory to be accessed by CUDA. There may be an additional latency due to new allocation and data migration, if the frame is produced on a different memory. See `cudaEglResourceLocationFlags`. """ SYSMEM = (cyruntime.cudaEglResourceLocationSysmem, 'Resource location sysmem') VIDMEM = (cyruntime.cudaEglResourceLocationVidmem, 'Resource location vidmem') class EglColorFormat(_cyb_FastEnum): """ CUDA EGL Color Format - The different planar and multiplanar formats currently supported for CUDA_EGL interops. See `cudaEglColorFormat`. """ YUV420_PLANAR = (cyruntime.cudaEglColorFormatYUV420Planar, 'Y, U, V in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = 1/2 Y height.') YUV420_SEMI_PLANAR = (cyruntime.cudaEglColorFormatYUV420SemiPlanar, 'Y, UV in two surfaces (UV as one surface) with VU byte ordering, width, height ratio same as YUV420Planar.') YUV422_PLANAR = (cyruntime.cudaEglColorFormatYUV422Planar, 'Y, U, V each in a separate surface, U/V width = 1/2 Y width, U/V height = Y height.') YUV422_SEMI_PLANAR = (cyruntime.cudaEglColorFormatYUV422SemiPlanar, 'Y, UV in two surfaces with VU byte ordering, width, height ratio same as YUV422Planar.') ARGB = (cyruntime.cudaEglColorFormatARGB, 'R/G/B/A four channels in one surface with BGRA byte ordering.') RGBA = (cyruntime.cudaEglColorFormatRGBA, 'R/G/B/A four channels in one surface with ABGR byte ordering.') L = (cyruntime.cudaEglColorFormatL, 'single luminance channel in one surface.') R = (cyruntime.cudaEglColorFormatR, 'single color channel in one surface.') YUV444_PLANAR = (cyruntime.cudaEglColorFormatYUV444Planar, 'Y, U, V in three surfaces, each in a separate surface, U/V width = Y width, U/V height = Y height.') YUV444_SEMI_PLANAR = (cyruntime.cudaEglColorFormatYUV444SemiPlanar, 'Y, UV in two surfaces (UV as one surface) with VU byte ordering, width, height ratio same as YUV444Planar.') YUYV422 = (cyruntime.cudaEglColorFormatYUYV422, 'Y, U, V in one surface, interleaved as UYVY in one channel.') UYVY422 = (cyruntime.cudaEglColorFormatUYVY422, 'Y, U, V in one surface, interleaved as YUYV in one channel.') ABGR = (cyruntime.cudaEglColorFormatABGR, 'R/G/B/A four channels in one surface with RGBA byte ordering.') BGRA = (cyruntime.cudaEglColorFormatBGRA, 'R/G/B/A four channels in one surface with ARGB byte ordering.') A = (cyruntime.cudaEglColorFormatA, 'Alpha color format - one channel in one surface.') RG = (cyruntime.cudaEglColorFormatRG, 'R/G color format - two channels in one surface with GR byte ordering') AYUV = (cyruntime.cudaEglColorFormatAYUV, 'Y, U, V, A four channels in one surface, interleaved as VUYA.') YVU444_SEMI_PLANAR = (cyruntime.cudaEglColorFormatYVU444SemiPlanar, 'Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = Y width, U/V height = Y height.') YVU422_SEMI_PLANAR = (cyruntime.cudaEglColorFormatYVU422SemiPlanar, 'Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = Y height.') YVU420_SEMI_PLANAR = (cyruntime.cudaEglColorFormatYVU420SemiPlanar, 'Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = 1/2 Y height.') Y10V10U10_444_SEMI_PLANAR = (cyruntime.cudaEglColorFormatY10V10U10_444SemiPlanar, 'Y10, V10U10 in two surfaces (VU as one surface) with UV byte ordering, U/V width = Y width, U/V height = Y height.') Y10V10U10_420_SEMI_PLANAR = (cyruntime.cudaEglColorFormatY10V10U10_420SemiPlanar, 'Y10, V10U10 in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = 1/2 Y height.') Y12V12U12_444_SEMI_PLANAR = (cyruntime.cudaEglColorFormatY12V12U12_444SemiPlanar, 'Y12, V12U12 in two surfaces (VU as one surface) with UV byte ordering, U/V width = Y width, U/V height = Y height.') Y12V12U12_420_SEMI_PLANAR = (cyruntime.cudaEglColorFormatY12V12U12_420SemiPlanar, 'Y12, V12U12 in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = 1/2 Y height.') VYUY_ER = (cyruntime.cudaEglColorFormatVYUY_ER, 'Extended Range Y, U, V in one surface, interleaved as YVYU in one channel.') UYVY_ER = (cyruntime.cudaEglColorFormatUYVY_ER, 'Extended Range Y, U, V in one surface, interleaved as YUYV in one channel.') YUYV_ER = (cyruntime.cudaEglColorFormatYUYV_ER, 'Extended Range Y, U, V in one surface, interleaved as UYVY in one channel.') YVYU_ER = (cyruntime.cudaEglColorFormatYVYU_ER, 'Extended Range Y, U, V in one surface, interleaved as VYUY in one channel.') YUVA_ER = (cyruntime.cudaEglColorFormatYUVA_ER, 'Extended Range Y, U, V, A four channels in one surface, interleaved as AVUY.') AYUV_ER = (cyruntime.cudaEglColorFormatAYUV_ER, 'Extended Range Y, U, V, A four channels in one surface, interleaved as VUYA.') YUV444_PLANAR_ER = (cyruntime.cudaEglColorFormatYUV444Planar_ER, 'Extended Range Y, U, V in three surfaces, U/V width = Y width, U/V height = Y height.') YUV422_PLANAR_ER = (cyruntime.cudaEglColorFormatYUV422Planar_ER, 'Extended Range Y, U, V in three surfaces, U/V width = 1/2 Y width, U/V height = Y height.') YUV420_PLANAR_ER = (cyruntime.cudaEglColorFormatYUV420Planar_ER, 'Extended Range Y, U, V in three surfaces, U/V width = 1/2 Y width, U/V height = 1/2 Y height.') YUV444_SEMI_PLANAR_ER = (cyruntime.cudaEglColorFormatYUV444SemiPlanar_ER, 'Extended Range Y, UV in two surfaces (UV as one surface) with VU byte ordering, U/V width = Y width, U/V height = Y height.') YUV422_SEMI_PLANAR_ER = (cyruntime.cudaEglColorFormatYUV422SemiPlanar_ER, 'Extended Range Y, UV in two surfaces (UV as one surface) with VU byte ordering, U/V width = 1/2 Y width, U/V height = Y height.') YUV420_SEMI_PLANAR_ER = (cyruntime.cudaEglColorFormatYUV420SemiPlanar_ER, 'Extended Range Y, UV in two surfaces (UV as one surface) with VU byte ordering, U/V width = 1/2 Y width, U/V height = 1/2 Y height.') YVU444_PLANAR_ER = (cyruntime.cudaEglColorFormatYVU444Planar_ER, 'Extended Range Y, V, U in three surfaces, U/V width = Y width, U/V height = Y height.') YVU422_PLANAR_ER = (cyruntime.cudaEglColorFormatYVU422Planar_ER, 'Extended Range Y, V, U in three surfaces, U/V width = 1/2 Y width, U/V height = Y height.') YVU420_PLANAR_ER = (cyruntime.cudaEglColorFormatYVU420Planar_ER, 'Extended Range Y, V, U in three surfaces, U/V width = 1/2 Y width, U/V height = 1/2 Y height.') YVU444_SEMI_PLANAR_ER = (cyruntime.cudaEglColorFormatYVU444SemiPlanar_ER, 'Extended Range Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = Y width, U/V height = Y height.') YVU422_SEMI_PLANAR_ER = (cyruntime.cudaEglColorFormatYVU422SemiPlanar_ER, 'Extended Range Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = Y height.') YVU420_SEMI_PLANAR_ER = (cyruntime.cudaEglColorFormatYVU420SemiPlanar_ER, 'Extended Range Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = 1/2 Y height.') BAYER_RGGB = (cyruntime.cudaEglColorFormatBayerRGGB, 'Bayer format - one channel in one surface with interleaved RGGB ordering.') BAYER_BGGR = (cyruntime.cudaEglColorFormatBayerBGGR, 'Bayer format - one channel in one surface with interleaved BGGR ordering.') BAYER_GRBG = (cyruntime.cudaEglColorFormatBayerGRBG, 'Bayer format - one channel in one surface with interleaved GRBG ordering.') BAYER_GBRG = (cyruntime.cudaEglColorFormatBayerGBRG, 'Bayer format - one channel in one surface with interleaved GBRG ordering.') BAYER10RGGB = (cyruntime.cudaEglColorFormatBayer10RGGB, 'Bayer10 format - one channel in one surface with interleaved RGGB ordering. Out of 16 bits, 10 bits used 6 bits No-op.') BAYER10BGGR = (cyruntime.cudaEglColorFormatBayer10BGGR, 'Bayer10 format - one channel in one surface with interleaved BGGR ordering. Out of 16 bits, 10 bits used 6 bits No-op.') BAYER10GRBG = (cyruntime.cudaEglColorFormatBayer10GRBG, 'Bayer10 format - one channel in one surface with interleaved GRBG ordering. Out of 16 bits, 10 bits used 6 bits No-op.') BAYER10GBRG = (cyruntime.cudaEglColorFormatBayer10GBRG, 'Bayer10 format - one channel in one surface with interleaved GBRG ordering. Out of 16 bits, 10 bits used 6 bits No-op.') BAYER12RGGB = (cyruntime.cudaEglColorFormatBayer12RGGB, 'Bayer12 format - one channel in one surface with interleaved RGGB ordering. Out of 16 bits, 12 bits used 4 bits No-op.') BAYER12BGGR = (cyruntime.cudaEglColorFormatBayer12BGGR, 'Bayer12 format - one channel in one surface with interleaved BGGR ordering. Out of 16 bits, 12 bits used 4 bits No-op.') BAYER12GRBG = (cyruntime.cudaEglColorFormatBayer12GRBG, 'Bayer12 format - one channel in one surface with interleaved GRBG ordering. Out of 16 bits, 12 bits used 4 bits No-op.') BAYER12GBRG = (cyruntime.cudaEglColorFormatBayer12GBRG, 'Bayer12 format - one channel in one surface with interleaved GBRG ordering. Out of 16 bits, 12 bits used 4 bits No-op.') BAYER14RGGB = (cyruntime.cudaEglColorFormatBayer14RGGB, 'Bayer14 format - one channel in one surface with interleaved RGGB ordering. Out of 16 bits, 14 bits used 2 bits No-op.') BAYER14BGGR = (cyruntime.cudaEglColorFormatBayer14BGGR, 'Bayer14 format - one channel in one surface with interleaved BGGR ordering. Out of 16 bits, 14 bits used 2 bits No-op.') BAYER14GRBG = (cyruntime.cudaEglColorFormatBayer14GRBG, 'Bayer14 format - one channel in one surface with interleaved GRBG ordering. Out of 16 bits, 14 bits used 2 bits No-op.') BAYER14GBRG = (cyruntime.cudaEglColorFormatBayer14GBRG, 'Bayer14 format - one channel in one surface with interleaved GBRG ordering. Out of 16 bits, 14 bits used 2 bits No-op.') BAYER20RGGB = (cyruntime.cudaEglColorFormatBayer20RGGB, 'Bayer20 format - one channel in one surface with interleaved RGGB ordering. Out of 32 bits, 20 bits used 12 bits No-op.') BAYER20BGGR = (cyruntime.cudaEglColorFormatBayer20BGGR, 'Bayer20 format - one channel in one surface with interleaved BGGR ordering. Out of 32 bits, 20 bits used 12 bits No-op.') BAYER20GRBG = (cyruntime.cudaEglColorFormatBayer20GRBG, 'Bayer20 format - one channel in one surface with interleaved GRBG ordering. Out of 32 bits, 20 bits used 12 bits No-op.') BAYER20GBRG = (cyruntime.cudaEglColorFormatBayer20GBRG, 'Bayer20 format - one channel in one surface with interleaved GBRG ordering. Out of 32 bits, 20 bits used 12 bits No-op.') YVU444_PLANAR = (cyruntime.cudaEglColorFormatYVU444Planar, 'Y, V, U in three surfaces, each in a separate surface, U/V width = Y width, U/V height = Y height.') YVU422_PLANAR = (cyruntime.cudaEglColorFormatYVU422Planar, 'Y, V, U in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = Y height.') YVU420_PLANAR = (cyruntime.cudaEglColorFormatYVU420Planar, 'Y, V, U in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = 1/2 Y height.') BAYER_ISP_RGGB = (cyruntime.cudaEglColorFormatBayerIspRGGB, 'Nvidia proprietary Bayer ISP format - one channel in one surface with interleaved RGGB ordering and mapped to opaque integer datatype.') BAYER_ISP_BGGR = (cyruntime.cudaEglColorFormatBayerIspBGGR, 'Nvidia proprietary Bayer ISP format - one channel in one surface with interleaved BGGR ordering and mapped to opaque integer datatype.') BAYER_ISP_GRBG = (cyruntime.cudaEglColorFormatBayerIspGRBG, 'Nvidia proprietary Bayer ISP format - one channel in one surface with interleaved GRBG ordering and mapped to opaque integer datatype.') BAYER_ISP_GBRG = (cyruntime.cudaEglColorFormatBayerIspGBRG, 'Nvidia proprietary Bayer ISP format - one channel in one surface with interleaved GBRG ordering and mapped to opaque integer datatype.') BAYER_BCCR = (cyruntime.cudaEglColorFormatBayerBCCR, 'Bayer format - one channel in one surface with interleaved BCCR ordering.') BAYER_RCCB = (cyruntime.cudaEglColorFormatBayerRCCB, 'Bayer format - one channel in one surface with interleaved RCCB ordering.') BAYER_CRBC = (cyruntime.cudaEglColorFormatBayerCRBC, 'Bayer format - one channel in one surface with interleaved CRBC ordering.') BAYER_CBRC = (cyruntime.cudaEglColorFormatBayerCBRC, 'Bayer format - one channel in one surface with interleaved CBRC ordering.') BAYER10CCCC = (cyruntime.cudaEglColorFormatBayer10CCCC, 'Bayer10 format - one channel in one surface with interleaved CCCC ordering. Out of 16 bits, 10 bits used 6 bits No-op.') BAYER12BCCR = (cyruntime.cudaEglColorFormatBayer12BCCR, 'Bayer12 format - one channel in one surface with interleaved BCCR ordering. Out of 16 bits, 12 bits used 4 bits No-op.') BAYER12RCCB = (cyruntime.cudaEglColorFormatBayer12RCCB, 'Bayer12 format - one channel in one surface with interleaved RCCB ordering. Out of 16 bits, 12 bits used 4 bits No-op.') BAYER12CRBC = (cyruntime.cudaEglColorFormatBayer12CRBC, 'Bayer12 format - one channel in one surface with interleaved CRBC ordering. Out of 16 bits, 12 bits used 4 bits No-op.') BAYER12CBRC = (cyruntime.cudaEglColorFormatBayer12CBRC, 'Bayer12 format - one channel in one surface with interleaved CBRC ordering. Out of 16 bits, 12 bits used 4 bits No-op.') BAYER12CCCC = (cyruntime.cudaEglColorFormatBayer12CCCC, 'Bayer12 format - one channel in one surface with interleaved CCCC ordering. Out of 16 bits, 12 bits used 4 bits No-op.') Y = (cyruntime.cudaEglColorFormatY, 'Color format for single Y plane.') YUV420_SEMI_PLANAR_2020 = (cyruntime.cudaEglColorFormatYUV420SemiPlanar_2020, 'Y, UV in two surfaces (UV as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height.') YVU420_SEMI_PLANAR_2020 = (cyruntime.cudaEglColorFormatYVU420SemiPlanar_2020, 'Y, VU in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height.') YUV420_PLANAR_2020 = (cyruntime.cudaEglColorFormatYUV420Planar_2020, 'Y, U, V in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = 1/2 Y height.') YVU420_PLANAR_2020 = (cyruntime.cudaEglColorFormatYVU420Planar_2020, 'Y, V, U in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = 1/2 Y height.') YUV420_SEMI_PLANAR_709 = (cyruntime.cudaEglColorFormatYUV420SemiPlanar_709, 'Y, UV in two surfaces (UV as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height.') YVU420_SEMI_PLANAR_709 = (cyruntime.cudaEglColorFormatYVU420SemiPlanar_709, 'Y, VU in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height.') YUV420_PLANAR_709 = (cyruntime.cudaEglColorFormatYUV420Planar_709, 'Y, U, V in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = 1/2 Y height.') YVU420_PLANAR_709 = (cyruntime.cudaEglColorFormatYVU420Planar_709, 'Y, V, U in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = 1/2 Y height.') Y10V10U10_420_SEMI_PLANAR_709 = (cyruntime.cudaEglColorFormatY10V10U10_420SemiPlanar_709, 'Y10, V10U10 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height.') Y10V10U10_420_SEMI_PLANAR_2020 = (cyruntime.cudaEglColorFormatY10V10U10_420SemiPlanar_2020, 'Y10, V10U10 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height.') Y10V10U10_422_SEMI_PLANAR_2020 = (cyruntime.cudaEglColorFormatY10V10U10_422SemiPlanar_2020, 'Y10, V10U10 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = Y height.') Y10V10U10_422_SEMI_PLANAR = (cyruntime.cudaEglColorFormatY10V10U10_422SemiPlanar, 'Y10, V10U10 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = Y height.') Y10V10U10_422_SEMI_PLANAR_709 = (cyruntime.cudaEglColorFormatY10V10U10_422SemiPlanar_709, 'Y10, V10U10 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = Y height.') Y_ER = (cyruntime.cudaEglColorFormatY_ER, 'Extended Range Color format for single Y plane.') Y_709_ER = (cyruntime.cudaEglColorFormatY_709_ER, 'Extended Range Color format for single Y plane.') Y10_ER = (cyruntime.cudaEglColorFormatY10_ER, 'Extended Range Color format for single Y10 plane.') Y10_709_ER = (cyruntime.cudaEglColorFormatY10_709_ER, 'Extended Range Color format for single Y10 plane.') Y12_ER = (cyruntime.cudaEglColorFormatY12_ER, 'Extended Range Color format for single Y12 plane.') Y12_709_ER = (cyruntime.cudaEglColorFormatY12_709_ER, 'Extended Range Color format for single Y12 plane.') YUVA = (cyruntime.cudaEglColorFormatYUVA, 'Y, U, V, A four channels in one surface, interleaved as AVUY.') YVYU = (cyruntime.cudaEglColorFormatYVYU, 'Y, U, V in one surface, interleaved as YVYU in one channel.') VYUY = (cyruntime.cudaEglColorFormatVYUY, 'Y, U, V in one surface, interleaved as VYUY in one channel.') Y10V10U10_420_SEMI_PLANAR_ER = (cyruntime.cudaEglColorFormatY10V10U10_420SemiPlanar_ER, 'Extended Range Y10, V10U10 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height.') Y10V10U10_420_SEMI_PLANAR_709_ER = (cyruntime.cudaEglColorFormatY10V10U10_420SemiPlanar_709_ER, 'Extended Range Y10, V10U10 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height.') Y10V10U10_444_SEMI_PLANAR_ER = (cyruntime.cudaEglColorFormatY10V10U10_444SemiPlanar_ER, 'Extended Range Y10, V10U10 in two surfaces (VU as one surface) U/V width = Y width, U/V height = Y height.') Y10V10U10_444_SEMI_PLANAR_709_ER = (cyruntime.cudaEglColorFormatY10V10U10_444SemiPlanar_709_ER, 'Extended Range Y10, V10U10 in two surfaces (VU as one surface) U/V width = Y width, U/V height = Y height.') Y12V12U12_420_SEMI_PLANAR_ER = (cyruntime.cudaEglColorFormatY12V12U12_420SemiPlanar_ER, 'Extended Range Y12, V12U12 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height.') Y12V12U12_420_SEMI_PLANAR_709_ER = (cyruntime.cudaEglColorFormatY12V12U12_420SemiPlanar_709_ER, 'Extended Range Y12, V12U12 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height.') Y12V12U12_444_SEMI_PLANAR_ER = (cyruntime.cudaEglColorFormatY12V12U12_444SemiPlanar_ER, 'Extended Range Y12, V12U12 in two surfaces (VU as one surface) U/V width = Y width, U/V height = Y height.') Y12V12U12_444_SEMI_PLANAR_709_ER = (cyruntime.cudaEglColorFormatY12V12U12_444SemiPlanar_709_ER, 'Extended Range Y12, V12U12 in two surfaces (VU as one surface) U/V width = Y width, U/V height = Y height.') UYVY709 = (cyruntime.cudaEglColorFormatUYVY709, 'Y, U, V in one surface, interleaved as UYVY in one channel.') UYVY709_ER = (cyruntime.cudaEglColorFormatUYVY709_ER, 'Extended Range Y, U, V in one surface, interleaved as UYVY in one channel.') UYVY2020 = (cyruntime.cudaEglColorFormatUYVY2020, 'Y, U, V in one surface, interleaved as UYVY in one channel.') class GLDeviceList(_cyb_FastEnum): """ CUDA devices corresponding to the current OpenGL context See `cudaGLDeviceList`. """ ALL = (cyruntime.cudaGLDeviceListAll, 'The CUDA devices for all GPUs used by the current OpenGL context') CURRENT_FRAME = (cyruntime.cudaGLDeviceListCurrentFrame, 'The CUDA devices for the GPUs used by the current OpenGL context in its currently rendering frame') NEXT_FRAME = (cyruntime.cudaGLDeviceListNextFrame, 'The CUDA devices for the GPUs to be used by the current OpenGL context in the next frame') class GLMapFlags(_cyb_FastEnum): """ CUDA GL Map Flags See `cudaGLMapFlags`. """ NONE = (cyruntime.cudaGLMapFlagsNone, 'Default; Assume resource can be read/written') READ_ONLY = (cyruntime.cudaGLMapFlagsReadOnly, 'CUDA kernels will not write to this resource') WRITE_DISCARD = (cyruntime.cudaGLMapFlagsWriteDiscard, 'CUDA kernels will only write to and will not read from this resource') class AtomicOperation(_cyb_FastEnum): """ CUDA-valid Atomic Operations See `cudaAtomicOperation`. """ INTEGER_ADD = cyruntime.cudaAtomicOperationIntegerAdd INTEGER_MIN = cyruntime.cudaAtomicOperationIntegerMin INTEGER_MAX = cyruntime.cudaAtomicOperationIntegerMax INTEGER_INCREMENT = cyruntime.cudaAtomicOperationIntegerIncrement INTEGER_DECREMENT = cyruntime.cudaAtomicOperationIntegerDecrement AND = cyruntime.cudaAtomicOperationAnd OR = cyruntime.cudaAtomicOperationOr XOR = cyruntime.cudaAtomicOperationXOR EXCHANGE = cyruntime.cudaAtomicOperationExchange CAS = cyruntime.cudaAtomicOperationCAS FLOAT_ADD = cyruntime.cudaAtomicOperationFloatAdd FLOAT_MIN = cyruntime.cudaAtomicOperationFloatMin FLOAT_MAX = cyruntime.cudaAtomicOperationFloatMax class AtomicOperationCapability(_cyb_FastEnum): """ CUDA-valid Atomic Operation capabilities See `cudaAtomicOperationCapability`. """ SIGNED = cyruntime.cudaAtomicCapabilitySigned UNSIGNED = cyruntime.cudaAtomicCapabilityUnsigned REDUCTION = cyruntime.cudaAtomicCapabilityReduction SCALAR32 = cyruntime.cudaAtomicCapabilityScalar32 SCALAR64 = cyruntime.cudaAtomicCapabilityScalar64 SCALAR128 = cyruntime.cudaAtomicCapabilityScalar128 VECTOR32X4 = cyruntime.cudaAtomicCapabilityVector32x4 class LogLevel(_cyb_FastEnum): """ See `cudaLogLevel`. """ ERROR = cyruntime.cudaLogLevelError WARNING = cyruntime.cudaLogLevelWarning class EmulationStrategy(_cyb_FastEnum): """ Enum for specifying how to leverage floating-point emulation algorithms See `cudaEmulationStrategy`. """ DEFAULT = (cyruntime.CUDA_EMULATION_STRATEGY_DEFAULT, 'The default emulation strategy. For emulated computations, this is equivalent to CUDA_EMULATION_STRATEGY_PERFORMANT, unless a library dependent environment variable is set') PERFORMANT = (cyruntime.CUDA_EMULATION_STRATEGY_PERFORMANT, 'An emulation strategy which configures libraries to use emulation when it provides a performance benefit') EAGER = (cyruntime.CUDA_EMULATION_STRATEGY_EAGER, 'An emulation strategy which configures libraries to use emulation whenever possible') class EmulationMantissaControl(_cyb_FastEnum): """ Enum to configure the mantissa related parameters for floating-point emulation algorithms See `cudaEmulationMantissaControl`. """ DYNAMIC = (cyruntime.CUDA_EMULATION_MANTISSA_CONTROL_DYNAMIC, 'The number of retained mantissa bits are computed at runtime to ensure the same or better accuracy than the floating point representation being emulated') FIXED = (cyruntime.CUDA_EMULATION_MANTISSA_CONTROL_FIXED, 'The number of retained mantissa bits are known at runtime') class EmulationSpecialValuesSupport(_cyb_FastEnum): """ Enum to configure how special floating-point values will be handled by emulation algorithms See `cudaEmulationSpecialValuesSupport`. """ DEFAULT = (cyruntime.CUDA_EMULATION_SPECIAL_VALUES_SUPPORT_DEFAULT, 'The default special value support mask which contains support for signed infinities and NaN values') NONE = (cyruntime.CUDA_EMULATION_SPECIAL_VALUES_SUPPORT_NONE, 'There are no requirements for emulation algorithms to support special values') INFINITY = (cyruntime.CUDA_EMULATION_SPECIAL_VALUES_SUPPORT_INFINITY, 'Require emulation algorithms to handle signed infinity inputs and outputs') NAN = (cyruntime.CUDA_EMULATION_SPECIAL_VALUES_SUPPORT_NAN, 'Require emulation algorithms to handle NaN inputs and outputs') class DevSmResourceGroupFlags(_cyb_FastEnum): """ Flags for a CUdevSmResource group See `cudaDevSmResourceGroup_flags`. """ DEFAULT = cyruntime.cudaDevSmResourceGroupDefault BACKFILL = (cyruntime.cudaDevSmResourceGroupBackfill, 'Treats constraints as a hint, ignoring them if necessary to reach the requested smCount. Lets smCount be a non-multiple of coscheduledSmCount, filling the difference between SM count and already assigned co-scheduled groupings with other SMs. When used with cudaDevSmResourceGroupLocalityDomainId, backfill fills up to the requested smCount using the target locality domain first, then SMs not attributed to any locality domain, then SMs from other locality domains. If no SMs can be found in the requested locality domain, cudaErrorInvalidResourceConfiguration is returned. When used with `cudaDevSmResourceGroupLocalityDomainNonPortableId`, backfill follows the same behavior after first consuming all SMs from the target locality domain.') LOCALITY_DOMAIN_ID = (cyruntime.cudaDevSmResourceGroupLocalityDomainId, 'The SMs must be located on a specific locality domain, specified by localityDomainId') LOCALITY_DOMAIN_SUPPLEMENTAL_SMS = (cyruntime.cudaDevSmResourceGroupLocalityDomainSupplementalSms, 'Modifier to `cudaDevSmResourceGroupLocalityDomainId` which allows selection of SMs in the locality domain exceeding the ``cudaDeviceAttr.cudaDevAttrLocalityDomainMultiprocessorCount``.') class DevSmResourceSplitByCountFlags(_cyb_FastEnum): """ See `cudaDevSmResourceSplitByCount_flags`. """ IGNORE_SM_COSCHEDULING = cyruntime.cudaDevSmResourceSplitIgnoreSmCoscheduling MAX_POTENTIAL_CLUSTER_SIZE = cyruntime.cudaDevSmResourceSplitMaxPotentialClusterSize class DevResourceType(_cyb_FastEnum): """ Type of resource See `cudaDevResourceType`. """ INVALID = cyruntime.cudaDevResourceTypeInvalid SM = (cyruntime.cudaDevResourceTypeSm, 'Streaming multiprocessors related information') WORKQUEUE_CONFIG = (cyruntime.cudaDevResourceTypeWorkqueueConfig, 'Workqueue configuration related information') WORKQUEUE = (cyruntime.cudaDevResourceTypeWorkqueue, 'Pre-existing workqueue related information') class DevWorkqueueConfigScope(_cyb_FastEnum): """ Sharing scope for workqueues See `cudaDevWorkqueueConfigScope`. """ DEVICE_CTX = (cyruntime.cudaDevWorkqueueConfigScopeDeviceCtx, 'Use all shared workqueue resources on the device. Default driver behaviour.') GREEN_CTX_BALANCED = (cyruntime.cudaDevWorkqueueConfigScopeGreenCtxBalanced, 'When possible, use non-overlapping workqueue resources with other balanced green contexts.') class HostTaskSyncMode(_cyb_FastEnum): """ Flags for host task sync mode See `cudaHostTaskSyncMode`. """ BLOCKING = cyruntime.cudaHostTaskBlocking SPIN_WAIT = cyruntime.cudaHostTaskSpinWait class KernelFunctionType(_cyb_FastEnum): """ CUDA Kernel Function Handle Type See `cudaKernelFunctionType`. """ UNSPECIFIED = (cyruntime.cudaKernelFunctionTypeUnspecified, 'CUDA will attempt to deduce the type of the function handle') DEVICE_ENTRY = (cyruntime.cudaKernelFunctionTypeDeviceEntry, 'Function handle is a device-entry function pointer(i.e. global function pointer)') KERNEL = (cyruntime.cudaKernelFunctionTypeKernel, 'Function handle is a `cudaKernel_t`') FUNCTION = (cyruntime.cudaKernelFunctionTypeFunction, 'Function handle is a `cudaFunction_t`') class LaunchAttributePortableClusterMode(_cyb_FastEnum): """ Enum for defining applicability of portable cluster size, used with `cudaLaunchKernelEx` See `cudaLaunchAttributePortableClusterMode`. """ DEFAULT = (cyruntime.cudaLaunchPortableClusterModeDefault, 'The default to use for allowing non-portable cluster size on launch - uses current function attribute for `cudaFuncAttributeNonPortableClusterSizeAllowed`') REQUIRE_PORTABLE = (cyruntime.cudaLaunchPortableClusterModeRequirePortable, 'Specifies that the cluster size requested must be a portable size') ALLOW_NON_PORTABLE = (cyruntime.cudaLaunchPortableClusterModeAllowNonPortable, 'Specifies that the cluster size requested may be a non-portable size') class SharedMemoryMode(_cyb_FastEnum): """ Shared memory related attributes for use with `cuLaunchKernelEx` See `cudaSharedMemoryMode`. """ DEFAULT = (cyruntime.cudaSharedMemoryModeDefault, 'The default to use for allowing non-portable shared memory size on launch - uses current function attributes for `cudaFuncAttributeMaxDynamicSharedMemorySize`') REQUIRE_PORTABLE = (cyruntime.cudaSharedMemoryModeRequirePortable, 'Specifies that the shared memory size requested must be a portable size within `cudaDevAttrMaxSharedMemoryPerBlock`') ALLOW_NON_PORTABLE = (cyruntime.cudaSharedMemoryModeAllowNonPortable, 'Specifies that the shared memory size requested may be a non-portable size up to `cudaDevAttrMaxSharedMemoryPerBlockOptin`') ALLOW_OVERSIZED_SHARED_MEMORY = (cyruntime.cudaSharedMemoryModeAllowOversizedSharedMemory, 'Specifies that oversized shared memory configurations may be used (with the limitation of only 8kB L1 cache)') PREFER_OVERSIZED_SHARED_MEMORY = (cyruntime.cudaSharedMemoryModePreferOversizedSharedMemory, 'Specifies that oversized shared memory configurations may be used (with the limitation of only 8kB L1 cache), and prefer an oversized shared memory configuration') class GraphRecaptureStatus(_cyb_FastEnum): """ Possible recapture statuses that can be returned to the user callback See `cudaGraphRecaptureStatus`. """ ELIGIBLE_FOR_UPDATE = (cyruntime.cudaGraphRecaptureEligibleForUpdate, 'Node is eligible for update in an instantiated graph.') INELIGIBLE_FOR_UPDATE = (cyruntime.cudaGraphRecaptureIneligibleForUpdate, 'Parameter changes in the node cannot be applied to an instantiated graph.') ERROR = (cyruntime.cudaGraphRecaptureError, 'Error while attempting to recapture the node. The recapture will be ended regardless of the return value from the callback.') class FabricOpStatusSource(_cyb_FastEnum): """ Fabric operation status source See `cudaFabricOpStatusSource`. """ MBARRIER_V1 = (cyruntime.cudaFabricOpStatusSourceMbarrierV1, '1B-aligned 1B-wide status from an mbarrier.layout::v1') MAX = cyruntime.cudaFabricOpStatusSourceMax class FabricOpStatusInfo(_cyb_FastEnum): """ Fabric operation status info See `cudaFabricOpStatusInfo`. """ SUCCESS = cyruntime.cudaFabricOpStatusInfoSuccess LAST = cyruntime.cudaFabricOpStatusInfoLast MAX = cyruntime.cudaFabricOpStatusInfoMax ############################################################################### # Enums for C preprocessor constants (`#define`), grouped by what they are used for. # The values are taken from the C constants, so they track the CTK header. ############################################################################### class ArrayFlags(_FastEnum): """Flags for `malloc_array`, `malloc_3d_array` and `malloc_mipmapped_array` (`cudaArray*`).""" DEFAULT = (cyruntime.cudaArrayDefault, 'Default CUDA array allocation flag') LAYERED = (cyruntime.cudaArrayLayered, 'Must be set in cudaMalloc3DArray to create a layered CUDA array') SURFACE_LOAD_STORE = (cyruntime.cudaArraySurfaceLoadStore, 'Must be set in cudaMallocArray or cudaMalloc3DArray in order to bind surfaces to the CUDA array') CUBEMAP = (cyruntime.cudaArrayCubemap, 'Must be set in cudaMalloc3DArray to create a cubemap CUDA array') TEXTURE_GATHER = (cyruntime.cudaArrayTextureGather, 'Must be set in cudaMallocArray or cudaMalloc3DArray in order to perform texture gather operations on the CUDA array') COLOR_ATTACHMENT = (cyruntime.cudaArrayColorAttachment, 'Must be set in cudaExternalMemoryGetMappedMipmappedArray if the mipmapped array is used as a color target in a graphics API') SPARSE = (cyruntime.cudaArraySparse, 'Must be set in cudaMallocArray, cudaMalloc3DArray or cudaMallocMipmappedArray in order to create a sparse CUDA array or CUDA mipmapped array') DEFERRED_MAPPING = (cyruntime.cudaArrayDeferredMapping, 'Must be set in cudaMallocArray, cudaMalloc3DArray or cudaMallocMipmappedArray in order to create a deferred mapping CUDA array or CUDA mipmapped array') class ArraySparsePropertiesFlags(_FastEnum): """Flags in `ArraySparseProperties.flags_` (`cudaArraySparseProperties*`).""" SINGLE_MIP_TAIL = (cyruntime.cudaArraySparsePropertiesSingleMipTail, 'Indicates that the layered sparse CUDA array or CUDA mipmapped array has a single mip tail region for all layers') class DeviceFlags(_FastEnum): """Flags for `set_device_flags` and `init_device` (`cudaDevice*`).""" SCHEDULE_AUTO = (cyruntime.cudaDeviceScheduleAuto, 'Device flag - Automatic scheduling') SCHEDULE_SPIN = (cyruntime.cudaDeviceScheduleSpin, 'Device flag - Spin default scheduling') SCHEDULE_YIELD = (cyruntime.cudaDeviceScheduleYield, 'Device flag - Yield default scheduling') SCHEDULE_BLOCKING_SYNC = (cyruntime.cudaDeviceScheduleBlockingSync, 'Device flag - Use blocking synchronization') BLOCKING_SYNC = (cyruntime.cudaDeviceBlockingSync, 'Device flag - Use blocking synchronization. Deprecated: use SCHEDULE_BLOCKING_SYNC') SCHEDULE_MASK = (cyruntime.cudaDeviceScheduleMask, 'Device schedule flags mask') MAP_HOST = (cyruntime.cudaDeviceMapHost, 'Device flag - Support mapped pinned allocations') LMEM_RESIZE_TO_MAX = (cyruntime.cudaDeviceLmemResizeToMax, 'Device flag - Keep local memory allocation after launch') SYNC_MEMOPS = (cyruntime.cudaDeviceSyncMemops, 'Device flag - Ensure synchronous memory operations on this context will synchronize') MASK = (cyruntime.cudaDeviceMask, 'Device flags mask') class InitDeviceFlags(_FastEnum): """Flags for `init_device` (`cudaInitDevice*`).""" FLAGS_ARE_VALID = (cyruntime.cudaInitDeviceFlagsAreValid, 'Tell the CUDA runtime that DeviceFlags is being set in cudaInitDevice call') class SpecialDevice(_FastEnum): """Special `int` device ordinals (`cuda*DeviceId`).""" CPU = (cyruntime.cudaCpuDeviceId, 'Device id that represents the CPU') INVALID = (cyruntime.cudaInvalidDeviceId, 'Device id that represents an invalid device') class EventFlags(_FastEnum): """Flags for `event_create_with_flags` (`cudaEvent*`).""" DEFAULT = (cyruntime.cudaEventDefault, 'Default event flag') BLOCKING_SYNC = (cyruntime.cudaEventBlockingSync, 'Event uses blocking synchronization') DISABLE_TIMING = (cyruntime.cudaEventDisableTiming, 'Event will not record timing data') INTERPROCESS = (cyruntime.cudaEventInterprocess, 'Event is suitable for interprocess use. cudaEventDisableTiming must be set') class EventRecordFlags(_FastEnum): """Flags for `event_record_with_flags` (`cudaEventRecord*`).""" DEFAULT = (cyruntime.cudaEventRecordDefault, 'Default event record flag') EXTERNAL = (cyruntime.cudaEventRecordExternal, 'Event is captured in the graph as an external event node when performing stream capture') class EventWaitFlags(_FastEnum): """Flags for `stream_wait_event` (`cudaEventWait*`).""" DEFAULT = (cyruntime.cudaEventWaitDefault, 'Default event wait flag') EXTERNAL = (cyruntime.cudaEventWaitExternal, 'Event is captured in the graph as an external event node when performing stream capture') class StreamFlags(_FastEnum): """Flags for `stream_create_with_flags` (`cudaStream*`).""" DEFAULT = (cyruntime.cudaStreamDefault, 'Default stream flag') NON_BLOCKING = (cyruntime.cudaStreamNonBlocking, 'Stream does not synchronize with stream 0 (the NULL stream)') class SpecialStream(_FastEnum): """Special streams, passed as a stream handle (`cudaStream*`).""" LEGACY = (cyruntime.cudaStreamLegacy, 'Legacy stream handle. Stream handle that can be passed as a cudaStream_t to use an implicit stream with legacy synchronization behavior.') PER_THREAD = (cyruntime.cudaStreamPerThread, 'Per-thread stream handle. Stream handle that can be passed as a cudaStream_t to use an implicit stream with per-thread synchronization behavior.') class HostAllocFlags(_FastEnum): """Flags for `host_alloc` (`cudaHostAlloc*`).""" DEFAULT = (cyruntime.cudaHostAllocDefault, 'Default page-locked allocation flag') PORTABLE = (cyruntime.cudaHostAllocPortable, 'Pinned memory accessible by all CUDA contexts') MAPPED = (cyruntime.cudaHostAllocMapped, 'Map allocation into device space') WRITE_COMBINED = (cyruntime.cudaHostAllocWriteCombined, 'Write-combined memory') class HostRegisterFlags(_FastEnum): """Flags for `host_register` (`cudaHostRegister*`).""" DEFAULT = (cyruntime.cudaHostRegisterDefault, 'Default host memory registration flag') PORTABLE = (cyruntime.cudaHostRegisterPortable, 'Pinned memory accessible by all CUDA contexts') MAPPED = (cyruntime.cudaHostRegisterMapped, 'Map registered memory into device space') IO_MEMORY = (cyruntime.cudaHostRegisterIoMemory, 'Memory-mapped I/O space') READ_ONLY = (cyruntime.cudaHostRegisterReadOnly, 'Memory-mapped read-only') class PeerAccessFlags(_FastEnum): """Flags for `device_enable_peer_access` (`cudaPeerAccess*`).""" DEFAULT = (cyruntime.cudaPeerAccessDefault, 'Default peer addressing enable flag') class IpcMemFlags(_FastEnum): """Flags for `ipc_open_mem_handle` (`cudaIpcMem*`).""" LAZY_ENABLE_PEER_ACCESS = (cyruntime.cudaIpcMemLazyEnablePeerAccess, 'Automatically enable peer access between remote devices as needed') class MemAttachFlags(_FastEnum): """Flags for `malloc_managed` and `stream_attach_mem_async` (`cudaMemAttach*`).""" GLOBAL = (cyruntime.cudaMemAttachGlobal, 'Memory can be accessed by any stream on any device') HOST = (cyruntime.cudaMemAttachHost, 'Memory cannot be accessed by any stream on any device') SINGLE = (cyruntime.cudaMemAttachSingle, 'Memory can only be accessed by a single stream on the associated device') class MemPoolCreateUsage(_FastEnum): """Usage hints for `MemPoolProps.usage` (`cudaMemPoolCreateUsage*`).""" HW_DECOMPRESS = (cyruntime.cudaMemPoolCreateUsageHwDecompress, 'This flag, if set, indicates that the memory will be used as a buffer for hardware accelerated decompression.') class OccupancyFlags(_FastEnum): """Flags for `occupancy_max_active_blocks_per_multiprocessor_with_flags` (`cudaOccupancy*`).""" DEFAULT = (cyruntime.cudaOccupancyDefault, 'Default behavior') DISABLE_CACHING_OVERRIDE = (cyruntime.cudaOccupancyDisableCachingOverride, 'Assume global caching is enabled and cannot be automatically turned off') class ExternalMemoryFlags(_FastEnum): """Flags for `ExternalMemoryHandleDesc.flags_` (`cudaExternalMemory*`).""" DEDICATED = (cyruntime.cudaExternalMemoryDedicated, 'Indicates that the external memory object is a dedicated resource') class ExternalSemaphoreSignalFlags(_FastEnum): """Flags for `ExternalSemaphoreSignalParams.flags_` (`cudaExternalSemaphoreSignal*`).""" SKIP_NVSCIBUF_MEMSYNC = (cyruntime.cudaExternalSemaphoreSignalSkipNvSciBufMemSync, 'Indicates that signaling an external semaphore object should skip performing appropriate memory synchronization operations over all the external memory objects that are imported as cudaExternalMemoryHandleTypeNvSciBuf, which otherwise are performed by default to ensure data coherency with other importers of the same NvSciBuf memory objects.') class ExternalSemaphoreWaitFlags(_FastEnum): """Flags for `ExternalSemaphoreWaitParams.flags_` (`cudaExternalSemaphoreWait*`).""" SKIP_NVSCIBUF_MEMSYNC = (cyruntime.cudaExternalSemaphoreWaitSkipNvSciBufMemSync, 'Indicates that waiting on an external semaphore object should skip performing appropriate memory synchronization operations over all the external memory objects that are imported as cudaExternalMemoryHandleTypeNvSciBuf, which otherwise are performed by default to ensure data coherency with other importers of the same NvSciBuf memory objects.') class NvSciSyncAttr(_FastEnum): """NvSciSync attribute directions (`cudaNvSciSyncAttr*`).""" SIGNAL = (cyruntime.cudaNvSciSyncAttrSignal, 'When flags of cudaDeviceGetNvSciSyncAttributes is set to this, it indicates that application needs signaler specific NvSciSyncAttr to be filled by cudaDeviceGetNvSciSyncAttributes.') WAIT = (cyruntime.cudaNvSciSyncAttrWait, 'When flags of cudaDeviceGetNvSciSyncAttributes is set to this, it indicates that application needs waiter specific NvSciSyncAttr to be filled by cudaDeviceGetNvSciSyncAttributes.') class GraphKernelNodePort(_FastEnum): """Outgoing ports of a kernel node, for `GraphEdgeData.from_port` (`cudaGraphKernelNodePort*`).""" DEFAULT = (cyruntime.cudaGraphKernelNodePortDefault, 'This port activates when the kernel has finished executing.') PROGRAMMATIC = (cyruntime.cudaGraphKernelNodePortProgrammatic, 'This port activates when all blocks of the kernel have performed cudaTriggerProgrammaticLaunchCompletion() or have terminated. It must be used with edge type cudaGraphDependencyTypeProgrammatic. See also cudaLaunchAttributeProgrammaticEvent.') LAUNCH_COMPLETION = (cyruntime.cudaGraphKernelNodePortLaunchCompletion, 'This port activates when all blocks of the kernel have begun execution. See also cudaLaunchAttributeLaunchCompletionEvent.') class SurfaceType(_FastEnum): """Surface types, for `ResourceDesc` surfaces (`cudaSurfaceType*`).""" TYPE_1D = (cyruntime.cudaSurfaceType1D, '1D surface') TYPE_2D = (cyruntime.cudaSurfaceType2D, '2D surface') TYPE_3D = (cyruntime.cudaSurfaceType3D, '3D surface') CUBEMAP = (cyruntime.cudaSurfaceTypeCubemap, 'Cubemap surface') TYPE_1D_LAYERED = (cyruntime.cudaSurfaceType1DLayered, '1D layered surface') TYPE_2D_LAYERED = (cyruntime.cudaSurfaceType2DLayered, '2D layered surface') CUBEMAP_LAYERED = (cyruntime.cudaSurfaceTypeCubemapLayered, 'Cubemap layered surface') class TextureType(_FastEnum): """Texture types (`cudaTextureType*`).""" TYPE_1D = (cyruntime.cudaTextureType1D, '1D texture') TYPE_2D = (cyruntime.cudaTextureType2D, '2D texture') TYPE_3D = (cyruntime.cudaTextureType3D, '3D texture') CUBEMAP = (cyruntime.cudaTextureTypeCubemap, 'Cubemap texture') TYPE_1D_LAYERED = (cyruntime.cudaTextureType1DLayered, '1D layered texture') TYPE_2D_LAYERED = (cyruntime.cudaTextureType2DLayered, '2D layered texture') CUBEMAP_LAYERED = (cyruntime.cudaTextureTypeCubemapLayered, 'Cubemap layered texture') # `cdef enum` constants of cyruntime are C-level and non-lvalues, so the Python module # attributes are injected through globals(). globals()['CUDART_VERSION'] = cyruntime.CUDART_VERSION globals()['CUDA_IPC_HANDLE_SIZE'] = cyruntime.CUDA_IPC_HANDLE_SIZE globals()['CUDA_EGL_MAX_PLANES'] = cyruntime.CUDA_EGL_MAX_PLANES globals()['DEV_SM_RESOURCE_GROUP_LOCALITY_DOMAIN_ID_ANY'] = cyruntime.cudaDevSmResourceGroupLocalityDomainIdAny ############################################################################### # Error handling ############################################################################### class CudaError(Exception): def __init__(self, status): self.status = status cdef str err try: s = Error(status) err = f"{s.name} ({s.value})" except ValueError: err = f"Unknown error ({status})" super(CudaError, self).__init__(err) def __reduce__(self): return (type(self), (self.status,)) class InvalidValueError(CudaError): pass class MemoryAllocationError(CudaError): pass class InitializationError(CudaError): pass class CudartUnloadingError(CudaError): pass class ProfilerDisabledError(CudaError): pass class ProfilerNotInitializedError(CudaError): pass class ProfilerAlreadyStartedError(CudaError): pass class ProfilerAlreadyStoppedError(CudaError): pass class InvalidConfigurationError(CudaError): pass class VersionTranslationError(CudaError): pass class InvalidPitchValueError(CudaError): pass class InvalidSymbolError(CudaError): pass class InvalidHostPointerError(CudaError): pass class InvalidDevicePointerError(CudaError): pass class InvalidTextureError(CudaError): pass class InvalidTextureBindingError(CudaError): pass class InvalidChannelDescriptorError(CudaError): pass class InvalidMemcpyDirectionError(CudaError): pass class AddressOfConstantError(CudaError): pass class TextureFetchFailedError(CudaError): pass class TextureNotBoundError(CudaError): pass class SynchronizationError(CudaError): pass class InvalidFilterSettingError(CudaError): pass class InvalidNormSettingError(CudaError): pass class MixedDeviceExecutionError(CudaError): pass class NotYetImplementedError(CudaError): pass class MemoryValueTooLargeError(CudaError): pass class StubLibraryError(CudaError): pass class InsufficientDriverError(CudaError): pass class CallRequiresNewerDriverError(CudaError): pass class InvalidSurfaceError(CudaError): pass class DuplicateVariableNameError(CudaError): pass class DuplicateTextureNameError(CudaError): pass class DuplicateSurfaceNameError(CudaError): pass class DevicesUnavailableError(CudaError): pass class IncompatibleDriverContextError(CudaError): pass class MissingConfigurationError(CudaError): pass class PriorLaunchFailureError(CudaError): pass class LaunchMaxDepthExceededError(CudaError): pass class LaunchFileScopedTexError(CudaError): pass class LaunchFileScopedSurfError(CudaError): pass class SyncDepthExceededError(CudaError): pass class LaunchPendingCountExceededError(CudaError): pass class InvalidDeviceFunctionError(CudaError): pass class NoDeviceError(CudaError): pass class InvalidDeviceError(CudaError): pass class DeviceNotLicensedError(CudaError): pass class SoftwareValidityNotEstablishedError(CudaError): pass class StartupFailureError(CudaError): pass class InvalidKernelImageError(CudaError): pass class DeviceUninitializedError(CudaError): pass class MapBufferObjectFailedError(CudaError): pass class UnmapBufferObjectFailedError(CudaError): pass class ArrayIsMappedError(CudaError): pass class AlreadyMappedError(CudaError): pass class NoKernelImageForDeviceError(CudaError): pass class AlreadyAcquiredError(CudaError): pass class NotMappedError(CudaError): pass class NotMappedAsArrayError(CudaError): pass class NotMappedAsPointerError(CudaError): pass class EccUncorrectableError(CudaError): pass class UnsupportedLimitError(CudaError): pass class DeviceAlreadyInUseError(CudaError): pass class PeerAccessUnsupportedError(CudaError): pass class InvalidPtxError(CudaError): pass class InvalidGraphicsContextError(CudaError): pass class NvlinkUncorrectableError(CudaError): pass class JitCompilerNotFoundError(CudaError): pass class UnsupportedPtxVersionError(CudaError): pass class JitCompilationDisabledError(CudaError): pass class UnsupportedExecAffinityError(CudaError): pass class UnsupportedDevSideSyncError(CudaError): pass class ContainedError(CudaError): pass class InsufficientLoaderVersionError(CudaError): pass class InvalidSourceError(CudaError): pass class CudaFileNotFoundError(CudaError): pass class SharedObjectSymbolNotFoundError(CudaError): pass class SharedObjectInitFailedError(CudaError): pass class OperatingSystemError(CudaError): pass class InvalidResourceHandleError(CudaError): pass class IllegalStateError(CudaError): pass class LossyQueryError(CudaError): pass class SymbolNotFoundError(CudaError): pass class NotReadyError(CudaError): pass class IllegalAddressError(CudaError): pass class LaunchOutOfResourcesError(CudaError): pass class LaunchTimeoutError(CudaError): pass class LaunchIncompatibleTexturingError(CudaError): pass class PeerAccessAlreadyEnabledError(CudaError): pass class PeerAccessNotEnabledError(CudaError): pass class SetOnActiveProcessError(CudaError): pass class ContextIsDestroyedError(CudaError): pass class AssertError(CudaError): pass class TooManyPeersError(CudaError): pass class HostMemoryAlreadyRegisteredError(CudaError): pass class HostMemoryNotRegisteredError(CudaError): pass class HardwareStackError(CudaError): pass class IllegalInstructionError(CudaError): pass class MisalignedAddressError(CudaError): pass class InvalidAddressSpaceError(CudaError): pass class InvalidPcError(CudaError): pass class LaunchFailureError(CudaError): pass class CooperativeLaunchTooLargeError(CudaError): pass class TensorMemoryLeakError(CudaError): pass class NotPermittedError(CudaError): pass class NotSupportedError(CudaError): pass class SystemNotReadyError(CudaError): pass class SystemDriverMismatchError(CudaError): pass class CompatNotSupportedOnDeviceError(CudaError): pass class MpsConnectionFailedError(CudaError): pass class MpsRpcFailureError(CudaError): pass class MpsServerNotReadyError(CudaError): pass class MpsMaxClientsReachedError(CudaError): pass class MpsMaxConnectionsReachedError(CudaError): pass class MpsClientTerminatedError(CudaError): pass class CdpNotSupportedError(CudaError): pass class CdpVersionMismatchError(CudaError): pass class StreamCaptureUnsupportedError(CudaError): pass class StreamCaptureInvalidatedError(CudaError): pass class StreamCaptureMergeError(CudaError): pass class StreamCaptureUnmatchedError(CudaError): pass class StreamCaptureUnjoinedError(CudaError): pass class StreamCaptureIsolationError(CudaError): pass class StreamCaptureImplicitError(CudaError): pass class CapturedEventError(CudaError): pass class StreamCaptureWrongThreadError(CudaError): pass class CudaTimeoutError(CudaError): pass class GraphExecUpdateFailureError(CudaError): pass class ExternalDeviceError(CudaError): pass class InvalidClusterSizeError(CudaError): pass class FunctionNotLoadedError(CudaError): pass class InvalidResourceTypeError(CudaError): pass class InvalidResourceConfigurationError(CudaError): pass class StreamDetachedError(CudaError): pass class GraphRecaptureFailureError(CudaError): pass class FabricNotReadyError(CudaError): pass class UnknownError(CudaError): pass class ApiFailureBaseError(CudaError): pass cdef object _runtime_error_factory(int status): cdef object pystatus = status if status == 1: return InvalidValueError(pystatus) elif status == 2: return MemoryAllocationError(pystatus) elif status == 3: return InitializationError(pystatus) elif status == 4: return CudartUnloadingError(pystatus) elif status == 5: return ProfilerDisabledError(pystatus) elif status == 6: return ProfilerNotInitializedError(pystatus) elif status == 7: return ProfilerAlreadyStartedError(pystatus) elif status == 8: return ProfilerAlreadyStoppedError(pystatus) elif status == 9: return InvalidConfigurationError(pystatus) elif status == 10: return VersionTranslationError(pystatus) elif status == 12: return InvalidPitchValueError(pystatus) elif status == 13: return InvalidSymbolError(pystatus) elif status == 16: return InvalidHostPointerError(pystatus) elif status == 17: return InvalidDevicePointerError(pystatus) elif status == 18: return InvalidTextureError(pystatus) elif status == 19: return InvalidTextureBindingError(pystatus) elif status == 20: return InvalidChannelDescriptorError(pystatus) elif status == 21: return InvalidMemcpyDirectionError(pystatus) elif status == 22: return AddressOfConstantError(pystatus) elif status == 23: return TextureFetchFailedError(pystatus) elif status == 24: return TextureNotBoundError(pystatus) elif status == 25: return SynchronizationError(pystatus) elif status == 26: return InvalidFilterSettingError(pystatus) elif status == 27: return InvalidNormSettingError(pystatus) elif status == 28: return MixedDeviceExecutionError(pystatus) elif status == 31: return NotYetImplementedError(pystatus) elif status == 32: return MemoryValueTooLargeError(pystatus) elif status == 34: return StubLibraryError(pystatus) elif status == 35: return InsufficientDriverError(pystatus) elif status == 36: return CallRequiresNewerDriverError(pystatus) elif status == 37: return InvalidSurfaceError(pystatus) elif status == 43: return DuplicateVariableNameError(pystatus) elif status == 44: return DuplicateTextureNameError(pystatus) elif status == 45: return DuplicateSurfaceNameError(pystatus) elif status == 46: return DevicesUnavailableError(pystatus) elif status == 49: return IncompatibleDriverContextError(pystatus) elif status == 52: return MissingConfigurationError(pystatus) elif status == 53: return PriorLaunchFailureError(pystatus) elif status == 65: return LaunchMaxDepthExceededError(pystatus) elif status == 66: return LaunchFileScopedTexError(pystatus) elif status == 67: return LaunchFileScopedSurfError(pystatus) elif status == 68: return SyncDepthExceededError(pystatus) elif status == 69: return LaunchPendingCountExceededError(pystatus) elif status == 98: return InvalidDeviceFunctionError(pystatus) elif status == 100: return NoDeviceError(pystatus) elif status == 101: return InvalidDeviceError(pystatus) elif status == 102: return DeviceNotLicensedError(pystatus) elif status == 103: return SoftwareValidityNotEstablishedError(pystatus) elif status == 127: return StartupFailureError(pystatus) elif status == 200: return InvalidKernelImageError(pystatus) elif status == 201: return DeviceUninitializedError(pystatus) elif status == 205: return MapBufferObjectFailedError(pystatus) elif status == 206: return UnmapBufferObjectFailedError(pystatus) elif status == 207: return ArrayIsMappedError(pystatus) elif status == 208: return AlreadyMappedError(pystatus) elif status == 209: return NoKernelImageForDeviceError(pystatus) elif status == 210: return AlreadyAcquiredError(pystatus) elif status == 211: return NotMappedError(pystatus) elif status == 212: return NotMappedAsArrayError(pystatus) elif status == 213: return NotMappedAsPointerError(pystatus) elif status == 214: return EccUncorrectableError(pystatus) elif status == 215: return UnsupportedLimitError(pystatus) elif status == 216: return DeviceAlreadyInUseError(pystatus) elif status == 217: return PeerAccessUnsupportedError(pystatus) elif status == 218: return InvalidPtxError(pystatus) elif status == 219: return InvalidGraphicsContextError(pystatus) elif status == 220: return NvlinkUncorrectableError(pystatus) elif status == 221: return JitCompilerNotFoundError(pystatus) elif status == 222: return UnsupportedPtxVersionError(pystatus) elif status == 223: return JitCompilationDisabledError(pystatus) elif status == 224: return UnsupportedExecAffinityError(pystatus) elif status == 225: return UnsupportedDevSideSyncError(pystatus) elif status == 226: return ContainedError(pystatus) elif status == 227: return InsufficientLoaderVersionError(pystatus) elif status == 300: return InvalidSourceError(pystatus) elif status == 301: return CudaFileNotFoundError(pystatus) elif status == 302: return SharedObjectSymbolNotFoundError(pystatus) elif status == 303: return SharedObjectInitFailedError(pystatus) elif status == 304: return OperatingSystemError(pystatus) elif status == 400: return InvalidResourceHandleError(pystatus) elif status == 401: return IllegalStateError(pystatus) elif status == 402: return LossyQueryError(pystatus) elif status == 500: return SymbolNotFoundError(pystatus) elif status == 600: return NotReadyError(pystatus) elif status == 700: return IllegalAddressError(pystatus) elif status == 701: return LaunchOutOfResourcesError(pystatus) elif status == 702: return LaunchTimeoutError(pystatus) elif status == 703: return LaunchIncompatibleTexturingError(pystatus) elif status == 704: return PeerAccessAlreadyEnabledError(pystatus) elif status == 705: return PeerAccessNotEnabledError(pystatus) elif status == 708: return SetOnActiveProcessError(pystatus) elif status == 709: return ContextIsDestroyedError(pystatus) elif status == 710: return AssertError(pystatus) elif status == 711: return TooManyPeersError(pystatus) elif status == 712: return HostMemoryAlreadyRegisteredError(pystatus) elif status == 713: return HostMemoryNotRegisteredError(pystatus) elif status == 714: return HardwareStackError(pystatus) elif status == 715: return IllegalInstructionError(pystatus) elif status == 716: return MisalignedAddressError(pystatus) elif status == 717: return InvalidAddressSpaceError(pystatus) elif status == 718: return InvalidPcError(pystatus) elif status == 719: return LaunchFailureError(pystatus) elif status == 720: return CooperativeLaunchTooLargeError(pystatus) elif status == 721: return TensorMemoryLeakError(pystatus) elif status == 800: return NotPermittedError(pystatus) elif status == 801: return NotSupportedError(pystatus) elif status == 802: return SystemNotReadyError(pystatus) elif status == 803: return SystemDriverMismatchError(pystatus) elif status == 804: return CompatNotSupportedOnDeviceError(pystatus) elif status == 805: return MpsConnectionFailedError(pystatus) elif status == 806: return MpsRpcFailureError(pystatus) elif status == 807: return MpsServerNotReadyError(pystatus) elif status == 808: return MpsMaxClientsReachedError(pystatus) elif status == 809: return MpsMaxConnectionsReachedError(pystatus) elif status == 810: return MpsClientTerminatedError(pystatus) elif status == 811: return CdpNotSupportedError(pystatus) elif status == 812: return CdpVersionMismatchError(pystatus) elif status == 900: return StreamCaptureUnsupportedError(pystatus) elif status == 901: return StreamCaptureInvalidatedError(pystatus) elif status == 902: return StreamCaptureMergeError(pystatus) elif status == 903: return StreamCaptureUnmatchedError(pystatus) elif status == 904: return StreamCaptureUnjoinedError(pystatus) elif status == 905: return StreamCaptureIsolationError(pystatus) elif status == 906: return StreamCaptureImplicitError(pystatus) elif status == 907: return CapturedEventError(pystatus) elif status == 908: return StreamCaptureWrongThreadError(pystatus) elif status == 909: return CudaTimeoutError(pystatus) elif status == 910: return GraphExecUpdateFailureError(pystatus) elif status == 911: return ExternalDeviceError(pystatus) elif status == 912: return InvalidClusterSizeError(pystatus) elif status == 913: return FunctionNotLoadedError(pystatus) elif status == 914: return InvalidResourceTypeError(pystatus) elif status == 915: return InvalidResourceConfigurationError(pystatus) elif status == 917: return StreamDetachedError(pystatus) elif status == 918: return GraphRecaptureFailureError(pystatus) elif status == 919: return FabricNotReadyError(pystatus) elif status == 999: return UnknownError(pystatus) elif status == 10000: return ApiFailureBaseError(pystatus) return CudaError(status) @cython.profile(False) cdef int check_status(int status) except 1 nogil: if status != 0: with gil: raise _runtime_error_factory(status) return status @cython.profile(False) cdef int check_status_size(int status) except 1 nogil: return check_status(status) ############################################################################### # POD definitions ############################################################################### cdef _get_dim3_dtype_offsets(): cdef dim3 *pod = _cyb_calloc(1, sizeof(dim3)) if pod == NULL: raise MemoryError("Error allocating dim3") try: return _numpy.dtype({ 'names': ['x', 'y', 'z'], 'formats': [_numpy.uint32, _numpy.uint32, _numpy.uint32], 'offsets': [ (&(pod.x)) - (pod), (&(pod.y)) - (pod), (&(pod.z)) - (pod), ], 'itemsize': sizeof(dim3), }) finally: _cyb_free(pod) dim3_dtype = _get_dim3_dtype_offsets() cdef class Dim3: """Empty-initialize an instance of `dim3`. .. seealso:: `dim3` """ cdef: dim3 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(dim3)) if self._ptr == NULL: raise MemoryError("Error allocating Dim3") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef dim3 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.Dim3 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef Dim3 other_ if not isinstance(other, Dim3): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(dim3)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(dim3), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This Dim3 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(dim3): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(dim3), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(dim3)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def x(self): """int: """ return self._ptr[0].x @x.setter def x(self, val): if self._readonly: raise ValueError("This Dim3 instance is read-only") self._ptr[0].x = val @property def y(self): """int: """ return self._ptr[0].y @y.setter def y(self, val): if self._readonly: raise ValueError("This Dim3 instance is read-only") self._ptr[0].y = val @property def z(self): """int: """ return self._ptr[0].z @z.setter def z(self, val): if self._readonly: raise ValueError("This Dim3 instance is read-only") self._ptr[0].z = val @staticmethod def from_buffer(buffer): """Create an Dim3 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(dim3), Dim3) @staticmethod def from_data(data): """Create an Dim3 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `dim3_dtype` holding the data. """ return _cyb_from_data(data, "dim3_dtype", dim3_dtype, Dim3) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an Dim3 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef Dim3 obj = Dim3.__new__(Dim3) if owner is None: obj._ptr = _cyb_malloc(sizeof(dim3)) if obj._ptr == NULL: raise MemoryError("Error allocating Dim3") _cyb_memcpy((obj._ptr), ptr, sizeof(dim3)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_channel_format_desc_dtype_offsets(): cdef cudaChannelFormatDesc *pod = _cyb_calloc(1, sizeof(cudaChannelFormatDesc)) if pod == NULL: raise MemoryError("Error allocating cudaChannelFormatDesc") try: return _numpy.dtype({ 'names': ['x', 'y', 'z', 'w', 'f'], 'formats': [_numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32], 'offsets': [ (&(pod.x)) - (pod), (&(pod.y)) - (pod), (&(pod.z)) - (pod), (&(pod.w)) - (pod), (&(pod.f)) - (pod), ], 'itemsize': sizeof(cudaChannelFormatDesc), }) finally: _cyb_free(pod) channel_format_desc_dtype = _get_channel_format_desc_dtype_offsets() cdef class ChannelFormatDesc: """Empty-initialize an instance of `cudaChannelFormatDesc`. .. seealso:: `cudaChannelFormatDesc` """ cdef: cudaChannelFormatDesc *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cudaChannelFormatDesc)) if self._ptr == NULL: raise MemoryError("Error allocating ChannelFormatDesc") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cudaChannelFormatDesc *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.ChannelFormatDesc object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef ChannelFormatDesc other_ if not isinstance(other, ChannelFormatDesc): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaChannelFormatDesc)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaChannelFormatDesc), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This ChannelFormatDesc instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaChannelFormatDesc): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaChannelFormatDesc), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cudaChannelFormatDesc)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def x(self): """int: x""" return self._ptr[0].x @x.setter def x(self, val): if self._readonly: raise ValueError("This ChannelFormatDesc instance is read-only") self._ptr[0].x = val @property def y(self): """int: y""" return self._ptr[0].y @y.setter def y(self, val): if self._readonly: raise ValueError("This ChannelFormatDesc instance is read-only") self._ptr[0].y = val @property def z(self): """int: z""" return self._ptr[0].z @z.setter def z(self, val): if self._readonly: raise ValueError("This ChannelFormatDesc instance is read-only") self._ptr[0].z = val @property def w(self): """int: w""" return self._ptr[0].w @w.setter def w(self, val): if self._readonly: raise ValueError("This ChannelFormatDesc instance is read-only") self._ptr[0].w = val @property def f(self): """int: Channel format kind""" return (self._ptr[0].f) @f.setter def f(self, val): if self._readonly: raise ValueError("This ChannelFormatDesc instance is read-only") self._ptr[0].f = val @staticmethod def from_buffer(buffer): """Create an ChannelFormatDesc instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaChannelFormatDesc), ChannelFormatDesc) @staticmethod def from_data(data): """Create an ChannelFormatDesc instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `channel_format_desc_dtype` holding the data. """ return _cyb_from_data(data, "channel_format_desc_dtype", channel_format_desc_dtype, ChannelFormatDesc) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an ChannelFormatDesc instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef ChannelFormatDesc obj = ChannelFormatDesc.__new__(ChannelFormatDesc) if owner is None: obj._ptr = _cyb_malloc(sizeof(cudaChannelFormatDesc)) if obj._ptr == NULL: raise MemoryError("Error allocating ChannelFormatDesc") _cyb_memcpy((obj._ptr), ptr, sizeof(cudaChannelFormatDesc)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod0_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod0 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod0)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod0") try: return _numpy.dtype({ 'names': ['width', 'height', 'depth'], 'formats': [_numpy.uint32, _numpy.uint32, _numpy.uint32], 'offsets': [ (&(pod.width)) - (pod), (&(pod.height)) - (pod), (&(pod.depth)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod0), }) finally: _cyb_free(pod) _py_anon_pod0_dtype = _get__py_anon_pod0_dtype_offsets() cdef class _py_anon_pod0: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod0`. .. seealso:: `cuda_bindings_runtime__anon_pod0` """ cdef: cuda_bindings_runtime__anon_pod0 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod0)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod0") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod0 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod0 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod0 other_ if not isinstance(other, _py_anon_pod0): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod0)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod0), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod0 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod0): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod0), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod0)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def width(self): """int: """ return self._ptr[0].width @width.setter def width(self, val): if self._readonly: raise ValueError("This _py_anon_pod0 instance is read-only") self._ptr[0].width = val @property def height(self): """int: """ return self._ptr[0].height @height.setter def height(self, val): if self._readonly: raise ValueError("This _py_anon_pod0 instance is read-only") self._ptr[0].height = val @property def depth(self): """int: """ return self._ptr[0].depth @depth.setter def depth(self, val): if self._readonly: raise ValueError("This _py_anon_pod0 instance is read-only") self._ptr[0].depth = val @staticmethod def from_buffer(buffer): """Create an _py_anon_pod0 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod0), _py_anon_pod0) @staticmethod def from_data(data): """Create an _py_anon_pod0 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod0_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod0_dtype", _py_anon_pod0_dtype, _py_anon_pod0) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod0 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod0 obj = _py_anon_pod0.__new__(_py_anon_pod0) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod0)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod0") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod0)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_array_memory_requirements_dtype_offsets(): cdef cudaArrayMemoryRequirements *pod = _cyb_calloc(1, sizeof(cudaArrayMemoryRequirements)) if pod == NULL: raise MemoryError("Error allocating cudaArrayMemoryRequirements") try: return _numpy.dtype({ 'names': ['size_', 'alignment', 'reserved'], 'formats': [_numpy.uint64, _numpy.uint64, (_numpy.uint32, 4)], 'offsets': [ (&(pod.size)) - (pod), (&(pod.alignment)) - (pod), (&(pod.reserved)) - (pod), ], 'itemsize': sizeof(cudaArrayMemoryRequirements), }) finally: _cyb_free(pod) array_memory_requirements_dtype = _get_array_memory_requirements_dtype_offsets() cdef class ArrayMemoryRequirements: """Empty-initialize an instance of `cudaArrayMemoryRequirements`. .. seealso:: `cudaArrayMemoryRequirements` """ cdef: cudaArrayMemoryRequirements _data cudaArrayMemoryRequirements *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.ArrayMemoryRequirements object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef ArrayMemoryRequirements other_ if not isinstance(other, ArrayMemoryRequirements): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaArrayMemoryRequirements)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaArrayMemoryRequirements), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This ArrayMemoryRequirements instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaArrayMemoryRequirements): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaArrayMemoryRequirements), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudaArrayMemoryRequirements)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def size_(self): """int: Total size of the array.""" return self._ptr[0].size @size_.setter def size_(self, val): if self._readonly: raise ValueError("This ArrayMemoryRequirements instance is read-only") self._ptr[0].size = val @property def alignment(self): """int: Alignment necessary for mapping the array.""" return self._ptr[0].alignment @alignment.setter def alignment(self, val): if self._readonly: raise ValueError("This ArrayMemoryRequirements instance is read-only") self._ptr[0].alignment = val @staticmethod def from_buffer(buffer): """Create an ArrayMemoryRequirements instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaArrayMemoryRequirements), ArrayMemoryRequirements) @staticmethod def from_data(data): """Create an ArrayMemoryRequirements instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `array_memory_requirements_dtype` holding the data. """ return _cyb_from_data(data, "array_memory_requirements_dtype", array_memory_requirements_dtype, ArrayMemoryRequirements) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an ArrayMemoryRequirements instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef ArrayMemoryRequirements obj = ArrayMemoryRequirements.__new__(ArrayMemoryRequirements) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudaArrayMemoryRequirements)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get_pitched_ptr_dtype_offsets(): cdef cudaPitchedPtr *pod = _cyb_calloc(1, sizeof(cudaPitchedPtr)) if pod == NULL: raise MemoryError("Error allocating cudaPitchedPtr") try: return _numpy.dtype({ 'names': ['ptr_', 'pitch', 'xsize', 'ysize'], 'formats': [_numpy.intp, _numpy.uint64, _numpy.uint64, _numpy.uint64], 'offsets': [ (&(pod.ptr)) - (pod), (&(pod.pitch)) - (pod), (&(pod.xsize)) - (pod), (&(pod.ysize)) - (pod), ], 'itemsize': sizeof(cudaPitchedPtr), }) finally: _cyb_free(pod) pitched_ptr_dtype = _get_pitched_ptr_dtype_offsets() cdef object pitched_ptr_dtype_record = _numpy.dtype((_numpy.record, pitched_ptr_dtype)) cdef class PitchedPtr: """Empty-initialize an array of `cudaPitchedPtr`. The resulting object is of length `size` and of dtype `pitched_ptr_dtype`. If default-constructed, the instance represents a single struct. Args: size (int): number of structs, default=1. .. seealso:: `cudaPitchedPtr` """ cdef: readonly object _data object _owner def __init__(self, size=1): self._data = _numpy.zeros(size, dtype=pitched_ptr_dtype_record) assert self._data.itemsize == sizeof(cudaPitchedPtr), \ f"itemsize {self._data.itemsize} mismatches struct size { sizeof(cudaPitchedPtr) }" def __repr__(self): if self._data.size > 1: return f"<{__name__}.PitchedPtr_Array_{self._data.size} object at {hex(id(self))}>" else: return f"<{__name__}.PitchedPtr object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return _cyb_array_ptr(self._data) cdef intptr_t _get_ptr(self): return _cyb_array_ptr(self._data) def __int__(self): if self._data.size > 1 and not self._data.flags["C_CONTIGUOUS"]: raise TypeError("int() argument must be a bytes-like object of size 1, or a " "C-contiguous array. To get the pointer address of a " "non-contiguous array, use .ptr") return _cyb_array_ptr(self._data) def __len__(self): return self._data.size def __eq__(self, other): cdef object self_data = self._data if (not isinstance(other, PitchedPtr)) or self_data.size != other._data.size or self_data.dtype != other._data.dtype: return False return bool((self_data == other._data).all()) def __getbuffer__(self, Py_buffer *buffer, int flags): _cyb_cpython.PyObject_GetBuffer(self._data, buffer, flags) def __releasebuffer__(self, Py_buffer *buffer): _cyb_cpython.PyBuffer_Release(buffer) @property def ptr_(self): """Union[~_numpy.intp, int]: Pointer to allocated memory""" if self._data.size == 1: return int(self._data["ptr_"][0]) return self._data["ptr_"] @ptr_.setter def ptr_(self, val): if not self._data.flags.writeable: raise ValueError("This PitchedPtr instance is read-only") self._data["ptr_"] = val @property def pitch(self): """Union[~_numpy.uint64, int]: Pitch of allocated memory in bytes""" if self._data.size == 1: return int(self._data["pitch"][0]) return self._data["pitch"] @pitch.setter def pitch(self, val): if not self._data.flags.writeable: raise ValueError("This PitchedPtr instance is read-only") self._data["pitch"] = val @property def xsize(self): """Union[~_numpy.uint64, int]: Logical width of allocation in elements""" if self._data.size == 1: return int(self._data["xsize"][0]) return self._data["xsize"] @xsize.setter def xsize(self, val): if not self._data.flags.writeable: raise ValueError("This PitchedPtr instance is read-only") self._data["xsize"] = val @property def ysize(self): """Union[~_numpy.uint64, int]: Logical height of allocation in elements""" if self._data.size == 1: return int(self._data["ysize"][0]) return self._data["ysize"] @ysize.setter def ysize(self, val): if not self._data.flags.writeable: raise ValueError("This PitchedPtr instance is read-only") self._data["ysize"] = val def __getitem__(self, key): cdef ssize_t key_ cdef ssize_t size cdef PitchedPtr obj if isinstance(key, int): key_ = key size = self._data.size if key_ >= size or key_ <= -(size+1): raise IndexError("index is out of bounds") if key_ < 0: key_ += size obj = PitchedPtr.__new__(PitchedPtr) obj._data = self._data[key_:key_+1] obj._owner = self._owner return obj out = self._data[key] if isinstance(out, _numpy.ndarray): if out.dtype == pitched_ptr_dtype: obj = PitchedPtr.from_data(out) obj._owner = self._owner return obj if out.dtype.names is not None: return out.view(_numpy.recarray) return out def __setitem__(self, key, val): self._data[key] = val @staticmethod def from_buffer(buffer): """Create an PitchedPtr instance with the memory from the given buffer.""" return PitchedPtr.from_data(_numpy.frombuffer(buffer, dtype=pitched_ptr_dtype)) @staticmethod def from_data(data): """Create an PitchedPtr instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a 1D array of dtype `pitched_ptr_dtype` holding the data. """ cdef PitchedPtr obj = PitchedPtr.__new__(PitchedPtr) if not isinstance(data, _numpy.ndarray): raise TypeError("data argument must be a NumPy ndarray") if data.ndim != 1: raise ValueError("data array must be 1D") if data.dtype != pitched_ptr_dtype: raise ValueError("data array must be of dtype pitched_ptr_dtype") obj._data = data.view(dtype=pitched_ptr_dtype_record, type=_numpy.ndarray) return obj @staticmethod def from_ptr(intptr_t ptr, size_t size=1, bint readonly=False, object owner=None): """Create an PitchedPtr instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. size (int): number of structs, default=1. readonly (bool): whether the data is read-only (to the user). default is `False`. owner (object): object that owns the memory at *ptr*. A strong reference is kept, by this wrapper and by every NumPy view of its data, so the backing storage outlives them. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef PitchedPtr obj = PitchedPtr.__new__(PitchedPtr) cdef _cyb_MemoryHolder buf = _cyb_MemoryHolder(ptr, sizeof(cudaPitchedPtr) * size, readonly, owner) obj._data = _numpy.ndarray(size, buffer=buf, dtype=pitched_ptr_dtype_record) obj._owner = owner return obj cdef _get_extent_dtype_offsets(): cdef cudaExtent *pod = _cyb_calloc(1, sizeof(cudaExtent)) if pod == NULL: raise MemoryError("Error allocating cudaExtent") try: return _numpy.dtype({ 'names': ['width', 'height', 'depth'], 'formats': [_numpy.uint64, _numpy.uint64, _numpy.uint64], 'offsets': [ (&(pod.width)) - (pod), (&(pod.height)) - (pod), (&(pod.depth)) - (pod), ], 'itemsize': sizeof(cudaExtent), }) finally: _cyb_free(pod) extent_dtype = _get_extent_dtype_offsets() cdef class Extent: """Empty-initialize an instance of `cudaExtent`. .. seealso:: `cudaExtent` """ cdef: cudaExtent *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cudaExtent)) if self._ptr == NULL: raise MemoryError("Error allocating Extent") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cudaExtent *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.Extent object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef Extent other_ if not isinstance(other, Extent): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaExtent)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaExtent), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This Extent instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaExtent): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaExtent), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cudaExtent)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def width(self): """int: Width in elements when referring to array memory, in bytes when referring to linear memory""" return self._ptr[0].width @width.setter def width(self, val): if self._readonly: raise ValueError("This Extent instance is read-only") self._ptr[0].width = val @property def height(self): """int: Height in elements""" return self._ptr[0].height @height.setter def height(self, val): if self._readonly: raise ValueError("This Extent instance is read-only") self._ptr[0].height = val @property def depth(self): """int: Depth in elements""" return self._ptr[0].depth @depth.setter def depth(self, val): if self._readonly: raise ValueError("This Extent instance is read-only") self._ptr[0].depth = val @staticmethod def from_buffer(buffer): """Create an Extent instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaExtent), Extent) @staticmethod def from_data(data): """Create an Extent instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `extent_dtype` holding the data. """ return _cyb_from_data(data, "extent_dtype", extent_dtype, Extent) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an Extent instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef Extent obj = Extent.__new__(Extent) if owner is None: obj._ptr = _cyb_malloc(sizeof(cudaExtent)) if obj._ptr == NULL: raise MemoryError("Error allocating Extent") _cyb_memcpy((obj._ptr), ptr, sizeof(cudaExtent)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_pos_dtype_offsets(): cdef cudaPos *pod = _cyb_calloc(1, sizeof(cudaPos)) if pod == NULL: raise MemoryError("Error allocating cudaPos") try: return _numpy.dtype({ 'names': ['x', 'y', 'z'], 'formats': [_numpy.uint64, _numpy.uint64, _numpy.uint64], 'offsets': [ (&(pod.x)) - (pod), (&(pod.y)) - (pod), (&(pod.z)) - (pod), ], 'itemsize': sizeof(cudaPos), }) finally: _cyb_free(pod) pos_dtype = _get_pos_dtype_offsets() cdef class Pos: """Empty-initialize an instance of `cudaPos`. .. seealso:: `cudaPos` """ cdef: cudaPos *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cudaPos)) if self._ptr == NULL: raise MemoryError("Error allocating Pos") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cudaPos *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.Pos object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef Pos other_ if not isinstance(other, Pos): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaPos)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaPos), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This Pos instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaPos): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaPos), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cudaPos)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def x(self): """int: x""" return self._ptr[0].x @x.setter def x(self, val): if self._readonly: raise ValueError("This Pos instance is read-only") self._ptr[0].x = val @property def y(self): """int: y""" return self._ptr[0].y @y.setter def y(self, val): if self._readonly: raise ValueError("This Pos instance is read-only") self._ptr[0].y = val @property def z(self): """int: z""" return self._ptr[0].z @z.setter def z(self, val): if self._readonly: raise ValueError("This Pos instance is read-only") self._ptr[0].z = val @staticmethod def from_buffer(buffer): """Create an Pos instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaPos), Pos) @staticmethod def from_data(data): """Create an Pos instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `pos_dtype` holding the data. """ return _cyb_from_data(data, "pos_dtype", pos_dtype, Pos) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an Pos instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef Pos obj = Pos.__new__(Pos) if owner is None: obj._ptr = _cyb_malloc(sizeof(cudaPos)) if obj._ptr == NULL: raise MemoryError("Error allocating Pos") _cyb_memcpy((obj._ptr), ptr, sizeof(cudaPos)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_memset_params_dtype_offsets(): cdef cudaMemsetParams *pod = _cyb_calloc(1, sizeof(cudaMemsetParams)) if pod == NULL: raise MemoryError("Error allocating cudaMemsetParams") try: return _numpy.dtype({ 'names': ['dst', 'pitch', 'value', 'element_size', 'width', 'height'], 'formats': [_numpy.intp, _numpy.uint64, _numpy.uint32, _numpy.uint32, _numpy.uint64, _numpy.uint64], 'offsets': [ (&(pod.dst)) - (pod), (&(pod.pitch)) - (pod), (&(pod.value)) - (pod), (&(pod.elementSize)) - (pod), (&(pod.width)) - (pod), (&(pod.height)) - (pod), ], 'itemsize': sizeof(cudaMemsetParams), }) finally: _cyb_free(pod) memset_params_dtype = _get_memset_params_dtype_offsets() cdef class MemsetParams: """Empty-initialize an instance of `cudaMemsetParams`. .. seealso:: `cudaMemsetParams` """ cdef: cudaMemsetParams _data cudaMemsetParams *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.MemsetParams object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef MemsetParams other_ if not isinstance(other, MemsetParams): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaMemsetParams)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaMemsetParams), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This MemsetParams instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaMemsetParams): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaMemsetParams), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudaMemsetParams)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def dst(self): """int: Destination device pointer""" return (self._ptr[0].dst) @dst.setter def dst(self, val): if self._readonly: raise ValueError("This MemsetParams instance is read-only") self._ptr[0].dst = val @property def pitch(self): """int: Pitch of destination device pointer. Unused if height is 1""" return self._ptr[0].pitch @pitch.setter def pitch(self, val): if self._readonly: raise ValueError("This MemsetParams instance is read-only") self._ptr[0].pitch = val @property def value(self): """int: Value to be set""" return self._ptr[0].value @value.setter def value(self, val): if self._readonly: raise ValueError("This MemsetParams instance is read-only") self._ptr[0].value = val @property def element_size(self): """int: Size of each element in bytes. Must be 1, 2, or 4.""" return self._ptr[0].elementSize @element_size.setter def element_size(self, val): if self._readonly: raise ValueError("This MemsetParams instance is read-only") self._ptr[0].elementSize = val @property def width(self): """int: Width of the row in elements""" return self._ptr[0].width @width.setter def width(self, val): if self._readonly: raise ValueError("This MemsetParams instance is read-only") self._ptr[0].width = val @property def height(self): """int: Number of rows""" return self._ptr[0].height @height.setter def height(self, val): if self._readonly: raise ValueError("This MemsetParams instance is read-only") self._ptr[0].height = val @staticmethod def from_buffer(buffer): """Create an MemsetParams instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaMemsetParams), MemsetParams) @staticmethod def from_data(data): """Create an MemsetParams instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `memset_params_dtype` holding the data. """ return _cyb_from_data(data, "memset_params_dtype", memset_params_dtype, MemsetParams) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an MemsetParams instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef MemsetParams obj = MemsetParams.__new__(MemsetParams) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudaMemsetParams)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get_memset_params_v2_dtype_offsets(): cdef cudaMemsetParamsV2 *pod = _cyb_calloc(1, sizeof(cudaMemsetParamsV2)) if pod == NULL: raise MemoryError("Error allocating cudaMemsetParamsV2") try: return _numpy.dtype({ 'names': ['dst', 'pitch', 'value', 'element_size', 'width', 'height', 'ctx'], 'formats': [_numpy.intp, _numpy.uint64, _numpy.uint32, _numpy.uint32, _numpy.uint64, _numpy.uint64, _numpy.intp], 'offsets': [ (&(pod.dst)) - (pod), (&(pod.pitch)) - (pod), (&(pod.value)) - (pod), (&(pod.elementSize)) - (pod), (&(pod.width)) - (pod), (&(pod.height)) - (pod), (&(pod.ctx)) - (pod), ], 'itemsize': sizeof(cudaMemsetParamsV2), }) finally: _cyb_free(pod) memset_params_v2_dtype = _get_memset_params_v2_dtype_offsets() cdef class MemsetParamsV2: """Empty-initialize an instance of `cudaMemsetParamsV2`. .. seealso:: `cudaMemsetParamsV2` """ cdef: cudaMemsetParamsV2 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cudaMemsetParamsV2)) if self._ptr == NULL: raise MemoryError("Error allocating MemsetParamsV2") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cudaMemsetParamsV2 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.MemsetParamsV2 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef MemsetParamsV2 other_ if not isinstance(other, MemsetParamsV2): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaMemsetParamsV2)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaMemsetParamsV2), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This MemsetParamsV2 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaMemsetParamsV2): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaMemsetParamsV2), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cudaMemsetParamsV2)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def dst(self): """int: Destination device pointer""" return (self._ptr[0].dst) @dst.setter def dst(self, val): if self._readonly: raise ValueError("This MemsetParamsV2 instance is read-only") self._ptr[0].dst = val @property def pitch(self): """int: Pitch of destination device pointer. Unused if height is 1""" return self._ptr[0].pitch @pitch.setter def pitch(self, val): if self._readonly: raise ValueError("This MemsetParamsV2 instance is read-only") self._ptr[0].pitch = val @property def value(self): """int: Value to be set""" return self._ptr[0].value @value.setter def value(self, val): if self._readonly: raise ValueError("This MemsetParamsV2 instance is read-only") self._ptr[0].value = val @property def element_size(self): """int: Size of each element in bytes. Must be 1, 2, or 4.""" return self._ptr[0].elementSize @element_size.setter def element_size(self, val): if self._readonly: raise ValueError("This MemsetParamsV2 instance is read-only") self._ptr[0].elementSize = val @property def width(self): """int: Width of the row in elements""" return self._ptr[0].width @width.setter def width(self, val): if self._readonly: raise ValueError("This MemsetParamsV2 instance is read-only") self._ptr[0].width = val @property def height(self): """int: Number of rows""" return self._ptr[0].height @height.setter def height(self, val): if self._readonly: raise ValueError("This MemsetParamsV2 instance is read-only") self._ptr[0].height = val @property def ctx(self): """int: Context in which to run the memset. If NULL will try to use the current context.""" return (self._ptr[0].ctx) @ctx.setter def ctx(self, val): if self._readonly: raise ValueError("This MemsetParamsV2 instance is read-only") self._ptr[0].ctx = val @staticmethod def from_buffer(buffer): """Create an MemsetParamsV2 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaMemsetParamsV2), MemsetParamsV2) @staticmethod def from_data(data): """Create an MemsetParamsV2 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `memset_params_v2_dtype` holding the data. """ return _cyb_from_data(data, "memset_params_v2_dtype", memset_params_v2_dtype, MemsetParamsV2) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an MemsetParamsV2 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef MemsetParamsV2 obj = MemsetParamsV2.__new__(MemsetParamsV2) if owner is None: obj._ptr = _cyb_malloc(sizeof(cudaMemsetParamsV2)) if obj._ptr == NULL: raise MemoryError("Error allocating MemsetParamsV2") _cyb_memcpy((obj._ptr), ptr, sizeof(cudaMemsetParamsV2)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_access_policy_window_dtype_offsets(): cdef cudaAccessPolicyWindow *pod = _cyb_calloc(1, sizeof(cudaAccessPolicyWindow)) if pod == NULL: raise MemoryError("Error allocating cudaAccessPolicyWindow") try: return _numpy.dtype({ 'names': ['base_ptr', 'num_bytes', 'hit_ratio', 'hit_prop', 'miss_prop'], 'formats': [_numpy.intp, _numpy.uint64, _numpy.float32, _numpy.int32, _numpy.int32], 'offsets': [ (&(pod.base_ptr)) - (pod), (&(pod.num_bytes)) - (pod), (&(pod.hitRatio)) - (pod), (&(pod.hitProp)) - (pod), (&(pod.missProp)) - (pod), ], 'itemsize': sizeof(cudaAccessPolicyWindow), }) finally: _cyb_free(pod) access_policy_window_dtype = _get_access_policy_window_dtype_offsets() cdef class AccessPolicyWindow: """Empty-initialize an instance of `cudaAccessPolicyWindow`. .. seealso:: `cudaAccessPolicyWindow` """ cdef: cudaAccessPolicyWindow *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cudaAccessPolicyWindow)) if self._ptr == NULL: raise MemoryError("Error allocating AccessPolicyWindow") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cudaAccessPolicyWindow *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.AccessPolicyWindow object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef AccessPolicyWindow other_ if not isinstance(other, AccessPolicyWindow): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaAccessPolicyWindow)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaAccessPolicyWindow), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This AccessPolicyWindow instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaAccessPolicyWindow): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaAccessPolicyWindow), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cudaAccessPolicyWindow)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def base_ptr(self): """int: Starting address of the access policy window. CUDA driver may align it.""" return (self._ptr[0].base_ptr) @base_ptr.setter def base_ptr(self, val): if self._readonly: raise ValueError("This AccessPolicyWindow instance is read-only") self._ptr[0].base_ptr = val @property def num_bytes(self): """int: Size in bytes of the window policy. CUDA driver may restrict the maximum size and alignment.""" return self._ptr[0].num_bytes @num_bytes.setter def num_bytes(self, val): if self._readonly: raise ValueError("This AccessPolicyWindow instance is read-only") self._ptr[0].num_bytes = val @property def hit_ratio(self): """float: hitRatio specifies percentage of lines assigned hitProp, rest are assigned missProp.""" return self._ptr[0].hitRatio @hit_ratio.setter def hit_ratio(self, val): if self._readonly: raise ValueError("This AccessPolicyWindow instance is read-only") self._ptr[0].hitRatio = val @property def hit_prop(self): """int: ::CUaccessProperty set for hit.""" return (self._ptr[0].hitProp) @hit_prop.setter def hit_prop(self, val): if self._readonly: raise ValueError("This AccessPolicyWindow instance is read-only") self._ptr[0].hitProp = val @property def miss_prop(self): """int: ::CUaccessProperty set for miss. Must be either NORMAL or STREAMING.""" return (self._ptr[0].missProp) @miss_prop.setter def miss_prop(self, val): if self._readonly: raise ValueError("This AccessPolicyWindow instance is read-only") self._ptr[0].missProp = val @staticmethod def from_buffer(buffer): """Create an AccessPolicyWindow instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaAccessPolicyWindow), AccessPolicyWindow) @staticmethod def from_data(data): """Create an AccessPolicyWindow instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `access_policy_window_dtype` holding the data. """ return _cyb_from_data(data, "access_policy_window_dtype", access_policy_window_dtype, AccessPolicyWindow) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an AccessPolicyWindow instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef AccessPolicyWindow obj = AccessPolicyWindow.__new__(AccessPolicyWindow) if owner is None: obj._ptr = _cyb_malloc(sizeof(cudaAccessPolicyWindow)) if obj._ptr == NULL: raise MemoryError("Error allocating AccessPolicyWindow") _cyb_memcpy((obj._ptr), ptr, sizeof(cudaAccessPolicyWindow)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_host_node_params_dtype_offsets(): cdef cudaHostNodeParams *pod = _cyb_calloc(1, sizeof(cudaHostNodeParams)) if pod == NULL: raise MemoryError("Error allocating cudaHostNodeParams") try: return _numpy.dtype({ 'names': ['fn', 'user_data'], 'formats': [_numpy.intp, _numpy.intp], 'offsets': [ (&(pod.fn)) - (pod), (&(pod.userData)) - (pod), ], 'itemsize': sizeof(cudaHostNodeParams), }) finally: _cyb_free(pod) host_node_params_dtype = _get_host_node_params_dtype_offsets() cdef class HostNodeParams: """Empty-initialize an instance of `cudaHostNodeParams`. .. seealso:: `cudaHostNodeParams` """ cdef: cudaHostNodeParams _data cudaHostNodeParams *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.HostNodeParams object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef HostNodeParams other_ if not isinstance(other, HostNodeParams): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaHostNodeParams)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaHostNodeParams), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This HostNodeParams instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaHostNodeParams): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaHostNodeParams), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudaHostNodeParams)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def fn(self): """int: The function to call when the node executes""" return (self._ptr[0].fn) @fn.setter def fn(self, val): if self._readonly: raise ValueError("This HostNodeParams instance is read-only") self._ptr[0].fn = val @property def user_data(self): """int: Argument to pass to the function""" return (self._ptr[0].userData) @user_data.setter def user_data(self, val): if self._readonly: raise ValueError("This HostNodeParams instance is read-only") self._ptr[0].userData = val @staticmethod def from_buffer(buffer): """Create an HostNodeParams instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaHostNodeParams), HostNodeParams) @staticmethod def from_data(data): """Create an HostNodeParams instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `host_node_params_dtype` holding the data. """ return _cyb_from_data(data, "host_node_params_dtype", host_node_params_dtype, HostNodeParams) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an HostNodeParams instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef HostNodeParams obj = HostNodeParams.__new__(HostNodeParams) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudaHostNodeParams)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get_host_node_params_v2_dtype_offsets(): cdef cudaHostNodeParamsV2 *pod = _cyb_calloc(1, sizeof(cudaHostNodeParamsV2)) if pod == NULL: raise MemoryError("Error allocating cudaHostNodeParamsV2") try: return _numpy.dtype({ 'names': ['fn', 'user_data', 'sync_mode', 'ctx'], 'formats': [_numpy.intp, _numpy.intp, _numpy.uint32, _numpy.intp], 'offsets': [ (&(pod.fn)) - (pod), (&(pod.userData)) - (pod), (&(pod.syncMode)) - (pod), (&(pod.ctx)) - (pod), ], 'itemsize': sizeof(cudaHostNodeParamsV2), }) finally: _cyb_free(pod) host_node_params_v2_dtype = _get_host_node_params_v2_dtype_offsets() cdef class HostNodeParamsV2: """Empty-initialize an instance of `cudaHostNodeParamsV2`. .. seealso:: `cudaHostNodeParamsV2` """ cdef: cudaHostNodeParamsV2 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cudaHostNodeParamsV2)) if self._ptr == NULL: raise MemoryError("Error allocating HostNodeParamsV2") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cudaHostNodeParamsV2 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.HostNodeParamsV2 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef HostNodeParamsV2 other_ if not isinstance(other, HostNodeParamsV2): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaHostNodeParamsV2)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaHostNodeParamsV2), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This HostNodeParamsV2 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaHostNodeParamsV2): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaHostNodeParamsV2), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cudaHostNodeParamsV2)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def fn(self): """int: The function to call when the node executes""" return (self._ptr[0].fn) @fn.setter def fn(self, val): if self._readonly: raise ValueError("This HostNodeParamsV2 instance is read-only") self._ptr[0].fn = val @property def user_data(self): """int: Argument to pass to the function""" return (self._ptr[0].userData) @user_data.setter def user_data(self, val): if self._readonly: raise ValueError("This HostNodeParamsV2 instance is read-only") self._ptr[0].userData = val @property def sync_mode(self): """int: The synchronization mode to use for the host task""" return self._ptr[0].syncMode @sync_mode.setter def sync_mode(self, val): if self._readonly: raise ValueError("This HostNodeParamsV2 instance is read-only") self._ptr[0].syncMode = val @property def ctx(self): """int: CUDA Execution Context""" return (self._ptr[0].ctx) @ctx.setter def ctx(self, val): if self._readonly: raise ValueError("This HostNodeParamsV2 instance is read-only") self._ptr[0].ctx = val @staticmethod def from_buffer(buffer): """Create an HostNodeParamsV2 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaHostNodeParamsV2), HostNodeParamsV2) @staticmethod def from_data(data): """Create an HostNodeParamsV2 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `host_node_params_v2_dtype` holding the data. """ return _cyb_from_data(data, "host_node_params_v2_dtype", host_node_params_v2_dtype, HostNodeParamsV2) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an HostNodeParamsV2 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef HostNodeParamsV2 obj = HostNodeParamsV2.__new__(HostNodeParamsV2) if owner is None: obj._ptr = _cyb_malloc(sizeof(cudaHostNodeParamsV2)) if obj._ptr == NULL: raise MemoryError("Error allocating HostNodeParamsV2") _cyb_memcpy((obj._ptr), ptr, sizeof(cudaHostNodeParamsV2)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod2_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod2 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod2)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod2") try: return _numpy.dtype({ 'names': ['array'], 'formats': [_numpy.intp], 'offsets': [ (&(pod.array)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod2), }) finally: _cyb_free(pod) _py_anon_pod2_dtype = _get__py_anon_pod2_dtype_offsets() cdef class _py_anon_pod2: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod2`. .. seealso:: `cuda_bindings_runtime__anon_pod2` """ cdef: cuda_bindings_runtime__anon_pod2 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod2)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod2") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod2 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod2 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod2 other_ if not isinstance(other, _py_anon_pod2): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod2)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod2), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod2 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod2): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod2), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod2)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def array(self): """int: """ return (self._ptr[0].array) @array.setter def array(self, val): if self._readonly: raise ValueError("This _py_anon_pod2 instance is read-only") self._ptr[0].array = val @staticmethod def from_buffer(buffer): """Create an _py_anon_pod2 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod2), _py_anon_pod2) @staticmethod def from_data(data): """Create an _py_anon_pod2 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod2_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod2_dtype", _py_anon_pod2_dtype, _py_anon_pod2) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod2 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod2 obj = _py_anon_pod2.__new__(_py_anon_pod2) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod2)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod2") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod2)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod3_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod3 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod3)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod3") try: return _numpy.dtype({ 'names': ['mipmap'], 'formats': [_numpy.intp], 'offsets': [ (&(pod.mipmap)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod3), }) finally: _cyb_free(pod) _py_anon_pod3_dtype = _get__py_anon_pod3_dtype_offsets() cdef class _py_anon_pod3: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod3`. .. seealso:: `cuda_bindings_runtime__anon_pod3` """ cdef: cuda_bindings_runtime__anon_pod3 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod3)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod3") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod3 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod3 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod3 other_ if not isinstance(other, _py_anon_pod3): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod3)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod3), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod3 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod3): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod3), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod3)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def mipmap(self): """int: """ return (self._ptr[0].mipmap) @mipmap.setter def mipmap(self, val): if self._readonly: raise ValueError("This _py_anon_pod3 instance is read-only") self._ptr[0].mipmap = val @staticmethod def from_buffer(buffer): """Create an _py_anon_pod3 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod3), _py_anon_pod3) @staticmethod def from_data(data): """Create an _py_anon_pod3 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod3_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod3_dtype", _py_anon_pod3_dtype, _py_anon_pod3) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod3 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod3 obj = _py_anon_pod3.__new__(_py_anon_pod3) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod3)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod3") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod3)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod6_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod6 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod6)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod6") try: return _numpy.dtype({ 'names': ['reserved'], 'formats': [(_numpy.int32, 32)], 'offsets': [ (&(pod.reserved)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod6), }) finally: _cyb_free(pod) _py_anon_pod6_dtype = _get__py_anon_pod6_dtype_offsets() cdef class _py_anon_pod6: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod6`. .. seealso:: `cuda_bindings_runtime__anon_pod6` """ cdef: cuda_bindings_runtime__anon_pod6 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod6)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod6") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod6 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod6 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod6 other_ if not isinstance(other, _py_anon_pod6): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod6)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod6), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod6 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod6): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod6), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod6)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @staticmethod def from_buffer(buffer): """Create an _py_anon_pod6 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod6), _py_anon_pod6) @staticmethod def from_data(data): """Create an _py_anon_pod6 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod6_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod6_dtype", _py_anon_pod6_dtype, _py_anon_pod6) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod6 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod6 obj = _py_anon_pod6.__new__(_py_anon_pod6) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod6)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod6") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod6)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_resource_view_desc_dtype_offsets(): cdef cudaResourceViewDesc *pod = _cyb_calloc(1, sizeof(cudaResourceViewDesc)) if pod == NULL: raise MemoryError("Error allocating cudaResourceViewDesc") try: return _numpy.dtype({ 'names': ['format', 'width', 'height', 'depth', 'first_mipmap_level', 'last_mipmap_level', 'first_layer', 'last_layer', 'reserved'], 'formats': [_numpy.int32, _numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.uint32, _numpy.uint32, _numpy.uint32, _numpy.uint32, (_numpy.uint32, 16)], 'offsets': [ (&(pod.format)) - (pod), (&(pod.width)) - (pod), (&(pod.height)) - (pod), (&(pod.depth)) - (pod), (&(pod.firstMipmapLevel)) - (pod), (&(pod.lastMipmapLevel)) - (pod), (&(pod.firstLayer)) - (pod), (&(pod.lastLayer)) - (pod), (&(pod.reserved)) - (pod), ], 'itemsize': sizeof(cudaResourceViewDesc), }) finally: _cyb_free(pod) resource_view_desc_dtype = _get_resource_view_desc_dtype_offsets() cdef class ResourceViewDesc: """Empty-initialize an instance of `cudaResourceViewDesc`. .. seealso:: `cudaResourceViewDesc` """ cdef: cudaResourceViewDesc _data cudaResourceViewDesc *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.ResourceViewDesc object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef ResourceViewDesc other_ if not isinstance(other, ResourceViewDesc): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaResourceViewDesc)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaResourceViewDesc), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This ResourceViewDesc instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaResourceViewDesc): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaResourceViewDesc), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudaResourceViewDesc)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def format(self): """int: Resource view format""" return (self._ptr[0].format) @format.setter def format(self, val): if self._readonly: raise ValueError("This ResourceViewDesc instance is read-only") self._ptr[0].format = val @property def width(self): """int: Width of the resource view""" return self._ptr[0].width @width.setter def width(self, val): if self._readonly: raise ValueError("This ResourceViewDesc instance is read-only") self._ptr[0].width = val @property def height(self): """int: Height of the resource view""" return self._ptr[0].height @height.setter def height(self, val): if self._readonly: raise ValueError("This ResourceViewDesc instance is read-only") self._ptr[0].height = val @property def depth(self): """int: Depth of the resource view""" return self._ptr[0].depth @depth.setter def depth(self, val): if self._readonly: raise ValueError("This ResourceViewDesc instance is read-only") self._ptr[0].depth = val @property def first_mipmap_level(self): """int: First defined mipmap level""" return self._ptr[0].firstMipmapLevel @first_mipmap_level.setter def first_mipmap_level(self, val): if self._readonly: raise ValueError("This ResourceViewDesc instance is read-only") self._ptr[0].firstMipmapLevel = val @property def last_mipmap_level(self): """int: Last defined mipmap level""" return self._ptr[0].lastMipmapLevel @last_mipmap_level.setter def last_mipmap_level(self, val): if self._readonly: raise ValueError("This ResourceViewDesc instance is read-only") self._ptr[0].lastMipmapLevel = val @property def first_layer(self): """int: First layer index""" return self._ptr[0].firstLayer @first_layer.setter def first_layer(self, val): if self._readonly: raise ValueError("This ResourceViewDesc instance is read-only") self._ptr[0].firstLayer = val @property def last_layer(self): """int: Last layer index""" return self._ptr[0].lastLayer @last_layer.setter def last_layer(self, val): if self._readonly: raise ValueError("This ResourceViewDesc instance is read-only") self._ptr[0].lastLayer = val @staticmethod def from_buffer(buffer): """Create an ResourceViewDesc instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaResourceViewDesc), ResourceViewDesc) @staticmethod def from_data(data): """Create an ResourceViewDesc instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `resource_view_desc_dtype` holding the data. """ return _cyb_from_data(data, "resource_view_desc_dtype", resource_view_desc_dtype, ResourceViewDesc) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an ResourceViewDesc instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef ResourceViewDesc obj = ResourceViewDesc.__new__(ResourceViewDesc) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudaResourceViewDesc)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get_func_attributes_dtype_offsets(): cdef cudaFuncAttributes *pod = _cyb_calloc(1, sizeof(cudaFuncAttributes)) if pod == NULL: raise MemoryError("Error allocating cudaFuncAttributes") try: return _numpy.dtype({ 'names': ['shared_size_bytes', 'const_size_bytes', 'local_size_bytes', 'max_threads_per_block', 'num_regs', 'ptx_version', 'binary_version', 'cache_mode_ca', 'max_dynamic_shared_size_bytes', 'preferred_shmem_carveout', 'cluster_dim_must_be_set', 'required_cluster_width', 'required_cluster_height', 'required_cluster_depth', 'cluster_scheduling_policy_preference', 'non_portable_cluster_size_allowed', 'device_node_update_status', 'shared_memory_mode', 'reserved'], 'formats': [_numpy.uint64, _numpy.uint64, _numpy.uint64, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, (_numpy.int32, 14)], 'offsets': [ (&(pod.sharedSizeBytes)) - (pod), (&(pod.constSizeBytes)) - (pod), (&(pod.localSizeBytes)) - (pod), (&(pod.maxThreadsPerBlock)) - (pod), (&(pod.numRegs)) - (pod), (&(pod.ptxVersion)) - (pod), (&(pod.binaryVersion)) - (pod), (&(pod.cacheModeCA)) - (pod), (&(pod.maxDynamicSharedSizeBytes)) - (pod), (&(pod.preferredShmemCarveout)) - (pod), (&(pod.clusterDimMustBeSet)) - (pod), (&(pod.requiredClusterWidth)) - (pod), (&(pod.requiredClusterHeight)) - (pod), (&(pod.requiredClusterDepth)) - (pod), (&(pod.clusterSchedulingPolicyPreference)) - (pod), (&(pod.nonPortableClusterSizeAllowed)) - (pod), (&(pod.deviceNodeUpdateStatus)) - (pod), (&(pod.sharedMemoryMode)) - (pod), (&(pod.reserved)) - (pod), ], 'itemsize': sizeof(cudaFuncAttributes), }) finally: _cyb_free(pod) func_attributes_dtype = _get_func_attributes_dtype_offsets() cdef class FuncAttributes: """Empty-initialize an instance of `cudaFuncAttributes`. .. seealso:: `cudaFuncAttributes` """ cdef: cudaFuncAttributes _data cudaFuncAttributes *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.FuncAttributes object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef FuncAttributes other_ if not isinstance(other, FuncAttributes): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaFuncAttributes)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaFuncAttributes), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This FuncAttributes instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaFuncAttributes): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaFuncAttributes), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudaFuncAttributes)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def shared_size_bytes(self): """int: The size in bytes of statically-allocated shared memory per block required by this function. This does not include dynamically-allocated shared memory requested by the user at runtime.""" return self._ptr[0].sharedSizeBytes @shared_size_bytes.setter def shared_size_bytes(self, val): if self._readonly: raise ValueError("This FuncAttributes instance is read-only") self._ptr[0].sharedSizeBytes = val @property def const_size_bytes(self): """int: The size in bytes of user-allocated constant memory required by this function.""" return self._ptr[0].constSizeBytes @const_size_bytes.setter def const_size_bytes(self, val): if self._readonly: raise ValueError("This FuncAttributes instance is read-only") self._ptr[0].constSizeBytes = val @property def local_size_bytes(self): """int: The size in bytes of local memory used by each thread of this function.""" return self._ptr[0].localSizeBytes @local_size_bytes.setter def local_size_bytes(self, val): if self._readonly: raise ValueError("This FuncAttributes instance is read-only") self._ptr[0].localSizeBytes = val @property def max_threads_per_block(self): """int: The maximum number of threads per block, beyond which a launch of the function would fail. This number depends on both the function and the device on which the function is currently loaded.""" return self._ptr[0].maxThreadsPerBlock @max_threads_per_block.setter def max_threads_per_block(self, val): if self._readonly: raise ValueError("This FuncAttributes instance is read-only") self._ptr[0].maxThreadsPerBlock = val @property def num_regs(self): """int: The number of registers used by each thread of this function.""" return self._ptr[0].numRegs @num_regs.setter def num_regs(self, val): if self._readonly: raise ValueError("This FuncAttributes instance is read-only") self._ptr[0].numRegs = val @property def ptx_version(self): """int: The PTX virtual architecture version for which the function was compiled. This value is the major PTX version * 10 + the minor PTX version, so a PTX version 1.3 function would return the value 13.""" return self._ptr[0].ptxVersion @ptx_version.setter def ptx_version(self, val): if self._readonly: raise ValueError("This FuncAttributes instance is read-only") self._ptr[0].ptxVersion = val @property def binary_version(self): """int: The binary architecture version for which the function was compiled. This value is the major binary version * 10 + the minor binary version, so a binary version 1.3 function would return the value 13.""" return self._ptr[0].binaryVersion @binary_version.setter def binary_version(self, val): if self._readonly: raise ValueError("This FuncAttributes instance is read-only") self._ptr[0].binaryVersion = val @property def cache_mode_ca(self): """int: The attribute to indicate whether the function has been compiled with user specified option "-Xptxas --dlcm=ca" set.""" return self._ptr[0].cacheModeCA @cache_mode_ca.setter def cache_mode_ca(self, val): if self._readonly: raise ValueError("This FuncAttributes instance is read-only") self._ptr[0].cacheModeCA = val @property def max_dynamic_shared_size_bytes(self): """int: The maximum size in bytes of dynamic shared memory per block for this function. Any launch must have a dynamic shared memory size smaller than this value. This attribute is ignored if the sharedMemoryMode function or launch attribute is set. This attribute cannot be used to access oversized shared memory. Oversized shared memory can only be accessed by setting the shared memory mode. See cudaFuncSetAttribute""" return self._ptr[0].maxDynamicSharedSizeBytes @max_dynamic_shared_size_bytes.setter def max_dynamic_shared_size_bytes(self, val): if self._readonly: raise ValueError("This FuncAttributes instance is read-only") self._ptr[0].maxDynamicSharedSizeBytes = val @property def preferred_shmem_carveout(self): """int: On devices where the L1 cache and shared memory use the same hardware resources, this sets the shared memory carveout preference, in percent of the maximum shared memory. Refer to cudaDevAttrMaxSharedMemoryPerMultiprocessor. This is only a hint, and the driver can choose a different ratio if required to execute the function. See cudaFuncSetAttribute""" return self._ptr[0].preferredShmemCarveout @preferred_shmem_carveout.setter def preferred_shmem_carveout(self, val): if self._readonly: raise ValueError("This FuncAttributes instance is read-only") self._ptr[0].preferredShmemCarveout = val @property def cluster_dim_must_be_set(self): """int: If this attribute is set, the kernel must launch with a valid cluster dimension specified.""" return self._ptr[0].clusterDimMustBeSet @cluster_dim_must_be_set.setter def cluster_dim_must_be_set(self, val): if self._readonly: raise ValueError("This FuncAttributes instance is read-only") self._ptr[0].clusterDimMustBeSet = val @property def required_cluster_width(self): """int: The required cluster width/height/depth in blocks. The values must either all be 0 or all be positive. The validity of the cluster dimensions is otherwise checked at launch time. If the value is set during compile time, it cannot be set at runtime. Setting it at runtime should return cudaErrorNotPermitted. See cudaFuncSetAttribute""" return self._ptr[0].requiredClusterWidth @required_cluster_width.setter def required_cluster_width(self, val): if self._readonly: raise ValueError("This FuncAttributes instance is read-only") self._ptr[0].requiredClusterWidth = val @property def required_cluster_height(self): """int: """ return self._ptr[0].requiredClusterHeight @required_cluster_height.setter def required_cluster_height(self, val): if self._readonly: raise ValueError("This FuncAttributes instance is read-only") self._ptr[0].requiredClusterHeight = val @property def required_cluster_depth(self): """int: """ return self._ptr[0].requiredClusterDepth @required_cluster_depth.setter def required_cluster_depth(self, val): if self._readonly: raise ValueError("This FuncAttributes instance is read-only") self._ptr[0].requiredClusterDepth = val @property def cluster_scheduling_policy_preference(self): """int: The block scheduling policy of a function. See cudaFuncSetAttribute""" return self._ptr[0].clusterSchedulingPolicyPreference @cluster_scheduling_policy_preference.setter def cluster_scheduling_policy_preference(self, val): if self._readonly: raise ValueError("This FuncAttributes instance is read-only") self._ptr[0].clusterSchedulingPolicyPreference = val @property def non_portable_cluster_size_allowed(self): """int: Whether the function can be launched with non-portable cluster size. 1 is allowed, 0 is disallowed. A non-portable cluster size may only function on the specific SKUs the program is tested on. The launch might fail if the program is run on a different hardware platform. CUDA API provides cudaOccupancyMaxActiveClusters to assist with checking whether the desired size can be launched on the current device. Portable Cluster Size A portable cluster size is guaranteed to be functional on all compute capabilities higher than the target compute capability. The portable cluster size for sm_90 is 8 blocks per cluster. This value may increase for future compute capabilities. The specific hardware unit may support higher cluster sizes that’s not guaranteed to be portable. See cudaFuncSetAttribute""" return self._ptr[0].nonPortableClusterSizeAllowed @non_portable_cluster_size_allowed.setter def non_portable_cluster_size_allowed(self, val): if self._readonly: raise ValueError("This FuncAttributes instance is read-only") self._ptr[0].nonPortableClusterSizeAllowed = val @property def device_node_update_status(self): """int: Whether the function can be updated on device. 1 means device node update is supported, 0 is unsupported or driver is too old to check the value.""" return self._ptr[0].deviceNodeUpdateStatus @device_node_update_status.setter def device_node_update_status(self, val): if self._readonly: raise ValueError("This FuncAttributes instance is read-only") self._ptr[0].deviceNodeUpdateStatus = val @property def shared_memory_mode(self): """int: This controls a kernel's use of non-portable or oversized shared memory configurations. See cudaFuncSetAttribute""" return (self._ptr[0].sharedMemoryMode) @shared_memory_mode.setter def shared_memory_mode(self, val): if self._readonly: raise ValueError("This FuncAttributes instance is read-only") self._ptr[0].sharedMemoryMode = val @staticmethod def from_buffer(buffer): """Create an FuncAttributes instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaFuncAttributes), FuncAttributes) @staticmethod def from_data(data): """Create an FuncAttributes instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `func_attributes_dtype` holding the data. """ return _cyb_from_data(data, "func_attributes_dtype", func_attributes_dtype, FuncAttributes) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an FuncAttributes instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef FuncAttributes obj = FuncAttributes.__new__(FuncAttributes) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudaFuncAttributes)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod9_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod9 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod9)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod9") try: return _numpy.dtype({ 'names': ['device_id', 'locality_domain_id'], 'formats': [_numpy.uint8, _numpy.uint8], 'offsets': [ (&(pod.deviceId)) - (pod), (&(pod.localityDomainId)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod9), }) finally: _cyb_free(pod) _py_anon_pod9_dtype = _get__py_anon_pod9_dtype_offsets() cdef class _py_anon_pod9: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod9`. .. seealso:: `cuda_bindings_runtime__anon_pod9` """ cdef: cuda_bindings_runtime__anon_pod9 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod9)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod9") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod9 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod9 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod9 other_ if not isinstance(other, _py_anon_pod9): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod9)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod9), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod9 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod9): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod9), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod9)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def device_id(self): """int: """ return self._ptr[0].deviceId @device_id.setter def device_id(self, val): if self._readonly: raise ValueError("This _py_anon_pod9 instance is read-only") self._ptr[0].deviceId = val @property def locality_domain_id(self): """int: """ return self._ptr[0].localityDomainId @locality_domain_id.setter def locality_domain_id(self, val): if self._readonly: raise ValueError("This _py_anon_pod9 instance is read-only") self._ptr[0].localityDomainId = val @staticmethod def from_buffer(buffer): """Create an _py_anon_pod9 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod9), _py_anon_pod9) @staticmethod def from_data(data): """Create an _py_anon_pod9 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod9_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod9_dtype", _py_anon_pod9_dtype, _py_anon_pod9) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod9 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod9 obj = _py_anon_pod9.__new__(_py_anon_pod9) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod9)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod9") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod9)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_mem_pool_ptr_export_data_dtype_offsets(): cdef cudaMemPoolPtrExportData *pod = _cyb_calloc(1, sizeof(cudaMemPoolPtrExportData)) if pod == NULL: raise MemoryError("Error allocating cudaMemPoolPtrExportData") try: return _numpy.dtype({ 'names': ['reserved'], 'formats': [(_numpy.uint8, 64)], 'offsets': [ (&(pod.reserved)) - (pod), ], 'itemsize': sizeof(cudaMemPoolPtrExportData), }) finally: _cyb_free(pod) mem_pool_ptr_export_data_dtype = _get_mem_pool_ptr_export_data_dtype_offsets() cdef class MemPoolPtrExportData: """Empty-initialize an instance of `cudaMemPoolPtrExportData`. .. seealso:: `cudaMemPoolPtrExportData` """ cdef: cudaMemPoolPtrExportData _data cudaMemPoolPtrExportData *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.MemPoolPtrExportData object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef MemPoolPtrExportData other_ if not isinstance(other, MemPoolPtrExportData): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaMemPoolPtrExportData)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaMemPoolPtrExportData), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This MemPoolPtrExportData instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaMemPoolPtrExportData): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaMemPoolPtrExportData), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudaMemPoolPtrExportData)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @staticmethod def from_buffer(buffer): """Create an MemPoolPtrExportData instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaMemPoolPtrExportData), MemPoolPtrExportData) @staticmethod def from_data(data): """Create an MemPoolPtrExportData instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `mem_pool_ptr_export_data_dtype` holding the data. """ return _cyb_from_data(data, "mem_pool_ptr_export_data_dtype", mem_pool_ptr_export_data_dtype, MemPoolPtrExportData) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an MemPoolPtrExportData instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef MemPoolPtrExportData obj = MemPoolPtrExportData.__new__(MemPoolPtrExportData) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudaMemPoolPtrExportData)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get_mem_free_node_params_dtype_offsets(): cdef cudaMemFreeNodeParams *pod = _cyb_calloc(1, sizeof(cudaMemFreeNodeParams)) if pod == NULL: raise MemoryError("Error allocating cudaMemFreeNodeParams") try: return _numpy.dtype({ 'names': ['dptr'], 'formats': [_numpy.intp], 'offsets': [ (&(pod.dptr)) - (pod), ], 'itemsize': sizeof(cudaMemFreeNodeParams), }) finally: _cyb_free(pod) mem_free_node_params_dtype = _get_mem_free_node_params_dtype_offsets() cdef class MemFreeNodeParams: """Empty-initialize an instance of `cudaMemFreeNodeParams`. .. seealso:: `cudaMemFreeNodeParams` """ cdef: cudaMemFreeNodeParams *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cudaMemFreeNodeParams)) if self._ptr == NULL: raise MemoryError("Error allocating MemFreeNodeParams") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cudaMemFreeNodeParams *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.MemFreeNodeParams object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef MemFreeNodeParams other_ if not isinstance(other, MemFreeNodeParams): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaMemFreeNodeParams)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaMemFreeNodeParams), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This MemFreeNodeParams instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaMemFreeNodeParams): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaMemFreeNodeParams), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cudaMemFreeNodeParams)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def dptr(self): """int: in: the pointer to free""" return (self._ptr[0].dptr) @dptr.setter def dptr(self, val): if self._readonly: raise ValueError("This MemFreeNodeParams instance is read-only") self._ptr[0].dptr = val @staticmethod def from_buffer(buffer): """Create an MemFreeNodeParams instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaMemFreeNodeParams), MemFreeNodeParams) @staticmethod def from_data(data): """Create an MemFreeNodeParams instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `mem_free_node_params_dtype` holding the data. """ return _cyb_from_data(data, "mem_free_node_params_dtype", mem_free_node_params_dtype, MemFreeNodeParams) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an MemFreeNodeParams instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef MemFreeNodeParams obj = MemFreeNodeParams.__new__(MemFreeNodeParams) if owner is None: obj._ptr = _cyb_malloc(sizeof(cudaMemFreeNodeParams)) if obj._ptr == NULL: raise MemoryError("Error allocating MemFreeNodeParams") _cyb_memcpy((obj._ptr), ptr, sizeof(cudaMemFreeNodeParams)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_offset3d_dtype_offsets(): cdef cudaOffset3D *pod = _cyb_calloc(1, sizeof(cudaOffset3D)) if pod == NULL: raise MemoryError("Error allocating cudaOffset3D") try: return _numpy.dtype({ 'names': ['x', 'y', 'z'], 'formats': [_numpy.uint64, _numpy.uint64, _numpy.uint64], 'offsets': [ (&(pod.x)) - (pod), (&(pod.y)) - (pod), (&(pod.z)) - (pod), ], 'itemsize': sizeof(cudaOffset3D), }) finally: _cyb_free(pod) offset3d_dtype = _get_offset3d_dtype_offsets() cdef class Offset3d: """Empty-initialize an instance of `cudaOffset3D`. .. seealso:: `cudaOffset3D` """ cdef: cudaOffset3D *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cudaOffset3D)) if self._ptr == NULL: raise MemoryError("Error allocating Offset3d") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cudaOffset3D *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.Offset3d object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef Offset3d other_ if not isinstance(other, Offset3d): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaOffset3D)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaOffset3D), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This Offset3d instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaOffset3D): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaOffset3D), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cudaOffset3D)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def x(self): """int: """ return self._ptr[0].x @x.setter def x(self, val): if self._readonly: raise ValueError("This Offset3d instance is read-only") self._ptr[0].x = val @property def y(self): """int: """ return self._ptr[0].y @y.setter def y(self, val): if self._readonly: raise ValueError("This Offset3d instance is read-only") self._ptr[0].y = val @property def z(self): """int: """ return self._ptr[0].z @z.setter def z(self, val): if self._readonly: raise ValueError("This Offset3d instance is read-only") self._ptr[0].z = val @staticmethod def from_buffer(buffer): """Create an Offset3d instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaOffset3D), Offset3d) @staticmethod def from_data(data): """Create an Offset3d instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `offset3d_dtype` holding the data. """ return _cyb_from_data(data, "offset3d_dtype", offset3d_dtype, Offset3d) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an Offset3d instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef Offset3d obj = Offset3d.__new__(Offset3d) if owner is None: obj._ptr = _cyb_malloc(sizeof(cudaOffset3D)) if obj._ptr == NULL: raise MemoryError("Error allocating Offset3d") _cyb_memcpy((obj._ptr), ptr, sizeof(cudaOffset3D)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_uuid_dtype_offsets(): cdef cudaUUID_t *pod = _cyb_calloc(1, sizeof(cudaUUID_t)) if pod == NULL: raise MemoryError("Error allocating cudaUUID_t") try: return _numpy.dtype({ 'names': ['bytes'], 'formats': [(_numpy.int8, 16)], 'offsets': [ (&(pod.bytes)) - (pod), ], 'itemsize': sizeof(cudaUUID_t), }) finally: _cyb_free(pod) uuid_dtype = _get_uuid_dtype_offsets() cdef class Uuid: """Empty-initialize an instance of `cudaUUID_t`. .. seealso:: `cudaUUID_t` """ cdef: cudaUUID_t *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cudaUUID_t)) if self._ptr == NULL: raise MemoryError("Error allocating Uuid") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cudaUUID_t *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.Uuid object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef Uuid other_ if not isinstance(other, Uuid): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaUUID_t)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaUUID_t), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This Uuid instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaUUID_t): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaUUID_t), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cudaUUID_t)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def bytes(self): """bytes: The 16 raw bytes of the UUID.""" return self._ptr[0].bytes[:16] @bytes.setter def bytes(self, val): if self._readonly: raise ValueError("This Uuid instance is read-only") cdef bytes buf = bytes(val) if len(buf) != 16: raise ValueError(f"A UUID is 16 bytes, got {len(buf)}") cdef const char* src = buf cdef int i for i in range(16): self._ptr[0].bytes[i] = src[i] @staticmethod def from_buffer(buffer): """Create an Uuid instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaUUID_t), Uuid) @staticmethod def from_data(data): """Create an Uuid instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `uuid_dtype` holding the data. """ return _cyb_from_data(data, "uuid_dtype", uuid_dtype, Uuid) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an Uuid instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef Uuid obj = Uuid.__new__(Uuid) if owner is None: obj._ptr = _cyb_malloc(sizeof(cudaUUID_t)) if obj._ptr == NULL: raise MemoryError("Error allocating Uuid") _cyb_memcpy((obj._ptr), ptr, sizeof(cudaUUID_t)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_ipc_event_handle_dtype_offsets(): cdef cudaIpcEventHandle_t *pod = _cyb_calloc(1, sizeof(cudaIpcEventHandle_t)) if pod == NULL: raise MemoryError("Error allocating cudaIpcEventHandle_t") try: return _numpy.dtype({ 'names': ['reserved'], 'formats': [(_numpy.int8, 64)], 'offsets': [ (&(pod.reserved)) - (pod), ], 'itemsize': sizeof(cudaIpcEventHandle_t), }) finally: _cyb_free(pod) ipc_event_handle_dtype = _get_ipc_event_handle_dtype_offsets() cdef class IpcEventHandle: """Empty-initialize an instance of `cudaIpcEventHandle_t`. .. seealso:: `cudaIpcEventHandle_t` """ cdef: cudaIpcEventHandle_t _data cudaIpcEventHandle_t *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.IpcEventHandle object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef IpcEventHandle other_ if not isinstance(other, IpcEventHandle): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaIpcEventHandle_t)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaIpcEventHandle_t), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This IpcEventHandle instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaIpcEventHandle_t): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaIpcEventHandle_t), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudaIpcEventHandle_t)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @staticmethod def from_buffer(buffer): """Create an IpcEventHandle instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaIpcEventHandle_t), IpcEventHandle) @staticmethod def from_data(data): """Create an IpcEventHandle instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `ipc_event_handle_dtype` holding the data. """ return _cyb_from_data(data, "ipc_event_handle_dtype", ipc_event_handle_dtype, IpcEventHandle) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an IpcEventHandle instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef IpcEventHandle obj = IpcEventHandle.__new__(IpcEventHandle) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudaIpcEventHandle_t)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get_ipc_mem_handle_dtype_offsets(): cdef cudaIpcMemHandle_t *pod = _cyb_calloc(1, sizeof(cudaIpcMemHandle_t)) if pod == NULL: raise MemoryError("Error allocating cudaIpcMemHandle_t") try: return _numpy.dtype({ 'names': ['reserved'], 'formats': [(_numpy.int8, 64)], 'offsets': [ (&(pod.reserved)) - (pod), ], 'itemsize': sizeof(cudaIpcMemHandle_t), }) finally: _cyb_free(pod) ipc_mem_handle_dtype = _get_ipc_mem_handle_dtype_offsets() cdef class IpcMemHandle: """Empty-initialize an instance of `cudaIpcMemHandle_t`. .. seealso:: `cudaIpcMemHandle_t` """ cdef: cudaIpcMemHandle_t _data cudaIpcMemHandle_t *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.IpcMemHandle object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef IpcMemHandle other_ if not isinstance(other, IpcMemHandle): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaIpcMemHandle_t)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaIpcMemHandle_t), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This IpcMemHandle instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaIpcMemHandle_t): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaIpcMemHandle_t), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudaIpcMemHandle_t)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @staticmethod def from_buffer(buffer): """Create an IpcMemHandle instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaIpcMemHandle_t), IpcMemHandle) @staticmethod def from_data(data): """Create an IpcMemHandle instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `ipc_mem_handle_dtype` holding the data. """ return _cyb_from_data(data, "ipc_mem_handle_dtype", ipc_mem_handle_dtype, IpcMemHandle) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an IpcMemHandle instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef IpcMemHandle obj = IpcMemHandle.__new__(IpcMemHandle) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudaIpcMemHandle_t)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get_mem_fabric_handle_dtype_offsets(): cdef cudaMemFabricHandle_t *pod = _cyb_calloc(1, sizeof(cudaMemFabricHandle_t)) if pod == NULL: raise MemoryError("Error allocating cudaMemFabricHandle_t") try: return _numpy.dtype({ 'names': ['reserved'], 'formats': [(_numpy.int8, 64)], 'offsets': [ (&(pod.reserved)) - (pod), ], 'itemsize': sizeof(cudaMemFabricHandle_t), }) finally: _cyb_free(pod) mem_fabric_handle_dtype = _get_mem_fabric_handle_dtype_offsets() cdef class MemFabricHandle: """Empty-initialize an instance of `cudaMemFabricHandle_t`. .. seealso:: `cudaMemFabricHandle_t` """ cdef: cudaMemFabricHandle_t _data cudaMemFabricHandle_t *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.MemFabricHandle object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef MemFabricHandle other_ if not isinstance(other, MemFabricHandle): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaMemFabricHandle_t)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaMemFabricHandle_t), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This MemFabricHandle instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaMemFabricHandle_t): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaMemFabricHandle_t), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudaMemFabricHandle_t)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @staticmethod def from_buffer(buffer): """Create an MemFabricHandle instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaMemFabricHandle_t), MemFabricHandle) @staticmethod def from_data(data): """Create an MemFabricHandle instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `mem_fabric_handle_dtype` holding the data. """ return _cyb_from_data(data, "mem_fabric_handle_dtype", mem_fabric_handle_dtype, MemFabricHandle) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an MemFabricHandle instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef MemFabricHandle obj = MemFabricHandle.__new__(MemFabricHandle) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudaMemFabricHandle_t)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod14_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod14 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod14)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod14") try: return _numpy.dtype({ 'names': ['handle', 'name'], 'formats': [_numpy.intp, _numpy.intp], 'offsets': [ (&(pod.handle)) - (pod), (&(pod.name)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod14), }) finally: _cyb_free(pod) _py_anon_pod14_dtype = _get__py_anon_pod14_dtype_offsets() cdef class _py_anon_pod14: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod14`. .. seealso:: `cuda_bindings_runtime__anon_pod14` """ cdef: cuda_bindings_runtime__anon_pod14 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod14)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod14") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod14 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod14 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod14 other_ if not isinstance(other, _py_anon_pod14): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod14)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod14), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod14 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod14): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod14), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod14)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def handle(self): """int: """ return (self._ptr[0].handle) @handle.setter def handle(self, val): if self._readonly: raise ValueError("This _py_anon_pod14 instance is read-only") self._ptr[0].handle = val @property def name(self): """int: """ return (self._ptr[0].name) @name.setter def name(self, val): if self._readonly: raise ValueError("This _py_anon_pod14 instance is read-only") self._ptr[0].name = val @staticmethod def from_buffer(buffer): """Create an _py_anon_pod14 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod14), _py_anon_pod14) @staticmethod def from_data(data): """Create an _py_anon_pod14 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod14_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod14_dtype", _py_anon_pod14_dtype, _py_anon_pod14) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod14 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod14 obj = _py_anon_pod14.__new__(_py_anon_pod14) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod14)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod14") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod14)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_external_memory_buffer_desc_dtype_offsets(): cdef cudaExternalMemoryBufferDesc *pod = _cyb_calloc(1, sizeof(cudaExternalMemoryBufferDesc)) if pod == NULL: raise MemoryError("Error allocating cudaExternalMemoryBufferDesc") try: return _numpy.dtype({ 'names': ['offset', 'size_', 'flags_', 'reserved'], 'formats': [_numpy.uint64, _numpy.uint64, _numpy.uint32, (_numpy.uint32, 16)], 'offsets': [ (&(pod.offset)) - (pod), (&(pod.size)) - (pod), (&(pod.flags)) - (pod), (&(pod.reserved)) - (pod), ], 'itemsize': sizeof(cudaExternalMemoryBufferDesc), }) finally: _cyb_free(pod) external_memory_buffer_desc_dtype = _get_external_memory_buffer_desc_dtype_offsets() cdef class ExternalMemoryBufferDesc: """Empty-initialize an instance of `cudaExternalMemoryBufferDesc`. .. seealso:: `cudaExternalMemoryBufferDesc` """ cdef: cudaExternalMemoryBufferDesc _data cudaExternalMemoryBufferDesc *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.ExternalMemoryBufferDesc object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef ExternalMemoryBufferDesc other_ if not isinstance(other, ExternalMemoryBufferDesc): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaExternalMemoryBufferDesc)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaExternalMemoryBufferDesc), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This ExternalMemoryBufferDesc instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaExternalMemoryBufferDesc): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaExternalMemoryBufferDesc), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudaExternalMemoryBufferDesc)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def offset(self): """int: Offset into the memory object where the buffer's base is""" return self._ptr[0].offset @offset.setter def offset(self, val): if self._readonly: raise ValueError("This ExternalMemoryBufferDesc instance is read-only") self._ptr[0].offset = val @property def size_(self): """int: Size of the buffer""" return self._ptr[0].size @size_.setter def size_(self, val): if self._readonly: raise ValueError("This ExternalMemoryBufferDesc instance is read-only") self._ptr[0].size = val @property def flags_(self): """int: Flags reserved for future use. Must be zero.""" return self._ptr[0].flags @flags_.setter def flags_(self, val): if self._readonly: raise ValueError("This ExternalMemoryBufferDesc instance is read-only") self._ptr[0].flags = val @staticmethod def from_buffer(buffer): """Create an ExternalMemoryBufferDesc instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaExternalMemoryBufferDesc), ExternalMemoryBufferDesc) @staticmethod def from_data(data): """Create an ExternalMemoryBufferDesc instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `external_memory_buffer_desc_dtype` holding the data. """ return _cyb_from_data(data, "external_memory_buffer_desc_dtype", external_memory_buffer_desc_dtype, ExternalMemoryBufferDesc) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an ExternalMemoryBufferDesc instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef ExternalMemoryBufferDesc obj = ExternalMemoryBufferDesc.__new__(ExternalMemoryBufferDesc) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudaExternalMemoryBufferDesc)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod16_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod16 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod16)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod16") try: return _numpy.dtype({ 'names': ['handle', 'name'], 'formats': [_numpy.intp, _numpy.intp], 'offsets': [ (&(pod.handle)) - (pod), (&(pod.name)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod16), }) finally: _cyb_free(pod) _py_anon_pod16_dtype = _get__py_anon_pod16_dtype_offsets() cdef class _py_anon_pod16: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod16`. .. seealso:: `cuda_bindings_runtime__anon_pod16` """ cdef: cuda_bindings_runtime__anon_pod16 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod16)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod16") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod16 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod16 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod16 other_ if not isinstance(other, _py_anon_pod16): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod16)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod16), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod16 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod16): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod16), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod16)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def handle(self): """int: """ return (self._ptr[0].handle) @handle.setter def handle(self, val): if self._readonly: raise ValueError("This _py_anon_pod16 instance is read-only") self._ptr[0].handle = val @property def name(self): """int: """ return (self._ptr[0].name) @name.setter def name(self, val): if self._readonly: raise ValueError("This _py_anon_pod16 instance is read-only") self._ptr[0].name = val @staticmethod def from_buffer(buffer): """Create an _py_anon_pod16 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod16), _py_anon_pod16) @staticmethod def from_data(data): """Create an _py_anon_pod16 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod16_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod16_dtype", _py_anon_pod16_dtype, _py_anon_pod16) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod16 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod16 obj = _py_anon_pod16.__new__(_py_anon_pod16) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod16)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod16") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod16)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod18_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod18 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod18)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod18") try: return _numpy.dtype({ 'names': ['value'], 'formats': [_numpy.uint64], 'offsets': [ (&(pod.value)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod18), }) finally: _cyb_free(pod) _py_anon_pod18_dtype = _get__py_anon_pod18_dtype_offsets() cdef class _py_anon_pod18: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod18`. .. seealso:: `cuda_bindings_runtime__anon_pod18` """ cdef: cuda_bindings_runtime__anon_pod18 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod18)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod18") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod18 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod18 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod18 other_ if not isinstance(other, _py_anon_pod18): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod18)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod18), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod18 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod18): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod18), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod18)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def value(self): """int: """ return self._ptr[0].value @value.setter def value(self, val): if self._readonly: raise ValueError("This _py_anon_pod18 instance is read-only") self._ptr[0].value = val @staticmethod def from_buffer(buffer): """Create an _py_anon_pod18 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod18), _py_anon_pod18) @staticmethod def from_data(data): """Create an _py_anon_pod18 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod18_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod18_dtype", _py_anon_pod18_dtype, _py_anon_pod18) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod18 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod18 obj = _py_anon_pod18.__new__(_py_anon_pod18) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod18)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod18") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod18)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod19_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod19 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod19)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod19") try: return _numpy.dtype({ 'names': ['fence', 'reserved'], 'formats': [_numpy.intp, _numpy.uint64], 'offsets': [ (&(pod.fence)) - (pod), (&(pod.reserved)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod19), }) finally: _cyb_free(pod) _py_anon_pod19_dtype = _get__py_anon_pod19_dtype_offsets() cdef class _py_anon_pod19: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod19`. .. seealso:: `cuda_bindings_runtime__anon_pod19` """ cdef: cuda_bindings_runtime__anon_pod19 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod19)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod19") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod19 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod19 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod19 other_ if not isinstance(other, _py_anon_pod19): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod19)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod19), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod19 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod19): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod19), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod19)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def fence(self): """int: """ return (self._ptr[0].fence) @fence.setter def fence(self, val): if self._readonly: raise ValueError("This _py_anon_pod19 instance is read-only") self._ptr[0].fence = val @staticmethod def from_buffer(buffer): """Create an _py_anon_pod19 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod19), _py_anon_pod19) @staticmethod def from_data(data): """Create an _py_anon_pod19 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod19_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod19_dtype", _py_anon_pod19_dtype, _py_anon_pod19) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod19 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod19 obj = _py_anon_pod19.__new__(_py_anon_pod19) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod19)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod19") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod19)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod20_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod20 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod20)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod20") try: return _numpy.dtype({ 'names': ['key'], 'formats': [_numpy.uint64], 'offsets': [ (&(pod.key)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod20), }) finally: _cyb_free(pod) _py_anon_pod20_dtype = _get__py_anon_pod20_dtype_offsets() cdef class _py_anon_pod20: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod20`. .. seealso:: `cuda_bindings_runtime__anon_pod20` """ cdef: cuda_bindings_runtime__anon_pod20 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod20)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod20") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod20 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod20 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod20 other_ if not isinstance(other, _py_anon_pod20): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod20)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod20), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod20 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod20): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod20), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod20)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def key(self): """int: """ return self._ptr[0].key @key.setter def key(self, val): if self._readonly: raise ValueError("This _py_anon_pod20 instance is read-only") self._ptr[0].key = val @staticmethod def from_buffer(buffer): """Create an _py_anon_pod20 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod20), _py_anon_pod20) @staticmethod def from_data(data): """Create an _py_anon_pod20 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod20_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod20_dtype", _py_anon_pod20_dtype, _py_anon_pod20) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod20 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod20 obj = _py_anon_pod20.__new__(_py_anon_pod20) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod20)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod20") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod20)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod22_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod22 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod22)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod22") try: return _numpy.dtype({ 'names': ['value'], 'formats': [_numpy.uint64], 'offsets': [ (&(pod.value)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod22), }) finally: _cyb_free(pod) _py_anon_pod22_dtype = _get__py_anon_pod22_dtype_offsets() cdef class _py_anon_pod22: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod22`. .. seealso:: `cuda_bindings_runtime__anon_pod22` """ cdef: cuda_bindings_runtime__anon_pod22 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod22)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod22") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod22 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod22 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod22 other_ if not isinstance(other, _py_anon_pod22): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod22)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod22), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod22 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod22): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod22), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod22)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def value(self): """int: """ return self._ptr[0].value @value.setter def value(self, val): if self._readonly: raise ValueError("This _py_anon_pod22 instance is read-only") self._ptr[0].value = val @staticmethod def from_buffer(buffer): """Create an _py_anon_pod22 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod22), _py_anon_pod22) @staticmethod def from_data(data): """Create an _py_anon_pod22 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod22_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod22_dtype", _py_anon_pod22_dtype, _py_anon_pod22) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod22 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod22 obj = _py_anon_pod22.__new__(_py_anon_pod22) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod22)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod22") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod22)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod23_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod23 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod23)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod23") try: return _numpy.dtype({ 'names': ['fence', 'reserved'], 'formats': [_numpy.intp, _numpy.uint64], 'offsets': [ (&(pod.fence)) - (pod), (&(pod.reserved)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod23), }) finally: _cyb_free(pod) _py_anon_pod23_dtype = _get__py_anon_pod23_dtype_offsets() cdef class _py_anon_pod23: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod23`. .. seealso:: `cuda_bindings_runtime__anon_pod23` """ cdef: cuda_bindings_runtime__anon_pod23 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod23)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod23") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod23 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod23 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod23 other_ if not isinstance(other, _py_anon_pod23): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod23)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod23), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod23 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod23): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod23), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod23)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def fence(self): """int: """ return (self._ptr[0].fence) @fence.setter def fence(self, val): if self._readonly: raise ValueError("This _py_anon_pod23 instance is read-only") self._ptr[0].fence = val @staticmethod def from_buffer(buffer): """Create an _py_anon_pod23 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod23), _py_anon_pod23) @staticmethod def from_data(data): """Create an _py_anon_pod23 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod23_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod23_dtype", _py_anon_pod23_dtype, _py_anon_pod23) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod23 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod23 obj = _py_anon_pod23.__new__(_py_anon_pod23) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod23)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod23") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod23)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod24_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod24 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod24)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod24") try: return _numpy.dtype({ 'names': ['key', 'timeout_ms'], 'formats': [_numpy.uint64, _numpy.uint32], 'offsets': [ (&(pod.key)) - (pod), (&(pod.timeoutMs)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod24), }) finally: _cyb_free(pod) _py_anon_pod24_dtype = _get__py_anon_pod24_dtype_offsets() cdef class _py_anon_pod24: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod24`. .. seealso:: `cuda_bindings_runtime__anon_pod24` """ cdef: cuda_bindings_runtime__anon_pod24 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod24)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod24") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod24 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod24 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod24 other_ if not isinstance(other, _py_anon_pod24): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod24)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod24), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod24 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod24): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod24), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod24)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def key(self): """int: """ return self._ptr[0].key @key.setter def key(self, val): if self._readonly: raise ValueError("This _py_anon_pod24 instance is read-only") self._ptr[0].key = val @property def timeout_ms(self): """int: """ return self._ptr[0].timeoutMs @timeout_ms.setter def timeout_ms(self, val): if self._readonly: raise ValueError("This _py_anon_pod24 instance is read-only") self._ptr[0].timeoutMs = val @staticmethod def from_buffer(buffer): """Create an _py_anon_pod24 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod24), _py_anon_pod24) @staticmethod def from_data(data): """Create an _py_anon_pod24 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod24_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod24_dtype", _py_anon_pod24_dtype, _py_anon_pod24) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod24 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod24 obj = _py_anon_pod24.__new__(_py_anon_pod24) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod24)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod24") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod24)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_library_host_universal_function_and_data_table_dtype_offsets(): cdef cudalibraryHostUniversalFunctionAndDataTable *pod = _cyb_calloc(1, sizeof(cudalibraryHostUniversalFunctionAndDataTable)) if pod == NULL: raise MemoryError("Error allocating cudalibraryHostUniversalFunctionAndDataTable") try: return _numpy.dtype({ 'names': ['function_table', 'function_window_size', 'data_table', 'data_window_size'], 'formats': [_numpy.intp, _numpy.uint64, _numpy.intp, _numpy.uint64], 'offsets': [ (&(pod.functionTable)) - (pod), (&(pod.functionWindowSize)) - (pod), (&(pod.dataTable)) - (pod), (&(pod.dataWindowSize)) - (pod), ], 'itemsize': sizeof(cudalibraryHostUniversalFunctionAndDataTable), }) finally: _cyb_free(pod) library_host_universal_function_and_data_table_dtype = _get_library_host_universal_function_and_data_table_dtype_offsets() cdef class LibraryHostUniversalFunctionAndDataTable: """Empty-initialize an instance of `cudalibraryHostUniversalFunctionAndDataTable`. .. seealso:: `cudalibraryHostUniversalFunctionAndDataTable` """ cdef: cudalibraryHostUniversalFunctionAndDataTable _data cudalibraryHostUniversalFunctionAndDataTable *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.LibraryHostUniversalFunctionAndDataTable object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef LibraryHostUniversalFunctionAndDataTable other_ if not isinstance(other, LibraryHostUniversalFunctionAndDataTable): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudalibraryHostUniversalFunctionAndDataTable)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudalibraryHostUniversalFunctionAndDataTable), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This LibraryHostUniversalFunctionAndDataTable instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudalibraryHostUniversalFunctionAndDataTable): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudalibraryHostUniversalFunctionAndDataTable), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudalibraryHostUniversalFunctionAndDataTable)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def function_table(self): """int: """ return (self._ptr[0].functionTable) @function_table.setter def function_table(self, val): if self._readonly: raise ValueError("This LibraryHostUniversalFunctionAndDataTable instance is read-only") self._ptr[0].functionTable = val @property def function_window_size(self): """int: """ return self._ptr[0].functionWindowSize @function_window_size.setter def function_window_size(self, val): if self._readonly: raise ValueError("This LibraryHostUniversalFunctionAndDataTable instance is read-only") self._ptr[0].functionWindowSize = val @property def data_table(self): """int: """ return (self._ptr[0].dataTable) @data_table.setter def data_table(self, val): if self._readonly: raise ValueError("This LibraryHostUniversalFunctionAndDataTable instance is read-only") self._ptr[0].dataTable = val @property def data_window_size(self): """int: """ return self._ptr[0].dataWindowSize @data_window_size.setter def data_window_size(self, val): if self._readonly: raise ValueError("This LibraryHostUniversalFunctionAndDataTable instance is read-only") self._ptr[0].dataWindowSize = val @staticmethod def from_buffer(buffer): """Create an LibraryHostUniversalFunctionAndDataTable instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudalibraryHostUniversalFunctionAndDataTable), LibraryHostUniversalFunctionAndDataTable) @staticmethod def from_data(data): """Create an LibraryHostUniversalFunctionAndDataTable instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `library_host_universal_function_and_data_table_dtype` holding the data. """ return _cyb_from_data(data, "library_host_universal_function_and_data_table_dtype", library_host_universal_function_and_data_table_dtype, LibraryHostUniversalFunctionAndDataTable) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an LibraryHostUniversalFunctionAndDataTable instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef LibraryHostUniversalFunctionAndDataTable obj = LibraryHostUniversalFunctionAndDataTable.__new__(LibraryHostUniversalFunctionAndDataTable) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudalibraryHostUniversalFunctionAndDataTable)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get_conditional_node_params_dtype_offsets(): cdef cudaConditionalNodeParams *pod = _cyb_calloc(1, sizeof(cudaConditionalNodeParams)) if pod == NULL: raise MemoryError("Error allocating cudaConditionalNodeParams") try: return _numpy.dtype({ 'names': ['handle', 'type', 'size_', 'ph_graph_out', 'ctx'], 'formats': [_numpy.uint64, _numpy.int32, _numpy.uint32, _numpy.intp, _numpy.intp], 'offsets': [ (&(pod.handle)) - (pod), (&(pod.type)) - (pod), (&(pod.size)) - (pod), (&(pod.phGraph_out)) - (pod), (&(pod.ctx)) - (pod), ], 'itemsize': sizeof(cudaConditionalNodeParams), }) finally: _cyb_free(pod) conditional_node_params_dtype = _get_conditional_node_params_dtype_offsets() cdef class ConditionalNodeParams: """Empty-initialize an instance of `cudaConditionalNodeParams`. .. seealso:: `cudaConditionalNodeParams` """ cdef: cudaConditionalNodeParams *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cudaConditionalNodeParams)) if self._ptr == NULL: raise MemoryError("Error allocating ConditionalNodeParams") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cudaConditionalNodeParams *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.ConditionalNodeParams object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef ConditionalNodeParams other_ if not isinstance(other, ConditionalNodeParams): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaConditionalNodeParams)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaConditionalNodeParams), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This ConditionalNodeParams instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaConditionalNodeParams): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaConditionalNodeParams), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cudaConditionalNodeParams)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def handle(self): """int: Conditional node handle. Handles must be created in advance of creating the node using cudaGraphConditionalHandleCreate.""" return (self._ptr[0].handle) @handle.setter def handle(self, val): if self._readonly: raise ValueError("This ConditionalNodeParams instance is read-only") self._ptr[0].handle = val @property def type(self): """int: Type of conditional node.""" return (self._ptr[0].type) @type.setter def type(self, val): if self._readonly: raise ValueError("This ConditionalNodeParams instance is read-only") self._ptr[0].type = val @property def size_(self): """int: Size of graph output array. Allowed values are 1 for cudaGraphCondTypeWhile, 1 or 2 for cudaGraphCondTypeIf, or any value greater than zero for cudaGraphCondTypeSwitch.""" return self._ptr[0].size @size_.setter def size_(self, val): if self._readonly: raise ValueError("This ConditionalNodeParams instance is read-only") self._ptr[0].size = val @property def ph_graph_out(self): """int: CUDA-owned array populated with conditional node child graphs during creation of the node. Valid for the lifetime of the conditional node. The contents of the graph(s) are subject to the following constraints: - Allowed node types are kernel nodes, empty nodes, child graphs, memsets, memcopies, and conditionals. This applies recursively to child graphs and conditional bodies. - All kernels, including kernels in nested conditionals or child graphs at any level, must belong to the same device context. These graphs may be populated using graph node creation APIs or cudaStreamBeginCaptureToGraph. cudaGraphCondTypeIf: phGraph_out[0] is executed when the condition is non-zero. If ``size`` == 2, phGraph_out[1] will be executed when the condition is zero. cudaGraphCondTypeWhile: phGraph_out[0] is executed as long as the condition is non-zero. cudaGraphCondTypeSwitch: phGraph_out[n] is executed when the condition is equal to n. If the condition >= ``size``, no body graph is executed.""" return (self._ptr[0].phGraph_out) @ph_graph_out.setter def ph_graph_out(self, val): if self._readonly: raise ValueError("This ConditionalNodeParams instance is read-only") self._ptr[0].phGraph_out = val @property def ctx(self): """int: CUDA Execution Context""" return (self._ptr[0].ctx) @ctx.setter def ctx(self, val): if self._readonly: raise ValueError("This ConditionalNodeParams instance is read-only") self._ptr[0].ctx = val @staticmethod def from_buffer(buffer): """Create an ConditionalNodeParams instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaConditionalNodeParams), ConditionalNodeParams) @staticmethod def from_data(data): """Create an ConditionalNodeParams instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `conditional_node_params_dtype` holding the data. """ return _cyb_from_data(data, "conditional_node_params_dtype", conditional_node_params_dtype, ConditionalNodeParams) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an ConditionalNodeParams instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef ConditionalNodeParams obj = ConditionalNodeParams.__new__(ConditionalNodeParams) if owner is None: obj._ptr = _cyb_malloc(sizeof(cudaConditionalNodeParams)) if obj._ptr == NULL: raise MemoryError("Error allocating ConditionalNodeParams") _cyb_memcpy((obj._ptr), ptr, sizeof(cudaConditionalNodeParams)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_child_graph_node_params_dtype_offsets(): cdef cudaChildGraphNodeParams *pod = _cyb_calloc(1, sizeof(cudaChildGraphNodeParams)) if pod == NULL: raise MemoryError("Error allocating cudaChildGraphNodeParams") try: return _numpy.dtype({ 'names': ['graph', 'ownership'], 'formats': [_numpy.intp, _numpy.int32], 'offsets': [ (&(pod.graph)) - (pod), (&(pod.ownership)) - (pod), ], 'itemsize': sizeof(cudaChildGraphNodeParams), }) finally: _cyb_free(pod) child_graph_node_params_dtype = _get_child_graph_node_params_dtype_offsets() cdef class ChildGraphNodeParams: """Empty-initialize an instance of `cudaChildGraphNodeParams`. .. seealso:: `cudaChildGraphNodeParams` """ cdef: cudaChildGraphNodeParams *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cudaChildGraphNodeParams)) if self._ptr == NULL: raise MemoryError("Error allocating ChildGraphNodeParams") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cudaChildGraphNodeParams *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.ChildGraphNodeParams object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef ChildGraphNodeParams other_ if not isinstance(other, ChildGraphNodeParams): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaChildGraphNodeParams)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaChildGraphNodeParams), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This ChildGraphNodeParams instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaChildGraphNodeParams): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaChildGraphNodeParams), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cudaChildGraphNodeParams)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def graph(self): """int: The child graph to clone into the node for node creation, or a handle to the graph owned by the node for node query. The graph must not contain conditional nodes. Graphs containing memory allocation or memory free nodes must set the ownership to be moved to the parent.""" return (self._ptr[0].graph) @graph.setter def graph(self, val): if self._readonly: raise ValueError("This ChildGraphNodeParams instance is read-only") self._ptr[0].graph = val @property def ownership(self): """int: The ownership relationship of the child graph node.""" return (self._ptr[0].ownership) @ownership.setter def ownership(self, val): if self._readonly: raise ValueError("This ChildGraphNodeParams instance is read-only") self._ptr[0].ownership = val @staticmethod def from_buffer(buffer): """Create an ChildGraphNodeParams instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaChildGraphNodeParams), ChildGraphNodeParams) @staticmethod def from_data(data): """Create an ChildGraphNodeParams instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `child_graph_node_params_dtype` holding the data. """ return _cyb_from_data(data, "child_graph_node_params_dtype", child_graph_node_params_dtype, ChildGraphNodeParams) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an ChildGraphNodeParams instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef ChildGraphNodeParams obj = ChildGraphNodeParams.__new__(ChildGraphNodeParams) if owner is None: obj._ptr = _cyb_malloc(sizeof(cudaChildGraphNodeParams)) if obj._ptr == NULL: raise MemoryError("Error allocating ChildGraphNodeParams") _cyb_memcpy((obj._ptr), ptr, sizeof(cudaChildGraphNodeParams)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_event_record_node_params_dtype_offsets(): cdef cudaEventRecordNodeParams *pod = _cyb_calloc(1, sizeof(cudaEventRecordNodeParams)) if pod == NULL: raise MemoryError("Error allocating cudaEventRecordNodeParams") try: return _numpy.dtype({ 'names': ['event', 'ctx'], 'formats': [_numpy.intp, _numpy.intp], 'offsets': [ (&(pod.event)) - (pod), (&(pod.ctx)) - (pod), ], 'itemsize': sizeof(cudaEventRecordNodeParams), }) finally: _cyb_free(pod) event_record_node_params_dtype = _get_event_record_node_params_dtype_offsets() cdef class EventRecordNodeParams: """Empty-initialize an instance of `cudaEventRecordNodeParams`. .. seealso:: `cudaEventRecordNodeParams` """ cdef: cudaEventRecordNodeParams *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cudaEventRecordNodeParams)) if self._ptr == NULL: raise MemoryError("Error allocating EventRecordNodeParams") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cudaEventRecordNodeParams *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.EventRecordNodeParams object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef EventRecordNodeParams other_ if not isinstance(other, EventRecordNodeParams): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaEventRecordNodeParams)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaEventRecordNodeParams), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This EventRecordNodeParams instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaEventRecordNodeParams): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaEventRecordNodeParams), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cudaEventRecordNodeParams)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def event(self): """int: The event to record when the node executes""" return (self._ptr[0].event) @event.setter def event(self, val): if self._readonly: raise ValueError("This EventRecordNodeParams instance is read-only") self._ptr[0].event = val @property def ctx(self): """int: CUDA Execution Context""" return (self._ptr[0].ctx) @ctx.setter def ctx(self, val): if self._readonly: raise ValueError("This EventRecordNodeParams instance is read-only") self._ptr[0].ctx = val @staticmethod def from_buffer(buffer): """Create an EventRecordNodeParams instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaEventRecordNodeParams), EventRecordNodeParams) @staticmethod def from_data(data): """Create an EventRecordNodeParams instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `event_record_node_params_dtype` holding the data. """ return _cyb_from_data(data, "event_record_node_params_dtype", event_record_node_params_dtype, EventRecordNodeParams) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an EventRecordNodeParams instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef EventRecordNodeParams obj = EventRecordNodeParams.__new__(EventRecordNodeParams) if owner is None: obj._ptr = _cyb_malloc(sizeof(cudaEventRecordNodeParams)) if obj._ptr == NULL: raise MemoryError("Error allocating EventRecordNodeParams") _cyb_memcpy((obj._ptr), ptr, sizeof(cudaEventRecordNodeParams)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_event_wait_node_params_dtype_offsets(): cdef cudaEventWaitNodeParams *pod = _cyb_calloc(1, sizeof(cudaEventWaitNodeParams)) if pod == NULL: raise MemoryError("Error allocating cudaEventWaitNodeParams") try: return _numpy.dtype({ 'names': ['event'], 'formats': [_numpy.intp], 'offsets': [ (&(pod.event)) - (pod), ], 'itemsize': sizeof(cudaEventWaitNodeParams), }) finally: _cyb_free(pod) event_wait_node_params_dtype = _get_event_wait_node_params_dtype_offsets() cdef class EventWaitNodeParams: """Empty-initialize an instance of `cudaEventWaitNodeParams`. .. seealso:: `cudaEventWaitNodeParams` """ cdef: cudaEventWaitNodeParams *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cudaEventWaitNodeParams)) if self._ptr == NULL: raise MemoryError("Error allocating EventWaitNodeParams") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cudaEventWaitNodeParams *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.EventWaitNodeParams object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef EventWaitNodeParams other_ if not isinstance(other, EventWaitNodeParams): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaEventWaitNodeParams)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaEventWaitNodeParams), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This EventWaitNodeParams instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaEventWaitNodeParams): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaEventWaitNodeParams), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cudaEventWaitNodeParams)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def event(self): """int: The event to wait on from the node""" return (self._ptr[0].event) @event.setter def event(self, val): if self._readonly: raise ValueError("This EventWaitNodeParams instance is read-only") self._ptr[0].event = val @staticmethod def from_buffer(buffer): """Create an EventWaitNodeParams instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaEventWaitNodeParams), EventWaitNodeParams) @staticmethod def from_data(data): """Create an EventWaitNodeParams instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `event_wait_node_params_dtype` holding the data. """ return _cyb_from_data(data, "event_wait_node_params_dtype", event_wait_node_params_dtype, EventWaitNodeParams) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an EventWaitNodeParams instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef EventWaitNodeParams obj = EventWaitNodeParams.__new__(EventWaitNodeParams) if owner is None: obj._ptr = _cyb_malloc(sizeof(cudaEventWaitNodeParams)) if obj._ptr == NULL: raise MemoryError("Error allocating EventWaitNodeParams") _cyb_memcpy((obj._ptr), ptr, sizeof(cudaEventWaitNodeParams)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_graph_edge_data_dtype_offsets(): cdef cudaGraphEdgeData *pod = _cyb_calloc(1, sizeof(cudaGraphEdgeData)) if pod == NULL: raise MemoryError("Error allocating cudaGraphEdgeData") try: return _numpy.dtype({ 'names': ['from_port', 'to_port', 'type', 'reserved'], 'formats': [_numpy.uint8, _numpy.uint8, _numpy.uint8, (_numpy.uint8, 5)], 'offsets': [ (&(pod.from_port)) - (pod), (&(pod.to_port)) - (pod), (&(pod.type)) - (pod), (&(pod.reserved)) - (pod), ], 'itemsize': sizeof(cudaGraphEdgeData), }) finally: _cyb_free(pod) graph_edge_data_dtype = _get_graph_edge_data_dtype_offsets() cdef object graph_edge_data_dtype_record = _numpy.dtype((_numpy.record, graph_edge_data_dtype)) cdef class GraphEdgeData: """Empty-initialize an array of `cudaGraphEdgeData`. The resulting object is of length `size` and of dtype `graph_edge_data_dtype`. If default-constructed, the instance represents a single struct. Args: size (int): number of structs, default=1. .. seealso:: `cudaGraphEdgeData` """ cdef: readonly object _data object _owner def __init__(self, size=1): self._data = _numpy.zeros(size, dtype=graph_edge_data_dtype_record) assert self._data.itemsize == sizeof(cudaGraphEdgeData), \ f"itemsize {self._data.itemsize} mismatches struct size { sizeof(cudaGraphEdgeData) }" def __repr__(self): if self._data.size > 1: return f"<{__name__}.GraphEdgeData_Array_{self._data.size} object at {hex(id(self))}>" else: return f"<{__name__}.GraphEdgeData object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return _cyb_array_ptr(self._data) cdef intptr_t _get_ptr(self): return _cyb_array_ptr(self._data) def __int__(self): if self._data.size > 1 and not self._data.flags["C_CONTIGUOUS"]: raise TypeError("int() argument must be a bytes-like object of size 1, or a " "C-contiguous array. To get the pointer address of a " "non-contiguous array, use .ptr") return _cyb_array_ptr(self._data) def __len__(self): return self._data.size def __eq__(self, other): cdef object self_data = self._data if (not isinstance(other, GraphEdgeData)) or self_data.size != other._data.size or self_data.dtype != other._data.dtype: return False return bool((self_data == other._data).all()) def __getbuffer__(self, Py_buffer *buffer, int flags): _cyb_cpython.PyObject_GetBuffer(self._data, buffer, flags) def __releasebuffer__(self, Py_buffer *buffer): _cyb_cpython.PyBuffer_Release(buffer) @property def from_port(self): """Union[~_numpy.uint8, int]: """ if self._data.size == 1: return int(self._data["from_port"][0]) return self._data["from_port"] @from_port.setter def from_port(self, val): if not self._data.flags.writeable: raise ValueError("This GraphEdgeData instance is read-only") self._data["from_port"] = val @property def to_port(self): """Union[~_numpy.uint8, int]: """ if self._data.size == 1: return int(self._data["to_port"][0]) return self._data["to_port"] @to_port.setter def to_port(self, val): if not self._data.flags.writeable: raise ValueError("This GraphEdgeData instance is read-only") self._data["to_port"] = val @property def type(self): """Union[~_numpy.uint8, int]: """ if self._data.size == 1: return int(self._data["type"][0]) return self._data["type"] @type.setter def type(self, val): if not self._data.flags.writeable: raise ValueError("This GraphEdgeData instance is read-only") self._data["type"] = val def __getitem__(self, key): cdef ssize_t key_ cdef ssize_t size cdef GraphEdgeData obj if isinstance(key, int): key_ = key size = self._data.size if key_ >= size or key_ <= -(size+1): raise IndexError("index is out of bounds") if key_ < 0: key_ += size obj = GraphEdgeData.__new__(GraphEdgeData) obj._data = self._data[key_:key_+1] obj._owner = self._owner return obj out = self._data[key] if isinstance(out, _numpy.ndarray): if out.dtype == graph_edge_data_dtype: obj = GraphEdgeData.from_data(out) obj._owner = self._owner return obj if out.dtype.names is not None: return out.view(_numpy.recarray) return out def __setitem__(self, key, val): self._data[key] = val @staticmethod def from_buffer(buffer): """Create an GraphEdgeData instance with the memory from the given buffer.""" return GraphEdgeData.from_data(_numpy.frombuffer(buffer, dtype=graph_edge_data_dtype)) @staticmethod def from_data(data): """Create an GraphEdgeData instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a 1D array of dtype `graph_edge_data_dtype` holding the data. """ cdef GraphEdgeData obj = GraphEdgeData.__new__(GraphEdgeData) if not isinstance(data, _numpy.ndarray): raise TypeError("data argument must be a NumPy ndarray") if data.ndim != 1: raise ValueError("data array must be 1D") if data.dtype != graph_edge_data_dtype: raise ValueError("data array must be of dtype graph_edge_data_dtype") obj._data = data.view(dtype=graph_edge_data_dtype_record, type=_numpy.ndarray) return obj @staticmethod def from_ptr(intptr_t ptr, size_t size=1, bint readonly=False, object owner=None): """Create an GraphEdgeData instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. size (int): number of structs, default=1. readonly (bool): whether the data is read-only (to the user). default is `False`. owner (object): object that owns the memory at *ptr*. A strong reference is kept, by this wrapper and by every NumPy view of its data, so the backing storage outlives them. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef GraphEdgeData obj = GraphEdgeData.__new__(GraphEdgeData) cdef _cyb_MemoryHolder buf = _cyb_MemoryHolder(ptr, sizeof(cudaGraphEdgeData) * size, readonly, owner) obj._data = _numpy.ndarray(size, buffer=buf, dtype=graph_edge_data_dtype_record) obj._owner = owner return obj cdef _get_graph_instantiate_params_dtype_offsets(): cdef cudaGraphInstantiateParams *pod = _cyb_calloc(1, sizeof(cudaGraphInstantiateParams)) if pod == NULL: raise MemoryError("Error allocating cudaGraphInstantiateParams") try: return _numpy.dtype({ 'names': ['flags_', 'upload_stream', 'err_node_out', 'result_out'], 'formats': [_numpy.uint64, _numpy.intp, _numpy.intp, _numpy.int32], 'offsets': [ (&(pod.flags)) - (pod), (&(pod.uploadStream)) - (pod), (&(pod.errNode_out)) - (pod), (&(pod.result_out)) - (pod), ], 'itemsize': sizeof(cudaGraphInstantiateParams), }) finally: _cyb_free(pod) graph_instantiate_params_dtype = _get_graph_instantiate_params_dtype_offsets() cdef class GraphInstantiateParams: """Empty-initialize an instance of `cudaGraphInstantiateParams`. .. seealso:: `cudaGraphInstantiateParams` """ cdef: cudaGraphInstantiateParams _data cudaGraphInstantiateParams *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.GraphInstantiateParams object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef GraphInstantiateParams other_ if not isinstance(other, GraphInstantiateParams): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaGraphInstantiateParams)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaGraphInstantiateParams), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This GraphInstantiateParams instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaGraphInstantiateParams): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaGraphInstantiateParams), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudaGraphInstantiateParams)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def flags_(self): """int: """ return self._ptr[0].flags @flags_.setter def flags_(self, val): if self._readonly: raise ValueError("This GraphInstantiateParams instance is read-only") self._ptr[0].flags = val @property def upload_stream(self): """int: """ return (self._ptr[0].uploadStream) @upload_stream.setter def upload_stream(self, val): if self._readonly: raise ValueError("This GraphInstantiateParams instance is read-only") self._ptr[0].uploadStream = val @property def err_node_out(self): """int: """ return (self._ptr[0].errNode_out) @err_node_out.setter def err_node_out(self, val): if self._readonly: raise ValueError("This GraphInstantiateParams instance is read-only") self._ptr[0].errNode_out = val @property def result_out(self): """int: """ return (self._ptr[0].result_out) @result_out.setter def result_out(self, val): if self._readonly: raise ValueError("This GraphInstantiateParams instance is read-only") self._ptr[0].result_out = val @staticmethod def from_buffer(buffer): """Create an GraphInstantiateParams instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaGraphInstantiateParams), GraphInstantiateParams) @staticmethod def from_data(data): """Create an GraphInstantiateParams instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `graph_instantiate_params_dtype` holding the data. """ return _cyb_from_data(data, "graph_instantiate_params_dtype", graph_instantiate_params_dtype, GraphInstantiateParams) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an GraphInstantiateParams instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef GraphInstantiateParams obj = GraphInstantiateParams.__new__(GraphInstantiateParams) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudaGraphInstantiateParams)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get_graph_exec_update_result_info_dtype_offsets(): cdef cudaGraphExecUpdateResultInfo *pod = _cyb_calloc(1, sizeof(cudaGraphExecUpdateResultInfo)) if pod == NULL: raise MemoryError("Error allocating cudaGraphExecUpdateResultInfo") try: return _numpy.dtype({ 'names': ['result', 'error_node', 'error_from_node'], 'formats': [_numpy.int32, _numpy.intp, _numpy.intp], 'offsets': [ (&(pod.result)) - (pod), (&(pod.errorNode)) - (pod), (&(pod.errorFromNode)) - (pod), ], 'itemsize': sizeof(cudaGraphExecUpdateResultInfo), }) finally: _cyb_free(pod) graph_exec_update_result_info_dtype = _get_graph_exec_update_result_info_dtype_offsets() cdef class GraphExecUpdateResultInfo: """Empty-initialize an instance of `cudaGraphExecUpdateResultInfo`. .. seealso:: `cudaGraphExecUpdateResultInfo` """ cdef: cudaGraphExecUpdateResultInfo _data cudaGraphExecUpdateResultInfo *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.GraphExecUpdateResultInfo object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef GraphExecUpdateResultInfo other_ if not isinstance(other, GraphExecUpdateResultInfo): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaGraphExecUpdateResultInfo)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaGraphExecUpdateResultInfo), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This GraphExecUpdateResultInfo instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaGraphExecUpdateResultInfo): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaGraphExecUpdateResultInfo), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudaGraphExecUpdateResultInfo)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def result(self): """int: """ return (self._ptr[0].result) @result.setter def result(self, val): if self._readonly: raise ValueError("This GraphExecUpdateResultInfo instance is read-only") self._ptr[0].result = val @property def error_node(self): """int: """ return (self._ptr[0].errorNode) @error_node.setter def error_node(self, val): if self._readonly: raise ValueError("This GraphExecUpdateResultInfo instance is read-only") self._ptr[0].errorNode = val @property def error_from_node(self): """int: """ return (self._ptr[0].errorFromNode) @error_from_node.setter def error_from_node(self, val): if self._readonly: raise ValueError("This GraphExecUpdateResultInfo instance is read-only") self._ptr[0].errorFromNode = val @staticmethod def from_buffer(buffer): """Create an GraphExecUpdateResultInfo instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaGraphExecUpdateResultInfo), GraphExecUpdateResultInfo) @staticmethod def from_data(data): """Create an GraphExecUpdateResultInfo instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `graph_exec_update_result_info_dtype` holding the data. """ return _cyb_from_data(data, "graph_exec_update_result_info_dtype", graph_exec_update_result_info_dtype, GraphExecUpdateResultInfo) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an GraphExecUpdateResultInfo instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef GraphExecUpdateResultInfo obj = GraphExecUpdateResultInfo.__new__(GraphExecUpdateResultInfo) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudaGraphExecUpdateResultInfo)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod28_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod28 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod28)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod28") try: return _numpy.dtype({ 'names': ['p_value', 'offset', 'size_'], 'formats': [_numpy.intp, _numpy.uint64, _numpy.uint64], 'offsets': [ (&(pod.pValue)) - (pod), (&(pod.offset)) - (pod), (&(pod.size)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod28), }) finally: _cyb_free(pod) _py_anon_pod28_dtype = _get__py_anon_pod28_dtype_offsets() cdef class _py_anon_pod28: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod28`. .. seealso:: `cuda_bindings_runtime__anon_pod28` """ cdef: cuda_bindings_runtime__anon_pod28 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod28)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod28") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod28 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod28 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod28 other_ if not isinstance(other, _py_anon_pod28): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod28)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod28), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod28 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod28): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod28), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod28)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def p_value(self): """int: """ return (self._ptr[0].pValue) @p_value.setter def p_value(self, val): if self._readonly: raise ValueError("This _py_anon_pod28 instance is read-only") self._ptr[0].pValue = val @property def offset(self): """int: """ return self._ptr[0].offset @offset.setter def offset(self, val): if self._readonly: raise ValueError("This _py_anon_pod28 instance is read-only") self._ptr[0].offset = val @property def size_(self): """int: """ return self._ptr[0].size @size_.setter def size_(self, val): if self._readonly: raise ValueError("This _py_anon_pod28 instance is read-only") self._ptr[0].size = val @staticmethod def from_buffer(buffer): """Create an _py_anon_pod28 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod28), _py_anon_pod28) @staticmethod def from_data(data): """Create an _py_anon_pod28 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod28_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod28_dtype", _py_anon_pod28_dtype, _py_anon_pod28) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod28 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod28 obj = _py_anon_pod28.__new__(_py_anon_pod28) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod28)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod28") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod28)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_launch_mem_sync_domain_map_dtype_offsets(): cdef cudaLaunchMemSyncDomainMap *pod = _cyb_calloc(1, sizeof(cudaLaunchMemSyncDomainMap)) if pod == NULL: raise MemoryError("Error allocating cudaLaunchMemSyncDomainMap") try: return _numpy.dtype({ 'names': ['default_', 'remote'], 'formats': [_numpy.uint8, _numpy.uint8], 'offsets': [ (&(pod.default_)) - (pod), (&(pod.remote)) - (pod), ], 'itemsize': sizeof(cudaLaunchMemSyncDomainMap), }) finally: _cyb_free(pod) launch_mem_sync_domain_map_dtype = _get_launch_mem_sync_domain_map_dtype_offsets() cdef class LaunchMemSyncDomainMap: """Empty-initialize an instance of `cudaLaunchMemSyncDomainMap`. .. seealso:: `cudaLaunchMemSyncDomainMap` """ cdef: cudaLaunchMemSyncDomainMap *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cudaLaunchMemSyncDomainMap)) if self._ptr == NULL: raise MemoryError("Error allocating LaunchMemSyncDomainMap") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cudaLaunchMemSyncDomainMap *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.LaunchMemSyncDomainMap object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef LaunchMemSyncDomainMap other_ if not isinstance(other, LaunchMemSyncDomainMap): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaLaunchMemSyncDomainMap)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaLaunchMemSyncDomainMap), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This LaunchMemSyncDomainMap instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaLaunchMemSyncDomainMap): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaLaunchMemSyncDomainMap), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cudaLaunchMemSyncDomainMap)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def default_(self): """int: """ return self._ptr[0].default_ @default_.setter def default_(self, val): if self._readonly: raise ValueError("This LaunchMemSyncDomainMap instance is read-only") self._ptr[0].default_ = val @property def remote(self): """int: """ return self._ptr[0].remote @remote.setter def remote(self, val): if self._readonly: raise ValueError("This LaunchMemSyncDomainMap instance is read-only") self._ptr[0].remote = val @staticmethod def from_buffer(buffer): """Create an LaunchMemSyncDomainMap instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaLaunchMemSyncDomainMap), LaunchMemSyncDomainMap) @staticmethod def from_data(data): """Create an LaunchMemSyncDomainMap instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `launch_mem_sync_domain_map_dtype` holding the data. """ return _cyb_from_data(data, "launch_mem_sync_domain_map_dtype", launch_mem_sync_domain_map_dtype, LaunchMemSyncDomainMap) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an LaunchMemSyncDomainMap instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef LaunchMemSyncDomainMap obj = LaunchMemSyncDomainMap.__new__(LaunchMemSyncDomainMap) if owner is None: obj._ptr = _cyb_malloc(sizeof(cudaLaunchMemSyncDomainMap)) if obj._ptr == NULL: raise MemoryError("Error allocating LaunchMemSyncDomainMap") _cyb_memcpy((obj._ptr), ptr, sizeof(cudaLaunchMemSyncDomainMap)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod29_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod29 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod29)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod29") try: return _numpy.dtype({ 'names': ['x', 'y', 'z'], 'formats': [_numpy.uint32, _numpy.uint32, _numpy.uint32], 'offsets': [ (&(pod.x)) - (pod), (&(pod.y)) - (pod), (&(pod.z)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod29), }) finally: _cyb_free(pod) _py_anon_pod29_dtype = _get__py_anon_pod29_dtype_offsets() cdef class _py_anon_pod29: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod29`. .. seealso:: `cuda_bindings_runtime__anon_pod29` """ cdef: cuda_bindings_runtime__anon_pod29 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod29)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod29") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod29 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod29 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod29 other_ if not isinstance(other, _py_anon_pod29): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod29)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod29), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod29 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod29): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod29), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod29)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def x(self): """int: """ return self._ptr[0].x @x.setter def x(self, val): if self._readonly: raise ValueError("This _py_anon_pod29 instance is read-only") self._ptr[0].x = val @property def y(self): """int: """ return self._ptr[0].y @y.setter def y(self, val): if self._readonly: raise ValueError("This _py_anon_pod29 instance is read-only") self._ptr[0].y = val @property def z(self): """int: """ return self._ptr[0].z @z.setter def z(self, val): if self._readonly: raise ValueError("This _py_anon_pod29 instance is read-only") self._ptr[0].z = val @staticmethod def from_buffer(buffer): """Create an _py_anon_pod29 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod29), _py_anon_pod29) @staticmethod def from_data(data): """Create an _py_anon_pod29 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod29_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod29_dtype", _py_anon_pod29_dtype, _py_anon_pod29) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod29 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod29 obj = _py_anon_pod29.__new__(_py_anon_pod29) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod29)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod29") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod29)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod30_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod30 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod30)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod30") try: return _numpy.dtype({ 'names': ['event', 'flags_', 'trigger_at_block_start'], 'formats': [_numpy.intp, _numpy.int32, _numpy.int32], 'offsets': [ (&(pod.event)) - (pod), (&(pod.flags)) - (pod), (&(pod.triggerAtBlockStart)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod30), }) finally: _cyb_free(pod) _py_anon_pod30_dtype = _get__py_anon_pod30_dtype_offsets() cdef class _py_anon_pod30: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod30`. .. seealso:: `cuda_bindings_runtime__anon_pod30` """ cdef: cuda_bindings_runtime__anon_pod30 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod30)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod30") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod30 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod30 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod30 other_ if not isinstance(other, _py_anon_pod30): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod30)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod30), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod30 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod30): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod30), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod30)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def event(self): """int: """ return (self._ptr[0].event) @event.setter def event(self, val): if self._readonly: raise ValueError("This _py_anon_pod30 instance is read-only") self._ptr[0].event = val @property def flags_(self): """int: """ return self._ptr[0].flags @flags_.setter def flags_(self, val): if self._readonly: raise ValueError("This _py_anon_pod30 instance is read-only") self._ptr[0].flags = val @property def trigger_at_block_start(self): """int: """ return self._ptr[0].triggerAtBlockStart @trigger_at_block_start.setter def trigger_at_block_start(self, val): if self._readonly: raise ValueError("This _py_anon_pod30 instance is read-only") self._ptr[0].triggerAtBlockStart = val @staticmethod def from_buffer(buffer): """Create an _py_anon_pod30 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod30), _py_anon_pod30) @staticmethod def from_data(data): """Create an _py_anon_pod30 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod30_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod30_dtype", _py_anon_pod30_dtype, _py_anon_pod30) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod30 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod30 obj = _py_anon_pod30.__new__(_py_anon_pod30) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod30)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod30") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod30)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod31_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod31 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod31)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod31") try: return _numpy.dtype({ 'names': ['x', 'y', 'z'], 'formats': [_numpy.uint32, _numpy.uint32, _numpy.uint32], 'offsets': [ (&(pod.x)) - (pod), (&(pod.y)) - (pod), (&(pod.z)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod31), }) finally: _cyb_free(pod) _py_anon_pod31_dtype = _get__py_anon_pod31_dtype_offsets() cdef class _py_anon_pod31: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod31`. .. seealso:: `cuda_bindings_runtime__anon_pod31` """ cdef: cuda_bindings_runtime__anon_pod31 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod31)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod31") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod31 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod31 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod31 other_ if not isinstance(other, _py_anon_pod31): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod31)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod31), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod31 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod31): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod31), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod31)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def x(self): """int: """ return self._ptr[0].x @x.setter def x(self, val): if self._readonly: raise ValueError("This _py_anon_pod31 instance is read-only") self._ptr[0].x = val @property def y(self): """int: """ return self._ptr[0].y @y.setter def y(self, val): if self._readonly: raise ValueError("This _py_anon_pod31 instance is read-only") self._ptr[0].y = val @property def z(self): """int: """ return self._ptr[0].z @z.setter def z(self, val): if self._readonly: raise ValueError("This _py_anon_pod31 instance is read-only") self._ptr[0].z = val @staticmethod def from_buffer(buffer): """Create an _py_anon_pod31 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod31), _py_anon_pod31) @staticmethod def from_data(data): """Create an _py_anon_pod31 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod31_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod31_dtype", _py_anon_pod31_dtype, _py_anon_pod31) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod31 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod31 obj = _py_anon_pod31.__new__(_py_anon_pod31) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod31)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod31") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod31)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod32_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod32 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod32)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod32") try: return _numpy.dtype({ 'names': ['event', 'flags_'], 'formats': [_numpy.intp, _numpy.int32], 'offsets': [ (&(pod.event)) - (pod), (&(pod.flags)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod32), }) finally: _cyb_free(pod) _py_anon_pod32_dtype = _get__py_anon_pod32_dtype_offsets() cdef class _py_anon_pod32: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod32`. .. seealso:: `cuda_bindings_runtime__anon_pod32` """ cdef: cuda_bindings_runtime__anon_pod32 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod32)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod32") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod32 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod32 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod32 other_ if not isinstance(other, _py_anon_pod32): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod32)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod32), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod32 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod32): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod32), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod32)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def event(self): """int: """ return (self._ptr[0].event) @event.setter def event(self, val): if self._readonly: raise ValueError("This _py_anon_pod32 instance is read-only") self._ptr[0].event = val @property def flags_(self): """int: """ return self._ptr[0].flags @flags_.setter def flags_(self, val): if self._readonly: raise ValueError("This _py_anon_pod32 instance is read-only") self._ptr[0].flags = val @staticmethod def from_buffer(buffer): """Create an _py_anon_pod32 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod32), _py_anon_pod32) @staticmethod def from_data(data): """Create an _py_anon_pod32 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod32_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod32_dtype", _py_anon_pod32_dtype, _py_anon_pod32) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod32 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod32 obj = _py_anon_pod32.__new__(_py_anon_pod32) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod32)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod32") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod32)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod33_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod33 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod33)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod33") try: return _numpy.dtype({ 'names': ['device_updatable', 'dev_node'], 'formats': [_numpy.int32, _numpy.intp], 'offsets': [ (&(pod.deviceUpdatable)) - (pod), (&(pod.devNode)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod33), }) finally: _cyb_free(pod) _py_anon_pod33_dtype = _get__py_anon_pod33_dtype_offsets() cdef class _py_anon_pod33: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod33`. .. seealso:: `cuda_bindings_runtime__anon_pod33` """ cdef: cuda_bindings_runtime__anon_pod33 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod33)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod33") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod33 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod33 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod33 other_ if not isinstance(other, _py_anon_pod33): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod33)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod33), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod33 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod33): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod33), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod33)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def device_updatable(self): """int: """ return self._ptr[0].deviceUpdatable @device_updatable.setter def device_updatable(self, val): if self._readonly: raise ValueError("This _py_anon_pod33 instance is read-only") self._ptr[0].deviceUpdatable = val @property def dev_node(self): """int: """ return (self._ptr[0].devNode) @dev_node.setter def dev_node(self, val): if self._readonly: raise ValueError("This _py_anon_pod33 instance is read-only") self._ptr[0].devNode = val @staticmethod def from_buffer(buffer): """Create an _py_anon_pod33 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod33), _py_anon_pod33) @staticmethod def from_data(data): """Create an _py_anon_pod33 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod33_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod33_dtype", _py_anon_pod33_dtype, _py_anon_pod33) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod33 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod33 obj = _py_anon_pod33.__new__(_py_anon_pod33) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod33)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod33") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod33)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod35_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod35 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod35)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod35") try: return _numpy.dtype({ 'names': ['bytes_over_budget'], 'formats': [_numpy.uint64], 'offsets': [ (&(pod.bytesOverBudget)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod35), }) finally: _cyb_free(pod) _py_anon_pod35_dtype = _get__py_anon_pod35_dtype_offsets() cdef class _py_anon_pod35: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod35`. .. seealso:: `cuda_bindings_runtime__anon_pod35` """ cdef: cuda_bindings_runtime__anon_pod35 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod35)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod35") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod35 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod35 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod35 other_ if not isinstance(other, _py_anon_pod35): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod35)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod35), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod35 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod35): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod35), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod35)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def bytes_over_budget(self): """int: """ return self._ptr[0].bytesOverBudget @bytes_over_budget.setter def bytes_over_budget(self, val): if self._readonly: raise ValueError("This _py_anon_pod35 instance is read-only") self._ptr[0].bytesOverBudget = val @staticmethod def from_buffer(buffer): """Create an _py_anon_pod35 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod35), _py_anon_pod35) @staticmethod def from_data(data): """Create an _py_anon_pod35 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod35_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod35_dtype", _py_anon_pod35_dtype, _py_anon_pod35) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod35 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod35 obj = _py_anon_pod35.__new__(_py_anon_pod35) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod35)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod35") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod35)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_texture_desc_dtype_offsets(): cdef cudaTextureDesc *pod = _cyb_calloc(1, sizeof(cudaTextureDesc)) if pod == NULL: raise MemoryError("Error allocating cudaTextureDesc") try: return _numpy.dtype({ 'names': ['address_mode', 'filter_mode', 'read_mode', 's_rgb', 'border_color', 'normalized_coords', 'max_anisotropy', 'mipmap_filter_mode', 'mipmap_level_bias', 'min_mipmap_level_clamp', 'max_mipmap_level_clamp', 'disable_trilinear_optimization', 'seamless_cubemap'], 'formats': [(_numpy.int32, 3), _numpy.int32, _numpy.int32, _numpy.int32, (_numpy.float32, 4), _numpy.int32, _numpy.uint32, _numpy.int32, _numpy.float32, _numpy.float32, _numpy.float32, _numpy.int32, _numpy.int32], 'offsets': [ (&(pod.addressMode)) - (pod), (&(pod.filterMode)) - (pod), (&(pod.readMode)) - (pod), (&(pod.sRGB)) - (pod), (&(pod.borderColor)) - (pod), (&(pod.normalizedCoords)) - (pod), (&(pod.maxAnisotropy)) - (pod), (&(pod.mipmapFilterMode)) - (pod), (&(pod.mipmapLevelBias)) - (pod), (&(pod.minMipmapLevelClamp)) - (pod), (&(pod.maxMipmapLevelClamp)) - (pod), (&(pod.disableTrilinearOptimization)) - (pod), (&(pod.seamlessCubemap)) - (pod), ], 'itemsize': sizeof(cudaTextureDesc), }) finally: _cyb_free(pod) texture_desc_dtype = _get_texture_desc_dtype_offsets() cdef class TextureDesc: """Empty-initialize an instance of `cudaTextureDesc`. .. seealso:: `cudaTextureDesc` """ cdef: cudaTextureDesc _data cudaTextureDesc *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.TextureDesc object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef TextureDesc other_ if not isinstance(other, TextureDesc): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaTextureDesc)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaTextureDesc), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This TextureDesc instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaTextureDesc): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaTextureDesc), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudaTextureDesc)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def address_mode(self): """~_numpy.int32: (array of length 3).Texture address mode for up to 3 dimensions""" cdef _cyb_view.array arr = _cyb_view.array(shape=(3,), itemsize=sizeof(intptr_t), format="q", mode="c", allocate_buffer=False) arr.data = (&(self._ptr[0].addressMode)) return _numpy.asarray(arr) @address_mode.setter def address_mode(self, val): if self._readonly: raise ValueError("This TextureDesc instance is read-only") if len(val) != 3: raise ValueError(f"Expected length { 3 } for field address_mode, got {len(val)}") cdef _cyb_view.array arr = _cyb_view.array(shape=(3,), itemsize=sizeof(intptr_t), format="q", mode="c") arr[:] = _numpy.asarray(val, dtype=_numpy.intp) _cyb_memcpy((&(self._ptr[0].addressMode)), (arr.data), sizeof(intptr_t) * len(val)) @property def filter_mode(self): """int: Texture filter mode""" return (self._ptr[0].filterMode) @filter_mode.setter def filter_mode(self, val): if self._readonly: raise ValueError("This TextureDesc instance is read-only") self._ptr[0].filterMode = val @property def read_mode(self): """int: Texture read mode""" return (self._ptr[0].readMode) @read_mode.setter def read_mode(self, val): if self._readonly: raise ValueError("This TextureDesc instance is read-only") self._ptr[0].readMode = val @property def s_rgb(self): """int: Perform sRGB->linear conversion during texture read""" return self._ptr[0].sRGB @s_rgb.setter def s_rgb(self, val): if self._readonly: raise ValueError("This TextureDesc instance is read-only") self._ptr[0].sRGB = val @property def border_color(self): """~_numpy.float32: (array of length 4).Texture Border Color""" cdef _cyb_view.array arr = _cyb_view.array(shape=(4,), itemsize=sizeof(float), format="f", mode="c", allocate_buffer=False) arr.data = (&(self._ptr[0].borderColor)) return _numpy.asarray(arr) @border_color.setter def border_color(self, val): if self._readonly: raise ValueError("This TextureDesc instance is read-only") if len(val) != 4: raise ValueError(f"Expected length { 4 } for field border_color, got {len(val)}") cdef _cyb_view.array arr = _cyb_view.array(shape=(4,), itemsize=sizeof(float), format="f", mode="c") arr[:] = _numpy.asarray(val, dtype=_numpy.float32) _cyb_memcpy((&(self._ptr[0].borderColor)), (arr.data), sizeof(float) * len(val)) @property def normalized_coords(self): """int: Indicates whether texture reads are normalized or not""" return self._ptr[0].normalizedCoords @normalized_coords.setter def normalized_coords(self, val): if self._readonly: raise ValueError("This TextureDesc instance is read-only") self._ptr[0].normalizedCoords = val @property def max_anisotropy(self): """int: Limit to the anisotropy ratio""" return self._ptr[0].maxAnisotropy @max_anisotropy.setter def max_anisotropy(self, val): if self._readonly: raise ValueError("This TextureDesc instance is read-only") self._ptr[0].maxAnisotropy = val @property def mipmap_filter_mode(self): """int: Mipmap filter mode""" return (self._ptr[0].mipmapFilterMode) @mipmap_filter_mode.setter def mipmap_filter_mode(self, val): if self._readonly: raise ValueError("This TextureDesc instance is read-only") self._ptr[0].mipmapFilterMode = val @property def mipmap_level_bias(self): """float: Offset applied to the supplied mipmap level""" return self._ptr[0].mipmapLevelBias @mipmap_level_bias.setter def mipmap_level_bias(self, val): if self._readonly: raise ValueError("This TextureDesc instance is read-only") self._ptr[0].mipmapLevelBias = val @property def min_mipmap_level_clamp(self): """float: Lower end of the mipmap level range to clamp access to""" return self._ptr[0].minMipmapLevelClamp @min_mipmap_level_clamp.setter def min_mipmap_level_clamp(self, val): if self._readonly: raise ValueError("This TextureDesc instance is read-only") self._ptr[0].minMipmapLevelClamp = val @property def max_mipmap_level_clamp(self): """float: Upper end of the mipmap level range to clamp access to""" return self._ptr[0].maxMipmapLevelClamp @max_mipmap_level_clamp.setter def max_mipmap_level_clamp(self, val): if self._readonly: raise ValueError("This TextureDesc instance is read-only") self._ptr[0].maxMipmapLevelClamp = val @property def disable_trilinear_optimization(self): """int: Disable any trilinear filtering optimizations.""" return self._ptr[0].disableTrilinearOptimization @disable_trilinear_optimization.setter def disable_trilinear_optimization(self, val): if self._readonly: raise ValueError("This TextureDesc instance is read-only") self._ptr[0].disableTrilinearOptimization = val @property def seamless_cubemap(self): """int: Enable seamless cube map filtering.""" return self._ptr[0].seamlessCubemap @seamless_cubemap.setter def seamless_cubemap(self, val): if self._readonly: raise ValueError("This TextureDesc instance is read-only") self._ptr[0].seamlessCubemap = val @staticmethod def from_buffer(buffer): """Create an TextureDesc instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaTextureDesc), TextureDesc) @staticmethod def from_data(data): """Create an TextureDesc instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `texture_desc_dtype` holding the data. """ return _cyb_from_data(data, "texture_desc_dtype", texture_desc_dtype, TextureDesc) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an TextureDesc instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef TextureDesc obj = TextureDesc.__new__(TextureDesc) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudaTextureDesc)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get_dev_sm_resource_dtype_offsets(): cdef cudaDevSmResource *pod = _cyb_calloc(1, sizeof(cudaDevSmResource)) if pod == NULL: raise MemoryError("Error allocating cudaDevSmResource") try: return _numpy.dtype({ 'names': ['sm_count', 'min_sm_partition_size', 'sm_coscheduled_alignment', 'flags_', 'locality_domain_id'], 'formats': [_numpy.uint32, _numpy.uint32, _numpy.uint32, _numpy.uint32, _numpy.uint32], 'offsets': [ (&(pod.smCount)) - (pod), (&(pod.minSmPartitionSize)) - (pod), (&(pod.smCoscheduledAlignment)) - (pod), (&(pod.flags)) - (pod), (&(pod.localityDomainId)) - (pod), ], 'itemsize': sizeof(cudaDevSmResource), }) finally: _cyb_free(pod) dev_sm_resource_dtype = _get_dev_sm_resource_dtype_offsets() cdef class DevSmResource: """Empty-initialize an instance of `cudaDevSmResource`. .. seealso:: `cudaDevSmResource` """ cdef: cudaDevSmResource *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cudaDevSmResource)) if self._ptr == NULL: raise MemoryError("Error allocating DevSmResource") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cudaDevSmResource *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.DevSmResource object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef DevSmResource other_ if not isinstance(other, DevSmResource): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaDevSmResource)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaDevSmResource), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This DevSmResource instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaDevSmResource): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaDevSmResource), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cudaDevSmResource)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def sm_count(self): """int: The amount of streaming multiprocessors available in this resource.""" return self._ptr[0].smCount @sm_count.setter def sm_count(self, val): if self._readonly: raise ValueError("This DevSmResource instance is read-only") self._ptr[0].smCount = val @property def min_sm_partition_size(self): """int: The minimum number of streaming multiprocessors required to partition this resource.""" return self._ptr[0].minSmPartitionSize @min_sm_partition_size.setter def min_sm_partition_size(self, val): if self._readonly: raise ValueError("This DevSmResource instance is read-only") self._ptr[0].minSmPartitionSize = val @property def sm_coscheduled_alignment(self): """int: The number of streaming multiprocessors in this resource that are guaranteed to be co-scheduled on the same GPU processing cluster. smCount will be a multiple of this value, unless the backfill flag is set.""" return self._ptr[0].smCoscheduledAlignment @sm_coscheduled_alignment.setter def sm_coscheduled_alignment(self, val): if self._readonly: raise ValueError("This DevSmResource instance is read-only") self._ptr[0].smCoscheduledAlignment = val @property def flags_(self): """int: The flags set on this SM resource. For available flags see cudaDevSmResourceGroup_flags.""" return self._ptr[0].flags @flags_.setter def flags_(self, val): if self._readonly: raise ValueError("This DevSmResource instance is read-only") self._ptr[0].flags = val @property def locality_domain_id(self): """int: Locality domain that the SM must be located on. Only valid if cudaDevSmResourceConstraintTypeLocalityDomainId is set in flags""" return self._ptr[0].localityDomainId @locality_domain_id.setter def locality_domain_id(self, val): if self._readonly: raise ValueError("This DevSmResource instance is read-only") self._ptr[0].localityDomainId = val @staticmethod def from_buffer(buffer): """Create an DevSmResource instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaDevSmResource), DevSmResource) @staticmethod def from_data(data): """Create an DevSmResource instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `dev_sm_resource_dtype` holding the data. """ return _cyb_from_data(data, "dev_sm_resource_dtype", dev_sm_resource_dtype, DevSmResource) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an DevSmResource instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef DevSmResource obj = DevSmResource.__new__(DevSmResource) if owner is None: obj._ptr = _cyb_malloc(sizeof(cudaDevSmResource)) if obj._ptr == NULL: raise MemoryError("Error allocating DevSmResource") _cyb_memcpy((obj._ptr), ptr, sizeof(cudaDevSmResource)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_dev_workqueue_config_resource_dtype_offsets(): cdef cudaDevWorkqueueConfigResource *pod = _cyb_calloc(1, sizeof(cudaDevWorkqueueConfigResource)) if pod == NULL: raise MemoryError("Error allocating cudaDevWorkqueueConfigResource") try: return _numpy.dtype({ 'names': ['device_', 'wq_concurrency_limit', 'sharing_scope'], 'formats': [_numpy.int32, _numpy.uint32, _numpy.int32], 'offsets': [ (&(pod.device)) - (pod), (&(pod.wqConcurrencyLimit)) - (pod), (&(pod.sharingScope)) - (pod), ], 'itemsize': sizeof(cudaDevWorkqueueConfigResource), }) finally: _cyb_free(pod) dev_workqueue_config_resource_dtype = _get_dev_workqueue_config_resource_dtype_offsets() cdef class DevWorkqueueConfigResource: """Empty-initialize an instance of `cudaDevWorkqueueConfigResource`. .. seealso:: `cudaDevWorkqueueConfigResource` """ cdef: cudaDevWorkqueueConfigResource *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cudaDevWorkqueueConfigResource)) if self._ptr == NULL: raise MemoryError("Error allocating DevWorkqueueConfigResource") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cudaDevWorkqueueConfigResource *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.DevWorkqueueConfigResource object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef DevWorkqueueConfigResource other_ if not isinstance(other, DevWorkqueueConfigResource): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaDevWorkqueueConfigResource)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaDevWorkqueueConfigResource), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This DevWorkqueueConfigResource instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaDevWorkqueueConfigResource): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaDevWorkqueueConfigResource), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cudaDevWorkqueueConfigResource)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def device_(self): """int: The device on which the workqueue resources are available""" return self._ptr[0].device @device_.setter def device_(self, val): if self._readonly: raise ValueError("This DevWorkqueueConfigResource instance is read-only") self._ptr[0].device = val @property def wq_concurrency_limit(self): """int: The expected maximum number of concurrent stream-ordered workloads""" return self._ptr[0].wqConcurrencyLimit @wq_concurrency_limit.setter def wq_concurrency_limit(self, val): if self._readonly: raise ValueError("This DevWorkqueueConfigResource instance is read-only") self._ptr[0].wqConcurrencyLimit = val @property def sharing_scope(self): """int: The sharing scope for the workqueue resources""" return (self._ptr[0].sharingScope) @sharing_scope.setter def sharing_scope(self, val): if self._readonly: raise ValueError("This DevWorkqueueConfigResource instance is read-only") self._ptr[0].sharingScope = val @staticmethod def from_buffer(buffer): """Create an DevWorkqueueConfigResource instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaDevWorkqueueConfigResource), DevWorkqueueConfigResource) @staticmethod def from_data(data): """Create an DevWorkqueueConfigResource instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `dev_workqueue_config_resource_dtype` holding the data. """ return _cyb_from_data(data, "dev_workqueue_config_resource_dtype", dev_workqueue_config_resource_dtype, DevWorkqueueConfigResource) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an DevWorkqueueConfigResource instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef DevWorkqueueConfigResource obj = DevWorkqueueConfigResource.__new__(DevWorkqueueConfigResource) if owner is None: obj._ptr = _cyb_malloc(sizeof(cudaDevWorkqueueConfigResource)) if obj._ptr == NULL: raise MemoryError("Error allocating DevWorkqueueConfigResource") _cyb_memcpy((obj._ptr), ptr, sizeof(cudaDevWorkqueueConfigResource)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_dev_workqueue_resource_dtype_offsets(): cdef cudaDevWorkqueueResource *pod = _cyb_calloc(1, sizeof(cudaDevWorkqueueResource)) if pod == NULL: raise MemoryError("Error allocating cudaDevWorkqueueResource") try: return _numpy.dtype({ 'names': ['reserved'], 'formats': [(_numpy.uint8, 40)], 'offsets': [ (&(pod.reserved)) - (pod), ], 'itemsize': sizeof(cudaDevWorkqueueResource), }) finally: _cyb_free(pod) dev_workqueue_resource_dtype = _get_dev_workqueue_resource_dtype_offsets() cdef class DevWorkqueueResource: """Empty-initialize an instance of `cudaDevWorkqueueResource`. .. seealso:: `cudaDevWorkqueueResource` """ cdef: cudaDevWorkqueueResource *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cudaDevWorkqueueResource)) if self._ptr == NULL: raise MemoryError("Error allocating DevWorkqueueResource") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cudaDevWorkqueueResource *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.DevWorkqueueResource object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef DevWorkqueueResource other_ if not isinstance(other, DevWorkqueueResource): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaDevWorkqueueResource)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaDevWorkqueueResource), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This DevWorkqueueResource instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaDevWorkqueueResource): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaDevWorkqueueResource), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cudaDevWorkqueueResource)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @staticmethod def from_buffer(buffer): """Create an DevWorkqueueResource instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaDevWorkqueueResource), DevWorkqueueResource) @staticmethod def from_data(data): """Create an DevWorkqueueResource instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `dev_workqueue_resource_dtype` holding the data. """ return _cyb_from_data(data, "dev_workqueue_resource_dtype", dev_workqueue_resource_dtype, DevWorkqueueResource) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an DevWorkqueueResource instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef DevWorkqueueResource obj = DevWorkqueueResource.__new__(DevWorkqueueResource) if owner is None: obj._ptr = _cyb_malloc(sizeof(cudaDevWorkqueueResource)) if obj._ptr == NULL: raise MemoryError("Error allocating DevWorkqueueResource") _cyb_memcpy((obj._ptr), ptr, sizeof(cudaDevWorkqueueResource)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_dev_sm_resource_group_params_dtype_offsets(): cdef cudaDevSmResourceGroupParams *pod = _cyb_calloc(1, sizeof(cudaDevSmResourceGroupParams)) if pod == NULL: raise MemoryError("Error allocating cudaDevSmResourceGroupParams") try: return _numpy.dtype({ 'names': ['sm_count', 'coscheduled_sm_count', 'preferred_coscheduled_sm_count', 'flags_', 'locality_domain_id', 'reserved'], 'formats': [_numpy.uint32, _numpy.uint32, _numpy.uint32, _numpy.uint32, _numpy.uint32, (_numpy.uint32, 11)], 'offsets': [ (&(pod.smCount)) - (pod), (&(pod.coscheduledSmCount)) - (pod), (&(pod.preferredCoscheduledSmCount)) - (pod), (&(pod.flags)) - (pod), (&(pod.localityDomainId)) - (pod), (&(pod.reserved)) - (pod), ], 'itemsize': sizeof(cudaDevSmResourceGroupParams), }) finally: _cyb_free(pod) dev_sm_resource_group_params_dtype = _get_dev_sm_resource_group_params_dtype_offsets() cdef object dev_sm_resource_group_params_dtype_record = _numpy.dtype((_numpy.record, dev_sm_resource_group_params_dtype)) cdef class DevSmResourceGroupParams: """Empty-initialize an array of `cudaDevSmResourceGroupParams`. The resulting object is of length `size` and of dtype `dev_sm_resource_group_params_dtype`. If default-constructed, the instance represents a single struct. Args: size (int): number of structs, default=1. .. seealso:: `cudaDevSmResourceGroupParams` """ cdef: readonly object _data object _owner def __init__(self, size=1): self._data = _numpy.zeros(size, dtype=dev_sm_resource_group_params_dtype_record) assert self._data.itemsize == sizeof(cudaDevSmResourceGroupParams), \ f"itemsize {self._data.itemsize} mismatches struct size { sizeof(cudaDevSmResourceGroupParams) }" def __repr__(self): if self._data.size > 1: return f"<{__name__}.DevSmResourceGroupParams_Array_{self._data.size} object at {hex(id(self))}>" else: return f"<{__name__}.DevSmResourceGroupParams object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return _cyb_array_ptr(self._data) cdef intptr_t _get_ptr(self): return _cyb_array_ptr(self._data) def __int__(self): if self._data.size > 1 and not self._data.flags["C_CONTIGUOUS"]: raise TypeError("int() argument must be a bytes-like object of size 1, or a " "C-contiguous array. To get the pointer address of a " "non-contiguous array, use .ptr") return _cyb_array_ptr(self._data) def __len__(self): return self._data.size def __eq__(self, other): cdef object self_data = self._data if (not isinstance(other, DevSmResourceGroupParams)) or self_data.size != other._data.size or self_data.dtype != other._data.dtype: return False return bool((self_data == other._data).all()) def __getbuffer__(self, Py_buffer *buffer, int flags): _cyb_cpython.PyObject_GetBuffer(self._data, buffer, flags) def __releasebuffer__(self, Py_buffer *buffer): _cyb_cpython.PyBuffer_Release(buffer) @property def sm_count(self): """Union[~_numpy.uint32, int]: """ if self._data.size == 1: return int(self._data["sm_count"][0]) return self._data["sm_count"] @sm_count.setter def sm_count(self, val): if not self._data.flags.writeable: raise ValueError("This DevSmResourceGroupParams instance is read-only") self._data["sm_count"] = val @property def coscheduled_sm_count(self): """Union[~_numpy.uint32, int]: """ if self._data.size == 1: return int(self._data["coscheduled_sm_count"][0]) return self._data["coscheduled_sm_count"] @coscheduled_sm_count.setter def coscheduled_sm_count(self, val): if not self._data.flags.writeable: raise ValueError("This DevSmResourceGroupParams instance is read-only") self._data["coscheduled_sm_count"] = val @property def preferred_coscheduled_sm_count(self): """Union[~_numpy.uint32, int]: """ if self._data.size == 1: return int(self._data["preferred_coscheduled_sm_count"][0]) return self._data["preferred_coscheduled_sm_count"] @preferred_coscheduled_sm_count.setter def preferred_coscheduled_sm_count(self, val): if not self._data.flags.writeable: raise ValueError("This DevSmResourceGroupParams instance is read-only") self._data["preferred_coscheduled_sm_count"] = val @property def flags_(self): """Union[~_numpy.uint32, int]: """ if self._data.size == 1: return int(self._data["flags_"][0]) return self._data["flags_"] @flags_.setter def flags_(self, val): if not self._data.flags.writeable: raise ValueError("This DevSmResourceGroupParams instance is read-only") self._data["flags_"] = val @property def locality_domain_id(self): """Union[~_numpy.uint32, int]: """ if self._data.size == 1: return int(self._data["locality_domain_id"][0]) return self._data["locality_domain_id"] @locality_domain_id.setter def locality_domain_id(self, val): if not self._data.flags.writeable: raise ValueError("This DevSmResourceGroupParams instance is read-only") self._data["locality_domain_id"] = val def __getitem__(self, key): cdef ssize_t key_ cdef ssize_t size cdef DevSmResourceGroupParams obj if isinstance(key, int): key_ = key size = self._data.size if key_ >= size or key_ <= -(size+1): raise IndexError("index is out of bounds") if key_ < 0: key_ += size obj = DevSmResourceGroupParams.__new__(DevSmResourceGroupParams) obj._data = self._data[key_:key_+1] obj._owner = self._owner return obj out = self._data[key] if isinstance(out, _numpy.ndarray): if out.dtype == dev_sm_resource_group_params_dtype: obj = DevSmResourceGroupParams.from_data(out) obj._owner = self._owner return obj if out.dtype.names is not None: return out.view(_numpy.recarray) return out def __setitem__(self, key, val): self._data[key] = val @staticmethod def from_buffer(buffer): """Create an DevSmResourceGroupParams instance with the memory from the given buffer.""" return DevSmResourceGroupParams.from_data(_numpy.frombuffer(buffer, dtype=dev_sm_resource_group_params_dtype)) @staticmethod def from_data(data): """Create an DevSmResourceGroupParams instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a 1D array of dtype `dev_sm_resource_group_params_dtype` holding the data. """ cdef DevSmResourceGroupParams obj = DevSmResourceGroupParams.__new__(DevSmResourceGroupParams) if not isinstance(data, _numpy.ndarray): raise TypeError("data argument must be a NumPy ndarray") if data.ndim != 1: raise ValueError("data array must be 1D") if data.dtype != dev_sm_resource_group_params_dtype: raise ValueError("data array must be of dtype dev_sm_resource_group_params_dtype") obj._data = data.view(dtype=dev_sm_resource_group_params_dtype_record, type=_numpy.ndarray) return obj @staticmethod def from_ptr(intptr_t ptr, size_t size=1, bint readonly=False, object owner=None): """Create an DevSmResourceGroupParams instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. size (int): number of structs, default=1. readonly (bool): whether the data is read-only (to the user). default is `False`. owner (object): object that owns the memory at *ptr*. A strong reference is kept, by this wrapper and by every NumPy view of its data, so the backing storage outlives them. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef DevSmResourceGroupParams obj = DevSmResourceGroupParams.__new__(DevSmResourceGroupParams) cdef _cyb_MemoryHolder buf = _cyb_MemoryHolder(ptr, sizeof(cudaDevSmResourceGroupParams) * size, readonly, owner) obj._data = _numpy.ndarray(size, buffer=buf, dtype=dev_sm_resource_group_params_dtype_record) obj._owner = owner return obj cdef _get_graph_recapture_callback_data_dtype_offsets(): cdef cudaGraphRecaptureCallbackData *pod = _cyb_calloc(1, sizeof(cudaGraphRecaptureCallbackData)) if pod == NULL: raise MemoryError("Error allocating cudaGraphRecaptureCallbackData") try: return _numpy.dtype({ 'names': ['callback_func', 'user_data'], 'formats': [_numpy.intp, _numpy.intp], 'offsets': [ (&(pod.callbackFunc)) - (pod), (&(pod.userData)) - (pod), ], 'itemsize': sizeof(cudaGraphRecaptureCallbackData), }) finally: _cyb_free(pod) graph_recapture_callback_data_dtype = _get_graph_recapture_callback_data_dtype_offsets() cdef class GraphRecaptureCallbackData: """Empty-initialize an instance of `cudaGraphRecaptureCallbackData`. .. seealso:: `cudaGraphRecaptureCallbackData` """ cdef: cudaGraphRecaptureCallbackData _data cudaGraphRecaptureCallbackData *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.GraphRecaptureCallbackData object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef GraphRecaptureCallbackData other_ if not isinstance(other, GraphRecaptureCallbackData): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaGraphRecaptureCallbackData)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaGraphRecaptureCallbackData), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This GraphRecaptureCallbackData instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaGraphRecaptureCallbackData): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaGraphRecaptureCallbackData), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudaGraphRecaptureCallbackData)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def callback_func(self): """int: Callback function that will be invoked""" return (self._ptr[0].callbackFunc) @callback_func.setter def callback_func(self, val): if self._readonly: raise ValueError("This GraphRecaptureCallbackData instance is read-only") self._ptr[0].callbackFunc = val @property def user_data(self): """int: Generic pointer that is passed to the callback function""" return (self._ptr[0].userData) @user_data.setter def user_data(self, val): if self._readonly: raise ValueError("This GraphRecaptureCallbackData instance is read-only") self._ptr[0].userData = val @staticmethod def from_buffer(buffer): """Create an GraphRecaptureCallbackData instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaGraphRecaptureCallbackData), GraphRecaptureCallbackData) @staticmethod def from_data(data): """Create an GraphRecaptureCallbackData instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `graph_recapture_callback_data_dtype` holding the data. """ return _cyb_from_data(data, "graph_recapture_callback_data_dtype", graph_recapture_callback_data_dtype, GraphRecaptureCallbackData) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an GraphRecaptureCallbackData instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef GraphRecaptureCallbackData obj = GraphRecaptureCallbackData.__new__(GraphRecaptureCallbackData) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudaGraphRecaptureCallbackData)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get_kernel_node_params_dtype_offsets(): cdef cudaKernelNodeParams *pod = _cyb_calloc(1, sizeof(cudaKernelNodeParams)) if pod == NULL: raise MemoryError("Error allocating cudaKernelNodeParams") try: return _numpy.dtype({ 'names': ['func', 'grid_dim', 'block_dim', 'shared_mem_bytes', 'kernel_params', 'extra'], 'formats': [_numpy.intp, dim3_dtype, dim3_dtype, _numpy.uint32, _numpy.intp, _numpy.intp], 'offsets': [ (&(pod.func)) - (pod), (&(pod.gridDim)) - (pod), (&(pod.blockDim)) - (pod), (&(pod.sharedMemBytes)) - (pod), (&(pod.kernelParams)) - (pod), (&(pod.extra)) - (pod), ], 'itemsize': sizeof(cudaKernelNodeParams), }) finally: _cyb_free(pod) kernel_node_params_dtype = _get_kernel_node_params_dtype_offsets() cdef class KernelNodeParams: """Empty-initialize an instance of `cudaKernelNodeParams`. .. seealso:: `cudaKernelNodeParams` """ cdef: cudaKernelNodeParams _data cudaKernelNodeParams *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.KernelNodeParams object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef KernelNodeParams other_ if not isinstance(other, KernelNodeParams): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaKernelNodeParams)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaKernelNodeParams), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This KernelNodeParams instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaKernelNodeParams): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaKernelNodeParams), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudaKernelNodeParams)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def grid_dim(self): """Dim3: Grid dimensions""" return Dim3.from_ptr( &(self._ptr[0].gridDim), readonly=self._readonly, owner=self, ) @grid_dim.setter def grid_dim(self, val): if self._readonly: raise ValueError("This KernelNodeParams instance is read-only") cdef Dim3 val_ = val _cyb_memcpy(&(self._ptr[0].gridDim), (val_._get_ptr()), sizeof(dim3) * 1) @property def block_dim(self): """Dim3: Block dimensions""" return Dim3.from_ptr( &(self._ptr[0].blockDim), readonly=self._readonly, owner=self, ) @block_dim.setter def block_dim(self, val): if self._readonly: raise ValueError("This KernelNodeParams instance is read-only") cdef Dim3 val_ = val _cyb_memcpy(&(self._ptr[0].blockDim), (val_._get_ptr()), sizeof(dim3) * 1) @property def func(self): """int: Kernel to launch""" return (self._ptr[0].func) @func.setter def func(self, val): if self._readonly: raise ValueError("This KernelNodeParams instance is read-only") self._ptr[0].func = val @property def shared_mem_bytes(self): """int: Dynamic shared-memory size per thread block in bytes""" return self._ptr[0].sharedMemBytes @shared_mem_bytes.setter def shared_mem_bytes(self, val): if self._readonly: raise ValueError("This KernelNodeParams instance is read-only") self._ptr[0].sharedMemBytes = val @property def kernel_params(self): """int: Array of pointers to individual kernel arguments""" return (self._ptr[0].kernelParams) @kernel_params.setter def kernel_params(self, val): if self._readonly: raise ValueError("This KernelNodeParams instance is read-only") self._ptr[0].kernelParams = val @property def extra(self): """int: Pointer to kernel arguments in the "extra" format""" return (self._ptr[0].extra) @extra.setter def extra(self, val): if self._readonly: raise ValueError("This KernelNodeParams instance is read-only") self._ptr[0].extra = val @staticmethod def from_buffer(buffer): """Create an KernelNodeParams instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaKernelNodeParams), KernelNodeParams) @staticmethod def from_data(data): """Create an KernelNodeParams instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `kernel_node_params_dtype` holding the data. """ return _cyb_from_data(data, "kernel_node_params_dtype", kernel_node_params_dtype, KernelNodeParams) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an KernelNodeParams instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef KernelNodeParams obj = KernelNodeParams.__new__(KernelNodeParams) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudaKernelNodeParams)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod4_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod4 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod4)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod4") try: return _numpy.dtype({ 'names': ['dev_ptr', 'desc', 'size_in_bytes'], 'formats': [_numpy.intp, channel_format_desc_dtype, _numpy.uint64], 'offsets': [ (&(pod.devPtr)) - (pod), (&(pod.desc)) - (pod), (&(pod.sizeInBytes)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod4), }) finally: _cyb_free(pod) _py_anon_pod4_dtype = _get__py_anon_pod4_dtype_offsets() cdef class _py_anon_pod4: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod4`. .. seealso:: `cuda_bindings_runtime__anon_pod4` """ cdef: cuda_bindings_runtime__anon_pod4 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod4)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod4") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod4 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod4 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod4 other_ if not isinstance(other, _py_anon_pod4): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod4)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod4), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod4 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod4): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod4), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod4)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def desc(self): """ChannelFormatDesc: """ return ChannelFormatDesc.from_ptr( &(self._ptr[0].desc), readonly=self._readonly, owner=self, ) @desc.setter def desc(self, val): if self._readonly: raise ValueError("This _py_anon_pod4 instance is read-only") cdef ChannelFormatDesc val_ = val _cyb_memcpy(&(self._ptr[0].desc), (val_._get_ptr()), sizeof(cudaChannelFormatDesc) * 1) @property def dev_ptr(self): """int: """ return (self._ptr[0].devPtr) @dev_ptr.setter def dev_ptr(self, val): if self._readonly: raise ValueError("This _py_anon_pod4 instance is read-only") self._ptr[0].devPtr = val @property def size_in_bytes(self): """int: """ return self._ptr[0].sizeInBytes @size_in_bytes.setter def size_in_bytes(self, val): if self._readonly: raise ValueError("This _py_anon_pod4 instance is read-only") self._ptr[0].sizeInBytes = val @staticmethod def from_buffer(buffer): """Create an _py_anon_pod4 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod4), _py_anon_pod4) @staticmethod def from_data(data): """Create an _py_anon_pod4 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod4_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod4_dtype", _py_anon_pod4_dtype, _py_anon_pod4) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod4 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod4 obj = _py_anon_pod4.__new__(_py_anon_pod4) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod4)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod4") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod4)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod5_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod5 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod5)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod5") try: return _numpy.dtype({ 'names': ['dev_ptr', 'desc', 'width', 'height', 'pitch_in_bytes'], 'formats': [_numpy.intp, channel_format_desc_dtype, _numpy.uint64, _numpy.uint64, _numpy.uint64], 'offsets': [ (&(pod.devPtr)) - (pod), (&(pod.desc)) - (pod), (&(pod.width)) - (pod), (&(pod.height)) - (pod), (&(pod.pitchInBytes)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod5), }) finally: _cyb_free(pod) _py_anon_pod5_dtype = _get__py_anon_pod5_dtype_offsets() cdef class _py_anon_pod5: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod5`. .. seealso:: `cuda_bindings_runtime__anon_pod5` """ cdef: cuda_bindings_runtime__anon_pod5 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod5)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod5") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod5 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod5 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod5 other_ if not isinstance(other, _py_anon_pod5): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod5)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod5), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod5 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod5): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod5), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod5)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def desc(self): """ChannelFormatDesc: """ return ChannelFormatDesc.from_ptr( &(self._ptr[0].desc), readonly=self._readonly, owner=self, ) @desc.setter def desc(self, val): if self._readonly: raise ValueError("This _py_anon_pod5 instance is read-only") cdef ChannelFormatDesc val_ = val _cyb_memcpy(&(self._ptr[0].desc), (val_._get_ptr()), sizeof(cudaChannelFormatDesc) * 1) @property def dev_ptr(self): """int: """ return (self._ptr[0].devPtr) @dev_ptr.setter def dev_ptr(self, val): if self._readonly: raise ValueError("This _py_anon_pod5 instance is read-only") self._ptr[0].devPtr = val @property def width(self): """int: """ return self._ptr[0].width @width.setter def width(self, val): if self._readonly: raise ValueError("This _py_anon_pod5 instance is read-only") self._ptr[0].width = val @property def height(self): """int: """ return self._ptr[0].height @height.setter def height(self, val): if self._readonly: raise ValueError("This _py_anon_pod5 instance is read-only") self._ptr[0].height = val @property def pitch_in_bytes(self): """int: """ return self._ptr[0].pitchInBytes @pitch_in_bytes.setter def pitch_in_bytes(self, val): if self._readonly: raise ValueError("This _py_anon_pod5 instance is read-only") self._ptr[0].pitchInBytes = val @staticmethod def from_buffer(buffer): """Create an _py_anon_pod5 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod5), _py_anon_pod5) @staticmethod def from_data(data): """Create an _py_anon_pod5 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod5_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod5_dtype", _py_anon_pod5_dtype, _py_anon_pod5) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod5 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod5 obj = _py_anon_pod5.__new__(_py_anon_pod5) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod5)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod5") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod5)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_egl_plane_desc_dtype_offsets(): cdef cudaEglPlaneDesc *pod = _cyb_calloc(1, sizeof(cudaEglPlaneDesc)) if pod == NULL: raise MemoryError("Error allocating cudaEglPlaneDesc") try: return _numpy.dtype({ 'names': ['width', 'height', 'depth', 'pitch', 'num_channels', 'channel_desc', 'reserved'], 'formats': [_numpy.uint32, _numpy.uint32, _numpy.uint32, _numpy.uint32, _numpy.uint32, channel_format_desc_dtype, (_numpy.uint32, 4)], 'offsets': [ (&(pod.width)) - (pod), (&(pod.height)) - (pod), (&(pod.depth)) - (pod), (&(pod.pitch)) - (pod), (&(pod.numChannels)) - (pod), (&(pod.channelDesc)) - (pod), (&(pod.reserved)) - (pod), ], 'itemsize': sizeof(cudaEglPlaneDesc), }) finally: _cyb_free(pod) egl_plane_desc_dtype = _get_egl_plane_desc_dtype_offsets() cdef object egl_plane_desc_dtype_record = _numpy.dtype((_numpy.record, egl_plane_desc_dtype)) cdef class EglPlaneDesc: """Empty-initialize an array of `cudaEglPlaneDesc`. The resulting object is of length `size` and of dtype `egl_plane_desc_dtype`. If default-constructed, the instance represents a single struct. Args: size (int): number of structs, default=1. .. seealso:: `cudaEglPlaneDesc` """ cdef: readonly object _data object _owner def __init__(self, size=1): self._data = _numpy.zeros(size, dtype=egl_plane_desc_dtype_record) assert self._data.itemsize == sizeof(cudaEglPlaneDesc), \ f"itemsize {self._data.itemsize} mismatches struct size { sizeof(cudaEglPlaneDesc) }" def __repr__(self): if self._data.size > 1: return f"<{__name__}.EglPlaneDesc_Array_{self._data.size} object at {hex(id(self))}>" else: return f"<{__name__}.EglPlaneDesc object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return _cyb_array_ptr(self._data) cdef intptr_t _get_ptr(self): return _cyb_array_ptr(self._data) def __int__(self): if self._data.size > 1 and not self._data.flags["C_CONTIGUOUS"]: raise TypeError("int() argument must be a bytes-like object of size 1, or a " "C-contiguous array. To get the pointer address of a " "non-contiguous array, use .ptr") return _cyb_array_ptr(self._data) def __len__(self): return self._data.size def __eq__(self, other): cdef object self_data = self._data if (not isinstance(other, EglPlaneDesc)) or self_data.size != other._data.size or self_data.dtype != other._data.dtype: return False return bool((self_data == other._data).all()) def __getbuffer__(self, Py_buffer *buffer, int flags): _cyb_cpython.PyObject_GetBuffer(self._data, buffer, flags) def __releasebuffer__(self, Py_buffer *buffer): _cyb_cpython.PyBuffer_Release(buffer) @property def width(self): """Union[~_numpy.uint32, int]: """ if self._data.size == 1: return int(self._data["width"][0]) return self._data["width"] @width.setter def width(self, val): if not self._data.flags.writeable: raise ValueError("This EglPlaneDesc instance is read-only") self._data["width"] = val @property def height(self): """Union[~_numpy.uint32, int]: """ if self._data.size == 1: return int(self._data["height"][0]) return self._data["height"] @height.setter def height(self, val): if not self._data.flags.writeable: raise ValueError("This EglPlaneDesc instance is read-only") self._data["height"] = val @property def depth(self): """Union[~_numpy.uint32, int]: """ if self._data.size == 1: return int(self._data["depth"][0]) return self._data["depth"] @depth.setter def depth(self, val): if not self._data.flags.writeable: raise ValueError("This EglPlaneDesc instance is read-only") self._data["depth"] = val @property def pitch(self): """Union[~_numpy.uint32, int]: """ if self._data.size == 1: return int(self._data["pitch"][0]) return self._data["pitch"] @pitch.setter def pitch(self, val): if not self._data.flags.writeable: raise ValueError("This EglPlaneDesc instance is read-only") self._data["pitch"] = val @property def num_channels(self): """Union[~_numpy.uint32, int]: """ if self._data.size == 1: return int(self._data["num_channels"][0]) return self._data["num_channels"] @num_channels.setter def num_channels(self, val): if not self._data.flags.writeable: raise ValueError("This EglPlaneDesc instance is read-only") self._data["num_channels"] = val @property def channel_desc(self): """channel_format_desc_dtype: """ return self._data["channel_desc"].view(_numpy.recarray) @channel_desc.setter def channel_desc(self, val): if not self._data.flags.writeable: raise ValueError("This EglPlaneDesc instance is read-only") self._data["channel_desc"] = val def __getitem__(self, key): cdef ssize_t key_ cdef ssize_t size cdef EglPlaneDesc obj if isinstance(key, int): key_ = key size = self._data.size if key_ >= size or key_ <= -(size+1): raise IndexError("index is out of bounds") if key_ < 0: key_ += size obj = EglPlaneDesc.__new__(EglPlaneDesc) obj._data = self._data[key_:key_+1] obj._owner = self._owner return obj out = self._data[key] if isinstance(out, _numpy.ndarray): if out.dtype == egl_plane_desc_dtype: obj = EglPlaneDesc.from_data(out) obj._owner = self._owner return obj if out.dtype.names is not None: return out.view(_numpy.recarray) return out def __setitem__(self, key, val): self._data[key] = val @staticmethod def from_buffer(buffer): """Create an EglPlaneDesc instance with the memory from the given buffer.""" return EglPlaneDesc.from_data(_numpy.frombuffer(buffer, dtype=egl_plane_desc_dtype)) @staticmethod def from_data(data): """Create an EglPlaneDesc instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a 1D array of dtype `egl_plane_desc_dtype` holding the data. """ cdef EglPlaneDesc obj = EglPlaneDesc.__new__(EglPlaneDesc) if not isinstance(data, _numpy.ndarray): raise TypeError("data argument must be a NumPy ndarray") if data.ndim != 1: raise ValueError("data array must be 1D") if data.dtype != egl_plane_desc_dtype: raise ValueError("data array must be of dtype egl_plane_desc_dtype") obj._data = data.view(dtype=egl_plane_desc_dtype_record, type=_numpy.ndarray) return obj @staticmethod def from_ptr(intptr_t ptr, size_t size=1, bint readonly=False, object owner=None): """Create an EglPlaneDesc instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. size (int): number of structs, default=1. readonly (bool): whether the data is read-only (to the user). default is `False`. owner (object): object that owns the memory at *ptr*. A strong reference is kept, by this wrapper and by every NumPy view of its data, so the backing storage outlives them. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef EglPlaneDesc obj = EglPlaneDesc.__new__(EglPlaneDesc) cdef _cyb_MemoryHolder buf = _cyb_MemoryHolder(ptr, sizeof(cudaEglPlaneDesc) * size, readonly, owner) obj._data = _numpy.ndarray(size, buffer=buf, dtype=egl_plane_desc_dtype_record) obj._owner = owner return obj cdef _get_array_sparse_properties_dtype_offsets(): cdef cudaArraySparseProperties *pod = _cyb_calloc(1, sizeof(cudaArraySparseProperties)) if pod == NULL: raise MemoryError("Error allocating cudaArraySparseProperties") try: return _numpy.dtype({ 'names': ['tile_extent', 'miptail_first_level', 'miptail_size', 'flags_', 'reserved'], 'formats': [_py_anon_pod0_dtype, _numpy.uint32, _numpy.uint64, _numpy.uint32, (_numpy.uint32, 4)], 'offsets': [ (&(pod.tileExtent)) - (pod), (&(pod.miptailFirstLevel)) - (pod), (&(pod.miptailSize)) - (pod), (&(pod.flags)) - (pod), (&(pod.reserved)) - (pod), ], 'itemsize': sizeof(cudaArraySparseProperties), }) finally: _cyb_free(pod) array_sparse_properties_dtype = _get_array_sparse_properties_dtype_offsets() cdef class ArraySparseProperties: """Empty-initialize an instance of `cudaArraySparseProperties`. .. seealso:: `cudaArraySparseProperties` """ cdef: cudaArraySparseProperties _data cudaArraySparseProperties *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.ArraySparseProperties object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef ArraySparseProperties other_ if not isinstance(other, ArraySparseProperties): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaArraySparseProperties)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaArraySparseProperties), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This ArraySparseProperties instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaArraySparseProperties): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaArraySparseProperties), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudaArraySparseProperties)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def tile_extent(self): """_py_anon_pod0: """ return _py_anon_pod0.from_ptr( &(self._ptr[0].tileExtent), readonly=self._readonly, owner=self, ) @tile_extent.setter def tile_extent(self, val): if self._readonly: raise ValueError("This ArraySparseProperties instance is read-only") cdef _py_anon_pod0 val_ = val _cyb_memcpy(&(self._ptr[0].tileExtent), (val_._get_ptr()), sizeof(cuda_bindings_runtime__anon_pod0) * 1) @property def miptail_first_level(self): """int: First mip level at which the mip tail begins""" return self._ptr[0].miptailFirstLevel @miptail_first_level.setter def miptail_first_level(self, val): if self._readonly: raise ValueError("This ArraySparseProperties instance is read-only") self._ptr[0].miptailFirstLevel = val @property def miptail_size(self): """int: Total size of the mip tail.""" return self._ptr[0].miptailSize @miptail_size.setter def miptail_size(self, val): if self._readonly: raise ValueError("This ArraySparseProperties instance is read-only") self._ptr[0].miptailSize = val @property def flags_(self): """int: Flags will either be zero or cudaArraySparsePropertiesSingleMipTail""" return self._ptr[0].flags @flags_.setter def flags_(self, val): if self._readonly: raise ValueError("This ArraySparseProperties instance is read-only") self._ptr[0].flags = val @staticmethod def from_buffer(buffer): """Create an ArraySparseProperties instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaArraySparseProperties), ArraySparseProperties) @staticmethod def from_data(data): """Create an ArraySparseProperties instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `array_sparse_properties_dtype` holding the data. """ return _cyb_from_data(data, "array_sparse_properties_dtype", array_sparse_properties_dtype, ArraySparseProperties) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an ArraySparseProperties instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef ArraySparseProperties obj = ArraySparseProperties.__new__(ArraySparseProperties) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudaArraySparseProperties)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod36_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod36 *pod = _cyb_calloc(1, sizeof((NULL).frame)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod36") try: return _numpy.dtype({ 'names': ['p_array', 'p_pitch'], 'formats': [(_numpy.intp, 3), (pitched_ptr_dtype, 3)], 'offsets': [ (&(pod.pArray)) - (pod), (&(pod.pPitch)) - (pod), ], 'itemsize': sizeof((NULL).frame), }) finally: _cyb_free(pod) _py_anon_pod36_dtype = _get__py_anon_pod36_dtype_offsets() cdef class _py_anon_pod36: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod36`. .. seealso:: `cuda_bindings_runtime__anon_pod36` """ cdef: cuda_bindings_runtime__anon_pod36 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof((NULL).frame)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod36") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod36 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod36 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod36 other_ if not isinstance(other, _py_anon_pod36): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof((NULL).frame)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof((NULL).frame), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod36 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof((NULL).frame): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof((NULL).frame), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof((NULL).frame)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def p_pitch(self): """PitchedPtr: """ return PitchedPtr.from_ptr( &(self._ptr[0].pPitch), 3, readonly=self._readonly, owner=self, ) @p_pitch.setter def p_pitch(self, val): if self._readonly: raise ValueError("This _py_anon_pod36 instance is read-only") cdef PitchedPtr val_ = val if len(val) != 3: raise ValueError(f"Expected length { 3 } for field p_pitch, got {len(val)}") _cyb_memcpy(&(self._ptr[0].pPitch), (val_._get_ptr()), sizeof(cudaPitchedPtr) * 3) @property def p_array(self): """~_numpy.intp: (array of length 3).""" cdef _cyb_view.array arr = _cyb_view.array(shape=(3,), itemsize=sizeof(intptr_t), format="q", mode="c", allocate_buffer=False) arr.data = (&(self._ptr[0].pArray)) return _numpy.asarray(arr) @p_array.setter def p_array(self, val): if self._readonly: raise ValueError("This _py_anon_pod36 instance is read-only") if len(val) != 3: raise ValueError(f"Expected length { 3 } for field p_array, got {len(val)}") cdef _cyb_view.array arr = _cyb_view.array(shape=(3,), itemsize=sizeof(intptr_t), format="q", mode="c") arr[:] = _numpy.asarray(val, dtype=_numpy.intp) _cyb_memcpy((&(self._ptr[0].pArray)), (arr.data), sizeof(intptr_t) * len(val)) @staticmethod def from_buffer(buffer): """Create an _py_anon_pod36 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof((NULL).frame), _py_anon_pod36) @staticmethod def from_data(data): """Create an _py_anon_pod36 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod36_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod36_dtype", _py_anon_pod36_dtype, _py_anon_pod36) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod36 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod36 obj = _py_anon_pod36.__new__(_py_anon_pod36) if owner is None: obj._ptr = _cyb_malloc(sizeof((NULL).frame)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod36") _cyb_memcpy((obj._ptr), ptr, sizeof((NULL).frame)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_external_memory_mipmapped_array_desc_dtype_offsets(): cdef cudaExternalMemoryMipmappedArrayDesc *pod = _cyb_calloc(1, sizeof(cudaExternalMemoryMipmappedArrayDesc)) if pod == NULL: raise MemoryError("Error allocating cudaExternalMemoryMipmappedArrayDesc") try: return _numpy.dtype({ 'names': ['offset', 'format_desc', 'extent', 'flags_', 'num_levels', 'reserved'], 'formats': [_numpy.uint64, channel_format_desc_dtype, extent_dtype, _numpy.uint32, _numpy.uint32, (_numpy.uint32, 16)], 'offsets': [ (&(pod.offset)) - (pod), (&(pod.formatDesc)) - (pod), (&(pod.extent)) - (pod), (&(pod.flags)) - (pod), (&(pod.numLevels)) - (pod), (&(pod.reserved)) - (pod), ], 'itemsize': sizeof(cudaExternalMemoryMipmappedArrayDesc), }) finally: _cyb_free(pod) external_memory_mipmapped_array_desc_dtype = _get_external_memory_mipmapped_array_desc_dtype_offsets() cdef class ExternalMemoryMipmappedArrayDesc: """Empty-initialize an instance of `cudaExternalMemoryMipmappedArrayDesc`. .. seealso:: `cudaExternalMemoryMipmappedArrayDesc` """ cdef: cudaExternalMemoryMipmappedArrayDesc _data cudaExternalMemoryMipmappedArrayDesc *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.ExternalMemoryMipmappedArrayDesc object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef ExternalMemoryMipmappedArrayDesc other_ if not isinstance(other, ExternalMemoryMipmappedArrayDesc): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaExternalMemoryMipmappedArrayDesc)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaExternalMemoryMipmappedArrayDesc), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This ExternalMemoryMipmappedArrayDesc instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaExternalMemoryMipmappedArrayDesc): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaExternalMemoryMipmappedArrayDesc), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudaExternalMemoryMipmappedArrayDesc)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def format_desc(self): """ChannelFormatDesc: Format of base level of the mipmap chain""" return ChannelFormatDesc.from_ptr( &(self._ptr[0].formatDesc), readonly=self._readonly, owner=self, ) @format_desc.setter def format_desc(self, val): if self._readonly: raise ValueError("This ExternalMemoryMipmappedArrayDesc instance is read-only") cdef ChannelFormatDesc val_ = val _cyb_memcpy(&(self._ptr[0].formatDesc), (val_._get_ptr()), sizeof(cudaChannelFormatDesc) * 1) @property def extent(self): """Extent: Dimensions of base level of the mipmap chain""" return Extent.from_ptr( &(self._ptr[0].extent), readonly=self._readonly, owner=self, ) @extent.setter def extent(self, val): if self._readonly: raise ValueError("This ExternalMemoryMipmappedArrayDesc instance is read-only") cdef Extent val_ = val _cyb_memcpy(&(self._ptr[0].extent), (val_._get_ptr()), sizeof(cudaExtent) * 1) @property def offset(self): """int: Offset into the memory object where the base level of the mipmap chain is.""" return self._ptr[0].offset @offset.setter def offset(self, val): if self._readonly: raise ValueError("This ExternalMemoryMipmappedArrayDesc instance is read-only") self._ptr[0].offset = val @property def flags_(self): """int: Flags associated with CUDA mipmapped arrays. See cudaMallocMipmappedArray""" return self._ptr[0].flags @flags_.setter def flags_(self, val): if self._readonly: raise ValueError("This ExternalMemoryMipmappedArrayDesc instance is read-only") self._ptr[0].flags = val @property def num_levels(self): """int: Total number of levels in the mipmap chain""" return self._ptr[0].numLevels @num_levels.setter def num_levels(self, val): if self._readonly: raise ValueError("This ExternalMemoryMipmappedArrayDesc instance is read-only") self._ptr[0].numLevels = val @staticmethod def from_buffer(buffer): """Create an ExternalMemoryMipmappedArrayDesc instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaExternalMemoryMipmappedArrayDesc), ExternalMemoryMipmappedArrayDesc) @staticmethod def from_data(data): """Create an ExternalMemoryMipmappedArrayDesc instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `external_memory_mipmapped_array_desc_dtype` holding the data. """ return _cyb_from_data(data, "external_memory_mipmapped_array_desc_dtype", external_memory_mipmapped_array_desc_dtype, ExternalMemoryMipmappedArrayDesc) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an ExternalMemoryMipmappedArrayDesc instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef ExternalMemoryMipmappedArrayDesc obj = ExternalMemoryMipmappedArrayDesc.__new__(ExternalMemoryMipmappedArrayDesc) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudaExternalMemoryMipmappedArrayDesc)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get_mem_cpy3d_parms_dtype_offsets(): cdef cudaMemcpy3DParms *pod = _cyb_calloc(1, sizeof(cudaMemcpy3DParms)) if pod == NULL: raise MemoryError("Error allocating cudaMemcpy3DParms") try: return _numpy.dtype({ 'names': ['src_array', 'src_pos', 'src_ptr', 'dst_array', 'dst_pos', 'dst_ptr', 'extent', 'kind'], 'formats': [_numpy.intp, pos_dtype, pitched_ptr_dtype, _numpy.intp, pos_dtype, pitched_ptr_dtype, extent_dtype, _numpy.int32], 'offsets': [ (&(pod.srcArray)) - (pod), (&(pod.srcPos)) - (pod), (&(pod.srcPtr)) - (pod), (&(pod.dstArray)) - (pod), (&(pod.dstPos)) - (pod), (&(pod.dstPtr)) - (pod), (&(pod.extent)) - (pod), (&(pod.kind)) - (pod), ], 'itemsize': sizeof(cudaMemcpy3DParms), }) finally: _cyb_free(pod) mem_cpy3d_parms_dtype = _get_mem_cpy3d_parms_dtype_offsets() cdef class MemCpy3dParms: """Empty-initialize an instance of `cudaMemcpy3DParms`. .. seealso:: `cudaMemcpy3DParms` """ cdef: cudaMemcpy3DParms *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cudaMemcpy3DParms)) if self._ptr == NULL: raise MemoryError("Error allocating MemCpy3dParms") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cudaMemcpy3DParms *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.MemCpy3dParms object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef MemCpy3dParms other_ if not isinstance(other, MemCpy3dParms): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaMemcpy3DParms)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaMemcpy3DParms), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This MemCpy3dParms instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaMemcpy3DParms): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaMemcpy3DParms), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cudaMemcpy3DParms)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def src_pos(self): """Pos: Source position offset""" return Pos.from_ptr( &(self._ptr[0].srcPos), readonly=self._readonly, owner=self, ) @src_pos.setter def src_pos(self, val): if self._readonly: raise ValueError("This MemCpy3dParms instance is read-only") cdef Pos val_ = val _cyb_memcpy(&(self._ptr[0].srcPos), (val_._get_ptr()), sizeof(cudaPos) * 1) @property def src_ptr(self): """PitchedPtr: Pitched source memory address""" return PitchedPtr.from_ptr( &(self._ptr[0].srcPtr), 1, readonly=self._readonly, owner=self, ) @src_ptr.setter def src_ptr(self, val): if self._readonly: raise ValueError("This MemCpy3dParms instance is read-only") cdef PitchedPtr val_ = val _cyb_memcpy(&(self._ptr[0].srcPtr), (val_._get_ptr()), sizeof(cudaPitchedPtr) * 1) @property def dst_pos(self): """Pos: Destination position offset""" return Pos.from_ptr( &(self._ptr[0].dstPos), readonly=self._readonly, owner=self, ) @dst_pos.setter def dst_pos(self, val): if self._readonly: raise ValueError("This MemCpy3dParms instance is read-only") cdef Pos val_ = val _cyb_memcpy(&(self._ptr[0].dstPos), (val_._get_ptr()), sizeof(cudaPos) * 1) @property def dst_ptr(self): """PitchedPtr: Pitched destination memory address""" return PitchedPtr.from_ptr( &(self._ptr[0].dstPtr), 1, readonly=self._readonly, owner=self, ) @dst_ptr.setter def dst_ptr(self, val): if self._readonly: raise ValueError("This MemCpy3dParms instance is read-only") cdef PitchedPtr val_ = val _cyb_memcpy(&(self._ptr[0].dstPtr), (val_._get_ptr()), sizeof(cudaPitchedPtr) * 1) @property def extent(self): """Extent: Requested memory copy size""" return Extent.from_ptr( &(self._ptr[0].extent), readonly=self._readonly, owner=self, ) @extent.setter def extent(self, val): if self._readonly: raise ValueError("This MemCpy3dParms instance is read-only") cdef Extent val_ = val _cyb_memcpy(&(self._ptr[0].extent), (val_._get_ptr()), sizeof(cudaExtent) * 1) @property def src_array(self): """int: Source memory address""" return (self._ptr[0].srcArray) @src_array.setter def src_array(self, val): if self._readonly: raise ValueError("This MemCpy3dParms instance is read-only") self._ptr[0].srcArray = val @property def dst_array(self): """int: Destination memory address""" return (self._ptr[0].dstArray) @dst_array.setter def dst_array(self, val): if self._readonly: raise ValueError("This MemCpy3dParms instance is read-only") self._ptr[0].dstArray = val @property def kind(self): """int: Type of transfer""" return (self._ptr[0].kind) @kind.setter def kind(self, val): if self._readonly: raise ValueError("This MemCpy3dParms instance is read-only") self._ptr[0].kind = val @staticmethod def from_buffer(buffer): """Create an MemCpy3dParms instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaMemcpy3DParms), MemCpy3dParms) @staticmethod def from_data(data): """Create an MemCpy3dParms instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `mem_cpy3d_parms_dtype` holding the data. """ return _cyb_from_data(data, "mem_cpy3d_parms_dtype", mem_cpy3d_parms_dtype, MemCpy3dParms) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an MemCpy3dParms instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef MemCpy3dParms obj = MemCpy3dParms.__new__(MemCpy3dParms) if owner is None: obj._ptr = _cyb_malloc(sizeof(cudaMemcpy3DParms)) if obj._ptr == NULL: raise MemoryError("Error allocating MemCpy3dParms") _cyb_memcpy((obj._ptr), ptr, sizeof(cudaMemcpy3DParms)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_mem_cpy3d_peer_parms_dtype_offsets(): cdef cudaMemcpy3DPeerParms *pod = _cyb_calloc(1, sizeof(cudaMemcpy3DPeerParms)) if pod == NULL: raise MemoryError("Error allocating cudaMemcpy3DPeerParms") try: return _numpy.dtype({ 'names': ['src_array', 'src_pos', 'src_ptr', 'src_device', 'dst_array', 'dst_pos', 'dst_ptr', 'dst_device', 'extent'], 'formats': [_numpy.intp, pos_dtype, pitched_ptr_dtype, _numpy.int32, _numpy.intp, pos_dtype, pitched_ptr_dtype, _numpy.int32, extent_dtype], 'offsets': [ (&(pod.srcArray)) - (pod), (&(pod.srcPos)) - (pod), (&(pod.srcPtr)) - (pod), (&(pod.srcDevice)) - (pod), (&(pod.dstArray)) - (pod), (&(pod.dstPos)) - (pod), (&(pod.dstPtr)) - (pod), (&(pod.dstDevice)) - (pod), (&(pod.extent)) - (pod), ], 'itemsize': sizeof(cudaMemcpy3DPeerParms), }) finally: _cyb_free(pod) mem_cpy3d_peer_parms_dtype = _get_mem_cpy3d_peer_parms_dtype_offsets() cdef class MemCpy3dPeerParms: """Empty-initialize an instance of `cudaMemcpy3DPeerParms`. .. seealso:: `cudaMemcpy3DPeerParms` """ cdef: cudaMemcpy3DPeerParms _data cudaMemcpy3DPeerParms *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.MemCpy3dPeerParms object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef MemCpy3dPeerParms other_ if not isinstance(other, MemCpy3dPeerParms): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaMemcpy3DPeerParms)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaMemcpy3DPeerParms), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This MemCpy3dPeerParms instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaMemcpy3DPeerParms): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaMemcpy3DPeerParms), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudaMemcpy3DPeerParms)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def src_pos(self): """Pos: Source position offset""" return Pos.from_ptr( &(self._ptr[0].srcPos), readonly=self._readonly, owner=self, ) @src_pos.setter def src_pos(self, val): if self._readonly: raise ValueError("This MemCpy3dPeerParms instance is read-only") cdef Pos val_ = val _cyb_memcpy(&(self._ptr[0].srcPos), (val_._get_ptr()), sizeof(cudaPos) * 1) @property def src_ptr(self): """PitchedPtr: Pitched source memory address""" return PitchedPtr.from_ptr( &(self._ptr[0].srcPtr), 1, readonly=self._readonly, owner=self, ) @src_ptr.setter def src_ptr(self, val): if self._readonly: raise ValueError("This MemCpy3dPeerParms instance is read-only") cdef PitchedPtr val_ = val _cyb_memcpy(&(self._ptr[0].srcPtr), (val_._get_ptr()), sizeof(cudaPitchedPtr) * 1) @property def dst_pos(self): """Pos: Destination position offset""" return Pos.from_ptr( &(self._ptr[0].dstPos), readonly=self._readonly, owner=self, ) @dst_pos.setter def dst_pos(self, val): if self._readonly: raise ValueError("This MemCpy3dPeerParms instance is read-only") cdef Pos val_ = val _cyb_memcpy(&(self._ptr[0].dstPos), (val_._get_ptr()), sizeof(cudaPos) * 1) @property def dst_ptr(self): """PitchedPtr: Pitched destination memory address""" return PitchedPtr.from_ptr( &(self._ptr[0].dstPtr), 1, readonly=self._readonly, owner=self, ) @dst_ptr.setter def dst_ptr(self, val): if self._readonly: raise ValueError("This MemCpy3dPeerParms instance is read-only") cdef PitchedPtr val_ = val _cyb_memcpy(&(self._ptr[0].dstPtr), (val_._get_ptr()), sizeof(cudaPitchedPtr) * 1) @property def extent(self): """Extent: Requested memory copy size""" return Extent.from_ptr( &(self._ptr[0].extent), readonly=self._readonly, owner=self, ) @extent.setter def extent(self, val): if self._readonly: raise ValueError("This MemCpy3dPeerParms instance is read-only") cdef Extent val_ = val _cyb_memcpy(&(self._ptr[0].extent), (val_._get_ptr()), sizeof(cudaExtent) * 1) @property def src_array(self): """int: Source memory address""" return (self._ptr[0].srcArray) @src_array.setter def src_array(self, val): if self._readonly: raise ValueError("This MemCpy3dPeerParms instance is read-only") self._ptr[0].srcArray = val @property def src_device(self): """int: Source device""" return self._ptr[0].srcDevice @src_device.setter def src_device(self, val): if self._readonly: raise ValueError("This MemCpy3dPeerParms instance is read-only") self._ptr[0].srcDevice = val @property def dst_array(self): """int: Destination memory address""" return (self._ptr[0].dstArray) @dst_array.setter def dst_array(self, val): if self._readonly: raise ValueError("This MemCpy3dPeerParms instance is read-only") self._ptr[0].dstArray = val @property def dst_device(self): """int: Destination device""" return self._ptr[0].dstDevice @dst_device.setter def dst_device(self, val): if self._readonly: raise ValueError("This MemCpy3dPeerParms instance is read-only") self._ptr[0].dstDevice = val @staticmethod def from_buffer(buffer): """Create an MemCpy3dPeerParms instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaMemcpy3DPeerParms), MemCpy3dPeerParms) @staticmethod def from_data(data): """Create an MemCpy3dPeerParms instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `mem_cpy3d_peer_parms_dtype` holding the data. """ return _cyb_from_data(data, "mem_cpy3d_peer_parms_dtype", mem_cpy3d_peer_parms_dtype, MemCpy3dPeerParms) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an MemCpy3dPeerParms instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef MemCpy3dPeerParms obj = MemCpy3dPeerParms.__new__(MemCpy3dPeerParms) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudaMemcpy3DPeerParms)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get_pointer_attributes_dtype_offsets(): cdef cudaPointerAttributes *pod = _cyb_calloc(1, sizeof(cudaPointerAttributes)) if pod == NULL: raise MemoryError("Error allocating cudaPointerAttributes") try: return _numpy.dtype({ 'names': ['type', 'device_', 'device_pointer', 'host_pointer', 'locality_domain_ordinal', 'unused', 'reserved'], 'formats': [_numpy.int32, _numpy.int32, _numpy.intp, _numpy.intp, _numpy.int32, _numpy.int32, (_numpy.int32, 7)], 'offsets': [ (&(pod.type)) - (pod), (&(pod.device)) - (pod), (&(pod.devicePointer)) - (pod), (&(pod.hostPointer)) - (pod), (&(pod.localityDomainOrdinal)) - (pod), (&(pod.unused)) - (pod), (&(pod.reserved)) - (pod), ], 'itemsize': sizeof(cudaPointerAttributes), }) finally: _cyb_free(pod) pointer_attributes_dtype = _get_pointer_attributes_dtype_offsets() cdef class PointerAttributes: """Empty-initialize an instance of `cudaPointerAttributes`. .. seealso:: `cudaPointerAttributes` """ cdef: cudaPointerAttributes _data cudaPointerAttributes *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.PointerAttributes object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef PointerAttributes other_ if not isinstance(other, PointerAttributes): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaPointerAttributes)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaPointerAttributes), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This PointerAttributes instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaPointerAttributes): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaPointerAttributes), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudaPointerAttributes)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def type(self): """int: The type of memory - cudaMemoryTypeUnregistered, cudaMemoryTypeHost, cudaMemoryTypeDevice or cudaMemoryTypeManaged.""" return (self._ptr[0].type) @type.setter def type(self, val): if self._readonly: raise ValueError("This PointerAttributes instance is read-only") self._ptr[0].type = val @property def device_(self): """int: The device against which the memory was allocated or registered. If the memory type is cudaMemoryTypeDevice then this identifies the device on which the memory referred physically resides. If the memory type is cudaMemoryTypeHost or::cudaMemoryTypeManaged then this identifies the device which was current when the memory was allocated or registered (and if that device is deinitialized then this allocation will vanish with that device's state).""" return self._ptr[0].device @device_.setter def device_(self, val): if self._readonly: raise ValueError("This PointerAttributes instance is read-only") self._ptr[0].device = val @property def device_pointer(self): """int: The address which may be dereferenced on the current device to access the memory or NULL if no such address exists.""" return (self._ptr[0].devicePointer) @device_pointer.setter def device_pointer(self, val): if self._readonly: raise ValueError("This PointerAttributes instance is read-only") self._ptr[0].devicePointer = val @property def host_pointer(self): """int: The address which may be dereferenced on the host to access the memory or NULL if no such address exists. CUDA doesn't check if unregistered memory is allocated so this field may contain invalid pointer if an invalid pointer has been passed to CUDA.""" return (self._ptr[0].hostPointer) @host_pointer.setter def host_pointer(self, val): if self._readonly: raise ValueError("This PointerAttributes instance is read-only") self._ptr[0].hostPointer = val @property def locality_domain_ordinal(self): """int: """ return self._ptr[0].localityDomainOrdinal @locality_domain_ordinal.setter def locality_domain_ordinal(self, val): if self._readonly: raise ValueError("This PointerAttributes instance is read-only") self._ptr[0].localityDomainOrdinal = val @staticmethod def from_buffer(buffer): """Create an PointerAttributes instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaPointerAttributes), PointerAttributes) @staticmethod def from_data(data): """Create an PointerAttributes instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `pointer_attributes_dtype` holding the data. """ return _cyb_from_data(data, "pointer_attributes_dtype", pointer_attributes_dtype, PointerAttributes) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an PointerAttributes instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef PointerAttributes obj = PointerAttributes.__new__(PointerAttributes) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudaPointerAttributes)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod12_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod12 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod12)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod12") try: return _numpy.dtype({ 'names': ['array', 'offset'], 'formats': [_numpy.intp, offset3d_dtype], 'offsets': [ (&(pod.array)) - (pod), (&(pod.offset)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod12), }) finally: _cyb_free(pod) _py_anon_pod12_dtype = _get__py_anon_pod12_dtype_offsets() cdef class _py_anon_pod12: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod12`. .. seealso:: `cuda_bindings_runtime__anon_pod12` """ cdef: cuda_bindings_runtime__anon_pod12 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod12)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod12") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod12 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod12 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod12 other_ if not isinstance(other, _py_anon_pod12): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod12)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod12), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod12 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod12): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod12), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod12)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def offset(self): """Offset3d: """ return Offset3d.from_ptr( &(self._ptr[0].offset), readonly=self._readonly, owner=self, ) @offset.setter def offset(self, val): if self._readonly: raise ValueError("This _py_anon_pod12 instance is read-only") cdef Offset3d val_ = val _cyb_memcpy(&(self._ptr[0].offset), (val_._get_ptr()), sizeof(cudaOffset3D) * 1) @property def array(self): """int: """ return (self._ptr[0].array) @array.setter def array(self, val): if self._readonly: raise ValueError("This _py_anon_pod12 instance is read-only") self._ptr[0].array = val @staticmethod def from_buffer(buffer): """Create an _py_anon_pod12 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod12), _py_anon_pod12) @staticmethod def from_data(data): """Create an _py_anon_pod12 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod12_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod12_dtype", _py_anon_pod12_dtype, _py_anon_pod12) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod12 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod12 obj = _py_anon_pod12.__new__(_py_anon_pod12) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod12)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod12") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod12)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_device_prop_dtype_offsets(): cdef cudaDeviceProp *pod = _cyb_calloc(1, sizeof(cudaDeviceProp)) if pod == NULL: raise MemoryError("Error allocating cudaDeviceProp") try: return _numpy.dtype({ 'names': ['name', 'uuid', 'luid', 'luid_device_node_mask', 'total_global_mem', 'shared_mem_per_block', 'regs_per_block', 'warp_size', 'mem_pitch', 'max_threads_per_block', 'max_threads_dim', 'max_grid_size', 'total_const_mem', 'major', 'minor', 'texture_alignment', 'texture_pitch_alignment', 'multi_processor_count', 'integrated', 'can_map_host_memory', 'max_texture1d', 'max_texture1d_mipmap', 'max_texture2d', 'max_texture2d_mipmap', 'max_texture2d_linear', 'max_texture2d_gather', 'max_texture3d', 'max_texture3d_alt', 'max_texture_cubemap', 'max_texture1d_layered', 'max_texture2d_layered', 'max_texture_cubemap_layered', 'max_surface1d', 'max_surface2d', 'max_surface3d', 'max_surface1d_layered', 'max_surface2d_layered', 'max_surface_cubemap', 'max_surface_cubemap_layered', 'surface_alignment', 'concurrent_kernels', 'ecc_enabled', 'pci_bus_id', 'pci_device_id', 'pci_domain_id', 'tcc_driver', 'async_engine_count', 'unified_addressing', 'memory_bus_width', 'l2cache_size', 'persisting_l2cache_max_size', 'max_threads_per_multi_processor', 'stream_priorities_supported', 'global_l1cache_supported', 'local_l1cache_supported', 'shared_mem_per_multiprocessor', 'regs_per_multiprocessor', 'managed_memory', 'is_multi_gpu_board', 'multi_gpu_board_group_id', 'host_native_atomic_supported', 'pageable_memory_access', 'concurrent_managed_access', 'compute_preemption_supported', 'can_use_host_pointer_for_registered_mem', 'cooperative_launch', 'shared_mem_per_block_optin', 'pageable_memory_access_uses_host_page_tables', 'direct_managed_mem_access_from_host', 'max_blocks_per_multi_processor', 'access_policy_max_window_size', 'reserved_shared_mem_per_block', 'host_register_supported', 'sparse_cuda_array_supported', 'host_register_read_only_supported', 'timeline_semaphore_interop_supported', 'memory_pools_supported', 'gpu_direct_rdma_supported', 'gpu_direct_rdma_flush_writes_options', 'gpu_direct_rdma_writes_ordering', 'memory_pool_supported_handle_types', 'deferred_mapping_cuda_array_supported', 'ipc_event_supported', 'cluster_launch', 'unified_function_pointers', 'device_numa_config', 'device_numa_id', 'mps_enabled', 'host_numa_id', 'gpu_pci_device_id', 'gpu_pci_subsystem_id', 'host_numa_multinode_ipc_supported', 'reserved'], 'formats': [(_numpy.int8, 256), uuid_dtype, (_numpy.int8, 8), _numpy.uint32, _numpy.uint64, _numpy.uint64, _numpy.int32, _numpy.int32, _numpy.uint64, _numpy.int32, (_numpy.int32, 3), (_numpy.int32, 3), _numpy.uint64, _numpy.int32, _numpy.int32, _numpy.uint64, _numpy.uint64, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, (_numpy.int32, 2), (_numpy.int32, 2), (_numpy.int32, 3), (_numpy.int32, 2), (_numpy.int32, 3), (_numpy.int32, 3), _numpy.int32, (_numpy.int32, 2), (_numpy.int32, 3), (_numpy.int32, 2), _numpy.int32, (_numpy.int32, 2), (_numpy.int32, 3), (_numpy.int32, 2), (_numpy.int32, 3), _numpy.int32, (_numpy.int32, 2), _numpy.uint64, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.uint64, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.uint64, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.uint64, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.uint32, _numpy.int32, _numpy.uint32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.int32, _numpy.uint32, _numpy.uint32, _numpy.int32, (_numpy.int32, 56)], 'offsets': [ (&(pod.name)) - (pod), (&(pod.uuid)) - (pod), (&(pod.luid)) - (pod), (&(pod.luidDeviceNodeMask)) - (pod), (&(pod.totalGlobalMem)) - (pod), (&(pod.sharedMemPerBlock)) - (pod), (&(pod.regsPerBlock)) - (pod), (&(pod.warpSize)) - (pod), (&(pod.memPitch)) - (pod), (&(pod.maxThreadsPerBlock)) - (pod), (&(pod.maxThreadsDim)) - (pod), (&(pod.maxGridSize)) - (pod), (&(pod.totalConstMem)) - (pod), (&(pod.major)) - (pod), (&(pod.minor)) - (pod), (&(pod.textureAlignment)) - (pod), (&(pod.texturePitchAlignment)) - (pod), (&(pod.multiProcessorCount)) - (pod), (&(pod.integrated)) - (pod), (&(pod.canMapHostMemory)) - (pod), (&(pod.maxTexture1D)) - (pod), (&(pod.maxTexture1DMipmap)) - (pod), (&(pod.maxTexture2D)) - (pod), (&(pod.maxTexture2DMipmap)) - (pod), (&(pod.maxTexture2DLinear)) - (pod), (&(pod.maxTexture2DGather)) - (pod), (&(pod.maxTexture3D)) - (pod), (&(pod.maxTexture3DAlt)) - (pod), (&(pod.maxTextureCubemap)) - (pod), (&(pod.maxTexture1DLayered)) - (pod), (&(pod.maxTexture2DLayered)) - (pod), (&(pod.maxTextureCubemapLayered)) - (pod), (&(pod.maxSurface1D)) - (pod), (&(pod.maxSurface2D)) - (pod), (&(pod.maxSurface3D)) - (pod), (&(pod.maxSurface1DLayered)) - (pod), (&(pod.maxSurface2DLayered)) - (pod), (&(pod.maxSurfaceCubemap)) - (pod), (&(pod.maxSurfaceCubemapLayered)) - (pod), (&(pod.surfaceAlignment)) - (pod), (&(pod.concurrentKernels)) - (pod), (&(pod.ECCEnabled)) - (pod), (&(pod.pciBusID)) - (pod), (&(pod.pciDeviceID)) - (pod), (&(pod.pciDomainID)) - (pod), (&(pod.tccDriver)) - (pod), (&(pod.asyncEngineCount)) - (pod), (&(pod.unifiedAddressing)) - (pod), (&(pod.memoryBusWidth)) - (pod), (&(pod.l2CacheSize)) - (pod), (&(pod.persistingL2CacheMaxSize)) - (pod), (&(pod.maxThreadsPerMultiProcessor)) - (pod), (&(pod.streamPrioritiesSupported)) - (pod), (&(pod.globalL1CacheSupported)) - (pod), (&(pod.localL1CacheSupported)) - (pod), (&(pod.sharedMemPerMultiprocessor)) - (pod), (&(pod.regsPerMultiprocessor)) - (pod), (&(pod.managedMemory)) - (pod), (&(pod.isMultiGpuBoard)) - (pod), (&(pod.multiGpuBoardGroupID)) - (pod), (&(pod.hostNativeAtomicSupported)) - (pod), (&(pod.pageableMemoryAccess)) - (pod), (&(pod.concurrentManagedAccess)) - (pod), (&(pod.computePreemptionSupported)) - (pod), (&(pod.canUseHostPointerForRegisteredMem)) - (pod), (&(pod.cooperativeLaunch)) - (pod), (&(pod.sharedMemPerBlockOptin)) - (pod), (&(pod.pageableMemoryAccessUsesHostPageTables)) - (pod), (&(pod.directManagedMemAccessFromHost)) - (pod), (&(pod.maxBlocksPerMultiProcessor)) - (pod), (&(pod.accessPolicyMaxWindowSize)) - (pod), (&(pod.reservedSharedMemPerBlock)) - (pod), (&(pod.hostRegisterSupported)) - (pod), (&(pod.sparseCudaArraySupported)) - (pod), (&(pod.hostRegisterReadOnlySupported)) - (pod), (&(pod.timelineSemaphoreInteropSupported)) - (pod), (&(pod.memoryPoolsSupported)) - (pod), (&(pod.gpuDirectRDMASupported)) - (pod), (&(pod.gpuDirectRDMAFlushWritesOptions)) - (pod), (&(pod.gpuDirectRDMAWritesOrdering)) - (pod), (&(pod.memoryPoolSupportedHandleTypes)) - (pod), (&(pod.deferredMappingCudaArraySupported)) - (pod), (&(pod.ipcEventSupported)) - (pod), (&(pod.clusterLaunch)) - (pod), (&(pod.unifiedFunctionPointers)) - (pod), (&(pod.deviceNumaConfig)) - (pod), (&(pod.deviceNumaId)) - (pod), (&(pod.mpsEnabled)) - (pod), (&(pod.hostNumaId)) - (pod), (&(pod.gpuPciDeviceID)) - (pod), (&(pod.gpuPciSubsystemID)) - (pod), (&(pod.hostNumaMultinodeIpcSupported)) - (pod), (&(pod.reserved)) - (pod), ], 'itemsize': sizeof(cudaDeviceProp), }) finally: _cyb_free(pod) device_prop_dtype = _get_device_prop_dtype_offsets() cdef class DeviceProp: """Empty-initialize an instance of `cudaDeviceProp`. .. seealso:: `cudaDeviceProp` """ cdef: cudaDeviceProp _data cudaDeviceProp *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.DeviceProp object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef DeviceProp other_ if not isinstance(other, DeviceProp): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaDeviceProp)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaDeviceProp), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This DeviceProp instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaDeviceProp): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaDeviceProp), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudaDeviceProp)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def uuid(self): """Uuid: 16-byte unique identifier""" return Uuid.from_ptr( &(self._ptr[0].uuid), readonly=self._readonly, owner=self, ) @uuid.setter def uuid(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") cdef Uuid val_ = val _cyb_memcpy(&(self._ptr[0].uuid), (val_._get_ptr()), sizeof(cudaUUID_t) * 1) @property def name(self): """~_numpy.int8: (array of length 256).ASCII string identifying device""" return _cyb_cpython.PyUnicode_FromString(self._ptr[0].name) @name.setter def name(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") cdef bytes buf = val.encode() if len(buf) >= 256: raise ValueError("String too long for field name, max length is 255") cdef char *ptr = buf _cyb_memcpy((self._ptr[0].name), ptr, 256) @property def luid(self): """~_numpy.int8: (array of length 8).8-byte locally unique identifier. Value is undefined on TCC and non-Windows platforms""" return _cyb_cpython.PyUnicode_FromString(self._ptr[0].luid) @luid.setter def luid(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") cdef bytes buf = val.encode() if len(buf) >= 8: raise ValueError("String too long for field luid, max length is 7") cdef char *ptr = buf _cyb_memcpy((self._ptr[0].luid), ptr, 8) @property def luid_device_node_mask(self): """int: LUID device node mask. Value is undefined on TCC and non-Windows platforms""" return self._ptr[0].luidDeviceNodeMask @luid_device_node_mask.setter def luid_device_node_mask(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].luidDeviceNodeMask = val @property def total_global_mem(self): """int: Global memory available on device in bytes""" return self._ptr[0].totalGlobalMem @total_global_mem.setter def total_global_mem(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].totalGlobalMem = val @property def shared_mem_per_block(self): """int: Shared memory available per block in bytes""" return self._ptr[0].sharedMemPerBlock @shared_mem_per_block.setter def shared_mem_per_block(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].sharedMemPerBlock = val @property def regs_per_block(self): """int: 32-bit registers available per block""" return self._ptr[0].regsPerBlock @regs_per_block.setter def regs_per_block(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].regsPerBlock = val @property def warp_size(self): """int: Warp size in threads""" return self._ptr[0].warpSize @warp_size.setter def warp_size(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].warpSize = val @property def mem_pitch(self): """int: Maximum pitch in bytes allowed by memory copies""" return self._ptr[0].memPitch @mem_pitch.setter def mem_pitch(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].memPitch = val @property def max_threads_per_block(self): """int: Maximum number of threads per block""" return self._ptr[0].maxThreadsPerBlock @max_threads_per_block.setter def max_threads_per_block(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].maxThreadsPerBlock = val @property def max_threads_dim(self): """~_numpy.int32: (array of length 3).Maximum size of each dimension of a block""" cdef _cyb_view.array arr = _cyb_view.array(shape=(3,), itemsize=sizeof(int), format="i", mode="c", allocate_buffer=False) arr.data = (&(self._ptr[0].maxThreadsDim)) return _numpy.asarray(arr) @max_threads_dim.setter def max_threads_dim(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") if len(val) != 3: raise ValueError(f"Expected length { 3 } for field max_threads_dim, got {len(val)}") cdef _cyb_view.array arr = _cyb_view.array(shape=(3,), itemsize=sizeof(int), format="i", mode="c") arr[:] = _numpy.asarray(val, dtype=_numpy.int32) _cyb_memcpy((&(self._ptr[0].maxThreadsDim)), (arr.data), sizeof(int) * len(val)) @property def max_grid_size(self): """~_numpy.int32: (array of length 3).Maximum size of each dimension of a grid""" cdef _cyb_view.array arr = _cyb_view.array(shape=(3,), itemsize=sizeof(int), format="i", mode="c", allocate_buffer=False) arr.data = (&(self._ptr[0].maxGridSize)) return _numpy.asarray(arr) @max_grid_size.setter def max_grid_size(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") if len(val) != 3: raise ValueError(f"Expected length { 3 } for field max_grid_size, got {len(val)}") cdef _cyb_view.array arr = _cyb_view.array(shape=(3,), itemsize=sizeof(int), format="i", mode="c") arr[:] = _numpy.asarray(val, dtype=_numpy.int32) _cyb_memcpy((&(self._ptr[0].maxGridSize)), (arr.data), sizeof(int) * len(val)) @property def total_const_mem(self): """int: Constant memory available on device in bytes""" return self._ptr[0].totalConstMem @total_const_mem.setter def total_const_mem(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].totalConstMem = val @property def major(self): """int: Major compute capability""" return self._ptr[0].major @major.setter def major(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].major = val @property def minor(self): """int: Minor compute capability""" return self._ptr[0].minor @minor.setter def minor(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].minor = val @property def texture_alignment(self): """int: Alignment requirement for textures""" return self._ptr[0].textureAlignment @texture_alignment.setter def texture_alignment(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].textureAlignment = val @property def texture_pitch_alignment(self): """int: Pitch alignment requirement for texture references bound to pitched memory""" return self._ptr[0].texturePitchAlignment @texture_pitch_alignment.setter def texture_pitch_alignment(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].texturePitchAlignment = val @property def multi_processor_count(self): """int: Number of multiprocessors on device""" return self._ptr[0].multiProcessorCount @multi_processor_count.setter def multi_processor_count(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].multiProcessorCount = val @property def integrated(self): """int: Device is integrated as opposed to discrete""" return self._ptr[0].integrated @integrated.setter def integrated(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].integrated = val @property def can_map_host_memory(self): """int: Device can map host memory with cudaHostAlloc/cudaHostGetDevicePointer""" return self._ptr[0].canMapHostMemory @can_map_host_memory.setter def can_map_host_memory(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].canMapHostMemory = val @property def max_texture1d(self): """int: Maximum 1D texture size""" return self._ptr[0].maxTexture1D @max_texture1d.setter def max_texture1d(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].maxTexture1D = val @property def max_texture1d_mipmap(self): """int: Maximum 1D mipmapped texture size""" return self._ptr[0].maxTexture1DMipmap @max_texture1d_mipmap.setter def max_texture1d_mipmap(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].maxTexture1DMipmap = val @property def max_texture2d(self): """~_numpy.int32: (array of length 2).Maximum 2D texture dimensions""" cdef _cyb_view.array arr = _cyb_view.array(shape=(2,), itemsize=sizeof(int), format="i", mode="c", allocate_buffer=False) arr.data = (&(self._ptr[0].maxTexture2D)) return _numpy.asarray(arr) @max_texture2d.setter def max_texture2d(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") if len(val) != 2: raise ValueError(f"Expected length { 2 } for field max_texture2d, got {len(val)}") cdef _cyb_view.array arr = _cyb_view.array(shape=(2,), itemsize=sizeof(int), format="i", mode="c") arr[:] = _numpy.asarray(val, dtype=_numpy.int32) _cyb_memcpy((&(self._ptr[0].maxTexture2D)), (arr.data), sizeof(int) * len(val)) @property def max_texture2d_mipmap(self): """~_numpy.int32: (array of length 2).Maximum 2D mipmapped texture dimensions""" cdef _cyb_view.array arr = _cyb_view.array(shape=(2,), itemsize=sizeof(int), format="i", mode="c", allocate_buffer=False) arr.data = (&(self._ptr[0].maxTexture2DMipmap)) return _numpy.asarray(arr) @max_texture2d_mipmap.setter def max_texture2d_mipmap(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") if len(val) != 2: raise ValueError(f"Expected length { 2 } for field max_texture2d_mipmap, got {len(val)}") cdef _cyb_view.array arr = _cyb_view.array(shape=(2,), itemsize=sizeof(int), format="i", mode="c") arr[:] = _numpy.asarray(val, dtype=_numpy.int32) _cyb_memcpy((&(self._ptr[0].maxTexture2DMipmap)), (arr.data), sizeof(int) * len(val)) @property def max_texture2d_linear(self): """~_numpy.int32: (array of length 3).Maximum dimensions (width, height, pitch) for 2D textures bound to pitched memory""" cdef _cyb_view.array arr = _cyb_view.array(shape=(3,), itemsize=sizeof(int), format="i", mode="c", allocate_buffer=False) arr.data = (&(self._ptr[0].maxTexture2DLinear)) return _numpy.asarray(arr) @max_texture2d_linear.setter def max_texture2d_linear(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") if len(val) != 3: raise ValueError(f"Expected length { 3 } for field max_texture2d_linear, got {len(val)}") cdef _cyb_view.array arr = _cyb_view.array(shape=(3,), itemsize=sizeof(int), format="i", mode="c") arr[:] = _numpy.asarray(val, dtype=_numpy.int32) _cyb_memcpy((&(self._ptr[0].maxTexture2DLinear)), (arr.data), sizeof(int) * len(val)) @property def max_texture2d_gather(self): """~_numpy.int32: (array of length 2).Maximum 2D texture dimensions if texture gather operations have to be performed""" cdef _cyb_view.array arr = _cyb_view.array(shape=(2,), itemsize=sizeof(int), format="i", mode="c", allocate_buffer=False) arr.data = (&(self._ptr[0].maxTexture2DGather)) return _numpy.asarray(arr) @max_texture2d_gather.setter def max_texture2d_gather(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") if len(val) != 2: raise ValueError(f"Expected length { 2 } for field max_texture2d_gather, got {len(val)}") cdef _cyb_view.array arr = _cyb_view.array(shape=(2,), itemsize=sizeof(int), format="i", mode="c") arr[:] = _numpy.asarray(val, dtype=_numpy.int32) _cyb_memcpy((&(self._ptr[0].maxTexture2DGather)), (arr.data), sizeof(int) * len(val)) @property def max_texture3d(self): """~_numpy.int32: (array of length 3).Maximum 3D texture dimensions""" cdef _cyb_view.array arr = _cyb_view.array(shape=(3,), itemsize=sizeof(int), format="i", mode="c", allocate_buffer=False) arr.data = (&(self._ptr[0].maxTexture3D)) return _numpy.asarray(arr) @max_texture3d.setter def max_texture3d(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") if len(val) != 3: raise ValueError(f"Expected length { 3 } for field max_texture3d, got {len(val)}") cdef _cyb_view.array arr = _cyb_view.array(shape=(3,), itemsize=sizeof(int), format="i", mode="c") arr[:] = _numpy.asarray(val, dtype=_numpy.int32) _cyb_memcpy((&(self._ptr[0].maxTexture3D)), (arr.data), sizeof(int) * len(val)) @property def max_texture3d_alt(self): """~_numpy.int32: (array of length 3).Maximum alternate 3D texture dimensions""" cdef _cyb_view.array arr = _cyb_view.array(shape=(3,), itemsize=sizeof(int), format="i", mode="c", allocate_buffer=False) arr.data = (&(self._ptr[0].maxTexture3DAlt)) return _numpy.asarray(arr) @max_texture3d_alt.setter def max_texture3d_alt(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") if len(val) != 3: raise ValueError(f"Expected length { 3 } for field max_texture3d_alt, got {len(val)}") cdef _cyb_view.array arr = _cyb_view.array(shape=(3,), itemsize=sizeof(int), format="i", mode="c") arr[:] = _numpy.asarray(val, dtype=_numpy.int32) _cyb_memcpy((&(self._ptr[0].maxTexture3DAlt)), (arr.data), sizeof(int) * len(val)) @property def max_texture_cubemap(self): """int: Maximum Cubemap texture dimensions""" return self._ptr[0].maxTextureCubemap @max_texture_cubemap.setter def max_texture_cubemap(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].maxTextureCubemap = val @property def max_texture1d_layered(self): """~_numpy.int32: (array of length 2).Maximum 1D layered texture dimensions""" cdef _cyb_view.array arr = _cyb_view.array(shape=(2,), itemsize=sizeof(int), format="i", mode="c", allocate_buffer=False) arr.data = (&(self._ptr[0].maxTexture1DLayered)) return _numpy.asarray(arr) @max_texture1d_layered.setter def max_texture1d_layered(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") if len(val) != 2: raise ValueError(f"Expected length { 2 } for field max_texture1d_layered, got {len(val)}") cdef _cyb_view.array arr = _cyb_view.array(shape=(2,), itemsize=sizeof(int), format="i", mode="c") arr[:] = _numpy.asarray(val, dtype=_numpy.int32) _cyb_memcpy((&(self._ptr[0].maxTexture1DLayered)), (arr.data), sizeof(int) * len(val)) @property def max_texture2d_layered(self): """~_numpy.int32: (array of length 3).Maximum 2D layered texture dimensions""" cdef _cyb_view.array arr = _cyb_view.array(shape=(3,), itemsize=sizeof(int), format="i", mode="c", allocate_buffer=False) arr.data = (&(self._ptr[0].maxTexture2DLayered)) return _numpy.asarray(arr) @max_texture2d_layered.setter def max_texture2d_layered(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") if len(val) != 3: raise ValueError(f"Expected length { 3 } for field max_texture2d_layered, got {len(val)}") cdef _cyb_view.array arr = _cyb_view.array(shape=(3,), itemsize=sizeof(int), format="i", mode="c") arr[:] = _numpy.asarray(val, dtype=_numpy.int32) _cyb_memcpy((&(self._ptr[0].maxTexture2DLayered)), (arr.data), sizeof(int) * len(val)) @property def max_texture_cubemap_layered(self): """~_numpy.int32: (array of length 2).Maximum Cubemap layered texture dimensions""" cdef _cyb_view.array arr = _cyb_view.array(shape=(2,), itemsize=sizeof(int), format="i", mode="c", allocate_buffer=False) arr.data = (&(self._ptr[0].maxTextureCubemapLayered)) return _numpy.asarray(arr) @max_texture_cubemap_layered.setter def max_texture_cubemap_layered(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") if len(val) != 2: raise ValueError(f"Expected length { 2 } for field max_texture_cubemap_layered, got {len(val)}") cdef _cyb_view.array arr = _cyb_view.array(shape=(2,), itemsize=sizeof(int), format="i", mode="c") arr[:] = _numpy.asarray(val, dtype=_numpy.int32) _cyb_memcpy((&(self._ptr[0].maxTextureCubemapLayered)), (arr.data), sizeof(int) * len(val)) @property def max_surface1d(self): """int: Maximum 1D surface size""" return self._ptr[0].maxSurface1D @max_surface1d.setter def max_surface1d(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].maxSurface1D = val @property def max_surface2d(self): """~_numpy.int32: (array of length 2).Maximum 2D surface dimensions""" cdef _cyb_view.array arr = _cyb_view.array(shape=(2,), itemsize=sizeof(int), format="i", mode="c", allocate_buffer=False) arr.data = (&(self._ptr[0].maxSurface2D)) return _numpy.asarray(arr) @max_surface2d.setter def max_surface2d(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") if len(val) != 2: raise ValueError(f"Expected length { 2 } for field max_surface2d, got {len(val)}") cdef _cyb_view.array arr = _cyb_view.array(shape=(2,), itemsize=sizeof(int), format="i", mode="c") arr[:] = _numpy.asarray(val, dtype=_numpy.int32) _cyb_memcpy((&(self._ptr[0].maxSurface2D)), (arr.data), sizeof(int) * len(val)) @property def max_surface3d(self): """~_numpy.int32: (array of length 3).Maximum 3D surface dimensions""" cdef _cyb_view.array arr = _cyb_view.array(shape=(3,), itemsize=sizeof(int), format="i", mode="c", allocate_buffer=False) arr.data = (&(self._ptr[0].maxSurface3D)) return _numpy.asarray(arr) @max_surface3d.setter def max_surface3d(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") if len(val) != 3: raise ValueError(f"Expected length { 3 } for field max_surface3d, got {len(val)}") cdef _cyb_view.array arr = _cyb_view.array(shape=(3,), itemsize=sizeof(int), format="i", mode="c") arr[:] = _numpy.asarray(val, dtype=_numpy.int32) _cyb_memcpy((&(self._ptr[0].maxSurface3D)), (arr.data), sizeof(int) * len(val)) @property def max_surface1d_layered(self): """~_numpy.int32: (array of length 2).Maximum 1D layered surface dimensions""" cdef _cyb_view.array arr = _cyb_view.array(shape=(2,), itemsize=sizeof(int), format="i", mode="c", allocate_buffer=False) arr.data = (&(self._ptr[0].maxSurface1DLayered)) return _numpy.asarray(arr) @max_surface1d_layered.setter def max_surface1d_layered(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") if len(val) != 2: raise ValueError(f"Expected length { 2 } for field max_surface1d_layered, got {len(val)}") cdef _cyb_view.array arr = _cyb_view.array(shape=(2,), itemsize=sizeof(int), format="i", mode="c") arr[:] = _numpy.asarray(val, dtype=_numpy.int32) _cyb_memcpy((&(self._ptr[0].maxSurface1DLayered)), (arr.data), sizeof(int) * len(val)) @property def max_surface2d_layered(self): """~_numpy.int32: (array of length 3).Maximum 2D layered surface dimensions""" cdef _cyb_view.array arr = _cyb_view.array(shape=(3,), itemsize=sizeof(int), format="i", mode="c", allocate_buffer=False) arr.data = (&(self._ptr[0].maxSurface2DLayered)) return _numpy.asarray(arr) @max_surface2d_layered.setter def max_surface2d_layered(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") if len(val) != 3: raise ValueError(f"Expected length { 3 } for field max_surface2d_layered, got {len(val)}") cdef _cyb_view.array arr = _cyb_view.array(shape=(3,), itemsize=sizeof(int), format="i", mode="c") arr[:] = _numpy.asarray(val, dtype=_numpy.int32) _cyb_memcpy((&(self._ptr[0].maxSurface2DLayered)), (arr.data), sizeof(int) * len(val)) @property def max_surface_cubemap(self): """int: Maximum Cubemap surface dimensions""" return self._ptr[0].maxSurfaceCubemap @max_surface_cubemap.setter def max_surface_cubemap(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].maxSurfaceCubemap = val @property def max_surface_cubemap_layered(self): """~_numpy.int32: (array of length 2).Maximum Cubemap layered surface dimensions""" cdef _cyb_view.array arr = _cyb_view.array(shape=(2,), itemsize=sizeof(int), format="i", mode="c", allocate_buffer=False) arr.data = (&(self._ptr[0].maxSurfaceCubemapLayered)) return _numpy.asarray(arr) @max_surface_cubemap_layered.setter def max_surface_cubemap_layered(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") if len(val) != 2: raise ValueError(f"Expected length { 2 } for field max_surface_cubemap_layered, got {len(val)}") cdef _cyb_view.array arr = _cyb_view.array(shape=(2,), itemsize=sizeof(int), format="i", mode="c") arr[:] = _numpy.asarray(val, dtype=_numpy.int32) _cyb_memcpy((&(self._ptr[0].maxSurfaceCubemapLayered)), (arr.data), sizeof(int) * len(val)) @property def surface_alignment(self): """int: Alignment requirements for surfaces""" return self._ptr[0].surfaceAlignment @surface_alignment.setter def surface_alignment(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].surfaceAlignment = val @property def concurrent_kernels(self): """int: Device can possibly execute multiple kernels concurrently""" return self._ptr[0].concurrentKernels @concurrent_kernels.setter def concurrent_kernels(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].concurrentKernels = val @property def ecc_enabled(self): """int: Device has ECC support enabled""" return self._ptr[0].ECCEnabled @ecc_enabled.setter def ecc_enabled(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].ECCEnabled = val @property def pci_bus_id(self): """int: PCI bus ID of the device""" return self._ptr[0].pciBusID @pci_bus_id.setter def pci_bus_id(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].pciBusID = val @property def pci_device_id(self): """int: PCI device ID of the device""" return self._ptr[0].pciDeviceID @pci_device_id.setter def pci_device_id(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].pciDeviceID = val @property def pci_domain_id(self): """int: PCI domain ID of the device""" return self._ptr[0].pciDomainID @pci_domain_id.setter def pci_domain_id(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].pciDomainID = val @property def tcc_driver(self): """int: 1 if device is a Tesla device using TCC driver, 0 otherwise""" return self._ptr[0].tccDriver @tcc_driver.setter def tcc_driver(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].tccDriver = val @property def async_engine_count(self): """int: Number of asynchronous engines""" return self._ptr[0].asyncEngineCount @async_engine_count.setter def async_engine_count(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].asyncEngineCount = val @property def unified_addressing(self): """int: Device shares a unified address space with the host""" return self._ptr[0].unifiedAddressing @unified_addressing.setter def unified_addressing(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].unifiedAddressing = val @property def memory_bus_width(self): """int: Global memory bus width in bits""" return self._ptr[0].memoryBusWidth @memory_bus_width.setter def memory_bus_width(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].memoryBusWidth = val @property def l2cache_size(self): """int: Size of L2 cache in bytes""" return self._ptr[0].l2CacheSize @l2cache_size.setter def l2cache_size(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].l2CacheSize = val @property def persisting_l2cache_max_size(self): """int: Device's maximum l2 persisting lines capacity setting in bytes""" return self._ptr[0].persistingL2CacheMaxSize @persisting_l2cache_max_size.setter def persisting_l2cache_max_size(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].persistingL2CacheMaxSize = val @property def max_threads_per_multi_processor(self): """int: Maximum resident threads per multiprocessor""" return self._ptr[0].maxThreadsPerMultiProcessor @max_threads_per_multi_processor.setter def max_threads_per_multi_processor(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].maxThreadsPerMultiProcessor = val @property def stream_priorities_supported(self): """int: Device supports stream priorities""" return self._ptr[0].streamPrioritiesSupported @stream_priorities_supported.setter def stream_priorities_supported(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].streamPrioritiesSupported = val @property def global_l1cache_supported(self): """int: Device supports caching globals in L1""" return self._ptr[0].globalL1CacheSupported @global_l1cache_supported.setter def global_l1cache_supported(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].globalL1CacheSupported = val @property def local_l1cache_supported(self): """int: Device supports caching locals in L1""" return self._ptr[0].localL1CacheSupported @local_l1cache_supported.setter def local_l1cache_supported(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].localL1CacheSupported = val @property def shared_mem_per_multiprocessor(self): """int: Shared memory available per multiprocessor in bytes""" return self._ptr[0].sharedMemPerMultiprocessor @shared_mem_per_multiprocessor.setter def shared_mem_per_multiprocessor(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].sharedMemPerMultiprocessor = val @property def regs_per_multiprocessor(self): """int: 32-bit registers available per multiprocessor""" return self._ptr[0].regsPerMultiprocessor @regs_per_multiprocessor.setter def regs_per_multiprocessor(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].regsPerMultiprocessor = val @property def managed_memory(self): """int: Device supports allocating managed memory on this system""" return self._ptr[0].managedMemory @managed_memory.setter def managed_memory(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].managedMemory = val @property def is_multi_gpu_board(self): """int: Device is on a multi-GPU board""" return self._ptr[0].isMultiGpuBoard @is_multi_gpu_board.setter def is_multi_gpu_board(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].isMultiGpuBoard = val @property def multi_gpu_board_group_id(self): """int: Unique identifier for a group of devices on the same multi-GPU board""" return self._ptr[0].multiGpuBoardGroupID @multi_gpu_board_group_id.setter def multi_gpu_board_group_id(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].multiGpuBoardGroupID = val @property def host_native_atomic_supported(self): """int: Link between the device and the host supports native atomic operations""" return self._ptr[0].hostNativeAtomicSupported @host_native_atomic_supported.setter def host_native_atomic_supported(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].hostNativeAtomicSupported = val @property def pageable_memory_access(self): """int: Device supports coherently accessing pageable memory without calling cudaHostRegister on it""" return self._ptr[0].pageableMemoryAccess @pageable_memory_access.setter def pageable_memory_access(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].pageableMemoryAccess = val @property def concurrent_managed_access(self): """int: Device can coherently access managed memory concurrently with the CPU""" return self._ptr[0].concurrentManagedAccess @concurrent_managed_access.setter def concurrent_managed_access(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].concurrentManagedAccess = val @property def compute_preemption_supported(self): """int: Device supports Compute Preemption""" return self._ptr[0].computePreemptionSupported @compute_preemption_supported.setter def compute_preemption_supported(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].computePreemptionSupported = val @property def can_use_host_pointer_for_registered_mem(self): """int: Device can access host registered memory at the same virtual address as the CPU""" return self._ptr[0].canUseHostPointerForRegisteredMem @can_use_host_pointer_for_registered_mem.setter def can_use_host_pointer_for_registered_mem(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].canUseHostPointerForRegisteredMem = val @property def cooperative_launch(self): """int: Device supports launching cooperative kernels via cudaLaunchCooperativeKernel""" return self._ptr[0].cooperativeLaunch @cooperative_launch.setter def cooperative_launch(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].cooperativeLaunch = val @property def shared_mem_per_block_optin(self): """int: Per device maximum shared memory per block usable by special opt in""" return self._ptr[0].sharedMemPerBlockOptin @shared_mem_per_block_optin.setter def shared_mem_per_block_optin(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].sharedMemPerBlockOptin = val @property def pageable_memory_access_uses_host_page_tables(self): """int: Device accesses pageable memory via the host's page tables""" return self._ptr[0].pageableMemoryAccessUsesHostPageTables @pageable_memory_access_uses_host_page_tables.setter def pageable_memory_access_uses_host_page_tables(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].pageableMemoryAccessUsesHostPageTables = val @property def direct_managed_mem_access_from_host(self): """int: Host can directly access managed memory on the device without migration.""" return self._ptr[0].directManagedMemAccessFromHost @direct_managed_mem_access_from_host.setter def direct_managed_mem_access_from_host(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].directManagedMemAccessFromHost = val @property def max_blocks_per_multi_processor(self): """int: Maximum number of resident blocks per multiprocessor""" return self._ptr[0].maxBlocksPerMultiProcessor @max_blocks_per_multi_processor.setter def max_blocks_per_multi_processor(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].maxBlocksPerMultiProcessor = val @property def access_policy_max_window_size(self): """int: The maximum value of cudaAccessPolicyWindow::num_bytes.""" return self._ptr[0].accessPolicyMaxWindowSize @access_policy_max_window_size.setter def access_policy_max_window_size(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].accessPolicyMaxWindowSize = val @property def reserved_shared_mem_per_block(self): """int: Shared memory reserved by CUDA driver per block in bytes""" return self._ptr[0].reservedSharedMemPerBlock @reserved_shared_mem_per_block.setter def reserved_shared_mem_per_block(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].reservedSharedMemPerBlock = val @property def host_register_supported(self): """int: Device supports host memory registration via cudaHostRegister.""" return self._ptr[0].hostRegisterSupported @host_register_supported.setter def host_register_supported(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].hostRegisterSupported = val @property def sparse_cuda_array_supported(self): """int: 1 if the device supports sparse CUDA arrays and sparse CUDA mipmapped arrays, 0 otherwise""" return self._ptr[0].sparseCudaArraySupported @sparse_cuda_array_supported.setter def sparse_cuda_array_supported(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].sparseCudaArraySupported = val @property def host_register_read_only_supported(self): """int: Device supports using the cudaHostRegister flag cudaHostRegisterReadOnly to register memory that must be mapped as read-only to the GPU""" return self._ptr[0].hostRegisterReadOnlySupported @host_register_read_only_supported.setter def host_register_read_only_supported(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].hostRegisterReadOnlySupported = val @property def timeline_semaphore_interop_supported(self): """int: External timeline semaphore interop is supported on the device""" return self._ptr[0].timelineSemaphoreInteropSupported @timeline_semaphore_interop_supported.setter def timeline_semaphore_interop_supported(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].timelineSemaphoreInteropSupported = val @property def memory_pools_supported(self): """int: 1 if the device supports using the cudaMallocAsync and cudaMemPool family of APIs, 0 otherwise""" return self._ptr[0].memoryPoolsSupported @memory_pools_supported.setter def memory_pools_supported(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].memoryPoolsSupported = val @property def gpu_direct_rdma_supported(self): """int: 1 if the device supports GPUDirect RDMA APIs, 0 otherwise""" return self._ptr[0].gpuDirectRDMASupported @gpu_direct_rdma_supported.setter def gpu_direct_rdma_supported(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].gpuDirectRDMASupported = val @property def gpu_direct_rdma_flush_writes_options(self): """int: Bitmask to be interpreted according to the cudaFlushGPUDirectRDMAWritesOptions enum""" return self._ptr[0].gpuDirectRDMAFlushWritesOptions @gpu_direct_rdma_flush_writes_options.setter def gpu_direct_rdma_flush_writes_options(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].gpuDirectRDMAFlushWritesOptions = val @property def gpu_direct_rdma_writes_ordering(self): """int: See the cudaGPUDirectRDMAWritesOrdering enum for numerical values""" return self._ptr[0].gpuDirectRDMAWritesOrdering @gpu_direct_rdma_writes_ordering.setter def gpu_direct_rdma_writes_ordering(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].gpuDirectRDMAWritesOrdering = val @property def memory_pool_supported_handle_types(self): """int: Bitmask of handle types supported with mempool-based IPC""" return self._ptr[0].memoryPoolSupportedHandleTypes @memory_pool_supported_handle_types.setter def memory_pool_supported_handle_types(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].memoryPoolSupportedHandleTypes = val @property def deferred_mapping_cuda_array_supported(self): """int: 1 if the device supports deferred mapping CUDA arrays and CUDA mipmapped arrays""" return self._ptr[0].deferredMappingCudaArraySupported @deferred_mapping_cuda_array_supported.setter def deferred_mapping_cuda_array_supported(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].deferredMappingCudaArraySupported = val @property def ipc_event_supported(self): """int: Device supports IPC Events.""" return self._ptr[0].ipcEventSupported @ipc_event_supported.setter def ipc_event_supported(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].ipcEventSupported = val @property def cluster_launch(self): """int: Indicates device supports cluster launch""" return self._ptr[0].clusterLaunch @cluster_launch.setter def cluster_launch(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].clusterLaunch = val @property def unified_function_pointers(self): """int: Indicates device supports unified pointers""" return self._ptr[0].unifiedFunctionPointers @unified_function_pointers.setter def unified_function_pointers(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].unifiedFunctionPointers = val @property def device_numa_config(self): """int: NUMA configuration of a device: value is of type cudaDeviceNumaConfig enum""" return self._ptr[0].deviceNumaConfig @device_numa_config.setter def device_numa_config(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].deviceNumaConfig = val @property def device_numa_id(self): """int: NUMA node ID of the GPU memory""" return self._ptr[0].deviceNumaId @device_numa_id.setter def device_numa_id(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].deviceNumaId = val @property def mps_enabled(self): """int: Indicates if contexts created on this device will be shared via MPS""" return self._ptr[0].mpsEnabled @mps_enabled.setter def mps_enabled(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].mpsEnabled = val @property def host_numa_id(self): """int: NUMA ID of the host node closest to the device or -1 when system does not support NUMA""" return self._ptr[0].hostNumaId @host_numa_id.setter def host_numa_id(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].hostNumaId = val @property def gpu_pci_device_id(self): """int: The combined 16-bit PCI device ID and 16-bit PCI vendor ID""" return self._ptr[0].gpuPciDeviceID @gpu_pci_device_id.setter def gpu_pci_device_id(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].gpuPciDeviceID = val @property def gpu_pci_subsystem_id(self): """int: The combined 16-bit PCI subsystem ID and 16-bit PCI subsystem vendor ID""" return self._ptr[0].gpuPciSubsystemID @gpu_pci_subsystem_id.setter def gpu_pci_subsystem_id(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].gpuPciSubsystemID = val @property def host_numa_multinode_ipc_supported(self): """int: 1 if the device supports HostNuma location IPC between nodes in a multi-node system.""" return self._ptr[0].hostNumaMultinodeIpcSupported @host_numa_multinode_ipc_supported.setter def host_numa_multinode_ipc_supported(self, val): if self._readonly: raise ValueError("This DeviceProp instance is read-only") self._ptr[0].hostNumaMultinodeIpcSupported = val @staticmethod def from_buffer(buffer): """Create an DeviceProp instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaDeviceProp), DeviceProp) @staticmethod def from_data(data): """Create an DeviceProp instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `device_prop_dtype` holding the data. """ return _cyb_from_data(data, "device_prop_dtype", device_prop_dtype, DeviceProp) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an DeviceProp instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef DeviceProp obj = DeviceProp.__new__(DeviceProp) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudaDeviceProp)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod13_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod13 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod13)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod13") try: return _numpy.dtype({ 'names': ['fd', 'win32', 'nv_sci_buf_object'], 'formats': [_numpy.int32, _py_anon_pod14_dtype, _numpy.intp], 'offsets': [ (&(pod.fd)) - (pod), (&(pod.win32)) - (pod), (&(pod.nvSciBufObject)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod13), }) finally: _cyb_free(pod) _py_anon_pod13_dtype = _get__py_anon_pod13_dtype_offsets() cdef class _py_anon_pod13: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod13`. .. seealso:: `cuda_bindings_runtime__anon_pod13` """ cdef: cuda_bindings_runtime__anon_pod13 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod13)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod13") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod13 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod13 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod13 other_ if not isinstance(other, _py_anon_pod13): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod13)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod13), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod13 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod13): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod13), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod13)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def win32(self): """_py_anon_pod14: """ return _py_anon_pod14.from_ptr( &(self._ptr[0].win32), readonly=self._readonly, owner=self, ) @win32.setter def win32(self, val): if self._readonly: raise ValueError("This _py_anon_pod13 instance is read-only") cdef _py_anon_pod14 val_ = val _cyb_memcpy(&(self._ptr[0].win32), (val_._get_ptr()), sizeof(cuda_bindings_runtime__anon_pod14) * 1) @property def fd(self): """int: """ return self._ptr[0].fd @fd.setter def fd(self, val): if self._readonly: raise ValueError("This _py_anon_pod13 instance is read-only") self._ptr[0].fd = val @property def nv_sci_buf_object(self): """int: """ return (self._ptr[0].nvSciBufObject) @nv_sci_buf_object.setter def nv_sci_buf_object(self, val): if self._readonly: raise ValueError("This _py_anon_pod13 instance is read-only") self._ptr[0].nvSciBufObject = val @staticmethod def from_buffer(buffer): """Create an _py_anon_pod13 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod13), _py_anon_pod13) @staticmethod def from_data(data): """Create an _py_anon_pod13 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod13_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod13_dtype", _py_anon_pod13_dtype, _py_anon_pod13) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod13 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod13 obj = _py_anon_pod13.__new__(_py_anon_pod13) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod13)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod13") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod13)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod15_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod15 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod15)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod15") try: return _numpy.dtype({ 'names': ['fd', 'win32', 'nv_sci_sync_obj'], 'formats': [_numpy.int32, _py_anon_pod16_dtype, _numpy.intp], 'offsets': [ (&(pod.fd)) - (pod), (&(pod.win32)) - (pod), (&(pod.nvSciSyncObj)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod15), }) finally: _cyb_free(pod) _py_anon_pod15_dtype = _get__py_anon_pod15_dtype_offsets() cdef class _py_anon_pod15: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod15`. .. seealso:: `cuda_bindings_runtime__anon_pod15` """ cdef: cuda_bindings_runtime__anon_pod15 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod15)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod15") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod15 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod15 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod15 other_ if not isinstance(other, _py_anon_pod15): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod15)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod15), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod15 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod15): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod15), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod15)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def win32(self): """_py_anon_pod16: """ return _py_anon_pod16.from_ptr( &(self._ptr[0].win32), readonly=self._readonly, owner=self, ) @win32.setter def win32(self, val): if self._readonly: raise ValueError("This _py_anon_pod15 instance is read-only") cdef _py_anon_pod16 val_ = val _cyb_memcpy(&(self._ptr[0].win32), (val_._get_ptr()), sizeof(cuda_bindings_runtime__anon_pod16) * 1) @property def fd(self): """int: """ return self._ptr[0].fd @fd.setter def fd(self, val): if self._readonly: raise ValueError("This _py_anon_pod15 instance is read-only") self._ptr[0].fd = val @property def nv_sci_sync_obj(self): """int: """ return (self._ptr[0].nvSciSyncObj) @nv_sci_sync_obj.setter def nv_sci_sync_obj(self, val): if self._readonly: raise ValueError("This _py_anon_pod15 instance is read-only") self._ptr[0].nvSciSyncObj = val @staticmethod def from_buffer(buffer): """Create an _py_anon_pod15 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod15), _py_anon_pod15) @staticmethod def from_data(data): """Create an _py_anon_pod15 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod15_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod15_dtype", _py_anon_pod15_dtype, _py_anon_pod15) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod15 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod15 obj = _py_anon_pod15.__new__(_py_anon_pod15) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod15)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod15") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod15)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod17_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod17 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod17)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod17") try: return _numpy.dtype({ 'names': ['fence', 'nv_sci_sync', 'keyed_mutex', 'reserved'], 'formats': [_py_anon_pod18_dtype, _py_anon_pod19_dtype, _py_anon_pod20_dtype, (_numpy.uint32, 12)], 'offsets': [ (&(pod.fence)) - (pod), (&(pod.nvSciSync)) - (pod), (&(pod.keyedMutex)) - (pod), (&(pod.reserved)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod17), }) finally: _cyb_free(pod) _py_anon_pod17_dtype = _get__py_anon_pod17_dtype_offsets() cdef class _py_anon_pod17: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod17`. .. seealso:: `cuda_bindings_runtime__anon_pod17` """ cdef: cuda_bindings_runtime__anon_pod17 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod17)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod17") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod17 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod17 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod17 other_ if not isinstance(other, _py_anon_pod17): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod17)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod17), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod17 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod17): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod17), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod17)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def fence(self): """_py_anon_pod18: """ return _py_anon_pod18.from_ptr( &(self._ptr[0].fence), readonly=self._readonly, owner=self, ) @fence.setter def fence(self, val): if self._readonly: raise ValueError("This _py_anon_pod17 instance is read-only") cdef _py_anon_pod18 val_ = val _cyb_memcpy(&(self._ptr[0].fence), (val_._get_ptr()), sizeof(cuda_bindings_runtime__anon_pod18) * 1) @property def nv_sci_sync(self): """_py_anon_pod19: """ return _py_anon_pod19.from_ptr( &(self._ptr[0].nvSciSync), readonly=self._readonly, owner=self, ) @nv_sci_sync.setter def nv_sci_sync(self, val): if self._readonly: raise ValueError("This _py_anon_pod17 instance is read-only") cdef _py_anon_pod19 val_ = val _cyb_memcpy(&(self._ptr[0].nvSciSync), (val_._get_ptr()), sizeof(cuda_bindings_runtime__anon_pod19) * 1) @property def keyed_mutex(self): """_py_anon_pod20: """ return _py_anon_pod20.from_ptr( &(self._ptr[0].keyedMutex), readonly=self._readonly, owner=self, ) @keyed_mutex.setter def keyed_mutex(self, val): if self._readonly: raise ValueError("This _py_anon_pod17 instance is read-only") cdef _py_anon_pod20 val_ = val _cyb_memcpy(&(self._ptr[0].keyedMutex), (val_._get_ptr()), sizeof(cuda_bindings_runtime__anon_pod20) * 1) @staticmethod def from_buffer(buffer): """Create an _py_anon_pod17 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod17), _py_anon_pod17) @staticmethod def from_data(data): """Create an _py_anon_pod17 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod17_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod17_dtype", _py_anon_pod17_dtype, _py_anon_pod17) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod17 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod17 obj = _py_anon_pod17.__new__(_py_anon_pod17) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod17)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod17") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod17)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod21_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod21 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod21)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod21") try: return _numpy.dtype({ 'names': ['fence', 'nv_sci_sync', 'keyed_mutex', 'reserved'], 'formats': [_py_anon_pod22_dtype, _py_anon_pod23_dtype, _py_anon_pod24_dtype, (_numpy.uint32, 10)], 'offsets': [ (&(pod.fence)) - (pod), (&(pod.nvSciSync)) - (pod), (&(pod.keyedMutex)) - (pod), (&(pod.reserved)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod21), }) finally: _cyb_free(pod) _py_anon_pod21_dtype = _get__py_anon_pod21_dtype_offsets() cdef class _py_anon_pod21: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod21`. .. seealso:: `cuda_bindings_runtime__anon_pod21` """ cdef: cuda_bindings_runtime__anon_pod21 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod21)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod21") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod21 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod21 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod21 other_ if not isinstance(other, _py_anon_pod21): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod21)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod21), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod21 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod21): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod21), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod21)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def fence(self): """_py_anon_pod22: """ return _py_anon_pod22.from_ptr( &(self._ptr[0].fence), readonly=self._readonly, owner=self, ) @fence.setter def fence(self, val): if self._readonly: raise ValueError("This _py_anon_pod21 instance is read-only") cdef _py_anon_pod22 val_ = val _cyb_memcpy(&(self._ptr[0].fence), (val_._get_ptr()), sizeof(cuda_bindings_runtime__anon_pod22) * 1) @property def nv_sci_sync(self): """_py_anon_pod23: """ return _py_anon_pod23.from_ptr( &(self._ptr[0].nvSciSync), readonly=self._readonly, owner=self, ) @nv_sci_sync.setter def nv_sci_sync(self, val): if self._readonly: raise ValueError("This _py_anon_pod21 instance is read-only") cdef _py_anon_pod23 val_ = val _cyb_memcpy(&(self._ptr[0].nvSciSync), (val_._get_ptr()), sizeof(cuda_bindings_runtime__anon_pod23) * 1) @property def keyed_mutex(self): """_py_anon_pod24: """ return _py_anon_pod24.from_ptr( &(self._ptr[0].keyedMutex), readonly=self._readonly, owner=self, ) @keyed_mutex.setter def keyed_mutex(self, val): if self._readonly: raise ValueError("This _py_anon_pod21 instance is read-only") cdef _py_anon_pod24 val_ = val _cyb_memcpy(&(self._ptr[0].keyedMutex), (val_._get_ptr()), sizeof(cuda_bindings_runtime__anon_pod24) * 1) @staticmethod def from_buffer(buffer): """Create an _py_anon_pod21 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod21), _py_anon_pod21) @staticmethod def from_data(data): """Create an _py_anon_pod21 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod21_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod21_dtype", _py_anon_pod21_dtype, _py_anon_pod21) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod21 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod21 obj = _py_anon_pod21.__new__(_py_anon_pod21) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod21)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod21") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod21)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_kernel_node_params_v2_dtype_offsets(): cdef cudaKernelNodeParamsV2 *pod = _cyb_calloc(1, sizeof(cudaKernelNodeParamsV2)) if pod == NULL: raise MemoryError("Error allocating cudaKernelNodeParamsV2") try: return _numpy.dtype({ 'names': ['func', 'kern', 'cu_func', 'grid_dim', 'block_dim', 'shared_mem_bytes', 'kernel_params', 'extra', 'ctx', 'function_type'], 'formats': [_numpy.intp, _numpy.intp, _numpy.intp, dim3_dtype, dim3_dtype, _numpy.uint32, _numpy.intp, _numpy.intp, _numpy.intp, _numpy.int32], 'offsets': [ (&(pod.func)) - (pod), (&(pod.kern)) - (pod), (&(pod.cuFunc)) - (pod), (&(pod.gridDim)) - (pod), (&(pod.blockDim)) - (pod), (&(pod.sharedMemBytes)) - (pod), (&(pod.kernelParams)) - (pod), (&(pod.extra)) - (pod), (&(pod.ctx)) - (pod), (&(pod.functionType)) - (pod), ], 'itemsize': sizeof(cudaKernelNodeParamsV2), }) finally: _cyb_free(pod) kernel_node_params_v2_dtype = _get_kernel_node_params_v2_dtype_offsets() cdef class KernelNodeParamsV2: """Empty-initialize an instance of `cudaKernelNodeParamsV2`. .. seealso:: `cudaKernelNodeParamsV2` """ cdef: cudaKernelNodeParamsV2 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cudaKernelNodeParamsV2)) if self._ptr == NULL: raise MemoryError("Error allocating KernelNodeParamsV2") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cudaKernelNodeParamsV2 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.KernelNodeParamsV2 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef KernelNodeParamsV2 other_ if not isinstance(other, KernelNodeParamsV2): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaKernelNodeParamsV2)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaKernelNodeParamsV2), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This KernelNodeParamsV2 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaKernelNodeParamsV2): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaKernelNodeParamsV2), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cudaKernelNodeParamsV2)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def grid_dim(self): """Dim3: Grid dimensions""" return Dim3.from_ptr( &(self._ptr[0].gridDim), readonly=self._readonly, owner=self, ) @grid_dim.setter def grid_dim(self, val): if self._readonly: raise ValueError("This KernelNodeParamsV2 instance is read-only") cdef Dim3 val_ = val _cyb_memcpy(&(self._ptr[0].gridDim), (val_._get_ptr()), sizeof(dim3) * 1) @property def block_dim(self): """Dim3: Block dimensions""" return Dim3.from_ptr( &(self._ptr[0].blockDim), readonly=self._readonly, owner=self, ) @block_dim.setter def block_dim(self, val): if self._readonly: raise ValueError("This KernelNodeParamsV2 instance is read-only") cdef Dim3 val_ = val _cyb_memcpy(&(self._ptr[0].blockDim), (val_._get_ptr()), sizeof(dim3) * 1) @property def func(self): """int: functionType = cudaKernelFucntionTypeDevice""" return (self._ptr[0].func) @func.setter def func(self, val): if self._readonly: raise ValueError("This KernelNodeParamsV2 instance is read-only") self._ptr[0].func = val @property def kern(self): """int: functionType = cudaKernelFucntionTypeKernel""" return (self._ptr[0].kern) @kern.setter def kern(self, val): if self._readonly: raise ValueError("This KernelNodeParamsV2 instance is read-only") self._ptr[0].kern = val @property def cu_func(self): """int: functionType = cudaKernelFucntionTypeFunction""" return (self._ptr[0].cuFunc) @cu_func.setter def cu_func(self, val): if self._readonly: raise ValueError("This KernelNodeParamsV2 instance is read-only") self._ptr[0].cuFunc = val @property def shared_mem_bytes(self): """int: Dynamic shared-memory size per thread block in bytes""" return self._ptr[0].sharedMemBytes @shared_mem_bytes.setter def shared_mem_bytes(self, val): if self._readonly: raise ValueError("This KernelNodeParamsV2 instance is read-only") self._ptr[0].sharedMemBytes = val @property def kernel_params(self): """int: Array of pointers to individual kernel arguments""" return (self._ptr[0].kernelParams) @kernel_params.setter def kernel_params(self, val): if self._readonly: raise ValueError("This KernelNodeParamsV2 instance is read-only") self._ptr[0].kernelParams = val @property def extra(self): """int: Pointer to kernel arguments in the "extra" format""" return (self._ptr[0].extra) @extra.setter def extra(self, val): if self._readonly: raise ValueError("This KernelNodeParamsV2 instance is read-only") self._ptr[0].extra = val @property def ctx(self): """int: Context in which to run the kernel. If NULL will try to use the current context.""" return (self._ptr[0].ctx) @ctx.setter def ctx(self, val): if self._readonly: raise ValueError("This KernelNodeParamsV2 instance is read-only") self._ptr[0].ctx = val @property def function_type(self): """int: Type of handle passed in the func/kern/cuFunc union above""" return (self._ptr[0].functionType) @function_type.setter def function_type(self, val): if self._readonly: raise ValueError("This KernelNodeParamsV2 instance is read-only") self._ptr[0].functionType = val @staticmethod def from_buffer(buffer): """Create an KernelNodeParamsV2 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaKernelNodeParamsV2), KernelNodeParamsV2) @staticmethod def from_data(data): """Create an KernelNodeParamsV2 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `kernel_node_params_v2_dtype` holding the data. """ return _cyb_from_data(data, "kernel_node_params_v2_dtype", kernel_node_params_v2_dtype, KernelNodeParamsV2) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an KernelNodeParamsV2 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef KernelNodeParamsV2 obj = KernelNodeParamsV2.__new__(KernelNodeParamsV2) if owner is None: obj._ptr = _cyb_malloc(sizeof(cudaKernelNodeParamsV2)) if obj._ptr == NULL: raise MemoryError("Error allocating KernelNodeParamsV2") _cyb_memcpy((obj._ptr), ptr, sizeof(cudaKernelNodeParamsV2)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod27_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod27 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod27)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod27") try: return _numpy.dtype({ 'names': ['grid_dim', 'param', 'is_enabled'], 'formats': [dim3_dtype, _py_anon_pod28_dtype, _numpy.uint32], 'offsets': [ (&(pod.gridDim)) - (pod), (&(pod.param)) - (pod), (&(pod.isEnabled)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod27), }) finally: _cyb_free(pod) _py_anon_pod27_dtype = _get__py_anon_pod27_dtype_offsets() cdef class _py_anon_pod27: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod27`. .. seealso:: `cuda_bindings_runtime__anon_pod27` """ cdef: cuda_bindings_runtime__anon_pod27 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod27)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod27") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod27 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod27 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod27 other_ if not isinstance(other, _py_anon_pod27): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod27)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod27), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod27 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod27): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod27), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod27)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def grid_dim(self): """Dim3: """ return Dim3.from_ptr( &(self._ptr[0].gridDim), readonly=self._readonly, owner=self, ) @grid_dim.setter def grid_dim(self, val): if self._readonly: raise ValueError("This _py_anon_pod27 instance is read-only") cdef Dim3 val_ = val _cyb_memcpy(&(self._ptr[0].gridDim), (val_._get_ptr()), sizeof(dim3) * 1) @property def param(self): """_py_anon_pod28: """ return _py_anon_pod28.from_ptr( &(self._ptr[0].param), readonly=self._readonly, owner=self, ) @param.setter def param(self, val): if self._readonly: raise ValueError("This _py_anon_pod27 instance is read-only") cdef _py_anon_pod28 val_ = val _cyb_memcpy(&(self._ptr[0].param), (val_._get_ptr()), sizeof(cuda_bindings_runtime__anon_pod28) * 1) @property def is_enabled(self): """int: """ return self._ptr[0].isEnabled @is_enabled.setter def is_enabled(self, val): if self._readonly: raise ValueError("This _py_anon_pod27 instance is read-only") self._ptr[0].isEnabled = val @staticmethod def from_buffer(buffer): """Create an _py_anon_pod27 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod27), _py_anon_pod27) @staticmethod def from_data(data): """Create an _py_anon_pod27 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod27_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod27_dtype", _py_anon_pod27_dtype, _py_anon_pod27) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod27 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod27 obj = _py_anon_pod27.__new__(_py_anon_pod27) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod27)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod27") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod27)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_launch_attribute_value_dtype_offsets(): cdef cudaLaunchAttributeValue *pod = _cyb_calloc(1, sizeof(cudaLaunchAttributeValue)) if pod == NULL: raise MemoryError("Error allocating cudaLaunchAttributeValue") try: return _numpy.dtype({ 'names': ['pad', 'access_policy_window', 'cooperative', 'sync_policy', 'cluster_dim', 'cluster_scheduling_policy_preference', 'programmatic_stream_serialization_allowed', 'programmatic_event', 'priority', 'mem_sync_domain_map', 'mem_sync_domain', 'preferred_cluster_dim', 'launch_completion_event', 'device_updatable_kernel_node', 'shared_mem_carveout', 'nvlink_util_centric_scheduling', 'portable_cluster_size_mode', 'shared_memory_mode'], 'formats': [(_numpy.int8, 64), access_policy_window_dtype, _numpy.int32, _numpy.int32, _py_anon_pod29_dtype, _numpy.int32, _numpy.int32, _py_anon_pod30_dtype, _numpy.int32, launch_mem_sync_domain_map_dtype, _numpy.int32, _py_anon_pod31_dtype, _py_anon_pod32_dtype, _py_anon_pod33_dtype, _numpy.uint32, _numpy.uint32, _numpy.int32, _numpy.int32], 'offsets': [ (&(pod.pad)) - (pod), (&(pod.accessPolicyWindow)) - (pod), (&(pod.cooperative)) - (pod), (&(pod.syncPolicy)) - (pod), (&(pod.clusterDim)) - (pod), (&(pod.clusterSchedulingPolicyPreference)) - (pod), (&(pod.programmaticStreamSerializationAllowed)) - (pod), (&(pod.programmaticEvent)) - (pod), (&(pod.priority)) - (pod), (&(pod.memSyncDomainMap)) - (pod), (&(pod.memSyncDomain)) - (pod), (&(pod.preferredClusterDim)) - (pod), (&(pod.launchCompletionEvent)) - (pod), (&(pod.deviceUpdatableKernelNode)) - (pod), (&(pod.sharedMemCarveout)) - (pod), (&(pod.nvlinkUtilCentricScheduling)) - (pod), (&(pod.portableClusterSizeMode)) - (pod), (&(pod.sharedMemoryMode)) - (pod), ], 'itemsize': sizeof(cudaLaunchAttributeValue), }) finally: _cyb_free(pod) launch_attribute_value_dtype = _get_launch_attribute_value_dtype_offsets() cdef class LaunchAttributeValue: """Empty-initialize an instance of `cudaLaunchAttributeValue`. .. seealso:: `cudaLaunchAttributeValue` """ cdef: cudaLaunchAttributeValue *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cudaLaunchAttributeValue)) if self._ptr == NULL: raise MemoryError("Error allocating LaunchAttributeValue") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cudaLaunchAttributeValue *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.LaunchAttributeValue object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef LaunchAttributeValue other_ if not isinstance(other, LaunchAttributeValue): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaLaunchAttributeValue)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaLaunchAttributeValue), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This LaunchAttributeValue instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaLaunchAttributeValue): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaLaunchAttributeValue), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cudaLaunchAttributeValue)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def access_policy_window(self): """AccessPolicyWindow: Value of launch attribute cudaLaunchAttributeAccessPolicyWindow.""" return AccessPolicyWindow.from_ptr( &(self._ptr[0].accessPolicyWindow), readonly=self._readonly, owner=self, ) @access_policy_window.setter def access_policy_window(self, val): if self._readonly: raise ValueError("This LaunchAttributeValue instance is read-only") cdef AccessPolicyWindow val_ = val _cyb_memcpy(&(self._ptr[0].accessPolicyWindow), (val_._get_ptr()), sizeof(cudaAccessPolicyWindow) * 1) @property def cluster_dim(self): """_py_anon_pod29: Value of launch attribute cudaLaunchAttributeClusterDimension that represents the desired cluster dimensions for the kernel. Opaque type with the following fields: - ``x`` - The X dimension of the cluster, in blocks. Must be a divisor of the grid X dimension. - ``y`` - The Y dimension of the cluster, in blocks. Must be a divisor of the grid Y dimension. - ``z`` - The Z dimension of the cluster, in blocks. Must be a divisor of the grid Z dimension.""" return _py_anon_pod29.from_ptr( &(self._ptr[0].clusterDim), readonly=self._readonly, owner=self, ) @cluster_dim.setter def cluster_dim(self, val): if self._readonly: raise ValueError("This LaunchAttributeValue instance is read-only") cdef _py_anon_pod29 val_ = val _cyb_memcpy(&(self._ptr[0].clusterDim), (val_._get_ptr()), sizeof(cuda_bindings_runtime__anon_pod29) * 1) @property def programmatic_event(self): """_py_anon_pod30: Value of launch attribute cudaLaunchAttributeProgrammaticEvent with the following fields: - ``cudaEvent_t`` event - Event to fire when all blocks trigger it. - ``int`` flags; - Event record flags, see cudaEventRecordWithFlags. Does not accept cudaEventRecordExternal. - ``int`` triggerAtBlockStart - If this is set to non-0, each block launch will automatically trigger the event.""" return _py_anon_pod30.from_ptr( &(self._ptr[0].programmaticEvent), readonly=self._readonly, owner=self, ) @programmatic_event.setter def programmatic_event(self, val): if self._readonly: raise ValueError("This LaunchAttributeValue instance is read-only") cdef _py_anon_pod30 val_ = val _cyb_memcpy(&(self._ptr[0].programmaticEvent), (val_._get_ptr()), sizeof(cuda_bindings_runtime__anon_pod30) * 1) @property def mem_sync_domain_map(self): """LaunchMemSyncDomainMap: Value of launch attribute cudaLaunchAttributeMemSyncDomainMap. See cudaLaunchMemSyncDomainMap.""" return LaunchMemSyncDomainMap.from_ptr( &(self._ptr[0].memSyncDomainMap), readonly=self._readonly, owner=self, ) @mem_sync_domain_map.setter def mem_sync_domain_map(self, val): if self._readonly: raise ValueError("This LaunchAttributeValue instance is read-only") cdef LaunchMemSyncDomainMap val_ = val _cyb_memcpy(&(self._ptr[0].memSyncDomainMap), (val_._get_ptr()), sizeof(cudaLaunchMemSyncDomainMap) * 1) @property def preferred_cluster_dim(self): """_py_anon_pod31: Value of launch attribute cudaLaunchAttributePreferredClusterDimension that represents the desired preferred cluster dimensions for the kernel. Opaque type with the following fields: - ``x`` - The X dimension of the preferred cluster, in blocks. Must be a divisor of the grid X dimension, and must be a multiple of the ``x`` field of cudaLaunchAttributeValue::clusterDim. - ``y`` - The Y dimension of the preferred cluster, in blocks. Must be a divisor of the grid Y dimension, and must be a multiple of the ``y`` field of cudaLaunchAttributeValue::clusterDim. - ``z`` - The Z dimension of the preferred cluster, in blocks. Must be equal to the ``z`` field of cudaLaunchAttributeValue::clusterDim.""" return _py_anon_pod31.from_ptr( &(self._ptr[0].preferredClusterDim), readonly=self._readonly, owner=self, ) @preferred_cluster_dim.setter def preferred_cluster_dim(self, val): if self._readonly: raise ValueError("This LaunchAttributeValue instance is read-only") cdef _py_anon_pod31 val_ = val _cyb_memcpy(&(self._ptr[0].preferredClusterDim), (val_._get_ptr()), sizeof(cuda_bindings_runtime__anon_pod31) * 1) @property def launch_completion_event(self): """_py_anon_pod32: Value of launch attribute cudaLaunchAttributeLaunchCompletionEvent with the following fields: - ``cudaEvent_t`` event - Event to fire when the last block launches. - ``int`` flags - Event record flags, see cudaEventRecordWithFlags. Does not accept cudaEventRecordExternal.""" return _py_anon_pod32.from_ptr( &(self._ptr[0].launchCompletionEvent), readonly=self._readonly, owner=self, ) @launch_completion_event.setter def launch_completion_event(self, val): if self._readonly: raise ValueError("This LaunchAttributeValue instance is read-only") cdef _py_anon_pod32 val_ = val _cyb_memcpy(&(self._ptr[0].launchCompletionEvent), (val_._get_ptr()), sizeof(cuda_bindings_runtime__anon_pod32) * 1) @property def device_updatable_kernel_node(self): """_py_anon_pod33: Value of launch attribute cudaLaunchAttributeDeviceUpdatableKernelNode with the following fields: - ``int`` deviceUpdatable - Whether or not the resulting kernel node should be device-updatable. - ``cudaGraphDeviceNode_t`` devNode - Returns a handle to pass to the various device-side update functions.""" return _py_anon_pod33.from_ptr( &(self._ptr[0].deviceUpdatableKernelNode), readonly=self._readonly, owner=self, ) @device_updatable_kernel_node.setter def device_updatable_kernel_node(self, val): if self._readonly: raise ValueError("This LaunchAttributeValue instance is read-only") cdef _py_anon_pod33 val_ = val _cyb_memcpy(&(self._ptr[0].deviceUpdatableKernelNode), (val_._get_ptr()), sizeof(cuda_bindings_runtime__anon_pod33) * 1) @property def cooperative(self): """int: Value of launch attribute cudaLaunchAttributeCooperative. Nonzero indicates a cooperative kernel (see cudaLaunchCooperativeKernel).""" return self._ptr[0].cooperative @cooperative.setter def cooperative(self, val): if self._readonly: raise ValueError("This LaunchAttributeValue instance is read-only") self._ptr[0].cooperative = val @property def sync_policy(self): """int: Value of launch attribute cudaLaunchAttributeSynchronizationPolicy. cudaSynchronizationPolicy for work queued up in this stream.""" return (self._ptr[0].syncPolicy) @sync_policy.setter def sync_policy(self, val): if self._readonly: raise ValueError("This LaunchAttributeValue instance is read-only") self._ptr[0].syncPolicy = val @property def cluster_scheduling_policy_preference(self): """int: Value of launch attribute cudaLaunchAttributeClusterSchedulingPolicyPreference. Cluster scheduling policy preference for the kernel.""" return (self._ptr[0].clusterSchedulingPolicyPreference) @cluster_scheduling_policy_preference.setter def cluster_scheduling_policy_preference(self, val): if self._readonly: raise ValueError("This LaunchAttributeValue instance is read-only") self._ptr[0].clusterSchedulingPolicyPreference = val @property def programmatic_stream_serialization_allowed(self): """int: Value of launch attribute cudaLaunchAttributeProgrammaticStreamSerialization.""" return self._ptr[0].programmaticStreamSerializationAllowed @programmatic_stream_serialization_allowed.setter def programmatic_stream_serialization_allowed(self, val): if self._readonly: raise ValueError("This LaunchAttributeValue instance is read-only") self._ptr[0].programmaticStreamSerializationAllowed = val @property def priority(self): """int: Value of launch attribute cudaLaunchAttributePriority. Execution priority of the kernel.""" return self._ptr[0].priority @priority.setter def priority(self, val): if self._readonly: raise ValueError("This LaunchAttributeValue instance is read-only") self._ptr[0].priority = val @property def mem_sync_domain(self): """int: Value of launch attribute cudaLaunchAttributeMemSyncDomain. See cudaLaunchMemSyncDomain.""" return (self._ptr[0].memSyncDomain) @mem_sync_domain.setter def mem_sync_domain(self, val): if self._readonly: raise ValueError("This LaunchAttributeValue instance is read-only") self._ptr[0].memSyncDomain = val @property def shared_mem_carveout(self): """int: Value of launch attribute cudaLaunchAttributePreferredSharedMemoryCarveout.""" return self._ptr[0].sharedMemCarveout @shared_mem_carveout.setter def shared_mem_carveout(self, val): if self._readonly: raise ValueError("This LaunchAttributeValue instance is read-only") self._ptr[0].sharedMemCarveout = val @property def nvlink_util_centric_scheduling(self): """int: Value of launch attribute cudaLaunchAttributeNvlinkUtilCentricScheduling.""" return self._ptr[0].nvlinkUtilCentricScheduling @nvlink_util_centric_scheduling.setter def nvlink_util_centric_scheduling(self, val): if self._readonly: raise ValueError("This LaunchAttributeValue instance is read-only") self._ptr[0].nvlinkUtilCentricScheduling = val @property def portable_cluster_size_mode(self): """int: Value of launch attribute cudaLaunchAttributePortableClusterSizeMode""" return (self._ptr[0].portableClusterSizeMode) @portable_cluster_size_mode.setter def portable_cluster_size_mode(self, val): if self._readonly: raise ValueError("This LaunchAttributeValue instance is read-only") self._ptr[0].portableClusterSizeMode = val @property def shared_memory_mode(self): """int: Value of launch attribute cudaLaunchAttributeSharedMemoryMode. See cudaSharedMemoryMode for acceptable values.""" return (self._ptr[0].sharedMemoryMode) @shared_memory_mode.setter def shared_memory_mode(self, val): if self._readonly: raise ValueError("This LaunchAttributeValue instance is read-only") self._ptr[0].sharedMemoryMode = val @staticmethod def from_buffer(buffer): """Create an LaunchAttributeValue instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaLaunchAttributeValue), LaunchAttributeValue) @staticmethod def from_data(data): """Create an LaunchAttributeValue instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `launch_attribute_value_dtype` holding the data. """ return _cyb_from_data(data, "launch_attribute_value_dtype", launch_attribute_value_dtype, LaunchAttributeValue) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an LaunchAttributeValue instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef LaunchAttributeValue obj = LaunchAttributeValue.__new__(LaunchAttributeValue) if owner is None: obj._ptr = _cyb_malloc(sizeof(cudaLaunchAttributeValue)) if obj._ptr == NULL: raise MemoryError("Error allocating LaunchAttributeValue") _cyb_memcpy((obj._ptr), ptr, sizeof(cudaLaunchAttributeValue)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod34_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod34 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod34)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod34") try: return _numpy.dtype({ 'names': ['over_budget'], 'formats': [_py_anon_pod35_dtype], 'offsets': [ (&(pod.overBudget)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod34), }) finally: _cyb_free(pod) _py_anon_pod34_dtype = _get__py_anon_pod34_dtype_offsets() cdef class _py_anon_pod34: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod34`. .. seealso:: `cuda_bindings_runtime__anon_pod34` """ cdef: cuda_bindings_runtime__anon_pod34 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod34)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod34") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod34 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod34 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod34 other_ if not isinstance(other, _py_anon_pod34): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod34)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod34), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod34 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod34): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod34), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod34)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def over_budget(self): """_py_anon_pod35: """ return _py_anon_pod35.from_ptr( &(self._ptr[0].overBudget), readonly=self._readonly, owner=self, ) @over_budget.setter def over_budget(self, val): if self._readonly: raise ValueError("This _py_anon_pod34 instance is read-only") cdef _py_anon_pod35 val_ = val _cyb_memcpy(&(self._ptr[0].overBudget), (val_._get_ptr()), sizeof(cuda_bindings_runtime__anon_pod35) * 1) @staticmethod def from_buffer(buffer): """Create an _py_anon_pod34 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod34), _py_anon_pod34) @staticmethod def from_data(data): """Create an _py_anon_pod34 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod34_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod34_dtype", _py_anon_pod34_dtype, _py_anon_pod34) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod34 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod34 obj = _py_anon_pod34.__new__(_py_anon_pod34) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod34)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod34") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod34)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod1_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod1 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod1)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod1") try: return _numpy.dtype({ 'names': ['array', 'mipmap', 'linear', 'pitch2d', 'reserved'], 'formats': [_py_anon_pod2_dtype, _py_anon_pod3_dtype, _py_anon_pod4_dtype, _py_anon_pod5_dtype, _py_anon_pod6_dtype], 'offsets': [ (&(pod.array)) - (pod), (&(pod.mipmap)) - (pod), (&(pod.linear)) - (pod), (&(pod.pitch2D)) - (pod), (&(pod.reserved)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod1), }) finally: _cyb_free(pod) _py_anon_pod1_dtype = _get__py_anon_pod1_dtype_offsets() cdef class _py_anon_pod1: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod1`. .. seealso:: `cuda_bindings_runtime__anon_pod1` """ cdef: cuda_bindings_runtime__anon_pod1 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod1)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod1") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod1 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod1 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod1 other_ if not isinstance(other, _py_anon_pod1): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod1)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod1), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod1 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod1): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod1), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod1)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def array(self): """_py_anon_pod2: """ return _py_anon_pod2.from_ptr( &(self._ptr[0].array), readonly=self._readonly, owner=self, ) @array.setter def array(self, val): if self._readonly: raise ValueError("This _py_anon_pod1 instance is read-only") cdef _py_anon_pod2 val_ = val _cyb_memcpy(&(self._ptr[0].array), (val_._get_ptr()), sizeof(cuda_bindings_runtime__anon_pod2) * 1) @property def mipmap(self): """_py_anon_pod3: """ return _py_anon_pod3.from_ptr( &(self._ptr[0].mipmap), readonly=self._readonly, owner=self, ) @mipmap.setter def mipmap(self, val): if self._readonly: raise ValueError("This _py_anon_pod1 instance is read-only") cdef _py_anon_pod3 val_ = val _cyb_memcpy(&(self._ptr[0].mipmap), (val_._get_ptr()), sizeof(cuda_bindings_runtime__anon_pod3) * 1) @property def linear(self): """_py_anon_pod4: """ return _py_anon_pod4.from_ptr( &(self._ptr[0].linear), readonly=self._readonly, owner=self, ) @linear.setter def linear(self, val): if self._readonly: raise ValueError("This _py_anon_pod1 instance is read-only") cdef _py_anon_pod4 val_ = val _cyb_memcpy(&(self._ptr[0].linear), (val_._get_ptr()), sizeof(cuda_bindings_runtime__anon_pod4) * 1) @property def pitch2d(self): """_py_anon_pod5: """ return _py_anon_pod5.from_ptr( &(self._ptr[0].pitch2D), readonly=self._readonly, owner=self, ) @pitch2d.setter def pitch2d(self, val): if self._readonly: raise ValueError("This _py_anon_pod1 instance is read-only") cdef _py_anon_pod5 val_ = val _cyb_memcpy(&(self._ptr[0].pitch2D), (val_._get_ptr()), sizeof(cuda_bindings_runtime__anon_pod5) * 1) @staticmethod def from_buffer(buffer): """Create an _py_anon_pod1 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod1), _py_anon_pod1) @staticmethod def from_data(data): """Create an _py_anon_pod1 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod1_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod1_dtype", _py_anon_pod1_dtype, _py_anon_pod1) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod1 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod1 obj = _py_anon_pod1.__new__(_py_anon_pod1) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod1)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod1") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod1)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_egl_frame_dtype_offsets(): cdef cudaEglFrame *pod = _cyb_calloc(1, sizeof(cudaEglFrame)) if pod == NULL: raise MemoryError("Error allocating cudaEglFrame") try: return _numpy.dtype({ 'names': ['frame', 'plane_desc', 'plane_count', 'frame_type', 'egl_color_format'], 'formats': [_py_anon_pod36_dtype, (egl_plane_desc_dtype, 3), _numpy.uint32, _numpy.int32, _numpy.int32], 'offsets': [ (&(pod.frame)) - (pod), (&(pod.planeDesc)) - (pod), (&(pod.planeCount)) - (pod), (&(pod.frameType)) - (pod), (&(pod.eglColorFormat)) - (pod), ], 'itemsize': sizeof(cudaEglFrame), }) finally: _cyb_free(pod) egl_frame_dtype = _get_egl_frame_dtype_offsets() cdef class EglFrame: """Empty-initialize an instance of `cudaEglFrame`. .. seealso:: `cudaEglFrame` """ cdef: cudaEglFrame _data cudaEglFrame *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.EglFrame object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef EglFrame other_ if not isinstance(other, EglFrame): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaEglFrame)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaEglFrame), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This EglFrame instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaEglFrame): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaEglFrame), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudaEglFrame)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def frame(self): """_py_anon_pod36: """ return _py_anon_pod36.from_ptr( &(self._ptr[0].frame), readonly=self._readonly, owner=self, ) @frame.setter def frame(self, val): if self._readonly: raise ValueError("This EglFrame instance is read-only") cdef _py_anon_pod36 val_ = val _cyb_memcpy(&(self._ptr[0].frame), (val_._get_ptr()), sizeof(cuda_bindings_runtime__anon_pod36) * 1) @property def plane_desc(self): """EglPlaneDesc: """ return EglPlaneDesc.from_ptr( &(self._ptr[0].planeDesc), 3, readonly=self._readonly, owner=self, ) @plane_desc.setter def plane_desc(self, val): if self._readonly: raise ValueError("This EglFrame instance is read-only") cdef EglPlaneDesc val_ = val if len(val) != 3: raise ValueError(f"Expected length { 3 } for field plane_desc, got {len(val)}") _cyb_memcpy(&(self._ptr[0].planeDesc), (val_._get_ptr()), sizeof(cudaEglPlaneDesc) * 3) @property def plane_count(self): """int: """ return self._ptr[0].planeCount @plane_count.setter def plane_count(self, val): if self._readonly: raise ValueError("This EglFrame instance is read-only") self._ptr[0].planeCount = val @property def frame_type(self): """int: """ return (self._ptr[0].frameType) @frame_type.setter def frame_type(self, val): if self._readonly: raise ValueError("This EglFrame instance is read-only") self._ptr[0].frameType = val @property def egl_color_format(self): """int: """ return (self._ptr[0].eglColorFormat) @egl_color_format.setter def egl_color_format(self, val): if self._readonly: raise ValueError("This EglFrame instance is read-only") self._ptr[0].eglColorFormat = val @staticmethod def from_buffer(buffer): """Create an EglFrame instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaEglFrame), EglFrame) @staticmethod def from_data(data): """Create an EglFrame instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `egl_frame_dtype` holding the data. """ return _cyb_from_data(data, "egl_frame_dtype", egl_frame_dtype, EglFrame) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an EglFrame instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef EglFrame obj = EglFrame.__new__(EglFrame) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudaEglFrame)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get_mem_cpy_node_params_dtype_offsets(): cdef cudaMemcpyNodeParams *pod = _cyb_calloc(1, sizeof(cudaMemcpyNodeParams)) if pod == NULL: raise MemoryError("Error allocating cudaMemcpyNodeParams") try: return _numpy.dtype({ 'names': ['flags_', 'reserved', 'ctx', 'copy_params'], 'formats': [_numpy.int32, _numpy.int32, _numpy.intp, mem_cpy3d_parms_dtype], 'offsets': [ (&(pod.flags)) - (pod), (&(pod.reserved)) - (pod), (&(pod.ctx)) - (pod), (&(pod.copyParams)) - (pod), ], 'itemsize': sizeof(cudaMemcpyNodeParams), }) finally: _cyb_free(pod) mem_cpy_node_params_dtype = _get_mem_cpy_node_params_dtype_offsets() cdef class MemCpyNodeParams: """Empty-initialize an instance of `cudaMemcpyNodeParams`. .. seealso:: `cudaMemcpyNodeParams` """ cdef: cudaMemcpyNodeParams *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cudaMemcpyNodeParams)) if self._ptr == NULL: raise MemoryError("Error allocating MemCpyNodeParams") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cudaMemcpyNodeParams *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.MemCpyNodeParams object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef MemCpyNodeParams other_ if not isinstance(other, MemCpyNodeParams): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaMemcpyNodeParams)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaMemcpyNodeParams), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This MemCpyNodeParams instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaMemcpyNodeParams): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaMemcpyNodeParams), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cudaMemcpyNodeParams)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def copy_params(self): """MemCpy3dParms: Parameters for the memory copy""" return MemCpy3dParms.from_ptr( &(self._ptr[0].copyParams), readonly=self._readonly, owner=self, ) @copy_params.setter def copy_params(self, val): if self._readonly: raise ValueError("This MemCpyNodeParams instance is read-only") cdef MemCpy3dParms val_ = val _cyb_memcpy(&(self._ptr[0].copyParams), (val_._get_ptr()), sizeof(cudaMemcpy3DParms) * 1) @property def flags_(self): """int: Must be zero""" return self._ptr[0].flags @flags_.setter def flags_(self, val): if self._readonly: raise ValueError("This MemCpyNodeParams instance is read-only") self._ptr[0].flags = val @property def ctx(self): """int: Context in which to run the memcpy. If NULL will try to use the current context.""" return (self._ptr[0].ctx) @ctx.setter def ctx(self, val): if self._readonly: raise ValueError("This MemCpyNodeParams instance is read-only") self._ptr[0].ctx = val @staticmethod def from_buffer(buffer): """Create an MemCpyNodeParams instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaMemcpyNodeParams), MemCpyNodeParams) @staticmethod def from_data(data): """Create an MemCpyNodeParams instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `mem_cpy_node_params_dtype` holding the data. """ return _cyb_from_data(data, "mem_cpy_node_params_dtype", mem_cpy_node_params_dtype, MemCpyNodeParams) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an MemCpyNodeParams instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef MemCpyNodeParams obj = MemCpyNodeParams.__new__(MemCpyNodeParams) if owner is None: obj._ptr = _cyb_malloc(sizeof(cudaMemcpyNodeParams)) if obj._ptr == NULL: raise MemoryError("Error allocating MemCpyNodeParams") _cyb_memcpy((obj._ptr), ptr, sizeof(cudaMemcpyNodeParams)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_mem_location_dtype_offsets(): cdef cudaMemLocation *pod = _cyb_calloc(1, sizeof(cudaMemLocation)) if pod == NULL: raise MemoryError("Error allocating cudaMemLocation") try: return _numpy.dtype({ 'names': ['type', 'id', 'localized'], 'formats': [_numpy.int32, _numpy.int32, _py_anon_pod9_dtype], 'offsets': [ (&(pod.type)) - (pod), (&(pod.id)) - (pod), (&(pod.localized)) - (pod), ], 'itemsize': sizeof(cudaMemLocation), }) finally: _cyb_free(pod) mem_location_dtype = _get_mem_location_dtype_offsets() cdef object mem_location_dtype_record = _numpy.dtype((_numpy.record, mem_location_dtype)) cdef class MemLocation: """Empty-initialize an array of `cudaMemLocation`. The resulting object is of length `size` and of dtype `mem_location_dtype`. If default-constructed, the instance represents a single struct. Args: size (int): number of structs, default=1. .. seealso:: `cudaMemLocation` """ cdef: readonly object _data object _owner def __init__(self, size=1): self._data = _numpy.zeros(size, dtype=mem_location_dtype_record) assert self._data.itemsize == sizeof(cudaMemLocation), \ f"itemsize {self._data.itemsize} mismatches struct size { sizeof(cudaMemLocation) }" def __repr__(self): if self._data.size > 1: return f"<{__name__}.MemLocation_Array_{self._data.size} object at {hex(id(self))}>" else: return f"<{__name__}.MemLocation object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return _cyb_array_ptr(self._data) cdef intptr_t _get_ptr(self): return _cyb_array_ptr(self._data) def __int__(self): if self._data.size > 1 and not self._data.flags["C_CONTIGUOUS"]: raise TypeError("int() argument must be a bytes-like object of size 1, or a " "C-contiguous array. To get the pointer address of a " "non-contiguous array, use .ptr") return _cyb_array_ptr(self._data) def __len__(self): return self._data.size def __eq__(self, other): cdef object self_data = self._data if (not isinstance(other, MemLocation)) or self_data.size != other._data.size or self_data.dtype != other._data.dtype: return False return bool((self_data == other._data).all()) def __getbuffer__(self, Py_buffer *buffer, int flags): _cyb_cpython.PyObject_GetBuffer(self._data, buffer, flags) def __releasebuffer__(self, Py_buffer *buffer): _cyb_cpython.PyBuffer_Release(buffer) @property def type(self): """Union[~_numpy.int32, int]: Specifies the location type, which modifies the meaning of id.""" if self._data.size == 1: return int(self._data["type"][0]) return self._data["type"] @type.setter def type(self, val): if not self._data.flags.writeable: raise ValueError("This MemLocation instance is read-only") self._data["type"] = val @property def id(self): """Union[~_numpy.int32, int]: Identifier for cudaMemLocationType::cudaMemLocationTypeDevice, cudaMemLocationType::cudaMemLocationTypeHost, or cudaMemLocationType::cudaMemLocationTypeHostNuma.""" if self._data.size == 1: return int(self._data["id"][0]) return self._data["id"] @id.setter def id(self, val): if not self._data.flags.writeable: raise ValueError("This MemLocation instance is read-only") self._data["id"] = val @property def localized(self): """_py_anon_pod9_dtype: Identifier for cudaMemLocationType::cudaMemLocationTypeDeviceLocalityDomain.""" return self._data["localized"].view(_numpy.recarray) @localized.setter def localized(self, val): if not self._data.flags.writeable: raise ValueError("This MemLocation instance is read-only") self._data["localized"] = val def __getitem__(self, key): cdef ssize_t key_ cdef ssize_t size cdef MemLocation obj if isinstance(key, int): key_ = key size = self._data.size if key_ >= size or key_ <= -(size+1): raise IndexError("index is out of bounds") if key_ < 0: key_ += size obj = MemLocation.__new__(MemLocation) obj._data = self._data[key_:key_+1] obj._owner = self._owner return obj out = self._data[key] if isinstance(out, _numpy.ndarray): if out.dtype == mem_location_dtype: obj = MemLocation.from_data(out) obj._owner = self._owner return obj if out.dtype.names is not None: return out.view(_numpy.recarray) return out def __setitem__(self, key, val): self._data[key] = val @staticmethod def from_buffer(buffer): """Create an MemLocation instance with the memory from the given buffer.""" return MemLocation.from_data(_numpy.frombuffer(buffer, dtype=mem_location_dtype)) @staticmethod def from_data(data): """Create an MemLocation instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a 1D array of dtype `mem_location_dtype` holding the data. """ cdef MemLocation obj = MemLocation.__new__(MemLocation) if not isinstance(data, _numpy.ndarray): raise TypeError("data argument must be a NumPy ndarray") if data.ndim != 1: raise ValueError("data array must be 1D") if data.dtype != mem_location_dtype: raise ValueError("data array must be of dtype mem_location_dtype") obj._data = data.view(dtype=mem_location_dtype_record, type=_numpy.ndarray) return obj @staticmethod def from_ptr(intptr_t ptr, size_t size=1, bint readonly=False, object owner=None): """Create an MemLocation instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. size (int): number of structs, default=1. readonly (bool): whether the data is read-only (to the user). default is `False`. owner (object): object that owns the memory at *ptr*. A strong reference is kept, by this wrapper and by every NumPy view of its data, so the backing storage outlives them. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef MemLocation obj = MemLocation.__new__(MemLocation) cdef _cyb_MemoryHolder buf = _cyb_MemoryHolder(ptr, sizeof(cudaMemLocation) * size, readonly, owner) obj._data = _numpy.ndarray(size, buffer=buf, dtype=mem_location_dtype_record) obj._owner = owner return obj cdef _get_external_memory_handle_desc_dtype_offsets(): cdef cudaExternalMemoryHandleDesc *pod = _cyb_calloc(1, sizeof(cudaExternalMemoryHandleDesc)) if pod == NULL: raise MemoryError("Error allocating cudaExternalMemoryHandleDesc") try: return _numpy.dtype({ 'names': ['type', 'handle', 'size_', 'flags_', 'reserved'], 'formats': [_numpy.int32, _py_anon_pod13_dtype, _numpy.uint64, _numpy.uint32, (_numpy.uint32, 16)], 'offsets': [ (&(pod.type)) - (pod), (&(pod.handle)) - (pod), (&(pod.size)) - (pod), (&(pod.flags)) - (pod), (&(pod.reserved)) - (pod), ], 'itemsize': sizeof(cudaExternalMemoryHandleDesc), }) finally: _cyb_free(pod) external_memory_handle_desc_dtype = _get_external_memory_handle_desc_dtype_offsets() cdef class ExternalMemoryHandleDesc: """Empty-initialize an instance of `cudaExternalMemoryHandleDesc`. .. seealso:: `cudaExternalMemoryHandleDesc` """ cdef: cudaExternalMemoryHandleDesc _data cudaExternalMemoryHandleDesc *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.ExternalMemoryHandleDesc object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef ExternalMemoryHandleDesc other_ if not isinstance(other, ExternalMemoryHandleDesc): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaExternalMemoryHandleDesc)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaExternalMemoryHandleDesc), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This ExternalMemoryHandleDesc instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaExternalMemoryHandleDesc): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaExternalMemoryHandleDesc), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudaExternalMemoryHandleDesc)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def handle(self): """_py_anon_pod13: Valid NT handle. Must be NULL if 'name' is non-NULL""" return _py_anon_pod13.from_ptr( &(self._ptr[0].handle), readonly=self._readonly, owner=self, ) @handle.setter def handle(self, val): if self._readonly: raise ValueError("This ExternalMemoryHandleDesc instance is read-only") cdef _py_anon_pod13 val_ = val _cyb_memcpy(&(self._ptr[0].handle), (val_._get_ptr()), sizeof(cuda_bindings_runtime__anon_pod13) * 1) @property def type(self): """int: Type of the handle""" return (self._ptr[0].type) @type.setter def type(self, val): if self._readonly: raise ValueError("This ExternalMemoryHandleDesc instance is read-only") self._ptr[0].type = val @property def size_(self): """int: Size of the memory allocation""" return self._ptr[0].size @size_.setter def size_(self, val): if self._readonly: raise ValueError("This ExternalMemoryHandleDesc instance is read-only") self._ptr[0].size = val @property def flags_(self): """int: Flags must either be zero or cudaExternalMemoryDedicated""" return self._ptr[0].flags @flags_.setter def flags_(self, val): if self._readonly: raise ValueError("This ExternalMemoryHandleDesc instance is read-only") self._ptr[0].flags = val @staticmethod def from_buffer(buffer): """Create an ExternalMemoryHandleDesc instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaExternalMemoryHandleDesc), ExternalMemoryHandleDesc) @staticmethod def from_data(data): """Create an ExternalMemoryHandleDesc instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `external_memory_handle_desc_dtype` holding the data. """ return _cyb_from_data(data, "external_memory_handle_desc_dtype", external_memory_handle_desc_dtype, ExternalMemoryHandleDesc) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an ExternalMemoryHandleDesc instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef ExternalMemoryHandleDesc obj = ExternalMemoryHandleDesc.__new__(ExternalMemoryHandleDesc) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudaExternalMemoryHandleDesc)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get_external_semaphore_handle_desc_dtype_offsets(): cdef cudaExternalSemaphoreHandleDesc *pod = _cyb_calloc(1, sizeof(cudaExternalSemaphoreHandleDesc)) if pod == NULL: raise MemoryError("Error allocating cudaExternalSemaphoreHandleDesc") try: return _numpy.dtype({ 'names': ['type', 'handle', 'flags_', 'reserved'], 'formats': [_numpy.int32, _py_anon_pod15_dtype, _numpy.uint32, (_numpy.uint32, 16)], 'offsets': [ (&(pod.type)) - (pod), (&(pod.handle)) - (pod), (&(pod.flags)) - (pod), (&(pod.reserved)) - (pod), ], 'itemsize': sizeof(cudaExternalSemaphoreHandleDesc), }) finally: _cyb_free(pod) external_semaphore_handle_desc_dtype = _get_external_semaphore_handle_desc_dtype_offsets() cdef class ExternalSemaphoreHandleDesc: """Empty-initialize an instance of `cudaExternalSemaphoreHandleDesc`. .. seealso:: `cudaExternalSemaphoreHandleDesc` """ cdef: cudaExternalSemaphoreHandleDesc _data cudaExternalSemaphoreHandleDesc *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.ExternalSemaphoreHandleDesc object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef ExternalSemaphoreHandleDesc other_ if not isinstance(other, ExternalSemaphoreHandleDesc): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaExternalSemaphoreHandleDesc)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaExternalSemaphoreHandleDesc), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This ExternalSemaphoreHandleDesc instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaExternalSemaphoreHandleDesc): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaExternalSemaphoreHandleDesc), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudaExternalSemaphoreHandleDesc)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def handle(self): """_py_anon_pod15: Valid NT handle. Must be NULL if 'name' is non-NULL""" return _py_anon_pod15.from_ptr( &(self._ptr[0].handle), readonly=self._readonly, owner=self, ) @handle.setter def handle(self, val): if self._readonly: raise ValueError("This ExternalSemaphoreHandleDesc instance is read-only") cdef _py_anon_pod15 val_ = val _cyb_memcpy(&(self._ptr[0].handle), (val_._get_ptr()), sizeof(cuda_bindings_runtime__anon_pod15) * 1) @property def type(self): """int: Type of the handle""" return (self._ptr[0].type) @type.setter def type(self, val): if self._readonly: raise ValueError("This ExternalSemaphoreHandleDesc instance is read-only") self._ptr[0].type = val @property def flags_(self): """int: Flags reserved for the future. Must be zero.""" return self._ptr[0].flags @flags_.setter def flags_(self, val): if self._readonly: raise ValueError("This ExternalSemaphoreHandleDesc instance is read-only") self._ptr[0].flags = val @staticmethod def from_buffer(buffer): """Create an ExternalSemaphoreHandleDesc instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaExternalSemaphoreHandleDesc), ExternalSemaphoreHandleDesc) @staticmethod def from_data(data): """Create an ExternalSemaphoreHandleDesc instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `external_semaphore_handle_desc_dtype` holding the data. """ return _cyb_from_data(data, "external_semaphore_handle_desc_dtype", external_semaphore_handle_desc_dtype, ExternalSemaphoreHandleDesc) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an ExternalSemaphoreHandleDesc instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef ExternalSemaphoreHandleDesc obj = ExternalSemaphoreHandleDesc.__new__(ExternalSemaphoreHandleDesc) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudaExternalSemaphoreHandleDesc)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get_external_semaphore_signal_params_dtype_offsets(): cdef cudaExternalSemaphoreSignalParams *pod = _cyb_calloc(1, sizeof(cudaExternalSemaphoreSignalParams)) if pod == NULL: raise MemoryError("Error allocating cudaExternalSemaphoreSignalParams") try: return _numpy.dtype({ 'names': ['params', 'flags_', 'reserved'], 'formats': [_py_anon_pod17_dtype, _numpy.uint32, (_numpy.uint32, 16)], 'offsets': [ (&(pod.params)) - (pod), (&(pod.flags)) - (pod), (&(pod.reserved)) - (pod), ], 'itemsize': sizeof(cudaExternalSemaphoreSignalParams), }) finally: _cyb_free(pod) external_semaphore_signal_params_dtype = _get_external_semaphore_signal_params_dtype_offsets() cdef object external_semaphore_signal_params_dtype_record = _numpy.dtype((_numpy.record, external_semaphore_signal_params_dtype)) cdef class ExternalSemaphoreSignalParams: """Empty-initialize an array of `cudaExternalSemaphoreSignalParams`. The resulting object is of length `size` and of dtype `external_semaphore_signal_params_dtype`. If default-constructed, the instance represents a single struct. Args: size (int): number of structs, default=1. .. seealso:: `cudaExternalSemaphoreSignalParams` """ cdef: readonly object _data object _owner def __init__(self, size=1): self._data = _numpy.zeros(size, dtype=external_semaphore_signal_params_dtype_record) assert self._data.itemsize == sizeof(cudaExternalSemaphoreSignalParams), \ f"itemsize {self._data.itemsize} mismatches struct size { sizeof(cudaExternalSemaphoreSignalParams) }" def __repr__(self): if self._data.size > 1: return f"<{__name__}.ExternalSemaphoreSignalParams_Array_{self._data.size} object at {hex(id(self))}>" else: return f"<{__name__}.ExternalSemaphoreSignalParams object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return _cyb_array_ptr(self._data) cdef intptr_t _get_ptr(self): return _cyb_array_ptr(self._data) def __int__(self): if self._data.size > 1 and not self._data.flags["C_CONTIGUOUS"]: raise TypeError("int() argument must be a bytes-like object of size 1, or a " "C-contiguous array. To get the pointer address of a " "non-contiguous array, use .ptr") return _cyb_array_ptr(self._data) def __len__(self): return self._data.size def __eq__(self, other): cdef object self_data = self._data if (not isinstance(other, ExternalSemaphoreSignalParams)) or self_data.size != other._data.size or self_data.dtype != other._data.dtype: return False return bool((self_data == other._data).all()) def __getbuffer__(self, Py_buffer *buffer, int flags): _cyb_cpython.PyObject_GetBuffer(self._data, buffer, flags) def __releasebuffer__(self, Py_buffer *buffer): _cyb_cpython.PyBuffer_Release(buffer) @property def params(self): """_py_anon_pod17_dtype: """ return self._data["params"].view(_numpy.recarray) @params.setter def params(self, val): if not self._data.flags.writeable: raise ValueError("This ExternalSemaphoreSignalParams instance is read-only") self._data["params"] = val @property def flags_(self): """Union[~_numpy.uint32, int]: Only when cudaExternalSemaphoreSignalParams is used to signal a cudaExternalSemaphore_t of type cudaExternalSemaphoreHandleTypeNvSciSync, the valid flag is cudaExternalSemaphoreSignalSkipNvSciBufMemSync: which indicates that while signaling the cudaExternalSemaphore_t, no memory synchronization operations should be performed for any external memory object imported as cudaExternalMemoryHandleTypeNvSciBuf. For all other types of cudaExternalSemaphore_t, flags must be zero.""" if self._data.size == 1: return int(self._data["flags_"][0]) return self._data["flags_"] @flags_.setter def flags_(self, val): if not self._data.flags.writeable: raise ValueError("This ExternalSemaphoreSignalParams instance is read-only") self._data["flags_"] = val def __getitem__(self, key): cdef ssize_t key_ cdef ssize_t size cdef ExternalSemaphoreSignalParams obj if isinstance(key, int): key_ = key size = self._data.size if key_ >= size or key_ <= -(size+1): raise IndexError("index is out of bounds") if key_ < 0: key_ += size obj = ExternalSemaphoreSignalParams.__new__(ExternalSemaphoreSignalParams) obj._data = self._data[key_:key_+1] obj._owner = self._owner return obj out = self._data[key] if isinstance(out, _numpy.ndarray): if out.dtype == external_semaphore_signal_params_dtype: obj = ExternalSemaphoreSignalParams.from_data(out) obj._owner = self._owner return obj if out.dtype.names is not None: return out.view(_numpy.recarray) return out def __setitem__(self, key, val): self._data[key] = val @staticmethod def from_buffer(buffer): """Create an ExternalSemaphoreSignalParams instance with the memory from the given buffer.""" return ExternalSemaphoreSignalParams.from_data(_numpy.frombuffer(buffer, dtype=external_semaphore_signal_params_dtype)) @staticmethod def from_data(data): """Create an ExternalSemaphoreSignalParams instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a 1D array of dtype `external_semaphore_signal_params_dtype` holding the data. """ cdef ExternalSemaphoreSignalParams obj = ExternalSemaphoreSignalParams.__new__(ExternalSemaphoreSignalParams) if not isinstance(data, _numpy.ndarray): raise TypeError("data argument must be a NumPy ndarray") if data.ndim != 1: raise ValueError("data array must be 1D") if data.dtype != external_semaphore_signal_params_dtype: raise ValueError("data array must be of dtype external_semaphore_signal_params_dtype") obj._data = data.view(dtype=external_semaphore_signal_params_dtype_record, type=_numpy.ndarray) return obj @staticmethod def from_ptr(intptr_t ptr, size_t size=1, bint readonly=False, object owner=None): """Create an ExternalSemaphoreSignalParams instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. size (int): number of structs, default=1. readonly (bool): whether the data is read-only (to the user). default is `False`. owner (object): object that owns the memory at *ptr*. A strong reference is kept, by this wrapper and by every NumPy view of its data, so the backing storage outlives them. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef ExternalSemaphoreSignalParams obj = ExternalSemaphoreSignalParams.__new__(ExternalSemaphoreSignalParams) cdef _cyb_MemoryHolder buf = _cyb_MemoryHolder(ptr, sizeof(cudaExternalSemaphoreSignalParams) * size, readonly, owner) obj._data = _numpy.ndarray(size, buffer=buf, dtype=external_semaphore_signal_params_dtype_record) obj._owner = owner return obj cdef _get_external_semaphore_wait_params_dtype_offsets(): cdef cudaExternalSemaphoreWaitParams *pod = _cyb_calloc(1, sizeof(cudaExternalSemaphoreWaitParams)) if pod == NULL: raise MemoryError("Error allocating cudaExternalSemaphoreWaitParams") try: return _numpy.dtype({ 'names': ['params', 'flags_', 'reserved'], 'formats': [_py_anon_pod21_dtype, _numpy.uint32, (_numpy.uint32, 16)], 'offsets': [ (&(pod.params)) - (pod), (&(pod.flags)) - (pod), (&(pod.reserved)) - (pod), ], 'itemsize': sizeof(cudaExternalSemaphoreWaitParams), }) finally: _cyb_free(pod) external_semaphore_wait_params_dtype = _get_external_semaphore_wait_params_dtype_offsets() cdef object external_semaphore_wait_params_dtype_record = _numpy.dtype((_numpy.record, external_semaphore_wait_params_dtype)) cdef class ExternalSemaphoreWaitParams: """Empty-initialize an array of `cudaExternalSemaphoreWaitParams`. The resulting object is of length `size` and of dtype `external_semaphore_wait_params_dtype`. If default-constructed, the instance represents a single struct. Args: size (int): number of structs, default=1. .. seealso:: `cudaExternalSemaphoreWaitParams` """ cdef: readonly object _data object _owner def __init__(self, size=1): self._data = _numpy.zeros(size, dtype=external_semaphore_wait_params_dtype_record) assert self._data.itemsize == sizeof(cudaExternalSemaphoreWaitParams), \ f"itemsize {self._data.itemsize} mismatches struct size { sizeof(cudaExternalSemaphoreWaitParams) }" def __repr__(self): if self._data.size > 1: return f"<{__name__}.ExternalSemaphoreWaitParams_Array_{self._data.size} object at {hex(id(self))}>" else: return f"<{__name__}.ExternalSemaphoreWaitParams object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return _cyb_array_ptr(self._data) cdef intptr_t _get_ptr(self): return _cyb_array_ptr(self._data) def __int__(self): if self._data.size > 1 and not self._data.flags["C_CONTIGUOUS"]: raise TypeError("int() argument must be a bytes-like object of size 1, or a " "C-contiguous array. To get the pointer address of a " "non-contiguous array, use .ptr") return _cyb_array_ptr(self._data) def __len__(self): return self._data.size def __eq__(self, other): cdef object self_data = self._data if (not isinstance(other, ExternalSemaphoreWaitParams)) or self_data.size != other._data.size or self_data.dtype != other._data.dtype: return False return bool((self_data == other._data).all()) def __getbuffer__(self, Py_buffer *buffer, int flags): _cyb_cpython.PyObject_GetBuffer(self._data, buffer, flags) def __releasebuffer__(self, Py_buffer *buffer): _cyb_cpython.PyBuffer_Release(buffer) @property def params(self): """_py_anon_pod21_dtype: """ return self._data["params"].view(_numpy.recarray) @params.setter def params(self, val): if not self._data.flags.writeable: raise ValueError("This ExternalSemaphoreWaitParams instance is read-only") self._data["params"] = val @property def flags_(self): """Union[~_numpy.uint32, int]: Only when cudaExternalSemaphoreSignalParams is used to signal a cudaExternalSemaphore_t of type cudaExternalSemaphoreHandleTypeNvSciSync, the valid flag is cudaExternalSemaphoreSignalSkipNvSciBufMemSync: which indicates that while waiting for the cudaExternalSemaphore_t, no memory synchronization operations should be performed for any external memory object imported as cudaExternalMemoryHandleTypeNvSciBuf. For all other types of cudaExternalSemaphore_t, flags must be zero.""" if self._data.size == 1: return int(self._data["flags_"][0]) return self._data["flags_"] @flags_.setter def flags_(self, val): if not self._data.flags.writeable: raise ValueError("This ExternalSemaphoreWaitParams instance is read-only") self._data["flags_"] = val def __getitem__(self, key): cdef ssize_t key_ cdef ssize_t size cdef ExternalSemaphoreWaitParams obj if isinstance(key, int): key_ = key size = self._data.size if key_ >= size or key_ <= -(size+1): raise IndexError("index is out of bounds") if key_ < 0: key_ += size obj = ExternalSemaphoreWaitParams.__new__(ExternalSemaphoreWaitParams) obj._data = self._data[key_:key_+1] obj._owner = self._owner return obj out = self._data[key] if isinstance(out, _numpy.ndarray): if out.dtype == external_semaphore_wait_params_dtype: obj = ExternalSemaphoreWaitParams.from_data(out) obj._owner = self._owner return obj if out.dtype.names is not None: return out.view(_numpy.recarray) return out def __setitem__(self, key, val): self._data[key] = val @staticmethod def from_buffer(buffer): """Create an ExternalSemaphoreWaitParams instance with the memory from the given buffer.""" return ExternalSemaphoreWaitParams.from_data(_numpy.frombuffer(buffer, dtype=external_semaphore_wait_params_dtype)) @staticmethod def from_data(data): """Create an ExternalSemaphoreWaitParams instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a 1D array of dtype `external_semaphore_wait_params_dtype` holding the data. """ cdef ExternalSemaphoreWaitParams obj = ExternalSemaphoreWaitParams.__new__(ExternalSemaphoreWaitParams) if not isinstance(data, _numpy.ndarray): raise TypeError("data argument must be a NumPy ndarray") if data.ndim != 1: raise ValueError("data array must be 1D") if data.dtype != external_semaphore_wait_params_dtype: raise ValueError("data array must be of dtype external_semaphore_wait_params_dtype") obj._data = data.view(dtype=external_semaphore_wait_params_dtype_record, type=_numpy.ndarray) return obj @staticmethod def from_ptr(intptr_t ptr, size_t size=1, bint readonly=False, object owner=None): """Create an ExternalSemaphoreWaitParams instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. size (int): number of structs, default=1. readonly (bool): whether the data is read-only (to the user). default is `False`. owner (object): object that owns the memory at *ptr*. A strong reference is kept, by this wrapper and by every NumPy view of its data, so the backing storage outlives them. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef ExternalSemaphoreWaitParams obj = ExternalSemaphoreWaitParams.__new__(ExternalSemaphoreWaitParams) cdef _cyb_MemoryHolder buf = _cyb_MemoryHolder(ptr, sizeof(cudaExternalSemaphoreWaitParams) * size, readonly, owner) obj._data = _numpy.ndarray(size, buffer=buf, dtype=external_semaphore_wait_params_dtype_record) obj._owner = owner return obj cdef _get_graph_kernel_node_update_dtype_offsets(): cdef cudaGraphKernelNodeUpdate *pod = _cyb_calloc(1, sizeof(cudaGraphKernelNodeUpdate)) if pod == NULL: raise MemoryError("Error allocating cudaGraphKernelNodeUpdate") try: return _numpy.dtype({ 'names': ['node', 'field', 'update_data'], 'formats': [_numpy.intp, _numpy.int32, _py_anon_pod27_dtype], 'offsets': [ (&(pod.node)) - (pod), (&(pod.field)) - (pod), (&(pod.updateData)) - (pod), ], 'itemsize': sizeof(cudaGraphKernelNodeUpdate), }) finally: _cyb_free(pod) graph_kernel_node_update_dtype = _get_graph_kernel_node_update_dtype_offsets() cdef class GraphKernelNodeUpdate: """Empty-initialize an instance of `cudaGraphKernelNodeUpdate`. .. seealso:: `cudaGraphKernelNodeUpdate` """ cdef: cudaGraphKernelNodeUpdate *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cudaGraphKernelNodeUpdate)) if self._ptr == NULL: raise MemoryError("Error allocating GraphKernelNodeUpdate") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cudaGraphKernelNodeUpdate *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.GraphKernelNodeUpdate object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef GraphKernelNodeUpdate other_ if not isinstance(other, GraphKernelNodeUpdate): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaGraphKernelNodeUpdate)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaGraphKernelNodeUpdate), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This GraphKernelNodeUpdate instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaGraphKernelNodeUpdate): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaGraphKernelNodeUpdate), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cudaGraphKernelNodeUpdate)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def update_data(self): """_py_anon_pod27: Update data to apply. Which field is used depends on field's value""" return _py_anon_pod27.from_ptr( &(self._ptr[0].updateData), readonly=self._readonly, owner=self, ) @update_data.setter def update_data(self, val): if self._readonly: raise ValueError("This GraphKernelNodeUpdate instance is read-only") cdef _py_anon_pod27 val_ = val _cyb_memcpy(&(self._ptr[0].updateData), (val_._get_ptr()), sizeof(cuda_bindings_runtime__anon_pod27) * 1) @property def node(self): """int: Node to update""" return (self._ptr[0].node) @node.setter def node(self, val): if self._readonly: raise ValueError("This GraphKernelNodeUpdate instance is read-only") self._ptr[0].node = val @property def field(self): """int: Which type of update to apply. Determines how updateData is interpreted""" return (self._ptr[0].field) @field.setter def field(self, val): if self._readonly: raise ValueError("This GraphKernelNodeUpdate instance is read-only") self._ptr[0].field = val @staticmethod def from_buffer(buffer): """Create an GraphKernelNodeUpdate instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaGraphKernelNodeUpdate), GraphKernelNodeUpdate) @staticmethod def from_data(data): """Create an GraphKernelNodeUpdate instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `graph_kernel_node_update_dtype` holding the data. """ return _cyb_from_data(data, "graph_kernel_node_update_dtype", graph_kernel_node_update_dtype, GraphKernelNodeUpdate) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an GraphKernelNodeUpdate instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef GraphKernelNodeUpdate obj = GraphKernelNodeUpdate.__new__(GraphKernelNodeUpdate) if owner is None: obj._ptr = _cyb_malloc(sizeof(cudaGraphKernelNodeUpdate)) if obj._ptr == NULL: raise MemoryError("Error allocating GraphKernelNodeUpdate") _cyb_memcpy((obj._ptr), ptr, sizeof(cudaGraphKernelNodeUpdate)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_launch_attribute_dtype_offsets(): cdef cudaLaunchAttribute *pod = _cyb_calloc(1, sizeof(cudaLaunchAttribute)) if pod == NULL: raise MemoryError("Error allocating cudaLaunchAttribute") try: return _numpy.dtype({ 'names': ['id', 'val'], 'formats': [_numpy.dtype(('V', sizeof(pod.id))), launch_attribute_value_dtype], 'offsets': [ (&(pod.id)) - (pod), (&(pod.val)) - (pod), ], 'itemsize': sizeof(cudaLaunchAttribute), }) finally: _cyb_free(pod) launch_attribute_dtype = _get_launch_attribute_dtype_offsets() cdef class LaunchAttribute: """Empty-initialize an instance of `cudaLaunchAttribute`. .. seealso:: `cudaLaunchAttribute` """ cdef: cudaLaunchAttribute _data cudaLaunchAttribute *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.LaunchAttribute object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef LaunchAttribute other_ if not isinstance(other, LaunchAttribute): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaLaunchAttribute)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaLaunchAttribute), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This LaunchAttribute instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaLaunchAttribute): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaLaunchAttribute), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudaLaunchAttribute)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def val(self): """LaunchAttributeValue: """ return LaunchAttributeValue.from_ptr( &(self._ptr[0].val), readonly=self._readonly, owner=self, ) @val.setter def val(self, val): if self._readonly: raise ValueError("This LaunchAttribute instance is read-only") cdef LaunchAttributeValue val_ = val _cyb_memcpy(&(self._ptr[0].val), (val_._get_ptr()), sizeof(cudaLaunchAttributeValue) * 1) @property def id(self): """: """ return self._ptr[0].id @id.setter def id(self, val): if self._readonly: raise ValueError("This LaunchAttribute instance is read-only") self._ptr[0].id = val @staticmethod def from_buffer(buffer): """Create an LaunchAttribute instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaLaunchAttribute), LaunchAttribute) @staticmethod def from_data(data): """Create an LaunchAttribute instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `launch_attribute_dtype` holding the data. """ return _cyb_from_data(data, "launch_attribute_dtype", launch_attribute_dtype, LaunchAttribute) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an LaunchAttribute instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef LaunchAttribute obj = LaunchAttribute.__new__(LaunchAttribute) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudaLaunchAttribute)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get_async_notification_info_dtype_offsets(): cdef cudaAsyncNotificationInfo_t *pod = _cyb_calloc(1, sizeof(cudaAsyncNotificationInfo_t)) if pod == NULL: raise MemoryError("Error allocating cudaAsyncNotificationInfo_t") try: return _numpy.dtype({ 'names': ['type', 'info'], 'formats': [_numpy.int32, _py_anon_pod34_dtype], 'offsets': [ (&(pod.type)) - (pod), (&(pod.info)) - (pod), ], 'itemsize': sizeof(cudaAsyncNotificationInfo_t), }) finally: _cyb_free(pod) async_notification_info_dtype = _get_async_notification_info_dtype_offsets() cdef class AsyncNotificationInfo: """Empty-initialize an instance of `cudaAsyncNotificationInfo_t`. .. seealso:: `cudaAsyncNotificationInfo_t` """ cdef: cudaAsyncNotificationInfo_t _data cudaAsyncNotificationInfo_t *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.AsyncNotificationInfo object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef AsyncNotificationInfo other_ if not isinstance(other, AsyncNotificationInfo): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaAsyncNotificationInfo_t)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaAsyncNotificationInfo_t), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This AsyncNotificationInfo instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaAsyncNotificationInfo_t): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaAsyncNotificationInfo_t), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudaAsyncNotificationInfo_t)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def info(self): """_py_anon_pod34: """ return _py_anon_pod34.from_ptr( &(self._ptr[0].info), readonly=self._readonly, owner=self, ) @info.setter def info(self, val): if self._readonly: raise ValueError("This AsyncNotificationInfo instance is read-only") cdef _py_anon_pod34 val_ = val _cyb_memcpy(&(self._ptr[0].info), (val_._get_ptr()), sizeof(cuda_bindings_runtime__anon_pod34) * 1) @property def type(self): """int: """ return (self._ptr[0].type) @type.setter def type(self, val): if self._readonly: raise ValueError("This AsyncNotificationInfo instance is read-only") self._ptr[0].type = val @staticmethod def from_buffer(buffer): """Create an AsyncNotificationInfo instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaAsyncNotificationInfo_t), AsyncNotificationInfo) @staticmethod def from_data(data): """Create an AsyncNotificationInfo instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `async_notification_info_dtype` holding the data. """ return _cyb_from_data(data, "async_notification_info_dtype", async_notification_info_dtype, AsyncNotificationInfo) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an AsyncNotificationInfo instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef AsyncNotificationInfo obj = AsyncNotificationInfo.__new__(AsyncNotificationInfo) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudaAsyncNotificationInfo_t)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get_dev_resource_dtype_offsets(): cdef cudaDevResource *pod = _cyb_calloc(1, sizeof(cudaDevResource)) if pod == NULL: raise MemoryError("Error allocating cudaDevResource") try: return _numpy.dtype({ 'names': ['type', '_internal_padding', 'sm', 'wq_config', 'wq', '_oversize', 'next_resource'], 'formats': [_numpy.int32, (_numpy.uint8, 92), dev_sm_resource_dtype, dev_workqueue_config_resource_dtype, dev_workqueue_resource_dtype, (_numpy.uint8, 40), _numpy.intp], 'offsets': [ (&(pod.type)) - (pod), (&(pod._internal_padding)) - (pod), (&(pod.sm)) - (pod), (&(pod.wqConfig)) - (pod), (&(pod.wq)) - (pod), (&(pod._oversize)) - (pod), (&(pod.nextResource)) - (pod), ], 'itemsize': sizeof(cudaDevResource), }) finally: _cyb_free(pod) dev_resource_dtype = _get_dev_resource_dtype_offsets() cdef object dev_resource_dtype_record = _numpy.dtype((_numpy.record, dev_resource_dtype)) cdef class DevResource: """Empty-initialize an array of `cudaDevResource`. The resulting object is of length `size` and of dtype `dev_resource_dtype`. If default-constructed, the instance represents a single struct. Args: size (int): number of structs, default=1. .. seealso:: `cudaDevResource` """ cdef: readonly object _data object _owner readonly tuple _sm readonly tuple _wq_config readonly tuple _wq def __init__(self, size=1): self._data = _numpy.zeros(size, dtype=dev_resource_dtype_record) assert self._data.itemsize == sizeof(cudaDevResource), \ f"itemsize {self._data.itemsize} mismatches struct size { sizeof(cudaDevResource) }" def __repr__(self): if self._data.size > 1: return f"<{__name__}.DevResource_Array_{self._data.size} object at {hex(id(self))}>" else: return f"<{__name__}.DevResource object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return _cyb_array_ptr(self._data) cdef intptr_t _get_ptr(self): return _cyb_array_ptr(self._data) def __int__(self): if self._data.size > 1 and not self._data.flags["C_CONTIGUOUS"]: raise TypeError("int() argument must be a bytes-like object of size 1, or a " "C-contiguous array. To get the pointer address of a " "non-contiguous array, use .ptr") return _cyb_array_ptr(self._data) def __len__(self): return self._data.size def __eq__(self, other): cdef object self_data = self._data if (not isinstance(other, DevResource)) or self_data.size != other._data.size or self_data.dtype != other._data.dtype: return False return bool((self_data == other._data).all()) def __getbuffer__(self, Py_buffer *buffer, int flags): _cyb_cpython.PyObject_GetBuffer(self._data, buffer, flags) def __releasebuffer__(self, Py_buffer *buffer): _cyb_cpython.PyBuffer_Release(buffer) @property def sm(self): """DevSmResource: """ if self._sm is None: sm_list = list() sm_base = _cyb_array_ptr(self._data) sm_offset = dev_resource_dtype.fields["sm"][1] sm_stride = self._data.strides[0] sm_readonly = not self._data.flags.writeable for i in range(self._data.size): addr = sm_base + i * sm_stride + sm_offset sm_obj = DevSmResource.from_ptr(addr, owner=self._data, readonly=sm_readonly) sm_list.append(sm_obj) self._sm = tuple(sm_list) if self._data.size == 1: return self._sm[0] return self._sm @sm.setter def sm(self, val): if not self._data.flags.writeable: raise ValueError("This DevResource instance is read-only") cdef DevSmResource val_ = val if self._data.size != 1: raise ValueError("Assign to the member of one element, e.g. array[i].sm = value") cdef intptr_t addr = _cyb_array_ptr(self._data) + dev_resource_dtype.fields["sm"][1] _cyb_memcpy(addr, (val_._get_ptr()), sizeof(cudaDevSmResource) * 1) @property def wq_config(self): """DevWorkqueueConfigResource: """ if self._wq_config is None: wq_config_list = list() wq_config_base = _cyb_array_ptr(self._data) wq_config_offset = dev_resource_dtype.fields["wq_config"][1] wq_config_stride = self._data.strides[0] wq_config_readonly = not self._data.flags.writeable for i in range(self._data.size): addr = wq_config_base + i * wq_config_stride + wq_config_offset wq_config_obj = DevWorkqueueConfigResource.from_ptr(addr, owner=self._data, readonly=wq_config_readonly) wq_config_list.append(wq_config_obj) self._wq_config = tuple(wq_config_list) if self._data.size == 1: return self._wq_config[0] return self._wq_config @wq_config.setter def wq_config(self, val): if not self._data.flags.writeable: raise ValueError("This DevResource instance is read-only") cdef DevWorkqueueConfigResource val_ = val if self._data.size != 1: raise ValueError("Assign to the member of one element, e.g. array[i].wq_config = value") cdef intptr_t addr = _cyb_array_ptr(self._data) + dev_resource_dtype.fields["wq_config"][1] _cyb_memcpy(addr, (val_._get_ptr()), sizeof(cudaDevWorkqueueConfigResource) * 1) @property def wq(self): """DevWorkqueueResource: """ if self._wq is None: wq_list = list() wq_base = _cyb_array_ptr(self._data) wq_offset = dev_resource_dtype.fields["wq"][1] wq_stride = self._data.strides[0] wq_readonly = not self._data.flags.writeable for i in range(self._data.size): addr = wq_base + i * wq_stride + wq_offset wq_obj = DevWorkqueueResource.from_ptr(addr, owner=self._data, readonly=wq_readonly) wq_list.append(wq_obj) self._wq = tuple(wq_list) if self._data.size == 1: return self._wq[0] return self._wq @wq.setter def wq(self, val): if not self._data.flags.writeable: raise ValueError("This DevResource instance is read-only") cdef DevWorkqueueResource val_ = val if self._data.size != 1: raise ValueError("Assign to the member of one element, e.g. array[i].wq = value") cdef intptr_t addr = _cyb_array_ptr(self._data) + dev_resource_dtype.fields["wq"][1] _cyb_memcpy(addr, (val_._get_ptr()), sizeof(cudaDevWorkqueueResource) * 1) @property def type(self): """Union[~_numpy.int32, int]: """ if self._data.size == 1: return int(self._data["type"][0]) return self._data["type"] @type.setter def type(self, val): if not self._data.flags.writeable: raise ValueError("This DevResource instance is read-only") self._data["type"] = val @property def _internal_padding(self): """~_numpy.uint8: (array of length 92).""" return self._data["_internal_padding"] @_internal_padding.setter def _internal_padding(self, val): if not self._data.flags.writeable: raise ValueError("This DevResource instance is read-only") self._data["_internal_padding"] = val @property def _oversize(self): """~_numpy.uint8: (array of length 40).""" return self._data["_oversize"] @_oversize.setter def _oversize(self, val): if not self._data.flags.writeable: raise ValueError("This DevResource instance is read-only") self._data["_oversize"] = val @property def next_resource(self): """Union[~_numpy.intp, int]: """ if self._data.size == 1: return int(self._data["next_resource"][0]) return self._data["next_resource"] @next_resource.setter def next_resource(self, val): if not self._data.flags.writeable: raise ValueError("This DevResource instance is read-only") self._data["next_resource"] = val def __getitem__(self, key): cdef ssize_t key_ cdef ssize_t size cdef DevResource obj if isinstance(key, int): key_ = key size = self._data.size if key_ >= size or key_ <= -(size+1): raise IndexError("index is out of bounds") if key_ < 0: key_ += size obj = DevResource.__new__(DevResource) obj._data = self._data[key_:key_+1] obj._owner = self._owner return obj out = self._data[key] if isinstance(out, _numpy.ndarray): if out.dtype == dev_resource_dtype: obj = DevResource.from_data(out) obj._owner = self._owner return obj if out.dtype.names is not None: return out.view(_numpy.recarray) return out def __setitem__(self, key, val): self._data[key] = val @staticmethod def from_buffer(buffer): """Create an DevResource instance with the memory from the given buffer.""" return DevResource.from_data(_numpy.frombuffer(buffer, dtype=dev_resource_dtype)) @staticmethod def from_data(data): """Create an DevResource instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a 1D array of dtype `dev_resource_dtype` holding the data. """ cdef DevResource obj = DevResource.__new__(DevResource) if not isinstance(data, _numpy.ndarray): raise TypeError("data argument must be a NumPy ndarray") if data.ndim != 1: raise ValueError("data array must be 1D") if data.dtype != dev_resource_dtype: raise ValueError("data array must be of dtype dev_resource_dtype") obj._data = data.view(dtype=dev_resource_dtype_record, type=_numpy.ndarray) return obj @staticmethod def from_ptr(intptr_t ptr, size_t size=1, bint readonly=False, object owner=None): """Create an DevResource instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. size (int): number of structs, default=1. readonly (bool): whether the data is read-only (to the user). default is `False`. owner (object): object that owns the memory at *ptr*. A strong reference is kept, by this wrapper and by every NumPy view of its data, so the backing storage outlives them. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef DevResource obj = DevResource.__new__(DevResource) cdef _cyb_MemoryHolder buf = _cyb_MemoryHolder(ptr, sizeof(cudaDevResource) * size, readonly, owner) obj._data = _numpy.ndarray(size, buffer=buf, dtype=dev_resource_dtype_record) obj._owner = owner return obj cdef _get_resource_desc_dtype_offsets(): cdef cudaResourceDesc *pod = _cyb_calloc(1, sizeof(cudaResourceDesc)) if pod == NULL: raise MemoryError("Error allocating cudaResourceDesc") try: return _numpy.dtype({ 'names': ['res_type', 'res', 'flags_'], 'formats': [_numpy.int32, _py_anon_pod1_dtype, _numpy.uint32], 'offsets': [ (&(pod.resType)) - (pod), (&(pod.res)) - (pod), (&(pod.flags)) - (pod), ], 'itemsize': sizeof(cudaResourceDesc), }) finally: _cyb_free(pod) resource_desc_dtype = _get_resource_desc_dtype_offsets() cdef class ResourceDesc: """Empty-initialize an instance of `cudaResourceDesc`. .. seealso:: `cudaResourceDesc` """ cdef: cudaResourceDesc _data cudaResourceDesc *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.ResourceDesc object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef ResourceDesc other_ if not isinstance(other, ResourceDesc): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaResourceDesc)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaResourceDesc), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This ResourceDesc instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaResourceDesc): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaResourceDesc), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudaResourceDesc)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def res(self): """_py_anon_pod1: """ return _py_anon_pod1.from_ptr( &(self._ptr[0].res), readonly=self._readonly, owner=self, ) @res.setter def res(self, val): if self._readonly: raise ValueError("This ResourceDesc instance is read-only") cdef _py_anon_pod1 val_ = val _cyb_memcpy(&(self._ptr[0].res), (val_._get_ptr()), sizeof(cuda_bindings_runtime__anon_pod1) * 1) @property def res_type(self): """int: Resource type""" return (self._ptr[0].resType) @res_type.setter def res_type(self, val): if self._readonly: raise ValueError("This ResourceDesc instance is read-only") self._ptr[0].resType = val @property def flags_(self): """int: Flags (must be zero)""" return self._ptr[0].flags @flags_.setter def flags_(self, val): if self._readonly: raise ValueError("This ResourceDesc instance is read-only") self._ptr[0].flags = val @staticmethod def from_buffer(buffer): """Create an ResourceDesc instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaResourceDesc), ResourceDesc) @staticmethod def from_data(data): """Create an ResourceDesc instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `resource_desc_dtype` holding the data. """ return _cyb_from_data(data, "resource_desc_dtype", resource_desc_dtype, ResourceDesc) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an ResourceDesc instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef ResourceDesc obj = ResourceDesc.__new__(ResourceDesc) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudaResourceDesc)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get_mem_access_desc_dtype_offsets(): cdef cudaMemAccessDesc *pod = _cyb_calloc(1, sizeof(cudaMemAccessDesc)) if pod == NULL: raise MemoryError("Error allocating cudaMemAccessDesc") try: return _numpy.dtype({ 'names': ['location', 'flags_'], 'formats': [mem_location_dtype, _numpy.int32], 'offsets': [ (&(pod.location)) - (pod), (&(pod.flags)) - (pod), ], 'itemsize': sizeof(cudaMemAccessDesc), }) finally: _cyb_free(pod) mem_access_desc_dtype = _get_mem_access_desc_dtype_offsets() cdef object mem_access_desc_dtype_record = _numpy.dtype((_numpy.record, mem_access_desc_dtype)) cdef class MemAccessDesc: """Empty-initialize an array of `cudaMemAccessDesc`. The resulting object is of length `size` and of dtype `mem_access_desc_dtype`. If default-constructed, the instance represents a single struct. Args: size (int): number of structs, default=1. .. seealso:: `cudaMemAccessDesc` """ cdef: readonly object _data object _owner readonly tuple _location def __init__(self, size=1): self._data = _numpy.zeros(size, dtype=mem_access_desc_dtype_record) assert self._data.itemsize == sizeof(cudaMemAccessDesc), \ f"itemsize {self._data.itemsize} mismatches struct size { sizeof(cudaMemAccessDesc) }" def __repr__(self): if self._data.size > 1: return f"<{__name__}.MemAccessDesc_Array_{self._data.size} object at {hex(id(self))}>" else: return f"<{__name__}.MemAccessDesc object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return _cyb_array_ptr(self._data) cdef intptr_t _get_ptr(self): return _cyb_array_ptr(self._data) def __int__(self): if self._data.size > 1 and not self._data.flags["C_CONTIGUOUS"]: raise TypeError("int() argument must be a bytes-like object of size 1, or a " "C-contiguous array. To get the pointer address of a " "non-contiguous array, use .ptr") return _cyb_array_ptr(self._data) def __len__(self): return self._data.size def __eq__(self, other): cdef object self_data = self._data if (not isinstance(other, MemAccessDesc)) or self_data.size != other._data.size or self_data.dtype != other._data.dtype: return False return bool((self_data == other._data).all()) def __getbuffer__(self, Py_buffer *buffer, int flags): _cyb_cpython.PyObject_GetBuffer(self._data, buffer, flags) def __releasebuffer__(self, Py_buffer *buffer): _cyb_cpython.PyBuffer_Release(buffer) @property def location(self): """MemLocation: Location on which the request is to change it's accessibility""" if self._location is None: location_list = list() location_base = _cyb_array_ptr(self._data) location_offset = mem_access_desc_dtype.fields["location"][1] location_stride = self._data.strides[0] location_readonly = not self._data.flags.writeable for i in range(self._data.size): addr = location_base + i * location_stride + location_offset location_obj = MemLocation.from_ptr(addr, owner=self._data, readonly=location_readonly) location_list.append(location_obj) self._location = tuple(location_list) if self._data.size == 1: return self._location[0] return self._location @location.setter def location(self, val): if not self._data.flags.writeable: raise ValueError("This MemAccessDesc instance is read-only") cdef MemLocation val_ = val if self._data.size != 1: raise ValueError("Assign to the member of one element, e.g. array[i].location = value") cdef intptr_t addr = _cyb_array_ptr(self._data) + mem_access_desc_dtype.fields["location"][1] _cyb_memcpy(addr, (val_._get_ptr()), sizeof(cudaMemLocation) * 1) @property def flags_(self): """Union[~_numpy.int32, int]: ::CUmemProt accessibility flags to set on the request""" if self._data.size == 1: return int(self._data["flags_"][0]) return self._data["flags_"] @flags_.setter def flags_(self, val): if not self._data.flags.writeable: raise ValueError("This MemAccessDesc instance is read-only") self._data["flags_"] = val def __getitem__(self, key): cdef ssize_t key_ cdef ssize_t size cdef MemAccessDesc obj if isinstance(key, int): key_ = key size = self._data.size if key_ >= size or key_ <= -(size+1): raise IndexError("index is out of bounds") if key_ < 0: key_ += size obj = MemAccessDesc.__new__(MemAccessDesc) obj._data = self._data[key_:key_+1] obj._owner = self._owner return obj out = self._data[key] if isinstance(out, _numpy.ndarray): if out.dtype == mem_access_desc_dtype: obj = MemAccessDesc.from_data(out) obj._owner = self._owner return obj if out.dtype.names is not None: return out.view(_numpy.recarray) return out def __setitem__(self, key, val): self._data[key] = val @staticmethod def from_buffer(buffer): """Create an MemAccessDesc instance with the memory from the given buffer.""" return MemAccessDesc.from_data(_numpy.frombuffer(buffer, dtype=mem_access_desc_dtype)) @staticmethod def from_data(data): """Create an MemAccessDesc instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a 1D array of dtype `mem_access_desc_dtype` holding the data. """ cdef MemAccessDesc obj = MemAccessDesc.__new__(MemAccessDesc) if not isinstance(data, _numpy.ndarray): raise TypeError("data argument must be a NumPy ndarray") if data.ndim != 1: raise ValueError("data array must be 1D") if data.dtype != mem_access_desc_dtype: raise ValueError("data array must be of dtype mem_access_desc_dtype") obj._data = data.view(dtype=mem_access_desc_dtype_record, type=_numpy.ndarray) return obj @staticmethod def from_ptr(intptr_t ptr, size_t size=1, bint readonly=False, object owner=None): """Create an MemAccessDesc instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. size (int): number of structs, default=1. readonly (bool): whether the data is read-only (to the user). default is `False`. owner (object): object that owns the memory at *ptr*. A strong reference is kept, by this wrapper and by every NumPy view of its data, so the backing storage outlives them. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef MemAccessDesc obj = MemAccessDesc.__new__(MemAccessDesc) cdef _cyb_MemoryHolder buf = _cyb_MemoryHolder(ptr, sizeof(cudaMemAccessDesc) * size, readonly, owner) obj._data = _numpy.ndarray(size, buffer=buf, dtype=mem_access_desc_dtype_record) obj._owner = owner return obj cdef _get_mem_pool_props_dtype_offsets(): cdef cudaMemPoolProps *pod = _cyb_calloc(1, sizeof(cudaMemPoolProps)) if pod == NULL: raise MemoryError("Error allocating cudaMemPoolProps") try: return _numpy.dtype({ 'names': ['alloc_type', 'handle_types', 'location', 'win32security_attributes', 'max_size', 'usage', 'reserved', 'reserved1'], 'formats': [_numpy.int32, _numpy.int32, mem_location_dtype, _numpy.intp, _numpy.uint64, _numpy.uint16, (_numpy.uint8, 53), _numpy.uint8], 'offsets': [ (&(pod.allocType)) - (pod), (&(pod.handleTypes)) - (pod), (&(pod.location)) - (pod), (&(pod.win32SecurityAttributes)) - (pod), (&(pod.maxSize)) - (pod), (&(pod.usage)) - (pod), (&(pod.reserved)) - (pod), (&(pod.reserved1)) - (pod), ], 'itemsize': sizeof(cudaMemPoolProps), }) finally: _cyb_free(pod) mem_pool_props_dtype = _get_mem_pool_props_dtype_offsets() cdef class MemPoolProps: """Empty-initialize an instance of `cudaMemPoolProps`. .. seealso:: `cudaMemPoolProps` """ cdef: cudaMemPoolProps *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cudaMemPoolProps)) if self._ptr == NULL: raise MemoryError("Error allocating MemPoolProps") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cudaMemPoolProps *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.MemPoolProps object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef MemPoolProps other_ if not isinstance(other, MemPoolProps): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaMemPoolProps)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaMemPoolProps), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This MemPoolProps instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaMemPoolProps): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaMemPoolProps), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cudaMemPoolProps)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def location(self): """MemLocation: Location allocations should reside.""" return MemLocation.from_ptr( &(self._ptr[0].location), 1, readonly=self._readonly, owner=self, ) @location.setter def location(self, val): if self._readonly: raise ValueError("This MemPoolProps instance is read-only") cdef MemLocation val_ = val _cyb_memcpy(&(self._ptr[0].location), (val_._get_ptr()), sizeof(cudaMemLocation) * 1) @property def alloc_type(self): """int: Allocation type. Currently must be specified as cudaMemAllocationTypePinned""" return (self._ptr[0].allocType) @alloc_type.setter def alloc_type(self, val): if self._readonly: raise ValueError("This MemPoolProps instance is read-only") self._ptr[0].allocType = val @property def handle_types(self): """int: Handle types that will be supported by allocations from the pool.""" return (self._ptr[0].handleTypes) @handle_types.setter def handle_types(self, val): if self._readonly: raise ValueError("This MemPoolProps instance is read-only") self._ptr[0].handleTypes = val @property def win32security_attributes(self): """int: Windows-specific LPSECURITYATTRIBUTES required when cudaMemHandleTypeWin32 is specified. This security attribute defines the scope of which exported allocations may be tranferred to other processes. In all other cases, this field is required to be zero.""" return (self._ptr[0].win32SecurityAttributes) @win32security_attributes.setter def win32security_attributes(self, val): if self._readonly: raise ValueError("This MemPoolProps instance is read-only") self._ptr[0].win32SecurityAttributes = val @property def max_size(self): """int: Maximum pool size. When set to 0, defaults to a system dependent value.""" return self._ptr[0].maxSize @max_size.setter def max_size(self, val): if self._readonly: raise ValueError("This MemPoolProps instance is read-only") self._ptr[0].maxSize = val @property def usage(self): """int: Bitmask indicating intended usage for the pool.""" return self._ptr[0].usage @usage.setter def usage(self, val): if self._readonly: raise ValueError("This MemPoolProps instance is read-only") self._ptr[0].usage = val @staticmethod def from_buffer(buffer): """Create an MemPoolProps instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaMemPoolProps), MemPoolProps) @staticmethod def from_data(data): """Create an MemPoolProps instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `mem_pool_props_dtype` holding the data. """ return _cyb_from_data(data, "mem_pool_props_dtype", mem_pool_props_dtype, MemPoolProps) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an MemPoolProps instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef MemPoolProps obj = MemPoolProps.__new__(MemPoolProps) if owner is None: obj._ptr = _cyb_malloc(sizeof(cudaMemPoolProps)) if obj._ptr == NULL: raise MemoryError("Error allocating MemPoolProps") _cyb_memcpy((obj._ptr), ptr, sizeof(cudaMemPoolProps)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_mem_cpy_attributes_dtype_offsets(): cdef cudaMemcpyAttributes *pod = _cyb_calloc(1, sizeof(cudaMemcpyAttributes)) if pod == NULL: raise MemoryError("Error allocating cudaMemcpyAttributes") try: return _numpy.dtype({ 'names': ['src_access_order', 'src_loc_hint', 'dst_loc_hint', 'flags_'], 'formats': [_numpy.int32, mem_location_dtype, mem_location_dtype, _numpy.uint32], 'offsets': [ (&(pod.srcAccessOrder)) - (pod), (&(pod.srcLocHint)) - (pod), (&(pod.dstLocHint)) - (pod), (&(pod.flags)) - (pod), ], 'itemsize': sizeof(cudaMemcpyAttributes), }) finally: _cyb_free(pod) mem_cpy_attributes_dtype = _get_mem_cpy_attributes_dtype_offsets() cdef object mem_cpy_attributes_dtype_record = _numpy.dtype((_numpy.record, mem_cpy_attributes_dtype)) cdef class MemCpyAttributes: """Empty-initialize an array of `cudaMemcpyAttributes`. The resulting object is of length `size` and of dtype `mem_cpy_attributes_dtype`. If default-constructed, the instance represents a single struct. Args: size (int): number of structs, default=1. .. seealso:: `cudaMemcpyAttributes` """ cdef: readonly object _data object _owner readonly tuple _src_loc_hint readonly tuple _dst_loc_hint def __init__(self, size=1): self._data = _numpy.zeros(size, dtype=mem_cpy_attributes_dtype_record) assert self._data.itemsize == sizeof(cudaMemcpyAttributes), \ f"itemsize {self._data.itemsize} mismatches struct size { sizeof(cudaMemcpyAttributes) }" def __repr__(self): if self._data.size > 1: return f"<{__name__}.MemCpyAttributes_Array_{self._data.size} object at {hex(id(self))}>" else: return f"<{__name__}.MemCpyAttributes object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return _cyb_array_ptr(self._data) cdef intptr_t _get_ptr(self): return _cyb_array_ptr(self._data) def __int__(self): if self._data.size > 1 and not self._data.flags["C_CONTIGUOUS"]: raise TypeError("int() argument must be a bytes-like object of size 1, or a " "C-contiguous array. To get the pointer address of a " "non-contiguous array, use .ptr") return _cyb_array_ptr(self._data) def __len__(self): return self._data.size def __eq__(self, other): cdef object self_data = self._data if (not isinstance(other, MemCpyAttributes)) or self_data.size != other._data.size or self_data.dtype != other._data.dtype: return False return bool((self_data == other._data).all()) def __getbuffer__(self, Py_buffer *buffer, int flags): _cyb_cpython.PyObject_GetBuffer(self._data, buffer, flags) def __releasebuffer__(self, Py_buffer *buffer): _cyb_cpython.PyBuffer_Release(buffer) @property def src_loc_hint(self): """MemLocation: Hint location for the source operand. Ignored when the pointers are not managed memory or memory allocated outside CUDA.""" if self._src_loc_hint is None: src_loc_hint_list = list() src_loc_hint_base = _cyb_array_ptr(self._data) src_loc_hint_offset = mem_cpy_attributes_dtype.fields["src_loc_hint"][1] src_loc_hint_stride = self._data.strides[0] src_loc_hint_readonly = not self._data.flags.writeable for i in range(self._data.size): addr = src_loc_hint_base + i * src_loc_hint_stride + src_loc_hint_offset src_loc_hint_obj = MemLocation.from_ptr(addr, owner=self._data, readonly=src_loc_hint_readonly) src_loc_hint_list.append(src_loc_hint_obj) self._src_loc_hint = tuple(src_loc_hint_list) if self._data.size == 1: return self._src_loc_hint[0] return self._src_loc_hint @src_loc_hint.setter def src_loc_hint(self, val): if not self._data.flags.writeable: raise ValueError("This MemCpyAttributes instance is read-only") cdef MemLocation val_ = val if self._data.size != 1: raise ValueError("Assign to the member of one element, e.g. array[i].src_loc_hint = value") cdef intptr_t addr = _cyb_array_ptr(self._data) + mem_cpy_attributes_dtype.fields["src_loc_hint"][1] _cyb_memcpy(addr, (val_._get_ptr()), sizeof(cudaMemLocation) * 1) @property def dst_loc_hint(self): """MemLocation: Hint location for the destination operand. Ignored when the pointers are not managed memory or memory allocated outside CUDA.""" if self._dst_loc_hint is None: dst_loc_hint_list = list() dst_loc_hint_base = _cyb_array_ptr(self._data) dst_loc_hint_offset = mem_cpy_attributes_dtype.fields["dst_loc_hint"][1] dst_loc_hint_stride = self._data.strides[0] dst_loc_hint_readonly = not self._data.flags.writeable for i in range(self._data.size): addr = dst_loc_hint_base + i * dst_loc_hint_stride + dst_loc_hint_offset dst_loc_hint_obj = MemLocation.from_ptr(addr, owner=self._data, readonly=dst_loc_hint_readonly) dst_loc_hint_list.append(dst_loc_hint_obj) self._dst_loc_hint = tuple(dst_loc_hint_list) if self._data.size == 1: return self._dst_loc_hint[0] return self._dst_loc_hint @dst_loc_hint.setter def dst_loc_hint(self, val): if not self._data.flags.writeable: raise ValueError("This MemCpyAttributes instance is read-only") cdef MemLocation val_ = val if self._data.size != 1: raise ValueError("Assign to the member of one element, e.g. array[i].dst_loc_hint = value") cdef intptr_t addr = _cyb_array_ptr(self._data) + mem_cpy_attributes_dtype.fields["dst_loc_hint"][1] _cyb_memcpy(addr, (val_._get_ptr()), sizeof(cudaMemLocation) * 1) @property def src_access_order(self): """Union[~_numpy.int32, int]: Source access ordering to be observed for copies with this attribute.""" if self._data.size == 1: return int(self._data["src_access_order"][0]) return self._data["src_access_order"] @src_access_order.setter def src_access_order(self, val): if not self._data.flags.writeable: raise ValueError("This MemCpyAttributes instance is read-only") self._data["src_access_order"] = val @property def flags_(self): """Union[~_numpy.uint32, int]: Additional flags for copies with this attribute. See cudaMemcpyFlags.""" if self._data.size == 1: return int(self._data["flags_"][0]) return self._data["flags_"] @flags_.setter def flags_(self, val): if not self._data.flags.writeable: raise ValueError("This MemCpyAttributes instance is read-only") self._data["flags_"] = val def __getitem__(self, key): cdef ssize_t key_ cdef ssize_t size cdef MemCpyAttributes obj if isinstance(key, int): key_ = key size = self._data.size if key_ >= size or key_ <= -(size+1): raise IndexError("index is out of bounds") if key_ < 0: key_ += size obj = MemCpyAttributes.__new__(MemCpyAttributes) obj._data = self._data[key_:key_+1] obj._owner = self._owner return obj out = self._data[key] if isinstance(out, _numpy.ndarray): if out.dtype == mem_cpy_attributes_dtype: obj = MemCpyAttributes.from_data(out) obj._owner = self._owner return obj if out.dtype.names is not None: return out.view(_numpy.recarray) return out def __setitem__(self, key, val): self._data[key] = val @staticmethod def from_buffer(buffer): """Create an MemCpyAttributes instance with the memory from the given buffer.""" return MemCpyAttributes.from_data(_numpy.frombuffer(buffer, dtype=mem_cpy_attributes_dtype)) @staticmethod def from_data(data): """Create an MemCpyAttributes instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a 1D array of dtype `mem_cpy_attributes_dtype` holding the data. """ cdef MemCpyAttributes obj = MemCpyAttributes.__new__(MemCpyAttributes) if not isinstance(data, _numpy.ndarray): raise TypeError("data argument must be a NumPy ndarray") if data.ndim != 1: raise ValueError("data array must be 1D") if data.dtype != mem_cpy_attributes_dtype: raise ValueError("data array must be of dtype mem_cpy_attributes_dtype") obj._data = data.view(dtype=mem_cpy_attributes_dtype_record, type=_numpy.ndarray) return obj @staticmethod def from_ptr(intptr_t ptr, size_t size=1, bint readonly=False, object owner=None): """Create an MemCpyAttributes instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. size (int): number of structs, default=1. readonly (bool): whether the data is read-only (to the user). default is `False`. owner (object): object that owns the memory at *ptr*. A strong reference is kept, by this wrapper and by every NumPy view of its data, so the backing storage outlives them. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef MemCpyAttributes obj = MemCpyAttributes.__new__(MemCpyAttributes) cdef _cyb_MemoryHolder buf = _cyb_MemoryHolder(ptr, sizeof(cudaMemcpyAttributes) * size, readonly, owner) obj._data = _numpy.ndarray(size, buffer=buf, dtype=mem_cpy_attributes_dtype_record) obj._owner = owner return obj cdef _get__py_anon_pod11_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod11 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod11)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod11") try: return _numpy.dtype({ 'names': ['ptr_', 'row_length', 'layer_height', 'loc_hint'], 'formats': [_numpy.intp, _numpy.uint64, _numpy.uint64, mem_location_dtype], 'offsets': [ (&(pod.ptr)) - (pod), (&(pod.rowLength)) - (pod), (&(pod.layerHeight)) - (pod), (&(pod.locHint)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod11), }) finally: _cyb_free(pod) _py_anon_pod11_dtype = _get__py_anon_pod11_dtype_offsets() cdef class _py_anon_pod11: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod11`. .. seealso:: `cuda_bindings_runtime__anon_pod11` """ cdef: cuda_bindings_runtime__anon_pod11 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod11)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod11") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod11 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod11 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod11 other_ if not isinstance(other, _py_anon_pod11): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod11)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod11), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod11 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod11): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod11), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod11)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def loc_hint(self): """MemLocation: """ return MemLocation.from_ptr( &(self._ptr[0].locHint), 1, readonly=self._readonly, owner=self, ) @loc_hint.setter def loc_hint(self, val): if self._readonly: raise ValueError("This _py_anon_pod11 instance is read-only") cdef MemLocation val_ = val _cyb_memcpy(&(self._ptr[0].locHint), (val_._get_ptr()), sizeof(cudaMemLocation) * 1) @property def ptr_(self): """int: """ return (self._ptr[0].ptr) @ptr_.setter def ptr_(self, val): if self._readonly: raise ValueError("This _py_anon_pod11 instance is read-only") self._ptr[0].ptr = val @property def row_length(self): """int: """ return self._ptr[0].rowLength @row_length.setter def row_length(self, val): if self._readonly: raise ValueError("This _py_anon_pod11 instance is read-only") self._ptr[0].rowLength = val @property def layer_height(self): """int: """ return self._ptr[0].layerHeight @layer_height.setter def layer_height(self, val): if self._readonly: raise ValueError("This _py_anon_pod11 instance is read-only") self._ptr[0].layerHeight = val @staticmethod def from_buffer(buffer): """Create an _py_anon_pod11 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod11), _py_anon_pod11) @staticmethod def from_data(data): """Create an _py_anon_pod11 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod11_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod11_dtype", _py_anon_pod11_dtype, _py_anon_pod11) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod11 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod11 obj = _py_anon_pod11.__new__(_py_anon_pod11) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod11)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod11") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod11)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_external_semaphore_signal_node_params_dtype_offsets(): cdef cudaExternalSemaphoreSignalNodeParams *pod = _cyb_calloc(1, sizeof(cudaExternalSemaphoreSignalNodeParams)) if pod == NULL: raise MemoryError("Error allocating cudaExternalSemaphoreSignalNodeParams") try: return _numpy.dtype({ 'names': ['ext_sem_array', 'params_array', 'num_ext_sems'], 'formats': [_numpy.intp, _numpy.intp, _numpy.uint32], 'offsets': [ (&(pod.extSemArray)) - (pod), (&(pod.paramsArray)) - (pod), (&(pod.numExtSems)) - (pod), ], 'itemsize': sizeof(cudaExternalSemaphoreSignalNodeParams), }) finally: _cyb_free(pod) external_semaphore_signal_node_params_dtype = _get_external_semaphore_signal_node_params_dtype_offsets() cdef class ExternalSemaphoreSignalNodeParams: """Empty-initialize an instance of `cudaExternalSemaphoreSignalNodeParams`. .. seealso:: `cudaExternalSemaphoreSignalNodeParams` """ cdef: cudaExternalSemaphoreSignalNodeParams _data cudaExternalSemaphoreSignalNodeParams *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.ExternalSemaphoreSignalNodeParams object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef ExternalSemaphoreSignalNodeParams other_ if not isinstance(other, ExternalSemaphoreSignalNodeParams): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaExternalSemaphoreSignalNodeParams)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaExternalSemaphoreSignalNodeParams), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This ExternalSemaphoreSignalNodeParams instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaExternalSemaphoreSignalNodeParams): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaExternalSemaphoreSignalNodeParams), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudaExternalSemaphoreSignalNodeParams)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def ext_sem_array(self): """int: Array of external semaphore handles.""" return (self._ptr[0].extSemArray) @ext_sem_array.setter def ext_sem_array(self, val): if self._readonly: raise ValueError("This ExternalSemaphoreSignalNodeParams instance is read-only") self._ptr[0].extSemArray = val @property def params_array(self): """int: Array of external semaphore signal parameters.""" return (self._ptr[0].paramsArray) @params_array.setter def params_array(self, val): if self._readonly: raise ValueError("This ExternalSemaphoreSignalNodeParams instance is read-only") self._ptr[0].paramsArray = val @property def num_ext_sems(self): """int: Number of handles and parameters supplied in extSemArray and paramsArray.""" return self._ptr[0].numExtSems @num_ext_sems.setter def num_ext_sems(self, val): if self._readonly: raise ValueError("This ExternalSemaphoreSignalNodeParams instance is read-only") self._ptr[0].numExtSems = val @staticmethod def from_buffer(buffer): """Create an ExternalSemaphoreSignalNodeParams instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaExternalSemaphoreSignalNodeParams), ExternalSemaphoreSignalNodeParams) @staticmethod def from_data(data): """Create an ExternalSemaphoreSignalNodeParams instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `external_semaphore_signal_node_params_dtype` holding the data. """ return _cyb_from_data(data, "external_semaphore_signal_node_params_dtype", external_semaphore_signal_node_params_dtype, ExternalSemaphoreSignalNodeParams) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an ExternalSemaphoreSignalNodeParams instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef ExternalSemaphoreSignalNodeParams obj = ExternalSemaphoreSignalNodeParams.__new__(ExternalSemaphoreSignalNodeParams) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudaExternalSemaphoreSignalNodeParams)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get_external_semaphore_signal_node_params_v2_dtype_offsets(): cdef cudaExternalSemaphoreSignalNodeParamsV2 *pod = _cyb_calloc(1, sizeof(cudaExternalSemaphoreSignalNodeParamsV2)) if pod == NULL: raise MemoryError("Error allocating cudaExternalSemaphoreSignalNodeParamsV2") try: return _numpy.dtype({ 'names': ['ext_sem_array', 'params_array', 'num_ext_sems', 'ctx'], 'formats': [_numpy.intp, _numpy.intp, _numpy.uint32, _numpy.intp], 'offsets': [ (&(pod.extSemArray)) - (pod), (&(pod.paramsArray)) - (pod), (&(pod.numExtSems)) - (pod), (&(pod.ctx)) - (pod), ], 'itemsize': sizeof(cudaExternalSemaphoreSignalNodeParamsV2), }) finally: _cyb_free(pod) external_semaphore_signal_node_params_v2_dtype = _get_external_semaphore_signal_node_params_v2_dtype_offsets() cdef class ExternalSemaphoreSignalNodeParamsV2: """Empty-initialize an instance of `cudaExternalSemaphoreSignalNodeParamsV2`. .. seealso:: `cudaExternalSemaphoreSignalNodeParamsV2` """ cdef: cudaExternalSemaphoreSignalNodeParamsV2 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cudaExternalSemaphoreSignalNodeParamsV2)) if self._ptr == NULL: raise MemoryError("Error allocating ExternalSemaphoreSignalNodeParamsV2") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cudaExternalSemaphoreSignalNodeParamsV2 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.ExternalSemaphoreSignalNodeParamsV2 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef ExternalSemaphoreSignalNodeParamsV2 other_ if not isinstance(other, ExternalSemaphoreSignalNodeParamsV2): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaExternalSemaphoreSignalNodeParamsV2)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaExternalSemaphoreSignalNodeParamsV2), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This ExternalSemaphoreSignalNodeParamsV2 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaExternalSemaphoreSignalNodeParamsV2): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaExternalSemaphoreSignalNodeParamsV2), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cudaExternalSemaphoreSignalNodeParamsV2)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def ext_sem_array(self): """int: Array of external semaphore handles.""" return (self._ptr[0].extSemArray) @ext_sem_array.setter def ext_sem_array(self, val): if self._readonly: raise ValueError("This ExternalSemaphoreSignalNodeParamsV2 instance is read-only") self._ptr[0].extSemArray = val @property def params_array(self): """int: Array of external semaphore signal parameters.""" return (self._ptr[0].paramsArray) @params_array.setter def params_array(self, val): if self._readonly: raise ValueError("This ExternalSemaphoreSignalNodeParamsV2 instance is read-only") self._ptr[0].paramsArray = val @property def num_ext_sems(self): """int: Number of handles and parameters supplied in extSemArray and paramsArray.""" return self._ptr[0].numExtSems @num_ext_sems.setter def num_ext_sems(self, val): if self._readonly: raise ValueError("This ExternalSemaphoreSignalNodeParamsV2 instance is read-only") self._ptr[0].numExtSems = val @property def ctx(self): """int: CUDA Execution Context""" return (self._ptr[0].ctx) @ctx.setter def ctx(self, val): if self._readonly: raise ValueError("This ExternalSemaphoreSignalNodeParamsV2 instance is read-only") self._ptr[0].ctx = val @staticmethod def from_buffer(buffer): """Create an ExternalSemaphoreSignalNodeParamsV2 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaExternalSemaphoreSignalNodeParamsV2), ExternalSemaphoreSignalNodeParamsV2) @staticmethod def from_data(data): """Create an ExternalSemaphoreSignalNodeParamsV2 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `external_semaphore_signal_node_params_v2_dtype` holding the data. """ return _cyb_from_data(data, "external_semaphore_signal_node_params_v2_dtype", external_semaphore_signal_node_params_v2_dtype, ExternalSemaphoreSignalNodeParamsV2) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an ExternalSemaphoreSignalNodeParamsV2 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef ExternalSemaphoreSignalNodeParamsV2 obj = ExternalSemaphoreSignalNodeParamsV2.__new__(ExternalSemaphoreSignalNodeParamsV2) if owner is None: obj._ptr = _cyb_malloc(sizeof(cudaExternalSemaphoreSignalNodeParamsV2)) if obj._ptr == NULL: raise MemoryError("Error allocating ExternalSemaphoreSignalNodeParamsV2") _cyb_memcpy((obj._ptr), ptr, sizeof(cudaExternalSemaphoreSignalNodeParamsV2)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_external_semaphore_wait_node_params_dtype_offsets(): cdef cudaExternalSemaphoreWaitNodeParams *pod = _cyb_calloc(1, sizeof(cudaExternalSemaphoreWaitNodeParams)) if pod == NULL: raise MemoryError("Error allocating cudaExternalSemaphoreWaitNodeParams") try: return _numpy.dtype({ 'names': ['ext_sem_array', 'params_array', 'num_ext_sems'], 'formats': [_numpy.intp, _numpy.intp, _numpy.uint32], 'offsets': [ (&(pod.extSemArray)) - (pod), (&(pod.paramsArray)) - (pod), (&(pod.numExtSems)) - (pod), ], 'itemsize': sizeof(cudaExternalSemaphoreWaitNodeParams), }) finally: _cyb_free(pod) external_semaphore_wait_node_params_dtype = _get_external_semaphore_wait_node_params_dtype_offsets() cdef class ExternalSemaphoreWaitNodeParams: """Empty-initialize an instance of `cudaExternalSemaphoreWaitNodeParams`. .. seealso:: `cudaExternalSemaphoreWaitNodeParams` """ cdef: cudaExternalSemaphoreWaitNodeParams _data cudaExternalSemaphoreWaitNodeParams *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.ExternalSemaphoreWaitNodeParams object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef ExternalSemaphoreWaitNodeParams other_ if not isinstance(other, ExternalSemaphoreWaitNodeParams): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaExternalSemaphoreWaitNodeParams)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaExternalSemaphoreWaitNodeParams), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This ExternalSemaphoreWaitNodeParams instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaExternalSemaphoreWaitNodeParams): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaExternalSemaphoreWaitNodeParams), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudaExternalSemaphoreWaitNodeParams)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def ext_sem_array(self): """int: Array of external semaphore handles.""" return (self._ptr[0].extSemArray) @ext_sem_array.setter def ext_sem_array(self, val): if self._readonly: raise ValueError("This ExternalSemaphoreWaitNodeParams instance is read-only") self._ptr[0].extSemArray = val @property def params_array(self): """int: Array of external semaphore wait parameters.""" return (self._ptr[0].paramsArray) @params_array.setter def params_array(self, val): if self._readonly: raise ValueError("This ExternalSemaphoreWaitNodeParams instance is read-only") self._ptr[0].paramsArray = val @property def num_ext_sems(self): """int: Number of handles and parameters supplied in extSemArray and paramsArray.""" return self._ptr[0].numExtSems @num_ext_sems.setter def num_ext_sems(self, val): if self._readonly: raise ValueError("This ExternalSemaphoreWaitNodeParams instance is read-only") self._ptr[0].numExtSems = val @staticmethod def from_buffer(buffer): """Create an ExternalSemaphoreWaitNodeParams instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaExternalSemaphoreWaitNodeParams), ExternalSemaphoreWaitNodeParams) @staticmethod def from_data(data): """Create an ExternalSemaphoreWaitNodeParams instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `external_semaphore_wait_node_params_dtype` holding the data. """ return _cyb_from_data(data, "external_semaphore_wait_node_params_dtype", external_semaphore_wait_node_params_dtype, ExternalSemaphoreWaitNodeParams) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an ExternalSemaphoreWaitNodeParams instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef ExternalSemaphoreWaitNodeParams obj = ExternalSemaphoreWaitNodeParams.__new__(ExternalSemaphoreWaitNodeParams) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudaExternalSemaphoreWaitNodeParams)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get_external_semaphore_wait_node_params_v2_dtype_offsets(): cdef cudaExternalSemaphoreWaitNodeParamsV2 *pod = _cyb_calloc(1, sizeof(cudaExternalSemaphoreWaitNodeParamsV2)) if pod == NULL: raise MemoryError("Error allocating cudaExternalSemaphoreWaitNodeParamsV2") try: return _numpy.dtype({ 'names': ['ext_sem_array', 'params_array', 'num_ext_sems', 'ctx'], 'formats': [_numpy.intp, _numpy.intp, _numpy.uint32, _numpy.intp], 'offsets': [ (&(pod.extSemArray)) - (pod), (&(pod.paramsArray)) - (pod), (&(pod.numExtSems)) - (pod), (&(pod.ctx)) - (pod), ], 'itemsize': sizeof(cudaExternalSemaphoreWaitNodeParamsV2), }) finally: _cyb_free(pod) external_semaphore_wait_node_params_v2_dtype = _get_external_semaphore_wait_node_params_v2_dtype_offsets() cdef class ExternalSemaphoreWaitNodeParamsV2: """Empty-initialize an instance of `cudaExternalSemaphoreWaitNodeParamsV2`. .. seealso:: `cudaExternalSemaphoreWaitNodeParamsV2` """ cdef: cudaExternalSemaphoreWaitNodeParamsV2 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cudaExternalSemaphoreWaitNodeParamsV2)) if self._ptr == NULL: raise MemoryError("Error allocating ExternalSemaphoreWaitNodeParamsV2") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cudaExternalSemaphoreWaitNodeParamsV2 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.ExternalSemaphoreWaitNodeParamsV2 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef ExternalSemaphoreWaitNodeParamsV2 other_ if not isinstance(other, ExternalSemaphoreWaitNodeParamsV2): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaExternalSemaphoreWaitNodeParamsV2)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaExternalSemaphoreWaitNodeParamsV2), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This ExternalSemaphoreWaitNodeParamsV2 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaExternalSemaphoreWaitNodeParamsV2): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaExternalSemaphoreWaitNodeParamsV2), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cudaExternalSemaphoreWaitNodeParamsV2)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def ext_sem_array(self): """int: Array of external semaphore handles.""" return (self._ptr[0].extSemArray) @ext_sem_array.setter def ext_sem_array(self, val): if self._readonly: raise ValueError("This ExternalSemaphoreWaitNodeParamsV2 instance is read-only") self._ptr[0].extSemArray = val @property def params_array(self): """int: Array of external semaphore wait parameters.""" return (self._ptr[0].paramsArray) @params_array.setter def params_array(self, val): if self._readonly: raise ValueError("This ExternalSemaphoreWaitNodeParamsV2 instance is read-only") self._ptr[0].paramsArray = val @property def num_ext_sems(self): """int: Number of handles and parameters supplied in extSemArray and paramsArray.""" return self._ptr[0].numExtSems @num_ext_sems.setter def num_ext_sems(self, val): if self._readonly: raise ValueError("This ExternalSemaphoreWaitNodeParamsV2 instance is read-only") self._ptr[0].numExtSems = val @property def ctx(self): """int: CUDA Execution Context""" return (self._ptr[0].ctx) @ctx.setter def ctx(self, val): if self._readonly: raise ValueError("This ExternalSemaphoreWaitNodeParamsV2 instance is read-only") self._ptr[0].ctx = val @staticmethod def from_buffer(buffer): """Create an ExternalSemaphoreWaitNodeParamsV2 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaExternalSemaphoreWaitNodeParamsV2), ExternalSemaphoreWaitNodeParamsV2) @staticmethod def from_data(data): """Create an ExternalSemaphoreWaitNodeParamsV2 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `external_semaphore_wait_node_params_v2_dtype` holding the data. """ return _cyb_from_data(data, "external_semaphore_wait_node_params_v2_dtype", external_semaphore_wait_node_params_v2_dtype, ExternalSemaphoreWaitNodeParamsV2) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an ExternalSemaphoreWaitNodeParamsV2 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef ExternalSemaphoreWaitNodeParamsV2 obj = ExternalSemaphoreWaitNodeParamsV2.__new__(ExternalSemaphoreWaitNodeParamsV2) if owner is None: obj._ptr = _cyb_malloc(sizeof(cudaExternalSemaphoreWaitNodeParamsV2)) if obj._ptr == NULL: raise MemoryError("Error allocating ExternalSemaphoreWaitNodeParamsV2") _cyb_memcpy((obj._ptr), ptr, sizeof(cudaExternalSemaphoreWaitNodeParamsV2)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_mem_alloc_node_params_dtype_offsets(): cdef cudaMemAllocNodeParams *pod = _cyb_calloc(1, sizeof(cudaMemAllocNodeParams)) if pod == NULL: raise MemoryError("Error allocating cudaMemAllocNodeParams") try: return _numpy.dtype({ 'names': ['pool_props', 'access_descs', 'access_desc_count', 'bytesize', 'dptr'], 'formats': [mem_pool_props_dtype, _numpy.intp, _numpy.uint64, _numpy.uint64, _numpy.intp], 'offsets': [ (&(pod.poolProps)) - (pod), (&(pod.accessDescs)) - (pod), (&(pod.accessDescCount)) - (pod), (&(pod.bytesize)) - (pod), (&(pod.dptr)) - (pod), ], 'itemsize': sizeof(cudaMemAllocNodeParams), }) finally: _cyb_free(pod) mem_alloc_node_params_dtype = _get_mem_alloc_node_params_dtype_offsets() cdef class MemAllocNodeParams: """Empty-initialize an instance of `cudaMemAllocNodeParams`. .. seealso:: `cudaMemAllocNodeParams` """ cdef: cudaMemAllocNodeParams _data cudaMemAllocNodeParams *_ptr object _owner bint _readonly def __init__(self): self._ptr = &self._data self._owner = None self._readonly = False def __repr__(self): return f"<{__name__}.MemAllocNodeParams object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef MemAllocNodeParams other_ if not isinstance(other, MemAllocNodeParams): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaMemAllocNodeParams)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaMemAllocNodeParams), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This MemAllocNodeParams instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaMemAllocNodeParams): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaMemAllocNodeParams), view.len) ) _cyb_memmove(&self._data, view.buf, sizeof(cudaMemAllocNodeParams)) self._ptr = &self._data self._owner = None self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def pool_props(self): """MemPoolProps: in: location where the allocation should reside (specified in ::location). ::handleTypes must be cudaMemHandleTypeNone. IPC is not supported. in: array of memory access descriptors. Used to describe peer GPU access""" return MemPoolProps.from_ptr( &(self._ptr[0].poolProps), readonly=self._readonly, owner=self, ) @pool_props.setter def pool_props(self, val): if self._readonly: raise ValueError("This MemAllocNodeParams instance is read-only") cdef MemPoolProps val_ = val _cyb_memcpy(&(self._ptr[0].poolProps), (val_._get_ptr()), sizeof(cudaMemPoolProps) * 1) @property def access_descs(self): """int: in: number of memory access descriptors. Must not exceed the number of GPUs.""" return (self._ptr[0].accessDescs) @access_descs.setter def access_descs(self, val): if self._readonly: raise ValueError("This MemAllocNodeParams instance is read-only") self._ptr[0].accessDescs = val @property def access_desc_count(self): """int: in: Number of ``accessDescs``\s""" return self._ptr[0].accessDescCount @access_desc_count.setter def access_desc_count(self, val): if self._readonly: raise ValueError("This MemAllocNodeParams instance is read-only") self._ptr[0].accessDescCount = val @property def bytesize(self): """int: in: size in bytes of the requested allocation""" return self._ptr[0].bytesize @bytesize.setter def bytesize(self, val): if self._readonly: raise ValueError("This MemAllocNodeParams instance is read-only") self._ptr[0].bytesize = val @property def dptr(self): """int: out: address of the allocation returned by CUDA""" return (self._ptr[0].dptr) @dptr.setter def dptr(self, val): if self._readonly: raise ValueError("This MemAllocNodeParams instance is read-only") self._ptr[0].dptr = val @staticmethod def from_buffer(buffer): """Create an MemAllocNodeParams instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaMemAllocNodeParams), MemAllocNodeParams) @staticmethod def from_data(data): """Create an MemAllocNodeParams instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `mem_alloc_node_params_dtype` holding the data. """ return _cyb_from_data(data, "mem_alloc_node_params_dtype", mem_alloc_node_params_dtype, MemAllocNodeParams) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an MemAllocNodeParams instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef MemAllocNodeParams obj = MemAllocNodeParams.__new__(MemAllocNodeParams) if owner is None: _cyb_memcpy(&obj._data, ptr, sizeof(cudaMemAllocNodeParams)) obj._ptr = &obj._data obj._owner = None else: obj._ptr = ptr obj._owner = owner obj._readonly = readonly return obj cdef _get_mem_alloc_node_params_v2_dtype_offsets(): cdef cudaMemAllocNodeParamsV2 *pod = _cyb_calloc(1, sizeof(cudaMemAllocNodeParamsV2)) if pod == NULL: raise MemoryError("Error allocating cudaMemAllocNodeParamsV2") try: return _numpy.dtype({ 'names': ['pool_props', 'access_descs', 'access_desc_count', 'bytesize', 'dptr'], 'formats': [mem_pool_props_dtype, _numpy.intp, _numpy.uint64, _numpy.uint64, _numpy.intp], 'offsets': [ (&(pod.poolProps)) - (pod), (&(pod.accessDescs)) - (pod), (&(pod.accessDescCount)) - (pod), (&(pod.bytesize)) - (pod), (&(pod.dptr)) - (pod), ], 'itemsize': sizeof(cudaMemAllocNodeParamsV2), }) finally: _cyb_free(pod) mem_alloc_node_params_v2_dtype = _get_mem_alloc_node_params_v2_dtype_offsets() cdef class MemAllocNodeParamsV2: """Empty-initialize an instance of `cudaMemAllocNodeParamsV2`. .. seealso:: `cudaMemAllocNodeParamsV2` """ cdef: cudaMemAllocNodeParamsV2 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cudaMemAllocNodeParamsV2)) if self._ptr == NULL: raise MemoryError("Error allocating MemAllocNodeParamsV2") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cudaMemAllocNodeParamsV2 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.MemAllocNodeParamsV2 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef MemAllocNodeParamsV2 other_ if not isinstance(other, MemAllocNodeParamsV2): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaMemAllocNodeParamsV2)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaMemAllocNodeParamsV2), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This MemAllocNodeParamsV2 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaMemAllocNodeParamsV2): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaMemAllocNodeParamsV2), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cudaMemAllocNodeParamsV2)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def pool_props(self): """MemPoolProps: in: location where the allocation should reside (specified in ::location). ::handleTypes must be cudaMemHandleTypeNone. IPC is not supported. in: array of memory access descriptors. Used to describe peer GPU access""" return MemPoolProps.from_ptr( &(self._ptr[0].poolProps), readonly=self._readonly, owner=self, ) @pool_props.setter def pool_props(self, val): if self._readonly: raise ValueError("This MemAllocNodeParamsV2 instance is read-only") cdef MemPoolProps val_ = val _cyb_memcpy(&(self._ptr[0].poolProps), (val_._get_ptr()), sizeof(cudaMemPoolProps) * 1) @property def access_descs(self): """int: in: number of memory access descriptors. Must not exceed the number of GPUs.""" return (self._ptr[0].accessDescs) @access_descs.setter def access_descs(self, val): if self._readonly: raise ValueError("This MemAllocNodeParamsV2 instance is read-only") self._ptr[0].accessDescs = val @property def access_desc_count(self): """int: in: Number of ``accessDescs``\s""" return self._ptr[0].accessDescCount @access_desc_count.setter def access_desc_count(self, val): if self._readonly: raise ValueError("This MemAllocNodeParamsV2 instance is read-only") self._ptr[0].accessDescCount = val @property def bytesize(self): """int: in: size in bytes of the requested allocation""" return self._ptr[0].bytesize @bytesize.setter def bytesize(self, val): if self._readonly: raise ValueError("This MemAllocNodeParamsV2 instance is read-only") self._ptr[0].bytesize = val @property def dptr(self): """int: out: address of the allocation returned by CUDA""" return (self._ptr[0].dptr) @dptr.setter def dptr(self, val): if self._readonly: raise ValueError("This MemAllocNodeParamsV2 instance is read-only") self._ptr[0].dptr = val @staticmethod def from_buffer(buffer): """Create an MemAllocNodeParamsV2 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaMemAllocNodeParamsV2), MemAllocNodeParamsV2) @staticmethod def from_data(data): """Create an MemAllocNodeParamsV2 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `mem_alloc_node_params_v2_dtype` holding the data. """ return _cyb_from_data(data, "mem_alloc_node_params_v2_dtype", mem_alloc_node_params_v2_dtype, MemAllocNodeParamsV2) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an MemAllocNodeParamsV2 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef MemAllocNodeParamsV2 obj = MemAllocNodeParamsV2.__new__(MemAllocNodeParamsV2) if owner is None: obj._ptr = _cyb_malloc(sizeof(cudaMemAllocNodeParamsV2)) if obj._ptr == NULL: raise MemoryError("Error allocating MemAllocNodeParamsV2") _cyb_memcpy((obj._ptr), ptr, sizeof(cudaMemAllocNodeParamsV2)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_mem_cpy_batch_node_params_dtype_offsets(): cdef cudaMemcpyBatchNodeParams *pod = _cyb_calloc(1, sizeof(cudaMemcpyBatchNodeParams)) if pod == NULL: raise MemoryError("Error allocating cudaMemcpyBatchNodeParams") try: return _numpy.dtype({ 'names': ['count', 'dsts', 'srcs', 'sizes', 'attrs', 'attrs_idxs', 'num_attrs', 'ctx'], 'formats': [_numpy.uint64, _numpy.intp, _numpy.intp, _numpy.intp, _numpy.intp, _numpy.intp, _numpy.uint64, _numpy.intp], 'offsets': [ (&(pod.count)) - (pod), (&(pod.dsts)) - (pod), (&(pod.srcs)) - (pod), (&(pod.sizes)) - (pod), (&(pod.attrs)) - (pod), (&(pod.attrsIdxs)) - (pod), (&(pod.numAttrs)) - (pod), (&(pod.ctx)) - (pod), ], 'itemsize': sizeof(cudaMemcpyBatchNodeParams), }) finally: _cyb_free(pod) mem_cpy_batch_node_params_dtype = _get_mem_cpy_batch_node_params_dtype_offsets() cdef class MemCpyBatchNodeParams: """Empty-initialize an instance of `cudaMemcpyBatchNodeParams`. .. seealso:: `cudaMemcpyBatchNodeParams` """ cdef: cudaMemcpyBatchNodeParams *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cudaMemcpyBatchNodeParams)) if self._ptr == NULL: raise MemoryError("Error allocating MemCpyBatchNodeParams") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cudaMemcpyBatchNodeParams *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.MemCpyBatchNodeParams object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef MemCpyBatchNodeParams other_ if not isinstance(other, MemCpyBatchNodeParams): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaMemcpyBatchNodeParams)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaMemcpyBatchNodeParams), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This MemCpyBatchNodeParams instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaMemcpyBatchNodeParams): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaMemcpyBatchNodeParams), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cudaMemcpyBatchNodeParams)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def count(self): """int: Size of ``dsts``, ``srcs`` and ``sizes`` arrays. This field cannot be updated in an instantiated graph.""" return self._ptr[0].count @count.setter def count(self, val): if self._readonly: raise ValueError("This MemCpyBatchNodeParams instance is read-only") self._ptr[0].count = val @property def dsts(self): """int: Array of destination pointers. This field can be updated in an instantiated graph.""" return (self._ptr[0].dsts) @dsts.setter def dsts(self, val): if self._readonly: raise ValueError("This MemCpyBatchNodeParams instance is read-only") self._ptr[0].dsts = val @property def srcs(self): """int: Array of source pointers. This field can be updated in an instantiated graph.""" return (self._ptr[0].srcs) @srcs.setter def srcs(self, val): if self._readonly: raise ValueError("This MemCpyBatchNodeParams instance is read-only") self._ptr[0].srcs = val @property def sizes(self): """int: Array of sizes for memcpy operations. This field can be updated in an instantiated graph. A size of 0 disables the individual copy operation.""" return (self._ptr[0].sizes) @sizes.setter def sizes(self, val): if self._readonly: raise ValueError("This MemCpyBatchNodeParams instance is read-only") self._ptr[0].sizes = val @property def attrs(self): """int: Array of memcpy attributes. This field cannot be updated in an instantiated graph.""" return (self._ptr[0].attrs) @attrs.setter def attrs(self, val): if self._readonly: raise ValueError("This MemCpyBatchNodeParams instance is read-only") self._ptr[0].attrs = val @property def attrs_idxs(self): """int: Array of indices specifying which copies each entry in ``attrs`` applies to. The array contents cannot be updated in an instantiated graph.""" return (self._ptr[0].attrsIdxs) @attrs_idxs.setter def attrs_idxs(self, val): if self._readonly: raise ValueError("This MemCpyBatchNodeParams instance is read-only") self._ptr[0].attrsIdxs = val @property def num_attrs(self): """int: Size of ``attrs`` and ``attrsIdxs`` arrays. The array contents cannot be updated in an instantiated graph.""" return self._ptr[0].numAttrs @num_attrs.setter def num_attrs(self, val): if self._readonly: raise ValueError("This MemCpyBatchNodeParams instance is read-only") self._ptr[0].numAttrs = val @property def ctx(self): """int: Preferred CUDA Execution Context to use for the copies. This field cannot be updated in an instantiated graph.""" return (self._ptr[0].ctx) @ctx.setter def ctx(self, val): if self._readonly: raise ValueError("This MemCpyBatchNodeParams instance is read-only") self._ptr[0].ctx = val @staticmethod def from_buffer(buffer): """Create an MemCpyBatchNodeParams instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaMemcpyBatchNodeParams), MemCpyBatchNodeParams) @staticmethod def from_data(data): """Create an MemCpyBatchNodeParams instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `mem_cpy_batch_node_params_dtype` holding the data. """ return _cyb_from_data(data, "mem_cpy_batch_node_params_dtype", mem_cpy_batch_node_params_dtype, MemCpyBatchNodeParams) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an MemCpyBatchNodeParams instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef MemCpyBatchNodeParams obj = MemCpyBatchNodeParams.__new__(MemCpyBatchNodeParams) if owner is None: obj._ptr = _cyb_malloc(sizeof(cudaMemcpyBatchNodeParams)) if obj._ptr == NULL: raise MemoryError("Error allocating MemCpyBatchNodeParams") _cyb_memcpy((obj._ptr), ptr, sizeof(cudaMemcpyBatchNodeParams)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get__py_anon_pod10_dtype_offsets(): cdef cuda_bindings_runtime__anon_pod10 *pod = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod10)) if pod == NULL: raise MemoryError("Error allocating cuda_bindings_runtime__anon_pod10") try: return _numpy.dtype({ 'names': ['ptr_', 'array'], 'formats': [_py_anon_pod11_dtype, _py_anon_pod12_dtype], 'offsets': [ (&(pod.ptr)) - (pod), (&(pod.array)) - (pod), ], 'itemsize': sizeof(cuda_bindings_runtime__anon_pod10), }) finally: _cyb_free(pod) _py_anon_pod10_dtype = _get__py_anon_pod10_dtype_offsets() cdef class _py_anon_pod10: """Empty-initialize an instance of `cuda_bindings_runtime__anon_pod10`. .. seealso:: `cuda_bindings_runtime__anon_pod10` """ cdef: cuda_bindings_runtime__anon_pod10 *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cuda_bindings_runtime__anon_pod10)) if self._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod10") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cuda_bindings_runtime__anon_pod10 *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}._py_anon_pod10 object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef _py_anon_pod10 other_ if not isinstance(other, _py_anon_pod10): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cuda_bindings_runtime__anon_pod10)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cuda_bindings_runtime__anon_pod10), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This _py_anon_pod10 instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cuda_bindings_runtime__anon_pod10): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cuda_bindings_runtime__anon_pod10), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cuda_bindings_runtime__anon_pod10)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def ptr_(self): """_py_anon_pod11: """ return _py_anon_pod11.from_ptr( &(self._ptr[0].ptr), readonly=self._readonly, owner=self, ) @ptr_.setter def ptr_(self, val): if self._readonly: raise ValueError("This _py_anon_pod10 instance is read-only") cdef _py_anon_pod11 val_ = val _cyb_memcpy(&(self._ptr[0].ptr), (val_._get_ptr()), sizeof(cuda_bindings_runtime__anon_pod11) * 1) @property def array(self): """_py_anon_pod12: """ return _py_anon_pod12.from_ptr( &(self._ptr[0].array), readonly=self._readonly, owner=self, ) @array.setter def array(self, val): if self._readonly: raise ValueError("This _py_anon_pod10 instance is read-only") cdef _py_anon_pod12 val_ = val _cyb_memcpy(&(self._ptr[0].array), (val_._get_ptr()), sizeof(cuda_bindings_runtime__anon_pod12) * 1) @staticmethod def from_buffer(buffer): """Create an _py_anon_pod10 instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cuda_bindings_runtime__anon_pod10), _py_anon_pod10) @staticmethod def from_data(data): """Create an _py_anon_pod10 instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `_py_anon_pod10_dtype` holding the data. """ return _cyb_from_data(data, "_py_anon_pod10_dtype", _py_anon_pod10_dtype, _py_anon_pod10) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an _py_anon_pod10 instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef _py_anon_pod10 obj = _py_anon_pod10.__new__(_py_anon_pod10) if owner is None: obj._ptr = _cyb_malloc(sizeof(cuda_bindings_runtime__anon_pod10)) if obj._ptr == NULL: raise MemoryError("Error allocating _py_anon_pod10") _cyb_memcpy((obj._ptr), ptr, sizeof(cuda_bindings_runtime__anon_pod10)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_mem_cpy3d_operand_dtype_offsets(): cdef cudaMemcpy3DOperand *pod = _cyb_calloc(1, sizeof(cudaMemcpy3DOperand)) if pod == NULL: raise MemoryError("Error allocating cudaMemcpy3DOperand") try: return _numpy.dtype({ 'names': ['type', 'op'], 'formats': [_numpy.int32, _py_anon_pod10_dtype], 'offsets': [ (&(pod.type)) - (pod), (&(pod.op)) - (pod), ], 'itemsize': sizeof(cudaMemcpy3DOperand), }) finally: _cyb_free(pod) mem_cpy3d_operand_dtype = _get_mem_cpy3d_operand_dtype_offsets() cdef class MemCpy3dOperand: """Empty-initialize an instance of `cudaMemcpy3DOperand`. .. seealso:: `cudaMemcpy3DOperand` """ cdef: cudaMemcpy3DOperand *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cudaMemcpy3DOperand)) if self._ptr == NULL: raise MemoryError("Error allocating MemCpy3dOperand") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cudaMemcpy3DOperand *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.MemCpy3dOperand object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef MemCpy3dOperand other_ if not isinstance(other, MemCpy3dOperand): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaMemcpy3DOperand)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaMemcpy3DOperand), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This MemCpy3dOperand instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaMemcpy3DOperand): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaMemcpy3DOperand), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cudaMemcpy3DOperand)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def op(self): """_py_anon_pod10: """ return _py_anon_pod10.from_ptr( &(self._ptr[0].op), readonly=self._readonly, owner=self, ) @op.setter def op(self, val): if self._readonly: raise ValueError("This MemCpy3dOperand instance is read-only") cdef _py_anon_pod10 val_ = val _cyb_memcpy(&(self._ptr[0].op), (val_._get_ptr()), sizeof(cuda_bindings_runtime__anon_pod10) * 1) @property def type(self): """int: """ return (self._ptr[0].type) @type.setter def type(self, val): if self._readonly: raise ValueError("This MemCpy3dOperand instance is read-only") self._ptr[0].type = val @staticmethod def from_buffer(buffer): """Create an MemCpy3dOperand instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaMemcpy3DOperand), MemCpy3dOperand) @staticmethod def from_data(data): """Create an MemCpy3dOperand instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `mem_cpy3d_operand_dtype` holding the data. """ return _cyb_from_data(data, "mem_cpy3d_operand_dtype", mem_cpy3d_operand_dtype, MemCpy3dOperand) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an MemCpy3dOperand instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef MemCpy3dOperand obj = MemCpy3dOperand.__new__(MemCpy3dOperand) if owner is None: obj._ptr = _cyb_malloc(sizeof(cudaMemcpy3DOperand)) if obj._ptr == NULL: raise MemoryError("Error allocating MemCpy3dOperand") _cyb_memcpy((obj._ptr), ptr, sizeof(cudaMemcpy3DOperand)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_graph_node_params_dtype_offsets(): cdef cudaGraphNodeParams *pod = _cyb_calloc(1, sizeof(cudaGraphNodeParams)) if pod == NULL: raise MemoryError("Error allocating cudaGraphNodeParams") try: return _numpy.dtype({ 'names': ['type', 'reserved0', 'reserved1', 'kernel', 'memcpy', 'memset', 'host', 'graph', 'event_wait', 'event_record', 'ext_sem_signal', 'ext_sem_wait', 'alloc', 'free', 'conditional', 'memcpy_batch', 'reserved2'], 'formats': [_numpy.int32, (_numpy.int32, 3), (_numpy.int64, 29), kernel_node_params_v2_dtype, mem_cpy_node_params_dtype, memset_params_v2_dtype, host_node_params_v2_dtype, child_graph_node_params_dtype, event_wait_node_params_dtype, event_record_node_params_dtype, external_semaphore_signal_node_params_v2_dtype, external_semaphore_wait_node_params_v2_dtype, mem_alloc_node_params_v2_dtype, mem_free_node_params_dtype, conditional_node_params_dtype, mem_cpy_batch_node_params_dtype, _numpy.int64], 'offsets': [ (&(pod.type)) - (pod), (&(pod.reserved0)) - (pod), (&(pod.reserved1)) - (pod), (&(pod.kernel)) - (pod), (&(pod.memcpy)) - (pod), (&(pod.memset)) - (pod), (&(pod.host)) - (pod), (&(pod.graph)) - (pod), (&(pod.eventWait)) - (pod), (&(pod.eventRecord)) - (pod), (&(pod.extSemSignal)) - (pod), (&(pod.extSemWait)) - (pod), (&(pod.alloc)) - (pod), (&(pod.free)) - (pod), (&(pod.conditional)) - (pod), (&(pod.memcpyBatch)) - (pod), (&(pod.reserved2)) - (pod), ], 'itemsize': sizeof(cudaGraphNodeParams), }) finally: _cyb_free(pod) graph_node_params_dtype = _get_graph_node_params_dtype_offsets() cdef class GraphNodeParams: """Empty-initialize an instance of `cudaGraphNodeParams`. .. seealso:: `cudaGraphNodeParams` """ cdef: cudaGraphNodeParams *_ptr object _owner bint _owns_ptr bint _readonly def __init__(self): self._ptr = _cyb_calloc(1, sizeof(cudaGraphNodeParams)) if self._ptr == NULL: raise MemoryError("Error allocating GraphNodeParams") self._owns_ptr = True self._owner = None self._readonly = False def __dealloc__(self): cdef cudaGraphNodeParams *ptr if self._owns_ptr and self._ptr != NULL: ptr = self._ptr self._ptr = NULL _cyb_free(ptr) def __repr__(self): return f"<{__name__}.GraphNodeParams object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return (self._ptr) cdef intptr_t _get_ptr(self): return (self._ptr) def __int__(self): return (self._ptr) def __eq__(self, other): cdef GraphNodeParams other_ if not isinstance(other, GraphNodeParams): return False other_ = other return (_cyb_memcmp((self._ptr), (other_._ptr), sizeof(cudaGraphNodeParams)) == 0) def __getbuffer__(self, _cyb_cpython.Py_buffer *buffer, int flags): _cyb___getbuffer(self, buffer, self._ptr, sizeof(cudaGraphNodeParams), self._readonly) def __releasebuffer__(self, Py_buffer *buffer): pass def __setitem__(self, key, val): cdef _cyb_Py_buffer view if key == 0: if self._readonly: raise ValueError("This GraphNodeParams instance is read-only") _cyb_PyObject_GetBuffer(val, &view, _cyb_PyBUF_SIMPLE) try: if view.len < sizeof(cudaGraphNodeParams): raise ValueError( "source buffer too small: expected at least %d bytes, got %d" % (sizeof(cudaGraphNodeParams), view.len) ) _cyb_memmove(self._ptr, view.buf, sizeof(cudaGraphNodeParams)) self._readonly = view.readonly != 0 finally: _cyb_PyBuffer_Release(&view) else: setattr(self, key, val) @property def kernel(self): """KernelNodeParamsV2: Kernel node parameters.""" return KernelNodeParamsV2.from_ptr( &(self._ptr[0].kernel), readonly=self._readonly, owner=self, ) @kernel.setter def kernel(self, val): if self._readonly: raise ValueError("This GraphNodeParams instance is read-only") cdef KernelNodeParamsV2 val_ = val _cyb_memcpy(&(self._ptr[0].kernel), (val_._get_ptr()), sizeof(cudaKernelNodeParamsV2) * 1) @property def memcpy(self): """MemCpyNodeParams: Memcpy node parameters.""" return MemCpyNodeParams.from_ptr( &(self._ptr[0].memcpy), readonly=self._readonly, owner=self, ) @memcpy.setter def memcpy(self, val): if self._readonly: raise ValueError("This GraphNodeParams instance is read-only") cdef MemCpyNodeParams val_ = val _cyb_memcpy(&(self._ptr[0].memcpy), (val_._get_ptr()), sizeof(cudaMemcpyNodeParams) * 1) @property def memset(self): """MemsetParamsV2: Memset node parameters.""" return MemsetParamsV2.from_ptr( &(self._ptr[0].memset), readonly=self._readonly, owner=self, ) @memset.setter def memset(self, val): if self._readonly: raise ValueError("This GraphNodeParams instance is read-only") cdef MemsetParamsV2 val_ = val _cyb_memcpy(&(self._ptr[0].memset), (val_._get_ptr()), sizeof(cudaMemsetParamsV2) * 1) @property def host(self): """HostNodeParamsV2: Host node parameters.""" return HostNodeParamsV2.from_ptr( &(self._ptr[0].host), readonly=self._readonly, owner=self, ) @host.setter def host(self, val): if self._readonly: raise ValueError("This GraphNodeParams instance is read-only") cdef HostNodeParamsV2 val_ = val _cyb_memcpy(&(self._ptr[0].host), (val_._get_ptr()), sizeof(cudaHostNodeParamsV2) * 1) @property def graph(self): """ChildGraphNodeParams: Child graph node parameters.""" return ChildGraphNodeParams.from_ptr( &(self._ptr[0].graph), readonly=self._readonly, owner=self, ) @graph.setter def graph(self, val): if self._readonly: raise ValueError("This GraphNodeParams instance is read-only") cdef ChildGraphNodeParams val_ = val _cyb_memcpy(&(self._ptr[0].graph), (val_._get_ptr()), sizeof(cudaChildGraphNodeParams) * 1) @property def event_wait(self): """EventWaitNodeParams: Event wait node parameters.""" return EventWaitNodeParams.from_ptr( &(self._ptr[0].eventWait), readonly=self._readonly, owner=self, ) @event_wait.setter def event_wait(self, val): if self._readonly: raise ValueError("This GraphNodeParams instance is read-only") cdef EventWaitNodeParams val_ = val _cyb_memcpy(&(self._ptr[0].eventWait), (val_._get_ptr()), sizeof(cudaEventWaitNodeParams) * 1) @property def event_record(self): """EventRecordNodeParams: Event record node parameters.""" return EventRecordNodeParams.from_ptr( &(self._ptr[0].eventRecord), readonly=self._readonly, owner=self, ) @event_record.setter def event_record(self, val): if self._readonly: raise ValueError("This GraphNodeParams instance is read-only") cdef EventRecordNodeParams val_ = val _cyb_memcpy(&(self._ptr[0].eventRecord), (val_._get_ptr()), sizeof(cudaEventRecordNodeParams) * 1) @property def ext_sem_signal(self): """ExternalSemaphoreSignalNodeParamsV2: External semaphore signal node parameters.""" return ExternalSemaphoreSignalNodeParamsV2.from_ptr( &(self._ptr[0].extSemSignal), readonly=self._readonly, owner=self, ) @ext_sem_signal.setter def ext_sem_signal(self, val): if self._readonly: raise ValueError("This GraphNodeParams instance is read-only") cdef ExternalSemaphoreSignalNodeParamsV2 val_ = val _cyb_memcpy(&(self._ptr[0].extSemSignal), (val_._get_ptr()), sizeof(cudaExternalSemaphoreSignalNodeParamsV2) * 1) @property def ext_sem_wait(self): """ExternalSemaphoreWaitNodeParamsV2: External semaphore wait node parameters.""" return ExternalSemaphoreWaitNodeParamsV2.from_ptr( &(self._ptr[0].extSemWait), readonly=self._readonly, owner=self, ) @ext_sem_wait.setter def ext_sem_wait(self, val): if self._readonly: raise ValueError("This GraphNodeParams instance is read-only") cdef ExternalSemaphoreWaitNodeParamsV2 val_ = val _cyb_memcpy(&(self._ptr[0].extSemWait), (val_._get_ptr()), sizeof(cudaExternalSemaphoreWaitNodeParamsV2) * 1) @property def alloc(self): """MemAllocNodeParamsV2: Memory allocation node parameters.""" return MemAllocNodeParamsV2.from_ptr( &(self._ptr[0].alloc), readonly=self._readonly, owner=self, ) @alloc.setter def alloc(self, val): if self._readonly: raise ValueError("This GraphNodeParams instance is read-only") cdef MemAllocNodeParamsV2 val_ = val _cyb_memcpy(&(self._ptr[0].alloc), (val_._get_ptr()), sizeof(cudaMemAllocNodeParamsV2) * 1) @property def free(self): """MemFreeNodeParams: Memory free node parameters.""" return MemFreeNodeParams.from_ptr( &(self._ptr[0].free), readonly=self._readonly, owner=self, ) @free.setter def free(self, val): if self._readonly: raise ValueError("This GraphNodeParams instance is read-only") cdef MemFreeNodeParams val_ = val _cyb_memcpy(&(self._ptr[0].free), (val_._get_ptr()), sizeof(cudaMemFreeNodeParams) * 1) @property def conditional(self): """ConditionalNodeParams: Conditional node parameters.""" return ConditionalNodeParams.from_ptr( &(self._ptr[0].conditional), readonly=self._readonly, owner=self, ) @conditional.setter def conditional(self, val): if self._readonly: raise ValueError("This GraphNodeParams instance is read-only") cdef ConditionalNodeParams val_ = val _cyb_memcpy(&(self._ptr[0].conditional), (val_._get_ptr()), sizeof(cudaConditionalNodeParams) * 1) @property def memcpy_batch(self): """MemCpyBatchNodeParams: Batch memcpy node parameters.""" return MemCpyBatchNodeParams.from_ptr( &(self._ptr[0].memcpyBatch), readonly=self._readonly, owner=self, ) @memcpy_batch.setter def memcpy_batch(self, val): if self._readonly: raise ValueError("This GraphNodeParams instance is read-only") cdef MemCpyBatchNodeParams val_ = val _cyb_memcpy(&(self._ptr[0].memcpyBatch), (val_._get_ptr()), sizeof(cudaMemcpyBatchNodeParams) * 1) @property def type(self): """int: Type of the node""" return (self._ptr[0].type) @type.setter def type(self, val): if self._readonly: raise ValueError("This GraphNodeParams instance is read-only") self._ptr[0].type = val @staticmethod def from_buffer(buffer): """Create an GraphNodeParams instance with the memory from the given buffer.""" return _cyb_from_buffer(buffer, sizeof(cudaGraphNodeParams), GraphNodeParams) @staticmethod def from_data(data): """Create an GraphNodeParams instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a single-element array of dtype `graph_node_params_dtype` holding the data. """ return _cyb_from_data(data, "graph_node_params_dtype", graph_node_params_dtype, GraphNodeParams) @staticmethod def from_ptr(intptr_t ptr, bint readonly=False, object owner=None): """Create an GraphNodeParams instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. owner (object): The Python object that owns the pointer. If not provided, data will be copied. readonly (bool): whether the data is read-only (to the user). default is `False`. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef GraphNodeParams obj = GraphNodeParams.__new__(GraphNodeParams) if owner is None: obj._ptr = _cyb_malloc(sizeof(cudaGraphNodeParams)) if obj._ptr == NULL: raise MemoryError("Error allocating GraphNodeParams") _cyb_memcpy((obj._ptr), ptr, sizeof(cudaGraphNodeParams)) obj._owns_ptr = True obj._owner = None else: obj._ptr = ptr obj._owns_ptr = False obj._owner = owner obj._readonly = readonly return obj cdef _get_mem_cpy3d_batch_op_dtype_offsets(): cdef cudaMemcpy3DBatchOp *pod = _cyb_calloc(1, sizeof(cudaMemcpy3DBatchOp)) if pod == NULL: raise MemoryError("Error allocating cudaMemcpy3DBatchOp") try: return _numpy.dtype({ 'names': ['src', 'dst', 'extent', 'src_access_order', 'flags_'], 'formats': [mem_cpy3d_operand_dtype, mem_cpy3d_operand_dtype, extent_dtype, _numpy.int32, _numpy.uint32], 'offsets': [ (&(pod.src)) - (pod), (&(pod.dst)) - (pod), (&(pod.extent)) - (pod), (&(pod.srcAccessOrder)) - (pod), (&(pod.flags)) - (pod), ], 'itemsize': sizeof(cudaMemcpy3DBatchOp), }) finally: _cyb_free(pod) mem_cpy3d_batch_op_dtype = _get_mem_cpy3d_batch_op_dtype_offsets() cdef object mem_cpy3d_batch_op_dtype_record = _numpy.dtype((_numpy.record, mem_cpy3d_batch_op_dtype)) cdef class MemCpy3dBatchOp: """Empty-initialize an array of `cudaMemcpy3DBatchOp`. The resulting object is of length `size` and of dtype `mem_cpy3d_batch_op_dtype`. If default-constructed, the instance represents a single struct. Args: size (int): number of structs, default=1. .. seealso:: `cudaMemcpy3DBatchOp` """ cdef: readonly object _data object _owner readonly tuple _src readonly tuple _dst readonly tuple _extent def __init__(self, size=1): self._data = _numpy.zeros(size, dtype=mem_cpy3d_batch_op_dtype_record) assert self._data.itemsize == sizeof(cudaMemcpy3DBatchOp), \ f"itemsize {self._data.itemsize} mismatches struct size { sizeof(cudaMemcpy3DBatchOp) }" def __repr__(self): if self._data.size > 1: return f"<{__name__}.MemCpy3dBatchOp_Array_{self._data.size} object at {hex(id(self))}>" else: return f"<{__name__}.MemCpy3dBatchOp object at {hex(id(self))}>" @property def ptr(self): """Get the pointer address to the data as Python :class:`int`.""" return _cyb_array_ptr(self._data) cdef intptr_t _get_ptr(self): return _cyb_array_ptr(self._data) def __int__(self): if self._data.size > 1 and not self._data.flags["C_CONTIGUOUS"]: raise TypeError("int() argument must be a bytes-like object of size 1, or a " "C-contiguous array. To get the pointer address of a " "non-contiguous array, use .ptr") return _cyb_array_ptr(self._data) def __len__(self): return self._data.size def __eq__(self, other): cdef object self_data = self._data if (not isinstance(other, MemCpy3dBatchOp)) or self_data.size != other._data.size or self_data.dtype != other._data.dtype: return False return bool((self_data == other._data).all()) def __getbuffer__(self, Py_buffer *buffer, int flags): _cyb_cpython.PyObject_GetBuffer(self._data, buffer, flags) def __releasebuffer__(self, Py_buffer *buffer): _cyb_cpython.PyBuffer_Release(buffer) @property def src(self): """MemCpy3dOperand: Source memcpy operand.""" if self._src is None: src_list = list() src_base = _cyb_array_ptr(self._data) src_offset = mem_cpy3d_batch_op_dtype.fields["src"][1] src_stride = self._data.strides[0] src_readonly = not self._data.flags.writeable for i in range(self._data.size): addr = src_base + i * src_stride + src_offset src_obj = MemCpy3dOperand.from_ptr(addr, owner=self._data, readonly=src_readonly) src_list.append(src_obj) self._src = tuple(src_list) if self._data.size == 1: return self._src[0] return self._src @src.setter def src(self, val): if not self._data.flags.writeable: raise ValueError("This MemCpy3dBatchOp instance is read-only") cdef MemCpy3dOperand val_ = val if self._data.size != 1: raise ValueError("Assign to the member of one element, e.g. array[i].src = value") cdef intptr_t addr = _cyb_array_ptr(self._data) + mem_cpy3d_batch_op_dtype.fields["src"][1] _cyb_memcpy(addr, (val_._get_ptr()), sizeof(cudaMemcpy3DOperand) * 1) @property def dst(self): """MemCpy3dOperand: Destination memcpy operand.""" if self._dst is None: dst_list = list() dst_base = _cyb_array_ptr(self._data) dst_offset = mem_cpy3d_batch_op_dtype.fields["dst"][1] dst_stride = self._data.strides[0] dst_readonly = not self._data.flags.writeable for i in range(self._data.size): addr = dst_base + i * dst_stride + dst_offset dst_obj = MemCpy3dOperand.from_ptr(addr, owner=self._data, readonly=dst_readonly) dst_list.append(dst_obj) self._dst = tuple(dst_list) if self._data.size == 1: return self._dst[0] return self._dst @dst.setter def dst(self, val): if not self._data.flags.writeable: raise ValueError("This MemCpy3dBatchOp instance is read-only") cdef MemCpy3dOperand val_ = val if self._data.size != 1: raise ValueError("Assign to the member of one element, e.g. array[i].dst = value") cdef intptr_t addr = _cyb_array_ptr(self._data) + mem_cpy3d_batch_op_dtype.fields["dst"][1] _cyb_memcpy(addr, (val_._get_ptr()), sizeof(cudaMemcpy3DOperand) * 1) @property def extent(self): """Extent: Extents of the memcpy between src and dst. The width, height and depth components must not be 0.""" if self._extent is None: extent_list = list() extent_base = _cyb_array_ptr(self._data) extent_offset = mem_cpy3d_batch_op_dtype.fields["extent"][1] extent_stride = self._data.strides[0] extent_readonly = not self._data.flags.writeable for i in range(self._data.size): addr = extent_base + i * extent_stride + extent_offset extent_obj = Extent.from_ptr(addr, owner=self._data, readonly=extent_readonly) extent_list.append(extent_obj) self._extent = tuple(extent_list) if self._data.size == 1: return self._extent[0] return self._extent @extent.setter def extent(self, val): if not self._data.flags.writeable: raise ValueError("This MemCpy3dBatchOp instance is read-only") cdef Extent val_ = val if self._data.size != 1: raise ValueError("Assign to the member of one element, e.g. array[i].extent = value") cdef intptr_t addr = _cyb_array_ptr(self._data) + mem_cpy3d_batch_op_dtype.fields["extent"][1] _cyb_memcpy(addr, (val_._get_ptr()), sizeof(cudaExtent) * 1) @property def src_access_order(self): """Union[~_numpy.int32, int]: Source access ordering to be observed for copy from src to dst.""" if self._data.size == 1: return int(self._data["src_access_order"][0]) return self._data["src_access_order"] @src_access_order.setter def src_access_order(self, val): if not self._data.flags.writeable: raise ValueError("This MemCpy3dBatchOp instance is read-only") self._data["src_access_order"] = val @property def flags_(self): """Union[~_numpy.uint32, int]: Additional flags for copy from src to dst. See cudaMemcpyFlags.""" if self._data.size == 1: return int(self._data["flags_"][0]) return self._data["flags_"] @flags_.setter def flags_(self, val): if not self._data.flags.writeable: raise ValueError("This MemCpy3dBatchOp instance is read-only") self._data["flags_"] = val def __getitem__(self, key): cdef ssize_t key_ cdef ssize_t size cdef MemCpy3dBatchOp obj if isinstance(key, int): key_ = key size = self._data.size if key_ >= size or key_ <= -(size+1): raise IndexError("index is out of bounds") if key_ < 0: key_ += size obj = MemCpy3dBatchOp.__new__(MemCpy3dBatchOp) obj._data = self._data[key_:key_+1] obj._owner = self._owner return obj out = self._data[key] if isinstance(out, _numpy.ndarray): if out.dtype == mem_cpy3d_batch_op_dtype: obj = MemCpy3dBatchOp.from_data(out) obj._owner = self._owner return obj if out.dtype.names is not None: return out.view(_numpy.recarray) return out def __setitem__(self, key, val): self._data[key] = val @staticmethod def from_buffer(buffer): """Create an MemCpy3dBatchOp instance with the memory from the given buffer.""" return MemCpy3dBatchOp.from_data(_numpy.frombuffer(buffer, dtype=mem_cpy3d_batch_op_dtype)) @staticmethod def from_data(data): """Create an MemCpy3dBatchOp instance wrapping the given NumPy array. Args: data (_numpy.ndarray): a 1D array of dtype `mem_cpy3d_batch_op_dtype` holding the data. """ cdef MemCpy3dBatchOp obj = MemCpy3dBatchOp.__new__(MemCpy3dBatchOp) if not isinstance(data, _numpy.ndarray): raise TypeError("data argument must be a NumPy ndarray") if data.ndim != 1: raise ValueError("data array must be 1D") if data.dtype != mem_cpy3d_batch_op_dtype: raise ValueError("data array must be of dtype mem_cpy3d_batch_op_dtype") obj._data = data.view(dtype=mem_cpy3d_batch_op_dtype_record, type=_numpy.ndarray) return obj @staticmethod def from_ptr(intptr_t ptr, size_t size=1, bint readonly=False, object owner=None): """Create an MemCpy3dBatchOp instance wrapping the given pointer. Args: ptr (intptr_t): pointer address as Python :class:`int` to the data. size (int): number of structs, default=1. readonly (bool): whether the data is read-only (to the user). default is `False`. owner (object): object that owns the memory at *ptr*. A strong reference is kept, by this wrapper and by every NumPy view of its data, so the backing storage outlives them. """ if ptr == 0: raise ValueError("ptr must not be null (0)") cdef MemCpy3dBatchOp obj = MemCpy3dBatchOp.__new__(MemCpy3dBatchOp) cdef _cyb_MemoryHolder buf = _cyb_MemoryHolder(ptr, sizeof(cudaMemcpy3DBatchOp) * size, readonly, owner) obj._data = _numpy.ndarray(size, buffer=buf, dtype=mem_cpy3d_batch_op_dtype_record) obj._owner = owner return obj ############################################################################### # Wrapper functions ############################################################################### ############################################################################### # Aliases ############################################################################### # `cudaStreamAttrID` and friends are the same types as the kernel launch attributes. StreamAttrID = LaunchAttributeID KernelNodeAttrID = LaunchAttributeID StreamAttrValue = LaunchAttributeValue KernelNodeAttrValue = LaunchAttributeValue ############################################################################### # Functions that do not return a status, or whose arguments or results the # generator cannot express, hand-written so the result is returned directly ############################################################################### cpdef int get_local_runtime_version() except? -1: """Return the version of the CUDA runtime this module was loaded against. Returns: int: The runtime version, encoded as ``1000 * major + 10 * minor``. """ cdef int version = 0 cdef cudaError_t status with nogil: status = getLocalRuntimeVersion(&version) check_status(status) return version cdef Py_ssize_t _buffer_item_count(const Py_buffer* view, size_t itemsize, str name, bint allow_raw_bytes=False) except -1: """Return the number of items in `view`, which must hold items of exactly `itemsize` bytes. The buffer is later cast to a C array of that item type, so a buffer with another item size (for example an ``int64`` array where ``int32`` values are expected) is rejected rather than being reinterpreted. With `allow_raw_bytes`, a buffer of single bytes is also accepted, as long as its length is a whole number of items (the cybind struct wrappers export their memory that way). """ if view.itemsize == itemsize: return view.len // view.itemsize if allow_raw_bytes and view.itemsize == 1 and view.len % itemsize == 0: return (view.len // itemsize) raise ValueError(f"{name} must hold items of {itemsize} bytes, got {view.itemsize}-byte items") cpdef memcpy_batch_async(object dsts, object srcs, object sizes, object attrs, object attrs_idxs, intptr_t stream): """Perform a batch of memory copies asynchronously. The batch as a whole executes in stream order but copies within a batch are not guaranteed to execute in any specific order. This API only supports pointer-to-pointer copies; for copies involving CUDA arrays use :func:`memcpy_3d_batch_async`. Every copy in the batch must be associated with a set of attributes via ``attrs``. Each entry in ``attrs`` can apply to more than one copy; the ``attrs_idxs`` array gives the index of the first copy each attribute entry applies to. The first entry in ``attrs_idxs`` must always be 0, entries must be strictly increasing, and ``len(attrs)`` must be <= ``len(dsts)``. ``dsts``, ``srcs``, and ``sizes`` must all have the same length; ``count`` is inferred from that length. ``attrs`` and ``attrs_idxs`` must both be ``None`` or both be provided with the same length; ``numAttrs`` is inferred from that length. Args: dsts: Buffer of destination pointers (e.g. numpy ``uint64`` array). srcs: Buffer of source pointers (e.g. numpy ``uint64`` array). sizes: Buffer of copy sizes in bytes (e.g. numpy ``uint64`` array). attrs: Buffer of :class:`MemCpyAttributes` values, or ``None``. attrs_idxs: Buffer of per-attribute copy indices parallel to ``attrs``, or ``None`` if ``attrs`` is ``None``. stream (intptr_t): Stream on which to perform the copies. .. seealso:: `cudaMemcpyBatchAsync` """ if (attrs is None) != (attrs_idxs is None): raise ValueError("attrs and attrs_idxs must both be None or both be provided") cdef size_t count, num_attrs = 0 cdef Py_buffer _dsts_view_, _srcs_view_, _sizes_view_ cdef Py_buffer _attrs_view_, _attrs_idxs_view_ cdef bint _attrs_acq_ = False, _attrs_idxs_acq_ = False cdef void* _attrs_ptr_ = NULL cdef void* _attrs_idxs_ptr_ = NULL cdef cudaError_t status acquire_contiguous_buffer(dsts, &_dsts_view_) try: acquire_contiguous_buffer(srcs, &_srcs_view_) try: acquire_contiguous_buffer(sizes, &_sizes_view_) try: if attrs is not None: acquire_contiguous_buffer(attrs, &_attrs_view_) _attrs_acq_ = True _attrs_ptr_ = _attrs_view_.buf if attrs_idxs is not None: acquire_contiguous_buffer(attrs_idxs, &_attrs_idxs_view_) _attrs_idxs_acq_ = True _attrs_idxs_ptr_ = _attrs_idxs_view_.buf count = _buffer_item_count(&_dsts_view_, sizeof(void*), "dsts") if ( _buffer_item_count(&_srcs_view_, sizeof(void*), "srcs") != count or _buffer_item_count(&_sizes_view_, sizeof(size_t), "sizes") != count ): raise ValueError("dsts, srcs, and sizes must hold the same number of items") if attrs is not None: num_attrs = _buffer_item_count(&_attrs_view_, sizeof(cudaMemcpyAttributes), "attrs", True) if _buffer_item_count(&_attrs_idxs_view_, sizeof(size_t), "attrs_idxs") != num_attrs: raise ValueError("attrs and attrs_idxs must hold the same number of items") with nogil: status = cudaMemcpyBatchAsync( _dsts_view_.buf, _srcs_view_.buf, _sizes_view_.buf, count, _attrs_ptr_, _attrs_idxs_ptr_, num_attrs, stream, ) check_status(status) finally: PyBuffer_Release(&_sizes_view_) if _attrs_acq_: PyBuffer_Release(&_attrs_view_) if _attrs_idxs_acq_: PyBuffer_Release(&_attrs_idxs_view_) finally: PyBuffer_Release(&_srcs_view_) finally: PyBuffer_Release(&_dsts_view_) cpdef unsigned int logs_dump_to_file(iterator, bytes path_to_file, unsigned int flags) except? 0: """Dump the runtime's error log buffer to a file. Args: iterator (int | None): Iterator from a previous call, or ``None`` to dump the whole buffer. path_to_file (bytes): Path of the output file. flags (unsigned int): Reserved, must be zero. Returns: int: The updated iterator, which can be passed to the next call to continue from there. .. seealso:: `cudaLogsDumpToFile` """ cdef cudaLogIterator it = 0 cdef cudaLogIterator* it_ptr = NULL cdef const char* c_path = path_to_file cdef cudaError_t status if iterator is not None: it = iterator it_ptr = &it with nogil: status = cudaLogsDumpToFile(it_ptr, c_path, flags) check_status(status) return it cpdef object graph_exec_update(intptr_t h_graph_exec, intptr_t h_graph): """Check whether an executable graph can be updated with a graph and perform the update if possible. Unlike most functions of this module, a failed update does not raise an exception when the cause is that the graph violates the constraints of graph update (``Error.ERROR_GRAPH_EXEC_UPDATE_FAILURE``), since the returned info says why it failed. Any other error raises. Updates the node parameters in the instantiated graph specified by ``h_graph_exec`` with the node parameters in a topologically identical graph specified by ``h_graph``. Limitations:. - Kernel nodes:. - The owning context of the function cannot change. - A node whose function originally did not use CUDA dynamic parallelism cannot be updated to a function which uses CDP. - A node whose function originally did not make device-side update calls cannot be updated to a function which makes device-side update calls. - A cooperative node cannot be updated to a non-cooperative node, and vice-versa. - If the graph was instantiated with cudaGraphInstantiateFlagUseNodePriority, the priority attribute cannot change. Equality is checked on the originally requested priority values, before they are clamped to the device's supported range. - If ``h_graph_exec`` was not instantiated for device launch, a node whose function originally did not use device-side :func:`graph_launch` cannot be updated to a function which uses device-side :func:`graph_launch` unless the node resides on the same device as nodes which contained such calls at instantiate-time. If no such calls were present at instantiation, these updates cannot be performed at all. - Neither ``h_graph`` nor ``h_graph_exec`` may contain device-updatable kernel nodes. - Memset and memcpy nodes:. - The CUDA device(s) to which the operand(s) was allocated/mapped cannot change. - The source/destination memory must be allocated from the same contexts as the original source/destination memory. - For 2d memsets, only address and assigned value may be updated. - For 1d memsets, updating dimensions is also allowed, but may fail if the resulting operation doesn't map onto the work resources already allocated for the node. - Additional memcpy node restrictions:. - Changing either the source or destination memory type(i.e. CU_MEMORYTYPE_DEVICE, CU_MEMORYTYPE_ARRAY, etc.) is not supported. - Conditional nodes:. - Changing node parameters is not supported. - Changing parameters of nodes within the conditional body graph is subject to the rules above. - Conditional handle flags and default values are updated as part of the graph update. Note: The API may add further restrictions in future releases. The return code should always be checked. cudaGraphExecUpdate sets the result member of ``result_info`` to cudaGraphExecUpdateErrorTopologyChanged under the following conditions:. - The count of nodes directly in ``h_graph_exec`` and ``h_graph`` differ, in which case result_info->errorNode is set to NULL. - ``h_graph`` has more exit nodes than ``h_graph``, in which case result_info->errorNode is set to one of the exit nodes in h_graph. - A node in ``h_graph`` has a different number of dependencies than the node from ``h_graph_exec`` it is paired with, in which case result_info->errorNode is set to the node from ``h_graph``. - A node in ``h_graph`` has a dependency that does not match with the corresponding dependency of the paired node from ``h_graph_exec``. result_info->errorNode will be set to the node from ``h_graph``. result_info->errorFromNode will be set to the mismatched dependency. The dependencies are paired based on edge order and a dependency does not match when the nodes are already paired based on other edges examined in the graph. cudaGraphExecUpdate sets ``the`` result member of ``result_info`` to:. - cudaGraphExecUpdateError if passed an invalid value. - cudaGraphExecUpdateErrorTopologyChanged if the graph topology changed. - cudaGraphExecUpdateErrorNodeTypeChanged if the type of a node changed, in which case ``hErrorNode_out`` is set to the node from ``h_graph``. - cudaGraphExecUpdateErrorFunctionChanged if the function of a kernel node changed (CUDA driver < 11.2). - cudaGraphExecUpdateErrorUnsupportedFunctionChange if the func field of a kernel changed in an unsupported way(see note above), in which case ``hErrorNode_out`` is set to the node from ``h_graph``. - cudaGraphExecUpdateErrorParametersChanged if any parameters to a node changed in a way that is not supported, in which case ``hErrorNode_out`` is set to the node from ``h_graph``. - cudaGraphExecUpdateErrorAttributesChanged if any attributes of a node changed in a way that is not supported, in which case ``hErrorNode_out`` is set to the node from ``h_graph``. - cudaGraphExecUpdateErrorNotSupported if something about a node is unsupported, like the node's type or configuration, in which case ``hErrorNode_out`` is set to the node from ``h_graph``. If the update fails for a reason not listed above, the result member of ``result_info`` will be set to cudaGraphExecUpdateError. If the update succeeds, the result member will be set to cudaGraphExecUpdateSuccess. cudaGraphExecUpdate returns cudaSuccess when the updated was performed successfully. It returns cudaErrorGraphExecUpdateFailure if the graph update was not performed because it included changes which violated constraints specific to instantiated graph update. Args: h_graph_exec (intptr_t): The instantiated graph to be updated. h_graph (intptr_t): The graph containing the updated parameters. Returns: cudaGraphExecUpdateResultInfo: the error info structure. .. seealso:: `cudaGraphExecUpdate` """ cdef GraphExecUpdateResultInfo result_info = GraphExecUpdateResultInfo() cdef cudaGraphExecUpdateResultInfo* result_info_ptr = result_info._ptr cdef cudaError_t status with nogil: status = cudaGraphExecUpdate(h_graph_exec, h_graph, result_info_ptr) if status != cudaSuccess and status != cudaErrorGraphExecUpdateFailure: check_status(status) return result_info cpdef object make_pitched_ptr(intptr_t d, size_t p, size_t xsz, size_t ysz): """Return a :class:`PitchedPtr`. Args: d (intptr_t): Pointer to allocated memory. p (size_t): Pitch of allocated memory in bytes. xsz (size_t): Logical width of allocation in elements. ysz (size_t): Logical height of allocation in elements. Returns: PitchedPtr: The pitched pointer. .. seealso:: `make_cudaPitchedPtr` """ cdef PitchedPtr result = PitchedPtr() cdef cudaPitchedPtr* result_ptr = result._get_ptr() result_ptr[0] = make_cudaPitchedPtr(d, p, xsz, ysz) return result cpdef object make_pos(size_t x, size_t y, size_t z): """Return a :class:`Pos`. Args: x (size_t): X position. y (size_t): Y position. z (size_t): Z position. Returns: Pos: The position. .. seealso:: `make_cudaPos` """ cdef Pos result = Pos() result._ptr[0] = make_cudaPos(x, y, z) return result cpdef object make_extent(size_t w, size_t h, size_t d): """Return an :class:`Extent`. Args: w (size_t): Width in elements when referring to array memory, in bytes when referring to linear memory. h (size_t): Height in elements. d (size_t): Depth in elements. Returns: Extent: The extent. .. seealso:: `make_cudaExtent` """ cdef Extent result = Extent() result._ptr[0] = make_cudaExtent(w, h, d) return result cpdef object create_channel_desc(int x, int y, int z, int w, int f): """Return a channel format descriptor. Args: x (int): X component, in bits. y (int): Y component, in bits. z (int): Z component, in bits. w (int): W component, in bits. f (int): A :class:`ChannelFormatKind` value. Returns: ChannelFormatDesc: The channel format descriptor. .. seealso:: `cudaCreateChannelDesc` """ cdef ChannelFormatDesc desc = ChannelFormatDesc() with nogil: desc._ptr[0] = cudaCreateChannelDesc(x, y, z, w, f) return desc cpdef int thread_exchange_stream_capture_mode(int mode) except? -1: """Swap the stream capture interaction mode of the calling thread. Sets the calling thread's stream capture interaction mode to ``mode`` and returns the mode it had before. Callers are encouraged to use this in a push-pop fashion: set the mode they need, and restore the returned one afterwards. Args: mode (int): The new mode, a :class:`StreamCaptureMode` value. Returns: int: The previous mode of the thread, a :class:`StreamCaptureMode` value. .. seealso:: `cudaThreadExchangeStreamCaptureMode` """ cdef cudaStreamCaptureMode c_mode = mode cdef cudaError_t status with nogil: status = cudaThreadExchangeStreamCaptureMode(&c_mode) check_status(status) return c_mode cpdef intptr_t graph_mem_free_node_get_params(intptr_t node) except? 0: """Return the device address freed by a memory free node. Args: node (intptr_t): Memory free node. Returns: int: The device address that is freed. .. seealso:: `cudaGraphMemFreeNodeGetParams` """ cdef void* dptr = NULL cdef cudaError_t status with nogil: status = cudaGraphMemFreeNodeGetParams(node, &dptr) check_status(status) return dptr cpdef intptr_t device_get_nv_sci_sync_attributes(intptr_t nv_sci_sync_attr_list, int device, int flags): """Fill in NvSciSync attributes for the given CUDA device. Args: nv_sci_sync_attr_list (intptr_t): Allocated NvSciSyncAttrList handle to fill. device (int): CUDA device ordinal. flags (int): Flags controlling which attributes are set, a combination of :class:`NvSciSyncAttr` values. Returns: intptr_t: The same ``nv_sci_sync_attr_list`` handle after being populated. .. seealso:: `cudaDeviceGetNvSciSyncAttributes` """ cdef cudaError_t status with nogil: status = cudaDeviceGetNvSciSyncAttributes(nv_sci_sync_attr_list, device, flags) check_status(status) return nv_sci_sync_attr_list cdef object _atomic_capabilities(object operations, int src_device, int dst_device, bint from_host): cdef Py_buffer view cdef unsigned int count cdef object capabilities cdef intptr_t caps_ptr cdef cudaError_t status acquire_contiguous_buffer(operations, &view) try: count = _buffer_item_count(&view, sizeof(cudaAtomicOperation), "operations") capabilities = _numpy.empty(count, dtype=_numpy.uint32) caps_ptr = capabilities.ctypes.data with nogil: if from_host: status = cudaDeviceGetHostAtomicCapabilities( caps_ptr, view.buf, count, src_device ) else: status = cudaDeviceGetP2PAtomicCapabilities( caps_ptr, view.buf, count, src_device, dst_device ) check_status(status) return capabilities finally: PyBuffer_Release(&view) cpdef object device_get_host_atomic_capabilities(object operations, int device): """Query atomic operation capabilities between host and device. Args: operations: Buffer of :class:`AtomicOperation` enum values whose capabilities should be queried (any buffer-exposing object, e.g. a numpy ``int32`` array; non-contiguous inputs are copied). device (int): Device ordinal. Returns: object: numpy ``uint32`` array of the same length as ``operations`` containing :class:`AtomicOperationCapability` flags for each operation. .. seealso:: `cudaDeviceGetHostAtomicCapabilities` """ return _atomic_capabilities(operations, device, 0, True) cpdef object device_get_p2p_atomic_capabilities(object operations, int src_device, int dst_device): """Query atomic operation capabilities between two devices. Args: operations: Buffer of :class:`AtomicOperation` enum values whose capabilities should be queried (any buffer-exposing object, e.g. a numpy ``int32`` array; non-contiguous inputs are copied). src_device (int): Source device ordinal. dst_device (int): Destination device ordinal. Returns: object: numpy ``uint32`` array of the same length as ``operations`` containing :class:`AtomicOperationCapability` flags for each operation. .. seealso:: `cudaDeviceGetP2PAtomicCapabilities` """ return _atomic_capabilities(operations, src_device, dst_device, False) cpdef object gl_get_devices(int device_list, unsigned int max_devices=64): """Gets the CUDA devices associated with the current OpenGL context. Args: device_list (int): A :class:`GLDeviceList` value: the set of devices to return. max_devices (unsigned int): The maximum number of devices to return. If more devices than this are associated with the context, :class:`ValueError` is raised rather than truncating the result. Returns: object: numpy ``int32`` array of the CUDA device ordinals associated with the current OpenGL context. .. seealso:: `cudaGLGetDevices` """ cdef unsigned int count = 0 cdef cudaError_t status cdef object result = _numpy.empty(max_devices, dtype=_numpy.intc) cdef intptr_t result_ptr = result.ctypes.data with nogil: status = cudaGLGetDevices(&count, result_ptr, max_devices, device_list) check_status(status) if count > max_devices: raise ValueError( f"{count} devices are associated with the OpenGL context, more than max_devices={max_devices}" ) return result[:count] ############################################################################### # Attribute queries whose value type depends on the attribute # # The C functions take a `void*` for the result, so they are hand-written: the # attribute selects what is read and the value is returned directly. ############################################################################### cdef enum _AttrKind: _ATTR_INT _ATTR_ULL cdef union _AttrSlot: int i unsigned long long ull cdef _AttrKind _mem_pool_attribute_kind(int attr) except *: if ( attr == cudaMemPoolAttrReleaseThreshold or attr == cudaMemPoolAttrReservedMemCurrent or attr == cudaMemPoolAttrReservedMemHigh or attr == cudaMemPoolAttrUsedMemCurrent or attr == cudaMemPoolAttrUsedMemHigh ): return _ATTR_ULL if attr == cudaMemPoolAttrMaxPoolSize: return _ATTR_ULL if ( attr == cudaMemPoolReuseFollowEventDependencies or attr == cudaMemPoolReuseAllowOpportunistic or attr == cudaMemPoolReuseAllowInternalDependencies ): return _ATTR_INT if ( attr == cudaMemPoolAttrAllocationType or attr == cudaMemPoolAttrExportHandleTypes or attr == cudaMemPoolAttrLocationId or attr == cudaMemPoolAttrLocationType or attr == cudaMemPoolAttrHwDecompressEnabled ): return _ATTR_INT if attr == cudaMemPoolAttrLocalityDomainId: return _ATTR_INT raise TypeError(f"Unsupported memory pool attribute: {attr}") cpdef object mem_pool_get_attribute(intptr_t mem_pool, int attr): """Return an attribute of a memory pool (an ``int``). Args: mem_pool (intptr_t): Memory pool handle. attr (int): A :class:`MemPoolAttr` value. Returns: int: The attribute value. .. seealso:: `cudaMemPoolGetAttribute` """ cdef _AttrKind kind = _mem_pool_attribute_kind(attr) cdef _AttrSlot slot cdef cudaError_t status _c_memset(&slot, 0, sizeof(slot)) with nogil: status = cudaMemPoolGetAttribute(mem_pool, attr, &slot) check_status(status) if kind == _ATTR_ULL: return slot.ull return slot.i cpdef mem_pool_set_attribute(intptr_t mem_pool, int attr, value): """Set an attribute of a memory pool. Args: mem_pool (intptr_t): Memory pool handle. attr (int): A :class:`MemPoolAttr` value. value (int): The value to set. It is converted to the type that the attribute has (an ``unsigned long long`` for ``RELEASE_THRESHOLD`` and the high watermarks, which can only be reset by setting them to 0; an ``int`` for the ``REUSE_*`` attributes). Raises :class:`OverflowError` if ``value`` does not fit the type of the attribute (for example a negative value for an ``unsigned long long`` attribute, or one beyond the range of an ``int``), and :class:`TypeError` if ``attr`` is not an attribute that this function supports. .. seealso:: `cudaMemPoolSetAttribute` """ cdef _AttrKind kind = _mem_pool_attribute_kind(attr) cdef _AttrSlot slot cdef cudaError_t status _c_memset(&slot, 0, sizeof(slot)) if kind == _ATTR_ULL: slot.ull = value else: slot.i = value with nogil: status = cudaMemPoolSetAttribute(mem_pool, attr, &slot) check_status(status) cdef int _check_graph_mem_attribute(int attr) except -1: if not ( attr == cudaGraphMemAttrUsedMemCurrent or attr == cudaGraphMemAttrUsedMemHigh or attr == cudaGraphMemAttrReservedMemCurrent or attr == cudaGraphMemAttrReservedMemHigh ): raise TypeError(f"Unsupported graph memory attribute: {attr}") return 0 cpdef unsigned long long device_get_graph_mem_attribute(int device, int attr) except? 0: """Return a graph memory attribute of a device, in bytes. Args: device (int): Device ordinal. attr (int): A :class:`GraphMemAttributeType` value (``USED_MEM_CURRENT``, ``USED_MEM_HIGH``, ``RESERVED_MEM_CURRENT`` or ``RESERVED_MEM_HIGH``). Returns: int: The attribute value, in bytes. .. seealso:: `cudaDeviceGetGraphMemAttribute` """ cdef unsigned long long value = 0 cdef cudaError_t status _check_graph_mem_attribute(attr) with nogil: status = cudaDeviceGetGraphMemAttribute(device, attr, &value) check_status(status) return value cpdef device_set_graph_mem_attribute(int device, int attr, unsigned long long value): """Set a graph memory attribute of a device. Args: device (int): Device ordinal. attr (int): A :class:`GraphMemAttributeType` value (``USED_MEM_HIGH`` or ``RESERVED_MEM_HIGH``; the high watermarks can only be reset, by setting them to 0). value (int): The value to set, in bytes. .. seealso:: `cudaDeviceSetGraphMemAttribute` """ cdef cudaError_t status _check_graph_mem_attribute(attr) with nogil: status = cudaDeviceSetGraphMemAttribute(device, attr, &value) check_status(status) cdef bint _mem_range_attribute_is_list(int attribute) except -1: if attribute == cudaMemRangeAttributeAccessedBy: return True if ( attribute == cudaMemRangeAttributeReadMostly or attribute == cudaMemRangeAttributePreferredLocation or attribute == cudaMemRangeAttributeLastPrefetchLocation or attribute == cudaMemRangeAttributePreferredLocationType or attribute == cudaMemRangeAttributePreferredLocationId or attribute == cudaMemRangeAttributeLastPrefetchLocationType or attribute == cudaMemRangeAttributeLastPrefetchLocationId ): return False raise TypeError(f"Unsupported memory range attribute: {attribute}") cdef object _mem_range_value_to_python(int attribute, void* buf, size_t size): cdef size_t i if _mem_range_attribute_is_list(attribute): return [(buf)[i] for i in range(size // sizeof(int))] return (buf)[0] cpdef object mem_range_get_attribute(size_t data_size, int attribute, intptr_t dev_ptr, size_t count): """Return an attribute of a memory range. Args: data_size (size_t): Size in bytes of the result; for ``ACCESSED_BY`` it sets how many devices (``data_size // 4``) are returned. attribute (int): A :class:`MemRangeAttribute` value. dev_ptr (intptr_t): Start of the memory range. count (size_t): Size of the range in bytes. Returns: int | list[int]: A list of device ordinals for ``ACCESSED_BY``, else an ``int``. .. seealso:: `cudaMemRangeGetAttribute` """ _mem_range_attribute_is_list(attribute) # validates the attribute # The scalar attributes need `data_size == 4`, which the driver validates (it rejects anything else before # writing). As in the legacy API, which reads a scalar from an internal `int`, the buffer always has room for # one, so reading the scalar below stays in bounds whatever `data_size` is. cdef size_t size = data_size if size < sizeof(int): size = sizeof(int) cdef void* buf = PyMem_Calloc(1, size) cdef cudaError_t status if buf == NULL: raise MemoryError("Failed to allocate the attribute buffer") try: with nogil: status = cudaMemRangeGetAttribute(buf, data_size, attribute, dev_ptr, count) check_status(status) return _mem_range_value_to_python(attribute, buf, data_size) finally: PyMem_Free(buf) cpdef list mem_range_get_attributes(data_sizes, attributes, intptr_t dev_ptr, size_t count): """Return several attributes of a memory range, in one call. Args: data_sizes (sequence of int): Size in bytes of each result. attributes (sequence of int): :class:`MemRangeAttribute` values. dev_ptr (intptr_t): Start of the memory range. count (size_t): Size of the range in bytes. Returns: list: One value per attribute, as for :func:`mem_range_get_attribute`. .. seealso:: `cudaMemRangeGetAttributes` """ cdef list sizes = [int(s) for s in data_sizes] cdef list attrs = [int(a) for a in attributes] cdef Py_ssize_t n = len(attrs) cdef Py_ssize_t i cdef size_t* c_sizes cdef cudaMemRangeAttribute* c_attrs cdef void** data cdef cudaError_t status cdef list out = [] if len(sizes) != n: raise ValueError("data_sizes and attributes must have the same length") if n == 0: return [] for i in range(n): _mem_range_attribute_is_list(attrs[i]) # validates the attribute c_sizes = PyMem_Calloc(n, sizeof(size_t)) c_attrs = PyMem_Calloc(n, sizeof(cudaMemRangeAttribute)) data = PyMem_Calloc(n, sizeof(void*)) try: if c_sizes == NULL or c_attrs == NULL or data == NULL: raise MemoryError("Failed to allocate the attribute buffers") for i in range(n): c_sizes[i] = sizes[i] c_attrs[i] = attrs[i] # Every result needs room for at least one int, so reading a scalar attribute stays in bounds # whatever size was given (the driver rejects a size other than 4 for those). data[i] = PyMem_Calloc(1, max(sizes[i], sizeof(int))) if data[i] == NULL: raise MemoryError("Failed to allocate the attribute buffer") with nogil: status = cudaMemRangeGetAttributes(data, c_sizes, c_attrs, n, dev_ptr, count) check_status(status) for i in range(n): out.append(_mem_range_value_to_python(attrs[i], data[i], c_sizes[i])) finally: if data != NULL: for i in range(n): PyMem_Free(data[i]) PyMem_Free(c_sizes) PyMem_Free(c_attrs) PyMem_Free(data) return out ############################################################################### # Exporting a memory pool, whose shareable handle depends on the handle type ############################################################################### cdef union _HandleSlot: int i unsigned int u void* p cudaMemFabricHandle_t mem_fabric cpdef object mem_pool_export_to_shareable_handle(intptr_t mem_pool, int handle_type, unsigned int flags): """Export a memory pool to an OS-specific shareable handle. Args: mem_pool (intptr_t): Memory pool to export. handle_type (int): A :class:`MemAllocationHandleType` value. flags (unsigned int): Reserved, must be zero. Returns: int | MemFabricHandle: A file descriptor or OS handle as an ``int`` (a :class:`MemFabricHandle` for ``FABRIC``). .. seealso:: `cudaMemPoolExportToShareableHandle` """ cdef _HandleSlot slot cdef cudaError_t status _c_memset(&slot, 0, sizeof(slot)) if ( handle_type != cudaMemHandleTypeNone and handle_type != cudaMemHandleTypePosixFileDescriptor and handle_type != cudaMemHandleTypeWin32 and handle_type != cudaMemHandleTypeWin32Kmt and handle_type != cudaMemHandleTypeFabric ): raise TypeError(f"Unsupported memory handle type: {handle_type}") with nogil: status = cudaMemPoolExportToShareableHandle(&slot, mem_pool, handle_type, flags) check_status(status) if handle_type == cudaMemHandleTypeNone or handle_type == cudaMemHandleTypePosixFileDescriptor: return slot.i if handle_type == cudaMemHandleTypeWin32: return slot.p if handle_type == cudaMemHandleTypeWin32Kmt: return slot.u return MemFabricHandle.from_ptr(&slot.mem_fabric) cpdef device_reset(): """Destroy all allocations and reset all state on the current device in the current process. Explicitly destroys and cleans up all resources associated with the current device in the current process. It is the caller's responsibility to ensure that the resources are not accessed or passed in subsequent API calls and doing so will result in undefined behavior. These resources include CUDA types ``cudaStream_t``, ``cudaEvent_t``, ``cudaArray_t``, ``cudaMipmappedArray_t``, ``cudaPitchedPtr``, ``cudaTextureObject_t``, ``cudaSurfaceObject_t``, ``textureReference``, ``surfaceReference``, ``cudaExternalMemory_t``, ``cudaExternalSemaphore_t`` and ``cudaGraphicsResource_t``. These resources also include memory allocations by ``cudaMalloc``, ``cudaMallocHost``, ``cudaMallocManaged`` and ``cudaMallocPitch``. Any subsequent API call to this device will reinitialize the device. Note that this function will reset the device immediately. It is the caller's responsibility to ensure that the device is not being accessed by any other host threads from the process when this function is called. .. note:: :func:`device_reset` will not destroy memory allocations by :func:`malloc_async` and :func:`malloc_from_pool_async`. These memory allocations need to be destroyed explicitly. .. note:: If a non-primary ``CUcontext`` is current to the thread, :func:`device_reset` will destroy only the internal CUDA RT state for that ``CUcontext``. .. seealso:: `cudaDeviceReset` """ with nogil: __status__ = cudaDeviceReset() check_status(__status__) cpdef device_synchronize(): """Wait for compute device to finish. Blocks until the device has completed all preceding requested tasks. :func:`device_synchronize` returns an error if one of the preceding tasks has failed. If the ``cudaDeviceScheduleBlockingSync`` flag was set for this device, the host thread will block until the device has finished its work. .. seealso:: `cudaDeviceSynchronize` """ with nogil: __status__ = cudaDeviceSynchronize() check_status(__status__) cpdef device_set_limit(int limit, size_t value): """Set resource limits. Setting ``limit`` to ``value`` is a request by the application to update the current limit maintained by the device. The driver is free to modify the requested value to meet h/w requirements (this could be clamping to minimum or maximum values, rounding up to nearest element size, etc). The application can use :func:`device_get_limit` to find out exactly what the limit has been set to. Setting each ``cudaLimit`` has its own specific restrictions, so each is discussed here. - ``cudaLimitStackSize`` controls the stack size in bytes of each GPU thread. - ``cudaLimitPrintfFifoSize`` controls the size in bytes of the shared FIFO used by the ``printf()`` device system call. Setting ``cudaLimitPrintfFifoSize`` must not be performed after launching any kernel that uses the ``printf()`` device system call - in such case ``cudaErrorInvalidValue`` will be returned. - ``cudaLimitMallocHeapSize`` controls the size in bytes of the heap used by the ``malloc()`` and ``free()`` device system calls. Setting ``cudaLimitMallocHeapSize`` must not be performed after launching any kernel that uses the ``malloc()`` or ``free()`` device system calls - in such case ``cudaErrorInvalidValue`` will be returned. - ``cudaLimitDevRuntimeSyncDepth`` controls the maximum nesting depth of a grid at which a thread can safely call :func:`device_synchronize`. Setting this limit must be performed before any launch of a kernel that uses the device runtime and calls :func:`device_synchronize` above the default sync depth, two levels of grids. Calls to :func:`device_synchronize` will fail with error code ``cudaErrorSyncDepthExceeded`` if the limitation is violated. This limit can be set smaller than the default or up the maximum launch depth of 24. When setting this limit, keep in mind that additional levels of sync depth require the runtime to reserve large amounts of device memory which can no longer be used for user allocations. If these reservations of device memory fail, ``cudaDeviceSetLimit`` will return ``cudaErrorMemoryAllocation``, and the limit can be reset to a lower value. This limit is only applicable to devices of compute capability < 9.0. Attempting to set this limit on devices of other compute capability will results in error ``cudaErrorUnsupportedLimit`` being returned. - ``cudaLimitDevRuntimePendingLaunchCount`` controls the maximum number of outstanding device runtime launches that can be made from the current device. A grid is outstanding from the point of launch up until the grid is known to have been completed. Device runtime launches which violate this limitation fail and return ``cudaErrorLaunchPendingCountExceeded`` when :func:`get_last_error` is called after launch. If more pending launches than the default (2048 launches) are needed for a module using the device runtime, this limit can be increased. Keep in mind that being able to sustain additional pending launches will require the runtime to reserve larger amounts of device memory upfront which can no longer be used for allocations. If these reservations fail, ``cudaDeviceSetLimit`` will return ``cudaErrorMemoryAllocation``, and the limit can be reset to a lower value. This limit is only applicable to devices of compute capability 3.5 and higher. Attempting to set this limit on devices of compute capability less than 3.5 will result in the error ``cudaErrorUnsupportedLimit`` being returned. - ``cudaLimitMaxL2FetchGranularity`` controls the L2 cache fetch granularity. Values can range from 0B to 128B. This is purely a performance hint and it can be ignored or clamped depending on the platform. - ``cudaLimitPersistingL2CacheSize`` controls size in bytes available for persisting L2 cache. This is purely a performance hint and it can be ignored or clamped depending on the platform. Args: limit (Limit): Limit to set. value (size_t): Size of limit. .. seealso:: `cudaDeviceSetLimit` """ with nogil: __status__ = cudaDeviceSetLimit(limit, value) check_status(__status__) cpdef size_t device_get_limit(int limit) except? 0: """Return resource limits. Returns in ``*p_value`` the current size of ``limit``. The following ``cudaLimit`` values are supported. - ``cudaLimitStackSize`` is the stack size in bytes of each GPU thread. - ``cudaLimitPrintfFifoSize`` is the size in bytes of the shared FIFO used by the ``printf()`` device system call. - ``cudaLimitMallocHeapSize`` is the size in bytes of the heap used by the ``malloc()`` and ``free()`` device system calls. - ``cudaLimitDevRuntimeSyncDepth`` is the maximum grid depth at which a thread can isssue the device runtime call :func:`device_synchronize` to wait on child grid launches to complete. This functionality is removed for devices of compute capability >= 9.0, and hence will return error ``cudaErrorUnsupportedLimit`` on such devices. - ``cudaLimitDevRuntimePendingLaunchCount`` is the maximum number of outstanding device runtime launches. - ``cudaLimitMaxL2FetchGranularity`` is the L2 cache fetch granularity. - ``cudaLimitPersistingL2CacheSize`` is the persisting L2 cache size in bytes. Args: limit (Limit): Limit to query. Returns: size_t: Returned size of the limit. .. seealso:: `cudaDeviceGetLimit` """ cdef size_t p_value with nogil: __status__ = cudaDeviceGetLimit(&p_value, limit) check_status(__status__) return p_value cpdef size_t device_get_texture_1d_linear_max_width(fmt_desc, int device) except? 0: """Returns the maximum number of elements allocatable in a 1D linear texture for a given element size. Returns in ``max_width_in_elements`` the maximum number of elements allocatable in a 1D linear texture for given format descriptor ``fmt_desc``. Args: fmt_desc (intptr_t): Texture format description. device (int): Device on which the texture would be allocated. Returns: size_t: Returns maximum number of texture elements allocatable for given ``fmt_desc``. .. seealso:: `cudaDeviceGetTexture1DLinearMaxWidth` """ cdef intptr_t _fmt_desc_ptr_ = 0 if fmt_desc is None else int(fmt_desc) cdef size_t max_width_in_elements with nogil: __status__ = cudaDeviceGetTexture1DLinearMaxWidth(&max_width_in_elements, _fmt_desc_ptr_, device) check_status(__status__) return max_width_in_elements cpdef int device_get_cache_config() except? -1: """Returns the preferred cache configuration for the current device. On devices where the L1 cache and shared memory use the same hardware resources, this returns through ``p_cache_config`` the preferred cache configuration for the current device. This is only a preference. The runtime will use the requested configuration if possible, but it is free to choose a different configuration if required to execute functions. This will return a ``p_cache_config`` of ``cudaFuncCachePreferNone`` on devices where the size of the L1 cache and shared memory are fixed. The supported cache configurations are:. - ``cudaFuncCachePreferNone``: no preference for shared memory or L1 (default). - ``cudaFuncCachePreferShared``: prefer larger shared memory and smaller L1 cache. - ``cudaFuncCachePreferL1``: prefer larger L1 cache and smaller shared memory. - ``cudaFuncCachePreferEqual``: prefer equal size L1 cache and shared memory. Returns: int: Returned cache configuration. .. seealso:: `cudaDeviceGetCacheConfig` """ cdef cudaFuncCache p_cache_config with nogil: __status__ = cudaDeviceGetCacheConfig(&p_cache_config) check_status(__status__) return p_cache_config cpdef tuple device_get_stream_priority_range(): """Returns numerical values that correspond to the least and greatest stream priorities. Returns in ``*least_priority`` and ``*greatest_priority`` the numerical values that correspond to the least and greatest stream priorities respectively. Stream priorities follow a convention where lower numbers imply greater priorities. The range of meaningful stream priorities is given by [``*greatest_priority``, ``*least_priority``]. If the user attempts to create a stream with a priority value that is outside the the meaningful range as specified by this API, the priority is automatically clamped down or up to either ``*least_priority`` or ``*greatest_priority`` respectively. See ``cudaStreamCreateWithPriority`` for details on creating a priority stream. A NULL may be passed in for ``*least_priority`` or ``*greatest_priority`` if the value is not desired. This function will return '0' in both ``*least_priority`` and ``*greatest_priority`` if the current context's device does not support stream priorities (see ``cudaDeviceGetAttribute``). Returns: A 2-tuple containing: - int: Pointer to an int in which the numerical value for least stream priority is returned. - int: Pointer to an int in which the numerical value for greatest stream priority is returned. .. seealso:: `cudaDeviceGetStreamPriorityRange` """ cdef int least_priority cdef int greatest_priority with nogil: __status__ = cudaDeviceGetStreamPriorityRange(&least_priority, &greatest_priority) check_status(__status__) return (least_priority, greatest_priority) cpdef device_set_cache_config(int cache_config): """Sets the preferred cache configuration for the current device. On devices where the L1 cache and shared memory use the same hardware resources, this sets through ``cache_config`` the preferred cache configuration for the current device. This is only a preference. The runtime will use the requested configuration if possible, but it is free to choose a different configuration if required to execute the function. Any function preference set via ``cudaFuncSetCacheConfig (C API)`` or cudaFuncSetCacheConfig (C++ API) will be preferred over this device-wide setting. Setting the device-wide cache configuration to ``cudaFuncCachePreferNone`` will cause subsequent kernel launches to prefer to not change the cache configuration unless required to launch the kernel. This setting does nothing on devices where the size of the L1 cache and shared memory are fixed. Launching a kernel with a different preference than the most recent preference setting may insert a device-side synchronization point. The supported cache configurations are:. - ``cudaFuncCachePreferNone``: no preference for shared memory or L1 (default). - ``cudaFuncCachePreferShared``: prefer larger shared memory and smaller L1 cache. - ``cudaFuncCachePreferL1``: prefer larger L1 cache and smaller shared memory. - ``cudaFuncCachePreferEqual``: prefer equal size L1 cache and shared memory. Args: cache_config (FuncCache): Requested cache configuration. .. seealso:: `cudaDeviceSetCacheConfig` """ with nogil: __status__ = cudaDeviceSetCacheConfig(cache_config) check_status(__status__) cpdef int device_get_by_pci_bus_id(pci_bus_id) except? -1: """Returns a handle to a compute device. Returns in ``*device`` a device ordinal given a PCI bus ID string. where ``domain``, ``bus``, ``device``, and ``function`` are all hexadecimal values. Args: pci_bus_id (bytes): String in one of the following forms:. Returns: int: Returned device ordinal. .. seealso:: `cudaDeviceGetByPCIBusId` """ cdef _cyb_BufferGuard _pci_bus_id_guard_ = _cyb_BufferGuard(pci_bus_id, 0, False, True, True) cdef void* _pci_bus_id_ = _pci_bus_id_guard_.ptr cdef int device with nogil: __status__ = cudaDeviceGetByPCIBusId(&device, _pci_bus_id_) check_status(__status__) return device cpdef bytes device_get_pci_bus_id(int len, int device): """Returns a PCI Bus Id string for the device. Returns an ASCII string identifying the device ``dev`` in the NULL-terminated string pointed to by ``pci_bus_id``. ``length`` specifies the maximum length of the string that may be returned. where ``domain``, ``bus``, ``device``, and ``function`` are all hexadecimal values. pci_bus_id should be large enough to store 13 characters including the NULL-terminator. Args: len (int): Maximum length of string to store in ``name``. device (int): Device to get identifier string for. Returns: bytes: Returned identifier string for the device in the following format. .. seealso:: `cudaDeviceGetPCIBusId` """ cdef bytes _pci_bus_id_ = bytes(len) cdef char* pci_bus_id = _pci_bus_id_ with nogil: __status__ = cudaDeviceGetPCIBusId(pci_bus_id, len, device) check_status(__status__) return _pci_bus_id_ cpdef object ipc_get_event_handle(intptr_t event): """Gets an interprocess handle for a previously allocated event. Takes as input a previously allocated event. This event must have been created with the ``cudaEventInterprocess`` and ``cudaEventDisableTiming`` flags set. This opaque handle may be copied into other processes and opened with ``cudaIpcOpenEventHandle`` to allow efficient hardware synchronization between GPU work in different processes. After the event has been been opened in the importing process, ``cudaEventRecord``, ``cudaEventSynchronize``, ``cudaStreamWaitEvent`` and ``cudaEventQuery`` may be used in either process. Performing operations on the imported event after the exported event has been freed with ``cudaEventDestroy`` will result in undefined behavior. IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users can test their device for IPC functionality by calling ``cudaDeviceGetAttribute`` with ``cudaDevAttrIpcEventSupport``. Args: event (intptr_t): Event allocated with ``cudaEventInterprocess`` and ``cudaEventDisableTiming`` flags. Returns: cudaIpcEventHandle_t: Pointer to a user allocated cudaIpcEventHandle in which to return the opaque event handle. .. seealso:: `cudaIpcGetEventHandle` """ cdef IpcEventHandle handle_py = IpcEventHandle() cdef cudaIpcEventHandle_t *handle = (handle_py._get_ptr()) with nogil: __status__ = cudaIpcGetEventHandle(handle, event) check_status(__status__) return handle_py cpdef intptr_t ipc_open_event_handle(handle) except? 0: """Opens an interprocess event handle for use in the current process. Opens an interprocess event handle exported from another process with ``cudaIpcGetEventHandle``. This function returns a ``cudaEvent_t`` that behaves like a locally created event with the ``cudaEventDisableTiming`` flag specified. This event must be freed with ``cudaEventDestroy``. Performing operations on the imported event after the exported event has been freed with ``cudaEventDestroy`` will result in undefined behavior. IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users can test their device for IPC functionality by calling ``cudaDeviceGetAttribute`` with ``cudaDevAttrIpcEventSupport``. Args: handle (cudaIpcEventHandle_t): Interprocess handle to open. Returns: intptr_t: Returns the imported event. .. seealso:: `cudaIpcOpenEventHandle` """ cdef intptr_t _handle_ptr_ = (handle)._get_ptr() cdef cudaEvent_t event with nogil: __status__ = cudaIpcOpenEventHandle(&event, (_handle_ptr_)[0]) check_status(__status__) return event cpdef object ipc_get_mem_handle(intptr_t dev_ptr): """Gets an interprocess memory handle for an existing device memory allocation. Takes a pointer to the base of an existing device memory allocation created with ``cudaMalloc`` and exports it for use in another process. This is a lightweight operation and may be called multiple times on an allocation without adverse effects. If a region of memory is freed with ``cudaFree`` and a subsequent call to ``cudaMalloc`` returns memory with the same device address, ``cudaIpcGetMemHandle`` will return a unique handle for the new memory. IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users can test their device for IPC functionality by calling ``cudaDeviceGetAttribute`` with ``cudaDevAttrIpcEventSupport``. Args: dev_ptr (intptr_t): Base pointer to previously allocated device memory. Returns: cudaIpcMemHandle_t: Pointer to user allocated ``cudaIpcMemHandle`` to return the handle in. .. seealso:: `cudaIpcGetMemHandle` """ cdef IpcMemHandle handle_py = IpcMemHandle() cdef cudaIpcMemHandle_t *handle = (handle_py._get_ptr()) with nogil: __status__ = cudaIpcGetMemHandle(handle, dev_ptr) check_status(__status__) return handle_py cpdef intptr_t ipc_open_mem_handle(handle, unsigned int flags) except? 0: """Opens an interprocess memory handle exported from another process and returns a device pointer usable in the local process. Maps memory exported from another process with ``cudaIpcGetMemHandle`` into the current device address space. For contexts on different devices ``cudaIpcOpenMemHandle`` can attempt to enable peer access between the devices as if the user called ``cudaDeviceEnablePeerAccess``. This behavior is controlled by the ``cudaIpcMemLazyEnablePeerAccess`` flag. ``cudaDeviceCanAccessPeer`` can determine if a mapping is possible. ``cudaIpcOpenMemHandle`` can open handles to devices that may not be visible in the process calling the API. Contexts that may open ``cudaIpcMemHandles`` are restricted in the following way. ``cudaIpcMemHandles`` from each device in a given process may only be opened by one context per device per other process. If the memory handle has already been opened by the current context, the reference count on the handle is incremented by 1 and the existing device pointer is returned. Memory returned from ``cudaIpcOpenMemHandle`` must be freed with ``cudaIpcCloseMemHandle``. Calling ``cudaFree`` on an exported memory region before calling ``cudaIpcCloseMemHandle`` in the importing context will result in undefined behavior. IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users can test their device for IPC functionality by calling ``cudaDeviceGetAttribute`` with ``cudaDevAttrIpcEventSupport``. Args: handle (cudaIpcMemHandle_t): ``cudaIpcMemHandle`` to open. flags (unsigned int): Flags for this operation. Must be specified as ``cudaIpcMemLazyEnablePeerAccess``. Returns: intptr_t: Returned device pointer. .. note:: No guarantees are made about the address returned in ``*dev_ptr``. In particular, multiple processes may not receive the same address for the same ``handle``. .. seealso:: `cudaIpcOpenMemHandle` """ cdef intptr_t _handle_ptr_ = (handle)._get_ptr() cdef void* dev_ptr with nogil: __status__ = cudaIpcOpenMemHandle(&dev_ptr, (_handle_ptr_)[0], flags) check_status(__status__) return dev_ptr cpdef ipc_close_mem_handle(intptr_t dev_ptr): """Attempts to close memory mapped with cudaIpcOpenMemHandle. Decrements the reference count of the memory returnd by ``cudaIpcOpenMemHandle`` by 1. When the reference count reaches 0, this API unmaps the memory. The original allocation in the exporting process as well as imported mappings in other processes will be unaffected. Any resources used to enable peer access will be freed if this is the last mapping using them. IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users can test their device for IPC functionality by calling ``cudaDeviceGetAttribute`` with ``cudaDevAttrIpcEventSupport``. Args: dev_ptr (intptr_t): Device pointer returned by ``cudaIpcOpenMemHandle``. .. seealso:: `cudaIpcCloseMemHandle` """ with nogil: __status__ = cudaIpcCloseMemHandle(dev_ptr) check_status(__status__) cpdef device_flush_gpu_direct_rdma_writes(int target, int scope): """Blocks until remote writes are visible to the specified scope. Blocks until remote writes to the target context via mappings created through GPUDirect RDMA APIs, like nvidia_p2p_get_pages (see https://docs.nvidia.com/cuda/gpudirect-rdma for more information), are visible to the specified scope. If the scope equals or lies within the scope indicated by ``cudaDevAttrGPUDirectRDMAWritesOrdering``, the call will be a no-op and can be safely omitted for performance. This can be determined by comparing the numerical values between the two enums, with smaller scopes having smaller values. Users may query support for this API via ``cudaDevAttrGPUDirectRDMAFlushWritesOptions``. Args: target (FlushGPUDirectRDMAWritesTarget): The target of the operation, see ``cudaFlushGPUDirectRDMAWritesTarget``. scope (FlushGPUDirectRDMAWritesScope): The scope of the operation, see ``cudaFlushGPUDirectRDMAWritesScope``. .. seealso:: `cudaDeviceFlushGPUDirectRDMAWrites` """ with nogil: __status__ = cudaDeviceFlushGPUDirectRDMAWrites(target, scope) check_status(__status__) cpdef intptr_t device_register_async_notification(int device, intptr_t callback_func, intptr_t user_data) except? 0: """Registers a callback function to receive async notifications. Registers ``callback_func`` to receive async notifications. The ``user_data`` parameter is passed to the callback function at async notification time. Likewise, ``callback`` is also passed to the callback function to distinguish between multiple registered callbacks. The callback function being registered should be designed to return quickly (~10ms). Any long running tasks should be queued for execution on an application thread. Callbacks may not call cudaDeviceRegisterAsyncNotification or cudaDeviceUnregisterAsyncNotification. Doing so will result in ``cudaErrorNotPermitted``. Async notification callbacks execute in an undefined order and may be serialized. Returns in ``*callback`` a handle representing the registered callback instance. Args: device (int): The device on which to register the callback. callback_func (intptr_t): The function to register as a callback. user_data (intptr_t): A generic pointer to user data. This is passed into the callback function. Returns: intptr_t: A handle representing the registered callback instance. .. seealso:: `cudaDeviceRegisterAsyncNotification` """ cdef cudaAsyncCallbackHandle_t callback with nogil: __status__ = cudaDeviceRegisterAsyncNotification(device, callback_func, user_data, &callback) check_status(__status__) return callback cpdef device_unregister_async_notification(int device, intptr_t callback): """Unregisters an async notification callback. Unregisters ``callback`` so that the corresponding callback function will stop receiving async notifications. Args: device (int): The device from which to remove ``callback``. callback (intptr_t): The callback instance to unregister from receiving async notifications. .. seealso:: `cudaDeviceUnregisterAsyncNotification` """ with nogil: __status__ = cudaDeviceUnregisterAsyncNotification(device, callback) check_status(__status__) cpdef int device_get_shared_mem_config() except? -1: """Returns the shared memory configuration for the current device. [Deprecated]. This function will return in ``p_config`` the current size of shared memory banks on the current device. On devices with configurable shared memory banks, ``cudaDeviceSetSharedMemConfig`` can be used to change this setting, so that all subsequent kernel launches will by default use the new bank size. When ``cudaDeviceGetSharedMemConfig`` is called on devices without configurable shared memory, it will return the fixed bank size of the hardware. The returned bank configurations can be either:. - ``cudaSharedMemBankSizeFourByte`` - shared memory bank width is four bytes. - ``cudaSharedMemBankSizeEightByte`` - shared memory bank width is eight bytes. Returns: int: Returned cache configuration. .. seealso:: `cudaDeviceGetSharedMemConfig` """ cdef cudaSharedMemConfig p_config with nogil: __status__ = cudaDeviceGetSharedMemConfig(&p_config) check_status(__status__) return p_config cpdef device_set_shared_mem_config(int config): """Sets the shared memory configuration for the current device. [Deprecated]. On devices with configurable shared memory banks, this function will set the shared memory bank size which is used for all subsequent kernel launches. Any per-function setting of shared memory set via ``cudaFuncSetSharedMemConfig`` will override the device wide setting. Changing the shared memory configuration between launches may introduce a device side synchronization point. Changing the shared memory bank size will not increase shared memory usage or affect occupancy of kernels, but may have major effects on performance. Larger bank sizes will allow for greater potential bandwidth to shared memory, but will change what kinds of accesses to shared memory will result in bank conflicts. This function will do nothing on devices with fixed shared memory bank size. The supported bank configurations are:. - ``cudaSharedMemBankSizeDefault``: set bank width the device default (currently, four bytes). - ``cudaSharedMemBankSizeFourByte``: set shared memory bank width to be four bytes natively. - ``cudaSharedMemBankSizeEightByte``: set shared memory bank width to be eight bytes natively. Args: config (SharedMemConfig): Requested cache configuration. .. seealso:: `cudaDeviceSetSharedMemConfig` """ with nogil: __status__ = cudaDeviceSetSharedMemConfig(config) check_status(__status__) cpdef int get_last_error() except? -1: """Returns the last error from a runtime call. Returns the last error that has been produced by any of the runtime calls in the same instance of the CUDA Runtime library in the host thread and resets it to ``cudaSuccess``. Note: Multiple instances of the CUDA Runtime library can be present in an application when using a library that statically links the CUDA Runtime. .. seealso:: `cudaGetLastError` """ cdef int ret with nogil: ret = cudaGetLastError() return ret cpdef int peek_at_last_error() except? -1: """Returns the last error from a runtime call. Returns the last error that has been produced by any of the runtime calls in the same instance of the CUDA Runtime library in the host thread. This call does not reset the error to ``cudaSuccess`` like :func:`get_last_error`. Note: Multiple instances of the CUDA Runtime library can be present in an application when using a library that statically links the CUDA Runtime. .. seealso:: `cudaPeekAtLastError` """ cdef int ret with nogil: ret = cudaPeekAtLastError() return ret cpdef str get_error_name(int error): """Returns the string representation of an error code enum name. Returns a string containing the name of an error code in the enum. If the error code is not recognized, "unrecognized error code" is returned. Args: error (Error): Error code to convert to string. .. seealso:: `cudaGetErrorName` """ cdef const char *_output_cstr_ cdef bytes _output_ with nogil: _output_cstr_ = cudaGetErrorName(error) _output_ = _output_cstr_ return _output_.decode() cpdef str get_error_string(int error): """Returns the description string for an error code. Returns the description string for an error code. If the error code is not recognized, "unrecognized error code" is returned. Args: error (Error): Error code to convert to string. .. seealso:: `cudaGetErrorString` """ cdef const char *_output_cstr_ cdef bytes _output_ with nogil: _output_cstr_ = cudaGetErrorString(error) _output_ = _output_cstr_ return _output_.decode() cpdef int get_device_count() except? -1: """Returns the number of compute-capable devices. Returns in ``*count`` the number of devices with compute capability greater or equal to 2.0 that are available for execution. Returns: int: Returns the number of devices with compute capability greater or equal to 2.0. .. seealso:: `cudaGetDeviceCount` """ cdef int count with nogil: __status__ = cudaGetDeviceCount(&count) check_status(__status__) return count cpdef int device_get_attribute(int attr, int device) except? -1: """Returns information about the device. Returns in ``*value`` the integer value of the attribute ``attr`` on device ``device``. Args: attr (DeviceAttr): Device attribute to query. device (int): Device number to query. Returns: int: Returned device attribute value. .. seealso:: `cudaDeviceGetAttribute` """ cdef int value with nogil: __status__ = cudaDeviceGetAttribute(&value, attr, device) check_status(__status__) return value cpdef intptr_t device_get_default_mem_pool(int device) except? 0: """Returns the default mempool of a device. The default mempool of a device contains device memory from that device. Args: device (int): Device to query the default memory pool of. Returns: intptr_t: Returned default memory pool of the device. .. seealso:: `cudaDeviceGetDefaultMemPool` """ cdef cudaMemPool_t mem_pool with nogil: __status__ = cudaDeviceGetDefaultMemPool(&mem_pool, device) check_status(__status__) return mem_pool cpdef device_set_mem_pool(int device, intptr_t mem_pool): """Sets the current memory pool of a device. The memory pool must be local to the specified device. Unless a mempool is specified in the ``cudaMallocAsync`` call, ``cudaMallocAsync`` allocates from the current mempool of the provided stream's device. By default, a device's current memory pool is its default memory pool. Args: device (int): Device to set the current memory pool of. mem_pool (intptr_t): Memory pool to set as the current memory pool of the device. .. note:: Use ``cudaMallocFromPoolAsync`` to specify asynchronous allocations from a device different than the one the stream runs on. .. seealso:: `cudaDeviceSetMemPool` """ with nogil: __status__ = cudaDeviceSetMemPool(device, mem_pool) check_status(__status__) cpdef intptr_t device_get_mem_pool(int device) except? 0: """Gets the current mempool for a device. Returns the last pool provided to ``cudaDeviceSetMemPool`` for this device or the device's default memory pool if ``cudaDeviceSetMemPool`` has never been called. By default the current mempool is the default mempool for a device, otherwise the returned pool must have been set with ``cuDeviceSetMemPool`` or ``cudaDeviceSetMemPool``. Args: device (int): Device to query the current memory pool of. Returns: intptr_t: Returned current memory pool of the device. .. seealso:: `cudaDeviceGetMemPool` """ cdef cudaMemPool_t mem_pool with nogil: __status__ = cudaDeviceGetMemPool(&mem_pool, device) check_status(__status__) return mem_pool cpdef int device_get_p2p_attribute(int attr, int src_device, int dst_device) except? -1: """Queries attributes of the link between two devices. Returns in ``*value`` the value of the requested attribute ``attrib`` of the link between ``src_device`` and ``dst_device``. The supported attributes are:. - ``cudaDevP2PAttrPerformanceRank``: A relative value indicating the performance of the link between two devices. Lower value means better performance (0 being the value used for most performant link). - ``cudaDevP2PAttrAccessSupported``: 1 if peer access is enabled. - ``cudaDevP2PAttrNativeAtomicSupported``: 1 if all native atomic operations over the link are supported. - ``cudaDevP2PAttrCudaArrayAccessSupported``: 1 if accessing CUDA arrays over the link is supported. - ``cudaDevP2PAttrOnlyPartialNativeAtomicSupported``: 1 if some CUDA-valid atomic operations over the link are supported. Information about specific operations can be retrieved with ``cudaDeviceGetP2PAtomicCapabilities``. Returns ``cudaErrorInvalidDevice`` if ``src_device`` or ``dst_device`` are not valid or if they represent the same device. Returns ``cudaErrorInvalidValue`` if ``attrib`` is not valid or if ``value`` is a null pointer. Args: attr (DeviceP2PAttr): The requested attribute of the link between ``src_device`` and ``dst_device``. src_device (int): The source device of the target link. dst_device (int): The destination device of the target link. Returns: int: Returned value of the requested attribute. .. seealso:: `cudaDeviceGetP2PAttribute` """ cdef int value with nogil: __status__ = cudaDeviceGetP2PAttribute(&value, attr, src_device, dst_device) check_status(__status__) return value cpdef int choose_device(prop) except? -1: """Select compute-device which best matches criteria. Returns in ``*device`` the device which has properties that best match ``*prop``. Args: prop (intptr_t): Desired device properties. Returns: int: Device with best match. .. seealso:: `cudaChooseDevice` """ cdef intptr_t _prop_ptr_ = 0 if prop is None else int(prop) cdef int device with nogil: __status__ = cudaChooseDevice(&device, _prop_ptr_) check_status(__status__) return device cpdef init_device(int device, unsigned int device_flags, unsigned int flags): """Initialize device to be used for GPU executions. This function will initialize the CUDA Runtime structures and primary context on ``device`` when called, but the context will not be made current to ``device``. When ``cudaInitDeviceFlagsAreValid`` is set in ``flags``, device_flags are applied to the requested device. The values of device_flags match those of the flags parameters in ``cudaSetDeviceFlags``. The effect may be verified by ``cudaGetDeviceFlags``. This function will return an error if the device is in ``cudaComputeModeExclusiveProcess`` and is occupied by another process or if the device is in ``cudaComputeModeProhibited``. Args: device (int): Device on which the runtime will initialize itself. device_flags (unsigned int): Parameters for device operation. flags (unsigned int): Flags for controlling the device initialization. .. seealso:: `cudaInitDevice` """ with nogil: __status__ = cudaInitDevice(device, device_flags, flags) check_status(__status__) cpdef set_device(int device): """Set device to be used for GPU executions. Sets ``device`` as the current device for the calling host thread. Valid device id's are 0 to (:func:`get_device_count` - 1). Any device memory subsequently allocated from this host thread using :func:`malloc`, :func:`malloc_pitch` or :func:`malloc_array` will be physically resident on ``device``. Any host memory allocated from this host thread using :func:`malloc_host` or :func:`host_alloc` or :func:`host_register` will have its lifetime associated with ``device``. Any streams or events created from this host thread will be associated with ``device``. Any kernels launched from this host thread using the <<<>>> operator or ``cudaLaunchKernel()`` will be executed on ``device`` when using the NULL or per-thread streams (otherwise, they will be executed on the device associated with the stream). This call may be made from any host thread, to any device, and at any time. This function will do no synchronization with the previous or new device, and should only take significant time when it initializes the runtime's context state. This call will bind the primary context of the specified device to the calling thread and all the subsequent memory allocations, stream and event creations will be associated with the primary context. This function will also immediately initialize the runtime state on the primary context, and the context will be current on ``device`` immediately. This function will return an error if the device is in ``cudaComputeModeExclusiveProcess`` and is occupied by another process or if the device is in ``cudaComputeModeProhibited``. It is not required to call ``cudaInitDevice`` before using this function. Args: device (int): Device on which the active host thread should execute the device code. .. seealso:: `cudaSetDevice` """ with nogil: __status__ = cudaSetDevice(device) check_status(__status__) cpdef int get_device() except? -1: """Returns which device is currently being used. Returns in ``*device`` the current device for the calling host thread. Returns: int: Returns the device on which the active host thread executes the device code. .. seealso:: `cudaGetDevice` """ cdef int device with nogil: __status__ = cudaGetDevice(&device) check_status(__status__) return device cpdef set_device_flags(unsigned int flags): """Sets flags to be used for device executions. Records ``flags`` as the flags for the current device. If the current device has been set and that device has already been initialized, the previous flags are overwritten. If the current device has not been initialized, it is initialized with the provided flags. If no device has been made current to the calling thread, a default device is selected and initialized with the provided flags. The three LSBs of the ``flags`` parameter can be used to control how the CPU thread interacts with the OS scheduler when waiting for results from the device. - ``cudaDeviceScheduleAuto``: The default value if the ``flags`` parameter is zero, uses a heuristic based on the number of active CUDA contexts in the process ``C`` and the number of logical processors in the system ``P``. If ``C`` > ``P``, then CUDA will yield to other OS threads when waiting for the device, otherwise CUDA will not yield while waiting for results and actively spin on the processor. Additionally, on Tegra devices, ``cudaDeviceScheduleAuto`` uses a heuristic based on the power profile of the platform and may choose ``cudaDeviceScheduleBlockingSync`` for low-powered devices. - ``cudaDeviceScheduleSpin``: Instruct CUDA to actively spin when waiting for results from the device. This can decrease latency when waiting for the device, but may lower the performance of CPU threads if they are performing work in parallel with the CUDA thread. - ``cudaDeviceScheduleYield``: Instruct CUDA to yield its thread when waiting for results from the device. This can increase latency when waiting for the device, but can increase the performance of CPU threads performing work in parallel with the device. - ``cudaDeviceScheduleBlockingSync``: Instruct CUDA to block the CPU thread on a synchronization primitive when waiting for the device to finish work. - ``cudaDeviceBlockingSync``: Instruct CUDA to block the CPU thread on a synchronization primitive when waiting for the device to finish work. ``Deprecated:`` This flag was deprecated as of CUDA 4.0 and replaced with ``cudaDeviceScheduleBlockingSync``. - ``cudaDeviceMapHost``: This flag enables allocating pinned host memory that is accessible to the device. It is implicit for the runtime but may be absent if a context is created using the driver API. If this flag is not set, :func:`host_get_device_pointer` will always return a failure code. - ``cudaDeviceLmemResizeToMax``: Instruct CUDA to not reduce local memory after resizing local memory for a kernel. This can prevent thrashing by local memory allocations when launching many kernels with high local memory usage at the cost of potentially increased memory usage. ``Deprecated:`` This flag is deprecated and the behavior enabled by this flag is now the default and cannot be disabled. - ``cudaDeviceSyncMemops``: Ensures that synchronous memory operations initiated on this context will always synchronize. See further documentation in the section titled "API Synchronization behavior" to learn more about cases when synchronous memory operations can exhibit asynchronous behavior. Args: flags (unsigned int): Parameters for device operation. .. seealso:: `cudaSetDeviceFlags` """ with nogil: __status__ = cudaSetDeviceFlags(flags) check_status(__status__) cpdef unsigned int get_device_flags() except? 0: """Gets the flags for the current device. Returns in ``flags`` the flags for the current device. If there is a current device for the calling thread, the flags for the device are returned. If there is no current device, the flags for the first device are returned, which may be the default flags. Compare to the behavior of ``cudaSetDeviceFlags``. Typically, the flags returned should match the behavior that will be seen if the calling thread uses a device after this call, without any change to the flags or current device inbetween by this or another thread. Note that if the device is not initialized, it is possible for another thread to change the flags for the current device before it is initialized. Additionally, when using exclusive mode, if this thread has not requested a specific device, it may use a device other than the first device, contrary to the assumption made by this function. If a context has been created via the driver API and is current to the calling thread, the flags for that context are always returned. Flags returned by this function may specifically include ``cudaDeviceMapHost`` even though it is not accepted by ``cudaSetDeviceFlags`` because it is implicit in runtime API flags. The reason for this is that the current context may have been created via the driver API in which case the flag is not implicit and may be unset. Returns: unsigned int: Pointer to store the device flags. .. seealso:: `cudaGetDeviceFlags` """ cdef unsigned int flags with nogil: __status__ = cudaGetDeviceFlags(&flags) check_status(__status__) return flags cpdef intptr_t stream_create() except? 0: """Create an asynchronous stream. Creates a new asynchronous stream on the context that is current to the calling host thread. If no context is current to the calling host thread, then the primary context for a device is selected, made current to the calling thread, and initialized before creating a stream on it. Returns: intptr_t: Pointer to new stream identifier. .. seealso:: `cudaStreamCreate` """ cdef cudaStream_t p_stream with nogil: __status__ = cudaStreamCreate(&p_stream) check_status(__status__) return p_stream cpdef intptr_t stream_create_with_flags(unsigned int flags) except? 0: """Create an asynchronous stream. Creates a new asynchronous stream on the context that is current to the calling host thread. If no context is current to the calling host thread, then the primary context for a device is selected, made current to the calling thread, and initialized before creating a stream on it. The ``flags`` argument determines the behaviors of the stream. Valid values for ``flags`` are. - ``cudaStreamDefault``: Default stream creation flag. - ``cudaStreamNonBlocking``: Specifies that work running in the created stream may run concurrently with work in stream 0 (the NULL stream), and that the created stream should perform no implicit synchronization with stream 0. Args: flags (unsigned int): Parameters for stream creation. Returns: intptr_t: Pointer to new stream identifier. .. seealso:: `cudaStreamCreateWithFlags` """ cdef cudaStream_t p_stream with nogil: __status__ = cudaStreamCreateWithFlags(&p_stream, flags) check_status(__status__) return p_stream cpdef intptr_t stream_create_with_priority(unsigned int flags, int priority) except? 0: """Create an asynchronous stream with the specified priority. Creates a stream with the specified priority and returns a handle in ``p_stream``. The stream is created on the context that is current to the calling host thread. If no context is current to the calling host thread, then the primary context for a device is selected, made current to the calling thread, and initialized before creating a stream on it. This affects the scheduling priority of work in the stream. Priorities provide a hint to preferentially run work with higher priority when possible, but do not preempt already-running work or provide any other functional guarantee on execution order. ``priority`` follows a convention where lower numbers represent higher priorities. '0' represents default priority. The range of meaningful numerical priorities can be queried using ``cudaDeviceGetStreamPriorityRange``. If the specified priority is outside the numerical range returned by ``cudaDeviceGetStreamPriorityRange``, it will automatically be clamped to the lowest or the highest number in the range. Args: flags (unsigned int): Flags for stream creation. See ``cudaStreamCreateWithFlags`` for a list of valid flags that can be passed. priority (int): Priority of the stream. Lower numbers represent higher priorities. See ``cudaDeviceGetStreamPriorityRange`` for more information about the meaningful stream priorities that can be passed. Returns: intptr_t: Pointer to new stream identifier. .. note:: Stream priorities are supported only on GPUs with compute capability 3.5 or higher. .. note:: In the current implementation, only compute kernels launched in priority streams are affected by the stream's priority. Stream priorities have no effect on host-to-device and device-to-host memory operations. .. seealso:: `cudaStreamCreateWithPriority` """ cdef cudaStream_t p_stream with nogil: __status__ = cudaStreamCreateWithPriority(&p_stream, flags, priority) check_status(__status__) return p_stream cpdef int stream_get_priority(intptr_t h_stream) except? -1: """Query the priority of a stream. Query the priority of a stream. The priority is returned in in ``priority``. Note that if the stream was created with a priority outside the meaningful numerical range returned by ``cudaDeviceGetStreamPriorityRange``, this function returns the clamped priority. See ``cudaStreamCreateWithPriority`` for details about priority clamping. Args: h_stream (intptr_t): Handle to the stream to be queried. Returns: int: Pointer to a signed integer in which the stream's priority is returned. .. seealso:: `cudaStreamGetPriority` """ cdef int priority with nogil: __status__ = cudaStreamGetPriority(h_stream, &priority) check_status(__status__) return priority cpdef unsigned int stream_get_flags(intptr_t h_stream) except? 0: """Query the flags of a stream. Query the flags of a stream. The flags are returned in ``flags``. See ``cudaStreamCreateWithFlags`` for a list of valid flags. Args: h_stream (intptr_t): Handle to the stream to be queried. Returns: unsigned int: Pointer to an unsigned integer in which the stream's flags are returned. .. seealso:: `cudaStreamGetFlags` """ cdef unsigned int flags with nogil: __status__ = cudaStreamGetFlags(h_stream, &flags) check_status(__status__) return flags cpdef unsigned long long stream_get_id(intptr_t h_stream) except? 0: """Query the Id of a stream. Query the Id of a stream. The Id is returned in ``stream_id``. The Id is unique for the life of the program. The stream handle ``h_stream`` can refer to any of the following:. - a stream created via any of the CUDA runtime APIs such as ``cudaStreamCreate``, ``cudaStreamCreateWithFlags`` and ``cudaStreamCreateWithPriority``, or their driver API equivalents such as ``cuStreamCreate`` or ``cuStreamCreateWithPriority``. Passing an invalid handle will result in undefined behavior. - any of the special streams such as the NULL stream, ``cudaStreamLegacy`` and ``cudaStreamPerThread`` respectively. The driver API equivalents of these are also accepted which are NULL, ``CU_STREAM_LEGACY`` and ``CU_STREAM_PER_THREAD``. Args: h_stream (intptr_t): Handle to the stream to be queried. Returns: unsigned long long: Pointer to an unsigned long long in which the stream Id is returned. .. seealso:: `cudaStreamGetId` """ cdef unsigned long long stream_id with nogil: __status__ = cudaStreamGetId(h_stream, &stream_id) check_status(__status__) return stream_id cpdef int stream_get_device(intptr_t h_stream) except? -1: """Query the device of a stream. Returns in ``*device`` the device of the stream. Args: h_stream (intptr_t): Handle to the stream to be queried. Returns: int: Returns the device to which the stream belongs. .. seealso:: `cudaStreamGetDevice` """ cdef int device with nogil: __status__ = cudaStreamGetDevice(h_stream, &device) check_status(__status__) return device cpdef ctx_reset_persisting_l2cache(): """Resets all persisting lines in cache to normal status. Resets all persisting lines in cache to normal status. Takes effect on function return. .. seealso:: `cudaCtxResetPersistingL2Cache` """ with nogil: __status__ = cudaCtxResetPersistingL2Cache() check_status(__status__) cpdef stream_copy_attributes(intptr_t dst, intptr_t src): """Copies attributes from source stream to destination stream. Copies attributes from source stream ``src`` to destination stream ``dst``. Both streams must have the same context. Args: dst (intptr_t): Destination stream. src (intptr_t): Source stream For attributes see ``cudaStreamAttrID``. .. seealso:: `cudaStreamCopyAttributes` """ with nogil: __status__ = cudaStreamCopyAttributes(dst, src) check_status(__status__) cpdef object stream_get_attribute(intptr_t h_stream, cudaLaunchAttributeID attr): """Queries stream attribute. Queries attribute ``attr`` from ``h_stream`` and stores it in corresponding member of ``value_out``. Args: h_stream (intptr_t): . attr (LaunchAttributeID): . Returns: cudaLaunchAttributeValue: . .. seealso:: `cudaStreamGetAttribute` """ cdef LaunchAttributeValue value_out_py = LaunchAttributeValue() cdef cudaLaunchAttributeValue *value_out = (value_out_py._get_ptr()) with nogil: __status__ = cudaStreamGetAttribute(h_stream, attr, value_out) check_status(__status__) return value_out_py cpdef stream_set_attribute(intptr_t h_stream, cudaLaunchAttributeID attr, value): """Sets stream attribute. Sets attribute ``attr`` on ``h_stream`` from corresponding attribute of ``value``. The updated attribute will be applied to subsequent work submitted to the stream. It will not affect previously submitted work. Args: h_stream (intptr_t): . attr (LaunchAttributeID): . value (intptr_t): . .. seealso:: `cudaStreamSetAttribute` """ cdef intptr_t _value_ptr_ = 0 if value is None else int(value) with nogil: __status__ = cudaStreamSetAttribute(h_stream, attr, _value_ptr_) check_status(__status__) cpdef stream_destroy(intptr_t stream): """Destroys and cleans up an asynchronous stream. Destroys and cleans up the asynchronous stream specified by ``stream``. In case the device is still doing work in the stream ``stream`` when :func:`stream_destroy` is called, the function will return immediately and the resources associated with ``stream`` will be released automatically once the device has completed all work in ``stream``. Args: stream (intptr_t): Stream identifier. .. seealso:: `cudaStreamDestroy` """ with nogil: __status__ = cudaStreamDestroy(stream) check_status(__status__) cpdef stream_wait_event(intptr_t stream, intptr_t event, unsigned int flags): """Make a compute stream wait on an event. Makes all future work submitted to ``stream`` wait for all work captured in ``event``. See :func:`event_record` for details on what is captured by an event. The synchronization will be performed efficiently on the device when applicable. ``event`` may be from a different device than ``stream``. flags include:. - ``cudaEventWaitDefault``: Default event creation flag. - ``cudaEventWaitExternal``: Event is captured in the graph as an external event node when performing stream capture. Args: stream (intptr_t): Stream to wait. event (intptr_t): Event to wait on. flags (unsigned int): Parameters for the operation(See above). .. seealso:: `cudaStreamWaitEvent` """ with nogil: __status__ = cudaStreamWaitEvent(stream, event, flags) check_status(__status__) cpdef stream_add_callback(intptr_t stream, intptr_t callback, intptr_t user_data, unsigned int flags): """Add a callback to a compute stream. Adds a callback to be called on the host after all currently enqueued items in the stream have completed. For each cudaStreamAddCallback call, a callback will be executed exactly once. The callback will block later work in the stream until it is finished. The callback may be passed ``cudaSuccess`` or an error code. In the event of a device error, all subsequently executed callbacks will receive an appropriate ``cudaError_t``. Callbacks must not make any CUDA API calls. Attempting to use CUDA APIs may result in ``cudaErrorNotPermitted``. Callbacks must not perform any synchronization that may depend on outstanding device work or other callbacks that are not mandated to run earlier. Callbacks without a mandated order (in independent streams) execute in undefined order and may be serialized. For the purposes of Unified Memory, callback execution makes a number of guarantees:. - The callback stream is considered idle for the duration of the callback. Thus, for example, a callback may always use memory attached to the callback stream. - The start of execution of a callback has the same effect as synchronizing an event recorded in the same stream immediately prior to the callback. It thus synchronizes streams which have been "joined" prior to the callback. - Adding device work to any stream does not have the effect of making the stream active until all preceding callbacks have executed. Thus, for example, a callback might use global attached memory even if work has been added to another stream, if it has been properly ordered with an event. - Completion of a callback does not cause a stream to become active except as described above. The callback stream will remain idle if no device work follows the callback, and will remain idle across consecutive callbacks without device work in between. Thus, for example, stream synchronization can be done by signaling from a callback at the end of the stream. Args: stream (intptr_t): Stream to add callback to. callback (intptr_t): The function to call once preceding stream operations are complete. user_data (intptr_t): User specified data to be passed to the callback function. flags (unsigned int): Reserved for future use, must be 0. .. note:: This function is slated for eventual deprecation and removal. If you do not require the callback to execute in case of a device error, consider using ``cudaLaunchHostFunc``. Additionally, this function is not supported with ``cudaStreamBeginCapture`` and ``cudaStreamEndCapture``, unlike ``cudaLaunchHostFunc``. .. seealso:: `cudaStreamAddCallback` """ with nogil: __status__ = cudaStreamAddCallback(stream, callback, user_data, flags) check_status(__status__) cpdef stream_synchronize(intptr_t stream): """Waits for stream tasks to complete. Blocks until ``stream`` has completed all operations. If the ``cudaDeviceScheduleBlockingSync`` flag was set for this device, the host thread will block until the stream is finished with all of its tasks. Args: stream (intptr_t): Stream identifier. .. seealso:: `cudaStreamSynchronize` """ with nogil: __status__ = cudaStreamSynchronize(stream) check_status(__status__) cpdef stream_query(intptr_t stream): """Queries an asynchronous stream for completion status. Returns ``cudaSuccess`` if all operations in ``stream`` have completed, or ``cudaErrorNotReady`` if not. For the purposes of Unified Memory, a return value of ``cudaSuccess`` is equivalent to having called :func:`stream_synchronize`. Args: stream (intptr_t): Stream identifier. .. seealso:: `cudaStreamQuery` """ with nogil: __status__ = cudaStreamQuery(stream) check_status(__status__) cpdef stream_query_no_raise(intptr_t stream): """Queries an asynchronous stream for completion status. This is the ``no_raise`` variant of :func:`stream_query`. Instead of raising an exception when the underlying C API call fails, it returns the raw status code. Returns ``cudaSuccess`` if all operations in ``stream`` have completed, or ``cudaErrorNotReady`` if not. For the purposes of Unified Memory, a return value of ``cudaSuccess`` is equivalent to having called :func:`stream_synchronize`. Args: stream (intptr_t): Stream identifier. Returns: int: The raw status code returned by the underlying C API. .. seealso:: `cudaStreamQuery` """ with nogil: __status__ = cudaStreamQuery(stream) return __status__ cpdef stream_attach_mem_async(intptr_t stream, intptr_t dev_ptr, size_t length, unsigned int flags): """Attach memory to a stream asynchronously. Enqueues an operation in ``stream`` to specify stream association of ``length`` bytes of memory starting from ``dev_ptr``. This function is a stream-ordered operation, meaning that it is dependent on, and will only take effect when, previous work in stream has completed. Any previous association is automatically replaced. ``dev_ptr`` must point to an one of the following types of memories:. - managed memory declared using the managed keyword or allocated with ``cudaMallocManaged``. - a valid host-accessible region of system-allocated pageable memory. This type of memory may only be specified if the device associated with the stream reports a non-zero value for the device attribute ``cudaDevAttrPageableMemoryAccess``. For managed allocations, ``length`` must be either zero or the entire allocation's size. Both indicate that the entire allocation's stream association is being changed. Currently, it is not possible to change stream association for a portion of a managed allocation. For pageable allocations, ``length`` must be non-zero. The stream association is specified using ``flags`` which must be one of ``cudaMemAttachGlobal``, ``cudaMemAttachHost`` or ``cudaMemAttachSingle``. The default value for ``flags`` is ``cudaMemAttachSingle`` If the ``cudaMemAttachGlobal`` flag is specified, the memory can be accessed by any stream on any device. If the ``cudaMemAttachHost`` flag is specified, the program makes a guarantee that it won't access the memory on the device from any stream on a device that has a zero value for the device attribute ``cudaDevAttrConcurrentManagedAccess``. If the ``cudaMemAttachSingle`` flag is specified and ``stream`` is associated with a device that has a zero value for the device attribute ``cudaDevAttrConcurrentManagedAccess``, the program makes a guarantee that it will only access the memory on the device from ``stream``. It is illegal to attach singly to the NULL stream, because the NULL stream is a virtual global stream and not a specific stream. An error will be returned in this case. When memory is associated with a single stream, the Unified Memory system will allow CPU access to this memory region so long as all operations in ``stream`` have completed, regardless of whether other streams are active. In effect, this constrains exclusive ownership of the managed memory region by an active GPU to per-stream activity instead of whole-GPU activity. Accessing memory on the device from streams that are not associated with it will produce undefined results. No error checking is performed by the Unified Memory system to ensure that kernels launched into other streams do not access this region. It is a program's responsibility to order calls to ``cudaStreamAttachMemAsync`` via events, synchronization or other means to ensure legal access to memory at all times. Data visibility and coherency will be changed appropriately for all kernels which follow a stream-association change. If ``stream`` is destroyed while data is associated with it, the association is removed and the association reverts to the default visibility of the allocation as specified at ``cudaMallocManaged``. For managed variables, the default association is always ``cudaMemAttachGlobal``. Note that destroying a stream is an asynchronous operation, and as a result, the change to default association won't happen until all work in the stream has completed. Args: stream (intptr_t): Stream in which to enqueue the attach operation. dev_ptr (intptr_t): Pointer to memory (must be a pointer to managed memory or to a valid host-accessible region of system-allocated memory). length (size_t): Length of memory (defaults to zero). flags (unsigned int): Must be one of ``cudaMemAttachGlobal``, ``cudaMemAttachHost`` or ``cudaMemAttachSingle`` (defaults to ``cudaMemAttachSingle``). .. seealso:: `cudaStreamAttachMemAsync` """ with nogil: __status__ = cudaStreamAttachMemAsync(stream, dev_ptr, length, flags) check_status(__status__) cpdef stream_begin_capture(intptr_t stream, int mode): """Begins graph capture on a stream. Begin graph capture on ``stream``. When a stream is in capture mode, all operations pushed into the stream will not be executed, but will instead be captured into a graph, which will be returned via ``cudaStreamEndCapture``. Capture may not be initiated if ``stream`` is ``cudaStreamLegacy``. Capture must be ended on the same stream in which it was initiated, and it may only be initiated if the stream is not already in capture mode. The capture mode may be queried via ``cudaStreamIsCapturing``. A unique id representing the capture sequence may be queried via ``cudaStreamGetCaptureInfo``. If ``mode`` is not ``cudaStreamCaptureModeRelaxed``, ``cudaStreamEndCapture`` must be called on this stream from the same thread. Args: stream (intptr_t): Stream in which to initiate capture. mode (StreamCaptureMode): Controls the interaction of this capture sequence with other API calls that are potentially unsafe. For more details see ``cudaThreadExchangeStreamCaptureMode``. .. note:: Kernels captured using this API must not use texture and surface references. Reading or writing through any texture or surface reference is undefined behavior. This restriction does not apply to texture and surface objects. .. seealso:: `cudaStreamBeginCapture` """ with nogil: __status__ = cudaStreamBeginCapture(stream, mode) check_status(__status__) cpdef stream_begin_capture_to_graph(intptr_t stream, intptr_t graph, dependencies, dependency_data, int mode): """Begins graph capture on a stream to an existing graph. Begin graph capture on ``stream``. When a stream is in capture mode, all operations pushed into the stream will not be executed, but will instead be captured into ``graph``, which will be returned via ``cudaStreamEndCapture``. Capture may not be initiated if ``stream`` is ``cudaStreamLegacy``. Capture must be ended on the same stream in which it was initiated, and it may only be initiated if the stream is not already in capture mode. The capture mode may be queried via ``cudaStreamIsCapturing``. A unique id representing the capture sequence may be queried via ``cudaStreamGetCaptureInfo``. If ``mode`` is not ``cudaStreamCaptureModeRelaxed``, ``cudaStreamEndCapture`` must be called on this stream from the same thread. Args: stream (intptr_t): Stream in which to initiate capture. graph (intptr_t): Graph to capture into. dependencies (object): Dependencies of the first node captured in the stream. Can be NULL if ``len(dependencies)`` is 0. It must be: - a Python sequence of :class:`int`\s (as pointer addresses), or - ``None`` for NULL. dependency_data (GraphEdgeData): Optional array of data associated with each dependency. It must be: - a :class:`GraphEdgeData`, or - ``None`` for NULL. mode (StreamCaptureMode): Controls the interaction of this capture sequence with other API calls that are potentially unsafe. For more details see ``cudaThreadExchangeStreamCaptureMode``. .. note:: Kernels captured using this API must not use texture and surface references. Reading or writing through any texture or surface reference is undefined behavior. This restriction does not apply to texture and surface objects. .. seealso:: `cudaStreamBeginCaptureToGraph` """ cdef _cyb_nullable_unique_ptr[ _cyb_vector[void*] ] _dependencies_ if isinstance(dependencies, int): raise TypeError( "dependencies must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _dependencies_len_ = 0 _cyb_get_resource_ptrs[void](_dependencies_, dependencies, NULL) if _dependencies_.get() != NULL: _dependencies_len_ = _dependencies_.get().size() cdef intptr_t _dependency_data_ptr_ = 0 cdef Py_ssize_t _dependency_data_len_ = 0 if dependency_data is None: pass else: (dependency_data) _dependency_data_ptr_ = int(dependency_data) _dependency_data_len_ = len(dependency_data) cdef Py_ssize_t _num_dependencies_length_ = 0 cdef bint _num_dependencies_is_set_ = False if dependencies is not None: _num_dependencies_length_ = _cyb_check_same_length(_num_dependencies_is_set_, _num_dependencies_length_, _dependencies_len_, "dependencies", "dependencies, dependency_data") _num_dependencies_is_set_ = True if dependency_data is not None: _num_dependencies_length_ = _cyb_check_same_length(_num_dependencies_is_set_, _num_dependencies_length_, _dependency_data_len_, "dependency_data", "dependencies, dependency_data") _num_dependencies_is_set_ = True cdef size_t num_dependencies = _num_dependencies_length_ if num_dependencies != _num_dependencies_length_: raise OverflowError( f"The length of (dependencies, dependency_data), {_num_dependencies_length_}, does not fit in 'numDependencies' (a size_t)" ) with nogil: __status__ = cudaStreamBeginCaptureToGraph(stream, graph, (_dependencies_.data()), _dependency_data_ptr_, num_dependencies, mode) check_status(__status__) cpdef intptr_t stream_end_capture(intptr_t stream) except? 0: """Ends capture on a stream, returning the captured graph. End capture on ``stream``, returning the captured graph via ``p_graph``. Capture must have been initiated on ``stream`` via a call to ``cudaStreamBeginCapture``. If capture was invalidated, due to a violation of the rules of stream capture, then a NULL graph will be returned. If the ``mode`` argument to ``cudaStreamBeginCapture`` was not ``cudaStreamCaptureModeRelaxed``, this call must be from the same thread as ``cudaStreamBeginCapture``. Args: stream (intptr_t): Stream to query. Returns: intptr_t: The captured graph. .. seealso:: `cudaStreamEndCapture` """ cdef cudaGraph_t p_graph with nogil: __status__ = cudaStreamEndCapture(stream, &p_graph) check_status(__status__) return p_graph cpdef int stream_is_capturing(intptr_t stream) except? -1: """Returns a stream's capture status. Return the capture status of ``stream`` via ``p_capture_status``. After a successful call, ``*p_capture_status`` will contain one of the following:. - ``cudaStreamCaptureStatusNone``: The stream is not capturing. - ``cudaStreamCaptureStatusActive``: The stream is capturing. - ``cudaStreamCaptureStatusInvalidated``: The stream was capturing but an error has invalidated the capture sequence. The capture sequence must be terminated with ``cudaStreamEndCapture`` on the stream where it was initiated in order to continue using ``stream``. Note that, if this is called on ``cudaStreamLegacy`` (the "null stream") while a blocking stream on the same device is capturing, it will return ``cudaErrorStreamCaptureImplicit`` and ``*p_capture_status`` is unspecified after the call. The blocking stream capture is not invalidated. When a blocking stream is capturing, the legacy stream is in an unusable state until the blocking stream capture is terminated. The legacy stream is not supported for stream capture, but attempted use would have an implicit dependency on the capturing stream(s). Args: stream (intptr_t): Stream to query. Returns: int: Returns the stream's capture status. .. seealso:: `cudaStreamIsCapturing` """ cdef cudaStreamCaptureStatus p_capture_status with nogil: __status__ = cudaStreamIsCapturing(stream, &p_capture_status) check_status(__status__) return p_capture_status cpdef stream_update_capture_dependencies(intptr_t stream, dependencies, dependency_data, unsigned int flags): """Update the set of dependencies in a capturing stream. Modifies the dependency set of a capturing stream. The dependency set is the set of nodes that the next captured node in the stream will depend on. Valid flags are ``cudaStreamAddCaptureDependencies`` and ``cudaStreamSetCaptureDependencies``. These control whether the set passed to the API is added to the existing set or replaces it. A flags value of 0 defaults to ``cudaStreamAddCaptureDependencies``. Nodes that are removed from the dependency set via this API do not result in ``cudaErrorStreamCaptureUnjoined`` if they are unreachable from the stream at ``cudaStreamEndCapture``. Returns ``cudaErrorIllegalState`` if the stream is not capturing. Args: stream (intptr_t): The stream to update. dependencies (object): The set of dependencies to add. It must be: - a Python sequence of :class:`int`\s (as pointer addresses), or - ``None`` for NULL. dependency_data (GraphEdgeData): Optional array of data associated with each dependency. It must be: - a :class:`GraphEdgeData`, or - ``None`` for NULL. flags (unsigned int): See above. .. seealso:: `cudaStreamUpdateCaptureDependencies` """ cdef _cyb_nullable_unique_ptr[ _cyb_vector[void*] ] _dependencies_ if isinstance(dependencies, int): raise TypeError( "dependencies must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _dependencies_len_ = 0 _cyb_get_resource_ptrs[void](_dependencies_, dependencies, NULL) if _dependencies_.get() != NULL: _dependencies_len_ = _dependencies_.get().size() cdef intptr_t _dependency_data_ptr_ = 0 cdef Py_ssize_t _dependency_data_len_ = 0 if dependency_data is None: pass else: (dependency_data) _dependency_data_ptr_ = int(dependency_data) _dependency_data_len_ = len(dependency_data) cdef Py_ssize_t _num_dependencies_length_ = 0 cdef bint _num_dependencies_is_set_ = False if dependencies is not None: _num_dependencies_length_ = _cyb_check_same_length(_num_dependencies_is_set_, _num_dependencies_length_, _dependencies_len_, "dependencies", "dependencies, dependency_data") _num_dependencies_is_set_ = True if dependency_data is not None: _num_dependencies_length_ = _cyb_check_same_length(_num_dependencies_is_set_, _num_dependencies_length_, _dependency_data_len_, "dependency_data", "dependencies, dependency_data") _num_dependencies_is_set_ = True cdef size_t num_dependencies = _num_dependencies_length_ if num_dependencies != _num_dependencies_length_: raise OverflowError( f"The length of (dependencies, dependency_data), {_num_dependencies_length_}, does not fit in 'numDependencies' (a size_t)" ) with nogil: __status__ = cudaStreamUpdateCaptureDependencies(stream, (_dependencies_.data()), _dependency_data_ptr_, num_dependencies, flags) check_status(__status__) cpdef intptr_t event_create() except? 0: """Creates an event object. Creates an event object for the current device using ``cudaEventDefault``. Returns: intptr_t: Newly created event. .. seealso:: `cudaEventCreate` """ cdef cudaEvent_t event with nogil: __status__ = cudaEventCreate(&event) check_status(__status__) return event cpdef intptr_t event_create_with_flags(unsigned int flags) except? 0: """Creates an event object with the specified flags. Creates an event object for the current device with the specified flags. Valid flags include:. - ``cudaEventDefault``: Default event creation flag. - ``cudaEventBlockingSync``: Specifies that event should use blocking synchronization. A host thread that uses :func:`event_synchronize` to wait on an event created with this flag will block until the event actually completes. - ``cudaEventDisableTiming``: Specifies that the created event does not need to record timing data. Events created with this flag specified and the ``cudaEventBlockingSync`` flag not specified will provide the best performance when used with :func:`stream_wait_event` and :func:`event_query`. - ``cudaEventInterprocess``: Specifies that the created event may be used as an interprocess event by :func:`ipc_get_event_handle`. ``cudaEventInterprocess`` must be specified along with ``cudaEventDisableTiming``. Args: flags (unsigned int): Flags for new event. Returns: intptr_t: Newly created event. .. seealso:: `cudaEventCreateWithFlags` """ cdef cudaEvent_t event with nogil: __status__ = cudaEventCreateWithFlags(&event, flags) check_status(__status__) return event cpdef event_record(intptr_t event, intptr_t stream): """Records an event. Captures in ``event`` the contents of ``stream`` at the time of this call. ``event`` and ``stream`` must be on the same CUDA context. Calls such as :func:`event_query` or :func:`stream_wait_event` will then examine or wait for completion of the work that was captured. Uses of ``stream`` after this call do not modify ``event``. See note on default stream behavior for what is captured in the default case. :func:`event_record` can be called multiple times on the same event and will overwrite the previously captured state. Other APIs such as :func:`stream_wait_event` use the most recently captured state at the time of the API call, and are not affected by later calls to :func:`event_record`. Before the first call to :func:`event_record`, an event represents an empty set of work, so for example :func:`event_query` would return ``cudaSuccess``. Args: event (intptr_t): Event to record. stream (intptr_t): Stream in which to record event. .. seealso:: `cudaEventRecord` """ with nogil: __status__ = cudaEventRecord(event, stream) check_status(__status__) cpdef event_record_with_flags(intptr_t event, intptr_t stream, unsigned int flags): """Records an event. Captures in ``event`` the contents of ``stream`` at the time of this call. ``event`` and ``stream`` must be on the same CUDA context. Calls such as :func:`event_query` or :func:`stream_wait_event` will then examine or wait for completion of the work that was captured. Uses of ``stream`` after this call do not modify ``event``. See note on default stream behavior for what is captured in the default case. :func:`event_record_with_flags` can be called multiple times on the same event and will overwrite the previously captured state. Other APIs such as :func:`stream_wait_event` use the most recently captured state at the time of the API call, and are not affected by later calls to :func:`event_record_with_flags`. Before the first call to :func:`event_record_with_flags`, an event represents an empty set of work, so for example :func:`event_query` would return ``cudaSuccess``. flags include:. - ``cudaEventRecordDefault``: Default event creation flag. - ``cudaEventRecordExternal``: Event is captured in the graph as an external event node when performing stream capture. Args: event (intptr_t): Event to record. stream (intptr_t): Stream in which to record event. flags (unsigned int): Parameters for the operation(See above). .. seealso:: `cudaEventRecordWithFlags` """ with nogil: __status__ = cudaEventRecordWithFlags(event, stream, flags) check_status(__status__) cpdef event_query(intptr_t event): """Queries an event's status. Queries the status of all work currently captured by ``event``. See :func:`event_record` for details on what is captured by an event. Returns ``cudaSuccess`` if all captured work has been completed, or ``cudaErrorNotReady`` if any captured work is incomplete. For the purposes of Unified Memory, a return value of ``cudaSuccess`` is equivalent to having called :func:`event_synchronize`. Args: event (intptr_t): Event to query. .. seealso:: `cudaEventQuery` """ with nogil: __status__ = cudaEventQuery(event) check_status(__status__) cpdef event_query_no_raise(intptr_t event): """Queries an event's status. This is the ``no_raise`` variant of :func:`event_query`. Instead of raising an exception when the underlying C API call fails, it returns the raw status code. Queries the status of all work currently captured by ``event``. See :func:`event_record` for details on what is captured by an event. Returns ``cudaSuccess`` if all captured work has been completed, or ``cudaErrorNotReady`` if any captured work is incomplete. For the purposes of Unified Memory, a return value of ``cudaSuccess`` is equivalent to having called :func:`event_synchronize`. Args: event (intptr_t): Event to query. Returns: int: The raw status code returned by the underlying C API. .. seealso:: `cudaEventQuery` """ with nogil: __status__ = cudaEventQuery(event) return __status__ cpdef event_synchronize(intptr_t event): """Waits for an event to complete. Waits until the completion of all work currently captured in ``event``. See :func:`event_record` for details on what is captured by an event. Waiting for an event that was created with the ``cudaEventBlockingSync`` flag will cause the calling CPU thread to block until the event has been completed by the device. If the ``cudaEventBlockingSync`` flag has not been set, then the CPU thread will busy-wait until the event has been completed by the device. Args: event (intptr_t): Event to wait for. .. seealso:: `cudaEventSynchronize` """ with nogil: __status__ = cudaEventSynchronize(event) check_status(__status__) cpdef event_destroy(intptr_t event): """Destroys an event object. Destroys the event specified by ``event``. An event may be destroyed before it is complete (i.e., while :func:`event_query` would return ``cudaErrorNotReady``). In this case, the call does not block on completion of the event, and any associated resources will automatically be released asynchronously at completion. Args: event (intptr_t): Event to destroy. .. seealso:: `cudaEventDestroy` """ with nogil: __status__ = cudaEventDestroy(event) check_status(__status__) cpdef float event_elapsed_time(intptr_t start, intptr_t end) except? -1.0: """Computes the elapsed time between events. Computes the elapsed time between two events (in milliseconds with a resolution of around 0.5 microseconds). Note this API is not guaranteed to return the latest errors for pending work. As such this API is intended to serve as a elapsed time calculation only and polling for completion on the events to be compared should be done with ``cudaEventQuery`` instead. If either event was last recorded in a non-NULL stream, the resulting time may be greater than expected (even if both used the same stream handle). This happens because the :func:`event_record` operation takes place asynchronously and there is no guarantee that the measured latency is actually just between the two events. Any number of other different stream operations could execute in between the two measured events, thus altering the timing in a significant way. If :func:`event_record` has not been called on either event, then ``cudaErrorInvalidResourceHandle`` is returned. If :func:`event_record` has been called on both events but one or both of them has not yet been completed (that is, :func:`event_query` would return ``cudaErrorNotReady`` on at least one of the events), ``cudaErrorNotReady`` is returned. If either event was created with the ``cudaEventDisableTiming`` flag, then this function will return ``cudaErrorInvalidResourceHandle``. Args: start (intptr_t): Starting event. end (intptr_t): Ending event. Returns: float: Time between ``start`` and ``end`` in ms. .. seealso:: `cudaEventElapsedTime` """ cdef float ms with nogil: __status__ = cudaEventElapsedTime(&ms, start, end) check_status(__status__) return ms cpdef intptr_t import_external_memory(mem_handle_desc) except? 0: """Imports an external memory object. Imports an externally allocated memory object and returns a handle to that in ``ext_mem_out``. The properties of the handle being imported must be described in ``mem_handle_desc``. The ``cudaExternalMemoryHandleDesc`` structure is defined as follows:. \*\*View CUDA Toolkit Documentation for a C++ code example*\*. where ``cudaExternalMemoryHandleDesc.type`` specifies the type of handle being imported. ``cudaExternalMemoryHandleType`` is defined as:. \*\*View CUDA Toolkit Documentation for a C++ code example*\*. If ``cudaExternalMemoryHandleDesc.type`` is ``cudaExternalMemoryHandleTypeOpaqueFd``, then ``cudaExternalMemoryHandleDesc.handle.fd`` must be a valid file descriptor referencing a memory object. Ownership of the file descriptor is transferred to the CUDA driver when the handle is imported successfully. Performing any operations on the file descriptor after it is imported results in undefined behavior. If ``cudaExternalMemoryHandleDesc.type`` is ``cudaExternalMemoryHandleTypeOpaqueWin32``, then exactly one of ``cudaExternalMemoryHandleDesc.handle.win32.handle`` and ``cudaExternalMemoryHandleDesc.handle.win32.name`` must not be NULL. If ``cudaExternalMemoryHandleDesc.handle.win32.handle`` is not NULL, then it must represent a valid shared NT handle that references a memory object. Ownership of this handle is not transferred to CUDA after the import operation, so the application must release the handle using the appropriate system call. If ``cudaExternalMemoryHandleDesc.handle.win32.name`` is not NULL, then it must point to a NULL-terminated array of UTF-16 characters that refers to a memory object. If ``cudaExternalMemoryHandleDesc.type`` is ``cudaExternalMemoryHandleTypeOpaqueWin32Kmt``, then ``cudaExternalMemoryHandleDesc.handle.win32.handle`` must be non-NULL and ``cudaExternalMemoryHandleDesc.handle.win32.name`` must be NULL. The handle specified must be a globally shared KMT handle. This handle does not hold a reference to the underlying object, and thus will be invalid when all references to the memory object are destroyed. If ``cudaExternalMemoryHandleDesc.type`` is ``cudaExternalMemoryHandleTypeD3D12Heap``, then exactly one of ``cudaExternalMemoryHandleDesc.handle.win32.handle`` and ``cudaExternalMemoryHandleDesc.handle.win32.name`` must not be NULL. If ``cudaExternalMemoryHandleDesc.handle.win32.handle`` is not NULL, then it must represent a valid shared NT handle that is returned by ``ID3D12Device.CreateSharedHandle`` when referring to a ID3D12Heap object. This handle holds a reference to the underlying object. If ``cudaExternalMemoryHandleDesc.handle.win32.name`` is not NULL, then it must point to a NULL-terminated array of UTF-16 characters that refers to a ID3D12Heap object. If ``cudaExternalMemoryHandleDesc.type`` is ``cudaExternalMemoryHandleTypeD3D12Resource``, then exactly one of ``cudaExternalMemoryHandleDesc.handle.win32.handle`` and ``cudaExternalMemoryHandleDesc.handle.win32.name`` must not be NULL. If ``cudaExternalMemoryHandleDesc.handle.win32.handle`` is not NULL, then it must represent a valid shared NT handle that is returned by ``ID3D12Device.CreateSharedHandle`` when referring to a ID3D12Resource object. This handle holds a reference to the underlying object. If ``cudaExternalMemoryHandleDesc.handle.win32.name`` is not NULL, then it must point to a NULL-terminated array of UTF-16 characters that refers to a ID3D12Resource object. If ``cudaExternalMemoryHandleDesc.type`` is ``cudaExternalMemoryHandleTypeD3D11Resource``,then exactly one of ``cudaExternalMemoryHandleDesc.handle.win32.handle`` and ``cudaExternalMemoryHandleDesc.handle.win32.name`` must not be NULL. If ``cudaExternalMemoryHandleDesc.handle.win32.handle`` is not NULL, then it must represent a valid shared NT handle that is returned by ``IDXGIResource1.CreateSharedHandle`` when referring to a ID3D11Resource object. If ``cudaExternalMemoryHandleDesc.handle.win32.name`` is not NULL, then it must point to a NULL-terminated array of UTF-16 characters that refers to a ID3D11Resource object. If ``cudaExternalMemoryHandleDesc.type`` is ``cudaExternalMemoryHandleTypeD3D11ResourceKmt``, then ``cudaExternalMemoryHandleDesc.handle.win32.handle`` must be non-NULL and ``cudaExternalMemoryHandleDesc.handle.win32.name`` must be NULL. The handle specified must be a valid shared KMT handle that is returned by ``IDXGIResource.GetSharedHandle`` when referring to a ID3D11Resource object. If ``cudaExternalMemoryHandleDesc.type`` is ``cudaExternalMemoryHandleTypeNvSciBuf``, then ``cudaExternalMemoryHandleDesc.handle.nvSciBufObject`` must be NON-NULL and reference a valid NvSciBuf object. If the NvSciBuf object imported into CUDA is also mapped by other drivers, then the application must use ``cudaWaitExternalSemaphoresAsync`` or ``cudaSignalExternalSemaphoresAsync`` as approprriate barriers to maintain coherence between CUDA and the other drivers. See ``cudaExternalSemaphoreWaitSkipNvSciBufMemSync`` and ``cudaExternalSemaphoreSignalSkipNvSciBufMemSync`` for memory synchronization. The size of the memory object must be specified in ``cudaExternalMemoryHandleDesc.size``. Specifying the flag ``cudaExternalMemoryDedicated`` in ``cudaExternalMemoryHandleDesc.flags`` indicates that the resource is a dedicated resource. The definition of what a dedicated resource is outside the scope of this extension. This flag must be set if ``cudaExternalMemoryHandleDesc.type`` is one of the following: ``cudaExternalMemoryHandleTypeD3D12Resource`` ``cudaExternalMemoryHandleTypeD3D11Resource`` ``cudaExternalMemoryHandleTypeD3D11ResourceKmt``. Args: mem_handle_desc (intptr_t): Memory import handle descriptor. Returns: intptr_t: Returned handle to an external memory object. .. note:: If the Vulkan memory imported into CUDA is mapped on the CPU then the application must use vkInvalidateMappedMemoryRanges/vkFlushMappedMemoryRanges as well as appropriate Vulkan pipeline barriers to maintain coherence between CPU and GPU. For more information on these APIs, please refer to "Synchronization and Cache Control" chapter from Vulkan specification. .. seealso:: `cudaImportExternalMemory` """ cdef intptr_t _mem_handle_desc_ptr_ = 0 if mem_handle_desc is None else int(mem_handle_desc) cdef cudaExternalMemory_t ext_mem_out with nogil: __status__ = cudaImportExternalMemory(&ext_mem_out, _mem_handle_desc_ptr_) check_status(__status__) return ext_mem_out cpdef intptr_t external_memory_get_mapped_buffer(intptr_t ext_mem, buffer_desc) except? 0: """Maps a buffer onto an imported memory object. Maps a buffer onto an imported memory object and returns a device pointer in ``dev_ptr``. The properties of the buffer being mapped must be described in ``buffer_desc``. The ``cudaExternalMemoryBufferDesc`` structure is defined as follows:. \*\*View CUDA Toolkit Documentation for a C++ code example*\*. where ``cudaExternalMemoryBufferDesc.offset`` is the offset in the memory object where the buffer's base address is. ``cudaExternalMemoryBufferDesc.size`` is the size of the buffer. ``cudaExternalMemoryBufferDesc.flags`` must be zero. The offset and size have to be suitably aligned to match the requirements of the external API. Mapping two buffers whose ranges overlap may or may not result in the same virtual address being returned for the overlapped portion. In such cases, the application must ensure that all accesses to that region from the GPU are volatile. Otherwise writes made via one address are not guaranteed to be visible via the other address, even if they're issued by the same thread. It is recommended that applications map the combined range instead of mapping separate buffers and then apply the appropriate offsets to the returned pointer to derive the individual buffers. The returned pointer ``dev_ptr`` must be freed using ``cudaFree``. Args: ext_mem (intptr_t): Handle to external memory object. buffer_desc (intptr_t): Buffer descriptor. Returns: intptr_t: Returned device pointer to buffer. .. seealso:: `cudaExternalMemoryGetMappedBuffer` """ cdef intptr_t _buffer_desc_ptr_ = 0 if buffer_desc is None else int(buffer_desc) cdef void* dev_ptr with nogil: __status__ = cudaExternalMemoryGetMappedBuffer(&dev_ptr, ext_mem, _buffer_desc_ptr_) check_status(__status__) return dev_ptr cpdef intptr_t external_memory_get_mapped_mipmapped_array(intptr_t ext_mem, mipmap_desc) except? 0: """Maps a CUDA mipmapped array onto an external memory object. Maps a CUDA mipmapped array onto an external object and returns a handle to it in ``mipmap``. The properties of the CUDA mipmapped array being mapped must be described in ``mipmap_desc``. The structure ``cudaExternalMemoryMipmappedArrayDesc`` is defined as follows:. \*\*View CUDA Toolkit Documentation for a C++ code example*\*. where ``cudaExternalMemoryMipmappedArrayDesc.offset`` is the offset in the memory object where the base level of the mipmap chain is. ``cudaExternalMemoryMipmappedArrayDesc.formatDesc`` describes the format of the data. ``cudaExternalMemoryMipmappedArrayDesc.extent`` specifies the dimensions of the base level of the mipmap chain. ``cudaExternalMemoryMipmappedArrayDesc.flags`` are flags associated with CUDA mipmapped arrays. For further details, please refer to the documentation for ``cudaMalloc3DArray``. Note that if the mipmapped array is bound as a color target in the graphics API, then the flag ``cudaArrayColorAttachment`` must be specified in ``cudaExternalMemoryMipmappedArrayDesc.flags``. ``cudaExternalMemoryMipmappedArrayDesc.numLevels`` specifies the total number of levels in the mipmap chain. The returned CUDA mipmapped array must be freed using ``cudaFreeMipmappedArray``. Args: ext_mem (intptr_t): Handle to external memory object. mipmap_desc (intptr_t): CUDA array descriptor. Returns: intptr_t: Returned CUDA mipmapped array. .. note:: If ``cudaExternalMemoryHandleDesc.type`` is ``cudaExternalMemoryHandleTypeNvSciBuf``, then ``cudaExternalMemoryMipmappedArrayDesc.numLevels`` must not be greater than 1. .. seealso:: `cudaExternalMemoryGetMappedMipmappedArray` """ cdef intptr_t _mipmap_desc_ptr_ = 0 if mipmap_desc is None else int(mipmap_desc) cdef cudaMipmappedArray_t mipmap with nogil: __status__ = cudaExternalMemoryGetMappedMipmappedArray(&mipmap, ext_mem, _mipmap_desc_ptr_) check_status(__status__) return mipmap cpdef destroy_external_memory(intptr_t ext_mem): """Destroys an external memory object. Destroys the specified external memory object. Any existing buffers and CUDA mipmapped arrays mapped onto this object must no longer be used and must be explicitly freed using ``cudaFree`` and ``cudaFreeMipmappedArray`` respectively. Args: ext_mem (intptr_t): External memory object to be destroyed. .. seealso:: `cudaDestroyExternalMemory` """ with nogil: __status__ = cudaDestroyExternalMemory(ext_mem) check_status(__status__) cpdef intptr_t import_external_semaphore(sem_handle_desc) except? 0: """Imports an external semaphore. Imports an externally allocated synchronization object and returns a handle to that in ``ext_sem_out``. The properties of the handle being imported must be described in ``sem_handle_desc``. The ``cudaExternalSemaphoreHandleDesc`` is defined as follows:. \*\*View CUDA Toolkit Documentation for a C++ code example*\*. where ``cudaExternalSemaphoreHandleDesc.type`` specifies the type of handle being imported. ``cudaExternalSemaphoreHandleType`` is defined as:. \*\*View CUDA Toolkit Documentation for a C++ code example*\*. If ``cudaExternalSemaphoreHandleDesc.type`` is ``cudaExternalSemaphoreHandleTypeOpaqueFd``, then ``cudaExternalSemaphoreHandleDesc.handle.fd`` must be a valid file descriptor referencing a synchronization object. Ownership of the file descriptor is transferred to the CUDA driver when the handle is imported successfully. Performing any operations on the file descriptor after it is imported results in undefined behavior. If ``cudaExternalSemaphoreHandleDesc.type`` is ``cudaExternalSemaphoreHandleTypeOpaqueWin32``, then exactly one of ``cudaExternalSemaphoreHandleDesc.handle.win32.handle`` and ``cudaExternalSemaphoreHandleDesc.handle.win32.name`` must not be NULL. If ``cudaExternalSemaphoreHandleDesc.handle.win32.handle`` is not NULL, then it must represent a valid shared NT handle that references a synchronization object. Ownership of this handle is not transferred to CUDA after the import operation, so the application must release the handle using the appropriate system call. If ``cudaExternalSemaphoreHandleDesc.handle.win32.name`` is not NULL, then it must name a valid synchronization object. If ``cudaExternalSemaphoreHandleDesc.type`` is ``cudaExternalSemaphoreHandleTypeOpaqueWin32Kmt``, then ``cudaExternalSemaphoreHandleDesc.handle.win32.handle`` must be non-NULL and ``cudaExternalSemaphoreHandleDesc.handle.win32.name`` must be NULL. The handle specified must be a globally shared KMT handle. This handle does not hold a reference to the underlying object, and thus will be invalid when all references to the synchronization object are destroyed. If ``cudaExternalSemaphoreHandleDesc.type`` is ``cudaExternalSemaphoreHandleTypeD3D12Fence``, then exactly one of ``cudaExternalSemaphoreHandleDesc.handle.win32.handle`` and ``cudaExternalSemaphoreHandleDesc.handle.win32.name`` must not be NULL. If ``cudaExternalSemaphoreHandleDesc.handle.win32.handle`` is not NULL, then it must represent a valid shared NT handle that is returned by ``ID3D12Device.CreateSharedHandle`` when referring to a ID3D12Fence object. This handle holds a reference to the underlying object. If ``cudaExternalSemaphoreHandleDesc.handle.win32.name`` is not NULL, then it must name a valid synchronization object that refers to a valid ID3D12Fence object. If ``cudaExternalSemaphoreHandleDesc.type`` is ``cudaExternalSemaphoreHandleTypeD3D11Fence``, then exactly one of ``cudaExternalSemaphoreHandleDesc.handle.win32.handle`` and ``cudaExternalSemaphoreHandleDesc.handle.win32.name`` must not be NULL. If ``cudaExternalSemaphoreHandleDesc.handle.win32.handle`` is not NULL, then it must represent a valid shared NT handle that is returned by ``ID3D11Fence.CreateSharedHandle``. If ``cudaExternalSemaphoreHandleDesc.handle.win32.name`` is not NULL, then it must name a valid synchronization object that refers to a valid ID3D11Fence object. If ``cudaExternalSemaphoreHandleDesc.type`` is ``cudaExternalSemaphoreHandleTypeNvSciSync``, then ``cudaExternalSemaphoreHandleDesc.handle.nvSciSyncObj`` represents a valid NvSciSyncObj. ``cudaExternalSemaphoreHandleTypeKeyedMutex``, then exactly one of ``cudaExternalSemaphoreHandleDesc.handle.win32.handle`` and ``cudaExternalSemaphoreHandleDesc.handle.win32.name`` must not be NULL. If ``cudaExternalSemaphoreHandleDesc.handle.win32.handle`` is not NULL, then it represent a valid shared NT handle that is returned by ``IDXGIResource1.CreateSharedHandle`` when referring to a IDXGIKeyedMutex object. If ``cudaExternalSemaphoreHandleDesc.type`` is ``cudaExternalSemaphoreHandleTypeKeyedMutexKmt``, then ``cudaExternalSemaphoreHandleDesc.handle.win32.handle`` must be non-NULL and ``cudaExternalSemaphoreHandleDesc.handle.win32.name`` must be NULL. The handle specified must represent a valid KMT handle that is returned by ``IDXGIResource.GetSharedHandle`` when referring to a IDXGIKeyedMutex object. If ``cudaExternalSemaphoreHandleDesc.type`` is ``cudaExternalSemaphoreHandleTypeTimelineSemaphoreFd``, then ``cudaExternalSemaphoreHandleDesc.handle.fd`` must be a valid file descriptor referencing a synchronization object. Ownership of the file descriptor is transferred to the CUDA driver when the handle is imported successfully. Performing any operations on the file descriptor after it is imported results in undefined behavior. If ``cudaExternalSemaphoreHandleDesc.type`` is ``cudaExternalSemaphoreHandleTypeTimelineSemaphoreWin32``, then exactly one of ``cudaExternalSemaphoreHandleDesc.handle.win32.handle`` and ``cudaExternalSemaphoreHandleDesc.handle.win32.name`` must not be NULL. If ``cudaExternalSemaphoreHandleDesc.handle.win32.handle`` is not NULL, then it must represent a valid shared NT handle that references a synchronization object. Ownership of this handle is not transferred to CUDA after the import operation, so the application must release the handle using the appropriate system call. If ``cudaExternalSemaphoreHandleDesc.handle.win32.name`` is not NULL, then it must name a valid synchronization object. Args: sem_handle_desc (intptr_t): Semaphore import handle descriptor. Returns: intptr_t: Returned handle to an external semaphore. .. seealso:: `cudaImportExternalSemaphore` """ cdef intptr_t _sem_handle_desc_ptr_ = 0 if sem_handle_desc is None else int(sem_handle_desc) cdef cudaExternalSemaphore_t ext_sem_out with nogil: __status__ = cudaImportExternalSemaphore(&ext_sem_out, _sem_handle_desc_ptr_) check_status(__status__) return ext_sem_out cpdef destroy_external_semaphore(intptr_t ext_sem): """Destroys an external semaphore. Destroys an external semaphore object and releases any references to the underlying resource. Any outstanding signals or waits must have completed before the semaphore is destroyed. Args: ext_sem (intptr_t): External semaphore to be destroyed. .. seealso:: `cudaDestroyExternalSemaphore` """ with nogil: __status__ = cudaDestroyExternalSemaphore(ext_sem) check_status(__status__) cpdef func_set_cache_config(intptr_t func, int cache_config): """Sets the preferred cache configuration for a device function. On devices where the L1 cache and shared memory use the same hardware resources, this sets through ``cache_config`` the preferred cache configuration for the function specified via ``func``. This is only a preference. The runtime will use the requested configuration if possible, but it is free to choose a different configuration if required to execute ``func``. ``func`` is a device function symbol and must be declared as a ``__global__`` function. If the specified function does not exist, then ``cudaErrorInvalidDeviceFunction`` is returned. For templated functions, pass the function symbol as follows: func_name. This setting does nothing on devices where the size of the L1 cache and shared memory are fixed. Launching a kernel with a different preference than the most recent preference setting may insert a device-side synchronization point. The supported cache configurations are:. - ``cudaFuncCachePreferNone``: no preference for shared memory or L1 (default). - ``cudaFuncCachePreferShared``: prefer larger shared memory and smaller L1 cache. - ``cudaFuncCachePreferL1``: prefer larger L1 cache and smaller shared memory. - ``cudaFuncCachePreferEqual``: prefer equal size L1 cache and shared memory. Args: func (intptr_t): Device function symbol. cache_config (FuncCache): Requested cache configuration. .. note:: This API does not accept a ``cudaKernel_t`` casted as void*. If cache config modification is required for a ``cudaKernel_t`` (or a global function), it can be replaced with a call to ``cudaFuncSetAttributes`` with the attribute ``cudaFuncAttributePreferredSharedMemoryCarveout`` to specify a more granular L1 cache and shared memory split configuration. .. seealso:: `cudaFuncSetCacheConfig` """ with nogil: __status__ = cudaFuncSetCacheConfig(func, cache_config) check_status(__status__) cpdef object func_get_attributes(intptr_t func): """Find out attributes for a given function. This function obtains the attributes of a function specified via ``func``. ``func`` is a device function symbol and must be declared as a ``__global__`` function. The fetched attributes are placed in ``attr``. If the specified function does not exist, then it is assumed to be a ``cudaKernel_t`` and used as is. For templated functions, pass the function symbol as follows: func_name. Note that some function attributes such as ``maxThreadsPerBlock`` may vary based on the device that is currently being used. Args: func (intptr_t): Device function symbol. Returns: cudaFuncAttributes: Return pointer to function's attributes. .. seealso:: `cudaFuncGetAttributes` """ cdef FuncAttributes attr_py = FuncAttributes() cdef cudaFuncAttributes *attr = (attr_py._get_ptr()) with nogil: __status__ = cudaFuncGetAttributes(attr, func) check_status(__status__) return attr_py cpdef func_set_attribute(intptr_t func, int attr, int value): """Set attributes for a given function. This function sets the attributes of a function specified via ``func``. The parameter ``func`` must be a pointer to a function that executes on the device. The parameter specified by ``func`` must be declared as a ``__global__`` function. The enumeration defined by ``attr`` is set to the value defined by ``value``. If the specified function does not exist, then it is assumed to be a ``cudaKernel_t`` and used as is. If the specified attribute cannot be written, or if the value is incorrect, then ``cudaErrorInvalidValue`` is returned. Valid values for ``attr`` are:. - ``cudaFuncAttributeMaxDynamicSharedMemorySize`` - The requested maximum size in bytes of dynamically-allocated shared memory. The sum of this value and the function attribute ``sharedSizeBytes`` cannot exceed the device attribute ``cudaDevAttrMaxSharedMemoryPerBlockOptin``. The maximal size of requestable dynamic shared memory may differ by GPU architecture. - ``cudaFuncAttributePreferredSharedMemoryCarveout`` - On devices where the L1 cache and shared memory use the same hardware resources, this sets the shared memory carveout preference, in percent of the total shared memory. See ``cudaDevAttrMaxSharedMemoryPerMultiprocessor``. This is only a hint, and the driver can choose a different ratio if required to execute the function. - ``cudaFuncAttributeRequiredClusterWidth``: The required cluster width in blocks. The width, height, and depth values must either all be 0 or all be positive. The validity of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime. Setting it at runtime will return cudaErrorNotPermitted. - ``cudaFuncAttributeRequiredClusterHeight``: The required cluster height in blocks. The width, height, and depth values must either all be 0 or all be positive. The validity of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime. Setting it at runtime will return cudaErrorNotPermitted. - ``cudaFuncAttributeRequiredClusterDepth``: The required cluster depth in blocks. The width, height, and depth values must either all be 0 or all be positive. The validity of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime. Setting it at runtime will return cudaErrorNotPermitted. - ``cudaFuncAttributeNonPortableClusterSizeAllowed``: Indicates whether the function can be launched with non-portable cluster size. 1 is allowed, 0 is disallowed. - ``cudaFuncAttributeClusterSchedulingPolicyPreference``: The block scheduling policy of a function. The value type is ``cudaClusterSchedulingPolicy``. cudaLaunchKernel (C++ API), cudaFuncSetCacheConfig (C++ API), ``cudaFuncGetAttributes (C API)``,. Args: func (intptr_t): Function to get attributes of. attr (FuncAttribute): Attribute to set. value (int): Value to set. .. seealso:: `cudaFuncSetAttribute` """ with nogil: __status__ = cudaFuncSetAttribute(func, attr, value) check_status(__status__) cpdef bytes func_get_name(intptr_t func): """Returns the function name for a device entry function pointer. Returns in ``**name`` the function name associated with the symbol ``func`` . The function name is returned as a null-terminated string. This API may return a mangled name if the function is not declared as having C linkage. If ``**name`` is NULL, ``cudaErrorInvalidValue`` is returned. If ``func`` is not a device entry function, then it is assumed to be a ``cudaKernel_t`` and used as is. cudaFuncGetName (C++ API). Args: func (intptr_t): The function pointer to retrieve name for. Returns: bytes: The returned name of the function. .. seealso:: `cudaFuncGetName` """ cdef const char* name = NULL with nogil: __status__ = cudaFuncGetName(&name, func) check_status(__status__) return (name) if name != NULL else b"" cpdef tuple func_get_param_info(intptr_t func, size_t param_index): """Returns the offset and size of a kernel parameter in the device-side parameter layout. Queries the kernel parameter at ``param_index`` in ``func's`` list of parameters and returns parameter information via ``param_offset`` and ``param_size``. ``param_offset`` returns the offset of the parameter in the device-side parameter layout. ``param_size`` returns the size in bytes of the parameter. This information can be used to update kernel node parameters from the device via ``cudaGraphKernelNodeSetParam()`` and ``cudaGraphKernelNodeUpdatesApply()``. ``param_index`` must be less than the number of parameters that ``func`` takes. Args: func (intptr_t): The function to query. param_index (size_t): The parameter index to query. Returns: A 2-tuple containing: - size_t: The offset into the device-side parameter layout at which the parameter resides. - size_t: The size of the parameter in the device-side parameter layout. .. seealso:: `cudaFuncGetParamInfo` """ cdef size_t param_offset cdef size_t param_size with nogil: __status__ = cudaFuncGetParamInfo(func, param_index, ¶m_offset, ¶m_size) check_status(__status__) return (param_offset, param_size) cpdef launch_host_func(intptr_t stream, intptr_t fn, intptr_t user_data): """Enqueues a host function call in a stream. Enqueues a host function to run in a stream. The function will be called after currently enqueued work and will block work added after it. The host function must not make any CUDA API calls. Attempting to use a CUDA API may result in ``cudaErrorNotPermitted``, but this is not required. The host function must not perform any synchronization that may depend on outstanding CUDA work not mandated to run earlier. Host functions without a mandated order (such as in independent streams) execute in undefined order and may be serialized. For the purposes of Unified Memory, execution makes a number of guarantees:. - The stream is considered idle for the duration of the function's execution. Thus, for example, the function may always use memory attached to the stream it was enqueued in. - The start of execution of the function has the same effect as synchronizing an event recorded in the same stream immediately prior to the function. It thus synchronizes streams which have been "joined" prior to the function. - Adding device work to any stream does not have the effect of making the stream active until all preceding host functions and stream callbacks have executed. Thus, for example, a function might use global attached memory even if work has been added to another stream, if the work has been ordered behind the function call with an event. - Completion of the function does not cause a stream to become active except as described above. The stream will remain idle if no device work follows the function, and will remain idle across consecutive host functions or stream callbacks without device work in between. Thus, for example, stream synchronization can be done by signaling from a host function at the end of the stream. Note that, in constrast to ``cuStreamAddCallback``, the function will not be called in the event of an error in the CUDA context. Args: stream (intptr_t): Stream to enqueue function call in. fn (intptr_t): The function to call once preceding stream operations are complete. user_data (intptr_t): User-specified data to be passed to the function. .. seealso:: `cudaLaunchHostFunc` """ with nogil: __status__ = cudaLaunchHostFunc(stream, fn, user_data) check_status(__status__) cpdef func_set_shared_mem_config(intptr_t func, int config): """Sets the shared memory configuration for a device function. [Deprecated]. On devices with configurable shared memory banks, this function will force all subsequent launches of the specified device function to have the given shared memory bank size configuration. On any given launch of the function, the shared memory configuration of the device will be temporarily changed if needed to suit the function's preferred configuration. Changes in shared memory configuration between subsequent launches of functions, may introduce a device side synchronization point. Any per-function setting of shared memory bank size set via ``cudaFuncSetSharedMemConfig`` will override the device wide setting set by ``cudaDeviceSetSharedMemConfig``. Changing the shared memory bank size will not increase shared memory usage or affect occupancy of kernels, but may have major effects on performance. Larger bank sizes will allow for greater potential bandwidth to shared memory, but will change what kinds of accesses to shared memory will result in bank conflicts. This function will do nothing on devices with fixed shared memory bank size. For templated functions, pass the function symbol as follows: func_name. The supported bank configurations are:. - ``cudaSharedMemBankSizeDefault``: use the device's shared memory configuration when launching this function. - ``cudaSharedMemBankSizeFourByte``: set shared memory bank width to be four bytes natively when launching this function. - ``cudaSharedMemBankSizeEightByte``: set shared memory bank width to be eight bytes natively when launching this function. Args: func (intptr_t): Device function symbol. config (SharedMemConfig): Requested shared memory configuration. .. seealso:: `cudaFuncSetSharedMemConfig` """ with nogil: __status__ = cudaFuncSetSharedMemConfig(func, config) check_status(__status__) cpdef int occupancy_max_active_blocks_per_multiprocessor(intptr_t func, int block_size, size_t dynamic_s_mem_size) except? -1: """Returns occupancy for a device function. Returns in ``*num_blocks`` the maximum number of active blocks per streaming multiprocessor for the device function. Args: func (intptr_t): Kernel function for which occupancy is calculated. block_size (int): Block size the kernel is intended to be launched with. dynamic_s_mem_size (size_t): Per-block dynamic shared memory usage intended, in bytes. Returns: int: Returned occupancy. .. seealso:: `cudaOccupancyMaxActiveBlocksPerMultiprocessor` """ cdef int num_blocks with nogil: __status__ = cudaOccupancyMaxActiveBlocksPerMultiprocessor(&num_blocks, func, block_size, dynamic_s_mem_size) check_status(__status__) return num_blocks cpdef size_t occupancy_available_dynamic_smem_per_block(intptr_t func, int num_blocks, int block_size) except? 0: """Returns dynamic shared memory available per block when launching ``num_blocks`` blocks on SM. Returns in ``*dynamic_smem_size`` the maximum size of dynamic shared memory to allow ``num_blocks`` blocks per SM. Args: func (intptr_t): Kernel function for which occupancy is calculated. num_blocks (int): Number of blocks to fit on SM. block_size (int): Size of the block. Returns: size_t: Returned maximum dynamic shared memory. .. seealso:: `cudaOccupancyAvailableDynamicSMemPerBlock` """ cdef size_t dynamic_smem_size with nogil: __status__ = cudaOccupancyAvailableDynamicSMemPerBlock(&dynamic_smem_size, func, num_blocks, block_size) check_status(__status__) return dynamic_smem_size cpdef int occupancy_max_active_blocks_per_multiprocessor_with_flags(intptr_t func, int block_size, size_t dynamic_s_mem_size, unsigned int flags) except? -1: """Returns occupancy for a device function with the specified flags. Returns in ``*num_blocks`` the maximum number of active blocks per streaming multiprocessor for the device function. The ``flags`` parameter controls how special cases are handled. Valid flags include:. - ``cudaOccupancyDefault``: keeps the default behavior as ``cudaOccupancyMaxActiveBlocksPerMultiprocessor``. - ``cudaOccupancyDisableCachingOverride``: This flag suppresses the default behavior on platform where global caching affects occupancy. On such platforms, if caching is enabled, but per-block SM resource usage would result in zero occupancy, the occupancy calculator will calculate the occupancy as if caching is disabled. Setting this flag makes the occupancy calculator to return 0 in such cases. More information can be found about this feature in the "Unified L1/Texture Cache" section of the Maxwell tuning guide. Args: func (intptr_t): Kernel function for which occupancy is calculated. block_size (int): Block size the kernel is intended to be launched with. dynamic_s_mem_size (size_t): Per-block dynamic shared memory usage intended, in bytes. flags (unsigned int): Requested behavior for the occupancy calculator. Returns: int: Returned occupancy. .. seealso:: `cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags` """ cdef int num_blocks with nogil: __status__ = cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(&num_blocks, func, block_size, dynamic_s_mem_size, flags) check_status(__status__) return num_blocks cpdef intptr_t malloc_managed(size_t size, unsigned int flags) except? 0: """Allocates memory that will be automatically managed by the Unified Memory system. Allocates ``size`` bytes of managed memory on the device and returns in ``*dev_ptr`` a pointer to the allocated memory. If the device doesn't support allocating managed memory, ``cudaErrorNotSupported`` is returned. Support for managed memory can be queried using the device attribute ``cudaDevAttrManagedMemory``. The allocated memory is suitably aligned for any kind of variable. The memory is not cleared. If ``size`` is 0, ``cudaMallocManaged`` returns ``cudaErrorInvalidValue``. The pointer is valid on the CPU and on all GPUs in the system that support managed memory. All accesses to this pointer must obey the Unified Memory programming model. ``flags`` specifies the default stream association for this allocation. ``flags`` must be one of ``cudaMemAttachGlobal`` or ``cudaMemAttachHost``. The default value for ``flags`` is ``cudaMemAttachGlobal``. If ``cudaMemAttachGlobal`` is specified, then this memory is accessible from any stream on any device. If ``cudaMemAttachHost`` is specified, then the allocation should not be accessed from devices that have a zero value for the device attribute ``cudaDevAttrConcurrentManagedAccess``; an explicit call to ``cudaStreamAttachMemAsync`` will be required to enable access on such devices. If the association is later changed via ``cudaStreamAttachMemAsync`` to a single stream, the default association, as specifed during ``cudaMallocManaged``, is restored when that stream is destroyed. For managed variables, the default association is always ``cudaMemAttachGlobal``. Note that destroying a stream is an asynchronous operation, and as a result, the change to default association won't happen until all work in the stream has completed. Memory allocated with ``cudaMallocManaged`` should be released with ``cudaFree``. Device memory oversubscription is possible for GPUs that have a non-zero value for the device attribute ``cudaDevAttrConcurrentManagedAccess``. Managed memory on such GPUs may be evicted from device memory to host memory at any time by the Unified Memory driver in order to make room for other allocations. In a system where all GPUs have a non-zero value for the device attribute ``cudaDevAttrConcurrentManagedAccess``, managed memory may not be populated when this API returns and instead may be populated on access. In such systems, managed memory can migrate to any processor's memory at any time. The Unified Memory driver will employ heuristics to maintain data locality and prevent excessive page faults to the extent possible. The application can also guide the driver about memory usage patterns via ``cudaMemAdvise``. The application can also explicitly migrate memory to a desired processor's memory via ``cudaMemPrefetchAsync``. In a multi-GPU system where all of the GPUs have a zero value for the device attribute ``cudaDevAttrConcurrentManagedAccess`` and all the GPUs have peer-to-peer support with each other, the physical storage for managed memory is created on the GPU which is active at the time ``cudaMallocManaged`` is called. All other GPUs will reference the data at reduced bandwidth via peer mappings over the PCIe bus. The Unified Memory driver does not migrate memory among such GPUs. In a multi-GPU system where not all GPUs have peer-to-peer support with each other and where the value of the device attribute ``cudaDevAttrConcurrentManagedAccess`` is zero for at least one of those GPUs, the location chosen for physical storage of managed memory is system-dependent. - On Linux, the location chosen will be device memory as long as the current set of active contexts are on devices that either have peer-to-peer support with each other or have a non-zero value for the device attribute ``cudaDevAttrConcurrentManagedAccess``. If there is an active context on a GPU that does not have a non-zero value for that device attribute and it does not have peer-to-peer support with the other devices that have active contexts on them, then the location for physical storage will be 'zero-copy' or host memory. Note that this means that managed memory that is located in device memory is migrated to host memory if a new context is created on a GPU that doesn't have a non-zero value for the device attribute and does not support peer-to-peer with at least one of the other devices that has an active context. This in turn implies that context creation may fail if there is insufficient host memory to migrate all managed allocations. - On Windows, the physical storage is always created in 'zero-copy' or host memory. All GPUs will reference the data at reduced bandwidth over the PCIe bus. In these circumstances, use of the environment variable CUDA_VISIBLE_DEVICES is recommended to restrict CUDA to only use those GPUs that have peer-to-peer support. Alternatively, users can also set CUDA_MANAGED_FORCE_DEVICE_ALLOC to a non-zero value to force the driver to always use device memory for physical storage. When this environment variable is set to a non-zero value, all devices used in that process that support managed memory have to be peer-to-peer compatible with each other. The error ``cudaErrorInvalidDevice`` will be returned if a device that supports managed memory is used and it is not peer-to-peer compatible with any of the other managed memory supporting devices that were previously used in that process, even if ``cudaDeviceReset`` has been called on those devices. These environment variables are described in the CUDA programming guide under the "CUDA environment variables" section. Args: size (size_t): Requested allocation size in bytes. flags (unsigned int): Must be either ``cudaMemAttachGlobal`` or ``cudaMemAttachHost`` (defaults to ``cudaMemAttachGlobal``). Returns: intptr_t: Pointer to allocated device memory. .. seealso:: `cudaMallocManaged` """ cdef void* dev_ptr with nogil: __status__ = cudaMallocManaged(&dev_ptr, size, flags) check_status(__status__) return dev_ptr cpdef intptr_t malloc(size_t size) except? 0: """Allocate memory on the device. Allocates ``size`` bytes of linear memory on the device and returns in ``*dev_ptr`` a pointer to the allocated memory. The allocated memory is suitably aligned for any kind of variable. The memory is not cleared. :func:`malloc` returns ``cudaErrorMemoryAllocation`` in case of failure. The device version of ``cudaFree`` cannot be used with a ``*dev_ptr`` allocated using the host API, and vice versa. Args: size (size_t): Requested allocation size in bytes. Returns: intptr_t: Pointer to allocated device memory. .. seealso:: `cudaMalloc` """ cdef void* dev_ptr with nogil: __status__ = cudaMalloc(&dev_ptr, size) check_status(__status__) return dev_ptr cpdef intptr_t malloc_host(size_t size) except? 0: """Allocates page-locked memory on the host. Allocates ``size`` bytes of host memory that is page-locked and accessible to the device. The driver tracks the virtual memory ranges allocated with this function and automatically accelerates calls to functions such as ``cudaMemcpy``\*(). Since the memory can be accessed directly by the device, it can be read or written with much higher bandwidth than pageable memory obtained with functions such as ``malloc()``. On systems where ``pageableMemoryAccessUsesHostPageTables`` is true, ``cudaMallocHost`` may not page-lock the allocated memory. Page-locking excessive amounts of memory with :func:`malloc_host` may degrade system performance, since it reduces the amount of memory available to the system for paging. As a result, this function is best used sparingly to allocate staging areas for data exchange between host and device. Args: size (size_t): Requested allocation size in bytes. Returns: intptr_t: Pointer to allocated host memory. .. seealso:: `cudaMallocHost` """ cdef void* ptr with nogil: __status__ = cudaMallocHost(&ptr, size) check_status(__status__) return ptr cpdef tuple malloc_pitch(size_t width, size_t height): """Allocates pitched memory on the device. Allocates at least ``width`` (in bytes) \* ``height`` bytes of linear memory on the device and returns in ``*dev_ptr`` a pointer to the allocated memory. The function may pad the allocation to ensure that corresponding pointers in any given row will continue to meet the alignment requirements for coalescing as the address is updated from row to row. The pitch returned in ``*pitch`` by :func:`malloc_pitch` is the width in bytes of the allocation. The intended usage of ``pitch`` is as a separate parameter of the allocation, used to compute addresses within the 2D array. Given the row and column of an array element of type ``T``, the address is computed as:. \*\*View CUDA Toolkit Documentation for a C++ code example*\*. For allocations of 2D arrays, it is recommended that programmers consider performing pitch allocations using :func:`malloc_pitch`. Due to pitch alignment restrictions in the hardware, this is especially true if the application will be performing 2D memory copies between different regions of device memory (whether linear memory or CUDA arrays). Args: width (size_t): Requested pitched allocation width (in bytes). height (size_t): Requested pitched allocation height. Returns: A 2-tuple containing: - intptr_t: Pointer to allocated pitched device memory. - size_t: Pitch for allocation. .. seealso:: `cudaMallocPitch` """ cdef void* dev_ptr cdef size_t pitch with nogil: __status__ = cudaMallocPitch(&dev_ptr, &pitch, width, height) check_status(__status__) return (dev_ptr, pitch) cpdef intptr_t malloc_array(desc, size_t width, size_t height, unsigned int flags) except? 0: """Allocate an array on the device. Allocates a CUDA array according to the ``cudaChannelFormatDesc`` structure ``desc`` and returns a handle to the new CUDA array in ``*array``. The ``cudaChannelFormatDesc`` is defined as:. \*\*View CUDA Toolkit Documentation for a C++ code example*\*. where ``cudaChannelFormatKind`` is one of ``cudaChannelFormatKindSigned``, ``cudaChannelFormatKindUnsigned``, or ``cudaChannelFormatKindFloat``. The ``flags`` parameter enables different options to be specified that affect the allocation, as follows. - ``cudaArrayDefault``: This flag's value is defined to be 0 and provides default array allocation. - ``cudaArraySurfaceLoadStore``: Allocates an array that can be read from or written to using a surface reference. - ``cudaArrayTextureGather``: This flag indicates that texture gather operations will be performed on the array. - ``cudaArraySparse``: Allocates a CUDA array without physical backing memory. The subregions within this sparse array can later be mapped onto a physical memory allocation by calling ``cuMemMapArrayAsync``. The physical backing memory must be allocated via ``cuMemCreate``. - ``cudaArrayDeferredMapping``: Allocates a CUDA array without physical backing memory. The entire array can later be mapped onto a physical memory allocation by calling ``cuMemMapArrayAsync``. The physical backing memory must be allocated via ``cuMemCreate``. ``width`` and ``height`` must meet certain size requirements. See :func:`malloc_3d_array` for more details. Args: desc (intptr_t): Requested channel format. width (size_t): Requested array allocation width. height (size_t): Requested array allocation height. flags (unsigned int): Requested properties of allocated array. Returns: intptr_t: Pointer to allocated array in device memory. .. seealso:: `cudaMallocArray` """ cdef intptr_t _desc_ptr_ = 0 if desc is None else int(desc) cdef cudaArray_t array with nogil: __status__ = cudaMallocArray(&array, _desc_ptr_, width, height, flags) check_status(__status__) return array cpdef free(intptr_t dev_ptr): """Frees memory on the device. Frees the memory space pointed to by ``dev_ptr``, which must have been returned by a previous call to one of the following memory allocation APIs - :func:`malloc`, :func:`malloc_pitch`, :func:`malloc_managed`, :func:`malloc_async`, :func:`malloc_from_pool_async`. Note - This API will not perform any implicit synchronization when the pointer was allocated with ``cudaMallocAsync`` or ``cudaMallocFromPoolAsync``. Callers must ensure that all accesses to these pointer have completed before invoking ``cudaFree``. For best performance and memory reuse, users should use ``cudaFreeAsync`` to free memory allocated via the stream ordered memory allocator. For all other pointers, this API may perform implicit synchronization. If ``cudaFree``\(``dev_ptr``) has already been called before, an error is returned. If ``dev_ptr`` is 0, no operation is performed. :func:`free` returns ``cudaErrorValue`` in case of failure. The device version of ``cudaFree`` cannot be used with a ``*dev_ptr`` allocated using the host API, and vice versa. Args: dev_ptr (intptr_t): Device pointer to memory to free. .. seealso:: `cudaFree` """ with nogil: __status__ = cudaFree(dev_ptr) check_status(__status__) cpdef free_host(ptr): """Frees page-locked memory. Frees the memory space pointed to by ``hostPtr``, which must have been returned by a previous call to :func:`malloc_host` or :func:`host_alloc`. Args: ptr (bytes): Pointer to memory to free. .. seealso:: `cudaFreeHost` """ cdef _cyb_BufferGuard _ptr_guard_ = _cyb_BufferGuard(ptr, 0, False, False, True) cdef void* _ptr_ = _ptr_guard_.ptr with nogil: __status__ = cudaFreeHost(_ptr_) check_status(__status__) cpdef free_array(intptr_t array): """Frees an array on the device. Frees the CUDA array ``array``, which must have been returned by a previous call to :func:`malloc_array`. If ``devPtr`` is 0, no operation is performed. Args: array (intptr_t): Pointer to array to free. .. seealso:: `cudaFreeArray` """ with nogil: __status__ = cudaFreeArray(array) check_status(__status__) cpdef free_mipmapped_array(intptr_t mipmapped_array): """Frees a mipmapped array on the device. Frees the CUDA mipmapped array ``mipmapped_array``, which must have been returned by a previous call to :func:`malloc_mipmapped_array`. If ``devPtr`` is 0, no operation is performed. Args: mipmapped_array (intptr_t): Pointer to mipmapped array to free. .. seealso:: `cudaFreeMipmappedArray` """ with nogil: __status__ = cudaFreeMipmappedArray(mipmapped_array) check_status(__status__) cpdef intptr_t host_alloc(size_t size, unsigned int flags) except? 0: """Allocates page-locked memory on the host. Allocates ``size`` bytes of host memory that is page-locked and accessible to the device. The driver tracks the virtual memory ranges allocated with this function and automatically accelerates calls to functions such as :func:`memcpy`. Since the memory can be accessed directly by the device, it can be read or written with much higher bandwidth than pageable memory obtained with functions such as ``malloc()``. Allocating excessive amounts of pinned memory may degrade system performance, since it reduces the amount of memory available to the system for paging. As a result, this function is best used sparingly to allocate staging areas for data exchange between host and device. The ``flags`` parameter enables different options to be specified that affect the allocation, as follows. - ``cudaHostAllocDefault``: This flag's value is defined to be 0 and causes :func:`host_alloc` to emulate :func:`malloc_host`. - ``cudaHostAllocPortable``: The memory returned by this call will be considered as pinned memory by all CUDA contexts, not just the one that performed the allocation. - ``cudaHostAllocMapped``: Maps the allocation into the CUDA address space. The device pointer to the memory may be obtained by calling :func:`host_get_device_pointer`. - ``cudaHostAllocWriteCombined``: Allocates the memory as write-combined (WC). WC memory can be transferred across the PCI Express bus more quickly on some system configurations, but cannot be read efficiently by most CPUs. WC memory is a good option for buffers that will be written by the CPU and read by the device via mapped pinned memory or host->device transfers. All of these flags are orthogonal to one another: a developer may allocate memory that is portable, mapped and/or write-combined with no restrictions. In order for the ``cudaHostAllocMapped`` flag to have any effect, the CUDA context must support the ``cudaDeviceMap_host`` flag, which can be checked via :func:`get_device_flags`. The ``cudaDeviceMap_host`` flag is implicitly set for contexts created via the runtime API. The ``cudaHostAllocMapped`` flag may be specified on CUDA contexts for devices that do not support mapped pinned memory. The failure is deferred to :func:`host_get_device_pointer` because the memory may be mapped into other CUDA contexts via the ``cudaHostAllocPortable`` flag. Memory allocated by this function must be freed with :func:`free_host`. Args: size (size_t): Requested allocation size in bytes. flags (unsigned int): Requested properties of allocated memory. Returns: intptr_t: Device pointer to allocated memory. .. seealso:: `cudaHostAlloc` """ cdef void* p_host with nogil: __status__ = cudaHostAlloc(&p_host, size, flags) check_status(__status__) return p_host cpdef host_register(ptr, size_t size, unsigned int flags): """Registers an existing host memory range for use by CUDA. Page-locks the memory range specified by ``ptr`` and ``size`` and maps it for the device(s) as specified by ``flags``. This memory range also is added to the same tracking mechanism as :func:`host_alloc` to automatically accelerate calls to functions such as :func:`memcpy`. Since the memory can be accessed directly by the device, it can be read or written with much higher bandwidth than pageable memory that has not been registered. Page-locking excessive amounts of memory may degrade system performance, since it reduces the amount of memory available to the system for paging. As a result, this function is best used sparingly to register staging areas for data exchange between host and device. On systems where ``pageableMemoryAccessUsesHostPageTables`` is true, ``cudaHostRegister`` will not page-lock the memory range specified by ``ptr`` but only populate unpopulated pages. ``cudaHostRegister`` is supported only on I/O coherent devices that have a non-zero value for the device attribute ``cudaDevAttrHostRegisterSupported``. The ``flags`` parameter enables different options to be specified that affect the allocation, as follows. - ``cudaHostRegisterDefault``: On a system with unified virtual addressing, the memory will be both mapped and portable. On a system with no unified virtual addressing, the memory will be neither mapped nor portable. - ``cudaHostRegisterPortable``: The memory returned by this call will be considered as pinned memory by all CUDA contexts, not just the one that performed the allocation. - ``cudaHostRegisterMapped``: Maps the allocation into the CUDA address space. The device pointer to the memory may be obtained by calling :func:`host_get_device_pointer`. - ``cudaHostRegisterIoMemory``: The passed memory pointer is treated as pointing to some memory-mapped I/O space, e.g. belonging to a third-party PCIe device, and it will marked as non cache-coherent and contiguous. - ``cudaHostRegisterReadOnly``: The passed memory pointer is treated as pointing to memory that is considered read-only by the device. On platforms without ``cudaDevAttrPageableMemoryAccessUsesHostPageTables``, this flag is required in order to register memory mapped to the CPU as read-only. Support for the use of this flag can be queried from the device attribute ``cudaDevAttrHostRegisterReadOnlySupported``. Using this flag with a current context associated with a device that does not have this attribute set will cause ``cudaHostRegister`` to error with cudaErrorNotSupported. All of these flags are orthogonal to one another: a developer may page-lock memory that is portable or mapped with no restrictions. The CUDA context must have been created with the ``cudaMapHost`` flag in order for the ``cudaHostRegisterMapped`` flag to have any effect. The ``cudaHostRegisterMapped`` flag may be specified on CUDA contexts for devices that do not support mapped pinned memory. The failure is deferred to :func:`host_get_device_pointer` because the memory may be mapped into other CUDA contexts via the ``cudaHostRegisterPortable`` flag. For devices that have a non-zero value for the device attribute ``cudaDevAttrCanUseHostPointerForRegisteredMem``, the memory can also be accessed from the device using the host pointer ``ptr``. The device pointer returned by :func:`host_get_device_pointer` may or may not match the original host pointer ``ptr`` and depends on the devices visible to the application. If all devices visible to the application have a non-zero value for the device attribute, the device pointer returned by :func:`host_get_device_pointer` will match the original pointer ``ptr``. If any device visible to the application has a zero value for the device attribute, the device pointer returned by :func:`host_get_device_pointer` will not match the original host pointer ``ptr``, but it will be suitable for use on all devices provided Unified Virtual Addressing is enabled. In such systems, it is valid to access the memory using either pointer on devices that have a non-zero value for the device attribute. Note however that such devices should access the memory using only of the two pointers and not both. The memory page-locked by this function must be unregistered with :func:`host_unregister`. Args: ptr (bytes): Host pointer to memory to page-lock. size (size_t): Size in bytes of the address range to page-lock in bytes. flags (unsigned int): Flags for allocation request. .. seealso:: `cudaHostRegister` """ cdef _cyb_BufferGuard _ptr_guard_ = _cyb_BufferGuard(ptr, 0, False, False, True) cdef void* _ptr_ = _ptr_guard_.ptr with nogil: __status__ = cudaHostRegister(_ptr_, size, flags) check_status(__status__) cpdef host_unregister(ptr): """Unregisters a memory range that was registered with cudaHostRegister. Unmaps the memory range whose base address is specified by ``ptr``, and makes it pageable again. The base address must be the same one specified to :func:`host_register`. Args: ptr (bytes): Host pointer to memory to unregister. .. seealso:: `cudaHostUnregister` """ cdef _cyb_BufferGuard _ptr_guard_ = _cyb_BufferGuard(ptr, 0, False, False, True) cdef void* _ptr_ = _ptr_guard_.ptr with nogil: __status__ = cudaHostUnregister(_ptr_) check_status(__status__) cpdef intptr_t host_get_device_pointer(p_host, unsigned int flags) except? 0: """Passes back device pointer of mapped host memory allocated by cudaHostAlloc or registered by cudaHostRegister. Passes back the device pointer corresponding to the mapped, pinned host buffer allocated by :func:`host_alloc` or registered by :func:`host_register`. :func:`host_get_device_pointer` will fail if the ``cudaDeviceMap_host`` flag was not specified before deferred context creation occurred, or if called on a device that does not support mapped, pinned memory. For devices that have a non-zero value for the device attribute ``cudaDevAttrCanUseHostPointerForRegisteredMem``, the memory can also be accessed from the device using the host pointer ``p_host``. The device pointer returned by :func:`host_get_device_pointer` may or may not match the original host pointer ``p_host`` and depends on the devices visible to the application. If all devices visible to the application have a non-zero value for the device attribute, the device pointer returned by :func:`host_get_device_pointer` will match the original pointer ``p_host``. If any device visible to the application has a zero value for the device attribute, the device pointer returned by :func:`host_get_device_pointer` will not match the original host pointer ``p_host``, but it will be suitable for use on all devices provided Unified Virtual Addressing is enabled. In such systems, it is valid to access the memory using either pointer on devices that have a non-zero value for the device attribute. Note however that such devices should access the memory using only of the two pointers and not both. ``flags`` provides for future releases. For now, it must be set to 0. Args: p_host (bytes): Requested host pointer mapping. flags (unsigned int): Flags for extensions (must be 0 for now). Returns: intptr_t: Returned device pointer for mapped memory. .. seealso:: `cudaHostGetDevicePointer` """ cdef _cyb_BufferGuard _p_host_guard_ = _cyb_BufferGuard(p_host, 0, False, False, True) cdef void* _p_host_ = _p_host_guard_.ptr cdef void* p_device with nogil: __status__ = cudaHostGetDevicePointer(&p_device, _p_host_, flags) check_status(__status__) return p_device cpdef unsigned int host_get_flags(p_host) except? 0: """Passes back flags used to allocate pinned host memory allocated by cudaHostAlloc. :func:`host_get_flags` will fail if the input pointer does not reside in an address range allocated by :func:`host_alloc`. Args: p_host (bytes): Host pointer. Returns: unsigned int: Returned flags word. .. seealso:: `cudaHostGetFlags` """ cdef _cyb_BufferGuard _p_host_guard_ = _cyb_BufferGuard(p_host, 0, False, False, True) cdef void* _p_host_ = _p_host_guard_.ptr cdef unsigned int p_flags with nogil: __status__ = cudaHostGetFlags(&p_flags, _p_host_) check_status(__status__) return p_flags cpdef object malloc_3d(extent): """Allocates logical 1D, 2D, or 3D memory objects on the device. Allocates at least ``width`` \* ``height`` \* ``depth`` bytes of linear memory on the device and returns a ``cudaPitchedPtr`` in which ``ptr`` is a pointer to the allocated memory. The function may pad the allocation to ensure hardware alignment requirements are met. The pitch returned in the ``pitch`` field of ``pitched_dev_ptr`` is the width in bytes of the allocation. The returned ``cudaPitchedPtr`` contains additional fields ``xsize`` and ``ysize``, the logical width and height of the allocation, which are equivalent to the ``width`` and ``height`` ``extent`` parameters provided by the programmer during allocation. For allocations of 2D and 3D objects, it is highly recommended that programmers perform allocations using :func:`malloc_3d` or :func:`malloc_pitch`. Due to alignment restrictions in the hardware, this is especially true if the application will be performing memory copies involving 2D or 3D objects (whether linear memory or CUDA arrays). Args: extent (cudaExtent): Requested allocation size (``width`` field in bytes). Returns: cudaPitchedPtr: Pointer to allocated pitched device memory. .. seealso:: `cudaMalloc3D` """ cdef intptr_t _extent_ptr_ = (extent)._get_ptr() cdef PitchedPtr pitched_dev_ptr_py = PitchedPtr() cdef cudaPitchedPtr *pitched_dev_ptr = (pitched_dev_ptr_py._get_ptr()) with nogil: __status__ = cudaMalloc3D(pitched_dev_ptr, (_extent_ptr_)[0]) check_status(__status__) return pitched_dev_ptr_py cpdef intptr_t malloc_3d_array(desc, extent, unsigned int flags) except? 0: """Allocate an array on the device. Allocates a CUDA array according to the ``cudaChannelFormatDesc`` structure ``desc`` and returns a handle to the new CUDA array in ``*array``. The ``cudaChannelFormatDesc`` is defined as:. \*\*View CUDA Toolkit Documentation for a C++ code example*\*. where ``cudaChannelFormatKind`` is one of ``cudaChannelFormatKindSigned``, ``cudaChannelFormatKindUnsigned``, or ``cudaChannelFormatKindFloat``. :func:`malloc_3d_array` can allocate the following:. - A 1D array is allocated if the height and depth extents are both zero. - A 2D array is allocated if only the depth extent is zero. - A 3D array is allocated if all three extents are non-zero. - A 1D layered CUDA array is allocated if only the height extent is zero and the cudaArrayLayered flag is set. Each layer is a 1D array. The number of layers is determined by the depth extent. - A 2D layered CUDA array is allocated if all three extents are non-zero and the cudaArrayLayered flag is set. Each layer is a 2D array. The number of layers is determined by the depth extent. - A cubemap CUDA array is allocated if all three extents are non-zero and the cudaArrayCubemap flag is set. Width must be equal to height, and depth must be six. A cubemap is a special type of 2D layered CUDA array, where the six layers represent the six faces of a cube. The order of the six layers in memory is the same as that listed in ``cudaGraphicsCubeFace``. - A cubemap layered CUDA array is allocated if all three extents are non-zero, and both, cudaArrayCubemap and cudaArrayLayered flags are set. Width must be equal to height, and depth must be a multiple of six. A cubemap layered CUDA array is a special type of 2D layered CUDA array that consists of a collection of cubemaps. The first six layers represent the first cubemap, the next six layers form the second cubemap, and so on. The ``flags`` parameter enables different options to be specified that affect the allocation, as follows. - ``cudaArrayDefault``: This flag's value is defined to be 0 and provides default array allocation. - ``cudaArrayLayered``: Allocates a layered CUDA array, with the depth extent indicating the number of layers. - ``cudaArrayCubemap``: Allocates a cubemap CUDA array. Width must be equal to height, and depth must be six. If the cudaArrayLayered flag is also set, depth must be a multiple of six. - ``cudaArraySurfaceLoadStore``: Allocates a CUDA array that could be read from or written to using a surface reference. - ``cudaArrayTextureGather``: This flag indicates that texture gather operations will be performed on the CUDA array. Texture gather can only be performed on 2D CUDA arrays. - ``cudaArraySparse``: Allocates a CUDA array without physical backing memory. The subregions within this sparse array can later be mapped onto a physical memory allocation by calling ``cuMemMapArrayAsync``. This flag can only be used for creating 2D, 3D or 2D layered sparse CUDA arrays. The physical backing memory must be allocated via ``cuMemCreate``. - ``cudaArrayDeferredMapping``: Allocates a CUDA array without physical backing memory. The entire array can later be mapped onto a physical memory allocation by calling ``cuMemMapArrayAsync``. The physical backing memory must be allocated via ``cuMemCreate``. The width, height and depth extents must meet certain size requirements as listed in the following table. All values are specified in elements. Note that 2D CUDA arrays have different size requirements if the ``cudaArrayTextureGather`` flag is set. In that case, the valid range for (width, height, depth) is ((1,maxTexture2DGather[0]), (1,maxTexture2DGather[1]), 0). \*\*View CUDA Toolkit Documentation for a table example*\*. Args: desc (intptr_t): Requested channel format. extent (cudaExtent): Requested allocation size (``width`` field in elements). flags (unsigned int): Flags for extensions. Returns: intptr_t: Pointer to allocated array in device memory. .. seealso:: `cudaMalloc3DArray` """ cdef intptr_t _desc_ptr_ = 0 if desc is None else int(desc) cdef intptr_t _extent_ptr_ = (extent)._get_ptr() cdef cudaArray_t array with nogil: __status__ = cudaMalloc3DArray(&array, _desc_ptr_, (_extent_ptr_)[0], flags) check_status(__status__) return array cpdef intptr_t malloc_mipmapped_array(desc, extent, unsigned int num_levels, unsigned int flags) except? 0: """Allocate a mipmapped array on the device. Allocates a CUDA mipmapped array according to the ``cudaChannelFormatDesc`` structure ``desc`` and returns a handle to the new CUDA mipmapped array in ``*mipmapped_array``. ``num_levels`` specifies the number of mipmap levels to be allocated. This value is clamped to the range [1, 1 + floor(log2(max(width, height, depth)))]. The ``cudaChannelFormatDesc`` is defined as:. \*\*View CUDA Toolkit Documentation for a C++ code example*\*. where ``cudaChannelFormatKind`` is one of ``cudaChannelFormatKindSigned``, ``cudaChannelFormatKindUnsigned``, or ``cudaChannelFormatKindFloat``. :func:`malloc_mipmapped_array` can allocate the following:. - A 1D mipmapped array is allocated if the height and depth extents are both zero. - A 2D mipmapped array is allocated if only the depth extent is zero. - A 3D mipmapped array is allocated if all three extents are non-zero. - A 1D layered CUDA mipmapped array is allocated if only the height extent is zero and the cudaArrayLayered flag is set. Each layer is a 1D mipmapped array. The number of layers is determined by the depth extent. - A 2D layered CUDA mipmapped array is allocated if all three extents are non-zero and the cudaArrayLayered flag is set. Each layer is a 2D mipmapped array. The number of layers is determined by the depth extent. - A cubemap CUDA mipmapped array is allocated if all three extents are non-zero and the cudaArrayCubemap flag is set. Width must be equal to height, and depth must be six. The order of the six layers in memory is the same as that listed in ``cudaGraphicsCubeFace``. - A cubemap layered CUDA mipmapped array is allocated if all three extents are non-zero, and both, cudaArrayCubemap and cudaArrayLayered flags are set. Width must be equal to height, and depth must be a multiple of six. A cubemap layered CUDA mipmapped array is a special type of 2D layered CUDA mipmapped array that consists of a collection of cubemap mipmapped arrays. The first six layers represent the first cubemap mipmapped array, the next six layers form the second cubemap mipmapped array, and so on. The ``flags`` parameter enables different options to be specified that affect the allocation, as follows. - ``cudaArrayDefault``: This flag's value is defined to be 0 and provides default mipmapped array allocation. - ``cudaArrayLayered``: Allocates a layered CUDA mipmapped array, with the depth extent indicating the number of layers. - ``cudaArrayCubemap``: Allocates a cubemap CUDA mipmapped array. Width must be equal to height, and depth must be six. If the cudaArrayLayered flag is also set, depth must be a multiple of six. - ``cudaArraySurfaceLoadStore``: This flag indicates that individual mipmap levels of the CUDA mipmapped array will be read from or written to using a surface reference. - ``cudaArrayTextureGather``: This flag indicates that texture gather operations will be performed on the CUDA array. Texture gather can only be performed on 2D CUDA mipmapped arrays, and the gather operations are performed only on the most detailed mipmap level. - ``cudaArraySparse``: Allocates a CUDA mipmapped array without physical backing memory. The subregions within this sparse array can later be mapped onto a physical memory allocation by calling ``cuMemMapArrayAsync``. This flag can only be used for creating 2D, 3D or 2D layered sparse CUDA mipmapped arrays. The physical backing memory must be allocated via ``cuMemCreate``. - ``cudaArrayDeferredMapping``: Allocates a CUDA mipmapped array without physical backing memory. The entire array can later be mapped onto a physical memory allocation by calling ``cuMemMapArrayAsync``. The physical backing memory must be allocated via ``cuMemCreate``. The width, height and depth extents must meet certain size requirements as listed in the following table. All values are specified in elements. \*\*View CUDA Toolkit Documentation for a table example*\*. Args: desc (intptr_t): Requested channel format. extent (cudaExtent): Requested allocation size (``width`` field in elements). num_levels (unsigned int): Number of mipmap levels to allocate. flags (unsigned int): Flags for extensions. Returns: intptr_t: Pointer to allocated mipmapped array in device memory. .. seealso:: `cudaMallocMipmappedArray` """ cdef intptr_t _desc_ptr_ = 0 if desc is None else int(desc) cdef intptr_t _extent_ptr_ = (extent)._get_ptr() cdef cudaMipmappedArray_t mipmapped_array with nogil: __status__ = cudaMallocMipmappedArray(&mipmapped_array, _desc_ptr_, (_extent_ptr_)[0], num_levels, flags) check_status(__status__) return mipmapped_array cpdef intptr_t get_mipmapped_array_level(intptr_t mipmapped_array, unsigned int level) except? 0: """Gets a mipmap level of a CUDA mipmapped array. Returns in ``*level_array`` a CUDA array that represents a single mipmap level of the CUDA mipmapped array ``mipmapped_array``. If ``level`` is greater than the maximum number of levels in this mipmapped array, ``cudaErrorInvalidValue`` is returned. If ``mipmapped_array`` is NULL, ``cudaErrorInvalidResourceHandle`` is returned. Args: mipmapped_array (intptr_t): CUDA mipmapped array. level (unsigned int): Mipmap level. Returns: intptr_t: Returned mipmap level CUDA array. .. seealso:: `cudaGetMipmappedArrayLevel` """ cdef cudaArray_t level_array with nogil: __status__ = cudaGetMipmappedArrayLevel(&level_array, mipmapped_array, level) check_status(__status__) return level_array cpdef memcpy_3d(p): """Copies data between 3D objects. \*\*View CUDA Toolkit Documentation for a C++ code example*\*. :func:`memcpy_3d` copies data betwen two 3D objects. The source and destination objects may be in either host memory, device memory, or a CUDA array. The source, destination, extent, and kind of copy performed is specified by the ``cudaMemcpy3DParms`` struct which should be initialized to zero before use:. \*\*View CUDA Toolkit Documentation for a C++ code example*\*. The struct passed to :func:`memcpy_3d` must specify one of ``srcArray`` or ``srcPtr`` and one of ``dstArray`` or ``dstPtr``. Passing more than one non-zero source or destination will cause :func:`memcpy_3d` to return an error. The ``srcPos`` and ``dstPos`` fields are optional offsets into the source and destination objects and are defined in units of each object's elements. The element for a host or device pointer is assumed to be unsigned char. The ``extent`` field defines the dimensions of the transferred area in elements. If a CUDA array is participating in the copy, the extent is defined in terms of that array's elements. If no CUDA array is participating in the copy then the extents are defined in elements of unsigned char. The ``kind`` field defines the direction of the copy. It must be one of ``cudaMemcpyHostToHost``, ``cudaMemcpyHostToDevice``, ``cudaMemcpyDeviceToHost``, ``cudaMemcpyDeviceToDevice``, or ``cudaMemcpyDefault``. Passing ``cudaMemcpyDefault`` is recommended, in which case the type of transfer is inferred from the pointer values. However, ``cudaMemcpyDefault`` is only allowed on systems that support unified virtual addressing. For ``cudaMemcpyHostToHost`` or ``cudaMemcpyHostToDevice`` or ``cudaMemcpyDeviceToHost`` passed as kind and cudaArray type passed as source or destination, if the kind implies cudaArray type to be present on the host, :func:`memcpy_3d` will disregard that implication and silently correct the kind based on the fact that cudaArray type can only be present on the device. If the source and destination are both arrays, :func:`memcpy_3d` will return an error if they do not have the same element size. The source and destination object may not overlap. If overlapping source and destination objects are specified, undefined behavior will result. The source object must entirely contain the region defined by ``srcPos`` and ``extent``. The destination object must entirely contain the region defined by ``dstPos`` and ``extent``. :func:`memcpy_3d` returns an error if the pitch of ``srcPtr`` or ``dstPtr`` exceeds the maximum allowed. The pitch of a ``cudaPitchedPtr`` allocated with :func:`malloc_3d` will always be valid. Args: p (intptr_t): 3D memory copy parameters. .. seealso:: `cudaMemcpy3D` """ cdef intptr_t _p_ptr_ = 0 if p is None else int(p) with nogil: __status__ = cudaMemcpy3D(_p_ptr_) check_status(__status__) cpdef memcpy_3d_peer(p): """Copies memory between devices. Perform a 3D memory copy according to the parameters specified in ``p``. See the definition of the ``cudaMemcpy3DPeerParms`` structure for documentation of its parameters. Note that this function is synchronous with respect to the host only if the source or destination of the transfer is host memory. Note also that this copy is serialized with respect to all pending and future asynchronous work in to the current device, the copy's source device, and the copy's destination device (use ``cudaMemcpy3DPeerAsync`` to avoid this synchronization). Args: p (intptr_t): Parameters for the memory copy. .. seealso:: `cudaMemcpy3DPeer` """ cdef intptr_t _p_ptr_ = 0 if p is None else int(p) with nogil: __status__ = cudaMemcpy3DPeer(_p_ptr_) check_status(__status__) cpdef memcpy_3d_async(p, intptr_t stream): """Copies data between 3D objects. \*\*View CUDA Toolkit Documentation for a C++ code example*\*. :func:`memcpy_3d_async` copies data betwen two 3D objects. The source and destination objects may be in either host memory, device memory, or a CUDA array. The source, destination, extent, and kind of copy performed is specified by the ``cudaMemcpy3DParms`` struct which should be initialized to zero before use:. \*\*View CUDA Toolkit Documentation for a C++ code example*\*. The struct passed to :func:`memcpy_3d_async` must specify one of ``srcArray`` or ``srcPtr`` and one of ``dstArray`` or ``dstPtr``. Passing more than one non-zero source or destination will cause :func:`memcpy_3d_async` to return an error. The ``srcPos`` and ``dstPos`` fields are optional offsets into the source and destination objects and are defined in units of each object's elements. The element for a host or device pointer is assumed to be unsigned char. For CUDA arrays, positions must be in the range [0, 2048) for any dimension. The ``extent`` field defines the dimensions of the transferred area in elements. If a CUDA array is participating in the copy, the extent is defined in terms of that array's elements. If no CUDA array is participating in the copy then the extents are defined in elements of unsigned char. The ``kind`` field defines the direction of the copy. It must be one of ``cudaMemcpyHostToHost``, ``cudaMemcpyHostToDevice``, ``cudaMemcpyDeviceToHost``, ``cudaMemcpyDeviceToDevice``, or ``cudaMemcpyDefault``. Passing ``cudaMemcpyDefault`` is recommended, in which case the type of transfer is inferred from the pointer values. However, ``cudaMemcpyDefault`` is only allowed on systems that support unified virtual addressing. For ``cudaMemcpyHostToHost`` or ``cudaMemcpyHostToDevice`` or ``cudaMemcpyDeviceToHost`` passed as kind and cudaArray type passed as source or destination, if the kind implies cudaArray type to be present on the host, :func:`memcpy_3d_async` will disregard that implication and silently correct the kind based on the fact that cudaArray type can only be present on the device. If the source and destination are both arrays, :func:`memcpy_3d_async` will return an error if they do not have the same element size. The source and destination object may not overlap. If overlapping source and destination objects are specified, undefined behavior will result. The source object must lie entirely within the region defined by ``srcPos`` and ``extent``. The destination object must lie entirely within the region defined by ``dstPos`` and ``extent``. :func:`memcpy_3d_async` returns an error if the pitch of ``srcPtr`` or ``dstPtr`` exceeds the maximum allowed. The pitch of a ``cudaPitchedPtr`` allocated with :func:`malloc_3d` will always be valid. :func:`memcpy_3d_async` is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero ``stream`` argument. If ``kind`` is ``cudaMemcpyHostToDevice`` or ``cudaMemcpyDeviceToHost`` and ``stream`` is non-zero, the copy may overlap with operations in other streams. The device version of this function only handles device to device copies and cannot be given local or shared pointers. Args: p (intptr_t): 3D memory copy parameters. stream (intptr_t): Stream identifier. .. seealso:: `cudaMemcpy3DAsync` """ cdef intptr_t _p_ptr_ = 0 if p is None else int(p) with nogil: __status__ = cudaMemcpy3DAsync(_p_ptr_, stream) check_status(__status__) cpdef memcpy_3d_peer_async(p, intptr_t stream): """Copies memory between devices asynchronously. Perform a 3D memory copy according to the parameters specified in ``p``. See the definition of the ``cudaMemcpy3DPeerParms`` structure for documentation of its parameters. Args: p (intptr_t): Parameters for the memory copy. stream (intptr_t): Stream identifier. .. seealso:: `cudaMemcpy3DPeerAsync` """ cdef intptr_t _p_ptr_ = 0 if p is None else int(p) with nogil: __status__ = cudaMemcpy3DPeerAsync(_p_ptr_, stream) check_status(__status__) cpdef tuple mem_get_info(): """Gets free and total device memory. Returns in ``*total`` the total amount of memory available to the the current context. Returns in ``*free`` the amount of memory on the device that is free according to the OS. CUDA is not guaranteed to be able to allocate all of the memory that the OS reports as free. In a multi-tenet situation, free estimate returned is prone to race condition where a new allocation/free done by a different process or a different thread in the same process between the time when free memory was estimated and reported, will result in deviation in free value reported and actual free memory. The integrated GPU on Tegra shares memory with CPU and other component of the SoC. The free and total values returned by the API excludes the SWAP memory space maintained by the OS on some platforms. The OS may move some of the memory pages into swap area as the GPU or CPU allocate or access memory. See Tegra app note on how to calculate total and free memory on Tegra. Returns: A 2-tuple containing: - size_t: Returned free memory in bytes. - size_t: Returned total memory in bytes. .. seealso:: `cudaMemGetInfo` """ cdef size_t free cdef size_t total with nogil: __status__ = cudaMemGetInfo(&free, &total) check_status(__status__) return (free, total) cpdef tuple array_get_info(intptr_t array): """Gets info about the specified cudaArray. Returns in ``*desc``, ``*extent`` and ``*flags`` respectively, the type, shape and flags of ``array``. Any of ``*desc``, ``*extent`` and ``*flags`` may be specified as NULL. Args: array (intptr_t): The ``cudaArray`` to get info for. Returns: A 3-tuple containing: - cudaChannelFormatDesc: Returned array type. - cudaExtent: Returned array shape. 2D arrays will have depth of zero. - unsigned int: Returned array flags. .. seealso:: `cudaArrayGetInfo` """ cdef ChannelFormatDesc desc_py = ChannelFormatDesc() cdef cudaChannelFormatDesc *desc = (desc_py._get_ptr()) cdef Extent extent_py = Extent() cdef cudaExtent *extent = (extent_py._get_ptr()) cdef unsigned int flags with nogil: __status__ = cudaArrayGetInfo(desc, extent, &flags, array) check_status(__status__) return (desc_py, extent_py, flags) cpdef intptr_t array_get_plane(intptr_t h_array, unsigned int plane_idx) except? 0: """Gets a CUDA array plane from a CUDA array. Returns in ``p_plane_array`` a CUDA array that represents a single format plane of the CUDA array ``h_array``. If ``plane_idx`` is greater than the maximum number of planes in this array or if the array does not have a multi-planar format e.g: ``cudaChannelFormatKindNV12``, then ``cudaErrorInvalidValue`` is returned. Note that if the ``h_array`` has format ``cudaChannelFormatKindNV12``, then passing in 0 for ``plane_idx`` returns a CUDA array of the same size as ``h_array`` but with one 8-bit channel and ``cudaChannelFormatKindUnsigned`` as its format kind. If 1 is passed for ``plane_idx``, then the returned CUDA array has half the height and width of ``h_array`` with two 8-bit channels and ``cudaChannelFormatKindUnsigned`` as its format kind. Args: h_array (intptr_t): CUDA array. plane_idx (unsigned int): Plane index. Returns: intptr_t: Returned CUDA array referenced by the ``plane_idx``. .. seealso:: `cudaArrayGetPlane` """ cdef cudaArray_t p_plane_array with nogil: __status__ = cudaArrayGetPlane(&p_plane_array, h_array, plane_idx) check_status(__status__) return p_plane_array cpdef object array_get_memory_requirements(intptr_t array, int device): """Returns the memory requirements of a CUDA array. Returns the memory requirements of a CUDA array in ``memory_requirements`` If the CUDA array is not allocated with flag ``cudaArrayDeferredMapping`` ``cudaErrorInvalidValue`` will be returned. The returned value in ``cudaArrayMemoryRequirements.size`` represents the total size of the CUDA array. The returned value in ``cudaArrayMemoryRequirements.alignment`` represents the alignment necessary for mapping the CUDA array. Args: array (intptr_t): CUDA array to get the memory requirements of. device (int): Device to get the memory requirements for. Returns: cudaArrayMemoryRequirements: Pointer to ``cudaArrayMemoryRequirements``. .. seealso:: `cudaArrayGetMemoryRequirements` """ cdef ArrayMemoryRequirements memory_requirements_py = ArrayMemoryRequirements() cdef cudaArrayMemoryRequirements *memory_requirements = (memory_requirements_py._get_ptr()) with nogil: __status__ = cudaArrayGetMemoryRequirements(memory_requirements, array, device) check_status(__status__) return memory_requirements_py cpdef object mipmapped_array_get_memory_requirements(intptr_t mipmap, int device): """Returns the memory requirements of a CUDA mipmapped array. Returns the memory requirements of a CUDA mipmapped array in ``memory_requirements`` If the CUDA mipmapped array is not allocated with flag ``cudaArrayDeferredMapping`` ``cudaErrorInvalidValue`` will be returned. The returned value in ``cudaArrayMemoryRequirements.size`` represents the total size of the CUDA mipmapped array. The returned value in ``cudaArrayMemoryRequirements.alignment`` represents the alignment necessary for mapping the CUDA mipmapped array. Args: mipmap (intptr_t): CUDA mipmapped array to get the memory requirements of. device (int): Device to get the memory requirements for. Returns: cudaArrayMemoryRequirements: Pointer to ``cudaArrayMemoryRequirements``. .. seealso:: `cudaMipmappedArrayGetMemoryRequirements` """ cdef ArrayMemoryRequirements memory_requirements_py = ArrayMemoryRequirements() cdef cudaArrayMemoryRequirements *memory_requirements = (memory_requirements_py._get_ptr()) with nogil: __status__ = cudaMipmappedArrayGetMemoryRequirements(memory_requirements, mipmap, device) check_status(__status__) return memory_requirements_py cpdef object array_get_sparse_properties(intptr_t array): """Returns the layout properties of a sparse CUDA array. Returns the layout properties of a sparse CUDA array in ``sparse_properties``. If the CUDA array is not allocated with flag ``cudaArraySparse`` ``cudaErrorInvalidValue`` will be returned. If the returned value in ``cudaArraySparseProperties.flags`` contains ``cudaArraySparsePropertiesSingleMipTail``, then ``cudaArraySparseProperties.miptailSize`` represents the total size of the array. Otherwise, it will be zero. Also, the returned value in ``cudaArraySparseProperties.miptailFirstLevel`` is always zero. Note that the ``array`` must have been allocated using ``cudaMallocArray`` or ``cudaMalloc3DArray``. For CUDA arrays obtained using ``cudaMipmappedArrayGetLevel``, ``cudaErrorInvalidValue`` will be returned. Instead, ``cudaMipmappedArrayGetSparseProperties`` must be used to obtain the sparse properties of the entire CUDA mipmapped array to which ``array`` belongs to. Args: array (intptr_t): The CUDA array to get the sparse properties of. Returns: cudaArraySparseProperties: Pointer to return the ``cudaArraySparseProperties``. .. seealso:: `cudaArrayGetSparseProperties` """ cdef ArraySparseProperties sparse_properties_py = ArraySparseProperties() cdef cudaArraySparseProperties *sparse_properties = (sparse_properties_py._get_ptr()) with nogil: __status__ = cudaArrayGetSparseProperties(sparse_properties, array) check_status(__status__) return sparse_properties_py cpdef object mipmapped_array_get_sparse_properties(intptr_t mipmap): """Returns the layout properties of a sparse CUDA mipmapped array. Returns the sparse array layout properties in ``sparse_properties``. If the CUDA mipmapped array is not allocated with flag ``cudaArraySparse`` ``cudaErrorInvalidValue`` will be returned. For non-layered CUDA mipmapped arrays, ``cudaArraySparseProperties.miptailSize`` returns the size of the mip tail region. The mip tail region includes all mip levels whose width, height or depth is less than that of the tile. For layered CUDA mipmapped arrays, if ``cudaArraySparseProperties.flags`` contains ``cudaArraySparsePropertiesSingleMipTail``, then ``cudaArraySparseProperties.miptailSize`` specifies the size of the mip tail of all layers combined. Otherwise, ``cudaArraySparseProperties.miptailSize`` specifies mip tail size per layer. The returned value of ``cudaArraySparseProperties.miptailFirstLevel`` is valid only if ``cudaArraySparseProperties.miptailSize`` is non-zero. Args: mipmap (intptr_t): The CUDA mipmapped array to get the sparse properties of. Returns: cudaArraySparseProperties: Pointer to return ``cudaArraySparseProperties``. .. seealso:: `cudaMipmappedArrayGetSparseProperties` """ cdef ArraySparseProperties sparse_properties_py = ArraySparseProperties() cdef cudaArraySparseProperties *sparse_properties = (sparse_properties_py._get_ptr()) with nogil: __status__ = cudaMipmappedArrayGetSparseProperties(sparse_properties, mipmap) check_status(__status__) return sparse_properties_py cpdef memcpy(dst, src, size_t count, int kind): """Copies data between host and device. Copies ``count`` bytes from the memory area pointed to by ``src`` to the memory area pointed to by ``dst``, where ``kind`` specifies the direction of the copy, and must be one of ``cudaMemcpyHostToHost``, ``cudaMemcpyHostToDevice``, ``cudaMemcpyDeviceToHost``, ``cudaMemcpyDeviceToDevice``, or ``cudaMemcpyDefault``. Passing ``cudaMemcpyDefault`` is recommended, in which case the type of transfer is inferred from the pointer values. However, ``cudaMemcpyDefault`` is only allowed on systems that support unified virtual addressing. Calling :func:`memcpy` with dst and src pointers that do not match the direction of the copy results in an undefined behavior. \note_sync. Args: dst (bytes): Destination memory address. src (bytes): Source memory address. count (size_t): Size in bytes to copy. kind (MemCpyKind): Type of transfer. .. seealso:: `cudaMemcpy` """ cdef _cyb_BufferGuard _dst_guard_ = _cyb_BufferGuard(dst, 0, False, False, True) cdef void* _dst_ = _dst_guard_.ptr cdef _cyb_BufferGuard _src_guard_ = _cyb_BufferGuard(src, 0, False, True, True) cdef void* _src_ = _src_guard_.ptr with nogil: __status__ = cudaMemcpy(_dst_, _src_, count, kind) check_status(__status__) cpdef memcpy_peer(intptr_t dst, int dst_device, intptr_t src, int src_device, size_t count): """Copies memory between two devices. Copies memory from one device to memory on another device. ``dst`` is the base device pointer of the destination memory and ``dst_device`` is the destination device. ``src`` is the base device pointer of the source memory and ``src_device`` is the source device. ``count`` specifies the number of bytes to copy. Note that this function is asynchronous with respect to the host, but serialized with respect all pending and future asynchronous work in to the current device, ``src_device``, and ``dst_device`` (use ``cudaMemcpyPeerAsync`` to avoid this synchronization). Args: dst (intptr_t): Destination device pointer. dst_device (int): Destination device. src (intptr_t): Source device pointer. src_device (int): Source device. count (size_t): Size of memory copy in bytes. .. seealso:: `cudaMemcpyPeer` """ with nogil: __status__ = cudaMemcpyPeer(dst, dst_device, src, src_device, count) check_status(__status__) cpdef memcpy_2d(dst, size_t dpitch, src, size_t spitch, size_t width, size_t height, int kind): """Copies data between host and device. Copies a matrix (``height`` rows of ``width`` bytes each) from the memory area pointed to by ``src`` to the memory area pointed to by ``dst``, where ``kind`` specifies the direction of the copy, and must be one of ``cudaMemcpyHostToHost``, ``cudaMemcpyHostToDevice``, ``cudaMemcpyDeviceToHost``, ``cudaMemcpyDeviceToDevice``, or ``cudaMemcpyDefault``. Passing ``cudaMemcpyDefault`` is recommended, in which case the type of transfer is inferred from the pointer values. However, ``cudaMemcpyDefault`` is only allowed on systems that support unified virtual addressing. ``dpitch`` and ``spitch`` are the widths in memory in bytes of the 2D arrays pointed to by ``dst`` and ``src``, including any padding added to the end of each row. The memory areas may not overlap. ``width`` must not exceed either ``dpitch`` or ``spitch``. Calling :func:`memcpy_2d` with ``dst`` and ``src`` pointers that do not match the direction of the copy results in an undefined behavior. :func:`memcpy_2d` returns an error if ``dpitch`` or ``spitch`` exceeds the maximum allowed. Args: dst (bytes): Destination memory address. dpitch (size_t): Pitch of destination memory. src (bytes): Source memory address. spitch (size_t): Pitch of source memory. width (size_t): Width of matrix transfer (columns in bytes). height (size_t): Height of matrix transfer (rows). kind (MemCpyKind): Type of transfer. .. seealso:: `cudaMemcpy2D` """ cdef _cyb_BufferGuard _dst_guard_ = _cyb_BufferGuard(dst, 0, False, False, True) cdef void* _dst_ = _dst_guard_.ptr cdef _cyb_BufferGuard _src_guard_ = _cyb_BufferGuard(src, 0, False, True, True) cdef void* _src_ = _src_guard_.ptr with nogil: __status__ = cudaMemcpy2D(_dst_, dpitch, _src_, spitch, width, height, kind) check_status(__status__) cpdef memcpy_2d_to_array(intptr_t dst, size_t w_offset, size_t h_offset, src, size_t spitch, size_t width, size_t height, int kind): """Copies data between host and device. Copies a matrix (``height`` rows of ``width`` bytes each) from the memory area pointed to by ``src`` to the CUDA array ``dst`` starting at ``h_offset`` rows and ``w_offset`` bytes from the upper left corner, where ``kind`` specifies the direction of the copy, and must be one of ``cudaMemcpyHostToHost``, ``cudaMemcpyHostToDevice``, ``cudaMemcpyDeviceToHost``, ``cudaMemcpyDeviceToDevice``, or ``cudaMemcpyDefault``. Passing ``cudaMemcpyDefault`` is recommended, in which case the type of transfer is inferred from the pointer values. However, ``cudaMemcpyDefault`` is only allowed on systems that support unified virtual addressing. ``spitch`` is the width in memory in bytes of the 2D array pointed to by ``src``, including any padding added to the end of each row. ``w_offset`` + ``width`` must not exceed the width of the CUDA array ``dst``. ``width`` must not exceed ``spitch``. :func:`memcpy_2d_to_array` returns an error if ``spitch`` exceeds the maximum allowed. Args: dst (intptr_t): Destination memory address. w_offset (size_t): Destination starting X offset (columns in bytes). h_offset (size_t): Destination starting Y offset (rows). src (bytes): Source memory address. spitch (size_t): Pitch of source memory. width (size_t): Width of matrix transfer (columns in bytes). height (size_t): Height of matrix transfer (rows). kind (MemCpyKind): Type of transfer. .. seealso:: `cudaMemcpy2DToArray` """ cdef _cyb_BufferGuard _src_guard_ = _cyb_BufferGuard(src, 0, False, True, True) cdef void* _src_ = _src_guard_.ptr with nogil: __status__ = cudaMemcpy2DToArray(dst, w_offset, h_offset, _src_, spitch, width, height, kind) check_status(__status__) cpdef memcpy_2d_from_array(dst, size_t dpitch, intptr_t src, size_t w_offset, size_t h_offset, size_t width, size_t height, int kind): """Copies data between host and device. Copies a matrix (``height`` rows of ``width`` bytes each) from the CUDA array ``src`` starting at ``h_offset`` rows and ``w_offset`` bytes from the upper left corner to the memory area pointed to by ``dst``, where ``kind`` specifies the direction of the copy, and must be one of ``cudaMemcpyHostToHost``, ``cudaMemcpyHostToDevice``, ``cudaMemcpyDeviceToHost``, ``cudaMemcpyDeviceToDevice``, or ``cudaMemcpyDefault``. Passing ``cudaMemcpyDefault`` is recommended, in which case the type of transfer is inferred from the pointer values. However, ``cudaMemcpyDefault`` is only allowed on systems that support unified virtual addressing. ``dpitch`` is the width in memory in bytes of the 2D array pointed to by ``dst``, including any padding added to the end of each row. ``w_offset`` + ``width`` must not exceed the width of the CUDA array ``src``. ``width`` must not exceed ``dpitch``. :func:`memcpy_2d_from_array` returns an error if ``dpitch`` exceeds the maximum allowed. Args: dst (bytes): Destination memory address. dpitch (size_t): Pitch of destination memory. src (intptr_t): Source memory address. w_offset (size_t): Source starting X offset (columns in bytes). h_offset (size_t): Source starting Y offset (rows). width (size_t): Width of matrix transfer (columns in bytes). height (size_t): Height of matrix transfer (rows). kind (MemCpyKind): Type of transfer. .. seealso:: `cudaMemcpy2DFromArray` """ cdef _cyb_BufferGuard _dst_guard_ = _cyb_BufferGuard(dst, 0, False, False, True) cdef void* _dst_ = _dst_guard_.ptr with nogil: __status__ = cudaMemcpy2DFromArray(_dst_, dpitch, src, w_offset, h_offset, width, height, kind) check_status(__status__) cpdef memcpy_2d_array_to_array(intptr_t dst, size_t w_offset_dst, size_t h_offset_dst, intptr_t src, size_t w_offset_src, size_t h_offset_src, size_t width, size_t height, int kind): """Copies data between host and device. Copies a matrix (``height`` rows of ``width`` bytes each) from the CUDA array ``src`` starting at ``h_offset_src`` rows and ``w_offset_src`` bytes from the upper left corner to the CUDA array ``dst`` starting at ``h_offset_dst`` rows and ``w_offset_dst`` bytes from the upper left corner, where ``kind`` specifies the direction of the copy, and must be one of ``cudaMemcpyHostToHost``, ``cudaMemcpyHostToDevice``, ``cudaMemcpyDeviceToHost``, ``cudaMemcpyDeviceToDevice``, or ``cudaMemcpyDefault``. Passing ``cudaMemcpyDefault`` is recommended, in which case the type of transfer is inferred from the pointer values. However, ``cudaMemcpyDefault`` is only allowed on systems that support unified virtual addressing. ``w_offset_dst`` + ``width`` must not exceed the width of the CUDA array ``dst``. ``w_offset_src`` + ``width`` must not exceed the width of the CUDA array ``src``. Args: dst (intptr_t): Destination memory address. w_offset_dst (size_t): Destination starting X offset (columns in bytes). h_offset_dst (size_t): Destination starting Y offset (rows). src (intptr_t): Source memory address. w_offset_src (size_t): Source starting X offset (columns in bytes). h_offset_src (size_t): Source starting Y offset (rows). width (size_t): Width of matrix transfer (columns in bytes). height (size_t): Height of matrix transfer (rows). kind (MemCpyKind): Type of transfer. .. seealso:: `cudaMemcpy2DArrayToArray` """ with nogil: __status__ = cudaMemcpy2DArrayToArray(dst, w_offset_dst, h_offset_dst, src, w_offset_src, h_offset_src, width, height, kind) check_status(__status__) cpdef memcpy_async(dst, src, size_t count, int kind, intptr_t stream): """Copies data between host and device. Copies ``count`` bytes from the memory area pointed to by ``src`` to the memory area pointed to by ``dst``, where ``kind`` specifies the direction of the copy, and must be one of ``cudaMemcpyHostToHost``, ``cudaMemcpyHostToDevice``, ``cudaMemcpyDeviceToHost``, ``cudaMemcpyDeviceToDevice``, or ``cudaMemcpyDefault``. Passing ``cudaMemcpyDefault`` is recommended, in which case the type of transfer is inferred from the pointer values. However, ``cudaMemcpyDefault`` is only allowed on systems that support unified virtual addressing. The memory areas may not overlap. Calling :func:`memcpy_async` with ``dst`` and ``src`` pointers that do not match the direction of the copy results in an undefined behavior. :func:`memcpy_async` is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero ``stream`` argument. If ``kind`` is ``cudaMemcpyHostToDevice`` or ``cudaMemcpyDeviceToHost`` and the ``stream`` is non-zero, the copy may overlap with operations in other streams. The device version of this function only handles device to device copies and cannot be given local or shared pointers. Args: dst (bytes): Destination memory address. src (bytes): Source memory address. count (size_t): Size in bytes to copy. kind (MemCpyKind): Type of transfer. stream (intptr_t): Stream identifier. .. seealso:: `cudaMemcpyAsync` """ cdef _cyb_BufferGuard _dst_guard_ = _cyb_BufferGuard(dst, 0, False, False, True) cdef void* _dst_ = _dst_guard_.ptr cdef _cyb_BufferGuard _src_guard_ = _cyb_BufferGuard(src, 0, False, True, True) cdef void* _src_ = _src_guard_.ptr with nogil: __status__ = cudaMemcpyAsync(_dst_, _src_, count, kind, stream) check_status(__status__) cpdef memcpy_peer_async(intptr_t dst, int dst_device, intptr_t src, int src_device, size_t count, intptr_t stream): """Copies memory between two devices asynchronously. Copies memory from one device to memory on another device. ``dst`` is the base device pointer of the destination memory and ``dst_device`` is the destination device. ``src`` is the base device pointer of the source memory and ``src_device`` is the source device. ``count`` specifies the number of bytes to copy. Note that this function is asynchronous with respect to the host and all work on other devices. Args: dst (intptr_t): Destination device pointer. dst_device (int): Destination device. src (intptr_t): Source device pointer. src_device (int): Source device. count (size_t): Size of memory copy in bytes. stream (intptr_t): Stream identifier. .. seealso:: `cudaMemcpyPeerAsync` """ with nogil: __status__ = cudaMemcpyPeerAsync(dst, dst_device, src, src_device, count, stream) check_status(__status__) cpdef memcpy_3d_batch_async(op_list, unsigned long long flags, intptr_t stream): """Performs a batch of 3D memory copies asynchronously. Performs a batch of memory copies. The batch as a whole executes in stream order but copies within a batch are not guaranteed to execute in any specific order. Note that this means specifying any dependent copies within a batch will result in undefined behavior. Performs memory copies as specified in the ``op_list`` array. The length of this array is specified in ``len(op_list)``. Each entry in this array describes a copy operation. This includes among other things, the source and destination operands for the copy as specified in ``cudaMemcpy3DBatchOp.src`` and ``cudaMemcpy3DBatchOp.dst`` respectively. The source and destination operands of a copy can either be a pointer or a CUDA array. The width, height and depth of a copy is specified in ``cudaMemcpy3DBatchOp.extent``. The width, height and depth of a copy are specified in elements and must not be zero. For pointer-to-pointer copies, the element size is considered to be 1. For pointer to CUDA array or vice versa copies, the element size is determined by the CUDA array. For CUDA array to CUDA array copies, the element size of the two CUDA arrays must match. For a given operand, if ``cudaMemcpy3DOperand.type`` is specified as ``cudaMemcpyOperandTypePointer``, then ``cudaMemcpy3DOperand.op.ptr`` will be used. The ``cudaMemcpy3DOperand.op.ptr.ptr`` field must contain the pointer where the copy should begin. The ``cudaMemcpy3DOperand.op.ptr.rowLength`` field specifies the length of each row in elements and must either be zero or be greater than or equal to the width of the copy specified in ``cudaMemcpy3DBatchOp.extent.width``. The ``cudaMemcpy3DOperand.op.ptr.layerHeight`` field specifies the height of each layer and must either be zero or be greater than or equal to the height of the copy specified in ``cudaMemcpy3DBatchOp.extent.height``. When either of these values is zero, that aspect of the operand is considered to be tightly packed according to the copy extent. For managed memory pointers on devices where ``cudaDevAttrConcurrentManagedAccess`` is true or system-allocated pageable memory on devices where ``cudaDevAttrPageableMemoryAccess`` is true, the ``cudaMemcpy3DOperand.op.ptr.locHint`` field can be used to hint the location of the operand. If an operand's type is specified as ``cudaMemcpyOperandTypeArray``, then ``cudaMemcpy3DOperand.op.array`` will be used. The ``cudaMemcpy3DOperand.op.array.array`` field specifies the CUDA array and ``cudaMemcpy3DOperand.op.array.offset`` specifies the 3D offset into that array where the copy begins. The ``cudaMemcpyAttributes.srcAccessOrder`` indicates the source access ordering to be observed for copies associated with the attribute. If the source access order is set to ``cudaMemcpySrcAccessOrderStream``, then the source will be accessed in stream order. If the source access order is set to ``cudaMemcpySrcAccessOrderDuringApiCall`` then it indicates that access to the source pointer can be out of stream order and all accesses must be complete before the API call returns. This flag is suited for ephemeral sources (ex., stack variables) when it's known that no prior operations in the stream can be accessing the memory and also that the lifetime of the memory is limited to the scope that the source variable was declared in. Specifying this flag allows the driver to optimize the copy and removes the need for the user to synchronize the stream after the API call. If the source access order is set to ``cudaMemcpySrcAccessOrderAny`` then it indicates that access to the source pointer can be out of stream order and the accesses can happen even after the API call returns. This flag is suited for host pointers allocated outside CUDA (ex., via malloc) when it's known that no prior operations in the stream can be accessing the memory. Specifying this flag allows the driver to optimize the copy on certain platforms. Each memcopy operation in ``op_list`` must have a valid srcAccessOrder setting, otherwise this API will return ``cudaErrorInvalidValue``. The ``cudaMemcpyAttributes.flags`` field can be used to specify certain flags for copies. Setting the ``cudaMemcpyFlagPreferOverlapWithCompute`` flag indicates that the associated copies should preferably overlap with any compute work. Note that this flag is a hint and can be ignored depending on the platform and other parameters of the copy. Args: op_list (MemCpy3dBatchOp): Array of size ``len(op_list)`` containing the actual memcpy operations. It must be: - a :class:`MemCpy3dBatchOp`, or - ``None`` for NULL. flags (unsigned long long): Flags for future use, must be zero now. stream (intptr_t): The stream to enqueue the operations in. Must not be default NULL stream. .. seealso:: `cudaMemcpy3DBatchAsync` """ cdef intptr_t _op_list_ptr_ = 0 cdef Py_ssize_t _op_list_len_ = 0 if op_list is None: pass else: (op_list) _op_list_ptr_ = int(op_list) _op_list_len_ = len(op_list) cdef Py_ssize_t _num_ops_length_ = 0 cdef bint _num_ops_is_set_ = False if op_list is not None: _num_ops_length_ = _cyb_check_same_length(_num_ops_is_set_, _num_ops_length_, _op_list_len_, "op_list", "op_list") _num_ops_is_set_ = True cdef size_t num_ops = _num_ops_length_ if num_ops != _num_ops_length_: raise OverflowError( f"The length of (op_list), {_num_ops_length_}, does not fit in 'numOps' (a size_t)" ) with nogil: __status__ = cudaMemcpy3DBatchAsync(num_ops, _op_list_ptr_, flags, stream) check_status(__status__) cpdef memcpy_2d_async(dst, size_t dpitch, src, size_t spitch, size_t width, size_t height, int kind, intptr_t stream): """Copies data between host and device. Copies a matrix (``height`` rows of ``width`` bytes each) from the memory area pointed to by ``src`` to the memory area pointed to by ``dst``, where ``kind`` specifies the direction of the copy, and must be one of ``cudaMemcpyHostToHost``, ``cudaMemcpyHostToDevice``, ``cudaMemcpyDeviceToHost``, ``cudaMemcpyDeviceToDevice``, or ``cudaMemcpyDefault``. Passing ``cudaMemcpyDefault`` is recommended, in which case the type of transfer is inferred from the pointer values. However, ``cudaMemcpyDefault`` is only allowed on systems that support unified virtual addressing. ``dpitch`` and ``spitch`` are the widths in memory in bytes of the 2D arrays pointed to by ``dst`` and ``src``, including any padding added to the end of each row. The memory areas may not overlap. ``width`` must not exceed either ``dpitch`` or ``spitch``. Calling :func:`memcpy_2d_async` with ``dst`` and ``src`` pointers that do not match the direction of the copy results in an undefined behavior. :func:`memcpy_2d_async` returns an error if ``dpitch`` or ``spitch`` is greater than the maximum allowed. :func:`memcpy_2d_async` is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero ``stream`` argument. If ``kind`` is ``cudaMemcpyHostToDevice`` or ``cudaMemcpyDeviceToHost`` and ``stream`` is non-zero, the copy may overlap with operations in other streams. The device version of this function only handles device to device copies and cannot be given local or shared pointers. Args: dst (bytes): Destination memory address. dpitch (size_t): Pitch of destination memory. src (bytes): Source memory address. spitch (size_t): Pitch of source memory. width (size_t): Width of matrix transfer (columns in bytes). height (size_t): Height of matrix transfer (rows). kind (MemCpyKind): Type of transfer. stream (intptr_t): Stream identifier. .. seealso:: `cudaMemcpy2DAsync` """ cdef _cyb_BufferGuard _dst_guard_ = _cyb_BufferGuard(dst, 0, False, False, True) cdef void* _dst_ = _dst_guard_.ptr cdef _cyb_BufferGuard _src_guard_ = _cyb_BufferGuard(src, 0, False, True, True) cdef void* _src_ = _src_guard_.ptr with nogil: __status__ = cudaMemcpy2DAsync(_dst_, dpitch, _src_, spitch, width, height, kind, stream) check_status(__status__) cpdef memcpy_2d_to_array_async(intptr_t dst, size_t w_offset, size_t h_offset, src, size_t spitch, size_t width, size_t height, int kind, intptr_t stream): """Copies data between host and device. Copies a matrix (``height`` rows of ``width`` bytes each) from the memory area pointed to by ``src`` to the CUDA array ``dst`` starting at ``h_offset`` rows and ``w_offset`` bytes from the upper left corner, where ``kind`` specifies the direction of the copy, and must be one of ``cudaMemcpyHostToHost``, ``cudaMemcpyHostToDevice``, ``cudaMemcpyDeviceToHost``, ``cudaMemcpyDeviceToDevice``, or ``cudaMemcpyDefault``. Passing ``cudaMemcpyDefault`` is recommended, in which case the type of transfer is inferred from the pointer values. However, ``cudaMemcpyDefault`` is only allowed on systems that support unified virtual addressing. ``spitch`` is the width in memory in bytes of the 2D array pointed to by ``src``, including any padding added to the end of each row. ``w_offset`` + ``width`` must not exceed the width of the CUDA array ``dst``. ``width`` must not exceed ``spitch``. :func:`memcpy_2d_to_array_async` returns an error if ``spitch`` exceeds the maximum allowed. :func:`memcpy_2d_to_array_async` is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero ``stream`` argument. If ``kind`` is ``cudaMemcpyHostToDevice`` or ``cudaMemcpyDeviceToHost`` and ``stream`` is non-zero, the copy may overlap with operations in other streams. ``cudaMemcpy2DFromArrayAsync``, ``cudaMemcpyToSymbolAsync``, ``cudaMemcpyFromSymbolAsync``, ``cuMemcpy2DAsync``. Args: dst (intptr_t): Destination memory address. w_offset (size_t): Destination starting X offset (columns in bytes). h_offset (size_t): Destination starting Y offset (rows). src (bytes): Source memory address. spitch (size_t): Pitch of source memory. width (size_t): Width of matrix transfer (columns in bytes). height (size_t): Height of matrix transfer (rows). kind (MemCpyKind): Type of transfer. stream (intptr_t): Stream identifier. .. seealso:: `cudaMemcpy2DToArrayAsync` """ cdef _cyb_BufferGuard _src_guard_ = _cyb_BufferGuard(src, 0, False, True, True) cdef void* _src_ = _src_guard_.ptr with nogil: __status__ = cudaMemcpy2DToArrayAsync(dst, w_offset, h_offset, _src_, spitch, width, height, kind, stream) check_status(__status__) cpdef memcpy_2d_from_array_async(dst, size_t dpitch, intptr_t src, size_t w_offset, size_t h_offset, size_t width, size_t height, int kind, intptr_t stream): """Copies data between host and device. Copies a matrix (``height`` rows of ``width`` bytes each) from the CUDA array ``src`` starting at ``h_offset`` rows and ``w_offset`` bytes from the upper left corner to the memory area pointed to by ``dst``, where ``kind`` specifies the direction of the copy, and must be one of ``cudaMemcpyHostToHost``, ``cudaMemcpyHostToDevice``, ``cudaMemcpyDeviceToHost``, ``cudaMemcpyDeviceToDevice``, or ``cudaMemcpyDefault``. Passing ``cudaMemcpyDefault`` is recommended, in which case the type of transfer is inferred from the pointer values. However, ``cudaMemcpyDefault`` is only allowed on systems that support unified virtual addressing. ``dpitch`` is the width in memory in bytes of the 2D array pointed to by ``dst``, including any padding added to the end of each row. ``w_offset`` + ``width`` must not exceed the width of the CUDA array ``src``. ``width`` must not exceed ``dpitch``. :func:`memcpy_2d_from_array_async` returns an error if ``dpitch`` exceeds the maximum allowed. :func:`memcpy_2d_from_array_async` is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero ``stream`` argument. If ``kind`` is ``cudaMemcpyHostToDevice`` or ``cudaMemcpyDeviceToHost`` and ``stream`` is non-zero, the copy may overlap with operations in other streams. ``cudaMemcpyToSymbolAsync``, ``cudaMemcpyFromSymbolAsync``, ``cuMemcpy2DAsync``. Args: dst (bytes): Destination memory address. dpitch (size_t): Pitch of destination memory. src (intptr_t): Source memory address. w_offset (size_t): Source starting X offset (columns in bytes). h_offset (size_t): Source starting Y offset (rows). width (size_t): Width of matrix transfer (columns in bytes). height (size_t): Height of matrix transfer (rows). kind (MemCpyKind): Type of transfer. stream (intptr_t): Stream identifier. .. seealso:: `cudaMemcpy2DFromArrayAsync` """ cdef _cyb_BufferGuard _dst_guard_ = _cyb_BufferGuard(dst, 0, False, False, True) cdef void* _dst_ = _dst_guard_.ptr with nogil: __status__ = cudaMemcpy2DFromArrayAsync(_dst_, dpitch, src, w_offset, h_offset, width, height, kind, stream) check_status(__status__) cpdef memset(intptr_t dev_ptr, int value, size_t count): """Initializes or sets device memory to a value. Fills the first ``count`` bytes of the memory area pointed to by ``dev_ptr`` with the constant byte value ``value``. Note that this function is asynchronous with respect to the host unless ``dev_ptr`` refers to pinned host memory. Args: dev_ptr (intptr_t): Pointer to device memory. value (int): Value to set for each byte of specified memory. count (size_t): Size in bytes to set. .. seealso:: `cudaMemset` """ with nogil: __status__ = cudaMemset(dev_ptr, value, count) check_status(__status__) cpdef memset_2d(intptr_t dev_ptr, size_t pitch, int value, size_t width, size_t height): """Initializes or sets device memory to a value. Sets to the specified value ``value`` a matrix (``height`` rows of ``width`` bytes each) pointed to by ``dstPtr``. ``pitch`` is the width in bytes of the 2D array pointed to by ``dstPtr``, including any padding added to the end of each row. This function performs fastest when the pitch is one that has been passed back by :func:`malloc_pitch`. Note that this function is asynchronous with respect to the host unless ``dev_ptr`` refers to pinned host memory. Args: dev_ptr (intptr_t): Pointer to 2D device memory. pitch (size_t): Pitch in bytes of 2D device memory(Unused if ``height`` is 1). value (int): Value to set for each byte of specified memory. width (size_t): Width of matrix set (columns in bytes). height (size_t): Height of matrix set (rows). .. seealso:: `cudaMemset2D` """ with nogil: __status__ = cudaMemset2D(dev_ptr, pitch, value, width, height) check_status(__status__) cpdef memset_3d(pitched_dev_ptr, int value, extent): """Initializes or sets device memory to a value. Initializes each element of a 3D array to the specified value ``value``. The object to initialize is defined by ``pitched_dev_ptr``. The ``pitch`` field of ``pitched_dev_ptr`` is the width in memory in bytes of the 3D array pointed to by ``pitched_dev_ptr``, including any padding added to the end of each row. The ``xsize`` field specifies the logical width of each row in bytes, while the ``ysize`` field specifies the height of each 2D slice in rows. The ``pitch`` field of ``pitched_dev_ptr`` is ignored when ``height`` and ``depth`` are both equal to 1. The extents of the initialized region are specified as a ``width`` in bytes, a ``height`` in rows, and a ``depth`` in slices. Extents with ``width`` greater than or equal to the ``xsize`` of ``pitched_dev_ptr`` may perform significantly faster than extents narrower than the ``xsize``. Secondarily, extents with ``height`` equal to the ``ysize`` of ``pitched_dev_ptr`` will perform faster than when the ``height`` is shorter than the ``ysize``. This function performs fastest when the ``pitched_dev_ptr`` has been allocated by :func:`malloc_3d`. Note that this function is asynchronous with respect to the host unless ``pitched_dev_ptr`` refers to pinned host memory. Args: pitched_dev_ptr (cudaPitchedPtr): Pointer to pitched device memory. value (int): Value to set for each byte of specified memory. extent (cudaExtent): Size parameters for where to set device memory (``width`` field in bytes). .. seealso:: `cudaMemset3D` """ cdef intptr_t _pitched_dev_ptr_ptr_ = (pitched_dev_ptr)._get_ptr() cdef intptr_t _extent_ptr_ = (extent)._get_ptr() with nogil: __status__ = cudaMemset3D((_pitched_dev_ptr_ptr_)[0], value, (_extent_ptr_)[0]) check_status(__status__) cpdef memset_async(intptr_t dev_ptr, int value, size_t count, intptr_t stream): """Initializes or sets device memory to a value. Fills the first ``count`` bytes of the memory area pointed to by ``dev_ptr`` with the constant byte value ``value``. :func:`memset_async` is asynchronous with respect to the host, so the call may return before the memset is complete. The operation can optionally be associated to a stream by passing a non-zero ``stream`` argument. If ``stream`` is non-zero, the operation may overlap with operations in other streams. The device version of this function only handles device to device copies and cannot be given local or shared pointers. Args: dev_ptr (intptr_t): Pointer to device memory. value (int): Value to set for each byte of specified memory. count (size_t): Size in bytes to set. stream (intptr_t): Stream identifier. .. seealso:: `cudaMemsetAsync` """ with nogil: __status__ = cudaMemsetAsync(dev_ptr, value, count, stream) check_status(__status__) cpdef memset_2d_async(intptr_t dev_ptr, size_t pitch, int value, size_t width, size_t height, intptr_t stream): """Initializes or sets device memory to a value. Sets to the specified value ``value`` a matrix (``height`` rows of ``width`` bytes each) pointed to by ``dstPtr``. ``pitch`` is the width in bytes of the 2D array pointed to by ``dstPtr``, including any padding added to the end of each row. This function performs fastest when the pitch is one that has been passed back by :func:`malloc_pitch`. :func:`memset_2d_async` is asynchronous with respect to the host, so the call may return before the memset is complete. The operation can optionally be associated to a stream by passing a non-zero ``stream`` argument. If ``stream`` is non-zero, the operation may overlap with operations in other streams. The device version of this function only handles device to device copies and cannot be given local or shared pointers. Args: dev_ptr (intptr_t): Pointer to 2D device memory. pitch (size_t): Pitch in bytes of 2D device memory(Unused if ``height`` is 1). value (int): Value to set for each byte of specified memory. width (size_t): Width of matrix set (columns in bytes). height (size_t): Height of matrix set (rows). stream (intptr_t): Stream identifier. .. seealso:: `cudaMemset2DAsync` """ with nogil: __status__ = cudaMemset2DAsync(dev_ptr, pitch, value, width, height, stream) check_status(__status__) cpdef memset_3d_async(pitched_dev_ptr, int value, extent, intptr_t stream): """Initializes or sets device memory to a value. Initializes each element of a 3D array to the specified value ``value``. The object to initialize is defined by ``pitched_dev_ptr``. The ``pitch`` field of ``pitched_dev_ptr`` is the width in memory in bytes of the 3D array pointed to by ``pitched_dev_ptr``, including any padding added to the end of each row. The ``xsize`` field specifies the logical width of each row in bytes, while the ``ysize`` field specifies the height of each 2D slice in rows. The ``pitch`` field of ``pitched_dev_ptr`` is ignored when ``height`` and ``depth`` are both equal to 1. The extents of the initialized region are specified as a ``width`` in bytes, a ``height`` in rows, and a ``depth`` in slices. Extents with ``width`` greater than or equal to the ``xsize`` of ``pitched_dev_ptr`` may perform significantly faster than extents narrower than the ``xsize``. Secondarily, extents with ``height`` equal to the ``ysize`` of ``pitched_dev_ptr`` will perform faster than when the ``height`` is shorter than the ``ysize``. This function performs fastest when the ``pitched_dev_ptr`` has been allocated by :func:`malloc_3d`. :func:`memset_3d_async` is asynchronous with respect to the host, so the call may return before the memset is complete. The operation can optionally be associated to a stream by passing a non-zero ``stream`` argument. If ``stream`` is non-zero, the operation may overlap with operations in other streams. The device version of this function only handles device to device copies and cannot be given local or shared pointers. Args: pitched_dev_ptr (cudaPitchedPtr): Pointer to pitched device memory. value (int): Value to set for each byte of specified memory. extent (cudaExtent): Size parameters for where to set device memory (``width`` field in bytes). stream (intptr_t): Stream identifier. .. seealso:: `cudaMemset3DAsync` """ cdef intptr_t _pitched_dev_ptr_ptr_ = (pitched_dev_ptr)._get_ptr() cdef intptr_t _extent_ptr_ = (extent)._get_ptr() with nogil: __status__ = cudaMemset3DAsync((_pitched_dev_ptr_ptr_)[0], value, (_extent_ptr_)[0], stream) check_status(__status__) cpdef mem_prefetch_async(intptr_t dev_ptr, size_t count, location, unsigned int flags, intptr_t stream): """Prefetches memory to the specified destination location. Prefetches memory to the specified destination location. ``dev_ptr`` is the base device pointer of the memory to be prefetched and ``location`` specifies the destination location. ``count`` specifies the number of bytes to copy. ``stream`` is the stream in which the operation is enqueued. The memory range must refer to managed memory allocated via ``cudaMallocManaged`` or declared via managed variables, or it may also refer to memory allocated from a managed memory pool, or it may also refer to system-allocated memory on systems with non-zero cudaDevAttrPageableMemoryAccess. Specifying ``cudaMemLocationTypeDevice`` for ``cudaMemLocation.type`` will prefetch memory to GPU specified by device ordinal ``cudaMemLocation.id`` which must have non-zero value for the device attribute ``concurrentManagedAccess``. Additionally, ``stream`` must be associated with a device that has a non-zero value for the device attribute ``concurrentManagedAccess``. Specifying ``cudaMemLocationTypeHost`` as ``cudaMemLocation.type`` will prefetch data to host memory. Applications can request prefetching memory to a specific host NUMA node by specifying ``cudaMemLocationTypeHostNuma`` for ``cudaMemLocation.type`` and a valid host NUMA node id in ``cudaMemLocation.id`` Users can also request prefetching memory to the host NUMA node closest to the current thread's CPU by specifying ``cudaMemLocationTypeHostNumaCurrent`` for ``cudaMemLocation.type``. Note when ``cudaMemLocation.type`` is etiher ``cudaMemLocationTypeHost`` OR ``cudaMemLocationTypeHostNumaCurrent``, ``cudaMemLocation.id`` will be ignored. Prefetching to ``cudaMemLocationTypeDeviceLocalityDomain`` locations is not supported. The start address and end address of the memory range will be rounded down and rounded up respectively to be aligned to CPU page size before the prefetch operation is enqueued in the stream. If no physical memory has been allocated for this region, then this memory region will be populated and mapped on the destination device. If there's insufficient memory to prefetch the desired region, the Unified Memory driver may evict pages from other ``cudaMallocManaged`` allocations to host memory in order to make room. Device memory allocated using ``cudaMalloc`` or ``cudaMallocArray`` will not be evicted. By default, any mappings to the previous location of the migrated pages are removed and mappings for the new location are only setup on the destination location. The exact behavior however also depends on the settings applied to this memory range via ``cuMemAdvise`` as described below:. If ``cudaMemAdviseSetReadMostly`` was set on any subset of this memory range, then that subset will create a read-only copy of the pages on destination location. If however the destination location is a host NUMA node, then any pages of that subset that are already in another host NUMA node will be transferred to the destination. If ``cudaMemAdviseSetPreferredLocation`` was called on any subset of this memory range, then the pages will be migrated to ``location`` even if ``location`` is not the preferred location of any pages in the memory range. If ``cudaMemAdviseSetAccessedBy`` was called on any subset of this memory range, then mappings to those pages from all the appropriate processors are updated to refer to the new location if establishing such a mapping is possible. Otherwise, those mappings are cleared. Note that this API is not required for functionality and only serves to improve performance by allowing the application to migrate data to a suitable location before it is accessed. Memory accesses to this range are always coherent and are allowed even when the data is actively being migrated. Note that this function is asynchronous with respect to the host and all work on other devices. Args: dev_ptr (intptr_t): Pointer to be prefetched. count (size_t): Size in bytes. location (cudaMemLocation): location to prefetch to. flags (unsigned int): flags for future use, must be zero now. stream (intptr_t): Stream to enqueue prefetch operation. .. seealso:: `cudaMemPrefetchAsync` """ cdef intptr_t _location_ptr_ = (location)._get_ptr() with nogil: __status__ = cudaMemPrefetchAsync(dev_ptr, count, (_location_ptr_)[0], flags, stream) check_status(__status__) cpdef mem_advise(intptr_t dev_ptr, size_t count, int advice, location): """Advise about the usage of a given memory range. Advise the Unified Memory subsystem about the usage pattern for the memory range starting at ``dev_ptr`` with a size of ``count`` bytes. The start address and end address of the memory range will be rounded down and rounded up respectively to be aligned to CPU page size before the advice is applied. The memory range must refer to managed memory allocated via ``cudaMallocManaged`` or declared via managed variables. The memory range could also refer to system-allocated pageable memory provided it represents a valid, host-accessible region of memory and all additional constraints imposed by ``advice`` as outlined below are also satisfied. Specifying an invalid system-allocated pageable memory range results in an error being returned. The ``advice`` parameter can take the following values:. - ``cudaMemAdviseSetReadMostly``: This implies that the data is mostly going to be read from and only occasionally written to. Any read accesses from any processor to this region will create a read-only copy of at least the accessed pages in that processor's memory. Additionally, if ``cudaMemPrefetchAsync`` or ``cudaMemPrefetchAsync`` is called on this region, it will create a read-only copy of the data on the destination processor. If the target location for ``cudaMemPrefetchAsync`` is a host NUMA node and a read-only copy already exists on another host NUMA node, that copy will be migrated to the targeted host NUMA node. If any processor writes to this region, all copies of the corresponding page will be invalidated except for the one where the write occurred. If the writing processor is the CPU and the preferred location of the page is a host NUMA node, then the page will also be migrated to that host NUMA node. The ``location`` argument is ignored for this advice. Note that for a page to be read-duplicated, the accessing processor must either be the CPU or a GPU that has a non-zero value for the device attribute ``cudaDevAttrConcurrentManagedAccess``. Also, if a context is created on a device that does not have the device attribute ``cudaDevAttrConcurrentManagedAccess`` set, then read-duplication will not occur until all such contexts are destroyed. If the memory region refers to valid system-allocated pageable memory, then the accessing device must have a non-zero value for the device attribute ``cudaDevAttrPageableMemoryAccess`` for a read-only copy to be created on that device. Note however that if the accessing device also has a non-zero value for the device attribute ``cudaDevAttrPageableMemoryAccessUsesHostPageTables``, then setting this advice will not create a read-only copy when that device accesses this memory region. - ``cudaMemAdviceUnsetReadMostly``: Undoes the effect of ``cudaMemAdviseSetReadMostly`` and also prevents the Unified Memory driver from attempting heuristic read-duplication on the memory range. Any read-duplicated copies of the data will be collapsed into a single copy. The location for the collapsed copy will be the preferred location if the page has a preferred location and one of the read-duplicated copies was resident at that location. Otherwise, the location chosen is arbitrary. Note: The ``location`` argument is ignored for this advice. - ``cudaMemAdviseSetPreferredLocation``: This advice sets the preferred location for the data to be the memory belonging to ``location``. When ``cudaMemLocation.type`` is ``cudaMemLocationTypeHost``, ``cudaMemLocation.id`` is ignored and the preferred location is set to be host memory. To set the preferred location to a specific host NUMA node, applications must set ``cudaMemLocation.type`` to ``cudaMemLocationTypeHostNuma`` and ``cudaMemLocation.id`` must specify the NUMA ID of the host NUMA node. If ``cudaMemLocation.type`` is set to ``cudaMemLocationTypeHostNumaCurrent``, ``cudaMemLocation.id`` will be ignored and the host NUMA node closest to the calling thread's CPU will be used as the preferred location. If ``cudaMemLocation.type`` is a ``cudaMemLocationTypeDevice``, then ``cudaMemLocation.id`` must be a valid device ordinal and the device must have a non-zero value for the device attribute ``cudaDevAttrConcurrentManagedAccess``. Setting the preferred location does not cause data to migrate to that location immediately. Instead, it guides the migration policy when a fault occurs on that memory region. If the data is already in its preferred location and the faulting processor can establish a mapping without requiring the data to be migrated, then data migration will be avoided. On the other hand, if the data is not in its preferred location or if a direct mapping cannot be established, then it will be migrated to the processor accessing it. It is important to note that setting the preferred location does not prevent data prefetching done using ``cudaMemPrefetchAsync``. Having a preferred location can override the page thrash detection and resolution logic in the Unified Memory driver. Normally, if a page is detected to be constantly thrashing between for example host and device memory, the page may eventually be pinned to host memory by the Unified Memory driver. But if the preferred location is set as device memory, then the page will continue to thrash indefinitely. If ``cudaMemAdviseSetReadMostly`` is also set on this memory region or any subset of it, then the policies associated with that advice will override the policies of this advice, unless read accesses from ``location`` will not result in a read-only copy being created on that procesor as outlined in description for the advice ``cudaMemAdviseSetReadMostly``. If the memory region refers to valid system-allocated pageable memory, and ``cudaMemLocation.type`` is ``cudaMemLocationTypeDevice`` then ``cudaMemLocation.id`` must be a valid device that has a non-zero alue for the device attribute ``cudaDevAttrPageableMemoryAccess``. - ``cudaMemAdviseUnsetPreferredLocation``: Undoes the effect of ``cudaMemAdviseSetPreferredLocation`` and changes the preferred location to none. The ``location`` argument is ignored for this advice. - ``cudaMemAdviseSetAccessedBy``: This advice implies that the data will be accessed by processor ``location``. The ``cudaMemLocation.type`` must be either ``cudaMemLocationTypeDevice`` with ``cudaMemLocation.id`` representing a valid device ordinal or ``cudaMemLocationTypeHost`` and ``cudaMemLocation.id`` will be ignored. All other location types are invalid. If ``cudaMemLocation.id`` is a GPU, then the device attribute ``cudaDevAttrConcurrentManagedAccess`` must be non-zero. This advice does not cause data migration and has no impact on the location of the data per se. Instead, it causes the data to always be mapped in the specified processor's page tables, as long as the location of the data permits a mapping to be established. If the data gets migrated for any reason, the mappings are updated accordingly. This advice is recommended in scenarios where data locality is not important, but avoiding faults is. Consider for example a system containing multiple GPUs with peer-to-peer access enabled, where the data located on one GPU is occasionally accessed by peer GPUs. In such scenarios, migrating data over to the other GPUs is not as important because the accesses are infrequent and the overhead of migration may be too high. But preventing faults can still help improve performance, and so having a mapping set up in advance is useful. Note that on CPU access of this data, the data may be migrated to host memory because the CPU typically cannot access device memory directly. Any GPU that had the ``cudaMemAdviseSetAccessedBy`` flag set for this data will now have its mapping updated to point to the page in host memory. If ``cudaMemAdviseSetReadMostly`` is also set on this memory region or any subset of it, then the policies associated with that advice will override the policies of this advice. Additionally, if the preferred location of this memory region or any subset of it is also ``location``, then the policies associated with ``CU_MEM_ADVISE_SET_PREFERRED_LOCATION`` will override the policies of this advice. If the memory region refers to valid system-allocated pageable memory, and ``cudaMemLocation.type`` is ``cudaMemLocationTypeDevice`` then device in ``cudaMemLocation.id`` must have a non-zero value for the device attribute ``cudaDevAttrPageableMemoryAccess``. Additionally, if ``cudaMemLocation.id`` has a non-zero value for the device attribute ``cudaDevAttrPageableMemoryAccessUsesHostPageTables``, then this call has no effect. - ``CU_MEM_ADVISE_UNSET_ACCESSED_BY``: Undoes the effect of ``cudaMemAdviseSetAccessedBy``. Any mappings to the data from ``location`` may be removed at any time causing accesses to result in non-fatal page faults. If the memory region refers to valid system-allocated pageable memory, and ``cudaMemLocation.type`` is ``cudaMemLocationTypeDevice`` then device in ``cudaMemLocation.id`` must have a non-zero value for the device attribute ``cudaDevAttrPageableMemoryAccess``. Additionally, if ``cudaMemLocation.id`` has a non-zero value for the device attribute ``cudaDevAttrPageableMemoryAccessUsesHostPageTables``, then this call has no effect. Args: dev_ptr (intptr_t): Pointer to memory to set the advice for. count (size_t): Size in bytes of the memory range. advice (MemoryAdvise): Advice to be applied for the specified memory range. location (cudaMemLocation): location to apply the advice for. .. seealso:: `cudaMemAdvise` """ cdef intptr_t _location_ptr_ = (location)._get_ptr() with nogil: __status__ = cudaMemAdvise(dev_ptr, count, advice, (_location_ptr_)[0]) check_status(__status__) cpdef memcpy_to_array(intptr_t dst, size_t w_offset, size_t h_offset, src, size_t count, int kind): """Copies data between host and device. [Deprecated]. Copies ``count`` bytes from the memory area pointed to by ``src`` to the CUDA array ``dst`` starting at ``h_offset`` rows and ``w_offset`` bytes from the upper left corner, where ``kind`` specifies the direction of the copy, and must be one of ``cudaMemcpyHostToHost``, ``cudaMemcpyHostToDevice``, ``cudaMemcpyDeviceToHost``, ``cudaMemcpyDeviceToDevice``, or ``cudaMemcpyDefault``. Passing ``cudaMemcpyDefault`` is recommended, in which case the type of transfer is inferred from the pointer values. However, ``cudaMemcpyDefault`` is only allowed on systems that support unified virtual addressing. Args: dst (intptr_t): Destination memory address. w_offset (size_t): Destination starting X offset (columns in bytes). h_offset (size_t): Destination starting Y offset (rows). src (bytes): Source memory address. count (size_t): Size in bytes to copy. kind (MemCpyKind): Type of transfer. .. seealso:: `cudaMemcpyToArray` """ cdef _cyb_BufferGuard _src_guard_ = _cyb_BufferGuard(src, 0, False, True, True) cdef void* _src_ = _src_guard_.ptr with nogil: __status__ = cudaMemcpyToArray(dst, w_offset, h_offset, _src_, count, kind) check_status(__status__) cpdef memcpy_from_array(dst, intptr_t src, size_t w_offset, size_t h_offset, size_t count, int kind): """Copies data between host and device. [Deprecated]. Copies ``count`` bytes from the CUDA array ``src`` starting at ``h_offset`` rows and ``w_offset`` bytes from the upper left corner to the memory area pointed to by ``dst``, where ``kind`` specifies the direction of the copy, and must be one of ``cudaMemcpyHostToHost``, ``cudaMemcpyHostToDevice``, ``cudaMemcpyDeviceToHost``, ``cudaMemcpyDeviceToDevice``, or ``cudaMemcpyDefault``. Passing ``cudaMemcpyDefault`` is recommended, in which case the type of transfer is inferred from the pointer values. However, ``cudaMemcpyDefault`` is only allowed on systems that support unified virtual addressing. Args: dst (bytes): Destination memory address. src (intptr_t): Source memory address. w_offset (size_t): Source starting X offset (columns in bytes). h_offset (size_t): Source starting Y offset (rows). count (size_t): Size in bytes to copy. kind (MemCpyKind): Type of transfer. .. seealso:: `cudaMemcpyFromArray` """ cdef _cyb_BufferGuard _dst_guard_ = _cyb_BufferGuard(dst, 0, False, False, True) cdef void* _dst_ = _dst_guard_.ptr with nogil: __status__ = cudaMemcpyFromArray(_dst_, src, w_offset, h_offset, count, kind) check_status(__status__) cpdef memcpy_array_to_array(intptr_t dst, size_t w_offset_dst, size_t h_offset_dst, intptr_t src, size_t w_offset_src, size_t h_offset_src, size_t count, int kind): """Copies data between host and device. [Deprecated]. Copies ``count`` bytes from the CUDA array ``src`` starting at ``h_offset_src`` rows and ``w_offset_src`` bytes from the upper left corner to the CUDA array ``dst`` starting at ``h_offset_dst`` rows and ``w_offset_dst`` bytes from the upper left corner, where ``kind`` specifies the direction of the copy, and must be one of ``cudaMemcpyHostToHost``, ``cudaMemcpyHostToDevice``, ``cudaMemcpyDeviceToHost``, ``cudaMemcpyDeviceToDevice``, or ``cudaMemcpyDefault``. Passing ``cudaMemcpyDefault`` is recommended, in which case the type of transfer is inferred from the pointer values. However, ``cudaMemcpyDefault`` is only allowed on systems that support unified virtual addressing. Args: dst (intptr_t): Destination memory address. w_offset_dst (size_t): Destination starting X offset (columns in bytes). h_offset_dst (size_t): Destination starting Y offset (rows). src (intptr_t): Source memory address. w_offset_src (size_t): Source starting X offset (columns in bytes). h_offset_src (size_t): Source starting Y offset (rows). count (size_t): Size in bytes to copy. kind (MemCpyKind): Type of transfer. .. seealso:: `cudaMemcpyArrayToArray` """ with nogil: __status__ = cudaMemcpyArrayToArray(dst, w_offset_dst, h_offset_dst, src, w_offset_src, h_offset_src, count, kind) check_status(__status__) cpdef memcpy_to_array_async(intptr_t dst, size_t w_offset, size_t h_offset, src, size_t count, int kind, intptr_t stream): """Copies data between host and device. [Deprecated]. Copies ``count`` bytes from the memory area pointed to by ``src`` to the CUDA array ``dst`` starting at ``h_offset`` rows and ``w_offset`` bytes from the upper left corner, where ``kind`` specifies the direction of the copy, and must be one of ``cudaMemcpyHostToHost``, ``cudaMemcpyHostToDevice``, ``cudaMemcpyDeviceToHost``, ``cudaMemcpyDeviceToDevice``, or ``cudaMemcpyDefault``. Passing ``cudaMemcpyDefault`` is recommended, in which case the type of transfer is inferred from the pointer values. However, ``cudaMemcpyDefault`` is only allowed on systems that support unified virtual addressing. :func:`memcpy_to_array_async` is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero ``stream`` argument. If ``kind`` is ``cudaMemcpyHostToDevice`` or ``cudaMemcpyDeviceToHost`` and ``stream`` is non-zero, the copy may overlap with operations in other streams. Args: dst (intptr_t): Destination memory address. w_offset (size_t): Destination starting X offset (columns in bytes). h_offset (size_t): Destination starting Y offset (rows). src (bytes): Source memory address. count (size_t): Size in bytes to copy. kind (MemCpyKind): Type of transfer. stream (intptr_t): Stream identifier. .. seealso:: `cudaMemcpyToArrayAsync` """ cdef _cyb_BufferGuard _src_guard_ = _cyb_BufferGuard(src, 0, False, True, True) cdef void* _src_ = _src_guard_.ptr with nogil: __status__ = cudaMemcpyToArrayAsync(dst, w_offset, h_offset, _src_, count, kind, stream) check_status(__status__) cpdef memcpy_from_array_async(dst, intptr_t src, size_t w_offset, size_t h_offset, size_t count, int kind, intptr_t stream): """Copies data between host and device. [Deprecated]. Copies ``count`` bytes from the CUDA array ``src`` starting at ``h_offset`` rows and ``w_offset`` bytes from the upper left corner to the memory area pointed to by ``dst``, where ``kind`` specifies the direction of the copy, and must be one of ``cudaMemcpyHostToHost``, ``cudaMemcpyHostToDevice``, ``cudaMemcpyDeviceToHost``, ``cudaMemcpyDeviceToDevice``, or ``cudaMemcpyDefault``. Passing ``cudaMemcpyDefault`` is recommended, in which case the type of transfer is inferred from the pointer values. However, ``cudaMemcpyDefault`` is only allowed on systems that support unified virtual addressing. :func:`memcpy_from_array_async` is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero ``stream`` argument. If ``kind`` is ``cudaMemcpyHostToDevice`` or ``cudaMemcpyDeviceToHost`` and ``stream`` is non-zero, the copy may overlap with operations in other streams. Args: dst (bytes): Destination memory address. src (intptr_t): Source memory address. w_offset (size_t): Source starting X offset (columns in bytes). h_offset (size_t): Source starting Y offset (rows). count (size_t): Size in bytes to copy. kind (MemCpyKind): Type of transfer. stream (intptr_t): Stream identifier. .. seealso:: `cudaMemcpyFromArrayAsync` """ cdef _cyb_BufferGuard _dst_guard_ = _cyb_BufferGuard(dst, 0, False, False, True) cdef void* _dst_ = _dst_guard_.ptr with nogil: __status__ = cudaMemcpyFromArrayAsync(_dst_, src, w_offset, h_offset, count, kind, stream) check_status(__status__) cpdef intptr_t malloc_async(size_t size, intptr_t h_stream) except? 0: """Allocates memory with stream ordered semantics. Inserts an allocation operation into ``h_stream``. A pointer to the allocated memory is returned immediately in \*dptr. The allocation must not be accessed until the the allocation operation completes. The allocation comes from the memory pool associated with the stream's device. Args: size (size_t): Number of bytes to allocate. h_stream (intptr_t): The stream establishing the stream ordering contract and the memory pool to allocate from. Returns: intptr_t: Returned device pointer. .. note:: The default memory pool of a device contains device memory from that device. .. note:: Basic stream ordering allows future work submitted into the same stream to use the allocation. Stream query, stream synchronize, and CUDA events can be used to guarantee that the allocation operation completes before work submitted in a separate stream runs. .. note:: During stream capture, this function results in the creation of an allocation node. In this case, the allocation is owned by the graph instead of the memory pool. The memory pool's properties are used to set the node's creation parameters. .. seealso:: `cudaMallocAsync` """ cdef void* dev_ptr with nogil: __status__ = cudaMallocAsync(&dev_ptr, size, h_stream) check_status(__status__) return dev_ptr cpdef free_async(intptr_t dev_ptr, intptr_t h_stream): """Frees memory with stream ordered semantics. Inserts a free operation into ``h_stream``. The allocation must not be accessed after stream execution reaches the free. After this API returns, accessing the memory from any subsequent work launched on the GPU or querying its pointer attributes results in undefined behavior. Args: dev_ptr (intptr_t): memory to free. h_stream (intptr_t): The stream establishing the stream ordering promise. .. note:: During stream capture, this function results in the creation of a free node and must therefore be passed the address of a graph allocation. .. seealso:: `cudaFreeAsync` """ with nogil: __status__ = cudaFreeAsync(dev_ptr, h_stream) check_status(__status__) cpdef mem_pool_trim_to(intptr_t mem_pool, size_t min_bytes_to_keep): """Tries to release memory back to the OS. Releases memory back to the OS until the pool contains fewer than min_bytes_to_keep reserved bytes, or there is no more memory that the allocator can safely release. The allocator cannot release OS allocations that back outstanding asynchronous allocations. The OS allocations may happen at different granularity from the user allocations. Args: mem_pool (intptr_t): The memory pool to trim. min_bytes_to_keep (size_t): If the pool has less than min_bytes_to_keep reserved, the TrimTo operation is a no-op. Otherwise the pool will be guaranteed to have at least min_bytes_to_keep bytes reserved after the operation. .. note:: : Allocations that have not been freed count as outstanding. .. note:: : Allocations that have been asynchronously freed but whose completion has not been observed on the host (eg. by a synchronize) can count as outstanding. .. seealso:: `cudaMemPoolTrimTo` """ with nogil: __status__ = cudaMemPoolTrimTo(mem_pool, min_bytes_to_keep) check_status(__status__) cpdef mem_pool_set_access(intptr_t mem_pool, desc_list): """Controls visibility of pools between devices. Args: mem_pool (intptr_t): The pool being modified. desc_list (MemAccessDesc): Array of access descriptors. Each descriptor instructs the access to enable for a single gpu. It must be: - a :class:`MemAccessDesc`, or - ``None`` for NULL. .. seealso:: `cudaMemPoolSetAccess` """ cdef intptr_t _desc_list_ptr_ = 0 cdef Py_ssize_t _desc_list_len_ = 0 if desc_list is None: pass else: (desc_list) _desc_list_ptr_ = int(desc_list) _desc_list_len_ = len(desc_list) cdef Py_ssize_t _count_length_ = 0 cdef bint _count_is_set_ = False if desc_list is not None: _count_length_ = _cyb_check_same_length(_count_is_set_, _count_length_, _desc_list_len_, "desc_list", "desc_list") _count_is_set_ = True cdef size_t count = _count_length_ if count != _count_length_: raise OverflowError( f"The length of (desc_list), {_count_length_}, does not fit in 'count' (a size_t)" ) with nogil: __status__ = cudaMemPoolSetAccess(mem_pool, _desc_list_ptr_, count) check_status(__status__) cpdef int mem_pool_get_access(intptr_t mem_pool, location) except? 0: """Returns the accessibility of a pool from a device. Returns the accessibility of the pool's memory from the specified location. Args: mem_pool (intptr_t): the pool being queried. location (intptr_t): the location accessing the pool. Returns: int: the accessibility of the pool from the specified location. .. seealso:: `cudaMemPoolGetAccess` """ cdef intptr_t _location_ptr_ = 0 if location is None else int(location) cdef cudaMemAccessFlags flags with nogil: __status__ = cudaMemPoolGetAccess(&flags, mem_pool, _location_ptr_) check_status(__status__) return flags cpdef intptr_t mem_pool_create(pool_props) except? 0: """Creates a memory pool. Creates a CUDA memory pool and returns the handle in ``pool``. The ``pool_props`` determines the properties of the pool such as the backing device and IPC capabilities. To create a memory pool for host memory not targeting a specific NUMA node, applications must set set ``cudaMemPoolProps.cudaMemLocation.type`` to ``cudaMemLocationTypeHost``. ``cudaMemPoolProps.cudaMemLocation.id`` is ignored for such pools. Pools created with the type ``cudaMemLocationTypeHost`` are not IPC capable and ``cudaMemPoolProps.handleTypes`` must be 0, any other values will result in ``cudaErrorInvalidValue``. To create a memory pool targeting a specific host NUMA node, applications must set ``cudaMemPoolProps.cudaMemLocation.type`` to ``cudaMemLocationTypeHostNuma`` and ``cudaMemPoolProps.cudaMemLocation.id`` must specify the NUMA ID of the host memory node. Specifying ``cudaMemLocationTypeHostNumaCurrent`` as the ``cudaMemPoolProps.cudaMemLocation.type`` will result in ``cudaErrorInvalidValue``. To create a memory pool targeting a specific device locality domain, applications must set ``cudaMemPoolProps.cudaMemLocation.type`` to ``cudaMemLocationTypeDeviceLocalityDomain``, ``cudaMemPoolProps.cudaMemLocation.localized.deviceId`` must specify the device ID, and ``cudaMemPoolProps.cudaMemLocation.localized.localityDomainId`` must specify the locality domain ID. The locality domain ID must be a valid locality domain ID for the specified device. See also ``cudaDeviceGetAttribute`` with the attribute ``cudaDevAttrLocalityDomainCount``. By default, the pool's memory will be accessible from the device it is allocated on. In the case of pools created with ``cudaMemLocationTypeHostNuma`` or ``cudaMemLocationTypeHost``, their default accessibility will be from the host CPU. Applications can control the maximum size of the pool by specifying a non-zero value for ``cudaMemPoolProps.maxSize``. If set to 0, the maximum size of the pool will default to a system dependent value. Applications that intend to use ``CU_MEM_HANDLE_TYPE_FABRIC`` based memory sharing must ensure: (1) ``nvidia-caps-imex-channels`` character device is created by the driver and is listed under /proc/devices (2) have at least one IMEX channel file accessible by the user launching the application. When exporter and importer CUDA processes have been granted access to the same IMEX channel, they can securely share memory. The IMEX channel security model works on a per user basis. Which means all processes under a user can share memory if the user has access to a valid IMEX channel. When multi-user isolation is desired, a separate IMEX channel is required for each user. These channel files exist in /dev/nvidia-caps-imex-channels/channel* and can be created using standard OS native calls like mknod on Linux. For example: To create channel0 with the major number from /proc/devices users can execute the following command: ``mknod /dev/nvidia-caps-imex-channels/channel0 c 0``. To create a managed memory pool, applications must set ``cudaMemPoolProps``:``cudaMemAllocationType`` to ``cudaMemAllocationTypeManaged``. ``cudaMemPoolProps.cudaMemAllocationHandleType`` must also be set to ``cudaMemHandleTypeNone`` since IPC is not supported. For managed memory pools, ``cudaMemPoolProps.cudaMemLocation`` will be treated as the preferred location for all allocations created from the pool. An application can also set ``cudaMemLocationTypeNone`` to indicate no preferred location. ``cudaMemPoolProps.maxSize`` must be set to zero for managed memory pools. ``cudaMemPoolProps.usage`` should be zero as decompress for managed memory is not supported. For managed memory pools, all devices on the system must have non-zero ``concurrentManagedAccess``. If not, this call returns ``cudaErrorNotSupported``. Args: pool_props (intptr_t): Properties of the memory pool to create. Returns: intptr_t: Returned handle of the new memory pool. .. note:: Specifying ``cudaMemHandleTypeNone`` creates a memory pool that will not support IPC. .. seealso:: `cudaMemPoolCreate` """ cdef intptr_t _pool_props_ptr_ = 0 if pool_props is None else int(pool_props) cdef cudaMemPool_t mem_pool with nogil: __status__ = cudaMemPoolCreate(&mem_pool, _pool_props_ptr_) check_status(__status__) return mem_pool cpdef mem_pool_destroy(intptr_t mem_pool): """Destroys the specified memory pool. If any pointers obtained from this pool haven't been freed or the pool has free operations that haven't completed when ``cudaMemPoolDestroy`` is invoked, the function will return immediately and the resources associated with the pool will be released automatically once there are no more outstanding allocations. Destroying the current mempool of a device sets the default mempool of that device as the current mempool for that device. Args: mem_pool (intptr_t): Memory pool to destroy. .. note:: A device's default memory pool cannot be destroyed. .. seealso:: `cudaMemPoolDestroy` """ with nogil: __status__ = cudaMemPoolDestroy(mem_pool) check_status(__status__) cpdef intptr_t malloc_from_pool_async(size_t size, intptr_t mem_pool, intptr_t stream) except? 0: """Allocates memory from a specified pool with stream ordered semantics. Inserts an allocation operation into ``stream``. A pointer to the allocated memory is returned immediately in \*dptr. The allocation must not be accessed until the the allocation operation completes. The allocation comes from the specified memory pool. Args: size (size_t): Number of bytes to allocate. mem_pool (intptr_t): The pool to allocate from. stream (intptr_t): The stream establishing the stream ordering semantic. Returns: intptr_t: Returned device pointer. .. note:: During stream capture, this function results in the creation of an allocation node. In this case, the allocation is owned by the graph instead of the memory pool. The memory pool's properties are used to set the node's creation parameters. .. seealso:: `cudaMallocFromPoolAsync` """ cdef void* ptr with nogil: __status__ = cudaMallocFromPoolAsync(&ptr, size, mem_pool, stream) check_status(__status__) return ptr cpdef intptr_t mem_pool_import_from_shareable_handle(intptr_t shareable_handle, int handle_type, unsigned int flags) except? 0: """imports a memory pool from a shared handle. Specific allocations can be imported from the imported pool with ``cudaMemPoolImportPointer``. Args: shareable_handle (intptr_t): OS handle of the pool to open. handle_type (MemAllocationHandleType): The type of handle being imported. flags (unsigned int): must be 0. Returns: intptr_t: Returned memory pool. .. note:: Imported memory pools do not support creating new allocations. As such imported memory pools may not be used in ``cudaDeviceSetMemPool`` or ``cudaMallocFromPoolAsync`` calls. .. seealso:: `cudaMemPoolImportFromShareableHandle` """ cdef cudaMemPool_t mem_pool with nogil: __status__ = cudaMemPoolImportFromShareableHandle(&mem_pool, shareable_handle, handle_type, flags) check_status(__status__) return mem_pool cpdef object mem_pool_export_pointer(intptr_t ptr): """Export data to share a memory pool allocation between processes. Constructs ``shareData_out`` for sharing a specific allocation from an already shared memory pool. The recipient process can import the allocation with the ``cudaMemPoolImportPointer`` api. The data is not a handle and may be shared through any IPC mechanism. Args: ptr (intptr_t): pointer to memory being exported. Returns: cudaMemPoolPtrExportData: Returned export data. .. seealso:: `cudaMemPoolExportPointer` """ cdef MemPoolPtrExportData export_data_py = MemPoolPtrExportData() cdef cudaMemPoolPtrExportData *export_data = (export_data_py._get_ptr()) with nogil: __status__ = cudaMemPoolExportPointer(export_data, ptr) check_status(__status__) return export_data_py cpdef intptr_t mem_pool_import_pointer(intptr_t mem_pool, export_data) except? 0: """Import a memory pool allocation from another process. Returns in ``ptr_out`` a pointer to the imported memory. The imported memory must not be accessed before the allocation operation completes in the exporting process. The imported memory must be freed from all importing processes before being freed in the exporting process. The pointer may be freed with cudaFree or cudaFreeAsync. If ``cudaFreeAsync`` is used, the free must be completed on the importing process before the free operation on the exporting process. Args: mem_pool (intptr_t): pool from which to import. export_data (intptr_t): data specifying the memory to import. Returns: intptr_t: pointer to imported memory. .. note:: The ``cudaFreeAsync`` api may be used in the exporting process before the ``cudaFreeAsync`` operation completes in its stream as long as the ``cudaFreeAsync`` in the exporting process specifies a stream with a stream dependency on the importing process's ``cudaFreeAsync``. .. seealso:: `cudaMemPoolImportPointer` """ cdef intptr_t _export_data_ptr_ = 0 if export_data is None else int(export_data) cdef void* ptr with nogil: __status__ = cudaMemPoolImportPointer(&ptr, mem_pool, _export_data_ptr_) check_status(__status__) return ptr cpdef object pointer_get_attributes(ptr): """Returns attributes about a specified pointer. Returns in ``*attributes`` the attributes of the pointer ``ptr``. If pointer was not allocated in, mapped by or registered with context supporting unified addressing ``cudaErrorInvalidValue`` is returned. The ``cudaPointerAttributes`` structure is defined as:. \*\*View CUDA Toolkit Documentation for a C++ code example*\*. In this structure, the individual fields mean. - ``cudaPointerAttributes.type`` identifies type of memory. It can be ``cudaMemoryTypeUnregistered`` for unregistered host memory, ``cudaMemoryTypeHost`` for registered host memory, ``cudaMemoryTypeDevice`` for device memory or ``cudaMemoryTypeManaged`` for managed memory. - ``device`` is the device against which ``ptr`` was allocated. If ``ptr`` has memory type ``cudaMemoryTypeDevice`` then this identifies the device on which the memory referred to by ``ptr`` physically resides. If ``ptr`` has memory type ``cudaMemoryTypeHost`` then this identifies the device which was current when the allocation was made (and if that device is deinitialized then this allocation will vanish with that device's state). - ``devicePointer`` is the device pointer alias through which the memory referred to by ``ptr`` may be accessed on the current device. If the memory referred to by ``ptr`` cannot be accessed directly by the current device then this is NULL. - ``hostPointer`` is the host pointer alias through which the memory referred to by ``ptr`` may be accessed on the host. If the memory referred to by ``ptr`` cannot be accessed directly by the host then this is NULL. - localityDomainOrdinal is the locality domain ordinal for device allocations localized to a locality domain, or -1 when the allocation is not localized to a locality domain. Args: ptr (bytes): Pointer to get attributes for. Returns: cudaPointerAttributes: Attributes for the specified pointer. .. note:: In CUDA 11.0 forward passing host pointer will return ``cudaMemoryTypeUnregistered`` in ``cudaPointerAttributes.type`` and call will return ``cudaSuccess``. .. seealso:: `cudaPointerGetAttributes` """ cdef _cyb_BufferGuard _ptr_guard_ = _cyb_BufferGuard(ptr, 0, False, True, True) cdef void* _ptr_ = _ptr_guard_.ptr cdef PointerAttributes attributes_py = PointerAttributes() cdef cudaPointerAttributes *attributes = (attributes_py._get_ptr()) with nogil: __status__ = cudaPointerGetAttributes(attributes, _ptr_) check_status(__status__) return attributes_py cpdef int device_can_access_peer(int device, int peer_device) except? -1: """Queries if a device may directly access a peer device's memory. Returns in ``*can_access_peer`` a value of 1 if device ``device`` is capable of directly accessing memory from ``peer_device`` and 0 otherwise. If direct access of ``peer_device`` from ``device`` is possible, then access may be enabled by calling :func:`device_enable_peer_access`. Args: device (int): Device from which allocations on ``peer_device`` are to be directly accessed. peer_device (int): Device on which the allocations to be directly accessed by ``device`` reside. Returns: int: Returned access capability. .. seealso:: `cudaDeviceCanAccessPeer` """ cdef int can_access_peer with nogil: __status__ = cudaDeviceCanAccessPeer(&can_access_peer, device, peer_device) check_status(__status__) return can_access_peer cpdef device_enable_peer_access(int peer_device, unsigned int flags): """Enables direct access to memory allocations on a peer device. On success, all allocations from ``peer_device`` will immediately be accessible by the current device. They will remain accessible until access is explicitly disabled using :func:`device_disable_peer_access` or either device is reset using :func:`device_reset`. Note that access granted by this call is unidirectional and that in order to access memory on the current device from ``peer_device``, a separate symmetric call to :func:`device_enable_peer_access` is required. Note that there are both device-wide and system-wide limitations per system configuration, as noted in the CUDA Programming Guide under the section "Peer-to-Peer Memory Access". Returns ``cudaErrorInvalidDevice`` if :func:`device_can_access_peer` indicates that the current device cannot directly access memory from ``peer_device``. Returns ``cudaErrorPeerAccessAlreadyEnabled`` if direct access of ``peer_device`` from the current device has already been enabled. Returns ``cudaErrorInvalidValue`` if ``flags`` is not 0. Args: peer_device (int): Peer device to enable direct access to from the current device. flags (unsigned int): Reserved for future use and must be set to 0. .. seealso:: `cudaDeviceEnablePeerAccess` """ with nogil: __status__ = cudaDeviceEnablePeerAccess(peer_device, flags) check_status(__status__) cpdef device_disable_peer_access(int peer_device): """Disables direct access to memory allocations on a peer device. Returns ``cudaErrorPeerAccessNotEnabled`` if direct access to memory on ``peer_device`` has not yet been enabled from the current device. Args: peer_device (int): Peer device to disable direct access to. .. seealso:: `cudaDeviceDisablePeerAccess` """ with nogil: __status__ = cudaDeviceDisablePeerAccess(peer_device) check_status(__status__) cpdef graphics_unregister_resource(intptr_t resource): """Unregisters a graphics resource for access by CUDA. Unregisters the graphics resource ``resource`` so it is not accessible by CUDA unless registered again. If ``resource`` is invalid then ``cudaErrorInvalidResourceHandle`` is returned. Args: resource (intptr_t): Resource to unregister. .. seealso:: `cudaGraphicsUnregisterResource` """ with nogil: __status__ = cudaGraphicsUnregisterResource(resource) check_status(__status__) cpdef graphics_resource_set_map_flags(intptr_t resource, unsigned int flags): """Set usage flags for mapping a graphics resource. Set ``flags`` for mapping the graphics resource ``resource``. Changes to ``flags`` will take effect the next time ``resource`` is mapped. The ``flags`` argument may be any of the following:. - ``cudaGraphicsMapFlagsNone``: Specifies no hints about how ``resource`` will be used. It is therefore assumed that CUDA may read from or write to ``resource``. - ``cudaGraphicsMapFlagsReadOnly``: Specifies that CUDA will not write to ``resource``. - ``cudaGraphicsMapFlagsWriteDiscard``: Specifies CUDA will not read from ``resource`` and will write over the entire contents of ``resource``, so none of the data previously stored in ``resource`` will be preserved. If ``resource`` is presently mapped for access by CUDA then ``cudaErrorUnknown`` is returned. If ``flags`` is not one of the above values then ``cudaErrorInvalidValue`` is returned. Args: resource (intptr_t): Registered resource to set flags for. flags (unsigned int): Parameters for resource mapping. .. seealso:: `cudaGraphicsResourceSetMapFlags` """ with nogil: __status__ = cudaGraphicsResourceSetMapFlags(resource, flags) check_status(__status__) cpdef graphics_map_resources(resources, intptr_t stream): """Map graphics resources for access by CUDA. Maps the ``len(resources)`` graphics resources in ``resources`` for access by CUDA. The resources in ``resources`` may be accessed by CUDA until they are unmapped. The graphics API from which ``resources`` were registered should not access any resources while they are mapped by CUDA. If an application does so, the results are undefined. This function provides the synchronization guarantee that any graphics calls issued before :func:`graphics_map_resources` will complete before any subsequent CUDA work issued in ``stream`` begins. If ``resources`` contains any duplicate entries then ``cudaErrorInvalidResourceHandle`` is returned. If any of ``resources`` are presently mapped for access by CUDA then ``cudaErrorUnknown`` is returned. Args: resources (object): Resources to map for CUDA. It must be: - a Python sequence of :class:`int`\s (as pointer addresses), or - ``None`` for NULL. stream (intptr_t): Stream for synchronization. .. seealso:: `cudaGraphicsMapResources` """ cdef _cyb_nullable_unique_ptr[ _cyb_vector[void*] ] _resources_ if isinstance(resources, int): raise TypeError( "resources must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _resources_len_ = 0 _cyb_get_resource_ptrs[void](_resources_, resources, NULL) if _resources_.get() != NULL: _resources_len_ = _resources_.get().size() cdef Py_ssize_t _count_length_ = 0 cdef bint _count_is_set_ = False if resources is not None: _count_length_ = _cyb_check_same_length(_count_is_set_, _count_length_, _resources_len_, "resources", "resources") _count_is_set_ = True cdef int count = _count_length_ if count != _count_length_: raise OverflowError( f"The length of (resources), {_count_length_}, does not fit in 'count' (a int)" ) with nogil: __status__ = cudaGraphicsMapResources(count, (_resources_.data()), stream) check_status(__status__) cpdef graphics_unmap_resources(resources, intptr_t stream): """Unmap graphics resources. Unmaps the ``len(resources)`` graphics resources in ``resources``. Once unmapped, the resources in ``resources`` may not be accessed by CUDA until they are mapped again. This function provides the synchronization guarantee that any CUDA work issued in ``stream`` before :func:`graphics_unmap_resources` will complete before any subsequently issued graphics work begins. If ``resources`` contains any duplicate entries then ``cudaErrorInvalidResourceHandle`` is returned. If any of ``resources`` are not presently mapped for access by CUDA then ``cudaErrorUnknown`` is returned. Args: resources (object): Resources to unmap. It must be: - a Python sequence of :class:`int`\s (as pointer addresses), or - ``None`` for NULL. stream (intptr_t): Stream for synchronization. .. seealso:: `cudaGraphicsUnmapResources` """ cdef _cyb_nullable_unique_ptr[ _cyb_vector[void*] ] _resources_ if isinstance(resources, int): raise TypeError( "resources must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _resources_len_ = 0 _cyb_get_resource_ptrs[void](_resources_, resources, NULL) if _resources_.get() != NULL: _resources_len_ = _resources_.get().size() cdef Py_ssize_t _count_length_ = 0 cdef bint _count_is_set_ = False if resources is not None: _count_length_ = _cyb_check_same_length(_count_is_set_, _count_length_, _resources_len_, "resources", "resources") _count_is_set_ = True cdef int count = _count_length_ if count != _count_length_: raise OverflowError( f"The length of (resources), {_count_length_}, does not fit in 'count' (a int)" ) with nogil: __status__ = cudaGraphicsUnmapResources(count, (_resources_.data()), stream) check_status(__status__) cpdef tuple graphics_resource_get_mapped_pointer(intptr_t resource): """Get an device pointer through which to access a mapped graphics resource. Returns in ``*dev_ptr`` a pointer through which the mapped graphics resource ``resource`` may be accessed. Returns in ``*size`` the size of the memory in bytes which may be accessed from that pointer. The value set in ``dev_ptr`` may change every time that ``resource`` is mapped. If ``resource`` is not a buffer then it cannot be accessed via a pointer and ``cudaErrorUnknown`` is returned. If ``resource`` is not mapped then ``cudaErrorUnknown`` is returned. Args: resource (intptr_t): Mapped resource to access. Returns: A 2-tuple containing: - intptr_t: Returned pointer through which ``resource`` may be accessed. - size_t: Returned size of the buffer accessible starting at ``*dev_ptr``. .. seealso:: `cudaGraphicsResourceGetMappedPointer` """ cdef void* dev_ptr cdef size_t size with nogil: __status__ = cudaGraphicsResourceGetMappedPointer(&dev_ptr, &size, resource) check_status(__status__) return (dev_ptr, size) cpdef intptr_t graphics_sub_resource_get_mapped_array(intptr_t resource, unsigned int array_index, unsigned int mip_level) except? 0: """Get an array through which to access a subresource of a mapped graphics resource. Returns in ``*array`` an array through which the subresource of the mapped graphics resource ``resource`` which corresponds to array index ``array_index`` and mipmap level ``mip_level`` may be accessed. The value set in ``array`` may change every time that ``resource`` is mapped. If ``resource`` is not a texture then it cannot be accessed via an array and ``cudaErrorUnknown`` is returned. If ``array_index`` is not a valid array index for ``resource`` then ``cudaErrorInvalidValue`` is returned. If ``mip_level`` is not a valid mipmap level for ``resource`` then ``cudaErrorInvalidValue`` is returned. If ``resource`` is not mapped then ``cudaErrorUnknown`` is returned. Args: resource (intptr_t): Mapped resource to access. array_index (unsigned int): Array index for array textures or cubemap face index as defined by ``cudaGraphicsCubeFace`` for cubemap textures for the subresource to access. mip_level (unsigned int): Mipmap level for the subresource to access. Returns: intptr_t: Returned array through which a subresource of ``resource`` may be accessed. .. seealso:: `cudaGraphicsSubResourceGetMappedArray` """ cdef cudaArray_t array with nogil: __status__ = cudaGraphicsSubResourceGetMappedArray(&array, resource, array_index, mip_level) check_status(__status__) return array cpdef intptr_t graphics_resource_get_mapped_mipmapped_array(intptr_t resource) except? 0: """Get a mipmapped array through which to access a mapped graphics resource. Returns in ``*mipmapped_array`` a mipmapped array through which the mapped graphics resource ``resource`` may be accessed. The value set in ``mipmapped_array`` may change every time that ``resource`` is mapped. If ``resource`` is not a texture then it cannot be accessed via an array and ``cudaErrorUnknown`` is returned. If ``resource`` is not mapped then ``cudaErrorUnknown`` is returned. Args: resource (intptr_t): Mapped resource to access. Returns: intptr_t: Returned mipmapped array through which ``resource`` may be accessed. .. seealso:: `cudaGraphicsResourceGetMappedMipmappedArray` """ cdef cudaMipmappedArray_t mipmapped_array with nogil: __status__ = cudaGraphicsResourceGetMappedMipmappedArray(&mipmapped_array, resource) check_status(__status__) return mipmapped_array cpdef object get_channel_desc(intptr_t array): """Get the channel descriptor of an array. Returns in ``*desc`` the channel descriptor of the CUDA array ``array``. Args: array (intptr_t): Memory array on device. Returns: cudaChannelFormatDesc: Channel format. .. seealso:: `cudaGetChannelDesc` """ cdef ChannelFormatDesc desc_py = ChannelFormatDesc() cdef cudaChannelFormatDesc *desc = (desc_py._get_ptr()) with nogil: __status__ = cudaGetChannelDesc(desc, array) check_status(__status__) return desc_py cpdef unsigned long long create_texture_object(p_res_desc, p_tex_desc, p_res_view_desc) except? 0: """Creates a texture object. Creates a texture object and returns it in ``p_tex_object``. ``p_res_desc`` describes the data to texture from. ``p_tex_desc`` describes how the data should be sampled. ``p_res_view_desc`` is an optional argument that specifies an alternate format for the data described by ``p_res_desc``, and also describes the subresource region to restrict access to when texturing. ``p_res_view_desc`` can only be specified if the type of resource is a CUDA array or a CUDA mipmapped array not in a block compressed format. Texture objects are only supported on devices of compute capability 3.0 or higher. Additionally, a texture object is an opaque value, and, as such, should only be accessed through CUDA API calls. The ``cudaResourceDesc`` structure is defined as:. \*\*View CUDA Toolkit Documentation for a C++ code example*\*. where:. - ``cudaResourceDesc.resType`` specifies the type of resource to texture from. CUresourceType is defined as:. - \*\*View CUDA Toolkit Documentation for a C++ code example*\*. If ``cudaResourceDesc.resType`` is set to ``cudaResourceTypeArray``, ``cudaResourceDesc.res.array.array`` must be set to a valid CUDA array handle. If ``cudaResourceDesc.resType`` is set to ``cudaResourceTypeMipmappedArray``, ``cudaResourceDesc.res.mipmap.mipmap`` must be set to a valid CUDA mipmapped array handle and ``cudaTextureDesc.normalizedCoords`` must be set to true. If ``cudaResourceDesc.resType`` is set to ``cudaResourceTypeLinear``, ``cudaResourceDesc.res.linear.devPtr`` must be set to a valid device pointer, that is aligned to ``cudaDeviceProp.textureAlignment``. ``cudaResourceDesc.res.linear.desc`` describes the format and the number of components per array element. ``cudaResourceDesc.res.linear.sizeInBytes`` specifies the size of the array in bytes. The total number of elements in the linear address range cannot exceed :func:`device_get_texture_1d_linear_max_width`. The number of elements is computed as (sizeInBytes / sizeof(desc)). If ``cudaResourceDesc.resType`` is set to ``cudaResourceTypePitch2D``, ``cudaResourceDesc.res.pitch2D.devPtr`` must be set to a valid device pointer, that is aligned to ``cudaDeviceProp.textureAlignment``. ``cudaResourceDesc.res.pitch2D.desc`` describes the format and the number of components per array element. ``cudaResourceDesc.res.pitch2D.width`` and ``cudaResourceDesc.res.pitch2D.height`` specify the width and height of the array in elements, and cannot exceed ``cudaDeviceProp.maxTexture2DLinear``\[0] and ``cudaDeviceProp.maxTexture2DLinear``\[1] respectively. ``cudaResourceDesc.res.pitch2D.pitchInBytes`` specifies the pitch between two rows in bytes and has to be aligned to ``cudaDeviceProp.texturePitchAlignment``. Pitch cannot exceed ``cudaDeviceProp.maxTexture2DLinear``\[2]. The ``cudaTextureDesc`` struct is defined as. \*\*View CUDA Toolkit Documentation for a C++ code example*\*. where. - ``cudaTextureDesc.addressMode`` specifies the addressing mode for each dimension of the texture data. ``cudaTextureAddressMode`` is defined as:. - \*\*View CUDA Toolkit Documentation for a C++ code example*\*. - This is ignored if ``cudaResourceDesc.resType`` is ``cudaResourceTypeLinear``. Also, if ``cudaTextureDesc.normalizedCoords`` is set to zero, ``cudaAddressModeWrap`` and ``cudaAddressModeMirror`` won't be supported and will be switched to ``cudaAddressModeClamp``. - ``cudaTextureDesc.filterMode`` specifies the filtering mode to be used when fetching from the texture. ``cudaTextureFilterMode`` is defined as:. - \*\*View CUDA Toolkit Documentation for a C++ code example*\*. - This is ignored if ``cudaResourceDesc.resType`` is ``cudaResourceTypeLinear``. - ``cudaTextureDesc.readMode`` specifies whether integer data should be converted to floating point or not. ``cudaTextureReadMode`` is defined as:. - \*\*View CUDA Toolkit Documentation for a C++ code example*\*. - Note that this applies only to 8-bit and 16-bit integer formats. 32-bit integer format would not be promoted, regardless of whether or not this ``cudaTextureDesc.readMode`` is set ``cudaReadModeNormalizedFloat`` is specified. - ``cudaTextureDesc.sRGB`` specifies whether sRGB to linear conversion should be performed during texture fetch. - ``cudaTextureDesc.borderColor`` specifies the float values of color. where: ``cudaTextureDesc.borderColor``\[0] contains value of 'R', ``cudaTextureDesc.borderColor``\[1] contains value of 'G', ``cudaTextureDesc.borderColor``\[2] contains value of 'B', ``cudaTextureDesc.borderColor``\[3] contains value of 'A' Note that application using integer border color values will need to these values to float. The values are set only when the addressing mode specified by ``cudaTextureDesc.addressMode`` is cudaAddressModeBorder. - ``cudaTextureDesc.normalizedCoords`` specifies whether the texture coordinates will be normalized or not. - ``cudaTextureDesc.maxAnisotropy`` specifies the maximum anistropy ratio to be used when doing anisotropic filtering. This value will be clamped to the range [1,16]. - ``cudaTextureDesc.mipmapFilterMode`` specifies the filter mode when the calculated mipmap level lies between two defined mipmap levels. - ``cudaTextureDesc.mipmapLevelBias`` specifies the offset to be applied to the calculated mipmap level. - ``cudaTextureDesc.minMipmapLevelClamp`` specifies the lower end of the mipmap level range to clamp access to. - ``cudaTextureDesc.maxMipmapLevelClamp`` specifies the upper end of the mipmap level range to clamp access to. - ``cudaTextureDesc.disableTrilinearOptimization`` specifies whether the trilinear filtering optimizations will be disabled. - ``cudaTextureDesc.seamlessCubemap`` specifies whether seamless cube map filtering is enabled. This flag can only be specified if the underlying resource is a CUDA array or a CUDA mipmapped array that was created with the flag ``cudaArrayCubemap``. When seamless cube map filtering is enabled, texture address modes specified by ``cudaTextureDesc.addressMode`` are ignored. Instead, if the ``cudaTextureDesc.filterMode`` is set to ``cudaFilterModePoint`` the address mode ``cudaAddressModeClamp`` will be applied for all dimensions. If the ``cudaTextureDesc.filterMode`` is set to ``cudaFilterModeLinear`` seamless cube map filtering will be performed when sampling along the cube face borders. The ``cudaResourceViewDesc`` struct is defined as. \*\*View CUDA Toolkit Documentation for a C++ code example*\*. where:. - ``cudaResourceViewDesc.format`` specifies how the data contained in the CUDA array or CUDA mipmapped array should be interpreted. Note that this can incur a change in size of the texture data. If the resource view format is a block compressed format, then the underlying CUDA array or CUDA mipmapped array has to have a 32-bit unsigned integer format with 2 or 4 channels, depending on the block compressed format. For ex., BC1 and BC4 require the underlying CUDA array to have a 32-bit unsigned int with 2 channels. The other BC formats require the underlying resource to have the same 32-bit unsigned int format but with 4 channels. - ``cudaResourceViewDesc.width`` specifies the new width of the texture data. If the resource view format is a block compressed format, this value has to be 4 times the original width of the resource. For non block compressed formats, this value has to be equal to that of the original resource. - ``cudaResourceViewDesc.height`` specifies the new height of the texture data. If the resource view format is a block compressed format, this value has to be 4 times the original height of the resource. For non block compressed formats, this value has to be equal to that of the original resource. - ``cudaResourceViewDesc.depth`` specifies the new depth of the texture data. This value has to be equal to that of the original resource. - ``cudaResourceViewDesc.firstMipmapLevel`` specifies the most detailed mipmap level. This will be the new mipmap level zero. For non-mipmapped resources, this value has to be zero.``cudaTextureDesc.minMipmapLevelClamp`` and ``cudaTextureDesc.maxMipmapLevelClamp`` will be relative to this value. For ex., if the firstMipmapLevel is set to 2, and a minMipmapLevelClamp of 1.2 is specified, then the actual minimum mipmap level clamp will be 3.2. - ``cudaResourceViewDesc.lastMipmapLevel`` specifies the least detailed mipmap level. For non-mipmapped resources, this value has to be zero. - ``cudaResourceViewDesc.firstLayer`` specifies the first layer index for layered textures. This will be the new layer zero. For non-layered resources, this value has to be zero. - ``cudaResourceViewDesc.lastLayer`` specifies the last layer index for layered textures. For non-layered resources, this value has to be zero. Args: p_res_desc (intptr_t): Resource descriptor. p_tex_desc (intptr_t): Texture descriptor. p_res_view_desc (intptr_t): Resource view descriptor. Returns: unsigned long long: Texture object to create. .. seealso:: `cudaCreateTextureObject` """ cdef intptr_t _p_res_desc_ptr_ = 0 if p_res_desc is None else int(p_res_desc) cdef intptr_t _p_tex_desc_ptr_ = 0 if p_tex_desc is None else int(p_tex_desc) cdef intptr_t _p_res_view_desc_ptr_ = 0 if p_res_view_desc is None else int(p_res_view_desc) cdef cudaTextureObject_t p_tex_object with nogil: __status__ = cudaCreateTextureObject(&p_tex_object, _p_res_desc_ptr_, _p_tex_desc_ptr_, _p_res_view_desc_ptr_) check_status(__status__) return p_tex_object cpdef destroy_texture_object(unsigned long long tex_object): """Destroys a texture object. Destroys the texture object specified by ``tex_object``. Args: tex_object (unsigned long long): Texture object to destroy. .. seealso:: `cudaDestroyTextureObject` """ with nogil: __status__ = cudaDestroyTextureObject(tex_object) check_status(__status__) cpdef object get_texture_object_resource_desc(unsigned long long tex_object): """Returns a texture object's resource descriptor. Returns the resource descriptor for the texture object specified by ``tex_object``. Args: tex_object (unsigned long long): Texture object. Returns: cudaResourceDesc: Resource descriptor. .. seealso:: `cudaGetTextureObjectResourceDesc` """ cdef ResourceDesc p_res_desc_py = ResourceDesc() cdef cudaResourceDesc *p_res_desc = (p_res_desc_py._get_ptr()) with nogil: __status__ = cudaGetTextureObjectResourceDesc(p_res_desc, tex_object) check_status(__status__) return p_res_desc_py cpdef object get_texture_object_texture_desc(unsigned long long tex_object): """Returns a texture object's texture descriptor. Returns the texture descriptor for the texture object specified by ``tex_object``. Args: tex_object (unsigned long long): Texture object. Returns: cudaTextureDesc: Texture descriptor. .. seealso:: `cudaGetTextureObjectTextureDesc` """ cdef TextureDesc p_tex_desc_py = TextureDesc() cdef cudaTextureDesc *p_tex_desc = (p_tex_desc_py._get_ptr()) with nogil: __status__ = cudaGetTextureObjectTextureDesc(p_tex_desc, tex_object) check_status(__status__) return p_tex_desc_py cpdef object get_texture_object_resource_view_desc(unsigned long long tex_object): """Returns a texture object's resource view descriptor. Returns the resource view descriptor for the texture object specified by ``tex_object``. If no resource view was specified, ``cudaErrorInvalidValue`` is returned. Args: tex_object (unsigned long long): Texture object. Returns: cudaResourceViewDesc: Resource view descriptor. .. seealso:: `cudaGetTextureObjectResourceViewDesc` """ cdef ResourceViewDesc p_res_view_desc_py = ResourceViewDesc() cdef cudaResourceViewDesc *p_res_view_desc = (p_res_view_desc_py._get_ptr()) with nogil: __status__ = cudaGetTextureObjectResourceViewDesc(p_res_view_desc, tex_object) check_status(__status__) return p_res_view_desc_py cpdef unsigned long long create_surface_object(p_res_desc) except? 0: """Creates a surface object. Creates a surface object and returns it in ``p_surf_object``. ``p_res_desc`` describes the data to perform surface load/stores on. ``cudaResourceDesc.resType`` must be ``cudaResourceTypeArray`` and ``cudaResourceDesc.res.array.array`` must be set to a valid CUDA array handle. Surface objects are only supported on devices of compute capability 3.0 or higher. Additionally, a surface object is an opaque value, and, as such, should only be accessed through CUDA API calls. Args: p_res_desc (intptr_t): Resource descriptor. Returns: unsigned long long: Surface object to create. .. seealso:: `cudaCreateSurfaceObject` """ cdef intptr_t _p_res_desc_ptr_ = 0 if p_res_desc is None else int(p_res_desc) cdef cudaSurfaceObject_t p_surf_object with nogil: __status__ = cudaCreateSurfaceObject(&p_surf_object, _p_res_desc_ptr_) check_status(__status__) return p_surf_object cpdef destroy_surface_object(unsigned long long surf_object): """Destroys a surface object. Destroys the surface object specified by ``surf_object``. Args: surf_object (unsigned long long): Surface object to destroy. .. seealso:: `cudaDestroySurfaceObject` """ with nogil: __status__ = cudaDestroySurfaceObject(surf_object) check_status(__status__) cpdef object get_surface_object_resource_desc(unsigned long long surf_object): """Returns a surface object's resource descriptor Returns the resource descriptor for the surface object specified by ``surf_object``. Args: surf_object (unsigned long long): Surface object. Returns: cudaResourceDesc: Resource descriptor. .. seealso:: `cudaGetSurfaceObjectResourceDesc` """ cdef ResourceDesc p_res_desc_py = ResourceDesc() cdef cudaResourceDesc *p_res_desc = (p_res_desc_py._get_ptr()) with nogil: __status__ = cudaGetSurfaceObjectResourceDesc(p_res_desc, surf_object) check_status(__status__) return p_res_desc_py cpdef int driver_get_version() except? -1: """Returns the latest version of CUDA supported by the driver. Returns in ``*driver_version`` the latest version of CUDA supported by the driver. The version is returned as (1000 \* major + 10 \* minor). For example, CUDA 9.2 would be represented by 9020. If no driver is installed, then 0 is returned as the driver version. This function automatically returns ``cudaErrorInvalidValue`` if ``driver_version`` is NULL. Returns: int: Returns the CUDA driver version. .. seealso:: `cudaDriverGetVersion` """ cdef int driver_version with nogil: __status__ = cudaDriverGetVersion(&driver_version) check_status(__status__) return driver_version cpdef int runtime_get_version() except? -1: """Returns the CUDA Runtime version. Returns in ``*runtime_version`` the version number of the current CUDA Runtime instance. The version is returned as (1000 \* major + 10 \* minor). For example, CUDA 9.2 would be represented by 9020. As of CUDA 12.0, this function no longer initializes CUDA. The purpose of this API is solely to return a compile-time constant stating the CUDA Toolkit version in the above format. As of CUDA 13.0, on Windows, the ``runtime_version`` may not be the same as the CUDA Toolkit version the app was built with. Windows will use the CUDA Runtime packaged with the display driver, and that version will be reported. This function automatically returns ``cudaErrorInvalidValue`` if the ``runtime_version`` argument is NULL. Returns: int: Returns the CUDA Runtime version. .. seealso:: `cudaRuntimeGetVersion` """ cdef int runtime_version with nogil: __status__ = cudaRuntimeGetVersion(&runtime_version) check_status(__status__) return runtime_version cpdef intptr_t graph_create(unsigned int flags) except? 0: """Creates a graph. Creates an empty graph, which is returned via ``p_graph``. Args: flags (unsigned int): Graph creation flags, must be 0. Returns: intptr_t: Returns newly created graph. .. seealso:: `cudaGraphCreate` """ cdef cudaGraph_t p_graph with nogil: __status__ = cudaGraphCreate(&p_graph, flags) check_status(__status__) return p_graph cpdef intptr_t graph_add_kernel_node(intptr_t graph, p_dependencies, p_node_params) except? 0: """Creates a kernel execution node and adds it to a graph. Creates a new kernel execution node and adds it to ``graph`` with ``len(p_dependencies)`` dependencies specified via ``p_dependencies`` and arguments specified in ``p_node_params``. It is possible for ``len(p_dependencies)`` to be 0, in which case the node will be placed at the root of the graph. ``p_dependencies`` may not have any duplicate entries. A handle to the new node will be returned in ``p_graph_node``. The ``cudaKernelNodeParams`` structure is defined as:. \*\*View CUDA Toolkit Documentation for a C++ code example*\*. When the graph is launched, the node will invoke kernel ``func`` on a (``gridDim.x`` x ``gridDim.y`` x ``gridDim.z``) grid of blocks. Each block contains (``blockDim.x`` x ``blockDim.y`` x ``blockDim.z``) threads. ``sharedMem`` sets the amount of dynamic shared memory that will be available to each thread block. Kernel parameters to ``func`` can be specified in one of two ways:. 1) Kernel parameters can be specified via ``kernelParams``. If the kernel has N parameters, then ``kernelParams`` needs to be an array of N pointers. Each pointer, from ``kernelParams``\[0] to ``kernelParams``\[N-1], points to the region of memory from which the actual parameter will be copied. The number of kernel parameters and their offsets and sizes do not need to be specified as that information is retrieved directly from the kernel's image. 2) Kernel parameters can also be packaged by the application into a single buffer that is passed in via ``extra``. This places the burden on the application of knowing each kernel parameter's size and alignment/padding within the buffer. The ``extra`` parameter exists to allow this function to take additional less commonly used arguments. ``extra`` specifies a list of names of extra settings and their corresponding values. Each extra setting name is immediately followed by the corresponding value. The list must be terminated with either NULL or CU_LAUNCH_PARAM_END. - ``CU_LAUNCH_PARAM_END``, which indicates the end of the ``extra`` array;. - ``CU_LAUNCH_PARAM_BUFFER_POINTER``, which specifies that the next value in ``extra`` will be a pointer to a buffer containing all the kernel parameters for launching kernel ``func``;. - ``CU_LAUNCH_PARAM_BUFFER_SIZE``, which specifies that the next value in ``extra`` will be a pointer to a size_t containing the size of the buffer specified with ``CU_LAUNCH_PARAM_BUFFER_POINTER``;. The error ``cudaErrorInvalidValue`` will be returned if kernel parameters are specified with both ``kernelParams`` and ``extra`` (i.e. both ``kernelParams`` and ``extra`` are non-NULL). The ``kernelParams`` or ``extra`` array, as well as the argument values it points to, are copied during this call. Args: graph (intptr_t): Graph to which to add the node. p_dependencies (object): Dependencies of the node. It must be: - a Python sequence of :class:`int`\s (as pointer addresses), or - ``None`` for NULL. p_node_params (intptr_t): Parameters for the GPU execution node. Returns: intptr_t: Returns newly created node. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphAddNode``. .. note:: Kernels launched using graphs must not use texture and surface references. Reading or writing through any texture or surface reference is undefined behavior. This restriction does not apply to texture and surface objects. .. seealso:: `cudaGraphAddKernelNode` """ cdef _cyb_nullable_unique_ptr[ _cyb_vector[void*] ] _p_dependencies_ if isinstance(p_dependencies, int): raise TypeError( "p_dependencies must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _p_dependencies_len_ = 0 _cyb_get_resource_ptrs[void](_p_dependencies_, p_dependencies, NULL) if _p_dependencies_.get() != NULL: _p_dependencies_len_ = _p_dependencies_.get().size() cdef intptr_t _p_node_params_ptr_ = 0 if p_node_params is None else int(p_node_params) cdef Py_ssize_t _num_dependencies_length_ = 0 cdef bint _num_dependencies_is_set_ = False if p_dependencies is not None: _num_dependencies_length_ = _cyb_check_same_length(_num_dependencies_is_set_, _num_dependencies_length_, _p_dependencies_len_, "p_dependencies", "p_dependencies") _num_dependencies_is_set_ = True cdef size_t num_dependencies = _num_dependencies_length_ if num_dependencies != _num_dependencies_length_: raise OverflowError( f"The length of (p_dependencies), {_num_dependencies_length_}, does not fit in 'numDependencies' (a size_t)" ) cdef cudaGraphNode_t p_graph_node with nogil: __status__ = cudaGraphAddKernelNode(&p_graph_node, graph, (_p_dependencies_.data()), num_dependencies, _p_node_params_ptr_) check_status(__status__) return p_graph_node cpdef object graph_kernel_node_get_params(intptr_t node): """Returns a kernel node's parameters. Returns the parameters of kernel node ``node`` in ``p_node_params``. The ``kernelParams`` or ``extra`` array returned in ``p_node_params``, as well as the argument values it points to, are owned by the node. This memory remains valid until the node is destroyed or its parameters are modified, and should not be modified directly. Use ``cudaGraphKernelNodeSetParams`` to update the parameters of this node. The params will contain either ``kernelParams`` or ``extra``, according to which of these was most recently set on the node. Args: node (intptr_t): Node to get the parameters for. Returns: cudaKernelNodeParams: Pointer to return the parameters. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphNodeGetParams``. .. seealso:: `cudaGraphKernelNodeGetParams` """ cdef KernelNodeParams p_node_params_py = KernelNodeParams() cdef cudaKernelNodeParams *p_node_params = (p_node_params_py._get_ptr()) with nogil: __status__ = cudaGraphKernelNodeGetParams(node, p_node_params) check_status(__status__) return p_node_params_py cpdef graph_kernel_node_set_params(intptr_t node, p_node_params): """Sets a kernel node's parameters. Sets the parameters of kernel node ``node`` to ``p_node_params``. Args: node (intptr_t): Node to set the parameters for. p_node_params (intptr_t): Parameters to copy. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphNodeSetParams``. .. seealso:: `cudaGraphKernelNodeSetParams` """ cdef intptr_t _p_node_params_ptr_ = 0 if p_node_params is None else int(p_node_params) with nogil: __status__ = cudaGraphKernelNodeSetParams(node, _p_node_params_ptr_) check_status(__status__) cpdef graph_kernel_node_copy_attributes(intptr_t h_dst, intptr_t h_src): """Copies attributes from source node to destination node. Copies attributes from source node ``h_src`` to destination node ``h_dst``. Both node must have the same context. Args: h_dst (intptr_t): Destination node. h_src (intptr_t): Source node For list of attributes see ``cudaKernelNodeAttrID``. .. seealso:: `cudaGraphKernelNodeCopyAttributes` """ with nogil: __status__ = cudaGraphKernelNodeCopyAttributes(h_dst, h_src) check_status(__status__) cpdef object graph_kernel_node_get_attribute(intptr_t h_node, cudaLaunchAttributeID attr): """Queries node attribute. Queries attribute ``attr`` from node ``h_node`` and stores it in corresponding member of ``value_out``. Args: h_node (intptr_t): . attr (LaunchAttributeID): . Returns: cudaLaunchAttributeValue: . .. seealso:: `cudaGraphKernelNodeGetAttribute` """ cdef LaunchAttributeValue value_out_py = LaunchAttributeValue() cdef cudaLaunchAttributeValue *value_out = (value_out_py._get_ptr()) with nogil: __status__ = cudaGraphKernelNodeGetAttribute(h_node, attr, value_out) check_status(__status__) return value_out_py cpdef graph_kernel_node_set_attribute(intptr_t h_node, cudaLaunchAttributeID attr, value): """Sets node attribute. Sets attribute ``attr`` on node ``h_node`` from corresponding attribute of ``value``. Args: h_node (intptr_t): . attr (LaunchAttributeID): . value (intptr_t): . .. seealso:: `cudaGraphKernelNodeSetAttribute` """ cdef intptr_t _value_ptr_ = 0 if value is None else int(value) with nogil: __status__ = cudaGraphKernelNodeSetAttribute(h_node, attr, _value_ptr_) check_status(__status__) cpdef intptr_t graph_add_memcpy_node(intptr_t graph, p_dependencies, p_copy_params) except? 0: """Creates a memcpy node and adds it to a graph. Creates a new memcpy node and adds it to ``graph`` with ``len(p_dependencies)`` dependencies specified via ``p_dependencies``. It is possible for ``len(p_dependencies)`` to be 0, in which case the node will be placed at the root of the graph. ``p_dependencies`` may not have any duplicate entries. A handle to the new node will be returned in ``p_graph_node``. When the graph is launched, the node will perform the memcpy described by ``p_copy_params``. See :func:`memcpy_3d` for a description of the structure and its restrictions. Memcpy nodes have some additional restrictions with regards to managed memory, if the system contains at least one device which has a zero value for the device attribute ``cudaDevAttrConcurrentManagedAccess``. Args: graph (intptr_t): Graph to which to add the node. p_dependencies (object): Dependencies of the node. It must be: - a Python sequence of :class:`int`\s (as pointer addresses), or - ``None`` for NULL. p_copy_params (intptr_t): Parameters for the memory copy. Returns: intptr_t: Returns newly created node. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphAddNode``. .. seealso:: `cudaGraphAddMemcpyNode` """ cdef _cyb_nullable_unique_ptr[ _cyb_vector[void*] ] _p_dependencies_ if isinstance(p_dependencies, int): raise TypeError( "p_dependencies must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _p_dependencies_len_ = 0 _cyb_get_resource_ptrs[void](_p_dependencies_, p_dependencies, NULL) if _p_dependencies_.get() != NULL: _p_dependencies_len_ = _p_dependencies_.get().size() cdef intptr_t _p_copy_params_ptr_ = 0 if p_copy_params is None else int(p_copy_params) cdef Py_ssize_t _num_dependencies_length_ = 0 cdef bint _num_dependencies_is_set_ = False if p_dependencies is not None: _num_dependencies_length_ = _cyb_check_same_length(_num_dependencies_is_set_, _num_dependencies_length_, _p_dependencies_len_, "p_dependencies", "p_dependencies") _num_dependencies_is_set_ = True cdef size_t num_dependencies = _num_dependencies_length_ if num_dependencies != _num_dependencies_length_: raise OverflowError( f"The length of (p_dependencies), {_num_dependencies_length_}, does not fit in 'numDependencies' (a size_t)" ) cdef cudaGraphNode_t p_graph_node with nogil: __status__ = cudaGraphAddMemcpyNode(&p_graph_node, graph, (_p_dependencies_.data()), num_dependencies, _p_copy_params_ptr_) check_status(__status__) return p_graph_node cpdef intptr_t graph_add_memcpy_node_1d(intptr_t graph, p_dependencies, dst, src, size_t count, int kind) except? 0: """Creates a 1D memcpy node and adds it to a graph. Creates a new 1D memcpy node and adds it to ``graph`` with ``len(p_dependencies)`` dependencies specified via ``p_dependencies``. It is possible for ``len(p_dependencies)`` to be 0, in which case the node will be placed at the root of the graph. ``p_dependencies`` may not have any duplicate entries. A handle to the new node will be returned in ``p_graph_node``. When the graph is launched, the node will copy ``count`` bytes from the memory area pointed to by ``src`` to the memory area pointed to by ``dst``, where ``kind`` specifies the direction of the copy, and must be one of ``cudaMemcpyHostToHost``, ``cudaMemcpyHostToDevice``, ``cudaMemcpyDeviceToHost``, ``cudaMemcpyDeviceToDevice``, or ``cudaMemcpyDefault``. Passing ``cudaMemcpyDefault`` is recommended, in which case the type of transfer is inferred from the pointer values. However, ``cudaMemcpyDefault`` is only allowed on systems that support unified virtual addressing. Launching a memcpy node with dst and src pointers that do not match the direction of the copy results in an undefined behavior. Memcpy nodes have some additional restrictions with regards to managed memory, if the system contains at least one device which has a zero value for the device attribute ``cudaDevAttrConcurrentManagedAccess``. Args: graph (intptr_t): Graph to which to add the node. p_dependencies (object): Dependencies of the node. It must be: - a Python sequence of :class:`int`\s (as pointer addresses), or - ``None`` for NULL. dst (bytes): Destination memory address. src (bytes): Source memory address. count (size_t): Size in bytes to copy. kind (MemCpyKind): Type of transfer. Returns: intptr_t: Returns newly created node. .. seealso:: `cudaGraphAddMemcpyNode1D` """ cdef _cyb_nullable_unique_ptr[ _cyb_vector[void*] ] _p_dependencies_ if isinstance(p_dependencies, int): raise TypeError( "p_dependencies must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _p_dependencies_len_ = 0 _cyb_get_resource_ptrs[void](_p_dependencies_, p_dependencies, NULL) if _p_dependencies_.get() != NULL: _p_dependencies_len_ = _p_dependencies_.get().size() cdef _cyb_BufferGuard _dst_guard_ = _cyb_BufferGuard(dst, 0, False, False, True) cdef void* _dst_ = _dst_guard_.ptr cdef _cyb_BufferGuard _src_guard_ = _cyb_BufferGuard(src, 0, False, True, True) cdef void* _src_ = _src_guard_.ptr cdef Py_ssize_t _num_dependencies_length_ = 0 cdef bint _num_dependencies_is_set_ = False if p_dependencies is not None: _num_dependencies_length_ = _cyb_check_same_length(_num_dependencies_is_set_, _num_dependencies_length_, _p_dependencies_len_, "p_dependencies", "p_dependencies") _num_dependencies_is_set_ = True cdef size_t num_dependencies = _num_dependencies_length_ if num_dependencies != _num_dependencies_length_: raise OverflowError( f"The length of (p_dependencies), {_num_dependencies_length_}, does not fit in 'numDependencies' (a size_t)" ) cdef cudaGraphNode_t p_graph_node with nogil: __status__ = cudaGraphAddMemcpyNode1D(&p_graph_node, graph, (_p_dependencies_.data()), num_dependencies, _dst_, _src_, count, kind) check_status(__status__) return p_graph_node cpdef object graph_memcpy_node_get_params(intptr_t node): """Returns a memcpy node's parameters. Returns the parameters of memcpy node ``node`` in ``p_node_params``. Args: node (intptr_t): Node to get the parameters for. Returns: cudaMemcpy3DParms: Pointer to return the parameters. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphNodeGetParams``. .. seealso:: `cudaGraphMemcpyNodeGetParams` """ cdef MemCpy3dParms p_node_params_py = MemCpy3dParms() cdef cudaMemcpy3DParms *p_node_params = (p_node_params_py._get_ptr()) with nogil: __status__ = cudaGraphMemcpyNodeGetParams(node, p_node_params) check_status(__status__) return p_node_params_py cpdef graph_memcpy_node_set_params(intptr_t node, p_node_params): """Sets a memcpy node's parameters. Sets the parameters of memcpy node ``node`` to ``p_node_params``. Args: node (intptr_t): Node to set the parameters for. p_node_params (intptr_t): Parameters to copy. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphNodeSetParams``. .. seealso:: `cudaGraphMemcpyNodeSetParams` """ cdef intptr_t _p_node_params_ptr_ = 0 if p_node_params is None else int(p_node_params) with nogil: __status__ = cudaGraphMemcpyNodeSetParams(node, _p_node_params_ptr_) check_status(__status__) cpdef graph_memcpy_node_set_params_1d(intptr_t node, dst, src, size_t count, int kind): """Sets a memcpy node's parameters to perform a 1-dimensional copy. Sets the parameters of memcpy node ``node`` to the copy described by the provided parameters. When the graph is launched, the node will copy ``count`` bytes from the memory area pointed to by ``src`` to the memory area pointed to by ``dst``, where ``kind`` specifies the direction of the copy, and must be one of ``cudaMemcpyHostToHost``, ``cudaMemcpyHostToDevice``, ``cudaMemcpyDeviceToHost``, ``cudaMemcpyDeviceToDevice``, or ``cudaMemcpyDefault``. Passing ``cudaMemcpyDefault`` is recommended, in which case the type of transfer is inferred from the pointer values. However, ``cudaMemcpyDefault`` is only allowed on systems that support unified virtual addressing. Launching a memcpy node with dst and src pointers that do not match the direction of the copy results in an undefined behavior. Args: node (intptr_t): Node to set the parameters for. dst (bytes): Destination memory address. src (bytes): Source memory address. count (size_t): Size in bytes to copy. kind (MemCpyKind): Type of transfer. .. seealso:: `cudaGraphMemcpyNodeSetParams1D` """ cdef _cyb_BufferGuard _dst_guard_ = _cyb_BufferGuard(dst, 0, False, False, True) cdef void* _dst_ = _dst_guard_.ptr cdef _cyb_BufferGuard _src_guard_ = _cyb_BufferGuard(src, 0, False, True, True) cdef void* _src_ = _src_guard_.ptr with nogil: __status__ = cudaGraphMemcpyNodeSetParams1D(node, _dst_, _src_, count, kind) check_status(__status__) cpdef intptr_t graph_add_memset_node(intptr_t graph, p_dependencies, p_memset_params) except? 0: """Creates a memset node and adds it to a graph. Creates a new memset node and adds it to ``graph`` with ``len(p_dependencies)`` dependencies specified via ``p_dependencies``. It is possible for ``len(p_dependencies)`` to be 0, in which case the node will be placed at the root of the graph. ``p_dependencies`` may not have any duplicate entries. A handle to the new node will be returned in ``p_graph_node``. The element size must be 1, 2, or 4 bytes. When the graph is launched, the node will perform the memset described by ``p_memset_params``. Args: graph (intptr_t): Graph to which to add the node. p_dependencies (object): Dependencies of the node. It must be: - a Python sequence of :class:`int`\s (as pointer addresses), or - ``None`` for NULL. p_memset_params (intptr_t): Parameters for the memory set. Returns: intptr_t: Returns newly created node. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphAddNode``. .. seealso:: `cudaGraphAddMemsetNode` """ cdef _cyb_nullable_unique_ptr[ _cyb_vector[void*] ] _p_dependencies_ if isinstance(p_dependencies, int): raise TypeError( "p_dependencies must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _p_dependencies_len_ = 0 _cyb_get_resource_ptrs[void](_p_dependencies_, p_dependencies, NULL) if _p_dependencies_.get() != NULL: _p_dependencies_len_ = _p_dependencies_.get().size() cdef intptr_t _p_memset_params_ptr_ = 0 if p_memset_params is None else int(p_memset_params) cdef Py_ssize_t _num_dependencies_length_ = 0 cdef bint _num_dependencies_is_set_ = False if p_dependencies is not None: _num_dependencies_length_ = _cyb_check_same_length(_num_dependencies_is_set_, _num_dependencies_length_, _p_dependencies_len_, "p_dependencies", "p_dependencies") _num_dependencies_is_set_ = True cdef size_t num_dependencies = _num_dependencies_length_ if num_dependencies != _num_dependencies_length_: raise OverflowError( f"The length of (p_dependencies), {_num_dependencies_length_}, does not fit in 'numDependencies' (a size_t)" ) cdef cudaGraphNode_t p_graph_node with nogil: __status__ = cudaGraphAddMemsetNode(&p_graph_node, graph, (_p_dependencies_.data()), num_dependencies, _p_memset_params_ptr_) check_status(__status__) return p_graph_node cpdef object graph_memset_node_get_params(intptr_t node): """Returns a memset node's parameters. Returns the parameters of memset node ``node`` in ``p_node_params``. Args: node (intptr_t): Node to get the parameters for. Returns: cudaMemsetParams: Pointer to return the parameters. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphNodeGetParams``. .. seealso:: `cudaGraphMemsetNodeGetParams` """ cdef MemsetParams p_node_params_py = MemsetParams() cdef cudaMemsetParams *p_node_params = (p_node_params_py._get_ptr()) with nogil: __status__ = cudaGraphMemsetNodeGetParams(node, p_node_params) check_status(__status__) return p_node_params_py cpdef graph_memset_node_set_params(intptr_t node, p_node_params): """Sets a memset node's parameters. Sets the parameters of memset node ``node`` to ``p_node_params``. Args: node (intptr_t): Node to set the parameters for. p_node_params (intptr_t): Parameters to copy. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphNodeSetParams``. .. seealso:: `cudaGraphMemsetNodeSetParams` """ cdef intptr_t _p_node_params_ptr_ = 0 if p_node_params is None else int(p_node_params) with nogil: __status__ = cudaGraphMemsetNodeSetParams(node, _p_node_params_ptr_) check_status(__status__) cpdef intptr_t graph_add_host_node(intptr_t graph, p_dependencies, p_node_params) except? 0: """Creates a host execution node and adds it to a graph. Creates a new CPU execution node and adds it to ``graph`` with ``len(p_dependencies)`` dependencies specified via ``p_dependencies`` and arguments specified in ``p_node_params``. It is possible for ``len(p_dependencies)`` to be 0, in which case the node will be placed at the root of the graph. ``p_dependencies`` may not have any duplicate entries. A handle to the new node will be returned in ``p_graph_node``. When the graph is launched, the node will invoke the specified CPU function. Host nodes are not supported under MPS with pre-Volta GPUs. Args: graph (intptr_t): Graph to which to add the node. p_dependencies (object): Dependencies of the node. It must be: - a Python sequence of :class:`int`\s (as pointer addresses), or - ``None`` for NULL. p_node_params (intptr_t): Parameters for the host node. Returns: intptr_t: Returns newly created node. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphAddNode``. .. seealso:: `cudaGraphAddHostNode` """ cdef _cyb_nullable_unique_ptr[ _cyb_vector[void*] ] _p_dependencies_ if isinstance(p_dependencies, int): raise TypeError( "p_dependencies must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _p_dependencies_len_ = 0 _cyb_get_resource_ptrs[void](_p_dependencies_, p_dependencies, NULL) if _p_dependencies_.get() != NULL: _p_dependencies_len_ = _p_dependencies_.get().size() cdef intptr_t _p_node_params_ptr_ = 0 if p_node_params is None else int(p_node_params) cdef Py_ssize_t _num_dependencies_length_ = 0 cdef bint _num_dependencies_is_set_ = False if p_dependencies is not None: _num_dependencies_length_ = _cyb_check_same_length(_num_dependencies_is_set_, _num_dependencies_length_, _p_dependencies_len_, "p_dependencies", "p_dependencies") _num_dependencies_is_set_ = True cdef size_t num_dependencies = _num_dependencies_length_ if num_dependencies != _num_dependencies_length_: raise OverflowError( f"The length of (p_dependencies), {_num_dependencies_length_}, does not fit in 'numDependencies' (a size_t)" ) cdef cudaGraphNode_t p_graph_node with nogil: __status__ = cudaGraphAddHostNode(&p_graph_node, graph, (_p_dependencies_.data()), num_dependencies, _p_node_params_ptr_) check_status(__status__) return p_graph_node cpdef object graph_host_node_get_params(intptr_t node): """Returns a host node's parameters. Returns the parameters of host node ``node`` in ``p_node_params``. Args: node (intptr_t): Node to get the parameters for. Returns: cudaHostNodeParams: Pointer to return the parameters. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphNodeGetParams``. .. seealso:: `cudaGraphHostNodeGetParams` """ cdef HostNodeParams p_node_params_py = HostNodeParams() cdef cudaHostNodeParams *p_node_params = (p_node_params_py._get_ptr()) with nogil: __status__ = cudaGraphHostNodeGetParams(node, p_node_params) check_status(__status__) return p_node_params_py cpdef graph_host_node_set_params(intptr_t node, p_node_params): """Sets a host node's parameters. Sets the parameters of host node ``node`` to ``nodeParams``. Args: node (intptr_t): Node to set the parameters for. p_node_params (intptr_t): Parameters to copy. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphNodeSetParams``. .. seealso:: `cudaGraphHostNodeSetParams` """ cdef intptr_t _p_node_params_ptr_ = 0 if p_node_params is None else int(p_node_params) with nogil: __status__ = cudaGraphHostNodeSetParams(node, _p_node_params_ptr_) check_status(__status__) cpdef intptr_t graph_add_child_graph_node(intptr_t graph, p_dependencies, intptr_t child_graph) except? 0: """Creates a child graph node and adds it to a graph. Creates a new node which executes an embedded graph, and adds it to ``graph`` with ``len(p_dependencies)`` dependencies specified via ``p_dependencies``. It is possible for ``len(p_dependencies)`` to be 0, in which case the node will be placed at the root of the graph. ``p_dependencies`` may not have any duplicate entries. A handle to the new node will be returned in ``p_graph_node``. If ``child_graph`` contains allocation nodes, free nodes, or conditional nodes, this call will return an error. The node executes an embedded child graph. The child graph is cloned in this call. Args: graph (intptr_t): Graph to which to add the node. p_dependencies (object): Dependencies of the node. It must be: - a Python sequence of :class:`int`\s (as pointer addresses), or - ``None`` for NULL. child_graph (intptr_t): The graph to clone into this node. Returns: intptr_t: Returns newly created node. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphAddNode``. .. seealso:: `cudaGraphAddChildGraphNode` """ cdef _cyb_nullable_unique_ptr[ _cyb_vector[void*] ] _p_dependencies_ if isinstance(p_dependencies, int): raise TypeError( "p_dependencies must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _p_dependencies_len_ = 0 _cyb_get_resource_ptrs[void](_p_dependencies_, p_dependencies, NULL) if _p_dependencies_.get() != NULL: _p_dependencies_len_ = _p_dependencies_.get().size() cdef Py_ssize_t _num_dependencies_length_ = 0 cdef bint _num_dependencies_is_set_ = False if p_dependencies is not None: _num_dependencies_length_ = _cyb_check_same_length(_num_dependencies_is_set_, _num_dependencies_length_, _p_dependencies_len_, "p_dependencies", "p_dependencies") _num_dependencies_is_set_ = True cdef size_t num_dependencies = _num_dependencies_length_ if num_dependencies != _num_dependencies_length_: raise OverflowError( f"The length of (p_dependencies), {_num_dependencies_length_}, does not fit in 'numDependencies' (a size_t)" ) cdef cudaGraphNode_t p_graph_node with nogil: __status__ = cudaGraphAddChildGraphNode(&p_graph_node, graph, (_p_dependencies_.data()), num_dependencies, child_graph) check_status(__status__) return p_graph_node cpdef intptr_t graph_child_graph_node_get_graph(intptr_t node) except? 0: """Gets a handle to the embedded graph of a child graph node. Gets a handle to the embedded graph in a child graph node. This call does not clone the graph. Changes to the graph will be reflected in the node, and the node retains ownership of the graph. Allocation and free nodes cannot be added to the returned graph. Attempting to do so will return an error. Args: node (intptr_t): Node to get the embedded graph for. Returns: intptr_t: Location to store a handle to the graph. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphNodeGetParams``. .. seealso:: `cudaGraphChildGraphNodeGetGraph` """ cdef cudaGraph_t p_graph with nogil: __status__ = cudaGraphChildGraphNodeGetGraph(node, &p_graph) check_status(__status__) return p_graph cpdef intptr_t graph_add_empty_node(intptr_t graph, p_dependencies) except? 0: """Creates an empty node and adds it to a graph. Creates a new node which performs no operation, and adds it to ``graph`` with ``len(p_dependencies)`` dependencies specified via ``p_dependencies``. It is possible for ``len(p_dependencies)`` to be 0, in which case the node will be placed at the root of the graph. ``p_dependencies`` may not have any duplicate entries. A handle to the new node will be returned in ``p_graph_node``. An empty node performs no operation during execution, but can be used for transitive ordering. For example, a phased execution graph with 2 groups of n nodes with a barrier between them can be represented using an empty node and 2*n dependency edges, rather than no empty node and n^2 dependency edges. Args: graph (intptr_t): Graph to which to add the node. p_dependencies (object): Dependencies of the node. It must be: - a Python sequence of :class:`int`\s (as pointer addresses), or - ``None`` for NULL. Returns: intptr_t: Returns newly created node. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphAddNode``. .. seealso:: `cudaGraphAddEmptyNode` """ cdef _cyb_nullable_unique_ptr[ _cyb_vector[void*] ] _p_dependencies_ if isinstance(p_dependencies, int): raise TypeError( "p_dependencies must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _p_dependencies_len_ = 0 _cyb_get_resource_ptrs[void](_p_dependencies_, p_dependencies, NULL) if _p_dependencies_.get() != NULL: _p_dependencies_len_ = _p_dependencies_.get().size() cdef Py_ssize_t _num_dependencies_length_ = 0 cdef bint _num_dependencies_is_set_ = False if p_dependencies is not None: _num_dependencies_length_ = _cyb_check_same_length(_num_dependencies_is_set_, _num_dependencies_length_, _p_dependencies_len_, "p_dependencies", "p_dependencies") _num_dependencies_is_set_ = True cdef size_t num_dependencies = _num_dependencies_length_ if num_dependencies != _num_dependencies_length_: raise OverflowError( f"The length of (p_dependencies), {_num_dependencies_length_}, does not fit in 'numDependencies' (a size_t)" ) cdef cudaGraphNode_t p_graph_node with nogil: __status__ = cudaGraphAddEmptyNode(&p_graph_node, graph, (_p_dependencies_.data()), num_dependencies) check_status(__status__) return p_graph_node cpdef intptr_t graph_add_event_record_node(intptr_t graph, p_dependencies, intptr_t event) except? 0: """Creates an event record node and adds it to a graph. Creates a new event record node and adds it to ``hGraph`` with ``len(p_dependencies)`` dependencies specified via ``dependencies`` and event specified in ``event``. It is possible for ``len(p_dependencies)`` to be 0, in which case the node will be placed at the root of the graph. ``dependencies`` may not have any duplicate entries. A handle to the new node will be returned in ``phGraphNode``. Each launch of the graph will record ``event`` to capture execution of the node's dependencies. These nodes may not be used in loops or conditionals. Args: graph (intptr_t): Graph to which to add the node. p_dependencies (object): Dependencies of the node. It must be: - a Python sequence of :class:`int`\s (as pointer addresses), or - ``None`` for NULL. event (intptr_t): Event for the node. Returns: intptr_t: Returns newly created node. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphAddNode``. .. seealso:: `cudaGraphAddEventRecordNode` """ cdef _cyb_nullable_unique_ptr[ _cyb_vector[void*] ] _p_dependencies_ if isinstance(p_dependencies, int): raise TypeError( "p_dependencies must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _p_dependencies_len_ = 0 _cyb_get_resource_ptrs[void](_p_dependencies_, p_dependencies, NULL) if _p_dependencies_.get() != NULL: _p_dependencies_len_ = _p_dependencies_.get().size() cdef Py_ssize_t _num_dependencies_length_ = 0 cdef bint _num_dependencies_is_set_ = False if p_dependencies is not None: _num_dependencies_length_ = _cyb_check_same_length(_num_dependencies_is_set_, _num_dependencies_length_, _p_dependencies_len_, "p_dependencies", "p_dependencies") _num_dependencies_is_set_ = True cdef size_t num_dependencies = _num_dependencies_length_ if num_dependencies != _num_dependencies_length_: raise OverflowError( f"The length of (p_dependencies), {_num_dependencies_length_}, does not fit in 'numDependencies' (a size_t)" ) cdef cudaGraphNode_t p_graph_node with nogil: __status__ = cudaGraphAddEventRecordNode(&p_graph_node, graph, (_p_dependencies_.data()), num_dependencies, event) check_status(__status__) return p_graph_node cpdef intptr_t graph_event_record_node_get_event(intptr_t node) except? 0: """Returns the event associated with an event record node. Returns the event of event record node ``hNode`` in ``event_out``. Args: node (intptr_t): Node to get the event for. Returns: intptr_t: Pointer to return the event. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphNodeGetParams``. .. seealso:: `cudaGraphEventRecordNodeGetEvent` """ cdef cudaEvent_t event_out with nogil: __status__ = cudaGraphEventRecordNodeGetEvent(node, &event_out) check_status(__status__) return event_out cpdef graph_event_record_node_set_event(intptr_t node, intptr_t event): """Sets an event record node's event. Sets the event of event record node ``hNode`` to ``event``. Args: node (intptr_t): Node to set the event for. event (intptr_t): Event to use. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphNodeSetParams``. .. seealso:: `cudaGraphEventRecordNodeSetEvent` """ with nogil: __status__ = cudaGraphEventRecordNodeSetEvent(node, event) check_status(__status__) cpdef intptr_t graph_add_event_wait_node(intptr_t graph, p_dependencies, intptr_t event) except? 0: """Creates an event wait node and adds it to a graph. Creates a new event wait node and adds it to ``hGraph`` with ``len(p_dependencies)`` dependencies specified via ``dependencies`` and event specified in ``event``. It is possible for ``len(p_dependencies)`` to be 0, in which case the node will be placed at the root of the graph. ``dependencies`` may not have any duplicate entries. A handle to the new node will be returned in ``phGraphNode``. The graph node will wait for all work captured in ``event``. See ``cuEventRecord()`` for details on what is captured by an event. The synchronization will be performed efficiently on the device when applicable. ``event`` may be from a different context or device than the launch stream. These nodes may not be used in loops or conditionals. Args: graph (intptr_t): Graph to which to add the node. p_dependencies (object): Dependencies of the node. It must be: - a Python sequence of :class:`int`\s (as pointer addresses), or - ``None`` for NULL. event (intptr_t): Event for the node. Returns: intptr_t: Returns newly created node. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphAddNode``. .. seealso:: `cudaGraphAddEventWaitNode` """ cdef _cyb_nullable_unique_ptr[ _cyb_vector[void*] ] _p_dependencies_ if isinstance(p_dependencies, int): raise TypeError( "p_dependencies must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _p_dependencies_len_ = 0 _cyb_get_resource_ptrs[void](_p_dependencies_, p_dependencies, NULL) if _p_dependencies_.get() != NULL: _p_dependencies_len_ = _p_dependencies_.get().size() cdef Py_ssize_t _num_dependencies_length_ = 0 cdef bint _num_dependencies_is_set_ = False if p_dependencies is not None: _num_dependencies_length_ = _cyb_check_same_length(_num_dependencies_is_set_, _num_dependencies_length_, _p_dependencies_len_, "p_dependencies", "p_dependencies") _num_dependencies_is_set_ = True cdef size_t num_dependencies = _num_dependencies_length_ if num_dependencies != _num_dependencies_length_: raise OverflowError( f"The length of (p_dependencies), {_num_dependencies_length_}, does not fit in 'numDependencies' (a size_t)" ) cdef cudaGraphNode_t p_graph_node with nogil: __status__ = cudaGraphAddEventWaitNode(&p_graph_node, graph, (_p_dependencies_.data()), num_dependencies, event) check_status(__status__) return p_graph_node cpdef intptr_t graph_event_wait_node_get_event(intptr_t node) except? 0: """Returns the event associated with an event wait node. Returns the event of event wait node ``hNode`` in ``event_out``. Args: node (intptr_t): Node to get the event for. Returns: intptr_t: Pointer to return the event. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphNodeGetParams``. .. seealso:: `cudaGraphEventWaitNodeGetEvent` """ cdef cudaEvent_t event_out with nogil: __status__ = cudaGraphEventWaitNodeGetEvent(node, &event_out) check_status(__status__) return event_out cpdef graph_event_wait_node_set_event(intptr_t node, intptr_t event): """Sets an event wait node's event. Sets the event of event wait node ``hNode`` to ``event``. Args: node (intptr_t): Node to set the event for. event (intptr_t): Event to use. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphNodeSetParams``. .. seealso:: `cudaGraphEventWaitNodeSetEvent` """ with nogil: __status__ = cudaGraphEventWaitNodeSetEvent(node, event) check_status(__status__) cpdef intptr_t graph_add_external_semaphores_signal_node(intptr_t graph, p_dependencies, node_params) except? 0: """Creates an external semaphore signal node and adds it to a graph. Creates a new external semaphore signal node and adds it to ``graph`` with ``len(p_dependencies)`` dependencies specified via ``dependencies`` and arguments specified in ``node_params``. It is possible for ``len(p_dependencies)`` to be 0, in which case the node will be placed at the root of the graph. ``dependencies`` may not have any duplicate entries. A handle to the new node will be returned in ``p_graph_node``. Performs a signal operation on a set of externally allocated semaphore objects when the node is launched. The operation(s) will occur after all of the node's dependencies have completed. Args: graph (intptr_t): Graph to which to add the node. p_dependencies (object): Dependencies of the node. It must be: - a Python sequence of :class:`int`\s (as pointer addresses), or - ``None`` for NULL. node_params (intptr_t): Parameters for the node. Returns: intptr_t: Returns newly created node. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphAddNode``. .. seealso:: `cudaGraphAddExternalSemaphoresSignalNode` """ cdef _cyb_nullable_unique_ptr[ _cyb_vector[void*] ] _p_dependencies_ if isinstance(p_dependencies, int): raise TypeError( "p_dependencies must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _p_dependencies_len_ = 0 _cyb_get_resource_ptrs[void](_p_dependencies_, p_dependencies, NULL) if _p_dependencies_.get() != NULL: _p_dependencies_len_ = _p_dependencies_.get().size() cdef intptr_t _node_params_ptr_ = 0 if node_params is None else int(node_params) cdef Py_ssize_t _num_dependencies_length_ = 0 cdef bint _num_dependencies_is_set_ = False if p_dependencies is not None: _num_dependencies_length_ = _cyb_check_same_length(_num_dependencies_is_set_, _num_dependencies_length_, _p_dependencies_len_, "p_dependencies", "p_dependencies") _num_dependencies_is_set_ = True cdef size_t num_dependencies = _num_dependencies_length_ if num_dependencies != _num_dependencies_length_: raise OverflowError( f"The length of (p_dependencies), {_num_dependencies_length_}, does not fit in 'numDependencies' (a size_t)" ) cdef cudaGraphNode_t p_graph_node with nogil: __status__ = cudaGraphAddExternalSemaphoresSignalNode(&p_graph_node, graph, (_p_dependencies_.data()), num_dependencies, _node_params_ptr_) check_status(__status__) return p_graph_node cpdef object graph_external_semaphores_signal_node_get_params(intptr_t h_node): """Returns an external semaphore signal node's parameters. Returns the parameters of an external semaphore signal node ``h_node`` in ``params_out``. The ``extSemArray`` and ``paramsArray`` returned in ``params_out``, are owned by the node. This memory remains valid until the node is destroyed or its parameters are modified, and should not be modified directly. Use ``cudaGraphExternalSemaphoresSignalNodeSetParams`` to update the parameters of this node. Args: h_node (intptr_t): Node to get the parameters for. Returns: cudaExternalSemaphoreSignalNodeParams: Pointer to return the parameters. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraph_nodeGetParams``. .. seealso:: `cudaGraphExternalSemaphoresSignalNodeGetParams` """ cdef ExternalSemaphoreSignalNodeParams params_out_py = ExternalSemaphoreSignalNodeParams() cdef cudaExternalSemaphoreSignalNodeParams *params_out = (params_out_py._get_ptr()) with nogil: __status__ = cudaGraphExternalSemaphoresSignalNodeGetParams(h_node, params_out) check_status(__status__) return params_out_py cpdef graph_external_semaphores_signal_node_set_params(intptr_t h_node, node_params): """Sets an external semaphore signal node's parameters. Sets the parameters of an external semaphore signal node ``h_node`` to ``node_params``. Args: h_node (intptr_t): Node to set the parameters for. node_params (intptr_t): Parameters to copy. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraph_nodeSetParams``. .. seealso:: `cudaGraphExternalSemaphoresSignalNodeSetParams` """ cdef intptr_t _node_params_ptr_ = 0 if node_params is None else int(node_params) with nogil: __status__ = cudaGraphExternalSemaphoresSignalNodeSetParams(h_node, _node_params_ptr_) check_status(__status__) cpdef intptr_t graph_add_external_semaphores_wait_node(intptr_t graph, p_dependencies, node_params) except? 0: """Creates an external semaphore wait node and adds it to a graph. Creates a new external semaphore wait node and adds it to ``graph`` with ``len(p_dependencies)`` dependencies specified via ``dependencies`` and arguments specified in ``node_params``. It is possible for ``len(p_dependencies)`` to be 0, in which case the node will be placed at the root of the graph. ``dependencies`` may not have any duplicate entries. A handle to the new node will be returned in ``p_graph_node``. Performs a wait operation on a set of externally allocated semaphore objects when the node is launched. The node's dependencies will not be launched until the wait operation has completed. Args: graph (intptr_t): Graph to which to add the node. p_dependencies (object): Dependencies of the node. It must be: - a Python sequence of :class:`int`\s (as pointer addresses), or - ``None`` for NULL. node_params (intptr_t): Parameters for the node. Returns: intptr_t: Returns newly created node. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphAddNode``. .. seealso:: `cudaGraphAddExternalSemaphoresWaitNode` """ cdef _cyb_nullable_unique_ptr[ _cyb_vector[void*] ] _p_dependencies_ if isinstance(p_dependencies, int): raise TypeError( "p_dependencies must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _p_dependencies_len_ = 0 _cyb_get_resource_ptrs[void](_p_dependencies_, p_dependencies, NULL) if _p_dependencies_.get() != NULL: _p_dependencies_len_ = _p_dependencies_.get().size() cdef intptr_t _node_params_ptr_ = 0 if node_params is None else int(node_params) cdef Py_ssize_t _num_dependencies_length_ = 0 cdef bint _num_dependencies_is_set_ = False if p_dependencies is not None: _num_dependencies_length_ = _cyb_check_same_length(_num_dependencies_is_set_, _num_dependencies_length_, _p_dependencies_len_, "p_dependencies", "p_dependencies") _num_dependencies_is_set_ = True cdef size_t num_dependencies = _num_dependencies_length_ if num_dependencies != _num_dependencies_length_: raise OverflowError( f"The length of (p_dependencies), {_num_dependencies_length_}, does not fit in 'numDependencies' (a size_t)" ) cdef cudaGraphNode_t p_graph_node with nogil: __status__ = cudaGraphAddExternalSemaphoresWaitNode(&p_graph_node, graph, (_p_dependencies_.data()), num_dependencies, _node_params_ptr_) check_status(__status__) return p_graph_node cpdef object graph_external_semaphores_wait_node_get_params(intptr_t h_node): """Returns an external semaphore wait node's parameters. Returns the parameters of an external semaphore wait node ``h_node`` in ``params_out``. The ``extSemArray`` and ``paramsArray`` returned in ``params_out``, are owned by the node. This memory remains valid until the node is destroyed or its parameters are modified, and should not be modified directly. Use ``cudaGraphExternalSemaphoresSignalNodeSetParams`` to update the parameters of this node. Args: h_node (intptr_t): Node to get the parameters for. Returns: cudaExternalSemaphoreWaitNodeParams: Pointer to return the parameters. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraph_nodeGetParams``. .. seealso:: `cudaGraphExternalSemaphoresWaitNodeGetParams` """ cdef ExternalSemaphoreWaitNodeParams params_out_py = ExternalSemaphoreWaitNodeParams() cdef cudaExternalSemaphoreWaitNodeParams *params_out = (params_out_py._get_ptr()) with nogil: __status__ = cudaGraphExternalSemaphoresWaitNodeGetParams(h_node, params_out) check_status(__status__) return params_out_py cpdef graph_external_semaphores_wait_node_set_params(intptr_t h_node, node_params): """Sets an external semaphore wait node's parameters. Sets the parameters of an external semaphore wait node ``h_node`` to ``node_params``. Args: h_node (intptr_t): Node to set the parameters for. node_params (intptr_t): Parameters to copy. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraph_nodeSetParams``. .. seealso:: `cudaGraphExternalSemaphoresWaitNodeSetParams` """ cdef intptr_t _node_params_ptr_ = 0 if node_params is None else int(node_params) with nogil: __status__ = cudaGraphExternalSemaphoresWaitNodeSetParams(h_node, _node_params_ptr_) check_status(__status__) cpdef intptr_t graph_add_mem_alloc_node(intptr_t graph, p_dependencies, node_params) except? 0: """Creates an allocation node and adds it to a graph. Creates a new allocation node and adds it to ``graph`` with ``len(p_dependencies)`` dependencies specified via ``p_dependencies`` and arguments specified in ``node_params``. It is possible for ``len(p_dependencies)`` to be 0, in which case the node will be placed at the root of the graph. ``p_dependencies`` may not have any duplicate entries. A handle to the new node will be returned in ``p_graph_node``. When ``cudaGraphAddMemAllocNode`` creates an allocation node, it returns the address of the allocation in ``node_params.dptr``. The allocation's address remains fixed across instantiations and launches. If the allocation is freed in the same graph, by creating a free node using ``cudaGraphAddMemFreeNode``, the allocation can be accessed by nodes ordered after the allocation node but before the free node. These allocations cannot be freed outside the owning graph, and they can only be freed once in the owning graph. If the allocation is not freed in the same graph, then it can be accessed not only by nodes in the graph which are ordered after the allocation node, but also by stream operations ordered after the graph's execution but before the allocation is freed. Allocations which are not freed in the same graph can be freed by:. - passing the allocation to ``cudaMemFreeAsync`` or ``cudaMemFree``;. - launching a graph with a free node for that allocation; or. - specifying ``cudaGraphInstantiateFlagAutoFreeOnLaunch`` during instantiation, which makes each launch behave as though it called ``cudaMemFreeAsync`` for every unfreed allocation. It is not possible to free an allocation in both the owning graph and another graph. If the allocation is freed in the same graph, a free node cannot be added to another graph. If the allocation is freed in another graph, a free node can no longer be added to the owning graph. The following restrictions apply to graphs which contain allocation and/or memory free nodes:. - Nodes and edges of the graph cannot be deleted. - The graph can only be used in a child node if the ownership is moved to the parent. - Only one instantiation of the graph may exist at any point in time. - The graph cannot be cloned. Args: graph (intptr_t): Graph to which to add the node. p_dependencies (object): Dependencies of the node. It must be: - a Python sequence of :class:`int`\s (as pointer addresses), or - ``None`` for NULL. node_params (intptr_t): Parameters for the node. Returns: intptr_t: Returns newly created node. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphAddNode``. .. seealso:: `cudaGraphAddMemAllocNode` """ cdef _cyb_nullable_unique_ptr[ _cyb_vector[void*] ] _p_dependencies_ if isinstance(p_dependencies, int): raise TypeError( "p_dependencies must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _p_dependencies_len_ = 0 _cyb_get_resource_ptrs[void](_p_dependencies_, p_dependencies, NULL) if _p_dependencies_.get() != NULL: _p_dependencies_len_ = _p_dependencies_.get().size() cdef intptr_t _node_params_ptr_ = 0 if node_params is None else int(node_params) cdef Py_ssize_t _num_dependencies_length_ = 0 cdef bint _num_dependencies_is_set_ = False if p_dependencies is not None: _num_dependencies_length_ = _cyb_check_same_length(_num_dependencies_is_set_, _num_dependencies_length_, _p_dependencies_len_, "p_dependencies", "p_dependencies") _num_dependencies_is_set_ = True cdef size_t num_dependencies = _num_dependencies_length_ if num_dependencies != _num_dependencies_length_: raise OverflowError( f"The length of (p_dependencies), {_num_dependencies_length_}, does not fit in 'numDependencies' (a size_t)" ) cdef cudaGraphNode_t p_graph_node with nogil: __status__ = cudaGraphAddMemAllocNode(&p_graph_node, graph, (_p_dependencies_.data()), num_dependencies, _node_params_ptr_) check_status(__status__) return p_graph_node cpdef object graph_mem_alloc_node_get_params(intptr_t node): """Returns a memory alloc node's parameters. Returns the parameters of a memory alloc node ``hNode`` in ``params_out``. The ``poolProps`` and ``accessDescs`` returned in ``params_out``, are owned by the node. This memory remains valid until the node is destroyed. The returned parameters must not be modified. Args: node (intptr_t): Node to get the parameters for. Returns: cudaMemAllocNodeParams: Pointer to return the parameters. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphNodeGetParams``. .. seealso:: `cudaGraphMemAllocNodeGetParams` """ cdef MemAllocNodeParams params_out_py = MemAllocNodeParams() cdef cudaMemAllocNodeParams *params_out = (params_out_py._get_ptr()) with nogil: __status__ = cudaGraphMemAllocNodeGetParams(node, params_out) check_status(__status__) return params_out_py cpdef intptr_t graph_add_mem_free_node(intptr_t graph, p_dependencies, intptr_t dptr) except? 0: """Creates a memory free node and adds it to a graph. Creates a new memory free node and adds it to ``graph`` with ``len(p_dependencies)`` dependencies specified via ``p_dependencies`` and address specified in ``dptr``. It is possible for ``len(p_dependencies)`` to be 0, in which case the node will be placed at the root of the graph. ``p_dependencies`` may not have any duplicate entries. A handle to the new node will be returned in ``p_graph_node``. ``cudaGraphAddMemFreeNode`` will return ``cudaErrorInvalidValue`` if the user attempts to free:. - an allocation twice in the same graph. - an address that was not returned by an allocation node. - an invalid address. The following restrictions apply to graphs which contain allocation and/or memory free nodes:. - Nodes and edges of the graph cannot be deleted. - The graph can only be used in a child node if the ownership is moved to the parent. - Only one instantiation of the graph may exist at any point in time. - The graph cannot be cloned. Args: graph (intptr_t): Graph to which to add the node. p_dependencies (object): Dependencies of the node. It must be: - a Python sequence of :class:`int`\s (as pointer addresses), or - ``None`` for NULL. dptr (intptr_t): Address of memory to free. Returns: intptr_t: Returns newly created node. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphAddNode``. .. seealso:: `cudaGraphAddMemFreeNode` """ cdef _cyb_nullable_unique_ptr[ _cyb_vector[void*] ] _p_dependencies_ if isinstance(p_dependencies, int): raise TypeError( "p_dependencies must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _p_dependencies_len_ = 0 _cyb_get_resource_ptrs[void](_p_dependencies_, p_dependencies, NULL) if _p_dependencies_.get() != NULL: _p_dependencies_len_ = _p_dependencies_.get().size() cdef Py_ssize_t _num_dependencies_length_ = 0 cdef bint _num_dependencies_is_set_ = False if p_dependencies is not None: _num_dependencies_length_ = _cyb_check_same_length(_num_dependencies_is_set_, _num_dependencies_length_, _p_dependencies_len_, "p_dependencies", "p_dependencies") _num_dependencies_is_set_ = True cdef size_t num_dependencies = _num_dependencies_length_ if num_dependencies != _num_dependencies_length_: raise OverflowError( f"The length of (p_dependencies), {_num_dependencies_length_}, does not fit in 'numDependencies' (a size_t)" ) cdef cudaGraphNode_t p_graph_node with nogil: __status__ = cudaGraphAddMemFreeNode(&p_graph_node, graph, (_p_dependencies_.data()), num_dependencies, dptr) check_status(__status__) return p_graph_node cpdef device_graph_mem_trim(int device): """Free unused memory that was cached on the specified device for use with graphs back to the OS. Blocks which are not in use by a graph that is either currently executing or scheduled to execute are freed back to the operating system. Args: device (int): The device for which cached memory should be freed. .. seealso:: `cudaDeviceGraphMemTrim` """ with nogil: __status__ = cudaDeviceGraphMemTrim(device) check_status(__status__) cpdef intptr_t graph_clone(intptr_t original_graph) except? 0: """Clones a graph. This function creates a copy of ``original_graph`` and returns it in ``p_graph_clone``. All parameters are copied into the cloned graph. The original graph may be modified after this call without affecting the clone. Child graph nodes in the original graph are recursively copied into the clone. Args: original_graph (intptr_t): Graph to clone. Returns: intptr_t: Returns newly created cloned graph. .. note:: : Cloning is not supported for graphs which contain memory allocation nodes, memory free nodes, or conditional nodes. .. seealso:: `cudaGraphClone` """ cdef cudaGraph_t p_graph_clone with nogil: __status__ = cudaGraphClone(&p_graph_clone, original_graph) check_status(__status__) return p_graph_clone cpdef intptr_t graph_node_find_in_clone(intptr_t original_node, intptr_t cloned_graph) except? 0: """Finds a cloned version of a node. This function returns the node in ``cloned_graph`` corresponding to ``original_node`` in the original graph. ``cloned_graph`` must have been cloned from ``originalGraph`` via ``cudaGraphClone``. ``original_node`` must have been in ``originalGraph`` at the time of the call to ``cudaGraphClone``, and the corresponding cloned node in ``cloned_graph`` must not have been removed. The cloned node is then returned via ``pClonedNode``. Args: original_node (intptr_t): Handle to the original node. cloned_graph (intptr_t): Cloned graph to query. Returns: intptr_t: Returns handle to the cloned node. .. seealso:: `cudaGraphNodeFindInClone` """ cdef cudaGraphNode_t p_node with nogil: __status__ = cudaGraphNodeFindInClone(&p_node, original_node, cloned_graph) check_status(__status__) return p_node cpdef int graph_node_get_type(intptr_t node) except? -1: """Returns a node's type. Returns the node type of ``node`` in ``p_type``. Args: node (intptr_t): Node to query. Returns: int: Pointer to return the node type. .. seealso:: `cudaGraphNodeGetType` """ cdef cudaGraphNodeType p_type with nogil: __status__ = cudaGraphNodeGetType(node, &p_type) check_status(__status__) return p_type cpdef object graph_get_nodes(intptr_t graph): """Returns a graph's nodes. Returns a list of ``graph's`` nodes. ``nodes`` may be NULL, in which case this function will return the number of nodes in ``num_nodes``. Otherwise, ``num_nodes`` entries will be filled in. If ``num_nodes`` is higher than the actual number of nodes, the remaining entries in ``nodes`` will be set to NULL, and the number of nodes actually obtained will be returned in ``num_nodes``. Args: graph (intptr_t): Graph to query. Returns: intptr_t: Pointer to return the nodes. .. seealso:: `cudaGraphGetNodes` """ cdef size_t[1] num_nodes = [0] with nogil: __status__ = cudaGraphGetNodes(graph, NULL, num_nodes) check_status_size(__status__) cdef _cyb_view.array _nodes_alloc_ = _cyb_view.array(shape=(max(num_nodes[0], 1),), itemsize=sizeof(intptr_t), format="q", mode="c") cdef intptr_t *nodes_ptr = (_nodes_alloc_.data) cdef object nodes = _nodes_alloc_[:num_nodes[0]] if num_nodes[0] != 0: with nogil: __status__ = cudaGraphGetNodes(graph, nodes_ptr, num_nodes) check_status(__status__) return nodes[:num_nodes[0]] cpdef object graph_get_root_nodes(intptr_t graph): """Returns a graph's root nodes. Returns a list of ``graph's`` root nodes. ``p_root_nodes`` may be NULL, in which case this function will return the number of root nodes in ``p_num_root_nodes``. Otherwise, ``p_num_root_nodes`` entries will be filled in. If ``p_num_root_nodes`` is higher than the actual number of root nodes, the remaining entries in ``p_root_nodes`` will be set to NULL, and the number of nodes actually obtained will be returned in ``p_num_root_nodes``. Args: graph (intptr_t): Graph to query. Returns: intptr_t: Pointer to return the root nodes. .. seealso:: `cudaGraphGetRootNodes` """ cdef size_t[1] p_num_root_nodes = [0] with nogil: __status__ = cudaGraphGetRootNodes(graph, NULL, p_num_root_nodes) check_status_size(__status__) cdef _cyb_view.array _p_root_nodes_alloc_ = _cyb_view.array(shape=(max(p_num_root_nodes[0], 1),), itemsize=sizeof(intptr_t), format="q", mode="c") cdef intptr_t *p_root_nodes_ptr = (_p_root_nodes_alloc_.data) cdef object p_root_nodes = _p_root_nodes_alloc_[:p_num_root_nodes[0]] if p_num_root_nodes[0] != 0: with nogil: __status__ = cudaGraphGetRootNodes(graph, p_root_nodes_ptr, p_num_root_nodes) check_status(__status__) return p_root_nodes[:p_num_root_nodes[0]] cpdef tuple graph_get_edges(intptr_t graph): """Returns a graph's dependency edges. Returns a list of ``graph's`` dependency edges. Edges are returned via corresponding indices in ``from_``, ``to`` and ``edge_data``; that is, the node in ``to``\[i] has a dependency on the node in ``from_``\[i] with data ``edge_data``\[i]. ``from_`` and ``to`` may both be NULL, in which case this function only returns the number of edges in ``num_edges``. Otherwise, ``num_edges`` entries will be filled in. If ``num_edges`` is higher than the actual number of edges, the remaining entries in ``from_`` and ``to`` will be set to NULL, and the number of edges actually returned will be written to ``num_edges``. ``edge_data`` may alone be NULL, in which case the edges must all have default (zeroed) edge data. Attempting a losst query via NULL ``edge_data`` will result in ``cudaErrorLossyQuery``. If ``edge_data`` is non-NULL then ``from_`` and ``to`` must be as well. Args: graph (intptr_t): Graph to get the edges from. Returns: A 3-tuple containing: - intptr_t: Location to return edge endpoints. - intptr_t: Location to return edge endpoints. - cudaGraphEdgeData: Optional location to return edge data. .. seealso:: `cudaGraphGetEdges` """ cdef size_t[1] num_edges = [0] with nogil: __status__ = cudaGraphGetEdges(graph, NULL, NULL, NULL, num_edges) check_status_size(__status__) cdef _cyb_view.array _from__alloc_ = _cyb_view.array(shape=(max(num_edges[0], 1),), itemsize=sizeof(intptr_t), format="q", mode="c") cdef intptr_t *from__ptr = (_from__alloc_.data) cdef object from_ = _from__alloc_[:num_edges[0]] cdef _cyb_view.array _to_alloc_ = _cyb_view.array(shape=(max(num_edges[0], 1),), itemsize=sizeof(intptr_t), format="q", mode="c") cdef intptr_t *to_ptr = (_to_alloc_.data) cdef object to = _to_alloc_[:num_edges[0]] cdef GraphEdgeData edge_data = GraphEdgeData(num_edges[0]) cdef cudaGraphEdgeData *edge_data_ptr = (edge_data._get_ptr()) if not (num_edges[0] == 0): with nogil: __status__ = cudaGraphGetEdges(graph, from__ptr, to_ptr, edge_data_ptr, num_edges) check_status(__status__) return (from_[:num_edges[0]], to[:num_edges[0]], edge_data[:num_edges[0]]) cpdef tuple graph_node_get_dependencies(intptr_t node): """Returns a node's dependencies. Returns a list of ``node's`` dependencies. ``p_dependencies`` may be NULL, in which case this function will return the number of dependencies in ``p_num_dependencies``. Otherwise, ``p_num_dependencies`` entries will be filled in. If ``p_num_dependencies`` is higher than the actual number of dependencies, the remaining entries in ``p_dependencies`` will be set to NULL, and the number of nodes actually obtained will be returned in ``p_num_dependencies``. Note that if an edge has non-zero (non-default) edge data and ``edge_data`` is NULL, this API will return ``cudaErrorLossyQuery``. If ``edge_data`` is non-NULL, then ``p_dependencies`` must be as well. Args: node (intptr_t): Node to query. Returns: A 2-tuple containing: - intptr_t: Pointer to return the dependencies. - cudaGraphEdgeData: Optional array to return edge data for each dependency. .. seealso:: `cudaGraphNodeGetDependencies` """ cdef size_t[1] p_num_dependencies = [0] with nogil: __status__ = cudaGraphNodeGetDependencies(node, NULL, NULL, p_num_dependencies) check_status_size(__status__) cdef _cyb_view.array _p_dependencies_alloc_ = _cyb_view.array(shape=(max(p_num_dependencies[0], 1),), itemsize=sizeof(intptr_t), format="q", mode="c") cdef intptr_t *p_dependencies_ptr = (_p_dependencies_alloc_.data) cdef object p_dependencies = _p_dependencies_alloc_[:p_num_dependencies[0]] cdef GraphEdgeData edge_data = GraphEdgeData(p_num_dependencies[0]) cdef cudaGraphEdgeData *edge_data_ptr = (edge_data._get_ptr()) if not (p_num_dependencies[0] == 0): with nogil: __status__ = cudaGraphNodeGetDependencies(node, p_dependencies_ptr, edge_data_ptr, p_num_dependencies) check_status(__status__) return (p_dependencies[:p_num_dependencies[0]], edge_data[:p_num_dependencies[0]]) cpdef tuple graph_node_get_dependent_nodes(intptr_t node): """Returns a node's dependent nodes. Returns a list of ``node's`` dependent nodes. ``p_dependent_nodes`` may be NULL, in which case this function will return the number of dependent nodes in ``p_num_dependent_nodes``. Otherwise, ``p_num_dependent_nodes`` entries will be filled in. If ``p_num_dependent_nodes`` is higher than the actual number of dependent nodes, the remaining entries in ``p_dependent_nodes`` will be set to NULL, and the number of nodes actually obtained will be returned in ``p_num_dependent_nodes``. Note that if an edge has non-zero (non-default) edge data and ``edge_data`` is NULL, this API will return ``cudaErrorLossyQuery``. If ``edge_data`` is non-NULL, then ``p_dependent_nodes`` must be as well. Args: node (intptr_t): Node to query. Returns: A 2-tuple containing: - intptr_t: Pointer to return the dependent nodes. - cudaGraphEdgeData: Optional pointer to return edge data for dependent nodes. .. seealso:: `cudaGraphNodeGetDependentNodes` """ cdef size_t[1] p_num_dependent_nodes = [0] with nogil: __status__ = cudaGraphNodeGetDependentNodes(node, NULL, NULL, p_num_dependent_nodes) check_status_size(__status__) cdef _cyb_view.array _p_dependent_nodes_alloc_ = _cyb_view.array(shape=(max(p_num_dependent_nodes[0], 1),), itemsize=sizeof(intptr_t), format="q", mode="c") cdef intptr_t *p_dependent_nodes_ptr = (_p_dependent_nodes_alloc_.data) cdef object p_dependent_nodes = _p_dependent_nodes_alloc_[:p_num_dependent_nodes[0]] cdef GraphEdgeData edge_data = GraphEdgeData(p_num_dependent_nodes[0]) cdef cudaGraphEdgeData *edge_data_ptr = (edge_data._get_ptr()) if not (p_num_dependent_nodes[0] == 0): with nogil: __status__ = cudaGraphNodeGetDependentNodes(node, p_dependent_nodes_ptr, edge_data_ptr, p_num_dependent_nodes) check_status(__status__) return (p_dependent_nodes[:p_num_dependent_nodes[0]], edge_data[:p_num_dependent_nodes[0]]) cpdef graph_add_dependencies(intptr_t graph, from_, to, edge_data): """Adds dependency edges to a graph. The number of dependencies to be added is defined by ``len(from_)`` Elements in ``pFrom`` and ``pTo`` at corresponding indices define a dependency. Each node in ``pFrom`` and ``pTo`` must belong to ``graph``. If ``len(from_)`` is 0, elements in ``pFrom`` and ``pTo`` will be ignored. Specifying an existing dependency will return an error. Args: graph (intptr_t): Graph to which dependencies are added. from_ (object): Array of nodes that provide the dependencies. It must be: - a Python sequence of :class:`int`\s (as pointer addresses), or - ``None`` for NULL. to (object): Array of dependent nodes. It must be: - a Python sequence of :class:`int`\s (as pointer addresses), or - ``None`` for NULL. edge_data (GraphEdgeData): Optional array of edge data. If NULL, default (zeroed) edge data is assumed. It must be: - a :class:`GraphEdgeData`, or - ``None`` for NULL. .. seealso:: `cudaGraphAddDependencies` """ cdef _cyb_nullable_unique_ptr[ _cyb_vector[void*] ] _from__ if isinstance(from_, int): raise TypeError( "from_ must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _from__len_ = 0 _cyb_get_resource_ptrs[void](_from__, from_, NULL) if _from__.get() != NULL: _from__len_ = _from__.get().size() cdef _cyb_nullable_unique_ptr[ _cyb_vector[void*] ] _to_ if isinstance(to, int): raise TypeError( "to must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _to_len_ = 0 _cyb_get_resource_ptrs[void](_to_, to, NULL) if _to_.get() != NULL: _to_len_ = _to_.get().size() cdef intptr_t _edge_data_ptr_ = 0 cdef Py_ssize_t _edge_data_len_ = 0 if edge_data is None: pass else: (edge_data) _edge_data_ptr_ = int(edge_data) _edge_data_len_ = len(edge_data) cdef Py_ssize_t _num_dependencies_length_ = 0 cdef bint _num_dependencies_is_set_ = False if from_ is not None: _num_dependencies_length_ = _cyb_check_same_length(_num_dependencies_is_set_, _num_dependencies_length_, _from__len_, "from_", "from_, to, edge_data") _num_dependencies_is_set_ = True if to is not None: _num_dependencies_length_ = _cyb_check_same_length(_num_dependencies_is_set_, _num_dependencies_length_, _to_len_, "to", "from_, to, edge_data") _num_dependencies_is_set_ = True if edge_data is not None: _num_dependencies_length_ = _cyb_check_same_length(_num_dependencies_is_set_, _num_dependencies_length_, _edge_data_len_, "edge_data", "from_, to, edge_data") _num_dependencies_is_set_ = True cdef size_t num_dependencies = _num_dependencies_length_ if num_dependencies != _num_dependencies_length_: raise OverflowError( f"The length of (from_, to, edge_data), {_num_dependencies_length_}, does not fit in 'numDependencies' (a size_t)" ) with nogil: __status__ = cudaGraphAddDependencies(graph, (_from__.data()), (_to_.data()), _edge_data_ptr_, num_dependencies) check_status(__status__) cpdef graph_remove_dependencies(intptr_t graph, from_, to, edge_data): """Removes dependency edges from a graph. The number of ``pDependencies`` to be removed is defined by ``len(from_)``. Elements in ``pFrom`` and ``pTo`` at corresponding indices define a dependency. Each node in ``pFrom`` and ``pTo`` must belong to ``graph``. If ``len(from_)`` is 0, elements in ``pFrom`` and ``pTo`` will be ignored. Specifying an edge that does not exist in the graph, with data matching ``edge_data``, results in an error. ``edge_data`` is nullable, which is equivalent to passing default (zeroed) data for each edge. Args: graph (intptr_t): Graph from which to remove dependencies. from_ (object): Array of nodes that provide the dependencies. It must be: - a Python sequence of :class:`int`\s (as pointer addresses), or - ``None`` for NULL. to (object): Array of dependent nodes. It must be: - a Python sequence of :class:`int`\s (as pointer addresses), or - ``None`` for NULL. edge_data (GraphEdgeData): Optional array of edge data. If NULL, edge data is assumed to be default (zeroed). It must be: - a :class:`GraphEdgeData`, or - ``None`` for NULL. .. seealso:: `cudaGraphRemoveDependencies` """ cdef _cyb_nullable_unique_ptr[ _cyb_vector[void*] ] _from__ if isinstance(from_, int): raise TypeError( "from_ must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _from__len_ = 0 _cyb_get_resource_ptrs[void](_from__, from_, NULL) if _from__.get() != NULL: _from__len_ = _from__.get().size() cdef _cyb_nullable_unique_ptr[ _cyb_vector[void*] ] _to_ if isinstance(to, int): raise TypeError( "to must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _to_len_ = 0 _cyb_get_resource_ptrs[void](_to_, to, NULL) if _to_.get() != NULL: _to_len_ = _to_.get().size() cdef intptr_t _edge_data_ptr_ = 0 cdef Py_ssize_t _edge_data_len_ = 0 if edge_data is None: pass else: (edge_data) _edge_data_ptr_ = int(edge_data) _edge_data_len_ = len(edge_data) cdef Py_ssize_t _num_dependencies_length_ = 0 cdef bint _num_dependencies_is_set_ = False if from_ is not None: _num_dependencies_length_ = _cyb_check_same_length(_num_dependencies_is_set_, _num_dependencies_length_, _from__len_, "from_", "from_, to, edge_data") _num_dependencies_is_set_ = True if to is not None: _num_dependencies_length_ = _cyb_check_same_length(_num_dependencies_is_set_, _num_dependencies_length_, _to_len_, "to", "from_, to, edge_data") _num_dependencies_is_set_ = True if edge_data is not None: _num_dependencies_length_ = _cyb_check_same_length(_num_dependencies_is_set_, _num_dependencies_length_, _edge_data_len_, "edge_data", "from_, to, edge_data") _num_dependencies_is_set_ = True cdef size_t num_dependencies = _num_dependencies_length_ if num_dependencies != _num_dependencies_length_: raise OverflowError( f"The length of (from_, to, edge_data), {_num_dependencies_length_}, does not fit in 'numDependencies' (a size_t)" ) with nogil: __status__ = cudaGraphRemoveDependencies(graph, (_from__.data()), (_to_.data()), _edge_data_ptr_, num_dependencies) check_status(__status__) cpdef graph_destroy_node(intptr_t node): """Remove a node from the graph. Removes ``node`` from its graph. This operation also severs any dependencies of other nodes on ``node`` and vice versa. Dependencies cannot be removed from graphs which contain allocation or free nodes. Any attempt to do so will return an error. Args: node (intptr_t): Node to remove. .. seealso:: `cudaGraphDestroyNode` """ with nogil: __status__ = cudaGraphDestroyNode(node) check_status(__status__) cpdef intptr_t graph_instantiate(intptr_t graph, unsigned long long flags) except? 0: """Creates an executable graph from a graph. Instantiates ``graph`` as an executable graph. The graph is validated for any structural constraints or intra-node constraints which were not previously validated. If instantiation is successful, a handle to the instantiated graph is returned in ``p_graph_exec``. The ``flags`` parameter controls the behavior of instantiation and subsequent graph launches. Valid flags are:. - ``cudaGraphInstantiateFlagAutoFreeOnLaunch``, which configures a graph containing memory allocation nodes to automatically free any unfreed memory allocations before the graph is relaunched. - ``cudaGraphInstantiateFlagDeviceLaunch``, which configures the graph for launch from the device. If this flag is passed, the executable graph handle returned can be used to launch the graph from both the host and device. This flag cannot be used in conjunction with ``cudaGraphInstantiateFlagAutoFreeOnLaunch``. - ``cudaGraphInstantiateFlagUseNodePriority``, which causes the graph to use the priorities from the per-node attributes rather than the priority of the launch stream during execution. Note that priorities are only available on kernel nodes, and are copied from stream priority during stream capture. If ``graph`` contains any allocation or free nodes, there can be at most one executable graph in existence for that graph at a time. An attempt to instantiate a second executable graph before destroying the first with ``cudaGraphExecDestroy`` will result in an error. The same also applies if ``graph`` contains any device-updatable kernel nodes. Graphs instantiated for launch on the device have additional restrictions which do not apply to host graphs:. - The graph's nodes must reside on a single device. - The graph can only contain kernel nodes, memcpy nodes, memset nodes, and child graph nodes. - The graph cannot be empty and must contain at least one kernel, memcpy, or memset node. Operation-specific restrictions are outlined below. - Kernel nodes:. - Use of CUDA Dynamic Parallelism is not permitted. - Cooperative launches are permitted as long as MPS is not in use. - Memcpy nodes:. - Only copies involving device memory and/or pinned device-mapped host memory are permitted. - Copies involving CUDA arrays are not permitted. - Both operands must be accessible from the current device, and the current device must match the device of other nodes in the graph. If ``graph`` is not instantiated for launch on the device but contains kernels which call device-side :func:`graph_launch` from multiple devices, this will result in an error. Args: graph (intptr_t): Graph to instantiate. flags (unsigned long long): Flags to control instantiation. See ``CUgraphInstantiate_flags``. Returns: intptr_t: Returns instantiated graph. .. seealso:: `cudaGraphInstantiate` """ cdef cudaGraphExec_t p_graph_exec with nogil: __status__ = cudaGraphInstantiate(&p_graph_exec, graph, flags) check_status(__status__) return p_graph_exec cpdef intptr_t graph_instantiate_with_flags(intptr_t graph, unsigned long long flags) except? 0: """Creates an executable graph from a graph. Instantiates ``graph`` as an executable graph. The graph is validated for any structural constraints or intra-node constraints which were not previously validated. If instantiation is successful, a handle to the instantiated graph is returned in ``p_graph_exec``. The ``flags`` parameter controls the behavior of instantiation and subsequent graph launches. Valid flags are:. - ``cudaGraphInstantiateFlagAutoFreeOnLaunch``, which configures a graph containing memory allocation nodes to automatically free any unfreed memory allocations before the graph is relaunched. - ``cudaGraphInstantiateFlagDeviceLaunch``, which configures the graph for launch from the device. If this flag is passed, the executable graph handle returned can be used to launch the graph from both the host and device. This flag can only be used on platforms which support unified addressing. This flag cannot be used in conjunction with ``cudaGraphInstantiateFlagAutoFreeOnLaunch``. - ``cudaGraphInstantiateFlagUseNodePriority``, which causes the graph to use the priorities from the per-node attributes rather than the priority of the launch stream during execution. Note that priorities are only available on kernel nodes, and are copied from stream priority during stream capture. If ``graph`` contains any allocation or free nodes, there can be at most one executable graph in existence for that graph at a time. An attempt to instantiate a second executable graph before destroying the first with ``cudaGraphExecDestroy`` will result in an error. The same also applies if ``graph`` contains any device-updatable kernel nodes. If ``graph`` contains kernels which call device-side :func:`graph_launch` from multiple devices, this will result in an error. Graphs instantiated for launch on the device have additional restrictions which do not apply to host graphs:. - The graph's nodes must reside on a single device. - The graph can only contain kernel nodes, memcpy nodes, memset nodes, and child graph nodes. - The graph cannot be empty and must contain at least one kernel, memcpy, or memset node. Operation-specific restrictions are outlined below. - Kernel nodes:. - Use of CUDA Dynamic Parallelism is not permitted. - Cooperative launches are permitted as long as MPS is not in use. - Memcpy nodes:. - Only copies involving device memory and/or pinned device-mapped host memory are permitted. - Copies involving CUDA arrays are not permitted. - Both operands must be accessible from the current device, and the current device must match the device of other nodes in the graph. Args: graph (intptr_t): Graph to instantiate. flags (unsigned long long): Flags to control instantiation. See ``CUgraphInstantiate_flags``. Returns: intptr_t: Returns instantiated graph. .. seealso:: `cudaGraphInstantiateWithFlags` """ cdef cudaGraphExec_t p_graph_exec with nogil: __status__ = cudaGraphInstantiateWithFlags(&p_graph_exec, graph, flags) check_status(__status__) return p_graph_exec cpdef intptr_t graph_instantiate_with_params(intptr_t graph, instantiate_params) except? 0: """Creates an executable graph from a graph. Instantiates ``graph`` as an executable graph according to the ``instantiate_params`` structure. The graph is validated for any structural constraints or intra-node constraints which were not previously validated. If instantiation is successful, a handle to the instantiated graph is returned in ``p_graph_exec``. ``instantiate_params`` controls the behavior of instantiation and subsequent graph launches, as well as returning more detailed information in the event of an error. ``cudaGraphInstantiateParams`` is defined as:. \*\*View CUDA Toolkit Documentation for a C++ code example*\*. The ``flags`` field controls the behavior of instantiation and subsequent graph launches. Valid flags are:. - ``cudaGraphInstantiateFlagAutoFreeOnLaunch``, which configures a graph containing memory allocation nodes to automatically free any unfreed memory allocations before the graph is relaunched. - ``cudaGraphInstantiateFlagUpload``, which will perform an upload of the graph into ``uploadStream`` once the graph has been instantiated. - ``cudaGraphInstantiateFlagDeviceLaunch``, which configures the graph for launch from the device. If this flag is passed, the executable graph handle returned can be used to launch the graph from both the host and device. This flag can only be used on platforms which support unified addressing. This flag cannot be used in conjunction with ``cudaGraphInstantiateFlagAutoFreeOnLaunch``. - ``cudaGraphInstantiateFlagUseNodePriority``, which causes the graph to use the priorities from the per-node attributes rather than the priority of the launch stream during execution. Note that priorities are only available on kernel nodes, and are copied from stream priority during stream capture. If ``graph`` contains any allocation or free nodes, there can be at most one executable graph in existence for that graph at a time. An attempt to instantiate a second executable graph before destroying the first with ``cudaGraphExecDestroy`` will result in an error. The same also applies if ``graph`` contains any device-updatable kernel nodes. If ``graph`` contains kernels which call device-side :func:`graph_launch` from multiple devices, this will result in an error. Graphs instantiated for launch on the device have additional restrictions which do not apply to host graphs:. - The graph's nodes must reside on a single device. - The graph can only contain kernel nodes, memcpy nodes, memset nodes, and child graph nodes. - The graph cannot be empty and must contain at least one kernel, memcpy, or memset node. Operation-specific restrictions are outlined below. - Kernel nodes:. - Use of CUDA Dynamic Parallelism is not permitted. - Cooperative launches are permitted as long as MPS is not in use. - Memcpy nodes:. - Only copies involving device memory and/or pinned device-mapped host memory are permitted. - Copies involving CUDA arrays are not permitted. - Both operands must be accessible from the current device, and the current device must match the device of other nodes in the graph. In the event of an error, the ``result_out`` and ``errNode_out`` fields will contain more information about the nature of the error. Possible error reporting includes:. - ``cudaGraphInstantiateError``, if passed an invalid value or if an unexpected error occurred which is described by the return value of the function. ``errNode_out`` will be set to NULL. - ``cudaGraphInstantiateInvalidStructure``, if the graph structure is invalid. ``errNode_out`` will be set to one of the offending nodes. - ``cudaGraphInstantiateNodeOperationNotSupported``, if the graph is instantiated for device launch but contains a node of an unsupported node type, or a node which performs unsupported operations, such as use of CUDA dynamic parallelism within a kernel node. ``errNode_out`` will be set to this node. - ``cudaGraphInstantiateMultipleDevicesNotSupported``, if the graph is instantiated for device launch but a node’s device differs from that of another node. This error can also be returned if a graph is not instantiated for device launch and it contains kernels which call device-side :func:`graph_launch` from multiple devices. ``errNode_out`` will be set to this node. If instantiation is successful, ``result_out`` will be set to ``cudaGraphInstantiateSuccess``, and ``hErrNode_out`` will be set to NULL. Args: graph (intptr_t): Graph to instantiate. instantiate_params (intptr_t): Instantiation parameters. Returns: intptr_t: Returns instantiated graph. .. seealso:: `cudaGraphInstantiateWithParams` """ cdef intptr_t _instantiate_params_ptr_ = 0 if instantiate_params is None else int(instantiate_params) cdef cudaGraphExec_t p_graph_exec with nogil: __status__ = cudaGraphInstantiateWithParams(&p_graph_exec, graph, _instantiate_params_ptr_) check_status(__status__) return p_graph_exec cpdef unsigned long long graph_exec_get_flags(intptr_t graph_exec) except? 0: """Query the instantiation flags of an executable graph. Returns the flags that were passed to instantiation for the given executable graph. ``cudaGraphInstantiateFlagUpload`` will not be returned by this API as it does not affect the resulting executable graph. Args: graph_exec (intptr_t): The executable graph to query. Returns: unsigned long long: Returns the instantiation flags. .. seealso:: `cudaGraphExecGetFlags` """ cdef unsigned long long flags with nogil: __status__ = cudaGraphExecGetFlags(graph_exec, &flags) check_status(__status__) return flags cpdef graph_exec_kernel_node_set_params(intptr_t h_graph_exec, intptr_t node, p_node_params): """Sets the parameters for a kernel node in the given graphExec. Sets the parameters of a kernel node in an executable graph ``h_graph_exec``. The node is identified by the corresponding node ``node`` in the non-executable graph, from which the executable graph was instantiated. ``node`` must not have been removed from the original graph. All ``nodeParams`` fields may change, but the following restrictions apply to ``func`` updates:. - The owning device of the function cannot change. - A node whose function originally did not use CUDA dynamic parallelism cannot be updated to a function which uses CDP. - A node whose function originally did not make device-side update calls cannot be updated to a function which makes device-side update calls. - If ``h_graph_exec`` was not instantiated for device launch, a node whose function originally did not use device-side :func:`graph_launch` cannot be updated to a function which uses device-side :func:`graph_launch` unless the node resides on the same device as nodes which contained such calls at instantiate-time. If no such calls were present at instantiation, these updates cannot be performed at all. The modifications only affect future launches of ``h_graph_exec``. Already enqueued or running launches of ``h_graph_exec`` are not affected by this call. ``node`` is also not modified by this call. If ``node`` is a device-updatable kernel node, the next upload/launch of ``h_graph_exec`` will overwrite any previous device-side updates. Additionally, applying host updates to a device-updatable kernel node while it is being updated from the device will result in undefined behavior. Args: h_graph_exec (intptr_t): The executable graph in which to set the specified node. node (intptr_t): kernel node from the graph from which graphExec was instantiated. p_node_params (intptr_t): Updated Parameters to set. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphExecNodeSetParams``. .. seealso:: `cudaGraphExecKernelNodeSetParams` """ cdef intptr_t _p_node_params_ptr_ = 0 if p_node_params is None else int(p_node_params) with nogil: __status__ = cudaGraphExecKernelNodeSetParams(h_graph_exec, node, _p_node_params_ptr_) check_status(__status__) cpdef graph_exec_memcpy_node_set_params(intptr_t h_graph_exec, intptr_t node, p_node_params): """Sets the parameters for a memcpy node in the given graphExec. Updates the work represented by ``node`` in ``h_graph_exec`` as though ``node`` had contained ``p_node_params`` at instantiation. ``node`` must remain in the graph which was used to instantiate ``h_graph_exec``. Changed edges to and from ``node`` are ignored. The source and destination memory in ``p_node_params`` must be allocated from the same contexts as the original source and destination memory. Both the instantiation-time memory operands and the memory operands in ``p_node_params`` must be 1-dimensional. Zero-length operations are not supported. The modifications only affect future launches of ``h_graph_exec``. Already enqueued or running launches of ``h_graph_exec`` are not affected by this call. ``node`` is also not modified by this call. Returns ``cudaErrorInvalidValue`` if the memory operands' mappings changed or either the original or new memory operands are multidimensional. Args: h_graph_exec (intptr_t): The executable graph in which to set the specified node. node (intptr_t): Memcpy node from the graph which was used to instantiate graphExec. p_node_params (intptr_t): Updated Parameters to set. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphExecNodeSetParams``. .. seealso:: `cudaGraphExecMemcpyNodeSetParams` """ cdef intptr_t _p_node_params_ptr_ = 0 if p_node_params is None else int(p_node_params) with nogil: __status__ = cudaGraphExecMemcpyNodeSetParams(h_graph_exec, node, _p_node_params_ptr_) check_status(__status__) cpdef graph_exec_memcpy_node_set_params_1d(intptr_t h_graph_exec, intptr_t node, dst, src, size_t count, int kind): """Sets the parameters for a memcpy node in the given graphExec to perform a 1-dimensional copy. Updates the work represented by ``node`` in ``h_graph_exec`` as though ``node`` had contained the given params at instantiation. ``node`` must remain in the graph which was used to instantiate ``h_graph_exec``. Changed edges to and from ``node`` are ignored. ``src`` and ``dst`` must be allocated from the same contexts as the original source and destination memory. The instantiation-time memory operands must be 1-dimensional. Zero-length operations are not supported. The modifications only affect future launches of ``h_graph_exec``. Already enqueued or running launches of ``h_graph_exec`` are not affected by this call. ``node`` is also not modified by this call. Returns ``cudaErrorInvalidValue`` if the memory operands' mappings changed or the original memory operands are multidimensional. Args: h_graph_exec (intptr_t): The executable graph in which to set the specified node. node (intptr_t): Memcpy node from the graph which was used to instantiate graphExec. dst (bytes): Destination memory address. src (bytes): Source memory address. count (size_t): Size in bytes to copy. kind (MemCpyKind): Type of transfer. .. seealso:: `cudaGraphExecMemcpyNodeSetParams1D` """ cdef _cyb_BufferGuard _dst_guard_ = _cyb_BufferGuard(dst, 0, False, False, True) cdef void* _dst_ = _dst_guard_.ptr cdef _cyb_BufferGuard _src_guard_ = _cyb_BufferGuard(src, 0, False, True, True) cdef void* _src_ = _src_guard_.ptr with nogil: __status__ = cudaGraphExecMemcpyNodeSetParams1D(h_graph_exec, node, _dst_, _src_, count, kind) check_status(__status__) cpdef graph_exec_memset_node_set_params(intptr_t h_graph_exec, intptr_t node, p_node_params): """Sets the parameters for a memset node in the given graphExec. Updates the work represented by ``node`` in ``h_graph_exec`` as though ``node`` had contained ``p_node_params`` at instantiation. ``node`` must remain in the graph which was used to instantiate ``h_graph_exec``. Changed edges to and from ``node`` are ignored. Zero sized operations are not supported. The new destination pointer in ``p_node_params`` must be to the same kind of allocation as the original destination pointer and have the same context association and device mapping as the original destination pointer. Both the value and pointer address may be updated. Changing other aspects of the memset (width, height, element size or pitch) may cause the update to be rejected. Specifically, for 2d memsets, all dimension changes are rejected. For 1d memsets, changes in height are explicitly rejected and other changes are opportunistically allowed if the resulting work maps onto the work resources already allocated for the node. The modifications only affect future launches of ``h_graph_exec``. Already enqueued or running launches of ``h_graph_exec`` are not affected by this call. ``node`` is also not modified by this call. Args: h_graph_exec (intptr_t): The executable graph in which to set the specified node. node (intptr_t): Memset node from the graph which was used to instantiate graphExec. p_node_params (intptr_t): Updated Parameters to set. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphExecNodeSetParams``. .. seealso:: `cudaGraphExecMemsetNodeSetParams` """ cdef intptr_t _p_node_params_ptr_ = 0 if p_node_params is None else int(p_node_params) with nogil: __status__ = cudaGraphExecMemsetNodeSetParams(h_graph_exec, node, _p_node_params_ptr_) check_status(__status__) cpdef graph_exec_host_node_set_params(intptr_t h_graph_exec, intptr_t node, p_node_params): """Sets the parameters for a host node in the given graphExec. Updates the work represented by ``node`` in ``h_graph_exec`` as though ``node`` had contained ``p_node_params`` at instantiation. ``node`` must remain in the graph which was used to instantiate ``h_graph_exec``. Changed edges to and from ``node`` are ignored. The modifications only affect future launches of ``h_graph_exec``. Already enqueued or running launches of ``h_graph_exec`` are not affected by this call. ``node`` is also not modified by this call. Args: h_graph_exec (intptr_t): The executable graph in which to set the specified node. node (intptr_t): Host node from the graph which was used to instantiate graphExec. p_node_params (intptr_t): Updated Parameters to set. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphExecNodeSetParams``. .. seealso:: `cudaGraphExecHostNodeSetParams` """ cdef intptr_t _p_node_params_ptr_ = 0 if p_node_params is None else int(p_node_params) with nogil: __status__ = cudaGraphExecHostNodeSetParams(h_graph_exec, node, _p_node_params_ptr_) check_status(__status__) cpdef graph_exec_child_graph_node_set_params(intptr_t h_graph_exec, intptr_t node, intptr_t child_graph): """Updates node parameters in the child graph node in the given graphExec. Updates the work represented by ``node`` in ``h_graph_exec`` as though the nodes contained in ``node's`` graph had the parameters contained in ``child_graph's`` nodes at instantiation. ``node`` must remain in the graph which was used to instantiate ``h_graph_exec``. Changed edges to and from ``node`` are ignored. The modifications only affect future launches of ``h_graph_exec``. Already enqueued or running launches of ``h_graph_exec`` are not affected by this call. ``node`` is also not modified by this call. The topology of ``child_graph``, as well as the node insertion order, must match that of the graph contained in ``node``. See :func:`graph_exec_update` for a list of restrictions on what can be updated in an instantiated graph. The update is recursive, so child graph nodes contained within the top level child graph will also be updated. Args: h_graph_exec (intptr_t): The executable graph in which to set the specified node. node (intptr_t): Host node from the graph which was used to instantiate graphExec. child_graph (intptr_t): The graph supplying the updated parameters. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphExecNodeSetParams``. .. seealso:: `cudaGraphExecChildGraphNodeSetParams` """ with nogil: __status__ = cudaGraphExecChildGraphNodeSetParams(h_graph_exec, node, child_graph) check_status(__status__) cpdef graph_exec_event_record_node_set_event(intptr_t h_graph_exec, intptr_t h_node, intptr_t event): """Sets the event for an event record node in the given graphExec. Sets the event of an event record node in an executable graph ``h_graph_exec``. The node is identified by the corresponding node ``h_node`` in the non-executable graph, from which the executable graph was instantiated. The modifications only affect future launches of ``h_graph_exec``. Already enqueued or running launches of ``h_graph_exec`` are not affected by this call. ``h_node`` is also not modified by this call. Args: h_graph_exec (intptr_t): The executable graph in which to set the specified node. h_node (intptr_t): Event record node from the graph from which graphExec was instantiated. event (intptr_t): Updated event to use. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphExecNodeSetParams``. .. seealso:: `cudaGraphExecEventRecordNodeSetEvent` """ with nogil: __status__ = cudaGraphExecEventRecordNodeSetEvent(h_graph_exec, h_node, event) check_status(__status__) cpdef graph_exec_event_wait_node_set_event(intptr_t h_graph_exec, intptr_t h_node, intptr_t event): """Sets the event for an event wait node in the given graphExec. Sets the event of an event wait node in an executable graph ``h_graph_exec``. The node is identified by the corresponding node ``h_node`` in the non-executable graph, from which the executable graph was instantiated. The modifications only affect future launches of ``h_graph_exec``. Already enqueued or running launches of ``h_graph_exec`` are not affected by this call. ``h_node`` is also not modified by this call. Args: h_graph_exec (intptr_t): The executable graph in which to set the specified node. h_node (intptr_t): Event wait node from the graph from which graphExec was instantiated. event (intptr_t): Updated event to use. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphExecNodeSetParams``. .. seealso:: `cudaGraphExecEventWaitNodeSetEvent` """ with nogil: __status__ = cudaGraphExecEventWaitNodeSetEvent(h_graph_exec, h_node, event) check_status(__status__) cpdef graph_exec_external_semaphores_signal_node_set_params(intptr_t h_graph_exec, intptr_t h_node, node_params): """Sets the parameters for an external semaphore signal node in the given graphExec. Sets the parameters of an external semaphore signal node in an executable graph ``h_graph_exec``. The node is identified by the corresponding node ``h_node`` in the non-executable graph, from which the executable graph was instantiated. ``h_node`` must not have been removed from the original graph. The modifications only affect future launches of ``h_graph_exec``. Already enqueued or running launches of ``h_graph_exec`` are not affected by this call. ``h_node`` is also not modified by this call. Changing ``node_params->numExtSems`` is not supported. Args: h_graph_exec (intptr_t): The executable graph in which to set the specified node. h_node (intptr_t): semaphore signal node from the graph from which graphExec was instantiated. node_params (intptr_t): Updated Parameters to set. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphExecNodeSetParams``. .. seealso:: `cudaGraphExecExternalSemaphoresSignalNodeSetParams` """ cdef intptr_t _node_params_ptr_ = 0 if node_params is None else int(node_params) with nogil: __status__ = cudaGraphExecExternalSemaphoresSignalNodeSetParams(h_graph_exec, h_node, _node_params_ptr_) check_status(__status__) cpdef graph_exec_external_semaphores_wait_node_set_params(intptr_t h_graph_exec, intptr_t h_node, node_params): """Sets the parameters for an external semaphore wait node in the given graphExec. Sets the parameters of an external semaphore wait node in an executable graph ``h_graph_exec``. The node is identified by the corresponding node ``h_node`` in the non-executable graph, from which the executable graph was instantiated. ``h_node`` must not have been removed from the original graph. The modifications only affect future launches of ``h_graph_exec``. Already enqueued or running launches of ``h_graph_exec`` are not affected by this call. ``h_node`` is also not modified by this call. Changing ``node_params->numExtSems`` is not supported. Args: h_graph_exec (intptr_t): The executable graph in which to set the specified node. h_node (intptr_t): semaphore wait node from the graph from which graphExec was instantiated. node_params (intptr_t): Updated Parameters to set. .. note:: This function will be deprecated in a future CUDA release. Please migrate to ``cudaGraphExecNodeSetParams``. .. seealso:: `cudaGraphExecExternalSemaphoresWaitNodeSetParams` """ cdef intptr_t _node_params_ptr_ = 0 if node_params is None else int(node_params) with nogil: __status__ = cudaGraphExecExternalSemaphoresWaitNodeSetParams(h_graph_exec, h_node, _node_params_ptr_) check_status(__status__) cpdef graph_node_set_enabled(intptr_t h_graph_exec, intptr_t h_node, unsigned int is_enabled): """Enables or disables the specified node in the given graphExec. Sets ``h_node`` to be either enabled or disabled. Disabled nodes are functionally equivalent to empty nodes until they are reenabled. Existing node parameters are not affected by disabling/enabling the node. The node is identified by the corresponding node ``h_node`` in the non-executable graph, from which the executable graph was instantiated. ``h_node`` must not have been removed from the original graph. The modifications only affect future launches of ``h_graph_exec``. Already enqueued or running launches of ``h_graph_exec`` are not affected by this call. ``h_node`` is also not modified by this call. Args: h_graph_exec (intptr_t): The executable graph in which to set the specified node. h_node (intptr_t): Node from the graph from which graphExec was instantiated. is_enabled (unsigned int): Node is enabled if != 0, otherwise the node is disabled. .. note:: Currently only kernel, memset and memcpy nodes are supported. .. seealso:: `cudaGraphNodeSetEnabled` """ with nogil: __status__ = cudaGraphNodeSetEnabled(h_graph_exec, h_node, is_enabled) check_status(__status__) cpdef unsigned int graph_node_get_enabled(intptr_t h_graph_exec, intptr_t h_node) except? 0: """Query whether a node in the given graphExec is enabled. Sets is_enabled to 1 if ``h_node`` is enabled, or 0 if ``h_node`` is disabled. The node is identified by the corresponding node ``h_node`` in the non-executable graph, from which the executable graph was instantiated. ``h_node`` must not have been removed from the original graph. Args: h_graph_exec (intptr_t): The executable graph in which to set the specified node. h_node (intptr_t): Node from the graph from which graphExec was instantiated. Returns: unsigned int: Location to return the enabled status of the node. .. note:: Currently only kernel, memset and memcpy nodes are supported. .. seealso:: `cudaGraphNodeGetEnabled` """ cdef unsigned int is_enabled with nogil: __status__ = cudaGraphNodeGetEnabled(h_graph_exec, h_node, &is_enabled) check_status(__status__) return is_enabled cpdef graph_upload(intptr_t graph_exec, intptr_t stream): """Uploads an executable graph in a stream. Uploads ``graph_exec`` to the device in ``stream`` without executing it. Uploads of the same ``graph_exec`` will be serialized. Each upload is ordered behind both any previous work in ``stream`` and any previous launches of ``graph_exec``. Uses memory cached by ``stream`` to back the allocations owned by ``graph_exec``. Args: graph_exec (intptr_t): Executable graph to upload. stream (intptr_t): Stream in which to upload the graph. .. seealso:: `cudaGraphUpload` """ with nogil: __status__ = cudaGraphUpload(graph_exec, stream) check_status(__status__) cpdef graph_launch(intptr_t graph_exec, intptr_t stream): """Launches an executable graph in a stream. Executes ``graph_exec`` in ``stream``. Only one instance of ``graph_exec`` may be executing at a time. Each launch is ordered behind both any previous work in ``stream`` and any previous launches of ``graph_exec``. To execute a graph concurrently, it must be instantiated multiple times into multiple executable graphs. If any allocations created by ``graph_exec`` remain unfreed (from a previous launch) and ``graph_exec`` was not instantiated with ``cudaGraphInstantiateFlagAutoFreeOnLaunch``, the launch will fail with ``cudaErrorInvalidValue``. Args: graph_exec (intptr_t): Executable graph to launch. stream (intptr_t): Stream in which to launch the graph. .. seealso:: `cudaGraphLaunch` """ with nogil: __status__ = cudaGraphLaunch(graph_exec, stream) check_status(__status__) cpdef graph_exec_destroy(intptr_t graph_exec): """Destroys an executable graph. Destroys the executable graph specified by ``graph_exec``. Args: graph_exec (intptr_t): Executable graph to destroy. .. seealso:: `cudaGraphExecDestroy` """ with nogil: __status__ = cudaGraphExecDestroy(graph_exec) check_status(__status__) cpdef graph_destroy(intptr_t graph): """Destroys a graph. Destroys the graph specified by ``graph``, as well as all of its nodes. Args: graph (intptr_t): Graph to destroy. .. seealso:: `cudaGraphDestroy` """ with nogil: __status__ = cudaGraphDestroy(graph) check_status(__status__) cpdef graph_debug_dot_print(intptr_t graph, path, unsigned int flags): """Write a DOT file describing graph structure. Using the provided ``graph``, write to ``path`` a DOT formatted description of the graph. By default this includes the graph topology, node types, node id, kernel names and memcpy direction. ``flags`` can be specified to write more detailed information about each node type such as parameter values, kernel attributes, node and function handles. Args: graph (intptr_t): The graph to create a DOT file from. path (bytes): The path to write the DOT file to. flags (unsigned int): Flags from ``cudaGraphDebugDotFlags`` for specifying which additional node information to write. .. seealso:: `cudaGraphDebugDotPrint` """ cdef _cyb_BufferGuard _path_guard_ = _cyb_BufferGuard(path, 0, False, True, True) cdef void* _path_ = _path_guard_.ptr with nogil: __status__ = cudaGraphDebugDotPrint(graph, _path_, flags) check_status(__status__) cpdef intptr_t user_object_create(ptr, intptr_t destroy, unsigned int initial_refcount, unsigned int flags) except? 0: """Create a user object. Create a user object with the specified destructor callback and initial reference count. The initial references are owned by the caller. Destructor callbacks cannot make CUDA API calls and should avoid blocking behavior, as they are executed by a shared internal thread. Another thread may be signaled to perform such actions, if it does not block forward progress of tasks scheduled through CUDA. See CUDA User Objects in the CUDA C++ Programming Guide for more information on user objects. Args: ptr (bytes): The pointer to pass to the destroy function. destroy (intptr_t): Callback to free the user object when it is no longer in use. initial_refcount (unsigned int): The initial refcount to create the object with, typically 1. The initial references are owned by the calling thread. flags (unsigned int): Currently it is required to pass ``cudaUserObjectNoDestructorSync``, which is the only defined flag. This indicates that the destroy callback cannot be waited on by any CUDA API. Users requiring synchronization of the callback should signal its completion manually. Returns: intptr_t: Location to return the user object handle. .. seealso:: `cudaUserObjectCreate` """ cdef _cyb_BufferGuard _ptr_guard_ = _cyb_BufferGuard(ptr, 0, False, False, True) cdef void* _ptr_ = _ptr_guard_.ptr cdef cudaUserObject_t object_out with nogil: __status__ = cudaUserObjectCreate(&object_out, _ptr_, destroy, initial_refcount, flags) check_status(__status__) return object_out cpdef user_object_retain(intptr_t object, unsigned int count): """Retain a reference to a user object. Retains new references to a user object. The new references are owned by the caller. See CUDA User Objects in the CUDA C++ Programming Guide for more information on user objects. Args: object (intptr_t): The object to retain. count (unsigned int): The number of references to retain, typically 1. Must be nonzero and not larger than INT_MAX. .. seealso:: `cudaUserObjectRetain` """ with nogil: __status__ = cudaUserObjectRetain(object, count) check_status(__status__) cpdef user_object_release(intptr_t object, unsigned int count): """Release a reference to a user object. Releases user object references owned by the caller. The object's destructor is invoked if the reference count reaches zero. It is undefined behavior to release references not owned by the caller, or to use a user object handle after all references are released. See CUDA User Objects in the CUDA C++ Programming Guide for more information on user objects. Args: object (intptr_t): The object to release. count (unsigned int): The number of references to release, typically 1. Must be nonzero and not larger than INT_MAX. .. seealso:: `cudaUserObjectRelease` """ with nogil: __status__ = cudaUserObjectRelease(object, count) check_status(__status__) cpdef graph_retain_user_object(intptr_t graph, intptr_t object, unsigned int count, unsigned int flags): """Retain a reference to a user object from a graph. Creates or moves user object references that will be owned by a CUDA graph. See CUDA User Objects in the CUDA C++ Programming Guide for more information on user objects. Args: graph (intptr_t): The graph to associate the reference with. object (intptr_t): The user object to retain a reference for. count (unsigned int): The number of references to add to the graph, typically 1. Must be nonzero and not larger than INT_MAX. flags (unsigned int): The optional flag ``cudaGraphUserObjectMove`` transfers references from the calling thread, rather than create new references. Pass 0 to create new references. .. seealso:: `cudaGraphRetainUserObject` """ with nogil: __status__ = cudaGraphRetainUserObject(graph, object, count, flags) check_status(__status__) cpdef graph_release_user_object(intptr_t graph, intptr_t object, unsigned int count): """Release a user object reference from a graph. Releases user object references owned by a graph. See CUDA User Objects in the CUDA C++ Programming Guide for more information on user objects. Args: graph (intptr_t): The graph that will release the reference. object (intptr_t): The user object to release a reference for. count (unsigned int): The number of references to release, typically 1. Must be nonzero and not larger than INT_MAX. .. seealso:: `cudaGraphReleaseUserObject` """ with nogil: __status__ = cudaGraphReleaseUserObject(graph, object, count) check_status(__status__) cpdef intptr_t graph_add_node(intptr_t graph, p_dependencies, dependency_data, node_params) except? 0: """Adds a node of arbitrary type to a graph. Creates a new node in ``graph`` described by ``node_params`` with ``len(p_dependencies)`` dependencies specified via ``p_dependencies``. ``len(p_dependencies)`` may be 0. ``p_dependencies`` may be null if ``len(p_dependencies)`` is 0. ``p_dependencies`` may not have any duplicate entries. ``node_params`` is a tagged union. The node type should be specified in the ``typename`` field, and type-specific parameters in the corresponding union member. All unused bytes - that is, ``reserved0`` and all bytes past the utilized union member - must be set to zero. It is recommended to use brace initialization or memset to ensure all bytes are initialized. Note that for some node types, ``node_params`` may contain "out parameters" which are modified during the call, such as ``node_params->alloc.dptr``. A handle to the new node will be returned in ``phGraphNode``. Args: graph (intptr_t): Graph to which to add the node. p_dependencies (object): Dependencies of the node. It must be: - a Python sequence of :class:`int`\s (as pointer addresses), or - ``None`` for NULL. dependency_data (GraphEdgeData): Optional edge data for the dependencies. If NULL, the data is assumed to be default (zeroed) for all dependencies. It must be: - a :class:`GraphEdgeData`, or - ``None`` for NULL. node_params (intptr_t): Specification of the node. Returns: intptr_t: Returns newly created node. .. seealso:: `cudaGraphAddNode` """ cdef _cyb_nullable_unique_ptr[ _cyb_vector[void*] ] _p_dependencies_ if isinstance(p_dependencies, int): raise TypeError( "p_dependencies must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _p_dependencies_len_ = 0 _cyb_get_resource_ptrs[void](_p_dependencies_, p_dependencies, NULL) if _p_dependencies_.get() != NULL: _p_dependencies_len_ = _p_dependencies_.get().size() cdef intptr_t _dependency_data_ptr_ = 0 cdef Py_ssize_t _dependency_data_len_ = 0 if dependency_data is None: pass else: (dependency_data) _dependency_data_ptr_ = int(dependency_data) _dependency_data_len_ = len(dependency_data) cdef intptr_t _node_params_ptr_ = 0 if node_params is None else int(node_params) cdef Py_ssize_t _num_dependencies_length_ = 0 cdef bint _num_dependencies_is_set_ = False if p_dependencies is not None: _num_dependencies_length_ = _cyb_check_same_length(_num_dependencies_is_set_, _num_dependencies_length_, _p_dependencies_len_, "p_dependencies", "p_dependencies, dependency_data") _num_dependencies_is_set_ = True if dependency_data is not None: _num_dependencies_length_ = _cyb_check_same_length(_num_dependencies_is_set_, _num_dependencies_length_, _dependency_data_len_, "dependency_data", "p_dependencies, dependency_data") _num_dependencies_is_set_ = True cdef size_t num_dependencies = _num_dependencies_length_ if num_dependencies != _num_dependencies_length_: raise OverflowError( f"The length of (p_dependencies, dependency_data), {_num_dependencies_length_}, does not fit in 'numDependencies' (a size_t)" ) cdef cudaGraphNode_t p_graph_node with nogil: __status__ = cudaGraphAddNode(&p_graph_node, graph, (_p_dependencies_.data()), _dependency_data_ptr_, num_dependencies, _node_params_ptr_) check_status(__status__) return p_graph_node cpdef graph_node_set_params(intptr_t node, node_params): """Update a graph node's parameters. Sets the parameters of graph node ``node`` to ``node_params``. The node type specified by ``node_params->type`` must match the type of ``node``. ``node_params`` must be fully initialized and all unused bytes (reserved, padding) zeroed. Modifying parameters is not supported for node types cudaGraphNodeTypeMemAlloc and cudaGraphNodeTypeMemFree. Args: node (intptr_t): Node to set the parameters for. node_params (intptr_t): Parameters to copy. .. seealso:: `cudaGraphNodeSetParams` """ cdef intptr_t _node_params_ptr_ = 0 if node_params is None else int(node_params) with nogil: __status__ = cudaGraphNodeSetParams(node, _node_params_ptr_) check_status(__status__) cpdef graph_exec_node_set_params(intptr_t graph_exec, intptr_t node, node_params): """Update a graph node's parameters in an instantiated graph. Sets the parameters of a node in an executable graph ``graph_exec``. The node is identified by the corresponding node ``node`` in the non-executable graph from which the executable graph was instantiated. ``node`` must not have been removed from the original graph. The modifications only affect future launches of ``graph_exec``. Already enqueued or running launches of ``graph_exec`` are not affected by this call. ``node`` is also not modified by this call. Allowed changes to parameters on executable graphs are as follows:. \*\*View CUDA Toolkit Documentation for a table example*\*. Args: graph_exec (intptr_t): The executable graph in which to update the specified node. node (intptr_t): Corresponding node from the graph from which graph_exec was instantiated. node_params (intptr_t): Updated Parameters to set. .. seealso:: `cudaGraphExecNodeSetParams` """ cdef intptr_t _node_params_ptr_ = 0 if node_params is None else int(node_params) with nogil: __status__ = cudaGraphExecNodeSetParams(graph_exec, node, _node_params_ptr_) check_status(__status__) cpdef unsigned long long graph_conditional_handle_create(intptr_t graph, unsigned int default_launch_value, unsigned int flags) except? 0: """Create a conditional handle. Creates a conditional handle associated with ``hGraph``. The conditional handle must be associated with a conditional node in this graph or one of its children. Handles not associated with a conditional node may cause graph instantiation to fail. Args: graph (intptr_t): Graph which will contain the conditional node using this handle. default_launch_value (unsigned int): Optional initial value for the conditional variable. Applied at the beginning of each graph execution if cudaGraphCondAssignDefault is set in ``flags``. flags (unsigned int): Currently must be cudaGraphCondAssignDefault or 0. Returns: unsigned long long: Pointer used to return the handle to the caller. .. seealso:: `cudaGraphConditionalHandleCreate` """ cdef cudaGraphConditionalHandle p_handle_out with nogil: __status__ = cudaGraphConditionalHandleCreate(&p_handle_out, graph, default_launch_value, flags) check_status(__status__) return p_handle_out cpdef tuple get_driver_entry_point(symbol, unsigned long long flags): """Returns the requested driver API function pointer. [Deprecated]. Returns in ``**func_ptr`` the address of the CUDA driver function for the requested flags. For a requested driver symbol, if the CUDA version in which the driver symbol was introduced is less than or equal to the CUDA runtime version, the API will return the function pointer to the corresponding versioned driver function. The pointer returned by the API should be cast to a function pointer matching the requested driver function's definition in the API header file. The function pointer typedef can be picked up from the corresponding typedefs header file. For example, cudaTypedefs.h consists of function pointer typedefs for driver APIs defined in cuda.h. The API will return ``cudaSuccess`` and set the returned ``func_ptr`` if the requested driver function is valid and supported on the platform. The API will return ``cudaSuccess`` and set the returned ``func_ptr`` to NULL if the requested driver function is not supported on the platform, no ABI compatible driver function exists for the CUDA runtime version or if the driver symbol is invalid. It will also set the optional ``driver_status`` to one of the values in ``cudaDriverEntryPointQueryResult`` with the following meanings:. - ``cudaDriverEntryPointSuccess`` - The requested symbol was succesfully found based on input arguments and ``pfn`` is valid. - ``cudaDriverEntryPointSymbolNotFound`` - The requested symbol was not found. - ``cudaDriverEntryPointVersionNotSufficent`` - The requested symbol was found but is not supported by the current runtime version (CUDART_VERSION). The requested flags can be:. - ``cudaEnableDefault``: This is the default mode. This is equivalent to ``cudaEnablePerThreadDefaultStream`` if the code is compiled with --default-stream per-thread compilation flag or the macro CUDA_API_PER_THREAD_DEFAULT_STREAM is defined; ``cudaEnableLegacyStream`` otherwise. - ``cudaEnableLegacyStream``: This will enable the search for all driver symbols that match the requested driver symbol name except the corresponding per-thread versions. - ``cudaEnablePerThreadDefaultStream``: This will enable the search for all driver symbols that match the requested driver symbol name including the per-thread versions. If a per-thread version is not found, the API will return the legacy version of the driver function. Args: symbol (bytes): The base name of the driver API function to look for. As an example, for the driver API ``cuMemAlloc_v2``, ``symbol`` would be cuMemAlloc. Note that the API will use the CUDA runtime version to return the address to the most recent ABI compatible driver symbol, ``cuMemAlloc`` or ``cuMemAlloc_v2``. flags (unsigned long long): Flags to specify search options. Returns: A 2-tuple containing: - intptr_t: Location to return the function pointer to the requested driver function. - int: Optional location to store the status of finding the symbol from the driver. See ``cudaDriverEntryPointQueryResult`` for possible values. .. note:: This API is deprecated and ``cudaGetDriverEntryPointByVersion`` (with a hardcoded ``cudaVersion``) should be used instead. .. seealso:: `cudaGetDriverEntryPoint` """ cdef _cyb_BufferGuard _symbol_guard_ = _cyb_BufferGuard(symbol, 0, False, True, True) cdef void* _symbol_ = _symbol_guard_.ptr cdef void* func_ptr cdef cudaDriverEntryPointQueryResult driver_status with nogil: __status__ = cudaGetDriverEntryPoint(_symbol_, &func_ptr, flags, &driver_status) check_status(__status__) return (func_ptr, driver_status) cpdef tuple get_driver_entry_point_by_version(symbol, unsigned int cuda_version, unsigned long long flags): """Returns the requested driver API function pointer by CUDA version. Returns in ``**func_ptr`` the address of the CUDA driver function for the requested flags and CUDA driver version. The CUDA version is specified as (1000 \* major + 10 \* minor), so CUDA 11.2 should be specified as 11020. For a requested driver symbol, if the specified CUDA version is greater than or equal to the CUDA version in which the driver symbol was introduced, this API will return the function pointer to the corresponding versioned function. If the specified CUDA version is greater than the driver version, the API will return ``cudaErrorInvalidValue``. The pointer returned by the API should be cast to a function pointer matching the requested driver function's definition in the API header file. The function pointer typedef can be picked up from the corresponding typedefs header file. For example, cudaTypedefs.h consists of function pointer typedefs for driver APIs defined in cuda.h. For the case where the CUDA version requested is greater than the CUDA Toolkit installed, there may not be an appropriate function pointer typedef in the corresponding header file and may need a custom typedef to match the driver function signature returned. This can be done by getting the typedefs from a later toolkit or creating appropriately matching custom function typedefs. The API will return ``cudaSuccess`` and set the returned ``func_ptr`` if the requested driver function is valid and supported on the platform. The API will return ``cudaSuccess`` and set the returned ``func_ptr`` to NULL if the requested driver function is not supported on the platform, no ABI compatible driver function exists for the requested version or if the driver symbol is invalid. It will also set the optional ``driver_status`` to one of the values in ``cudaDriverEntryPointQueryResult`` with the following meanings:. - ``cudaDriverEntryPointSuccess`` - The requested symbol was succesfully found based on input arguments and ``pfn`` is valid. - ``cudaDriverEntryPointSymbolNotFound`` - The requested symbol was not found. - ``cudaDriverEntryPointVersionNotSufficent`` - The requested symbol was found but is not supported by the specified version ``cuda_version``. The requested flags can be:. - ``cudaEnableDefault``: This is the default mode. This is equivalent to ``cudaEnablePerThreadDefaultStream`` if the code is compiled with --default-stream per-thread compilation flag or the macro CUDA_API_PER_THREAD_DEFAULT_STREAM is defined; ``cudaEnableLegacyStream`` otherwise. - ``cudaEnableLegacyStream``: This will enable the search for all driver symbols that match the requested driver symbol name except the corresponding per-thread versions. - ``cudaEnablePerThreadDefaultStream``: This will enable the search for all driver symbols that match the requested driver symbol name including the per-thread versions. If a per-thread version is not found, the API will return the legacy version of the driver function. Args: symbol (bytes): The base name of the driver API function to look for. As an example, for the driver API ``cuMemAlloc_v2``, ``symbol`` would be cuMemAlloc. cuda_version (unsigned int): The CUDA version to look for the requested driver symbol. flags (unsigned long long): Flags to specify search options. Returns: A 2-tuple containing: - intptr_t: Location to return the function pointer to the requested driver function. - int: Optional location to store the status of finding the symbol from the driver. See ``cudaDriverEntryPointQueryResult`` for possible values. .. seealso:: `cudaGetDriverEntryPointByVersion` """ cdef _cyb_BufferGuard _symbol_guard_ = _cyb_BufferGuard(symbol, 0, False, True, True) cdef void* _symbol_ = _symbol_guard_.ptr cdef void* func_ptr cdef cudaDriverEntryPointQueryResult driver_status with nogil: __status__ = cudaGetDriverEntryPointByVersion(_symbol_, &func_ptr, cuda_version, flags, &driver_status) check_status(__status__) return (func_ptr, driver_status) cpdef intptr_t library_load_data(code, intptr_t jit_options, intptr_t jit_options_values, unsigned int num_jit_options, intptr_t library_options, intptr_t library_option_values, unsigned int num_library_options) except? 0: """Load a library with specified code and options. Takes a pointer ``code`` and loads the corresponding library ``library`` based on the application defined library loading mode:. - If module loading is set to EAGER, via the environment variables described in "Module loading", ``library`` is loaded eagerly into all contexts at the time of the call and future contexts at the time of creation until the library is unloaded with :func:`library_unload`. - If the environment variables are set to LAZY, ``library`` is not immediately loaded onto all existent contexts and will only be loaded when a function is needed for that context, such as a kernel launch. These environment variables are described in the CUDA programming guide under the "CUDA environment variables" section. The ``code`` may be a ``cubin`` or ``fatbin`` as output by nvcc, or a NULL-terminated ``PTX``, either as output by nvcc or hand-written, or ``Tile`` IR data. A fatbin should also contain relocatable code when doing separate compilation. Please also see the documentation for nvrtc (https://docs.nvidia.com/cuda/nvrtc/index.html), nvjitlink (https://docs.nvidia.com/cuda/nvjitlink/index.html), and nvfatbin (https://docs.nvidia.com/cuda/nvfatbin/index.html) for more information on generating loadable code at runtime. Options are passed as an array via ``jit_options`` and any corresponding parameters are passed in ``jit_optionsValues``. The number of total JIT options is supplied via ``num_jit_options``. Any outputs will be returned via ``jit_optionsValues``. Library load options are passed as an array via ``library_options`` and any corresponding parameters are passed in ``library_option_values``. The number of total library load options is supplied via ``num_library_options``. Args: code (bytes): Code to load. jit_options (intptr_t): Options for JIT. jit_options_values (intptr_t): Option values for JIT. num_jit_options (unsigned int): Number of options. library_options (intptr_t): Options for loading. library_option_values (intptr_t): Option values for loading. num_library_options (unsigned int): Number of options for loading. Returns: intptr_t: Returned library. .. seealso:: `cudaLibraryLoadData` """ cdef _cyb_BufferGuard _code_guard_ = _cyb_BufferGuard(code, 0, False, True, True) cdef void* _code_ = _code_guard_.ptr cdef cudaLibrary_t library with nogil: __status__ = cudaLibraryLoadData(&library, _code_, jit_options, jit_options_values, num_jit_options, library_options, library_option_values, num_library_options) check_status(__status__) return library cpdef intptr_t library_load_from_file(file_name, intptr_t jit_options, intptr_t jit_options_values, unsigned int num_jit_options, intptr_t library_options, intptr_t library_option_values, unsigned int num_library_options) except? 0: """Load a library with specified file and options. Takes a pointer ``code`` and loads the corresponding library ``library`` based on the application defined library loading mode:. - If module loading is set to EAGER, via the environment variables described in "Module loading", ``library`` is loaded eagerly into all contexts at the time of the call and future contexts at the time of creation until the library is unloaded with :func:`library_unload`. - If the environment variables are set to LAZY, ``library`` is not immediately loaded onto all existent contexts and will only be loaded when a function is needed for that context, such as a kernel launch. These environment variables are described in the CUDA programming guide under the "CUDA environment variables" section. The file should be a ``cubin`` file as output by nvcc, or a ``PTX`` file either as output by nvcc or handwritten, or a ``fatbin`` file as output by nvcc or hand-written, or ``Tile`` IR file. A fatbin should also contain relocatable code when doing separate compilation. Please also see the documentation for nvrtc (https://docs.nvidia.com/cuda/nvrtc/index.html), nvjitlink (https://docs.nvidia.com/cuda/nvjitlink/index.html), and nvfatbin (https://docs.nvidia.com/cuda/nvfatbin/index.html) for more information on generating loadable code at runtime. Options are passed as an array via ``jit_options`` and any corresponding parameters are passed in ``jit_optionsValues``. The number of total options is supplied via ``num_jit_options``. Any outputs will be returned via ``jit_optionsValues``. Library load options are passed as an array via ``library_options`` and any corresponding parameters are passed in ``library_option_values``. The number of total library load options is supplied via ``num_library_options``. Args: file_name (bytes): File to load from. jit_options (intptr_t): Options for JIT. jit_options_values (intptr_t): Option values for JIT. num_jit_options (unsigned int): Number of options. library_options (intptr_t): Options for loading. library_option_values (intptr_t): Option values for loading. num_library_options (unsigned int): Number of options for loading. Returns: intptr_t: Returned library. .. seealso:: `cudaLibraryLoadFromFile` """ cdef _cyb_BufferGuard _file_name_guard_ = _cyb_BufferGuard(file_name, 0, False, True, True) cdef void* _file_name_ = _file_name_guard_.ptr cdef cudaLibrary_t library with nogil: __status__ = cudaLibraryLoadFromFile(&library, _file_name_, jit_options, jit_options_values, num_jit_options, library_options, library_option_values, num_library_options) check_status(__status__) return library cpdef library_unload(intptr_t library): """Unloads a library. Unloads the library specified with ``library``. Args: library (intptr_t): Library to unload. .. seealso:: `cudaLibraryUnload` """ with nogil: __status__ = cudaLibraryUnload(library) check_status(__status__) cpdef intptr_t library_get_kernel(intptr_t library, name) except? 0: """Returns a kernel handle. Returns in ``p_kernel`` the handle of the kernel with name ``name`` located in library ``library``. If kernel handle is not found, the call returns ``cudaErrorSymbolNotFound``. Args: library (intptr_t): Library to retrieve kernel from. name (bytes): Name of kernel to retrieve. Returns: intptr_t: Returned kernel handle. .. seealso:: `cudaLibraryGetKernel` """ cdef _cyb_BufferGuard _name_guard_ = _cyb_BufferGuard(name, 0, False, True, True) cdef void* _name_ = _name_guard_.ptr cdef cudaKernel_t p_kernel with nogil: __status__ = cudaLibraryGetKernel(&p_kernel, library, _name_) check_status(__status__) return p_kernel cpdef tuple library_get_global(intptr_t library, name): """Returns a global device pointer. Returns in ``*dptr`` and ``*bytes`` the base pointer and size of the global with name ``name`` for the requested library ``library`` and the current device. If no global for the requested name ``name`` exists, the call returns ``cudaErrorSymbolNotFound``. One of the parameters ``dptr`` or ``numbytes`` (not both) can be NULL in which case it is ignored. The returned ``dptr`` cannot be passed to the Symbol APIs such as ``cudaMemcpyToSymbol``, ``cudaMemcpyFromSymbol``, ``cudaGetSymbolAddress``, or ``cudaGetSymbolSize``. Args: library (intptr_t): Library to retrieve global from. name (bytes): Name of global to retrieve. Returns: A 2-tuple containing: - intptr_t: Returned global device pointer for the requested library. - size_t: Returned global size in bytes. .. seealso:: `cudaLibraryGetGlobal` """ cdef _cyb_BufferGuard _name_guard_ = _cyb_BufferGuard(name, 0, False, True, True) cdef void* _name_ = _name_guard_.ptr cdef void* dptr cdef size_t bytes with nogil: __status__ = cudaLibraryGetGlobal(&dptr, &bytes, library, _name_) check_status(__status__) return (dptr, bytes) cpdef tuple library_get_managed(intptr_t library, name): """Returns a pointer to managed memory. Returns in ``*dptr`` and ``*bytes`` the base pointer and size of the managed memory with name ``name`` for the requested library ``library``. If no managed memory with the requested name ``name`` exists, the call returns ``cudaErrorSymbolNotFound``. One of the parameters ``dptr`` or ``numbytes`` (not both) can be NULL in which case it is ignored. Note that managed memory for library ``library`` is shared across devices and is registered when the library is loaded. The returned ``dptr`` cannot be passed to the Symbol APIs such as ``cudaMemcpyToSymbol``, ``cudaMemcpyFromSymbol``, ``cudaGetSymbolAddress``, or ``cudaGetSymbolSize``. Args: library (intptr_t): Library to retrieve managed memory from. name (bytes): Name of managed memory to retrieve. Returns: A 2-tuple containing: - intptr_t: Returned pointer to the managed memory. - size_t: Returned memory size in bytes. .. seealso:: `cudaLibraryGetManaged` """ cdef _cyb_BufferGuard _name_guard_ = _cyb_BufferGuard(name, 0, False, True, True) cdef void* _name_ = _name_guard_.ptr cdef void* dptr cdef size_t bytes with nogil: __status__ = cudaLibraryGetManaged(&dptr, &bytes, library, _name_) check_status(__status__) return (dptr, bytes) cpdef intptr_t library_get_unified_function(intptr_t library, symbol) except? 0: """Returns a pointer to a unified function. Returns in ``*fptr`` the function pointer to a unified function denoted by ``symbol``. If no unified function with name ``symbol`` exists, the call returns ``cudaErrorSymbolNotFound``. If there is no device with attribute ``cudaDeviceProp.unifiedFunctionPointers`` present in the system, the call may return ``cudaErrorSymbolNotFound``. Args: library (intptr_t): Library to retrieve function pointer memory from. symbol (bytes): Name of function pointer to retrieve. Returns: intptr_t: Returned pointer to a unified function. .. seealso:: `cudaLibraryGetUnifiedFunction` """ cdef _cyb_BufferGuard _symbol_guard_ = _cyb_BufferGuard(symbol, 0, False, True, True) cdef void* _symbol_ = _symbol_guard_.ptr cdef void* fptr with nogil: __status__ = cudaLibraryGetUnifiedFunction(&fptr, library, _symbol_) check_status(__status__) return fptr cpdef unsigned int library_get_kernel_count(intptr_t lib) except? 0: """Returns the number of kernels within a library. Returns in ``count`` the number of kernels in ``lib``. Args: lib (intptr_t): Library to query. Returns: unsigned int: Number of kernels found within the library. .. seealso:: `cudaLibraryGetKernelCount` """ cdef unsigned int count with nogil: __status__ = cudaLibraryGetKernelCount(&count, lib) check_status(__status__) return count cpdef object library_enumerate_kernels(intptr_t lib): """Retrieve the kernel handles within a library. Returns in ``kernels`` a maximum number of ``num_kernels`` kernel handles within ``lib``. The returned kernel handle becomes invalid when the library is unloaded. Args: lib (intptr_t): Library to query from. Returns: intptr_t: Buffer where the kernel handles are returned to. .. seealso:: `cudaLibraryEnumerateKernels` """ cdef unsigned int num_kernels with nogil: __status__ = cudaLibraryGetKernelCount(&num_kernels, lib) check_status(__status__) cdef _cyb_view.array _kernels_alloc_ = _cyb_view.array(shape=(max(num_kernels, 1),), itemsize=sizeof(intptr_t), format="q", mode="c") cdef intptr_t *kernels_ptr = (_kernels_alloc_.data) cdef object kernels = _kernels_alloc_[:num_kernels] if num_kernels != 0: with nogil: __status__ = cudaLibraryEnumerateKernels(kernels_ptr, num_kernels, lib) check_status(__status__) return kernels cpdef kernel_set_attribute_for_device(intptr_t kernel, int attr, int value, int device): """Sets information about a kernel. This call sets the value of a specified attribute ``attr`` on the kernel ``kernel`` for the requested device ``device`` to an integer value specified by ``value``. This function returns ``cudaSuccess`` if the new value of the attribute could be successfully set. If the set fails, this call will return an error. Not all attributes can have values set. Attempting to set a value on a read-only attribute will result in an error (``cudaErrorInvalidValue``). Note that attributes set using :func:`func_set_attribute` will override the attribute set by this API irrespective of whether the call to :func:`func_set_attribute` is made before or after this API call. Because of this and the stricter locking requirements mentioned below it is suggested that this call be used during the initialization path and not on each thread accessing ``kernel`` such as on kernel launches or on the critical path. Valid values for ``attr`` are:. - ``cudaFuncAttributeMaxDynamicSharedMemorySize`` - The requested maximum size in bytes of dynamically-allocated shared memory. The sum of this value and the function attribute ``sharedSizeBytes`` cannot exceed the device attribute ``cudaDevAttrMaxSharedMemoryPerBlockOptin``. The maximal size of requestable dynamic shared memory may differ by GPU architecture. - ``cudaFuncAttributePreferredSharedMemoryCarveout`` - On devices where the L1 cache and shared memory use the same hardware resources, this sets the shared memory carveout preference, in percent of the total shared memory. See ``cudaDevAttrMaxSharedMemoryPerMultiprocessor``. This is only a hint, and the driver can choose a different ratio if required to execute the function. - ``cudaFuncAttributeRequiredClusterWidth``: The required cluster width in blocks. The width, height, and depth values must either all be 0 or all be positive. The validity of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime. Setting it at runtime will return cudaErrorNotPermitted. - ``cudaFuncAttributeRequiredClusterHeight``: The required cluster height in blocks. The width, height, and depth values must either all be 0 or all be positive. The validity of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime. Setting it at runtime will return cudaErrorNotPermitted. - ``cudaFuncAttributeRequiredClusterDepth``: The required cluster depth in blocks. The width, height, and depth values must either all be 0 or all be positive. The validity of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime. Setting it at runtime will return cudaErrorNotPermitted. - ``cudaFuncAttributeNonPortableClusterSizeAllowed``: Indicates whether the function can be launched with non-portable cluster size. 1 is allowed, 0 is disallowed. - ``cudaFuncAttributeClusterSchedulingPolicyPreference``: The block scheduling policy of a function. The value type is ``cudaClusterSchedulingPolicy``. Args: kernel (intptr_t): Kernel to set attribute of. attr (FuncAttribute): Attribute requested. value (int): Value to set. device (int): Device to set attribute of. .. note:: The API has stricter locking requirements in comparison to its legacy counterpart :func:`func_set_attribute` due to device-wide semantics. If multiple threads are trying to set the same attribute on the same device simultaneously, the attribute setting will depend on the interleavings chosen by the OS scheduler and memory consistency. .. seealso:: `cudaKernelSetAttributeForDevice` """ with nogil: __status__ = cudaKernelSetAttributeForDevice(kernel, attr, value, device) check_status(__status__) cpdef intptr_t get_export_table(p_export_table_id) except? 0: """Gets an internal export table. Intended for use by CUDA libraries, not by applications. Args: p_export_table_id (intptr_t): UUID of the export table to get. Returns: intptr_t: Returned pointer to the export table. .. seealso:: `cudaGetExportTable` """ cdef intptr_t _p_export_table_id_ptr_ = 0 if p_export_table_id is None else int(p_export_table_id) cdef const void* pp_export_table with nogil: __status__ = cudaGetExportTable(&pp_export_table, _p_export_table_id_ptr_) check_status(__status__) return pp_export_table cpdef intptr_t get_kernel(intptr_t entry_func_addr) except? 0: """Get pointer to device kernel that matches entry function ``entry_func_addr``. Returns in ``kernel_ptr`` the device kernel corresponding to the entry function ``entry_func_addr``. Note that it is possible that there are multiple symbols belonging to different translation units with the same ``entry_func_addr`` registered with this CUDA Runtime and so the order which the translation units are loaded and registered with the CUDA Runtime can lead to differing return pointers in ``kernel_ptr`` . Suggested methods of ensuring uniqueness are to limit visibility of global device functions by using static or hidden visibility attribute in the respective translation units. Args: entry_func_addr (intptr_t): Address of device entry function to search kernel for. Returns: intptr_t: Returns the device kernel. .. seealso:: `cudaGetKernel` """ cdef cudaKernel_t kernel_ptr with nogil: __status__ = cudaGetKernel(&kernel_ptr, entry_func_addr) check_status(__status__) return kernel_ptr cpdef intptr_t graphics_egl_register_image(intptr_t image, unsigned int flags) except? 0: """Registers an EGL image. Registers the ``EGLImageKHR`` specified by ``image`` for access by CUDA. A handle to the registered object is returned as ``p_cuda_resource``. Additional Mapping/Unmapping is not required for the registered resource and ``cudaGraphicsResourceGetMappedEglFrame`` can be directly called on the ``p_cuda_resource``. The application will be responsible for synchronizing access to shared objects. The application must ensure that any pending operation which access the objects have completed before passing control to CUDA. This may be accomplished by issuing and waiting for glFinish command on all GLcontexts (for OpenGL and likewise for other APIs). The application will be also responsible for ensuring that any pending operation on the registered CUDA resource has completed prior to executing subsequent commands in other APIs accesing the same memory objects. This can be accomplished by calling cuCtxSynchronize or cuEventSynchronize (preferably). The surface's intended usage is specified using ``flags``, as follows:. - ``cudaGraphicsRegisterFlagsNone``: Specifies no hints about how this resource will be used. It is therefore assumed that this resource will be read from and written to by CUDA. This is the default value. - ``cudaGraphicsRegisterFlagsReadOnly``: Specifies that CUDA will not write to this resource. - ``cudaGraphicsRegisterFlagsWriteDiscard``: Specifies that CUDA will not read from this resource and will write over the entire contents of the resource, so none of the data previously stored in the resource will be preserved. The ``EGLImageKHR`` is an object which can be used to create EGLImage target resource. It is defined as a void pointer. typedef void* ``EGLImageKHR``. Args: image (intptr_t): An ``EGLImageKHR`` image which can be used to create target resource. flags (unsigned int): Map flags. Returns: intptr_t: Pointer to the returned object handle. .. seealso:: `cudaGraphicsEGLRegisterImage` """ cdef cudaGraphicsResource* p_cuda_resource with nogil: __status__ = cudaGraphicsEGLRegisterImage(&p_cuda_resource, image, flags) check_status(__status__) return p_cuda_resource cpdef intptr_t egl_stream_consumer_connect(intptr_t egl_stream) except? 0: """Connect CUDA to EGLStream as a consumer. Connect CUDA as a consumer to ``EGLStreamKHR`` specified by ``egl_stream``. The ``EGLStreamKHR`` is an EGL object that transfers a sequence of image frames from one API to another. Args: egl_stream (intptr_t): ``EGLStreamKHR`` handle. Returns: intptr_t: Pointer to the returned connection handle. .. seealso:: `cudaEGLStreamConsumerConnect` """ cdef cudaEglStreamConnection conn with nogil: __status__ = cudaEGLStreamConsumerConnect(&conn, egl_stream) check_status(__status__) return conn cpdef intptr_t egl_stream_consumer_connect_with_flags(intptr_t egl_stream, unsigned int flags) except? 0: """Connect CUDA to EGLStream as a consumer with given flags. Connect CUDA as a consumer to ``EGLStreamKHR`` specified by ``stream`` with specified ``flags`` defined by ``cudaEglResourceLocationFlags``. The flags specify whether the consumer wants to access frames from system memory or video memory. Default is ``cudaEglResourceLocationVidmem``. Args: egl_stream (intptr_t): ``EGLStreamKHR`` handle. flags (unsigned int): Flags denote intended location - system or video. Returns: intptr_t: Pointer to the returned connection handle. .. seealso:: `cudaEGLStreamConsumerConnectWithFlags` """ cdef cudaEglStreamConnection conn with nogil: __status__ = cudaEGLStreamConsumerConnectWithFlags(&conn, egl_stream, flags) check_status(__status__) return conn cpdef egl_stream_consumer_disconnect(intptr_t conn): """Disconnect CUDA as a consumer to EGLStream . Disconnect CUDA as a consumer to ``EGLStreamKHR``. Args: conn (intptr_t): Conection to disconnect. .. seealso:: `cudaEGLStreamConsumerDisconnect` """ cdef cudaEglStreamConnection _conn_ = conn with nogil: __status__ = cudaEGLStreamConsumerDisconnect(&_conn_) check_status(__status__) cpdef intptr_t egl_stream_consumer_acquire_frame(intptr_t conn, intptr_t p_stream, unsigned int timeout) except? 0: """Acquire an image frame from the EGLStream with CUDA as a consumer. Acquire an image frame from ``EGLStreamKHR``. ``cudaGraphicsResourceGetMappedEglFrame`` can be called on ``p_cuda_resource`` to get ``cudaEglFrame``. Args: conn (intptr_t): Connection on which to acquire. p_stream (intptr_t): CUDA stream for synchronization and any data migrations implied by ``cudaEglResourceLocationFlags``. timeout (unsigned int): Desired timeout in usec. Returns: intptr_t: CUDA resource on which the EGLStream frame will be mapped for use. .. seealso:: `cudaEGLStreamConsumerAcquireFrame` """ cdef cudaEglStreamConnection _conn_ = conn cdef cudaStream_t _p_stream_ = p_stream cdef cudaGraphicsResource_t p_cuda_resource with nogil: __status__ = cudaEGLStreamConsumerAcquireFrame(&_conn_, &p_cuda_resource, &_p_stream_, timeout) check_status(__status__) return p_cuda_resource cpdef egl_stream_consumer_release_frame(intptr_t conn, intptr_t p_cuda_resource, intptr_t p_stream): """Releases the last frame acquired from the EGLStream. Release the acquired image frame specified by ``p_cuda_resource`` to ``EGLStreamKHR``. Args: conn (intptr_t): Connection on which to release. p_cuda_resource (intptr_t): CUDA resource whose corresponding frame is to be released. p_stream (intptr_t): CUDA stream on which release will be done. .. seealso:: `cudaEGLStreamConsumerReleaseFrame` """ cdef cudaEglStreamConnection _conn_ = conn cdef cudaStream_t _p_stream_ = p_stream with nogil: __status__ = cudaEGLStreamConsumerReleaseFrame(&_conn_, p_cuda_resource, &_p_stream_) check_status(__status__) cpdef intptr_t egl_stream_producer_connect(intptr_t egl_stream, unsigned int width, unsigned int height) except? 0: """Connect CUDA to EGLStream as a producer. Connect CUDA as a producer to ``EGLStreamKHR`` specified by ``stream``. The ``EGLStreamKHR`` is an EGL object that transfers a sequence of image frames from one API to another. Args: egl_stream (intptr_t): ``EGLStreamKHR`` handle. width (unsigned int): width of the image to be submitted to the stream. height (unsigned int): height of the image to be submitted to the stream. Returns: intptr_t: Pointer to the returned connection handle. .. seealso:: `cudaEGLStreamProducerConnect` """ cdef cudaEglStreamConnection conn with nogil: __status__ = cudaEGLStreamProducerConnect(&conn, egl_stream, width, height) check_status(__status__) return conn cpdef egl_stream_producer_disconnect(intptr_t conn): """Disconnect CUDA as a producer to EGLStream . Disconnect CUDA as a producer to ``EGLStreamKHR``. Args: conn (intptr_t): Conection to disconnect. .. seealso:: `cudaEGLStreamProducerDisconnect` """ cdef cudaEglStreamConnection _conn_ = conn with nogil: __status__ = cudaEGLStreamProducerDisconnect(&_conn_) check_status(__status__) cpdef egl_stream_producer_present_frame(intptr_t conn, eglframe, intptr_t p_stream): """Present a CUDA eglFrame to the EGLStream with CUDA as a producer. The ``cudaEglFrame`` is defined as:. \*\*View CUDA Toolkit Documentation for a C++ code example*\*. For ``cudaEglFrame`` of type ``cudaEglFrameTypePitch``, the application may present sub-region of a memory allocation. In that case, ``cudaPitchedPtr.ptr`` will specify the start address of the sub-region in the allocation and ``cudaEglPlaneDesc`` will specify the dimensions of the sub-region. Args: conn (intptr_t): Connection on which to present the CUDA array. eglframe (cudaEglFrame): CUDA Eglstream Proucer Frame handle to be sent to the consumer over EglStream. p_stream (intptr_t): CUDA stream on which to present the frame. .. seealso:: `cudaEGLStreamProducerPresentFrame` """ cdef cudaEglStreamConnection _conn_ = conn cdef intptr_t _eglframe_ptr_ = (eglframe)._get_ptr() cdef cudaStream_t _p_stream_ = p_stream with nogil: __status__ = cudaEGLStreamProducerPresentFrame(&_conn_, (_eglframe_ptr_)[0], &_p_stream_) check_status(__status__) cpdef object egl_stream_producer_return_frame(intptr_t conn, intptr_t p_stream): """Return the CUDA eglFrame to the EGLStream last released by the consumer. This API can potentially return cudaErrorLaunchTimeout if the consumer has not returned a frame to EGL stream. If timeout is returned the application can retry. Args: conn (intptr_t): Connection on which to present the CUDA array. p_stream (intptr_t): CUDA stream on which to return the frame. Returns: cudaEglFrame: CUDA Eglstream Proucer Frame handle returned from the consumer over EglStream. .. seealso:: `cudaEGLStreamProducerReturnFrame` """ cdef cudaEglStreamConnection _conn_ = conn cdef cudaStream_t _p_stream_ = p_stream cdef EglFrame eglframe_py = EglFrame() cdef cudaEglFrame *eglframe = (eglframe_py._get_ptr()) with nogil: __status__ = cudaEGLStreamProducerReturnFrame(&_conn_, eglframe, &_p_stream_) check_status(__status__) return eglframe_py cpdef object graphics_resource_get_mapped_egl_frame(intptr_t resource, unsigned int index, unsigned int mip_level): """Get an egl_frame through which to access a registered EGL graphics resource. Returns in ``*egl_frame`` an egl_frame pointer through which the registered graphics resource ``resource`` may be accessed. This API can only be called for EGL graphics resources. The ``cudaEglFrame`` is defined as. \*\*View CUDA Toolkit Documentation for a C++ code example*\*. Args: resource (intptr_t): Registered resource to access. index (unsigned int): Index for cubemap surfaces. mip_level (unsigned int): Mipmap level for the subresource to access. Returns: cudaEglFrame: Returned egl_frame. .. note:: Note that in case of multiplanar ``*egl_frame``, pitch of only first plane (unsigned int ``cudaEglPlaneDesc.pitch``) is to be considered by the application. .. seealso:: `cudaGraphicsResourceGetMappedEglFrame` """ cdef EglFrame egl_frame_py = EglFrame() cdef cudaEglFrame *egl_frame = (egl_frame_py._get_ptr()) with nogil: __status__ = cudaGraphicsResourceGetMappedEglFrame(egl_frame, resource, index, mip_level) check_status(__status__) return egl_frame_py cpdef intptr_t event_create_from_egl_sync(intptr_t egl_sync, unsigned int flags) except? 0: """Creates an event from EGLSync object. Creates an event \*ph_event from an ``EGLSyncKHR`` egl_sync with the flages specified via ``flags``. Valid flags include:. - ``cudaEventDefault``: Default event creation flag. - ``cudaEventBlockingSync``: Specifies that the created event should use blocking synchronization. A CPU thread that uses :func:`event_synchronize` to wait on an event created with this flag will block until the event has actually been completed. ``cudaEventRecord`` and TimingData are not supported for events created from EGLSync. The ``EGLSyncKHR`` is an opaque handle to an EGL sync object. typedef void* ``EGLSyncKHR``. Args: egl_sync (intptr_t): Opaque handle to EGLSync object. flags (unsigned int): Event creation flags. Returns: intptr_t: Returns newly created event. .. seealso:: `cudaEventCreateFromEGLSync` """ cdef cudaEvent_t ph_event with nogil: __status__ = cudaEventCreateFromEGLSync(&ph_event, egl_sync, flags) check_status(__status__) return ph_event cpdef profiler_start(): """Enable profiling. Enables profile collection by the active profiling tool for the current context. If profiling is already enabled, then :func:`profiler_start` has no effect. cudaProfilerStart and cudaProfilerStop APIs are used to programmatically control the profiling granularity by allowing profiling to be done only on selective pieces of code. .. seealso:: `cudaProfilerStart` """ with nogil: __status__ = cudaProfilerStart() check_status(__status__) cpdef profiler_stop(): """Disable profiling. Disables profile collection by the active profiling tool for the current context. If profiling is already disabled, then :func:`profiler_stop` has no effect. cudaProfilerStart and cudaProfilerStop APIs are used to programmatically control the profiling granularity by allowing profiling to be done only on selective pieces of code. .. seealso:: `cudaProfilerStop` """ with nogil: __status__ = cudaProfilerStop() check_status(__status__) cpdef intptr_t graphics_gl_register_image(GLuint image, GLenum target, unsigned int flags) except? 0: """Register an OpenGL texture or renderbuffer object. Registers the texture or renderbuffer object specified by ``image`` for access by CUDA. A handle to the registered object is returned as ``resource``. ``target`` must match the type of the object, and must be one of ``GL_TEXTURE_2D``, ``GL_TEXTURE_RECTANGLE``, ``GL_TEXTURE_CUBE_MAP``, ``GL_TEXTURE_3D``, ``GL_TEXTURE_2D_ARRAY``, or ``GL_RENDERBUFFER``. The register flags ``flags`` specify the intended usage, as follows:. - ``cudaGraphicsRegisterFlagsNone``: Specifies no hints about how this resource will be used. It is therefore assumed that this resource will be read from and written to by CUDA. This is the default value. - ``cudaGraphicsRegisterFlagsReadOnly``: Specifies that CUDA will not write to this resource. - ``cudaGraphicsRegisterFlagsWriteDiscard``: Specifies that CUDA will not read from this resource and will write over the entire contents of the resource, so none of the data previously stored in the resource will be preserved. - ``cudaGraphicsRegisterFlagsSurfaceLoadStore``: Specifies that CUDA will bind this resource to a surface reference. - ``cudaGraphicsRegisterFlagsTextureGather``: Specifies that CUDA will perform texture gather operations on this resource. The following image formats are supported. For brevity's sake, the list is abbreviated. For ex., {GL_R, GL_RG} X {8, 16} would expand to the following 4 formats {GL_R8, GL_R16, GL_RG8, GL_RG16} :. - GL_RED, GL_RG, GL_RGBA, GL_LUMINANCE, GL_ALPHA, GL_LUMINANCE_ALPHA, GL_INTENSITY. - {GL_R, GL_RG, GL_RGBA} X {8, 16, 16F, 32F, 8UI, 16UI, 32UI, 8I, 16I, 32I}. - {GL_LUMINANCE, GL_ALPHA, GL_LUMINANCE_ALPHA, GL_INTENSITY} X {8, 16, 16F_ARB, 32F_ARB, 8UI_EXT, 16UI_EXT, 32UI_EXT, 8I_EXT, 16I_EXT, 32I_EXT}. The following image classes are currently disallowed:. - Textures with borders. - Multisampled renderbuffers. Args: image (GLuint): name of texture or renderbuffer object to be registered. target (GLenum): Identifies the type of object specified by ``image``. flags (unsigned int): Register flags. Returns: intptr_t: Pointer to the returned object handle. .. seealso:: `cudaGraphicsGLRegisterImage` """ cdef cudaGraphicsResource* resource with nogil: __status__ = cudaGraphicsGLRegisterImage(&resource, image, target, flags) check_status(__status__) return resource cpdef intptr_t graphics_gl_register_buffer(GLuint buffer, unsigned int flags) except? 0: """Registers an OpenGL buffer object. Registers the buffer object specified by ``buffer`` for access by CUDA. A handle to the registered object is returned as ``resource``. The register flags ``flags`` specify the intended usage, as follows:. - ``cudaGraphicsRegisterFlagsNone``: Specifies no hints about how this resource will be used. It is therefore assumed that this resource will be read from and written to by CUDA. This is the default value. - ``cudaGraphicsRegisterFlagsReadOnly``: Specifies that CUDA will not write to this resource. - ``cudaGraphicsRegisterFlagsWriteDiscard``: Specifies that CUDA will not read from this resource and will write over the entire contents of the resource, so none of the data previously stored in the resource will be preserved. Args: buffer (GLuint): name of buffer object to be registered. flags (unsigned int): Register flags. Returns: intptr_t: Pointer to the returned object handle. .. seealso:: `cudaGraphicsGLRegisterBuffer` """ cdef cudaGraphicsResource* resource with nogil: __status__ = cudaGraphicsGLRegisterBuffer(&resource, buffer, flags) check_status(__status__) return resource cpdef int vdpau_get_device(VdpDevice vdp_device, intptr_t vdp_get_proc_address) except? -1: """Gets the CUDA device associated with a ``VdpDevice``. Returns the CUDA device associated with a ``VdpDevice``, if applicable. Args: vdp_device (VdpDevice): A ``VdpDevice`` handle. vdp_get_proc_address (intptr_t): VDPAU's ``VdpGetProcAddress`` function pointer. Returns: int: Returns the device associated with vdp_device, or -1 if the device associated with vdp_device is not a compute device. .. seealso:: `cudaVDPAUGetDevice` """ cdef int device with nogil: __status__ = cudaVDPAUGetDevice(&device, vdp_device, vdp_get_proc_address) check_status(__status__) return device cpdef vdpau_set_vdpau_device(int device, VdpDevice vdp_device, intptr_t vdp_get_proc_address): """Sets a CUDA device to use VDPAU interoperability. Records ``vdp_device`` as the ``VdpDevice`` for VDPAU interoperability with the CUDA device ``device`` and sets ``device`` as the current device for the calling host thread. This function will immediately initialize the primary context on ``device`` if needed. If ``device`` has already been initialized then this call will fail with the error ``cudaErrorSetOnActiveProcess``. In this case it is necessary to reset ``device`` using :func:`device_reset` before VDPAU interoperability on ``device`` may be enabled. Args: device (int): Device to use for VDPAU interoperability. vdp_device (VdpDevice): The ``VdpDevice`` to interoperate with. vdp_get_proc_address (intptr_t): VDPAU's ``VdpGetProcAddress`` function pointer. .. seealso:: `cudaVDPAUSetVDPAUDevice` """ with nogil: __status__ = cudaVDPAUSetVDPAUDevice(device, vdp_device, vdp_get_proc_address) check_status(__status__) cpdef intptr_t graphics_vdpau_register_video_surface(VdpVideoSurface vdp_surface, unsigned int flags) except? 0: """Register a ``VdpVideoSurface`` object. Registers the ``VdpVideoSurface`` specified by ``vdp_surface`` for access by CUDA. A handle to the registered object is returned as ``resource``. The surface's intended usage is specified using ``flags``, as follows:. - ``cudaGraphicsMapFlagsNone``: Specifies no hints about how this resource will be used. It is therefore assumed that this resource will be read from and written to by CUDA. This is the default value. - ``cudaGraphicsMapFlagsReadOnly``: Specifies that CUDA will not write to this resource. - ``cudaGraphicsMapFlagsWriteDiscard``: Specifies that CUDA will not read from this resource and will write over the entire contents of the resource, so none of the data previously stored in the resource will be preserved. Args: vdp_surface (VdpVideoSurface): VDPAU object to be registered. flags (unsigned int): Map flags. Returns: intptr_t: Pointer to the returned object handle. .. seealso:: `cudaGraphicsVDPAURegisterVideoSurface` """ cdef cudaGraphicsResource* resource with nogil: __status__ = cudaGraphicsVDPAURegisterVideoSurface(&resource, vdp_surface, flags) check_status(__status__) return resource cpdef intptr_t graphics_vdpau_register_output_surface(VdpOutputSurface vdp_surface, unsigned int flags) except? 0: """Register a ``VdpOutputSurface`` object. Registers the ``VdpOutputSurface`` specified by ``vdp_surface`` for access by CUDA. A handle to the registered object is returned as ``resource``. The surface's intended usage is specified using ``flags``, as follows:. - ``cudaGraphicsMapFlagsNone``: Specifies no hints about how this resource will be used. It is therefore assumed that this resource will be read from and written to by CUDA. This is the default value. - ``cudaGraphicsMapFlagsReadOnly``: Specifies that CUDA will not write to this resource. - ``cudaGraphicsMapFlagsWriteDiscard``: Specifies that CUDA will not read from this resource and will write over the entire contents of the resource, so none of the data previously stored in the resource will be preserved. Args: vdp_surface (VdpOutputSurface): VDPAU object to be registered. flags (unsigned int): Map flags. Returns: intptr_t: Pointer to the returned object handle. .. seealso:: `cudaGraphicsVDPAURegisterOutputSurface` """ cdef cudaGraphicsResource* resource with nogil: __status__ = cudaGraphicsVDPAURegisterOutputSurface(&resource, vdp_surface, flags) check_status(__status__) return resource cpdef object get_device_properties(int device): """Returns information about the compute-device. Returns in ``*prop`` the properties of device ``dev``. Args: device (int): Device number to get properties for. Returns: cudaDeviceProp: Properties for the specified device. .. seealso:: `cudaGetDeviceProperties` """ cdef DeviceProp prop_py = DeviceProp() cdef cudaDeviceProp *prop = (prop_py._get_ptr()) with nogil: __status__ = cudaGetDeviceProperties(prop, device) check_status(__status__) return prop_py cpdef tuple stream_get_capture_info(intptr_t stream): """Query a stream's capture state. Query stream state related to stream capture. If called on ``cudaStreamLegacy`` (the "null stream") while a stream not created with ``cudaStreamNonBlocking`` is capturing, returns ``cudaErrorStreamCaptureImplicit``. Valid data (other than capture status) is returned only if both of the following are true:. - the call returns cudaSuccess. - the returned capture status is ``cudaStreamCaptureStatusActive``. If ``edge_data_out`` is non-NULL then ``dependencies_out`` must be as well. If ``dependencies_out`` is non-NULL and ``edge_data_out`` is NULL, but there is non-zero edge data for one or more of the current stream dependencies, the call will return ``cudaErrorLossyQuery``. Args: stream (intptr_t): The stream to query. Returns: A 5-tuple containing: - int: Location to return the capture status of the stream; required. - unsigned long long: Optional location to return an id for the capture sequence, which is unique over the lifetime of the process. - intptr_t: Optional location to return the graph being captured into. All operations other than destroy and node removal are permitted on the graph while the capture sequence is in progress. This API does not transfer ownership of the graph, which is transferred or destroyed at ``cudaStreamEndCapture``. Note that the graph handle may be invalidated before end of capture for certain errors. Nodes that are or become unreachable from the original stream at ``cudaStreamEndCapture`` due to direct actions on the graph do not trigger ``cudaErrorStreamCaptureUnjoined``. - intptr_t: Optional location to store a pointer to an array of nodes. The next node to be captured in the stream will depend on this set of nodes, absent operations such as event wait which modify this set. The array pointer is valid until the next API call which operates on the stream or until the capture is terminated. The node handles may be copied out and are valid until they or the graph is destroyed. The driver-owned array may also be passed directly to APIs that operate on the graph (not the stream) without copying. - cudaGraphEdgeData: Optional location to store a pointer to an array of graph edge data. This array parallels ``dependencies_out``; the next node to be added has an edge to ``dependencies_out``\[i] with annotation ``edge_data_out``\[i] for each ``i``. The array pointer is valid until the next API call which operates on the stream or until the capture is terminated. .. seealso:: `cudaStreamGetCaptureInfo` """ cdef cudaStreamCaptureStatus capture_status_out cdef unsigned long long id_out cdef cudaGraph_t graph_out cdef size_t[1] num_dependencies_out = [0] cdef const cudaGraphNode_t* dependencies_out = NULL cdef const cudaGraphEdgeData* edge_data_out = NULL with nogil: __status__ = cudaStreamGetCaptureInfo(stream, &capture_status_out, &id_out, &graph_out, &dependencies_out, &edge_data_out, num_dependencies_out) check_status(__status__) return (capture_status_out, id_out, graph_out, (_numpy.empty(0, dtype=_numpy.intp) if num_dependencies_out[0] == 0 or dependencies_out == NULL else _numpy.frombuffer(_cyb_PyMemoryView_FromMemory(dependencies_out, (num_dependencies_out[0] * sizeof(cudaGraphNode_t)), _cyb_PyBUF_READ), dtype=_numpy.intp)), (_numpy.empty(0, dtype=graph_edge_data_dtype) if num_dependencies_out[0] == 0 or edge_data_out == NULL else _numpy.frombuffer(_cyb_PyMemoryView_FromMemory(edge_data_out, (num_dependencies_out[0] * sizeof(cudaGraphEdgeData)), _cyb_PyBUF_READ), dtype=graph_edge_data_dtype))) cpdef signal_external_semaphores_async(ext_sem_array, params_array, intptr_t stream): """Signals a set of external semaphore objects. Enqueues a signal operation on a set of externally allocated semaphore object in the specified stream. The operations will be executed when all prior operations in the stream complete. The exact semantics of signaling a semaphore depends on the type of the object. If the semaphore object is any one of the following types: ``cudaExternalSemaphoreHandleTypeOpaqueFd``, ``cudaExternalSemaphoreHandleTypeOpaqueWin32``, ``cudaExternalSemaphoreHandleTypeOpaqueWin32Kmt`` then signaling the semaphore will set it to the signaled state. If the semaphore object is any one of the following types: ``cudaExternalSemaphoreHandleTypeD3D12Fence``, ``cudaExternalSemaphoreHandleTypeD3D11Fence``, ``cudaExternalSemaphoreHandleTypeTimelineSemaphoreFd``, ``cudaExternalSemaphoreHandleTypeTimelineSemaphoreWin32`` then the semaphore will be set to the value specified in ``cudaExternalSemaphoreSignalParams.params.fence.value``. If the semaphore object is of the type ``cudaExternalSemaphoreHandleTypeNvSciSync`` this API sets ``cudaExternalSemaphoreSignalParams.params.nvSciSync.fence`` to a value that can be used by subsequent waiters of the same NvSciSync object to order operations with those currently submitted in ``stream``. Such an update will overwrite previous contents of ``cudaExternalSemaphoreSignalParams.params.nvSciSync.fence``. By default, signaling such an external semaphore object causes appropriate memory synchronization operations to be performed over all the external memory objects that are imported as ``cudaExternalMemoryHandleTypeNvSciBuf``. This ensures that any subsequent accesses made by other importers of the same set of NvSciBuf memory object(s) are coherent. These operations can be skipped by specifying the flag ``cudaExternalSemaphoreSignalSkipNvSciBufMemSync``, which can be used as a performance optimization when data coherency is not required. But specifying this flag in scenarios where data coherency is required results in undefined behavior. Also, for semaphore object of the type ``cudaExternalSemaphoreHandleTypeNvSciSync``, if the NvSciSyncAttrList used to create the NvSciSyncObj had not set the flags in ``cudaDeviceGetNvSciSyncAttributes`` to cudaNvSciSyncAttrSignal, this API will return cudaErrorNotSupported. ``cudaExternalSemaphoreSignalParams.params.nvSciSync.fence`` associated with semaphore object of the type ``cudaExternalSemaphoreHandleTypeNvSciSync`` can be deterministic. For this the NvSciSyncAttrList used to create the semaphore object must have value of NvSciSyncAttrKey_RequireDeterministicFences key set to true. Deterministic fences allow users to enqueue a wait over the semaphore object even before corresponding signal is enqueued. For such a semaphore object, CUDA guarantees that each signal operation will increment the fence value by '1'. Users are expected to track count of signals enqueued on the semaphore object and insert waits accordingly. When such a semaphore object is signaled from multiple streams, due to concurrent stream execution, it is possible that the order in which the semaphore gets signaled is indeterministic. This could lead to waiters of the semaphore getting unblocked incorrectly. Users are expected to handle such situations, either by not using the same semaphore object with deterministic fence support enabled in different streams or by adding explicit dependency amongst such streams so that the semaphore is signaled in order. ``cudaExternalSemaphoreSignalParams.params.nvSciSync.fence`` associated with semaphore object of the type ``cudaExternalSemaphoreHandleTypeNvSciSync`` can be timestamp enabled. For this the NvSciSyncAttrList used to create the object must have the value of NvSciSyncAttrKey_WaiterRequireTimestamps key set to true. Timestamps are emitted asynchronously by the GPU and CUDA saves the GPU timestamp in the corresponding NvSciSyncFence at the time of signal on GPU. Users are expected to convert GPU clocks to CPU clocks using appropriate scaling functions. Users are expected to wait for the completion of the fence before extracting timestamp using appropriate NvSciSync APIs. Users are expected to ensure that there is only one outstanding timestamp enabled fence per Cuda-NvSciSync object at any point of time, failing which leads to undefined behavior. Extracting the timestamp before the corresponding fence is signalled could lead to undefined behaviour. Timestamp extracted via appropriate NvSciSync API would be in microseconds. If the semaphore object is any one of the following types: ``cudaExternalSemaphoreHandleTypeKeyedMutex``, ``cudaExternalSemaphoreHandleTypeKeyedMutexKmt``, then the keyed mutex will be released with the key specified in ``cudaExternalSemaphoreSignalParams.params.keyedmutex.key``. Args: ext_sem_array (object): Set of external semaphores to be signaled. It must be: - a Python sequence of :class:`int`\s (as pointer addresses), or - ``None`` for NULL. params_array (ExternalSemaphoreSignalParams): Array of semaphore parameters. It must be: - a :class:`ExternalSemaphoreSignalParams`, or - ``None`` for NULL. stream (intptr_t): Stream to enqueue the signal operations in. .. seealso:: `cudaSignalExternalSemaphoresAsync` """ cdef _cyb_nullable_unique_ptr[ _cyb_vector[void*] ] _ext_sem_array_ if isinstance(ext_sem_array, int): raise TypeError( "ext_sem_array must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _ext_sem_array_len_ = 0 _cyb_get_resource_ptrs[void](_ext_sem_array_, ext_sem_array, NULL) if _ext_sem_array_.get() != NULL: _ext_sem_array_len_ = _ext_sem_array_.get().size() cdef intptr_t _params_array_ptr_ = 0 cdef Py_ssize_t _params_array_len_ = 0 if params_array is None: pass else: (params_array) _params_array_ptr_ = int(params_array) _params_array_len_ = len(params_array) cdef Py_ssize_t _num_ext_sems_length_ = 0 cdef bint _num_ext_sems_is_set_ = False if ext_sem_array is not None: _num_ext_sems_length_ = _cyb_check_same_length(_num_ext_sems_is_set_, _num_ext_sems_length_, _ext_sem_array_len_, "ext_sem_array", "ext_sem_array, params_array") _num_ext_sems_is_set_ = True if params_array is not None: _num_ext_sems_length_ = _cyb_check_same_length(_num_ext_sems_is_set_, _num_ext_sems_length_, _params_array_len_, "params_array", "ext_sem_array, params_array") _num_ext_sems_is_set_ = True cdef unsigned int num_ext_sems = _num_ext_sems_length_ if num_ext_sems != _num_ext_sems_length_: raise OverflowError( f"The length of (ext_sem_array, params_array), {_num_ext_sems_length_}, does not fit in 'numExtSems' (a unsigned int)" ) with nogil: __status__ = cudaSignalExternalSemaphoresAsync((_ext_sem_array_.data()), _params_array_ptr_, num_ext_sems, stream) check_status(__status__) cpdef wait_external_semaphores_async(ext_sem_array, params_array, intptr_t stream): """Waits on a set of external semaphore objects. Enqueues a wait operation on a set of externally allocated semaphore object in the specified stream. The operations will be executed when all prior operations in the stream complete. The exact semantics of waiting on a semaphore depends on the type of the object. If the semaphore object is any one of the following types: ``cudaExternalSemaphoreHandleTypeOpaqueFd``, ``cudaExternalSemaphoreHandleTypeOpaqueWin32``, ``cudaExternalSemaphoreHandleTypeOpaqueWin32Kmt`` then waiting on the semaphore will wait until the semaphore reaches the signaled state. The semaphore will then be reset to the unsignaled state. Therefore for every signal operation, there can only be one wait operation. If the semaphore object is any one of the following types: ``cudaExternalSemaphoreHandleTypeD3D12Fence``, ``cudaExternalSemaphoreHandleTypeD3D11Fence``, ``cudaExternalSemaphoreHandleTypeTimelineSemaphoreFd``, ``cudaExternalSemaphoreHandleTypeTimelineSemaphoreWin32`` then waiting on the semaphore will wait until the value of the semaphore is greater than or equal to ``cudaExternalSemaphoreWaitParams.params.fence.value``. If the semaphore object is of the type ``cudaExternalSemaphoreHandleTypeNvSciSync`` then, waiting on the semaphore will wait until the ``cudaExternalSemaphoreSignalParams.params.nvSciSync.fence`` is signaled by the signaler of the NvSciSyncObj that was associated with this semaphore object. By default, waiting on such an external semaphore object causes appropriate memory synchronization operations to be performed over all external memory objects that are imported as ``cudaExternalMemoryHandleTypeNvSciBuf``. This ensures that any subsequent accesses made by other importers of the same set of NvSciBuf memory object(s) are coherent. These operations can be skipped by specifying the flag ``cudaExternalSemaphoreWaitSkipNvSciBufMemSync``, which can be used as a performance optimization when data coherency is not required. But specifying this flag in scenarios where data coherency is required results in undefined behavior. Also, for semaphore object of the type ``cudaExternalSemaphoreHandleTypeNvSciSync``, if the NvSciSyncAttrList used to create the NvSciSyncObj had not set the flags in ``cudaDeviceGetNvSciSyncAttributes`` to cudaNvSciSyncAttrWait, this API will return cudaErrorNotSupported. If the semaphore object is any one of the following types: ``cudaExternalSemaphoreHandleTypeKeyedMutex``, ``cudaExternalSemaphoreHandleTypeKeyedMutexKmt``, then the keyed mutex will be acquired when it is released with the key specified in ``cudaExternalSemaphoreSignalParams.params.keyedmutex.key`` or until the timeout specified by ``cudaExternalSemaphoreSignalParams.params.keyedmutex.timeoutMs`` has lapsed. The timeout interval can either be a finite value specified in milliseconds or an infinite value. In case an infinite value is specified the timeout never elapses. The windows INFINITE macro must be used to specify infinite timeout. Args: ext_sem_array (object): External semaphores to be waited on. It must be: - a Python sequence of :class:`int`\s (as pointer addresses), or - ``None`` for NULL. params_array (ExternalSemaphoreWaitParams): Array of semaphore parameters. It must be: - a :class:`ExternalSemaphoreWaitParams`, or - ``None`` for NULL. stream (intptr_t): Stream to enqueue the wait operations in. .. seealso:: `cudaWaitExternalSemaphoresAsync` """ cdef _cyb_nullable_unique_ptr[ _cyb_vector[void*] ] _ext_sem_array_ if isinstance(ext_sem_array, int): raise TypeError( "ext_sem_array must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _ext_sem_array_len_ = 0 _cyb_get_resource_ptrs[void](_ext_sem_array_, ext_sem_array, NULL) if _ext_sem_array_.get() != NULL: _ext_sem_array_len_ = _ext_sem_array_.get().size() cdef intptr_t _params_array_ptr_ = 0 cdef Py_ssize_t _params_array_len_ = 0 if params_array is None: pass else: (params_array) _params_array_ptr_ = int(params_array) _params_array_len_ = len(params_array) cdef Py_ssize_t _num_ext_sems_length_ = 0 cdef bint _num_ext_sems_is_set_ = False if ext_sem_array is not None: _num_ext_sems_length_ = _cyb_check_same_length(_num_ext_sems_is_set_, _num_ext_sems_length_, _ext_sem_array_len_, "ext_sem_array", "ext_sem_array, params_array") _num_ext_sems_is_set_ = True if params_array is not None: _num_ext_sems_length_ = _cyb_check_same_length(_num_ext_sems_is_set_, _num_ext_sems_length_, _params_array_len_, "params_array", "ext_sem_array, params_array") _num_ext_sems_is_set_ = True cdef unsigned int num_ext_sems = _num_ext_sems_length_ if num_ext_sems != _num_ext_sems_length_: raise OverflowError( f"The length of (ext_sem_array, params_array), {_num_ext_sems_length_}, does not fit in 'numExtSems' (a unsigned int)" ) with nogil: __status__ = cudaWaitExternalSemaphoresAsync((_ext_sem_array_.data()), _params_array_ptr_, num_ext_sems, stream) check_status(__status__) cpdef mem_prefetch_batch_async(dptrs, sizes, prefetch_locs, prefetch_loc_idxs, unsigned long long flags, intptr_t stream): """Performs a batch of memory prefetches asynchronously. Performs a batch of memory prefetches. The batch as a whole executes in stream order but operations within a batch are not guaranteed to execute in any specific order. All devices in the system must have a non-zero value for the device attribute ``cudaDevAttrConcurrentManagedAccess`` otherwise the API will return an error. The semantics of the individual prefetch operations are as described in ``cudaMemPrefetchAsync``. Performs memory prefetch on address ranges specified in ``dptrs`` and ``sizes``. Both arrays must be of the same length as specified by ``len(dptrs)``. Each memory range specified must refer to managed memory allocated via ``cudaMallocManaged`` or declared via managed variables or it may also refer to system-allocated memory when all devices have a non-zero value for ``cudaDevAttrPageableMemoryAccess``. The prefetch location for every operation in the batch is specified in the ``prefetch_locs`` array. Each entry in this array can apply to more than one operation. This can be done by specifying in the ``prefetch_loc_idxs`` array, the index of the first prefetch operation that the corresponding entry in the ``prefetch_locs`` array applies to. Both ``prefetch_locs`` and ``prefetch_loc_idxs`` must be of the same length as specified by ``len(prefetch_locs)``. For example, if a batch has 10 prefetches listed in dptrs/sizes, the first 4 of which are to be prefetched to one location and the remaining 6 are to be prefetched to another, then ``len(prefetch_locs)`` will be 2, ``prefetch_loc_idxs`` will be {0, 4} and ``prefetch_locs`` will contain the two locations. Note the first entry in ``prefetch_loc_idxs`` must always be 0. Also, each entry must be greater than the previous entry and the last entry should be less than ``len(dptrs)``. Furthermore, ``len(prefetch_locs)`` must be lesser than or equal to ``len(dptrs)``. Args: dptrs (object): Array of pointers to be prefetched. It must be: - a Python sequence of :class:`int`\s (as pointer addresses), or - ``None`` for NULL. sizes (object): Array of sizes for memory prefetch operations. It must be: - a Python sequence of ``size_t``, or - ``None`` for NULL. prefetch_locs (MemLocation): Array of locations to prefetch to. It must be: - a :class:`MemLocation`, or - ``None`` for NULL. prefetch_loc_idxs (object): Array of indices to specify which operands each entry in the ``prefetch_locs`` array applies to. The locations specified in prefetch_locs[k] will be applied to copies starting from prefetch_loc_idxs[k] through prefetch_loc_idxs[k+1] - 1. Also prefetch_locs[``len(prefetch_locs)`` - 1] will apply to prefetches starting from prefetch_loc_idxs[``len(prefetch_locs)`` - 1] through ``len(dptrs)`` - 1. It must be: - a Python sequence of ``size_t``, or - ``None`` for NULL. flags (unsigned long long): Flags reserved for future use. Must be zero. stream (intptr_t): The stream to enqueue the operations in. Must not be legacy NULL stream. .. seealso:: `cudaMemPrefetchBatchAsync` """ cdef _cyb_nullable_unique_ptr[ _cyb_vector[void*] ] _dptrs_ if isinstance(dptrs, int): raise TypeError( "dptrs must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _dptrs_len_ = 0 _cyb_get_resource_ptrs[void](_dptrs_, dptrs, NULL) if _dptrs_.get() != NULL: _dptrs_len_ = _dptrs_.get().size() cdef _cyb_nullable_unique_ptr[ _cyb_vector[size_t] ] _sizes_ if isinstance(sizes, int): raise TypeError( "sizes must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _sizes_len_ = 0 _cyb_get_resource_ptr[size_t](_sizes_, sizes, NULL) if _sizes_.get() != NULL: _sizes_len_ = _sizes_.get().size() cdef intptr_t _prefetch_locs_ptr_ = 0 cdef Py_ssize_t _prefetch_locs_len_ = 0 if prefetch_locs is None: pass else: (prefetch_locs) _prefetch_locs_ptr_ = int(prefetch_locs) _prefetch_locs_len_ = len(prefetch_locs) cdef _cyb_nullable_unique_ptr[ _cyb_vector[size_t] ] _prefetch_loc_idxs_ if isinstance(prefetch_loc_idxs, int): raise TypeError( "prefetch_loc_idxs must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _prefetch_loc_idxs_len_ = 0 _cyb_get_resource_ptr[size_t](_prefetch_loc_idxs_, prefetch_loc_idxs, NULL) if _prefetch_loc_idxs_.get() != NULL: _prefetch_loc_idxs_len_ = _prefetch_loc_idxs_.get().size() cdef Py_ssize_t _count_length_ = 0 cdef bint _count_is_set_ = False if dptrs is not None: _count_length_ = _cyb_check_same_length(_count_is_set_, _count_length_, _dptrs_len_, "dptrs", "dptrs, sizes") _count_is_set_ = True if sizes is not None: _count_length_ = _cyb_check_same_length(_count_is_set_, _count_length_, _sizes_len_, "sizes", "dptrs, sizes") _count_is_set_ = True cdef size_t count = _count_length_ if count != _count_length_: raise OverflowError( f"The length of (dptrs, sizes), {_count_length_}, does not fit in 'count' (a size_t)" ) cdef Py_ssize_t _num_prefetch_locs_length_ = 0 cdef bint _num_prefetch_locs_is_set_ = False if prefetch_locs is not None: _num_prefetch_locs_length_ = _cyb_check_same_length(_num_prefetch_locs_is_set_, _num_prefetch_locs_length_, _prefetch_locs_len_, "prefetch_locs", "prefetch_locs, prefetch_loc_idxs") _num_prefetch_locs_is_set_ = True if prefetch_loc_idxs is not None: _num_prefetch_locs_length_ = _cyb_check_same_length(_num_prefetch_locs_is_set_, _num_prefetch_locs_length_, _prefetch_loc_idxs_len_, "prefetch_loc_idxs", "prefetch_locs, prefetch_loc_idxs") _num_prefetch_locs_is_set_ = True cdef size_t num_prefetch_locs = _num_prefetch_locs_length_ if num_prefetch_locs != _num_prefetch_locs_length_: raise OverflowError( f"The length of (prefetch_locs, prefetch_loc_idxs), {_num_prefetch_locs_length_}, does not fit in 'numPrefetchLocs' (a size_t)" ) with nogil: __status__ = cudaMemPrefetchBatchAsync((_dptrs_.data()), (_sizes_.data()), count, _prefetch_locs_ptr_, (_prefetch_loc_idxs_.data()), num_prefetch_locs, flags, stream) check_status(__status__) cpdef mem_discard_batch_async(dptrs, sizes, unsigned long long flags, intptr_t stream): """Performs a batch of memory discards asynchronously. Performs a batch of memory discards. The batch as a whole executes in stream order but operations within a batch are not guaranteed to execute in any specific order. All devices in the system must have a non-zero value for the device attribute ``cudaDevAttrConcurrentManagedAccess`` otherwise the API will return an error. Discarding a memory range informs the driver that the contents of that range are no longer useful. Discarding memory ranges allows the driver to optimize certain data migrations and can also help reduce memory pressure. This operation can be undone on any part of the range by either writing to it or prefetching it via ``cudaMemPrefetchAsync`` or ``cudaMemPrefetchBatchAsync``. Reading from a discarded range, without a subsequent write or prefetch to that part of the range, will return an indeterminate value. Note that any reads, writes or prefetches to any part of the memory range that occur simultaneously with the discard operation result in undefined behavior. Performs memory discard on address ranges specified in ``dptrs`` and ``sizes``. Both arrays must be of the same length as specified by ``len(dptrs)``. Each memory range specified must refer to managed memory allocated via ``cudaMallocManaged`` or declared via managed variables or it may also refer to system-allocated memory when all devices have a non-zero value for ``cudaDevAttrPageableMemoryAccess``. Args: dptrs (object): Array of pointers to be discarded. It must be: - a Python sequence of :class:`int`\s (as pointer addresses), or - ``None`` for NULL. sizes (object): Array of sizes for memory discard operations. It must be: - a Python sequence of ``size_t``, or - ``None`` for NULL. flags (unsigned long long): Flags reserved for future use. Must be zero. stream (intptr_t): The stream to enqueue the operations in. Must not be legacy NULL stream. .. seealso:: `cudaMemDiscardBatchAsync` """ cdef _cyb_nullable_unique_ptr[ _cyb_vector[void*] ] _dptrs_ if isinstance(dptrs, int): raise TypeError( "dptrs must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _dptrs_len_ = 0 _cyb_get_resource_ptrs[void](_dptrs_, dptrs, NULL) if _dptrs_.get() != NULL: _dptrs_len_ = _dptrs_.get().size() cdef _cyb_nullable_unique_ptr[ _cyb_vector[size_t] ] _sizes_ if isinstance(sizes, int): raise TypeError( "sizes must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _sizes_len_ = 0 _cyb_get_resource_ptr[size_t](_sizes_, sizes, NULL) if _sizes_.get() != NULL: _sizes_len_ = _sizes_.get().size() cdef Py_ssize_t _count_length_ = 0 cdef bint _count_is_set_ = False if dptrs is not None: _count_length_ = _cyb_check_same_length(_count_is_set_, _count_length_, _dptrs_len_, "dptrs", "dptrs, sizes") _count_is_set_ = True if sizes is not None: _count_length_ = _cyb_check_same_length(_count_is_set_, _count_length_, _sizes_len_, "sizes", "dptrs, sizes") _count_is_set_ = True cdef size_t count = _count_length_ if count != _count_length_: raise OverflowError( f"The length of (dptrs, sizes), {_count_length_}, does not fit in 'count' (a size_t)" ) with nogil: __status__ = cudaMemDiscardBatchAsync((_dptrs_.data()), (_sizes_.data()), count, flags, stream) check_status(__status__) cpdef mem_discard_and_prefetch_batch_async(dptrs, sizes, prefetch_locs, prefetch_loc_idxs, unsigned long long flags, intptr_t stream): """Performs a batch of memory discards and prefetches asynchronously. Performs a batch of memory discards followed by prefetches. The batch as a whole executes in stream order but operations within a batch are not guaranteed to execute in any specific order. All devices in the system must have a non-zero value for the device attribute ``cudaDevAttrConcurrentManagedAccess`` otherwise the API will return an error. Calling ``cudaMemDiscardAndPrefetchBatchAsync`` is semantically equivalent to calling ``cudaMemDiscardBatchAsync`` followed by ``cudaMemPrefetchBatchAsync``, but is more optimal. For more details on what discarding and prefetching imply, please refer to ``cudaMemDiscardBatchAsync`` and ``cudaMemPrefetchBatchAsync`` respectively. Note that any reads, writes or prefetches to any part of the memory range that occur simultaneously with this combined discard+prefetch operation result in undefined behavior. Performs memory discard and prefetch on address ranges specified in ``dptrs`` and ``sizes``. Both arrays must be of the same length as specified by ``len(dptrs)``. Each memory range specified must refer to managed memory allocated via ``cudaMallocManaged`` or declared via managed variables or it may also refer to system-allocated memory when all devices have a non-zero value for ``cudaDevAttrPageableMemoryAccess``. Every operation in the batch has to be associated with a valid location to prefetch the address range to and specified in the ``prefetch_locs`` array. Each entry in this array can apply to more than one operation. This can be done by specifying in the ``prefetch_loc_idxs`` array, the index of the first operation that the corresponding entry in the ``prefetch_locs`` array applies to. Both ``prefetch_locs`` and ``prefetch_loc_idxs`` must be of the same length as specified by ``len(prefetch_locs)``. For example, if a batch has 10 operations listed in dptrs/sizes, the first 6 of which are to be prefetched to one location and the remaining 4 are to be prefetched to another, then ``len(prefetch_locs)`` will be 2, ``prefetch_loc_idxs`` will be {0, 6} and ``prefetch_locs`` will contain the two set of locations. Note the first entry in ``prefetch_loc_idxs`` must always be 0. Also, each entry must be greater than the previous entry and the last entry should be less than ``len(dptrs)``. Furthermore, ``len(prefetch_locs)`` must be lesser than or equal to ``len(dptrs)``. Args: dptrs (object): Array of pointers to be discarded. It must be: - a Python sequence of :class:`int`\s (as pointer addresses), or - ``None`` for NULL. sizes (object): Array of sizes for memory discard operations. It must be: - a Python sequence of ``size_t``, or - ``None`` for NULL. prefetch_locs (MemLocation): Array of locations to prefetch to. It must be: - a :class:`MemLocation`, or - ``None`` for NULL. prefetch_loc_idxs (object): Array of indices to specify which operands each entry in the ``prefetch_locs`` array applies to. The locations specified in prefetch_locs[k] will be applied to operations starting from prefetch_loc_idxs[k] through prefetch_loc_idxs[k+1] - 1. Also prefetch_locs[``len(prefetch_locs)`` - 1] will apply to copies starting from prefetch_loc_idxs[``len(prefetch_locs)`` - 1] through ``len(dptrs)`` - 1. It must be: - a Python sequence of ``size_t``, or - ``None`` for NULL. flags (unsigned long long): Flags reserved for future use. Must be zero. stream (intptr_t): The stream to enqueue the operations in. Must not be legacy NULL stream. .. seealso:: `cudaMemDiscardAndPrefetchBatchAsync` """ cdef _cyb_nullable_unique_ptr[ _cyb_vector[void*] ] _dptrs_ if isinstance(dptrs, int): raise TypeError( "dptrs must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _dptrs_len_ = 0 _cyb_get_resource_ptrs[void](_dptrs_, dptrs, NULL) if _dptrs_.get() != NULL: _dptrs_len_ = _dptrs_.get().size() cdef _cyb_nullable_unique_ptr[ _cyb_vector[size_t] ] _sizes_ if isinstance(sizes, int): raise TypeError( "sizes must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _sizes_len_ = 0 _cyb_get_resource_ptr[size_t](_sizes_, sizes, NULL) if _sizes_.get() != NULL: _sizes_len_ = _sizes_.get().size() cdef intptr_t _prefetch_locs_ptr_ = 0 cdef Py_ssize_t _prefetch_locs_len_ = 0 if prefetch_locs is None: pass else: (prefetch_locs) _prefetch_locs_ptr_ = int(prefetch_locs) _prefetch_locs_len_ = len(prefetch_locs) cdef _cyb_nullable_unique_ptr[ _cyb_vector[size_t] ] _prefetch_loc_idxs_ if isinstance(prefetch_loc_idxs, int): raise TypeError( "prefetch_loc_idxs must be a sequence of the elements or None, not an address, since its length is needed" ) cdef Py_ssize_t _prefetch_loc_idxs_len_ = 0 _cyb_get_resource_ptr[size_t](_prefetch_loc_idxs_, prefetch_loc_idxs, NULL) if _prefetch_loc_idxs_.get() != NULL: _prefetch_loc_idxs_len_ = _prefetch_loc_idxs_.get().size() cdef Py_ssize_t _count_length_ = 0 cdef bint _count_is_set_ = False if dptrs is not None: _count_length_ = _cyb_check_same_length(_count_is_set_, _count_length_, _dptrs_len_, "dptrs", "dptrs, sizes") _count_is_set_ = True if sizes is not None: _count_length_ = _cyb_check_same_length(_count_is_set_, _count_length_, _sizes_len_, "sizes", "dptrs, sizes") _count_is_set_ = True cdef size_t count = _count_length_ if count != _count_length_: raise OverflowError( f"The length of (dptrs, sizes), {_count_length_}, does not fit in 'count' (a size_t)" ) cdef Py_ssize_t _num_prefetch_locs_length_ = 0 cdef bint _num_prefetch_locs_is_set_ = False if prefetch_locs is not None: _num_prefetch_locs_length_ = _cyb_check_same_length(_num_prefetch_locs_is_set_, _num_prefetch_locs_length_, _prefetch_locs_len_, "prefetch_locs", "prefetch_locs, prefetch_loc_idxs") _num_prefetch_locs_is_set_ = True if prefetch_loc_idxs is not None: _num_prefetch_locs_length_ = _cyb_check_same_length(_num_prefetch_locs_is_set_, _num_prefetch_locs_length_, _prefetch_loc_idxs_len_, "prefetch_loc_idxs", "prefetch_locs, prefetch_loc_idxs") _num_prefetch_locs_is_set_ = True cdef size_t num_prefetch_locs = _num_prefetch_locs_length_ if num_prefetch_locs != _num_prefetch_locs_length_: raise OverflowError( f"The length of (prefetch_locs, prefetch_loc_idxs), {_num_prefetch_locs_length_}, does not fit in 'numPrefetchLocs' (a size_t)" ) with nogil: __status__ = cudaMemDiscardAndPrefetchBatchAsync((_dptrs_.data()), (_sizes_.data()), count, _prefetch_locs_ptr_, (_prefetch_loc_idxs_.data()), num_prefetch_locs, flags, stream) check_status(__status__) cpdef intptr_t mem_get_default_mem_pool(location, int type) except? 0: """Returns the default memory pool for a given location and allocation type. The memory location can be of one of ``cudaMemLocationTypeDevice``, ``cudaMemLocationTypeHost``, ``cudaMemLocationTypeHostNuma``, or ``cudaMemLocationTypeDeviceLocalityDomain``. The allocation type can be one of ``cudaMemAllocationTypePinned`` or ``cudaMemAllocationTypeManaged``. When the allocation type is ``cudaMemAllocationTypeManaged``, the location type can also be ``cudaMemLocationTypeNone`` to indicate no preferred location for the managed memory pool. ``cudaMemAllocationTypeManaged`` can not be used with ``cudaMemLocationTypeDeviceLocalityDomain``. In all other cases, the call return ``cudaErrorInvalidValue``. Args: location (intptr_t): Memory location to query the default memory pool of. type (MemAllocationType): Allocation type to query the default memory pool of. Returns: intptr_t: Returned default memory pool. .. seealso:: `cudaMemGetDefaultMemPool` """ cdef intptr_t _location_ptr_ = 0 if location is None else int(location) cdef cudaMemPool_t mem_pool with nogil: __status__ = cudaMemGetDefaultMemPool(&mem_pool, _location_ptr_, type) check_status(__status__) return mem_pool cpdef intptr_t mem_get_mem_pool(location, int type) except? 0: """Gets the current memory pool for a given memory location and allocation type. The memory location can be of one of ``cudaMemLocationTypeDevice``, ``cudaMemLocationTypeHost``, ``cudaMemLocationTypeHostNuma``, or ``cudaMemLocationTypeDeviceLocalityDomain``. The allocation type can be one of ``cudaMemAllocationTypePinned`` or ``cudaMemAllocationTypeManaged``. When the allocation type is ``cudaMemAllocationTypeManaged``, the location type can also be ``cudaMemLocationTypeNone`` to indicate no preferred location for the managed memory pool. ``cudaMemAllocationTypeManaged`` can not be used with ``cudaMemLocationTypeDeviceLocalityDomain``. In all other cases, the call return ``cudaErrorInvalidValue``. Returns the last pool provided to ``cudaMemSetMemPool`` or ``cudaDeviceSetMemPool`` for this location and allocation type or the location's default memory pool if ``cudaMemSetMemPool`` or ``cudaDeviceSetMemPool`` for that allocType and location has never been called. By default the current mempool of a location is the default mempool for a device that can be obtained via cudaMemGetDefaultMemPool Otherwise the returned pool must have been set with ``cudaDeviceSetMemPool``. Args: location (intptr_t): Memory location to query the current memory pool of. type (MemAllocationType): Allocation type to query the current memory pool of. Returns: intptr_t: Returned current memory pool. .. seealso:: `cudaMemGetMemPool` """ cdef intptr_t _location_ptr_ = 0 if location is None else int(location) cdef cudaMemPool_t mem_pool with nogil: __status__ = cudaMemGetMemPool(&mem_pool, _location_ptr_, type) check_status(__status__) return mem_pool cpdef mem_set_mem_pool(location, int type, intptr_t mem_pool): """Sets the current memory pool for a memory location and allocation type. The memory location can be of one of ``cudaMemLocationTypeDevice``, ``cudaMemLocationTypeHost`` ``cudaMemLocationTypeHostNuma``, or ``cudaMemLocationTypeDeviceLocalityDomain``. The allocation type can be one of ``cudaMemAllocationTypePinned`` or ``cudaMemAllocationTypeManaged``. When the allocation type is ``cudaMemAllocationTypeManaged``, the location type can also be ``cudaMemLocationTypeNone`` to indicate no preferred location for the managed memory pool. ``cudaMemAllocationTypeManaged`` can not be used with ``cudaMemLocationTypeDeviceLocalityDomain``. In all other cases, the call return ``cudaErrorInvalidValue``. When a memory pool is set as the current memory pool, the location parameter should be the same as the location of the pool. If the location type or index don't match, the call returns ``cudaErrorInvalidValue``. The type of memory pool should also match the parameter allocType. Else the call returns ``cudaErrorInvalidValue``. By default, a memory location's current memory pool is its default memory pool. If the location type is ``cudaMemLocationTypeDevice`` and the allocation type is ``cudaMemAllocationTypePinned``, then this API is the equivalent of calling ``cudaDeviceSetMemPool`` with the location id as the device. For further details on the implications, please refer to the documentation for ``cudaDeviceSetMemPool``. Args: location (intptr_t): Memory location to set the current memory pool of. type (MemAllocationType): Allocation type to set the current memory pool of. mem_pool (intptr_t): Memory pool to set as the current memory pool. .. note:: Use ``cudaMallocFromPoolAsync`` to specify asynchronous allocations from a device different than the one the stream runs on. .. seealso:: `cudaMemSetMemPool` """ cdef intptr_t _location_ptr_ = 0 if location is None else int(location) with nogil: __status__ = cudaMemSetMemPool(_location_ptr_, type, mem_pool) check_status(__status__) cpdef intptr_t logs_register_callback(intptr_t callback_func, intptr_t user_data) except? 0: """Register a callback function to receive error log messages. Args: callback_func (intptr_t): The function to register as a callback. user_data (intptr_t): A generic pointer to user data. This is passed into the callback function. Returns: intptr_t: Optional location to store the callback handle after it is registered. .. seealso:: `cudaLogsRegisterCallback` """ cdef cudaLogsCallbackHandle callback_out with nogil: __status__ = cudaLogsRegisterCallback(callback_func, user_data, &callback_out) check_status(__status__) return callback_out cpdef logs_unregister_callback(intptr_t callback): """Unregister a log message callback. Args: callback (intptr_t): The callback instance to unregister from receiving log messages. .. seealso:: `cudaLogsUnregisterCallback` """ with nogil: __status__ = cudaLogsUnregisterCallback(callback) check_status(__status__) cpdef unsigned int logs_current(unsigned int flags) except? 0: """Sets log iterator to point to the end of log buffer, where the next message would be written. Args: flags (unsigned int): Reserved for future use, must be 0. Returns: unsigned int: Location to store an iterator to the current tail of the logs. .. seealso:: `cudaLogsCurrent` """ cdef cudaLogIterator iterator_out with nogil: __status__ = cudaLogsCurrent(&iterator_out, flags) check_status(__status__) return iterator_out cpdef logs_dump_to_memory(intptr_t iterator, intptr_t buffer, intptr_t size, unsigned int flags): """Dump accumulated driver logs into a buffer. Logs generated by the driver are stored in an internal buffer and can be copied out using this API. This API dumps driver logs from ``iterator`` into ``buffer`` up to the size specified in ``*size``. The driver will always null terminate the buffer but there will not be a null character between log entries, only a newline \n. The driver will then return the actual number of bytes written in ``*size``, excluding the null terminator. If there are no messages to dump, ``*size`` will be set to 0 and the function will return ``CUDA_SUCCESS``. If the provided ``buffer`` is not large enough to hold any messages, ``*size`` will be set to 0 and the function will return ``CUDA_ERROR_INVALID_VALUE``. Args: iterator (intptr_t): Optional auto-advancing iterator specifying the starting log to read. NULL value dumps all logs. buffer (intptr_t): Pointer to dump logs. size (intptr_t): See description. flags (unsigned int): Reserved for future use, must be 0. .. note:: ``iterator`` is auto-advancing. Dumping logs will update the value of ``iterator`` to receive the next generated log. .. note:: The driver reserves limited memory for storing logs. The maximum size of the buffer is 25600 bytes. The oldest logs may be overwritten and become unrecoverable. An indication will appear in the destination outupt if the logs have been truncated. Call dump after each failed API to mitigate this risk. .. note:: If the provided value in ``*size`` is not large enough to hold all buffered messages, a message will be added at the head of the buffer indicating this. The driver then computes the number of messages it is able to store in ``buffer`` and writes it out. The final message in ``buffer`` will always be the most recent log message as of when the API is called. .. seealso:: `cudaLogsDumpToMemory` """ with nogil: __status__ = cudaLogsDumpToMemory(iterator, buffer, size, flags) check_status(__status__) cpdef intptr_t graph_node_get_containing_graph(intptr_t h_node) except? 0: """Returns the graph that contains a given graph node. Returns the graph that contains ``h_node`` in ``*ph_graph``. If h_node is in a child graph, the child graph it is in is returned. Args: h_node (intptr_t): Node to query. Returns: intptr_t: Pointer to return the containing graph. .. seealso:: `cudaGraphNodeGetContainingGraph` """ cdef cudaGraph_t ph_graph with nogil: __status__ = cudaGraphNodeGetContainingGraph(h_node, &ph_graph) check_status(__status__) return ph_graph cpdef unsigned int graph_node_get_local_id(intptr_t h_node) except? 0: """Returns the node id of a given graph node. Returns the node id of ``h_node`` in ``*node_id``. The node_id matches that referenced by ``cudaGraphDebugDotPrint``. The local node_id and graphId together can uniquely identify the node. Args: h_node (intptr_t): Node to query. Returns: unsigned int: Pointer to return the node_id. .. seealso:: `cudaGraphNodeGetLocalId` """ cdef unsigned int node_id with nogil: __status__ = cudaGraphNodeGetLocalId(h_node, &node_id) check_status(__status__) return node_id cpdef unsigned long long graph_node_get_tools_id(intptr_t h_node) except? 0: """Returns an id used by tools to identify a given node. Args: h_node (intptr_t): Node to query. Returns: unsigned long long: Pointer to return the id used by tools. .. seealso:: `cudaGraphNodeGetToolsId` """ cdef unsigned long long tools_node_id with nogil: __status__ = cudaGraphNodeGetToolsId(h_node, &tools_node_id) check_status(__status__) return tools_node_id cpdef unsigned int graph_get_id(intptr_t h_graph) except? 0: """Returns the id of a given graph. Returns the id of ``h_graph`` in ``*graphId``. The value in ``*graphId`` matches that referenced by ``cudaGraphDebugDotPrint``. Args: h_graph (intptr_t): Graph to query. Returns: unsigned int: Pointer to return the graphId. .. seealso:: `cudaGraphGetId` """ cdef unsigned int graph_id with nogil: __status__ = cudaGraphGetId(h_graph, &graph_id) check_status(__status__) return graph_id cpdef unsigned int graph_exec_get_id(intptr_t h_graph_exec) except? 0: """Returns the id of a given graph exec. Returns the id of ``h_graph_exec`` in ``*graphId``. The value in ``*graphId`` matches that referenced by ``cudaGraphDebugDotPrint``. Args: h_graph_exec (intptr_t): Graph to query. Returns: unsigned int: Pointer to return the graphId. .. seealso:: `cudaGraphExecGetId` """ cdef unsigned int graph_id with nogil: __status__ = cudaGraphExecGetId(h_graph_exec, &graph_id) check_status(__status__) return graph_id cpdef unsigned long long graph_conditional_handle_create_v2(intptr_t graph, intptr_t ctx, unsigned int default_launch_value, unsigned int flags) except? 0: """Create a conditional handle. Creates a conditional handle associated with ``hGraph``. The conditional handle must be associated with a conditional node in this graph or one of its children. Handles not associated with a conditional node may cause graph instantiation to fail. Args: graph (intptr_t): Graph which will contain the conditional node using this handle. ctx (intptr_t): Execution context for the handle and associated conditional node. If NULL, current context will be used. default_launch_value (unsigned int): Optional initial value for the conditional variable. Applied at the beginning of each graph execution if cudaGraphCondAssignDefault is set in ``flags``. flags (unsigned int): Currently must be cudaGraphCondAssignDefault or 0. Returns: unsigned long long: Pointer used to return the handle to the caller. .. seealso:: `cudaGraphConditionalHandleCreate_v2` """ cdef cudaGraphConditionalHandle p_handle_out with nogil: __status__ = cudaGraphConditionalHandleCreate_v2(&p_handle_out, graph, ctx, default_launch_value, flags) check_status(__status__) return p_handle_out cpdef object device_get_dev_resource(int device, int type): """Get device resources. Get the ``typename`` resources available to the ``device``. This may often be the starting point for further partitioning or configuring of resources. Note: The API is not supported on 32-bit platforms. Args: device (int): Device to get resource for. type (DevResourceType): Type of resource to retrieve. Returns: cudaDevResource: Output pointer to a ``cudaDevResource`` structure. .. seealso:: `cudaDeviceGetDevResource` """ cdef DevResource resource_py = DevResource() cdef cudaDevResource *resource = (resource_py._get_ptr()) with nogil: __status__ = cudaDeviceGetDevResource(device, resource, type) check_status(__status__) return resource_py cpdef tuple dev_sm_resource_split_by_count(input, unsigned int flags, unsigned int min_count): """Splits ``cudaDevResourceTypeSm`` resources. Splits ``cudaDevResourceTypeSm`` resources into ``nb_groups``, adhering to the minimum SM count specified in ``min_count`` and the usage flags in ``flags``. If ``result`` is NULL, the API simulates a split and provides the amount of groups that would be created in ``nb_groups``. Otherwise, ``nb_groups`` must point to the amount of elements in ``result`` and on return, the API will overwrite ``nb_groups`` with the amount actually created. The groups are written to the array in ``result``. ``nb_groups`` can be less than the total amount if a smaller number of groups is needed. This API is used to spatially partition the input resource. The input resource needs to come from one of ``cudaDeviceGetDevResource``, or ``cudaExecutionCtxGetDevResource``. A limitation of the API is that the output results cannot be split again without first creating a descriptor and a green context with that descriptor. When creating the groups, the API will take into account the performance and functional characteristics of the input resource, and guarantee a split that will create a disjoint set of symmetrical partitions. This may lead to fewer groups created than purely dividing the total SM count by the ``min_count`` due to cluster requirements or alignment and granularity requirements for the min_count. These requirements can be queried with ``cudaDeviceGetDevResource``, or ``cudaExecutionCtxGetDevResource`` for ``cudaDevResourceTypeSm``, using the ``minSmPartitionSize`` and ``smCoscheduledAlignment`` fields to determine minimum partition size and alignment granularity, respectively. The ``remainder`` set does not have the same functional or performance guarantees as the groups in ``result``. Its use should be carefully planned and future partitions of the ``remainder`` set are discouraged. The following flags are supported:. - ``cudaDevSmResourceSplitIgnoreSmCoscheduling`` : Lower the minimum SM count and alignment, and treat each SM independent of its hierarchy. This allows more fine grained partitions but at the cost of advanced features (such as large clusters on compute capability 9.0+). - ``cudaDevSmResourceSplitMaxPotentialClusterSize`` : Compute Capability 9.0+ only. Attempt to create groups that may allow for maximally sized thread clusters. This can be queried post green context creation using ``cudaOccupancyMaxPotentialClusterSize``. A successful API call must either have:. - A valid array of ``result`` pointers of size passed in ``nb_groups``, with ``input`` of type ``cudaDevResourceTypeSm``. Value of ``min_count`` must be between 0 and the SM count specified in ``input``. ``remaining`` may be NULL. - NULL passed in for ``result``, with a valid integer pointer in ``nb_groups`` and ``input`` of type ``cudaDevResourceTypeSm``. Value of ``min_count`` must be between 0 and the SM count specified in ``input``. ``remaining`` may be NULL. This queries the number of groups that would be created by the API. Note: The API is not supported on 32-bit platforms. Args: input (intptr_t): Input SM resource to be split. Must be a valid ``cudaDevSmResource`` resource. flags (unsigned int): Flags specifying how these partitions are used or which constraints to abide by when splitting the input. Zero is valid for default behavior. min_count (unsigned int): Minimum number of SMs required. Returns: A 2-tuple containing: - cudaDevResource: Output array of ``cudaDevResource`` resources. Can be NULL to query the number of groups. - cudaDevResource: If the input resource cannot be cleanly split among ``nb_groups``, the remaining is placed in here. Can be ommitted (NULL) if the user does not need the remaining set. .. seealso:: `cudaDevSmResourceSplitByCount` """ cdef intptr_t _input_ptr_ = 0 if input is None else int(input) cdef unsigned int[1] nb_groups = [0] cdef DevResource remaining_py = DevResource() cdef cudaDevResource *remaining = (remaining_py._get_ptr()) with nogil: __status__ = cudaDevSmResourceSplitByCount(NULL, nb_groups, _input_ptr_, remaining, flags, min_count) check_status_size(__status__) cdef DevResource result = DevResource(nb_groups[0]) cdef cudaDevResource *result_ptr = (result._get_ptr()) if not (nb_groups[0] == 0): with nogil: __status__ = cudaDevSmResourceSplitByCount(result_ptr, nb_groups, _input_ptr_, remaining, flags, min_count) check_status(__status__) return (result[:nb_groups[0]], remaining_py) cpdef tuple dev_sm_resource_split(input, unsigned int flags, group_params): """Splits a ``cudaDevResourceTypeSm`` resource into structured groups. This API will split a resource of ``cudaDevResourceTypeSm`` into ``len(group_params)`` structured device resource groups (the ``result`` array), as well as an optional ``remainder``, according to a set of requirements specified in the ``group_params`` array. The term “structured” is a trait that specifies the ``result`` has SMs that are co-scheduled together. This co-scheduling can be specified via the ``coscheduledSmCount`` field of the ``group_params`` structure, while the ``smCount`` will specify how many SMs are required in total for that result. The remainder is always “unstructured”, it does not have any set guarantees with respect to co-scheduling and those properties will need to either be queried via the occupancy set of APIs or further split into structured groups by this API. The API has a discovery mode for use cases where it is difficult to know ahead of time what the SM count should be. Discovery happens when the ``smCount`` field of a given ``group_params`` array entry is set to 0 - the smCount will be filled in by the API with the derived SM count according to the provided ``group_params`` fields and constraints. Discovery can be used with both a valid result array and with a NULL ``result`` pointer value. The latter is useful in situations where the smCount will end up being zero, which is an invalid value to create a result entry with, but allowed for discovery purposes when the ``result`` is NULL. The ``group_params`` array is evaluated from index 0 to ``len(group_params)`` - 1. For each index in the ``group_params`` array, the API will evaluate which SMs may be a good fit based on constraints and assign those SMs to ``result``. This evaluation order is important to consider when using discovery mode, as it helps discover the remaining SMs. For a valid call:. - ``result`` should point to a ``cudaDevResource`` array of size ``len(group_params)``, or alternatively, may be NULL, if the developer wishes for only the group_params entries to be updated. - ``input`` should be a valid ``cudaDevResourceTypeSm`` resource that originates from querying the execution context, or device. - The ``remainder`` group may be NULL. - There are no API ``flags`` at this time, so the value passed in should be 0. - A ``cudaDevSmResourceGroupParams`` array of size ``len(group_params)``. Each entry must be zero-initialized. - ``smCount:`` must be either 0 or in the range of [2,inputSmCount] where inputSmCount is the amount of SMs the ``input`` resource has. ``smCount`` must be a multiple of 2, as well as a multiple of ``coscheduledSmCount``. When assigning SMs to a group (and if results are expected by having the ``result`` parameter set), ``smCount`` cannot end up with 0 or a value less than ``coscheduledSmCount`` otherwise ``cudaErrorInvalidResourceConfiguration`` will be returned. - ``coscheduledSmCount:`` allows grouping SMs together in order to be able to launch clusters on Compute Architecture 9.0+. The default value may be queried from the device’s ``cudaDevResourceTypeSm`` resource (8 on Compute Architecture 9.0+ and 2 otherwise). The maximum is 32 on Compute Architecture 9.0+ and 2 otherwise. - ``preferredCoscheduledSmCount:`` Attempts to merge ``coscheduledSmCount`` groups into larger groups, in order to make use of ``preferredClusterDimensions`` on Compute Architecture 10.0+. The default value is set to ``coscheduledSmCount``. - ``flags:``. - ``cudaDevSmResourceGroupBackfill:`` Treats constraints as a hint, ignoring them if necessary to reach the requested ``smCount``. Lets ``smCount`` be a non-multiple of ``coscheduledSmCount``, filling the difference between SM count and already assigned co-scheduled groupings with other SMs. This lets any resulting group behave similar to the ``remainder`` group for example. When used with ``cudaDevSmResourceGroupLocalityDomainId``, backfill fills up to the requested ``smCount`` using the target locality domain first, then SMs not attributed to any locality domain, then SMs from other locality domains. If no SMs can be found in the requested locality domain, ``cudaErrorInvalidResourceConfiguration`` is returned. When used with ``cudaDevSmResourceGroupLocalityDomainSupplementalSms``, backfill follows the same behavior after first consuming all SMs from the target locality domain. - ``cudaDevSmResourceGroupLocalityDomainId:`` Specifies that the SM partition should be localized to the specified ``localityDomainId``. - ``cudaDevSmResourceGroupLocalityDomainSupplementalSms:`` Modifier to ``cudaDevSmResourceGroupLocalityDomainId`` which allows selection of SMs in the locality domain exceeding the ``cudaDeviceAttr.cudaDevAttrLocalityDomainMultiprocessorCount``. - ``localityDomainId:`` Specifies the locality domain that the partitioned SMs must be located on. Only valid when ``cudaDevSmResourceGroupLocalityDomainId`` is set in flags. The special value ``cudaDevSmResourceGroupLocalityDomainIdAny`` specifies that the partitioned SMs must be selected from the union of all available locality domains in the input SM resource. Example params and their effect:. A group_params array element is defined in the following order:. \*\*View CUDA Toolkit Documentation for a C++ code example*\*. \*\*View CUDA Toolkit Documentation for a C++ code example*\*. \*\*View CUDA Toolkit Documentation for a C++ code example*\*. \*\*View CUDA Toolkit Documentation for a C++ code example*\*. The difference between a catch-all param group as the last entry and the remainder is in two aspects:. - The remainder may be NULL / _TYPE_INVALID (if there are no SMs remaining), while a result group must always be valid. - The remainder does not have a structure, while the result group will always need to adhere to a structure of coscheduledSmCount (even if its just 2), and therefore must always have enough coscheduled SMs to cover that requirement (even with the ``cudaDevSmResourceGroupBackfill`` flag enabled). Splitting an input into N groups, can be accomplished by repeatedly splitting off 1 group and re-splitting the remainder (a bisect operation). However, it's recommended to accomplish this with a single call wherever possible. Args: input (intptr_t): Input SM resource to be split. Must be a valid ``cudaDevResourceTypeSm`` resource. flags (unsigned int): Flags specifying how the API should behave. The value should be 0 for now. group_params (DevSmResourceGroupParams): Description of how the SMs should be split and assigned to the corresponding result entry. It must be: - a :class:`DevSmResourceGroupParams`, or - ``None`` for NULL. Returns: A 2-tuple containing: - cudaDevResource: Output array of ``cudaDevResource`` resources. Can be NULL, alongside an smCount of 0, for discovery purpose. - cudaDevResource: If splitting the input resource leaves any SMs, the remainder is placed in here. .. seealso:: `cudaDevSmResourceSplit` """ cdef intptr_t _input_ptr_ = 0 if input is None else int(input) cdef intptr_t _group_params_ptr_ = 0 cdef Py_ssize_t _group_params_len_ = 0 if group_params is None: pass else: (group_params) _group_params_ptr_ = int(group_params) _group_params_len_ = len(group_params) cdef Py_ssize_t _nb_groups_length_ = 0 cdef bint _nb_groups_is_set_ = False if group_params is not None: _nb_groups_length_ = _cyb_check_same_length(_nb_groups_is_set_, _nb_groups_length_, _group_params_len_, "group_params", "group_params") _nb_groups_is_set_ = True cdef unsigned int nb_groups = _nb_groups_length_ if nb_groups != _nb_groups_length_: raise OverflowError( f"The length of (group_params), {_nb_groups_length_}, does not fit in 'nbGroups' (a unsigned int)" ) cdef DevResource result = DevResource(nb_groups) cdef cudaDevResource *result_ptr = (result._get_ptr()) cdef DevResource remainder_py = DevResource() cdef cudaDevResource *remainder = (remainder_py._get_ptr()) with nogil: __status__ = cudaDevSmResourceSplit(result_ptr, nb_groups, _input_ptr_, remainder, flags, _group_params_ptr_) check_status(__status__) return (result, remainder_py) cpdef intptr_t dev_resource_generate_desc(resources) except? 0: """Generate a resource descriptor. Generates a single resource descriptor with the set of resources specified in ``resources``. The generated resource descriptor is necessary for the creation of green contexts via the ``cudaGreenCtxCreate`` API. Resources of the same type can be passed in, provided they meet the requirements as noted below. A successful API call must have:. - A valid output pointer for the ``ph_desc`` descriptor as well as a valid array of ``resources`` pointers, with the array size passed in ``len(resources)``. If multiple resources are provided in ``resources``, the device they came from must be the same, otherwise ``cudaErrorInvalidResourceConfiguration`` is returned. If multiple resources are provided in ``resources`` and they are of type ``cudaDevResourceTypeSm``, they must be outputs (whether ``result`` or ``remaining``) from the same split API instance and have the same smCoscheduledAlignment values, otherwise ``cudaErrorInvalidResourceConfiguration`` is returned. Note: The API is not supported on 32-bit platforms. Args: resources (DevResource): Array of resources to be included in the descriptor. It must be: - a :class:`DevResource`, or - ``None`` for NULL. Returns: intptr_t: Output descriptor. .. seealso:: `cudaDevResourceGenerateDesc` """ cdef intptr_t _resources_ptr_ = 0 cdef Py_ssize_t _resources_len_ = 0 if resources is None: pass else: (resources) _resources_ptr_ = int(resources) _resources_len_ = len(resources) cdef Py_ssize_t _nb_resources_length_ = 0 cdef bint _nb_resources_is_set_ = False if resources is not None: _nb_resources_length_ = _cyb_check_same_length(_nb_resources_is_set_, _nb_resources_length_, _resources_len_, "resources", "resources") _nb_resources_is_set_ = True cdef unsigned int nb_resources = _nb_resources_length_ if nb_resources != _nb_resources_length_: raise OverflowError( f"The length of (resources), {_nb_resources_length_}, does not fit in 'nbResources' (a unsigned int)" ) cdef cudaDevResourceDesc_t ph_desc with nogil: __status__ = cudaDevResourceGenerateDesc(&ph_desc, _resources_ptr_, nb_resources) check_status(__status__) return ph_desc cpdef intptr_t green_ctx_create(intptr_t desc, int device, unsigned int flags) except? 0: """Creates a green context with a specified set of resources. This API creates a green context with the resources specified in the descriptor ``desc`` and returns it in the handle represented by ``ph_ctx``. This API retains the device’s primary context for the lifetime of the green context. The primary context will be released when the green context is destroyed. To avoid the overhead of repeated initialization and teardown, it is recommended to explicitly initialize the device's primary context ahead of time using ``cudaInitDevice``. This ensures that the primary context remains initialized throughout the program’s lifetime, minimizing overhead during green context creation and destruction. The API does not create a default stream for the green context. Developers are expected to create streams explicitly using ``cudaExecutionCtxStreamCreate`` to submit work to the green context. Note: The API is not supported on 32-bit platforms. Args: desc (intptr_t): Descriptor generated via ``cudaDevResourceGenerateDesc`` which contains the set of resources to be used. device (int): Device on which to create the green context. flags (unsigned int): Green context creation flags. Must be 0, currently reserved for future use. Returns: intptr_t: Pointer for the output handle to the green context. .. seealso:: `cudaGreenCtxCreate` """ cdef cudaExecutionContext_t ph_ctx with nogil: __status__ = cudaGreenCtxCreate(&ph_ctx, desc, device, flags) check_status(__status__) return ph_ctx cpdef execution_ctx_destroy(intptr_t ctx): """Destroy a execution context. Destroys the specified execution context ``ctx``. It is the responsibility of the caller to ensure that no API call issues using ``ctx`` while :func:`execution_ctx_destroy` is executing or subsequently. If ``ctx`` is a green context, any resources provisioned for it (that were initially available via the resource descriptor) are released as well. The API does not destroy streams created via ``cudaExecutionCtxStreamCreate``. Users are expected to destroy these streams explicitly using ``cudaStreamDestroy`` to avoid resource leaks. Once the execution context is destroyed, any subsequent API calls involving these streams will return ``cudaErrorStreamDetached`` with the exception of the following APIs:. - ``cudaStreamDestroy``. Note this is only supported on CUDA drivers 13.1 and above. Additionally, the API will invalidate all active captures on these streams. Passing in a ``ctx`` that was not explicitly created via CUDA Runtime APIs is not allowed and will result in undefined behavior. Args: ctx (intptr_t): Execution context to destroy (required parameter, see note below). .. seealso:: `cudaExecutionCtxDestroy` """ with nogil: __status__ = cudaExecutionCtxDestroy(ctx) check_status(__status__) cpdef object execution_ctx_get_dev_resource(intptr_t ctx, int type): """Get context resources. Get the ``typename`` resources available to context represented by ``ctx``. Note: The API is not supported on 32-bit platforms. Args: ctx (intptr_t): Execution context to get resource for (required parameter, see note below). type (DevResourceType): Type of resource to retrieve. Returns: cudaDevResource: Output pointer to a ``cudaDevResource`` structure. .. seealso:: `cudaExecutionCtxGetDevResource` """ cdef DevResource resource_py = DevResource() cdef cudaDevResource *resource = (resource_py._get_ptr()) with nogil: __status__ = cudaExecutionCtxGetDevResource(ctx, resource, type) check_status(__status__) return resource_py cpdef int execution_ctx_get_device(intptr_t ctx) except? -1: """Returns the device handle for the execution context. Returns in ``*device`` the handle of the specified execution context's device. The execution context should not be NULL. Args: ctx (intptr_t): Execution context for which to obtain the device (required parameter, see note below). Returns: int: Returned device handle for the specified execution context. .. seealso:: `cudaExecutionCtxGetDevice` """ cdef int device with nogil: __status__ = cudaExecutionCtxGetDevice(&device, ctx) check_status(__status__) return device cpdef unsigned long long execution_ctx_get_id(intptr_t ctx) except? 0: """Returns the unique Id associated with the execution context supplied. Returns in ``ctx_id`` the unique Id which is associated with a given context. The Id is unique for the life of the program for this instance of CUDA. The execution context should not be NULL. Args: ctx (intptr_t): Context for which to obtain the Id (required parameter, see note below). Returns: unsigned long long: Pointer to store the Id of the context. .. seealso:: `cudaExecutionCtxGetId` """ cdef unsigned long long ctx_id with nogil: __status__ = cudaExecutionCtxGetId(ctx, &ctx_id) check_status(__status__) return ctx_id cpdef intptr_t execution_ctx_stream_create(intptr_t ctx, unsigned int flags, int priority) except? 0: """Creates a stream and initializes it for the given execution context. The API creates a CUDA stream with the specified ``flags`` and ``priority``, initializing it with resources as defined at the time of creating the specified ``ctx``. Additionally, the API also enables work submitted to to the stream to be tracked under ``ctx``. The supported values for ``flags`` are:. - ``cudaStreamDefault``: Default stream creation flag. This would be ``cudaStreamNonBlocking`` for streams created on a green context. - ``cudaStreamNonBlocking``: Specifies that work running in the created stream may run concurrently with work in stream 0 (the NULL stream), and that the created stream should perform no implicit synchronization with stream 0. Specifying ``priority`` affects the scheduling priority of work in the stream. Priorities provide a hint to preferentially run work with higher priority when possible, but do not preempt already-running work or provide any other functional guarantee on execution order. ``priority`` follows a convention where lower numbers represent higher priorities. '0' represents default priority. The range of meaningful numerical priorities can be queried using ``cudaDeviceGetStreamPriorityRange``. If the specified priority is outside the numerical range returned by ``cudaDeviceGetStreamPriorityRange``, it will automatically be clamped to the lowest or the highest number in the range. Args: ctx (intptr_t): Execution context to initialize the stream with (required parameter, see note below). flags (unsigned int): Flags for stream creation. priority (int): Stream priority. Returns: intptr_t: Returned stream handle. .. note:: In the current implementation, only compute kernels launched in priority streams are affected by the stream's priority. Stream priorities have no effect on host-to-device and device-to-host memory operations. .. seealso:: `cudaExecutionCtxStreamCreate` """ cdef cudaStream_t ph_stream with nogil: __status__ = cudaExecutionCtxStreamCreate(&ph_stream, ctx, flags, priority) check_status(__status__) return ph_stream cpdef execution_ctx_synchronize(intptr_t ctx): """Block for the specified execution context's tasks to complete. Blocks until the specified execution context has completed all preceding requested tasks. If the specified execution context is the device (primary) context obtained via ``cudaDeviceGetExecutionCtx``, green contexts that have been created on the device will also be synchronized. The API returns an error if one of the preceding tasks failed. Args: ctx (intptr_t): Execution context to synchronize (required parameter, see note below). .. seealso:: `cudaExecutionCtxSynchronize` """ with nogil: __status__ = cudaExecutionCtxSynchronize(ctx) check_status(__status__) cpdef object stream_get_dev_resource(intptr_t h_stream, int type): """Get stream resources. Get the ``typename`` resources available to the ``h_stream`` and store them in ``resource``. Note: The API will return ``cudaErrorInvalidResourceType`` is ``typename`` is ``cudaDevResourceTypeWorkqueueConfig`` or ``cudaDevResourceTypeWorkqueue``. Args: h_stream (intptr_t): Stream to get resource for. type (DevResourceType): Type of resource to retrieve. Returns: cudaDevResource: Output pointer to a ``cudaDevResource`` structure. .. seealso:: `cudaStreamGetDevResource` """ cdef DevResource resource_py = DevResource() cdef cudaDevResource *resource = (resource_py._get_ptr()) with nogil: __status__ = cudaStreamGetDevResource(h_stream, resource, type) check_status(__status__) return resource_py cpdef execution_ctx_record_event(intptr_t ctx, intptr_t event): """Records an event for the specified execution context. Captures in ``event`` all the activities of the execution context ``ctx`` at the time of this call. ``event`` and ``ctx`` must be from the same CUDA device, otherwise ``cudaErrorInvalidHandle`` will be returned. Calls such as :func:`event_query` or :func:`execution_ctx_wait_event` will then examine or wait for completion of the work that was captured. Uses of ``ctx`` after this call do not modify ``event``. If the execution context passed to ``ctx`` is the device (primary) context obtained via :func:`device_get_execution_ctx`, ``event`` will capture all the activities of the green contexts created on the device as well. Args: ctx (intptr_t): Execution context to record event for (required parameter, see note below). event (intptr_t): Event to record. .. note:: The API will return ``cudaErrorStreamCaptureUnsupported`` if the specified execution context ``ctx`` has a stream in the capture mode. In such a case, the call will invalidate all the conflicting captures. .. seealso:: `cudaExecutionCtxRecordEvent` """ with nogil: __status__ = cudaExecutionCtxRecordEvent(ctx, event) check_status(__status__) cpdef execution_ctx_wait_event(intptr_t ctx, intptr_t event): """Make an execution context wait on an event. Makes all future work submitted to execution context ``ctx`` wait for all work captured in ``event``. The synchronization will be performed on the device and will not block the calling CPU thread. See :func:`execution_ctx_record_event` for details on what is captured by an event. If the execution context passed to ``ctx`` is the device (primary) context obtained via :func:`device_get_execution_ctx`, all green contexts created on the device will wait for ``event`` as well. Args: ctx (intptr_t): Execution context to wait for (required parameter, see note below). event (intptr_t): Event to wait on. .. note:: ``event`` may be from a different execution context or device than ``ctx``. .. note:: The API will return ``cudaErrorStreamCaptureUnsupported`` and invalidate the capture if the specified event ``event`` is part of an ongoing capture sequence or if the specified execution context ``ctx`` has a stream in the capture mode. .. seealso:: `cudaExecutionCtxWaitEvent` """ with nogil: __status__ = cudaExecutionCtxWaitEvent(ctx, event) check_status(__status__) cpdef intptr_t device_get_execution_ctx(int device) except? 0: """Returns the execution context for a device. Returns in ``ctx`` the execution context for the specified device. This is the device's primary context. The returned context can then be passed to APIs that take in a ``cudaExecutionContext_t`` enabling explicit context-based programming without relying on thread-local state. Passing the returned execution context to :func:`execution_ctx_destroy` is not allowed and will result in undefined behavior. Args: device (int): Device to get the execution context for. Returns: intptr_t: Returns the device execution context. .. seealso:: `cudaDeviceGetExecutionCtx` """ cdef cudaExecutionContext_t ctx with nogil: __status__ = cudaDeviceGetExecutionCtx(&ctx, device) check_status(__status__) return ctx cpdef size_t func_get_param_count(intptr_t func) except? 0: """Returns the number of parameters used by the function. Queries the number of kernel parameters used by ``func`` and returns it in ``param_count``. Args: func (intptr_t): The function to query. Returns: size_t: Returns the number of parameters used by the function. .. seealso:: `cudaFuncGetParamCount` """ cdef size_t param_count with nogil: __status__ = cudaFuncGetParamCount(func, ¶m_count) check_status(__status__) return param_count cpdef launch_host_func_v2(intptr_t stream, intptr_t fn, intptr_t user_data, unsigned int sync_mode): """Enqueues a host function call in a stream. Enqueues a host function to run in a stream. The function will be called after currently enqueued work and will block work added after it. The host function must not make any CUDA API calls. Attempting to use a CUDA API may result in ``cudaErrorNotPermitted``, but this is not required. The host function must not perform any synchronization that may depend on outstanding CUDA work not mandated to run earlier. Host functions without a mandated order (such as in independent streams) execute in undefined order and may be serialized. For the purposes of Unified Memory, execution makes a number of guarantees:. - The stream is considered idle for the duration of the function's execution. Thus, for example, the function may always use memory attached to the stream it was enqueued in. - The start of execution of the function has the same effect as synchronizing an event recorded in the same stream immediately prior to the function. It thus synchronizes streams which have been "joined" prior to the function. - Adding device work to any stream does not have the effect of making the stream active until all preceding host functions and stream callbacks have executed. Thus, for example, a function might use global attached memory even if work has been added to another stream, if the work has been ordered behind the function call with an event. - Completion of the function does not cause a stream to become active except as described above. The stream will remain idle if no device work follows the function, and will remain idle across consecutive host functions or stream callbacks without device work in between. Thus, for example, stream synchronization can be done by signaling from a host function at the end of the stream. Note that, in constrast to ``cuStreamAddCallback``, the function will not be called in the event of an error in the CUDA context. Args: stream (intptr_t): Stream to enqueue function call in. fn (intptr_t): The function to call once preceding stream operations are complete. user_data (intptr_t): User-specified data to be passed to the function. sync_mode (unsigned int): Sync mode for the host function. .. seealso:: `cudaLaunchHostFunc_v2` """ with nogil: __status__ = cudaLaunchHostFunc_v2(stream, fn, user_data, sync_mode) check_status(__status__) cpdef memcpy_with_attributes_async(dst, src, size_t size, attr, intptr_t stream): """Performs asynchronous memory copy operation with the specified attributes. Performs asynchronous memory copy operation where ``dst`` and ``src`` are the destination and source pointers respectively. ``size`` specifies the number of bytes to copy. ``attr`` specifies the attributes for the copy and ``stream`` specifies the stream to enqueue the operation in. For more information regarding the attributes, please refer to ``cudaMemcpyAttributes`` and it's usage desciption ``in.cudaMemcpyBatchAsync``. Args: dst (bytes): Destination device pointer. src (bytes): Source device pointer. size (size_t): Number of bytes to copy. attr (intptr_t): Attributes for the copy. stream (intptr_t): Stream to enqueue the operation in. .. seealso:: `cudaMemcpyWithAttributesAsync` """ cdef _cyb_BufferGuard _dst_guard_ = _cyb_BufferGuard(dst, 0, False, False, True) cdef void* _dst_ = _dst_guard_.ptr cdef _cyb_BufferGuard _src_guard_ = _cyb_BufferGuard(src, 0, False, True, True) cdef void* _src_ = _src_guard_.ptr cdef intptr_t _attr_ptr_ = 0 if attr is None else int(attr) with nogil: __status__ = cudaMemcpyWithAttributesAsync(_dst_, _src_, size, _attr_ptr_, stream) check_status(__status__) cpdef memcpy_3d_with_attributes_async(op, unsigned long long flags, intptr_t stream): """Performs 3D asynchronous memory copy with the specified attributes. Performs the copy operation specified in ``op``. ``flags`` specifies the flags for the copy and ``stream`` specifies the stream to enqueue the operation in. For more information regarding the operation, please refer to ``cudaMemcpy3DBatchOp`` and it's usage desciption ``in.cudaMemcpy3DBatchAsync``. Args: op (intptr_t): Operation to perform. flags (unsigned long long): Flags for the copy, must be zero now. stream (intptr_t): Stream to enqueue the operation in. .. seealso:: `cudaMemcpy3DWithAttributesAsync` """ cdef intptr_t _op_ptr_ = 0 if op is None else int(op) with nogil: __status__ = cudaMemcpy3DWithAttributesAsync(_op_ptr_, flags, stream) check_status(__status__) cpdef object graph_node_get_params(intptr_t node): """Returns a graph node's parameters. Returns the parameters of graph node ``node`` in ``*node_params``. Any pointers returned in ``*node_params`` point to driver-owned memory associated with the node. This memory remains valid until the node is destroyed. Any memory pointed to from ``*node_params`` must not be modified. The returned parameters are a description of the node, but may not be identical to the struct provided at creation and may not be suitable for direct creation of identical nodes. This is because parameters may be partially unspecified and filled in by the driver at creation, may reference non-copyable handles, or may describe ownership semantics or other parameters that govern behavior of node creation but are not part of the final functional descriptor. Args: node (intptr_t): Node to get the parameters for. Returns: cudaGraphNodeParams: Pointer to return the parameters. .. seealso:: `cudaGraphNodeGetParams` """ cdef GraphNodeParams node_params_py = GraphNodeParams() cdef cudaGraphNodeParams *node_params = (node_params_py._get_ptr()) with nogil: __status__ = cudaGraphNodeGetParams(node, node_params) check_status(__status__) return node_params_py cpdef stream_begin_recapture_to_graph(intptr_t stream, int mode, intptr_t graph, callback_data): """Begin graph capture on a stream to an existing graph. Begin graph capture on ``stream`` to the existing ``graph``. The node creation order while recapturing the graph must be identical to the original graph. The recapture will fail immediately for:. - Topology mismatches between the existing graph and the recaptured graph. - Parameter mismatches for memory allocation or free nodes. Any other node parameter mismatches during recapture can be configured to call the function provided in ``callbackFunc``. The recapture will fail immediately if the callback returns anything other than cudaSuccess. If the recapture fails for any reason, the ``graph`` will be in an undefined state and should be destroyed. See cudaStreamBeginCapture for additional detail on beginning the capture. Args: stream (intptr_t): Stream in which to initiate capture. mode (StreamCaptureMode): Controls the interaction of this capture sequence with other API calls that are potentially unsafe. For more details see ``cudaThreadExchangeStreamCaptureMode``. graph (intptr_t): Existing CUDA graph to be captured into. callback_data (intptr_t): Optional struct of callback data that will be invoked for all parameter mismatches from the original graph. .. note:: Any user objects associated with ``graph`` will be released prior to the recapture. .. seealso:: `cudaStreamBeginRecaptureToGraph` """ cdef intptr_t _callback_data_ptr_ = 0 if callback_data is None else int(callback_data) with nogil: __status__ = cudaStreamBeginRecaptureToGraph(stream, mode, graph, _callback_data_ptr_) check_status(__status__) cpdef object mem_get_location_info(intptr_t dev_ptr, size_t size, size_t summary_granularity, size_t sampling_granularity): """Gets location information for a memory address range. Retrieves memory location information for the specified address range starting at ``ptr`` with size ``size``. The API determines the most common location by sampling memory at intervals defined by ``sampling_granularity`` within the whole interval. The location information is returned in the ``location_out`` array, with one entry per summary region. The total number of locations returned will be ceil(size/summary_granularity). The user is expected to allocate the ``location_out`` array with sufficient memory. For example, with an address range of 1GB, a ``summary_granularity`` of 128MB, and a ``sampling_granularity`` of 2MB, the function will:. - Divide the 1GB range into 8 summary regions of 128MB each. - Within each 128MB region, sample every 2MB to determine the most common location. If there is a tie a random winner is chosen. - Populate the ``location_out`` array with 8 entries, one for each 128MB region ``summary_granularity`` should be less than or equal to ``size`` and greater than 0. ``sampling_granularity`` should be less than or equal to ``summary_granularity``. If the ``sampling_granularity`` is set to 0 it is set to a system dependent default value. In all other cases, the call returns ``cudaErrorInvalidValue``. When the memory is not resident on any processor, the call returns ``cudaSuccess`` and the returned location type for that interval is ``cudaMemLocationTypeNone``. The memory range must refer to one of the following:. - Managed memory allocated via ``cudaMallocManaged``, via ``cudaMallocFromPoolAsync`` from a managed memory pool or declared via managed variables. - System-allocated pageable memory that is not registered via ``cudaHostRegister``. If the memory range does not refer to one of the above, the call returns ``cudaErrorInvalidValue``. All devices on the system must have non-zero value for the device attribute ``cudaDevAttrConcurrentManagedAccess``. If not, this call returns ``cudaErrorNotSupported``. Args: dev_ptr (intptr_t): Starting address of the memory range to query. size (size_t): Size in bytes of the memory range to query. summary_granularity (size_t): Granularity in bytes at which to summarize location information. sampling_granularity (size_t): Granularity in bytes at which to sample memory within each summary region. Returns: cudaMemLocation: Array to store location information, one entry per summary region. .. seealso:: `cudaMemGetLocationInfo` """ cdef MemLocation location_out_py = MemLocation() cdef cudaMemLocation *location_out = (location_out_py._get_ptr()) with nogil: __status__ = cudaMemGetLocationInfo(dev_ptr, size, summary_granularity, sampling_granularity, location_out) check_status(__status__) return location_out_py del _cyb_FastEnum