DevicePolicies

The class-template DevicePolicies is designed to serve as a template parameter to the Hybrid_ struct. It offers a metaprogramming interface which can be investigated to find out which device to use for each of the routines. Its definition is listed below. For convenience, the output from the example in Section 4 is used.


\begin{lstlisting}
// Possible devices
struct CPU{};
struct GPU{};
struct Dummy{...
...ame Get_<Policy<Dummy>, PolicyList ...>::Device Device;
};
};
\end{lstlisting}
When a type of the form DevicePolicies<...> is passed as a template parameter to a Hybrid_, the count-value can be used to find out how many policies were specified (mostly to check for consistency). More importantly, its Get-member is used to get the device that should be used for a certain routine. In our case, for example Get<SumVec3Device>::Device will be a typedef for either CPU or GPU, depending on what you specified. Note that Get expects a template template argument. This prevented me from using template specialization techniques to find out which device was passed as a template argument to a certain policy. Instead, I had to equip each of the policies with a unique ID that is used to match the template-template parameter and extract its device-type.

Joren Heit 2013-12-17