\doxysection{scoped\+\_\+device\+\_\+id\+\_\+guard.\+hpp}
\hypertarget{scoped__device__id__guard_8hpp_source}{}\label{scoped__device__id__guard_8hpp_source}\index{ginkgo/core/base/scoped\_device\_id\_guard.hpp@{ginkgo/core/base/scoped\_device\_id\_guard.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\_SCOPED\_DEVICE\_ID\_GUARD\_HPP\_}}
\DoxyCodeLine{00006\ \textcolor{preprocessor}{\#define\ GKO\_PUBLIC\_CORE\_BASE\_SCOPED\_DEVICE\_ID\_GUARD\_HPP\_}}
\DoxyCodeLine{00007\ }
\DoxyCodeLine{00008\ }
\DoxyCodeLine{00009\ \textcolor{preprocessor}{\#include\ <memory>}}
\DoxyCodeLine{00010\ }
\DoxyCodeLine{00011\ }
\DoxyCodeLine{00012\ \textcolor{keyword}{namespace\ }\doxymbox{\hyperlink{namespacegko}{gko}}\ \{}
\DoxyCodeLine{00013\ }
\DoxyCodeLine{00014\ }
\DoxyCodeLine{00015\ \textcolor{keyword}{class\ }\doxymbox{\hyperlink{classgko_1_1OmpExecutor}{OmpExecutor}};}
\DoxyCodeLine{00016\ \textcolor{keyword}{class\ }\doxymbox{\hyperlink{classgko_1_1ReferenceExecutor}{ReferenceExecutor}};}
\DoxyCodeLine{00017\ \textcolor{keyword}{class\ }\doxymbox{\hyperlink{classgko_1_1CudaExecutor}{CudaExecutor}};}
\DoxyCodeLine{00018\ \textcolor{keyword}{class\ }\doxymbox{\hyperlink{classgko_1_1HipExecutor}{HipExecutor}};}
\DoxyCodeLine{00019\ \textcolor{keyword}{class\ }\doxymbox{\hyperlink{classgko_1_1DpcppExecutor}{DpcppExecutor}};}
\DoxyCodeLine{00020\ }
\DoxyCodeLine{00021\ }
\DoxyCodeLine{00022\ \textcolor{keyword}{namespace\ }detail\ \{}
\DoxyCodeLine{00023\ }
\DoxyCodeLine{00024\ }
\DoxyCodeLine{00029\ \textcolor{keyword}{class\ }generic\_scoped\_device\_id\_guard\ \{}
\DoxyCodeLine{00030\ \textcolor{keyword}{public}:}
\DoxyCodeLine{00031\ \ \ \ \ generic\_scoped\_device\_id\_guard()\ =\ \textcolor{keywordflow}{default};}
\DoxyCodeLine{00032\ }
\DoxyCodeLine{00033\ \ \ \ \ \textcolor{comment}{//\ TODO:\ this\ should\ be\ a\ purely\ virtual\ function,\ but\ somehow\ that\ leads\ to}}
\DoxyCodeLine{00034\ \ \ \ \ \textcolor{comment}{//\ linker\ errors}}
\DoxyCodeLine{00035\ \ \ \ \ \textcolor{keyword}{virtual}\ \string~generic\_scoped\_device\_id\_guard()\ =\ \textcolor{keywordflow}{default};}
\DoxyCodeLine{00036\ }
\DoxyCodeLine{00037\ \ \ \ \ \textcolor{comment}{//\ Prohibit\ copy\ construction}}
\DoxyCodeLine{00038\ \ \ \ \ generic\_scoped\_device\_id\_guard(}
\DoxyCodeLine{00039\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ generic\_scoped\_device\_id\_guard\&\ other)\ =\ \textcolor{keyword}{delete};}
\DoxyCodeLine{00040\ }
\DoxyCodeLine{00041\ \ \ \ \ \textcolor{comment}{//\ Prohibit\ copy\ assignment}}
\DoxyCodeLine{00042\ \ \ \ \ generic\_scoped\_device\_id\_guard\&\ operator=(}
\DoxyCodeLine{00043\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ generic\_scoped\_device\_id\_guard\&\ other)\ =\ \textcolor{keyword}{delete};}
\DoxyCodeLine{00044\ \};}
\DoxyCodeLine{00045\ }
\DoxyCodeLine{00046\ }
\DoxyCodeLine{00047\ \}\ \ \textcolor{comment}{//\ namespace\ detail}}
\DoxyCodeLine{00048\ }
\DoxyCodeLine{00049\ }
\DoxyCodeLine{00076\ \textcolor{keyword}{class\ }\doxymbox{\hyperlink{classgko_1_1scoped__device__id__guard_acc33bf23522f0697b0728c467683a77f}{scoped\_device\_id\_guard}}\ \{}
\DoxyCodeLine{00077\ \textcolor{keyword}{public}:}
\DoxyCodeLine{00086\ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1scoped__device__id__guard_acc33bf23522f0697b0728c467683a77f}{scoped\_device\_id\_guard}}(\textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1ReferenceExecutor}{ReferenceExecutor}}*\ exec,\ \textcolor{keywordtype}{int}\ device\_id);}
\DoxyCodeLine{00087\ }
\DoxyCodeLine{00096\ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1scoped__device__id__guard_a793cf06e7d67c04e586a0416c6623623}{scoped\_device\_id\_guard}}(\textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1OmpExecutor}{OmpExecutor}}*\ exec,\ \textcolor{keywordtype}{int}\ device\_id);}
\DoxyCodeLine{00097\ }
\DoxyCodeLine{00106\ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1scoped__device__id__guard_aa1ec4e747e4b094bb72f63c6c2d71f24}{scoped\_device\_id\_guard}}(\textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1CudaExecutor}{CudaExecutor}}*\ exec,\ \textcolor{keywordtype}{int}\ device\_id);}
\DoxyCodeLine{00107\ }
\DoxyCodeLine{00116\ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1scoped__device__id__guard_a97bba4ea5903f97038952382e9dcd702}{scoped\_device\_id\_guard}}(\textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1HipExecutor}{HipExecutor}}*\ exec,\ \textcolor{keywordtype}{int}\ device\_id);}
\DoxyCodeLine{00117\ }
\DoxyCodeLine{00126\ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1scoped__device__id__guard_a3cc19e477c4992b07b22491841bfd9e0}{scoped\_device\_id\_guard}}(\textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1DpcppExecutor}{DpcppExecutor}}*\ exec,\ \textcolor{keywordtype}{int}\ device\_id);}
\DoxyCodeLine{00127\ }
\DoxyCodeLine{00128\ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1scoped__device__id__guard_acc33bf23522f0697b0728c467683a77f}{scoped\_device\_id\_guard}}()\ =\ \textcolor{keywordflow}{default};}
\DoxyCodeLine{00129\ }
\DoxyCodeLine{00130\ \ \ \ \ \textcolor{comment}{//\ Prohibit\ copy\ construction.}}
\DoxyCodeLine{00131\ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1scoped__device__id__guard_acc33bf23522f0697b0728c467683a77f}{scoped\_device\_id\_guard}}(\textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1scoped__device__id__guard_acc33bf23522f0697b0728c467683a77f}{scoped\_device\_id\_guard}}\&)\ =\ \textcolor{keyword}{delete};}
\DoxyCodeLine{00132\ }
\DoxyCodeLine{00133\ \ \ \ \ \textcolor{comment}{//\ Allow\ move\ construction.}}
\DoxyCodeLine{00134\ \ \ \ \ \textcolor{comment}{//\ These\ are\ needed,\ since\ C++14\ does\ not\ guarantee\ copy\ elision.}}
\DoxyCodeLine{00135\ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1scoped__device__id__guard_acc33bf23522f0697b0728c467683a77f}{scoped\_device\_id\_guard}}(\doxymbox{\hyperlink{classgko_1_1scoped__device__id__guard_acc33bf23522f0697b0728c467683a77f}{scoped\_device\_id\_guard}}\&\&)\ =\ \textcolor{keywordflow}{default};}
\DoxyCodeLine{00136\ }
\DoxyCodeLine{00137\ \ \ \ \ \textcolor{comment}{//\ Prohibit\ copy\ assignment.}}
\DoxyCodeLine{00138\ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1scoped__device__id__guard_acc33bf23522f0697b0728c467683a77f}{scoped\_device\_id\_guard}}\&\ operator=(\textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1scoped__device__id__guard_acc33bf23522f0697b0728c467683a77f}{scoped\_device\_id\_guard}}\&)\ =\ \textcolor{keyword}{delete};}
\DoxyCodeLine{00139\ }
\DoxyCodeLine{00140\ \ \ \ \ \textcolor{comment}{//\ Allow\ move\ construction.}}
\DoxyCodeLine{00141\ \ \ \ \ \textcolor{comment}{//\ These\ are\ needed,\ since\ C++14\ does\ not\ guarantee\ copy\ elision.}}
\DoxyCodeLine{00142\ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1scoped__device__id__guard_acc33bf23522f0697b0728c467683a77f}{scoped\_device\_id\_guard}}\&\ operator=(\doxymbox{\hyperlink{classgko_1_1scoped__device__id__guard_acc33bf23522f0697b0728c467683a77f}{scoped\_device\_id\_guard}}\&\&)\ =\ \textcolor{keywordflow}{default};}
\DoxyCodeLine{00143\ }
\DoxyCodeLine{00144\ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1scoped__device__id__guard_acc33bf23522f0697b0728c467683a77f}{\string~scoped\_device\_id\_guard}}()\ =\ \textcolor{keywordflow}{default};}
\DoxyCodeLine{00145\ }
\DoxyCodeLine{00146\ \textcolor{keyword}{private}:}
\DoxyCodeLine{00147\ \ \ \ \ std::unique\_ptr<detail::generic\_scoped\_device\_id\_guard>\ scope\_;}
\DoxyCodeLine{00148\ \};}
\DoxyCodeLine{00149\ }
\DoxyCodeLine{00150\ }
\DoxyCodeLine{00151\ \}\ \ \textcolor{comment}{//\ namespace\ gko}}
\DoxyCodeLine{00152\ }
\DoxyCodeLine{00153\ \textcolor{preprocessor}{\#endif\ \ }\textcolor{comment}{//\ GKO\_PUBLIC\_CORE\_BASE\_SCOPED\_DEVICE\_ID\_GUARD\_HPP\_}}

\end{DoxyCode}
