Class CudaEventTimer#

Class Documentation#

class CudaEventTimer#

A timer based on GPU events

Public Types

enum class State#

State of the CudaEventTimer, which can be either READY, RECODING or STEPPED

  • READY: the timer is ready for starting a recording (cannot stop the timer)

  • RECODING: the timer is recording (can not start a new recording or getting the elapsed time)

  • STOPPED: the timer has stopped, but hasn’t sync with the GPU to get the elapsed time yet (cannot stop again or start a new recording)

When more than one device is included, the elapsed time will be the maximum time among all devices.

Values:

enumerator READY#
enumerator RECORDING#
enumerator STOPPED#

Public Functions

inline explicit CudaEventTimer(const std::vector<Index> &deviceIndices)#

Initialize a timer with the specified set of devices through their indices

CudaEventTimer(const CudaEventTimer&) = delete#
CudaEventTimer &operator=(const CudaEventTimer&) = delete#
inline CudaEventTimer(CudaEventTimer &&other) noexcept#
inline CudaEventTimer &operator=(CudaEventTimer &&other) noexcept#
inline ~CudaEventTimer()#
inline State currentState() const#

Get the current state of the timer

inline void startTimer()#

Starts the timer

The state must be READY, will transit to RECORDING

inline void stopTimer()#

Stops the timer

The state must be RECORDING, will transit to STOPPED

inline float getElapsedTime()#

Gets the elapsed time in milliseconds

The state must be either STOPPED or READY, will transit to READY.

  • If the state is STOPPED, will first synchronize with the devices to get the elapsed time.

  • If the state is READY, will return the elapsed time get from previous record