VTK-m  2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
vtkm::cont::Timer Class Reference

A class that can be used to time operations in VTK-m that might be occuring in parallel. More...

#include <Timer.h>

Public Member Functions

VTKM_CONT Timer ()
 
VTKM_CONT Timer (vtkm::cont::DeviceAdapterId device)
 
VTKM_CONT ~Timer ()
 
VTKM_CONT void Reset ()
 Resets the timer. More...
 
VTKM_CONT void Reset (vtkm::cont::DeviceAdapterId device)
 Resets the timer and changes the device to time on. More...
 
VTKM_CONT void Start ()
 
VTKM_CONT void Stop ()
 
VTKM_CONT bool Started () const
 
VTKM_CONT bool Stopped () const
 
VTKM_CONT bool Ready () const
 Used to check if Timer has finished the synchronization to get the result from the device. More...
 
VTKM_CONT vtkm::Float64 GetElapsedTime () const
 Get the elapsed time measured by the given device adapter. More...
 
VTKM_CONT vtkm::cont::DeviceAdapterId GetDevice () const
 Returns the device for which this timer is synchronized. More...
 
VTKM_CONT void Synchronize () const
 Synchronize the device(s) that this timer is monitoring without starting or stopping the timer. More...
 

Private Member Functions

VTKM_CONT Timer (const Timer &)=delete
 Some timers are ill-defined when copied, so disallow that for all timers. More...
 
VTKM_CONT void operator= (const Timer &)=delete
 

Private Attributes

vtkm::cont::DeviceAdapterId Device
 
std::unique_ptr< detail::EnabledDeviceTimerImpls > Internal
 

Detailed Description

A class that can be used to time operations in VTK-m that might be occuring in parallel.

Users are recommended to provide a device adapter at construction time which matches the one being used to execute algorithms to ensure that thread synchronization is correct and accurate. If no device adapter is provided at construction time, the maximum elapsed time of all enabled deivces will be returned. Normally cuda is expected to have the longest execution time if enabled. Per device adapter time query is also supported. It's useful when users want to reuse the same timer to measure the cuda kernal call as well as the cuda device execution. It is also possible to change the device adapter after construction by calling the form of the Reset method with a new DeviceAdapterId.

The there is no guaranteed resolution of the time but should generally be good to about a millisecond.

Constructor & Destructor Documentation

◆ Timer() [1/3]

VTKM_CONT vtkm::cont::Timer::Timer ( )

◆ Timer() [2/3]

VTKM_CONT vtkm::cont::Timer::Timer ( vtkm::cont::DeviceAdapterId  device)

◆ ~Timer()

VTKM_CONT vtkm::cont::Timer::~Timer ( )

◆ Timer() [3/3]

VTKM_CONT vtkm::cont::Timer::Timer ( const Timer )
privatedelete

Some timers are ill-defined when copied, so disallow that for all timers.

Member Function Documentation

◆ GetDevice()

VTKM_CONT vtkm::cont::DeviceAdapterId vtkm::cont::Timer::GetDevice ( ) const
inline

Returns the device for which this timer is synchronized.

If the device adapter has the same id as DeviceAdapterTagAny, then the timer will synchronize all devices.

◆ GetElapsedTime()

VTKM_CONT vtkm::Float64 vtkm::cont::Timer::GetElapsedTime ( ) const

Get the elapsed time measured by the given device adapter.

If no device is specified, the max time of all device measurements will be returned.

◆ operator=()

VTKM_CONT void vtkm::cont::Timer::operator= ( const Timer )
privatedelete

◆ Ready()

VTKM_CONT bool vtkm::cont::Timer::Ready ( ) const

Used to check if Timer has finished the synchronization to get the result from the device.

◆ Reset() [1/2]

VTKM_CONT void vtkm::cont::Timer::Reset ( )

Resets the timer.

◆ Reset() [2/2]

VTKM_CONT void vtkm::cont::Timer::Reset ( vtkm::cont::DeviceAdapterId  device)

Resets the timer and changes the device to time on.

◆ Start()

VTKM_CONT void vtkm::cont::Timer::Start ( )

◆ Started()

VTKM_CONT bool vtkm::cont::Timer::Started ( ) const

◆ Stop()

VTKM_CONT void vtkm::cont::Timer::Stop ( )

◆ Stopped()

VTKM_CONT bool vtkm::cont::Timer::Stopped ( ) const

◆ Synchronize()

VTKM_CONT void vtkm::cont::Timer::Synchronize ( ) const

Synchronize the device(s) that this timer is monitoring without starting or stopping the timer.

This is useful for ensuring that external events are synchronized to this timer.

Note that this method will allways block until the device(s) finish even if the Start/Stop methods do not actually block. For example, the timer for CUDA does not actually wait for asynchronous operations to finish. Rather, it inserts a fence and records the time as fences are encounted. But regardless, this Synchronize method will block for the CUDA device.

Member Data Documentation

◆ Device

vtkm::cont::DeviceAdapterId vtkm::cont::Timer::Device
private

◆ Internal

std::unique_ptr<detail::EnabledDeviceTimerImpls> vtkm::cont::Timer::Internal
private

The documentation for this class was generated from the following file: