VPI - Vision Programming Interface

1.2 Release

CPU Interoperability

Declaration of functions for CPU/host interoperability. More...

Functions

VPIStatus vpiArrayCreateHostMemWrapper (const VPIArrayData *arrayData, uint32_t flags, VPIArray *array)
 Create an array object by wrapping an existing host memory block. More...
 
VPIStatus vpiArraySetWrappedHostMem (VPIArray array, const VPIArrayData *arrayData)
 Redefines the wrapped host memory in an existing VPIArray wrapper. More...
 
VPIStatus vpiImageCreateHostMemWrapper (const VPIImageData *hostData, uint32_t flags, VPIImage *img)
 Create an image object by wrapping around an existing host memory block. More...
 
VPIStatus vpiImageSetWrappedHostMem (VPIImage img, const VPIImageData *hostData)
 Redefines the wrapped host memory in an existing VPIImage wrapper. More...
 

Detailed Description

Declaration of functions for CPU/host interoperability.

The provided methods allows wrapping CPU/host objects external to VPI, e.g., allocated by malloc or new. They can then be used efficiently in VPI compute pipelines.

Function Documentation

◆ vpiArrayCreateHostMemWrapper()

VPIStatus vpiArrayCreateHostMemWrapper ( const VPIArrayData arrayData,
uint32_t  flags,
VPIArray array 
)

#include <vpi/Array.h>

Create an array object by wrapping an existing host memory block.

Stride between elements has to be at least as large as the element structure size. It also has to respect alignment requirements of the element data structure.

The returned handle must be destroyed when not being used anymore by calling vpiArrayDestroy.

The object doesn't own the wrapped memory. The user is still responsible for wrapped memory lifetime, which must be valid until the array object is destroyed.

Parameters
[in]arrayDataVPIArrayData pointing to the host memory block to be wrapped.
[in]flagsArray flags. Here it can be specified in what backends the array can be used by or-ing together VPIBackend flags. Set flags to 0 to enable it in all backends supported by the active VPI context.
[out]arrayPointer to memory that will receive the created array handle.
Returns
an error code on failure else VPI_SUCCESS

◆ vpiArraySetWrappedHostMem()

VPIStatus vpiArraySetWrappedHostMem ( VPIArray  array,
const VPIArrayData arrayData 
)

#include <vpi/Array.h>

Redefines the wrapped host memory in an existing VPIArray wrapper.

The old wrapped memory and the new one must have same capacity, element format and must point to host-side (cpu-accessible) memory.

The VPIArray must have been created by vpiArrayCreateHostMemWrapper.

This operation is efficient and does not allocate memory. The wrapped memory will be accessible to the same backends specified during wrapper creation.

The wrapped memory must not be deallocated while it's still being wrapped.

Parameters
[in]arrayHandle to array created by vpiArrayCreateHostMemWrapper.
[in]arrayDataVPIArrayData pointing to the new host memory block to be wrapped.
Returns
an error code on failure else VPI_SUCCESS

◆ vpiImageCreateHostMemWrapper()

VPIStatus vpiImageCreateHostMemWrapper ( const VPIImageData hostData,
uint32_t  flags,
VPIImage img 
)

#include <vpi/Image.h>

Create an image object by wrapping around an existing host memory block.

Only pitch-linear memory layout is supported. The underlying image object does not own/claim the memory block.

Parameters
[in]hostDataPointer to structure with host memory to be wrapped.
[in]flagsImage flags. Here it can be specified in what backends the image can be used by or-ing together VPIBackend flags. Set flags to 0 to enable it in all backends supported by the active VPI context.
[out]imgPointer to memory that will receive the created image handle.
Returns
an error code on failure else VPI_SUCCESS
+ Here is the caller graph for this function:

◆ vpiImageSetWrappedHostMem()

VPIStatus vpiImageSetWrappedHostMem ( VPIImage  img,
const VPIImageData hostData 
)

#include <vpi/Image.h>

Redefines the wrapped host memory in an existing VPIImage wrapper.

The old wrapped memory and the new one must have same dimensions, format and must point to host-side (cpu-accessible) memory.

The VPIImage must have been created by vpiImageCreateHostMemWrapper.

This operation is efficient and does not allocate memory. The wrapped memory will be accessible to the same backends specified during wrapper creation.

The wrapped memory must not be deallocated while it's still being wrapped.

Parameters
[in]imgHandle to image created by vpiImageCreateHostMemWrapper.
[in]hostDataVPIImageData pointing to the new host memory block to be wrapped.
Returns
an error code on failure else VPI_SUCCESS
+ Here is the caller graph for this function: