\doxysection{timer.\+hpp}
\hypertarget{timer_8hpp_source}{}\label{timer_8hpp_source}\index{ginkgo/core/base/timer.hpp@{ginkgo/core/base/timer.hpp}}

\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{comment}{//\ SPDX-\/FileCopyrightText:\ 2017\ -\/\ 2024\ The\ Ginkgo\ authors}}
\DoxyCodeLine{00002\ \textcolor{comment}{//}}
\DoxyCodeLine{00003\ \textcolor{comment}{//\ SPDX-\/License-\/Identifier:\ BSD-\/3-\/Clause}}
\DoxyCodeLine{00004\ }
\DoxyCodeLine{00005\ \textcolor{preprocessor}{\#ifndef\ GKO\_PUBLIC\_CORE\_BASE\_TIMER\_HPP\_}}
\DoxyCodeLine{00006\ \textcolor{preprocessor}{\#define\ GKO\_PUBLIC\_CORE\_BASE\_TIMER\_HPP\_}}
\DoxyCodeLine{00007\ }
\DoxyCodeLine{00008\ }
\DoxyCodeLine{00009\ \textcolor{preprocessor}{\#include\ <chrono>}}
\DoxyCodeLine{00010\ }
\DoxyCodeLine{00011\ \textcolor{preprocessor}{\#include\ <ginkgo/core/base/executor.hpp>}}
\DoxyCodeLine{00012\ }
\DoxyCodeLine{00013\ }
\DoxyCodeLine{00014\ \textcolor{keyword}{namespace\ }\doxymbox{\hyperlink{namespacegko}{gko}}\ \{}
\DoxyCodeLine{00015\ }
\DoxyCodeLine{00016\ }
\DoxyCodeLine{00020\ \textcolor{keyword}{class\ }time\_point\ \{}
\DoxyCodeLine{00021\ \textcolor{keyword}{public}:}
\DoxyCodeLine{00022\ \ \ \ \ \string~time\_point();}
\DoxyCodeLine{00023\ }
\DoxyCodeLine{00024\ \ \ \ \ time\_point(time\_point\&\&);}
\DoxyCodeLine{00025\ }
\DoxyCodeLine{00026\ \ \ \ \ time\_point\&\ operator=(time\_point\&\&);}
\DoxyCodeLine{00027\ }
\DoxyCodeLine{00028\ \ \ \ \ time\_point(\textcolor{keyword}{const}\ time\_point\&)\ =\ \textcolor{keyword}{delete};}
\DoxyCodeLine{00029\ }
\DoxyCodeLine{00030\ \ \ \ \ time\_point\&\ operator=(\textcolor{keyword}{const}\ time\_point\&)\ =\ \textcolor{keyword}{delete};}
\DoxyCodeLine{00031\ }
\DoxyCodeLine{00032\ \textcolor{keyword}{private}:}
\DoxyCodeLine{00033\ \ \ \ \ time\_point();}
\DoxyCodeLine{00034\ }
\DoxyCodeLine{00035\ \ \ \ \ \textcolor{keyword}{friend}\ \textcolor{keyword}{class\ }Timer;}
\DoxyCodeLine{00036\ \ \ \ \ \textcolor{keyword}{friend}\ \textcolor{keyword}{class\ }CpuTimer;}
\DoxyCodeLine{00037\ \ \ \ \ \textcolor{keyword}{friend}\ \textcolor{keyword}{class\ }CudaTimer;}
\DoxyCodeLine{00038\ \ \ \ \ \textcolor{keyword}{friend}\ \textcolor{keyword}{class\ }HipTimer;}
\DoxyCodeLine{00039\ \ \ \ \ \textcolor{keyword}{friend}\ \textcolor{keyword}{class\ }DpcppTimer;}
\DoxyCodeLine{00040\ }
\DoxyCodeLine{00042\ \ \ \ \ \textcolor{keyword}{enum\ class}\ type\ \{}
\DoxyCodeLine{00044\ \ \ \ \ \ \ \ \ cpu,}
\DoxyCodeLine{00046\ \ \ \ \ \ \ \ \ cuda,}
\DoxyCodeLine{00048\ \ \ \ \ \ \ \ \ hip,}
\DoxyCodeLine{00050\ \ \ \ \ \ \ \ \ dpcpp,}
\DoxyCodeLine{00051\ \ \ \ \ \};}
\DoxyCodeLine{00052\ }
\DoxyCodeLine{00053\ \ \ \ \ type\ type\_;}
\DoxyCodeLine{00054\ \ \ \ \ \textcolor{keyword}{union\ }data\_union\ \{}
\DoxyCodeLine{00055\ \ \ \ \ \ \ \ \ CUevent\_st*\ cuda\_event;}
\DoxyCodeLine{00056\ \ \ \ \ \ \ \ \ GKO\_HIP\_EVENT\_STRUCT*\ hip\_event;}
\DoxyCodeLine{00057\ \ \ \ \ \ \ \ \ sycl::event*\ dpcpp\_event;}
\DoxyCodeLine{00058\ \ \ \ \ \ \ \ \ std::chrono::steady\_clock::time\_point\ chrono;}
\DoxyCodeLine{00059\ }
\DoxyCodeLine{00060\ \ \ \ \ \ \ \ \ data\_union();}
\DoxyCodeLine{00061\ \ \ \ \ \}\ data\_;}
\DoxyCodeLine{00062\ \};}
\DoxyCodeLine{00063\ }
\DoxyCodeLine{00064\ }
\DoxyCodeLine{00080\ \textcolor{keyword}{class\ }\doxymbox{\hyperlink{classgko_1_1Timer}{Timer}}\ \{}
\DoxyCodeLine{00081\ \textcolor{keyword}{public}:}
\DoxyCodeLine{00082\ \ \ \ \ \textcolor{keyword}{virtual}\ \doxymbox{\hyperlink{classgko_1_1Timer}{\string~Timer}}()\ =\ \textcolor{keywordflow}{default};}
\DoxyCodeLine{00083\ }
\DoxyCodeLine{00088\ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1time__point}{time\_point}}\ \doxymbox{\hyperlink{classgko_1_1Timer_a36a9fae8d1f1df78829a264e0049addb}{create\_time\_point}}();}
\DoxyCodeLine{00089\ }
\DoxyCodeLine{00093\ \ \ \ \ \textcolor{keyword}{virtual}\ \textcolor{keywordtype}{void}\ \doxymbox{\hyperlink{classgko_1_1Timer_af60e8cb620d9e87a90c6e799dc97cb76}{record}}(\doxymbox{\hyperlink{classgko_1_1time__point}{time\_point}}\&\ time)\ =\ 0;}
\DoxyCodeLine{00094\ }
\DoxyCodeLine{00099\ \ \ \ \ \textcolor{keyword}{virtual}\ \textcolor{keywordtype}{void}\ \doxymbox{\hyperlink{classgko_1_1Timer_a895f02685ba5da78e8cceef4246fd399}{wait}}(\doxymbox{\hyperlink{classgko_1_1time__point}{time\_point}}\&\ time)\ =\ 0;}
\DoxyCodeLine{00100\ }
\DoxyCodeLine{00109\ \ \ \ \ 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}});}
\DoxyCodeLine{00110\ }
\DoxyCodeLine{00123\ \ \ \ \ \textcolor{keyword}{virtual}\ std::chrono::nanoseconds\ \doxymbox{\hyperlink{classgko_1_1Timer_a9f6ea65e99c2e65d67803a7da3f4d8a1}{difference\_async}}(}
\DoxyCodeLine{00124\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1time__point}{time\_point}}\&\ start,\ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1time__point}{time\_point}}\&\ \doxymbox{\hyperlink{namespacegko_1_1stop}{stop}})\ =\ 0;}
\DoxyCodeLine{00125\ }
\DoxyCodeLine{00136\ \ \ \ \ \textcolor{keyword}{static}\ std::unique\_ptr<Timer>\ \doxymbox{\hyperlink{classgko_1_1Timer_a8e44eae260c1b3ad7a642338c1c5ce1e}{create\_for\_executor}}(}
\DoxyCodeLine{00137\ \ \ \ \ \ \ \ \ std::shared\_ptr<const\ Executor>\ exec);}
\DoxyCodeLine{00138\ }
\DoxyCodeLine{00139\ \textcolor{keyword}{protected}:}
\DoxyCodeLine{00141\ \ \ \ \ \textcolor{keyword}{virtual}\ \textcolor{keywordtype}{void}\ init\_time\_point(\doxymbox{\hyperlink{classgko_1_1time__point}{time\_point}}\&\ time)\ =\ 0;}
\DoxyCodeLine{00142\ \};}
\DoxyCodeLine{00143\ }
\DoxyCodeLine{00144\ }
\DoxyCodeLine{00146\ \textcolor{keyword}{class\ }\doxymbox{\hyperlink{classgko_1_1CpuTimer}{CpuTimer}}\ :\ \textcolor{keyword}{public}\ \doxymbox{\hyperlink{classgko_1_1Timer}{Timer}}\ \{}
\DoxyCodeLine{00147\ \textcolor{keyword}{public}:}
\DoxyCodeLine{00148\ \ \ \ \ \textcolor{keywordtype}{void}\ \doxymbox{\hyperlink{classgko_1_1CpuTimer_af9752e97dcf1d14d068d167d7a8c2137}{record}}(\doxymbox{\hyperlink{classgko_1_1time__point}{time\_point}}\&\ time)\ \textcolor{keyword}{override};}
\DoxyCodeLine{00149\ }
\DoxyCodeLine{00150\ \ \ \ \ \textcolor{keywordtype}{void}\ \doxymbox{\hyperlink{classgko_1_1CpuTimer_acf1d0af0c06e29c54b6e4b3b88839a63}{wait}}(\doxymbox{\hyperlink{classgko_1_1time__point}{time\_point}}\&\ time)\ \textcolor{keyword}{override};}
\DoxyCodeLine{00151\ }
\DoxyCodeLine{00152\ \ \ \ \ std::chrono::nanoseconds\ \doxymbox{\hyperlink{classgko_1_1CpuTimer_a1ea7361ad460b0ce9b4cd66b9de35b15}{difference\_async}}(\textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1time__point}{time\_point}}\&\ start,}
\DoxyCodeLine{00153\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1time__point}{time\_point}}\&\ \doxymbox{\hyperlink{namespacegko_1_1stop}{stop}})\ \textcolor{keyword}{override};}
\DoxyCodeLine{00154\ }
\DoxyCodeLine{00155\ \textcolor{keyword}{protected}:}
\DoxyCodeLine{00156\ \ \ \ \ \textcolor{keywordtype}{void}\ init\_time\_point(\doxymbox{\hyperlink{classgko_1_1time__point}{time\_point}}\&\ time)\ \textcolor{keyword}{override};}
\DoxyCodeLine{00157\ \};}
\DoxyCodeLine{00158\ }
\DoxyCodeLine{00159\ }
\DoxyCodeLine{00166\ \textcolor{keyword}{class\ }CudaTimer\ :\ \textcolor{keyword}{public}\ \doxymbox{\hyperlink{classgko_1_1Timer}{Timer}}\ \{}
\DoxyCodeLine{00167\ \textcolor{keyword}{public}:}
\DoxyCodeLine{00168\ \ \ \ \ \textcolor{keywordtype}{void}\ \doxymbox{\hyperlink{classgko_1_1CudaTimer_ad3ace2bda308a6eca1455a87e27b6500}{record}}(\doxymbox{\hyperlink{classgko_1_1time__point}{time\_point}}\&\ time)\ \textcolor{keyword}{override};}
\DoxyCodeLine{00169\ }
\DoxyCodeLine{00170\ \ \ \ \ \textcolor{keywordtype}{void}\ \doxymbox{\hyperlink{classgko_1_1CudaTimer_a9b555245710892bad0ec3c092255530a}{wait}}(\doxymbox{\hyperlink{classgko_1_1time__point}{time\_point}}\&\ time)\ \textcolor{keyword}{override};}
\DoxyCodeLine{00171\ }
\DoxyCodeLine{00172\ \ \ \ \ std::chrono::nanoseconds\ \doxymbox{\hyperlink{classgko_1_1CudaTimer_ab338a41567ae37e0339564b3e2b5333b}{difference\_async}}(\textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1time__point}{time\_point}}\&\ start,}
\DoxyCodeLine{00173\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1time__point}{time\_point}}\&\ \doxymbox{\hyperlink{namespacegko_1_1stop}{stop}})\ \textcolor{keyword}{override};}
\DoxyCodeLine{00174\ }
\DoxyCodeLine{00175\ \ \ \ \ CudaTimer(std::shared\_ptr<const\ CudaExecutor>\ exec);}
\DoxyCodeLine{00176\ }
\DoxyCodeLine{00177\ \textcolor{keyword}{protected}:}
\DoxyCodeLine{00178\ \ \ \ \ \textcolor{keywordtype}{void}\ init\_time\_point(\doxymbox{\hyperlink{classgko_1_1time__point}{time\_point}}\&\ time)\ \textcolor{keyword}{override};}
\DoxyCodeLine{00179\ }
\DoxyCodeLine{00180\ \textcolor{keyword}{private}:}
\DoxyCodeLine{00181\ \ \ \ \ \textcolor{keywordtype}{int}\ device\_id\_;}
\DoxyCodeLine{00182\ \ \ \ \ CUstream\_st*\ stream\_;}
\DoxyCodeLine{00183\ \};}
\DoxyCodeLine{00184\ }
\DoxyCodeLine{00185\ }
\DoxyCodeLine{00192\ \textcolor{keyword}{class\ }HipTimer\ :\ \textcolor{keyword}{public}\ \doxymbox{\hyperlink{classgko_1_1Timer}{Timer}}\ \{}
\DoxyCodeLine{00193\ \textcolor{keyword}{public}:}
\DoxyCodeLine{00194\ \ \ \ \ \textcolor{keywordtype}{void}\ \doxymbox{\hyperlink{classgko_1_1HipTimer_aa0d5d6a21951d8285c9792fe121d7e84}{record}}(\doxymbox{\hyperlink{classgko_1_1time__point}{time\_point}}\&\ time)\ \textcolor{keyword}{override};}
\DoxyCodeLine{00195\ }
\DoxyCodeLine{00196\ \ \ \ \ \textcolor{keywordtype}{void}\ \doxymbox{\hyperlink{classgko_1_1HipTimer_a015ae24012216bb2ac53aab461590e08}{wait}}(\doxymbox{\hyperlink{classgko_1_1time__point}{time\_point}}\&\ time)\ \textcolor{keyword}{override};}
\DoxyCodeLine{00197\ }
\DoxyCodeLine{00198\ \ \ \ \ std::chrono::nanoseconds\ \doxymbox{\hyperlink{classgko_1_1HipTimer_a71d849b3113f8402082939806935670a}{difference\_async}}(\textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1time__point}{time\_point}}\&\ start,}
\DoxyCodeLine{00199\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1time__point}{time\_point}}\&\ \doxymbox{\hyperlink{namespacegko_1_1stop}{stop}})\ \textcolor{keyword}{override};}
\DoxyCodeLine{00200\ }
\DoxyCodeLine{00201\ \ \ \ \ HipTimer(std::shared\_ptr<const\ HipExecutor>\ exec);}
\DoxyCodeLine{00202\ }
\DoxyCodeLine{00203\ \textcolor{keyword}{protected}:}
\DoxyCodeLine{00204\ \ \ \ \ \textcolor{keywordtype}{void}\ init\_time\_point(\doxymbox{\hyperlink{classgko_1_1time__point}{time\_point}}\&\ time)\ \textcolor{keyword}{override};}
\DoxyCodeLine{00205\ }
\DoxyCodeLine{00206\ \textcolor{keyword}{private}:}
\DoxyCodeLine{00207\ \ \ \ \ \textcolor{keywordtype}{int}\ device\_id\_;}
\DoxyCodeLine{00208\ \ \ \ \ GKO\_HIP\_STREAM\_STRUCT*\ stream\_;}
\DoxyCodeLine{00209\ \};}
\DoxyCodeLine{00210\ }
\DoxyCodeLine{00211\ }
\DoxyCodeLine{00213\ \textcolor{keyword}{class\ }DpcppTimer\ :\ \textcolor{keyword}{public}\ \doxymbox{\hyperlink{classgko_1_1Timer}{Timer}}\ \{}
\DoxyCodeLine{00214\ \textcolor{keyword}{public}:}
\DoxyCodeLine{00215\ \ \ \ \ \textcolor{keywordtype}{void}\ \doxymbox{\hyperlink{classgko_1_1DpcppTimer_ae0455fb540b6a22fdf754a6684dd391a}{record}}(\doxymbox{\hyperlink{classgko_1_1time__point}{time\_point}}\&\ time)\ \textcolor{keyword}{override};}
\DoxyCodeLine{00216\ }
\DoxyCodeLine{00217\ \ \ \ \ \textcolor{keywordtype}{void}\ \doxymbox{\hyperlink{classgko_1_1DpcppTimer_aea1f314a29fecb8bd45c0ea4a0a17dc9}{wait}}(\doxymbox{\hyperlink{classgko_1_1time__point}{time\_point}}\&\ time)\ \textcolor{keyword}{override};}
\DoxyCodeLine{00218\ }
\DoxyCodeLine{00219\ \ \ \ \ std::chrono::nanoseconds\ \doxymbox{\hyperlink{classgko_1_1DpcppTimer_ae4a46b8259af4dad4c6a6014e333ecd2}{difference\_async}}(\textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1time__point}{time\_point}}\&\ start,}
\DoxyCodeLine{00220\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1time__point}{time\_point}}\&\ \doxymbox{\hyperlink{namespacegko_1_1stop}{stop}})\ \textcolor{keyword}{override};}
\DoxyCodeLine{00221\ }
\DoxyCodeLine{00222\ \ \ \ \ DpcppTimer(std::shared\_ptr<const\ DpcppExecutor>\ exec);}
\DoxyCodeLine{00223\ }
\DoxyCodeLine{00224\ \textcolor{keyword}{protected}:}
\DoxyCodeLine{00225\ \ \ \ \ \textcolor{keywordtype}{void}\ init\_time\_point(\doxymbox{\hyperlink{classgko_1_1time__point}{time\_point}}\&\ time)\ \textcolor{keyword}{override};}
\DoxyCodeLine{00226\ }
\DoxyCodeLine{00227\ \textcolor{keyword}{private}:}
\DoxyCodeLine{00228\ \ \ \ \ sycl::queue*\ queue\_;}
\DoxyCodeLine{00229\ \};}
\DoxyCodeLine{00230\ }
\DoxyCodeLine{00231\ }
\DoxyCodeLine{00232\ \}\ \ \textcolor{comment}{//\ namespace\ gko}}
\DoxyCodeLine{00233\ }
\DoxyCodeLine{00234\ }
\DoxyCodeLine{00235\ \textcolor{preprocessor}{\#endif\ \ }\textcolor{comment}{//\ GKO\_PUBLIC\_CORE\_BASE\_TIMER\_HPP\_}}

\end{DoxyCode}
