|
XVector
|
Execution context management for the XVector library. More...
#include "xvec_types.h"Go to the source code of this file.
Functions | |
| xvecStatus | xvecGetNumDevices (uint32_t *outNumDevices) |
| Get the number of available devices. More... | |
| xvecStatus | xvecCreateContext (xvecExecutionContextTag **outContext, uint32_t deviceId) |
| Create an execution context. More... | |
| xvecStatus | xvecDestroyContext (xvecExecutionContextTag *context) |
| Release a context. More... | |
| xvecStatus | xvecSetContextProperty (xvecExecutionContextTag *context, const char *key, const char *value) |
| Set a property on the execution context. More... | |
| xvecStatus | xvecGetContextProperty (xvecExecutionContextTag *context, const char *key, char *value, size_t valueSize, size_t *outRequiredSize) |
| Get a property from the execution context. More... | |
| xvecStatus | xvecResetVpeContext (xvecExecutionContextTag *context) |
| Reset the VPE (Vector Process Engine) SRAM allocator state. More... | |
Execution context management for the XVector library.
This header provides the API for creating, configuring, and destroying execution contexts. An execution context encapsulates the device handle, embedded production kernel, and runtime properties required for XVector operations.
Definition in file xvec_context.h.
| xvecStatus xvecCreateContext | ( | xvecExecutionContextTag ** | outContext, |
| uint32_t | deviceId | ||
| ) |
Create an execution context.
Initializes a new execution context associated with the specified device using the production kernel embedded in libxvector. The created context manages resources required for buffer allocations and kernel execution.
This call does not automatically apply environment settings from xvec::host::ConfigManager. Pass the device ID explicitly and use xvecSetContextProperty() to configure execution properties.
The returned context handle (xvecExecutionContextTag) must be released using xvecDestroyContext when it is no longer needed.
| [out] | outContext | Pointer to a variable that will receive the created context handle. Must not be NULL. |
| [in] | deviceId | Identifier of the target device on which the context will be created. |
| xvecStatus xvecDestroyContext | ( | xvecExecutionContextTag * | context | ) |
Release a context.
Releases the context and frees associated resources.
| [in] | context | Pointer previously returned by xvecCreateContext. Must not be NULL. |
| xvecStatus xvecGetContextProperty | ( | xvecExecutionContextTag * | context, |
| const char * | key, | ||
| char * | value, | ||
| size_t | valueSize, | ||
| size_t * | outRequiredSize | ||
| ) |
Get a property from the execution context.
Retrieves a named property value from the execution context as a string. If the property exists, its value will be copied to the provided buffer. The buffer must be large enough to hold the property value and null terminator.
To query the required buffer size, pass NULL for value and 0 for valueSize. The required size (including null terminator) will be written to outRequiredSize.
| [in] | context | Execution context handle. Must not be NULL. |
| [in] | key | Property name. Must be a null-terminated string. Must not be NULL. |
| [out] | value | Buffer to receive property value. May be NULL to query required size. |
| [in] | valueSize | Size of the value buffer in bytes. |
| [out] | outRequiredSize | Optional. If not NULL, receives the required buffer size including null terminator. |
| xvecStatus xvecGetNumDevices | ( | uint32_t * | outNumDevices | ) |
Get the number of available devices.
Returns the number of XCENA devices currently available on the system. This function can be called before creating any context.
| [out] | outNumDevices | Pointer to a variable that will receive the device count. Must not be NULL. |
| xvecStatus xvecResetVpeContext | ( | xvecExecutionContextTag * | context | ) |
Reset the VPE (Vector Process Engine) SRAM allocator state.
Clears the SRAM buffer allocation state across all subsystems on the device. This must be called before executing kernels that use VpeContext to ensure a clean allocator state.
Sized like a search's Job: the "numSub" context property if set, else the device's Sub count.
| [in] | context | Execution context handle. Must not be NULL. |
| xvecStatus xvecSetContextProperty | ( | xvecExecutionContextTag * | context, |
| const char * | key, | ||
| const char * | value | ||
| ) |
Set a property on the execution context.
Sets a named property with a string value on the execution context. The caller is responsible for converting the value to the appropriate type when reading the property. Common properties include:
xvecSetContextProperty(ctx, "ivfFlatL2NormTrick", "1") to enable this optimization for IVF-Flat L2 searches in QUERY_FIXED mode. It is disabled by default. Accepted values are "1"/"true" and "0"/"false"; other values return XVEC_ERROR_INVALID_PARAMETER. It has no effect on inner-product searches or CLUSTER_LIST_FIXED mode.The first enabled search caches squared vector norms (4 bytes of device memory per indexed vector); later enabled searches compute only query norms. Disabling the option stops norm processing but retains the cache until context destruction. Cache allocation failure during search returns XVEC_ERROR_OUT_OF_MEMORY_PXL. Default searches do not allocate this cache.
Close vectors use direct differences to limit cancellation. Scores can differ due to floating-point rounding, and equal-score ties may change. Benchmark representative data before enabling: performance depends on the workload, and highly similar vectors can make this optimization slower.
| [in] | context | Execution context handle. Must not be NULL. |
| [in] | key | Property name. Must be a null-terminated string. Must not be NULL. |
| [in] | value | Property value as a string. Must be a null-terminated string. Must not be NULL. |