The Heterogeneous Programming Library (HPL) is a C++ framework that provides an easy and portable way to exploit heterogeneous computing systems on top of the OpenCL standard. HPL can be used in two ways that can be mixed:
- on top of existing OpenCL kernels, largely simplifying their usage, or
- developing the heterogeneous kernels in the embedded language it provides, which is naturally integrated in C++
As an example, the code below computes the SAXPY function Y = alpha * X + Y
, which is described in the C++ function saxpy using the HPL embedded language.
#include "HPL.h"
using namespace HPL;
//SAXPY kernel in which thread idx computes y[idx]
void saxpy(Array<float,1> y, Array<float,1> x, Float alpha)
{
y[idx] = alpha * x[idx] + y[idx];
}
int main(int argc, char **argv)
{ Array<float, 1> x(1000), y(1000);
float alpha;
//the vectors x and y are filled in with data (not shown)
//Run SAXPY on an accelerator, or the CPU if no OpenCL capable accelerator is found
eval(saxpy)(y, x, alpha);
}
If an OpenCL C kernel is already available, it can be associated to a C++ function that is used to invoke it in HPL. The function parameter list specifies whether each non scalar arguments is an input, an output or both. HPL can get the kernel from a file or a string in the program. The following example illustrates this second possibility.
#include "HPL.h"
using namespace HPL;
//string with the OpenCL C kernel for SAXPY
const char *saxpy_kernel =
"__kernel void saxpy(__global float *y, __global float *x, float alpha) {\n \
int i = get_global_id(0); \n \
y[i] = alpha * x[i] + y[i]; \n \
}";
//Function whose arguments define the kernel for HPL
void saxpy_handle(InOut< Array<float,1> > y, In< Array<float,1> > x, Float alpha)
{ }
int main(int argc, char **argv)
{ Array<float, 1> x(1000), y(1000);
float alpha;
//the vectors x and y are filled in with data (not shown)
//associate the kernel string with the HPL function handle
nativeHandle(saxpy_handle, “saxpy”, saxpy_kernel);
eval(saxpy_handle)(y, x, alpha);
}
- At least one OpenCL distribution that supports version 1.1 of the standard. HPL currently supports AMD, Apple, Intel and NVIDIA implementations.
- A C++ compiler that supports C++11
- M. Viñas, B.B. Fraguela, D. Andrade, R. Doallo. Heterogeneous Distributed Computing based on High Level Abstractions. Concurrency and Computation: Practice and Experience, 30(17):e4664, September 2018.
- M. Viñas, B.B. Fraguela, D. Andrade, R. Doallo. Facilitating the development of stencil applications using the Heterogeneous Programming Library. Concurrency and Computation: Practice and Experience, 29(12):e4152, June 2017.
- N. Losada, B.B. Fraguela, P. González, M.J. Martín. A portable and adaptable fault tolerance solution for heterogeneous applications. Journal of Parallel and Distributed Computing, 104:146-158, June 2017.
- M. Viñas, B.B. Fraguela, D. Andrade, R. Doallo. High Productivity Multi-device Exploitation with the Heterogeneous Programming Library. Journal of Parallel and Distributed Computing, 101:51-68, March 2017.
- M. Viñas, B.B. Fraguela, D. Andrade, R. Doallo. Towards a high level approach for the programming of heterogeneous clusters. 45th Intl. Conf. on Parallel Processing Workshops (ICPPW 2016), pp. 106-114. Philadelphia (USA), August 2016.
- J. F. Fabeiro, D. Andrade, B.B. Fraguela, R. Doallo. How to write performance portable codes using the Heterogeneous Programming Library. 19th Workshop on Compilers for Parallel Computing (CPC 2016). Valladolid (Spain), July 2016.
- M. Viñas (Advisors: B.B. Fraguela and D. Andrade). Improving the programmability of heterogeneous systems by means of libraries. PhD Thesis, Department of Electronics and Systems, University of A Coruña (Spain). July 2016.
- S. Altuntaş, Z. Bozkus, B.B. Fraguela. GPU accelerated molecular docking simulation with genetic algorithms. 19th European Conf. on Applications of Evolutionary Computation (EvoApps 2016), pp. 134-146. Porto (Portugal), April 2016.
- J. F. Fabeiro, D. Andrade, B.B. Fraguela. Writing a performance-portable matrix multiplication. Parallel Computing, 52:65-77, February 2016.
- M. Viñas, B.B. Fraguela, Z. Bozkus, D. Andrade. Improving OpenCL programmability with the Heterogeneous Programming Library. International Conference on Computational Science (ICCS 2015), pp. 110-119. Reykjavik (Iceland), June 2015
- M. Viñas, Z. Bozkus, B.B. Fraguela, D. Andrade, R. Doallo. Developing adaptive multi-device applications with the Heterogeneous Programming Library. The Journal of Supercomputing, 71(6):2204-2220, June 2015. The final publication is available at http://link.springer.com here
- J.F. Fabeiro, D. Andrade, B.B. Fraguela, R. Doallo. Writing self-adaptive codes for heterogeneous systems. 20th International Euro-par Conference (Euro-Par 2014), Lecture Notes in Computer Science Vol. 8632, Springer, pp. 800-811. Porto (Portugal), August 2014.
- M. Viñas, Z. Bozkus, B.B. Fraguela, D. Andrade, R. Doallo. Exploiting multi-GPU systems using the Heterogeneous Programming Library. 14th Intl. Conf. on Computational and Mathematical Methods in Science and Engineering (CMMSE 2014), pp. 1280-1291. Rota (Spain), July 2014.
- M. Viñas, Z. Bozkus, B.B. Fraguela. Exploiting heterogeneous parallelism with the Heterogeneous Programming Library. Journal of Parallel and Distributed Computing, 73(12):1627-1638, December 2013.
- Z. Bozkus, B.B. Fraguela. A Portable High-Productivity Approach to Program Heterogeneous Systems. 21st International Heterogeneity in Computing Workshop (HCW 2012), in conjunction with IPDPS'12, pp. 163-173. Shanghai (China). May 2012.
The HPL library is available under the GPL license v3.