\doxysection{gko::\+Timer Class Reference}
\hypertarget{classgko_1_1Timer}{}\label{classgko_1_1Timer}\index{gko::Timer@{gko::Timer}}


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




{\ttfamily \+\#include $<$ginkgo/\+core/\+base/\+timer.\+hpp$>$}



Inheritance diagram for gko::\+Timer:\+
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{classgko_1_1Timer__inherit__graph}
\end{center}
\end{figure}
\doxysubsubsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\doxymbox{\hyperlink{classgko_1_1time__point}{time\+\_\+point}} \doxymbox{\hyperlink{classgko_1_1Timer_a36a9fae8d1f1df78829a264e0049addb}{create\+\_\+time\+\_\+point}} ()
\begin{DoxyCompactList}\small\item\em Returns a newly created time point. \end{DoxyCompactList}\item 
virtual void \doxymbox{\hyperlink{classgko_1_1Timer_af60e8cb620d9e87a90c6e799dc97cb76}{record}} (\doxymbox{\hyperlink{classgko_1_1time__point}{time\+\_\+point}} \&time)=0
\begin{DoxyCompactList}\small\item\em Records a time point at the current time. \end{DoxyCompactList}\item 
virtual void \doxymbox{\hyperlink{classgko_1_1Timer_a895f02685ba5da78e8cceef4246fd399}{wait}} (\doxymbox{\hyperlink{classgko_1_1time__point}{time\+\_\+point}} \&time)=0
\begin{DoxyCompactList}\small\item\em Waits until all kernels in-\/process when recording the time point are finished. \end{DoxyCompactList}\item 
std::\+chrono::\+nanoseconds \doxymbox{\hyperlink{classgko_1_1Timer_a096e0525fc320073239e63305b9bcea0}{difference}} (\doxymbox{\hyperlink{classgko_1_1time__point}{time\+\_\+point}} \&start, \doxymbox{\hyperlink{classgko_1_1time__point}{time\+\_\+point}} \&\doxymbox{\hyperlink{namespacegko_1_1stop}{stop}})
\begin{DoxyCompactList}\small\item\em Computes the difference between the two time points in nanoseconds. \end{DoxyCompactList}\item 
virtual std::\+chrono::\+nanoseconds \doxymbox{\hyperlink{classgko_1_1Timer_a9f6ea65e99c2e65d67803a7da3f4d8a1}{difference\+\_\+async}} (const \doxymbox{\hyperlink{classgko_1_1time__point}{time\+\_\+point}} \&start, const \doxymbox{\hyperlink{classgko_1_1time__point}{time\+\_\+point}} \&\doxymbox{\hyperlink{namespacegko_1_1stop}{stop}})=0
\begin{DoxyCompactList}\small\item\em Computes the difference between the two time points in nanoseconds. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsubsection*{Static Public Member Functions}
\begin{DoxyCompactItemize}
\item 
static std::\+unique\+\_\+ptr$<$ \doxymbox{\hyperlink{classgko_1_1Timer}{Timer}} $>$ \doxymbox{\hyperlink{classgko_1_1Timer_a8e44eae260c1b3ad7a642338c1c5ce1e}{create\+\_\+for\+\_\+executor}} (std::\+shared\+\_\+ptr$<$ const \doxymbox{\hyperlink{classgko_1_1Executor}{Executor}} $>$ exec)
\begin{DoxyCompactList}\small\item\em Creates the timer type most suitable for recording accurate timings of kernels on the given executor. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{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 \doxylink{classgko_1_1Timer_a36a9fae8d1f1df78829a264e0049addb}{Timer::\+create\+\_\+time\+\_\+point}:\+ 
\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keyword}{auto}\ begin\ =\ timer-\/>create\_time\_point();}
\DoxyCodeLine{\textcolor{keyword}{auto}\ end\ =\ timer-\/>create\_time\_point();}
\DoxyCodeLine{\textcolor{comment}{//\ ...}}
\DoxyCodeLine{timer-\/>record(begin);}
\DoxyCodeLine{run\_expensive\_operation();}
\DoxyCodeLine{timer-\/>record(end);}
\DoxyCodeLine{\textcolor{keyword}{auto}\ elapsed\ =\ timer-\/>difference(begin,\ end);}

\end{DoxyCode}
 

\label{doc-func-members}
\Hypertarget{classgko_1_1Timer_doc-func-members}
\doxysubsection{Member Function Documentation}
\Hypertarget{classgko_1_1Timer_a8e44eae260c1b3ad7a642338c1c5ce1e}\index{gko::Timer@{gko::Timer}!create\_for\_executor@{create\_for\_executor}}
\index{create\_for\_executor@{create\_for\_executor}!gko::Timer@{gko::Timer}}
\doxysubsubsection{\texorpdfstring{create\_for\_executor()}{create\_for\_executor()}}
{\footnotesize\ttfamily \label{classgko_1_1Timer_a8e44eae260c1b3ad7a642338c1c5ce1e} 
std::\+unique\+\_\+ptr$<$ \doxymbox{\hyperlink{classgko_1_1Timer}{Timer}} $>$ gko::\+\+Timer::\+create\+\_\+for\+\_\+executor (\begin{DoxyParamCaption}\item[{std::\+shared\+\_\+ptr$<$ const \doxymbox{\hyperlink{classgko_1_1Executor}{Executor}} $>$}]{exec}{}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



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


\begin{DoxyParams}{Parameters}
{\em exec} & the executor to create a \doxylink{classgko_1_1Timer}{Timer} for\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
\doxylink{classgko_1_1CpuTimer}{Cpu\+Timer} for \doxylink{classgko_1_1ReferenceExecutor}{Reference\+Executor} and \doxylink{classgko_1_1OmpExecutor}{Omp\+Executor}, \doxylink{classgko_1_1CudaTimer}{Cuda\+Timer} for \doxylink{classgko_1_1CudaExecutor}{Cuda\+Executor}, \doxylink{classgko_1_1HipTimer}{Hip\+Timer} for \doxylink{classgko_1_1HipExecutor}{Hip\+Executor} or \doxylink{classgko_1_1DpcppTimer}{Dpcpp\+Timer} for \doxylink{classgko_1_1DpcppExecutor}{Dpcpp\+Executor}. 
\end{DoxyReturn}
\Hypertarget{classgko_1_1Timer_a36a9fae8d1f1df78829a264e0049addb}\index{gko::Timer@{gko::Timer}!create\_time\_point@{create\_time\_point}}
\index{create\_time\_point@{create\_time\_point}!gko::Timer@{gko::Timer}}
\doxysubsubsection{\texorpdfstring{create\_time\_point()}{create\_time\_point()}}
{\footnotesize\ttfamily \label{classgko_1_1Timer_a36a9fae8d1f1df78829a264e0049addb} 
\doxymbox{\hyperlink{classgko_1_1time__point}{time\+\_\+point}} gko::\+\+Timer::\+create\+\_\+time\+\_\+point (\begin{DoxyParamCaption}{}{}\end{DoxyParamCaption})}



Returns a newly created time point. 

Time points may only be used with the timer they were created with. \Hypertarget{classgko_1_1Timer_a096e0525fc320073239e63305b9bcea0}\index{gko::Timer@{gko::Timer}!difference@{difference}}
\index{difference@{difference}!gko::Timer@{gko::Timer}}
\doxysubsubsection{\texorpdfstring{difference()}{difference()}}
{\footnotesize\ttfamily \label{classgko_1_1Timer_a096e0525fc320073239e63305b9bcea0} 
std::\+chrono::\+nanoseconds gko::\+\+Timer::\+difference (\begin{DoxyParamCaption}\item[{\doxymbox{\hyperlink{classgko_1_1time__point}{time\+\_\+point}} \&}]{start}{, }\item[{\doxymbox{\hyperlink{classgko_1_1time__point}{time\+\_\+point}} \&}]{stop}{}\end{DoxyParamCaption})}



Computes the difference between the two time points in nanoseconds. 

The function synchronizes with {\ttfamily \doxylink{namespacegko_1_1stop}{stop}} before computing the difference.


\begin{DoxyParams}{Parameters}
{\em start} & the first time point (earlier) \\
\hline
{\em end} & the second time point (later) \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the difference between the time points in nanoseconds. 
\end{DoxyReturn}
\Hypertarget{classgko_1_1Timer_a9f6ea65e99c2e65d67803a7da3f4d8a1}\index{gko::Timer@{gko::Timer}!difference\_async@{difference\_async}}
\index{difference\_async@{difference\_async}!gko::Timer@{gko::Timer}}
\doxysubsubsection{\texorpdfstring{difference\_async()}{difference\_async()}}
{\footnotesize\ttfamily \label{classgko_1_1Timer_a9f6ea65e99c2e65d67803a7da3f4d8a1} 
virtual std::\+chrono::\+nanoseconds gko::\+\+Timer::\+difference\+\_\+async (\begin{DoxyParamCaption}\item[{const \doxymbox{\hyperlink{classgko_1_1time__point}{time\+\_\+point}} \&}]{start}{, }\item[{const \doxymbox{\hyperlink{classgko_1_1time__point}{time\+\_\+point}} \&}]{stop}{}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [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. {\ttfamily timer-\/\texorpdfstring{$>$}{>}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.


\begin{DoxyParams}{Parameters}
{\em start} & the first time point (earlier) \\
\hline
{\em end} & the second time point (later)\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the difference between the time points in nanoseconds. 
\end{DoxyReturn}


Implemented in \doxymbox{\hyperlink{classgko_1_1CpuTimer_a1ea7361ad460b0ce9b4cd66b9de35b15}{gko::\+\+Cpu\+Timer}}, \doxymbox{\hyperlink{classgko_1_1CudaTimer_ab338a41567ae37e0339564b3e2b5333b}{gko::\+\+Cuda\+Timer}}, \doxymbox{\hyperlink{classgko_1_1DpcppTimer_ae4a46b8259af4dad4c6a6014e333ecd2}{gko::\+\+Dpcpp\+Timer}}, and \doxymbox{\hyperlink{classgko_1_1HipTimer_a71d849b3113f8402082939806935670a}{gko::\+\+Hip\+Timer}}.

\Hypertarget{classgko_1_1Timer_af60e8cb620d9e87a90c6e799dc97cb76}\index{gko::Timer@{gko::Timer}!record@{record}}
\index{record@{record}!gko::Timer@{gko::Timer}}
\doxysubsubsection{\texorpdfstring{record()}{record()}}
{\footnotesize\ttfamily \label{classgko_1_1Timer_af60e8cb620d9e87a90c6e799dc97cb76} 
virtual void gko::\+\+Timer::\+record (\begin{DoxyParamCaption}\item[{\doxymbox{\hyperlink{classgko_1_1time__point}{time\+\_\+point}} \&}]{time}{}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [pure virtual]}}



Records a time point at the current time. 



Implemented in \doxymbox{\hyperlink{classgko_1_1CpuTimer_af9752e97dcf1d14d068d167d7a8c2137}{gko::\+\+Cpu\+Timer}}, \doxymbox{\hyperlink{classgko_1_1CudaTimer_ad3ace2bda308a6eca1455a87e27b6500}{gko::\+\+Cuda\+Timer}}, \doxymbox{\hyperlink{classgko_1_1DpcppTimer_ae0455fb540b6a22fdf754a6684dd391a}{gko::\+\+Dpcpp\+Timer}}, and \doxymbox{\hyperlink{classgko_1_1HipTimer_aa0d5d6a21951d8285c9792fe121d7e84}{gko::\+\+Hip\+Timer}}.

\Hypertarget{classgko_1_1Timer_a895f02685ba5da78e8cceef4246fd399}\index{gko::Timer@{gko::Timer}!wait@{wait}}
\index{wait@{wait}!gko::Timer@{gko::Timer}}
\doxysubsubsection{\texorpdfstring{wait()}{wait()}}
{\footnotesize\ttfamily \label{classgko_1_1Timer_a895f02685ba5da78e8cceef4246fd399} 
virtual void gko::\+\+Timer::\+wait (\begin{DoxyParamCaption}\item[{\doxymbox{\hyperlink{classgko_1_1time__point}{time\+\_\+point}} \&}]{time}{}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [pure virtual]}}



Waits until all kernels in-\/process when recording the time point are finished. 



Implemented in \doxymbox{\hyperlink{classgko_1_1CpuTimer_acf1d0af0c06e29c54b6e4b3b88839a63}{gko::\+\+Cpu\+Timer}}, \doxymbox{\hyperlink{classgko_1_1CudaTimer_a9b555245710892bad0ec3c092255530a}{gko::\+\+Cuda\+Timer}}, \doxymbox{\hyperlink{classgko_1_1DpcppTimer_aea1f314a29fecb8bd45c0ea4a0a17dc9}{gko::\+\+Dpcpp\+Timer}}, and \doxymbox{\hyperlink{classgko_1_1HipTimer_a015ae24012216bb2ac53aab461590e08}{gko::\+\+Hip\+Timer}}.



The documentation for this class was generated from the following file:\+\begin{DoxyCompactItemize}
\item 
ginkgo/\+core/\+base/\+timer.\+hpp\end{DoxyCompactItemize}
