C API
Source header: cuvs/core/c_api.h
cuVS Error Messages
cuvsError_t
An enum denoting error statuses for function calls
Values
cuvsGetLastErrorText
Returns a string describing the last seen error on this thread, or NULL if the last function succeeded.
Returns
const char*
cuvsSetLastErrorText
Sets a string describing an error seen on the thread. Passing NULL clears any previously seen error message.
Parameters
Returns
void
cuVS Logging
cuvsLogLevel_t
An enum denoting log levels
Values
cuvsGetLogLevel
Returns the current log level
Returns
cuvsSetLogLevel
Sets the log level
Parameters
Returns
void
cuVS Resources Handle
cuvsResources_t
An opaque C handle for C++ type raft::resources
cuvsResourcesCreate
Create an Initialized opaque C handle for C++ type raft::resources
Parameters
Returns
cuvsResourcesCreateWithMemoryTracking
Create an opaque C handle for C++ type raft::resources whose memory allocations are tracked and written as CSV samples from a background thread.
The returned handle wraps all reachable memory resources (host, pinned, managed, device, workspace, large_workspace) with allocation-tracking adaptors and replaces the global host and device memory resources for the lifetime of the handle. It can be used with single-GPU operations that accept a ::cuvsResources_t, except ::cuvsResourcesSetMemoryPool. The CSV reporter is stopped and the global memory resources are restored when the handle is destroyed via ::cuvsResourcesDestroy.
Parameters
Returns
cuvsResourcesDestroy
Destroy and de-allocate opaque C handle for C++ type raft::resources
Parameters
Returns
cuvsResourcesSetMemoryPool
Set a memory pool on the device used by these resources
Call before the handle’s first operation that configures or uses a workspace or large workspace resource. RAFT captures the allocator when either resource is registered, so later device pool changes are rejected. Only handles created by ::cuvsResourcesCreate are supported. Passing a handle created by :cuvsResourcesCreateWithMemoryTracking returns CUVS_ERROR.
Parameters
Returns
cuvsResourcesSetStreamPool
Set a CUDA stream pool on these resources
Parameters
Returns
cuvsStreamSet
Set cudaStream_t on cuvsResources_t to queue CUDA kernels on APIs that accept a cuvsResources_t handle
Parameters
Returns
cuvsStreamGet
Get the cudaStream_t from a cuvsResources_t
Parameters
Returns
cuvsStreamSync
Syncs the current CUDA stream on the resources object
Parameters
Returns
cuvsDeviceIdGet
Get the id of the device associated with this cuvsResources_t
Parameters
Returns
cuvsResourcesSetWorkspacePool
Configure the temporary workspace on this resources object as an uncapped pool, backed by the current device memory resource. After the initial reservation is allocated on first use, subsequent calls to cuvsRMMAlloc / cuvsRMMFree on the same resources handle hit the pool cache rather than calling cudaMallocAsync / cudaFreeAsync, reducing CUDA context lock contention under concurrent query threads. The pool grows without shrinking: freed allocations are returned to the pool rather than to the device, so the pool’s high-water mark only increases until the resources object is destroyed.
Parameters
Returns
cuvsMultiGpuResourcesCreate
Create an Initialized opaque C handle for C++ type raft::device_resources_snmg for multi-GPU operations
Parameters
Returns
cuvsMultiGpuResourcesCreateWithDeviceIds
Create an Initialized opaque C handle for C++ type raft::device_resources_snmg for multi-GPU operations with specific device IDs
Parameters
Returns
cuvsMultiGpuResourcesDestroy
Destroy and de-allocate opaque C handle for C++ type raft::device_resources_snmg
Parameters
Returns
cuvsMultiGpuResourcesSetMemoryPool
Set a memory pool on all devices managed by the multi-GPU resources
Call before the first operation that configures or uses a workspace or large workspace resource on the handle or any managed device. RAFT captures the allocator when either resource is registered, so later pool changes are rejected.
Parameters
Returns
cuvsMultiGpuResourcesSetStreamPool
Set a CUDA stream pool on all devices managed by the multi-GPU resources
Parameters
Returns
cuVS Memory Allocation
cuvsRMMAlloc
Allocates device memory using RMM
Parameters
Returns
cuvsRMMFree
Deallocates device memory using RMM
Parameters
Returns
cuvsRMMPoolMemoryResourceEnable
Switches the working memory resource to use the RMM pool memory resource, which will bypass unnecessary synchronizations by allocating a chunk of device memory up front and carving that up for temporary memory allocations within algorithms. Be aware that this function will change the memory resource for the whole process and the new memory resource will be used until explicitly changed.
Parameters
Returns
cuvsRMMAsyncMemoryResourceEnable
Switches the working memory resource to use stream-ordered asynchronous allocation (cudaMallocAsync / cudaFreeAsync). Unlike the pool resource, this resource returns memory to the stream immediately without blocking the CPU, eliminating device-wide synchronization on deallocation. This is especially beneficial when multiple CAGRA searches run concurrently on separate CUDA streams, because the internal workspace allocations no longer serialize kernel launches. Be aware that this function will change the memory resource for the whole process and the new memory resource will be used until explicitly changed.
Returns
cuvsRMMMemoryResourceReset
Resets the memory resource to use the default memory resource (cuda_memory_resource)
Returns
cuvsRMMHostAlloc
Allocates pinned memory on the host using RMM
Parameters
Returns
cuvsRMMHostFree
Deallocates pinned memory on the host using RMM
Parameters
Returns
cuvsVersionGet
Get the version of the cuVS library
Parameters
Returns
cuvsMatrixCopy
Copy a matrix
This function copies a matrix from dst to src. This lets you copy a matrix from device memory to host memory (or vice versa), while accounting for differences in strides.
Both src and dst must have the same shape and dtype, but can have different strides and device type. The memory for the output dst tensor must already be allocated and the tensor initialized.
Parameters
Returns
cuvsMatrixSliceRows
Slices rows from a matrix
Parameters
Returns