Ginkgo  Generated from pipelines/1330831941 branch based on master. Ginkgo version 1.8.0
A numerical linear algebra library targeting many-core architectures
Public Member Functions | Static Public Member Functions | List of all members
gko::Timer Class Referenceabstract

Represents a generic timer that can be used to record time points and measure time differences on host or device streams. More...

#include <ginkgo/core/base/timer.hpp>

Inheritance diagram for gko::Timer:
[legend]

Public Member Functions

time_point create_time_point ()
 Returns a newly created time point. More...
 
virtual void record (time_point &time)=0
 Records a time point at the current time.
 
virtual void wait (time_point &time)=0
 Waits until all kernels in-process when recording the time point are finished.
 
std::chrono::nanoseconds difference (time_point &start, time_point &stop)
 Computes the difference between the two time points in nanoseconds. More...
 
virtual std::chrono::nanoseconds difference_async (const time_point &start, const time_point &stop)=0
 Computes the difference between the two time points in nanoseconds. More...
 

Static Public Member Functions

static std::unique_ptr< Timercreate_for_executor (std::shared_ptr< const Executor > exec)
 Creates the timer type most suitable for recording accurate timings of kernels on the given executor. More...
 

Detailed Description

Represents a generic timer that can be used to record time points and measure time differences on host or device streams.

To keep the runtime overhead of timing minimal, time points need to be allocated beforehand using Timer::create_time_point:

auto begin = timer->create_time_point();
auto end = timer->create_time_point();
// ...
timer->record(begin);
run_expensive_operation();
timer->record(end);
auto elapsed = timer->difference(begin, end);

Member Function Documentation

◆ create_for_executor()

static std::unique_ptr<Timer> gko::Timer::create_for_executor ( std::shared_ptr< const Executor exec)
static

Creates the timer type most suitable for recording accurate timings of kernels on the given executor.

Parameters
execthe executor to create a Timer for
Returns
CpuTimer for ReferenceExecutor and OmpExecutor, CudaTimer for CudaExecutor, HipTimer for HipExecutor or DpcppTimer for DpcppExecutor.

◆ create_time_point()

time_point gko::Timer::create_time_point ( )

Returns a newly created time point.

Time points may only be used with the timer they were created with.

◆ difference()

std::chrono::nanoseconds gko::Timer::difference ( time_point start,
time_point stop 
)

Computes the difference between the two time points in nanoseconds.

The function synchronizes with stop before computing the difference.

Parameters
startthe first time point (earlier)
endthe second time point (later)
Returns
the difference between the time points in nanoseconds.

◆ difference_async()

virtual std::chrono::nanoseconds gko::Timer::difference_async ( const time_point start,
const time_point stop 
)
pure virtual

Computes the difference between the two time points in nanoseconds.

This asynchronous version does not synchronize itself, so the time points need to have been synchronized with, i.e. timer->wait(stop) needs to have been called. The version is intended for more advanced users who want to measure the overhead of timing functionality separately.

Parameters
startthe first time point (earlier)
endthe second time point (later)
Returns
the difference between the time points in nanoseconds.

Implemented in gko::DpcppTimer, gko::HipTimer, gko::CudaTimer, and gko::CpuTimer.


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