DevicePolicies

In the previous section, we have already encountered the DevicePolicies that are used to synchronize data between CPU and GPU. These policies of course have to be declared somewhere, which is done in the X_devicepolicies.h file. It defines the macro ADD_DEVICE_POLICY which allows you to easily add policies. It expects 2 arguments: the name of the policy and its ID, which should be unique! I suggest you just keep incrementing this ID to keep things simple. Once your policy has been added, you can move back to the header file in which Hybrid_ is declared.

A lot is going on in the private section of Hybrid_, but we now focus on the list of typedefs of the form
\begin{lstlisting}
typedef typename UseParent<typename DevicePolicies::template Get<RoutineDevice>::Device>::Parent RoutineDevice;
\end{lstlisting}
Here, RoutineDevice is the device used for the routine you are adding. It uses the TMP mechanism to find out which device, CPU or GPU, you have specified in the DevicePolicices. Again, just copy-paste and make sure the names are consistent.

Of course, the typedef for DevicePolicies itself should also be edited. As you might remember, it resides in the main header X.h (an example was shown in Section 4.2.5).

Joren Heit 2013-12-17