# Exploiting parallelism within a single heterogeneous computing node

I'm looking for a library to exploit parallelism within a single heterogeneous computing node (possibly using Accelerators like Xeon Phi or nVidia's GPGPU's) in a C++ FV/DG code using hierarchical octree-like grids. It should

• support multiple back-ends (e.g. OpenCL, CUDA, OpenMP, OpenACC, ...)
• hopefully be generic enough to support back-ends from the future,
• be easy to install/configure,
• be easy to use.

Linear algebra would be nice, but the library should at least be able to do a simple transform with a user defined kernel on a computing device:

auto vd = device_vector<double>{ 11., 22., 33., 44. };
transform(vd, begin(vd), [](double vd_i){ return 2. * vd_i; });
host_vector<double> vh = vd;  // no-op if the device is the CPU
for (auto vh_i&& : vh) { cout << vh_i << "\n"; } // 22, 44, 66, 88


I've looked at Intel TBB, openMP, openACC, AMD's bolt, and nVidia's Thrust.

Thrust seems to be the best fit for my application because:

• it provides different backends: CUDA, TBB, and OpenMP (no OpenCL),
• it has a familiar STL-like interface: host/device containers, iterators, and algorithms,
• the documentation seems nice.

However, I have no experience at all (and don't know anyone who has) building an hybrid MPI-Thrust application.

So to my question:

• Is there any other library worth looking into that might fit my needs better?
• Does anyone has experience with hybrid MPI-Thrust applications that can comment on how good of a fit Thrust is for such a thing?

I suggest you take a look at ViennaCL. It's written in c++, leverages template meta programming, and supports OpenCL, CUDA, and OpenMP as backends. Just like Thrust, it has abstraction layers for device and host containers and implements several algorithms, mostly in the area of linear algebra. Although, device integer containers are missing as of version 1.4.2 (apparently they will be included in 1.5.0)
Moreover, what I like about it is that it nicely wraps around OpenCL API and simplifies the task of writing custom OpenCL kernels. I have not used ViennaCL or Thrust in a hybrid environment so I cannot comment on that. However, I know PETSc has interface to ViennaCL and supports hybrid mpi-viennacl vec types. This should simplify the hybrid approach -- Its actually one of my future projects to utilize this feature.
All in all, I recommend you take a look at their webpage. Oh, I almsot forgot to mention that ViennaCL is very nicely documented :).