Member Declarations
Let us
start with declaring the new member-functions in every necessary
header, assuming that you want both a CPU and a GPU routine to be
implemented. In the X_default_cpu.h and
X_default_gpu.h header-files, you will find
function-declarations of the form void routine() in the
public section and void routine_() (note the underscore) in
the private section of the class interface. This is where the new
routine should be declared in two-fold: with and without a trailing
underscore. The non-underscored version is merely a wrapper of the
underscored version, and takes care of the timing (if necessary). Each
of the non-underscored routines has an inline implementation in the
same file, which looks like this (same for DefaultGPU):
Assuming there are already other inline implementations present, you
can simply copy-paste and change the routine-identifier.
The Hybrid_ class also contains function-declarations in its
public section (non-underscored). The implementation is again a
wrapper, this time of either the CPU or GPU version. Exactly which one
is determined by the DevicePolicies, which we will come to
later. Their inline implementation (in the same file) should look like
this:
This is also the tricky part. You have to figure out for yourself
which device has the data that is used by this particular routine
(SourceDevice), and make sure you synchronize with it.
Joren Heit
2013-12-17