VPI - Vision Programming Interface

4.1 Release

CUDA Host Function

Submits a user-defined function that receives the stream's CUDA stream handle, so that custom CUDA kernels or external library CUDA calls can run in the same order as VPI work (including Tegra backends). More...

Typedefs

typedef void(* VPICUDAHostFunction) (cudaStream_t cudaStream, void *userData)
 Pointer to a CUDA host function invoked with the stream's CUDA stream. More...
 

Functions

VPIStatus vpiSubmitCUDAHostFunction (VPIStream stream, VPICUDAHostFunction hostFunc, void *userData)
 Submits a CUDA host function to run on the stream in submission order. More...
 

Detailed Description

Submits a user-defined function that receives the stream's CUDA stream handle, so that custom CUDA kernels or external library CUDA calls can run in the same order as VPI work (including Tegra backends).

Typedef Documentation

◆ VPICUDAHostFunction

typedef void(* VPICUDAHostFunction) (cudaStream_t cudaStream, void *userData)

#include <vpi/CUDAInterop.h>

Pointer to a CUDA host function invoked with the stream's CUDA stream.

The callback runs on VPI's stream worker thread after all prior commands (VPI algorithms, Tegra backends, and previous callbacks) have been submitted. Launch custom CUDA kernels or call external libraries (e.g. cuBLAS, cuFFT) using cudaStream so that they execute in submission order with VPI work.

Parameters
[in]cudaStreamThe CUDA stream for this VPIStream's CUDA backend.
[in]userDataCallback data passed to the submission function.

Definition at line 93 of file CUDAInterop.h.

Function Documentation

◆ vpiSubmitCUDAHostFunction()

VPIStatus vpiSubmitCUDAHostFunction ( VPIStream  stream,
VPICUDAHostFunction  hostFunc,
void *  userData 
)

#include <vpi/CUDAInterop.h>

Submits a CUDA host function to run on the stream in submission order.

The callback is executed after all prior commands on the stream (including VPI Tegra and CUDA work) have been submitted. The callback receives the stream's CUDA stream so the user can launch custom kernels or call external CUDA libraries on it. Subsequent VPI submissions run after the callback, preserving order.

The stream must have the CUDA backend enabled (e.g. created with vpiStreamCreate or vpiStreamCreateWrapperCUDA with CUDA enabled). This call implicitly flushes the stream before enqueueing the callback.

Parameters
[in]streamStream that will execute the callback (mandatory).
[in]hostFuncCallback to run with the CUDA stream (mandatory).
[in]userDataPointer passed unchanged to hostFunc.
Note
userData must remain valid until the callback has executed (for example, after vpiStreamSync).
Return values
VPI_ERROR_INVALID_ARGUMENTstream or hostFunc is NULL.
VPI_ERROR_INVALID_OPERATIONStream does not have CUDA backend enabled.
VPI_ERROR_INVALID_OPERATIONVPI not built with CUDA support.
VPI_ERROR_INVALID_CONTEXTCurrent context was destroyed.
VPI_SUCCESSCallback enqueued successfully.