Typedefs | |
typedef struct VPIEventImpl * | VPIEvent |
Functions | |
VPIStatus | vpiEventCreate (uint32_t flags, VPIEvent *event) |
Create an event instance with the specified flags. More... | |
void | vpiEventDestroy (VPIEvent event) |
Destroy an event instance as well as all resources it owns. More... | |
VPIStatus | vpiEventWrapCudaEvent (CUevent cudaEvent, VPIEvent *event) |
Create an event object by wrapping around an existing CUDA CUevent object. More... | |
VPIStatus | vpiEventRecord (VPIEvent event, VPIStream stream) |
Captures in the event the contents of the stream command queue at the time of this call. More... | |
VPIStatus | vpiEventSync (VPIEvent event) |
Blocks the calling thread until the event is completed. More... | |
VPIStatus | vpiEventQuery (VPIEvent event) |
Queries the status of all work currently captured by the event. More... | |
VPIStatus | vpiEventElapsedTime (VPIEvent start, VPIEvent end, float *msec) |
Computes the elapsed time in (msec) between two completed events. More... | |
Event flags | |
#define | VPI_EVENT_NO_PVA 0x01 |
Event can't be used by PVA backend. | |
#define | VPI_EVENT_NO_CPU 0x02 |
Event can't be used by CPU backend. | |
#define | VPI_EVENT_NO_CUDA 0x04 |
Event can't be used by CUDA backend. | |
#define | VPI_EVENT_DISABLE_TIMESTAMP 0x08 |
disable time-stamping of event signalled state-change for better performance | |
#define | VPI_EVENT_ONLY_CUDA (VPI_EVENT_NO_PVA | VPI_EVENT_NO_CPU) |
shared helper flags | |
#define | VPI_EVENT_ONLY_CPU (VPI_EVENT_NO_PVA | VPI_EVENT_NO_CUDA) |
Event can't be used by PVA backend. | |
#define | VPI_EVENT_ONLY_PVA (VPI_EVENT_NO_CUDA | VPI_EVENT_NO_CPU) |
Event can't be used by PVA backend. | |
Each compute function in the API is executed asynchronously with respect to the calling thread, i.e., returns immediately without waiting for the completion. There are two ways of synchronizing with the backend. One is to wait until all the commands in the VPIStream queue are finished, with the vpiStreamSync call. This approach, while simple, doesn't allow for fine-grained ("wait for until function X is completed") or inter-device ("before running function A in device B, wait until function C in device D finishes") synchronization. That's where VPIEvent objects come in. Conceptually, they correspond to binary semaphores and are designed to closely mimic events in CUDA API:
typedef struct VPIEventImpl* VPIEvent |
#include <vpi/Event.h>
Create an event instance with the specified flags.
flags | [in] flags |
event | [out] pointer to event handle |
void vpiEventDestroy | ( | VPIEvent | event | ) |
#include <vpi/Event.h>
Destroy an event instance as well as all resources it owns.
event | [in] event handle |
#include <vpi/Event.h>
Computes the elapsed time in (msec) between two completed events.
If one or both are not completed at the time of the call, VPI_ERROR_NOT_READY is returned, otherwise VPI_SUCCESS.
start | [in] an event handle marking the start of the time interval |
end | [in] an event handle marking the end of the time interval |
msec | [out] a pointer to a variable which will be set to the time difference between the events |
#include <vpi/Event.h>
Queries the status of all work currently captured by the event.
If all commands are complete, VPI_SUCCESS is returned, otherwise VPI_ERROR_NOT_READY.
event | [in] an event handle |
#include <vpi/Event.h>
Captures in the event the contents of the stream command queue at the time of this call.
This function can be called multiple times on the same event, however, vpiEventSync / vpiStreamWaitFor are not affected by later calls to vpiEventRecord. This means they will wait for the event completion of the command queue tasks described by the event at the time of the initial vpiEventSync / vpiStreamWaitFor call.
event | [in] an event handle |
stream | [in] a stream handle |
#include <vpi/Event.h>
Blocks the calling thread until the event is completed.
The event is considered completed when all the commands captured with vpiEventRecord() are complete or when no commands were captured.
event | [in] an event handle |
#include <vpi/Event.h>
Create an event object by wrapping around an existing CUDA CUevent
object.
The created event can be used by vpiEventSync / vpiStreamWaitFor to synchronize on a previously recorded CUDA event, or CUDA synchronization functions can be used to synchronize on events captured with vpiEventRecord().
cudaEvent | [in] CUDA event handle |
event | [out] pointer to an event handle |