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... | |
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.
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.
[in] | arrayData | VPIArrayData pointing to the host memory block to be wrapped. |
[in] | flags | Array 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] | array | Pointer to memory that will receive the created array handle. |
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 type 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.
[in] | array | Handle to array created by vpiArrayCreateHostMemWrapper. |
[in] | arrayData | VPIArrayData pointing to the new host memory block to be wrapped. |
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.
[in] | hostData | Pointer to structure with host memory to be wrapped. |
[in] | flags | Image flags. Here it can be specified in what backends the mage 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] | img | Pointer to memory that will receive the created image handle. |
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.
[in] | img | Handle to image created by vpiImageCreateHostMemWrapper. |
[in] | hostData | VPIImageData pointing to the new host memory block to be wrapped. |