Skip to main content

cudaEventElapsedTime

Function cudaEventElapsedTime 

Source
pub unsafe extern "C" fn cudaEventElapsedTime(
    ms: *mut f32,
    start: cudaEvent_t,
    end: cudaEvent_t,
) -> cudaError_t
Expand description

Computes the elapsed time between events.

Computes the elapsed time between two events (in milliseconds with a resolution of around 0.5 microseconds). Note this API is not guaranteed to return the latest errors for pending work. As such this API is intended to serve as a elapsed time calculation only and polling for completion on the events to be compared should be done with cudaEventQuery instead.

If either event was last recorded in a non-NULL stream, the resulting time may be greater than expected (even if both used the same stream handle). This happens because the cudaEventRecord operation takes place asynchronously and there is no guarantee that the measured latency is actually just between the two events. Any number of other different stream operations could execute in between the two measured events, thus altering the timing in a significant way.

If cudaEventRecord has not been called on either event, then cudaError_t::CUDA_ERROR_INVALID_HANDLE is returned. If cudaEventRecord has been called on both events but one or both of them has not yet been completed (that is, cudaEventQuery would return cudaError_t::CUDA_ERROR_NOT_READY on at least one of the events), cudaError_t::CUDA_ERROR_NOT_READY is returned. If either event was created with the cudaEventDisableTiming flag, then this function will return cudaError_t::CUDA_ERROR_INVALID_HANDLE.

Note that this function may also return error codes from previous, asynchronous launches.

Note that this function may also return cudaError_t::CUDA_ERROR_NOT_INITIALIZED, cudaErrorInsufficientDriver or cudaError_t::CUDA_ERROR_NO_DEVICE if this call tries to initialize internal CUDA RT state.

Note that as specified by cudaStreamAddCallback no CUDA function may be called from callback. cudaError_t::CUDA_ERROR_NOT_PERMITTED may, but is not guaranteed to, be returned as a diagnostic in such case.

Note: Returns cudaError_t::CUDA_ERROR_INVALID_HANDLE in the event of being passed NULL as the input event.

§Parameters

  • ms: Time between start and end in ms.
  • start: Starting event.
  • end: Ending event.

§Return value

See also: cudaEventCreate (C API), cudaEventCreateWithFlags, cudaEventQuery, cudaEventSynchronize, cudaEventDestroy, cudaEventRecord, cuEventElapsedTime.