In this work, we examine the performance, energy efficiency and usability when using Python for developing HPC codes running on the GPU. We investigate the portability of performance and energy efficiency between CUDA and OpenCL; between GPU generations; and between low-end, mid-range and high-end GPUs. Our findings show that the impact of using Python is negligible for our applications, and furthermore, CUDA and OpenCL applications tuned to an equivalent level can in many cases obtain the same computational performance. Our experiments show that performance in general varies more between different GPUs than between using CUDA and OpenCL. We also show that tuning for performance is a good way of tuning for energy efficiency, but that specific tuning is needed to obtain optimal energy efficiency.We show that accessing the GPU from Python is as efficient as from C/C++ in many cases, demonstrate how profile-driven development in Python is essential for increasing performance for GPU code (up to 5 times), and show that the energy efficiency increases proportionally with performance tuning. Finally, we investigate the portability of the improvements and power efficiency both between CUDA and OpenCL and between different GPUs. Our findings are summarized in tables that justify that using Python can be preferable to C++, and that using CUDA can be preferable to using OpenCL. Our observations should be directly transferable to other similar architectures and problems.
Related WorkThere are several high-level programming languages and libraries that offer access to the GPU for certain sets of problems and algorithms. OpenACC [14] is one example which is pragma-based and offers a set of directives to execute code in parallel on the GPU. However, such high-level abstractions are typically only efficient for certain classes of problems and are often unsuitable for non-trivial parallelization or data movement. CUDA [15] and OpenCL [16] are two programming languages that offer full access to the GPU hardware, including the whole memory subsystem. This is an especially important point, since memory movement is a key bottleneck in many numerical algorithms [6] and therefore has a significant impact on energy consumption.The performance of GPUs has been reported extensively [17], and several authors have shown that GPUs are efficient in terms of energy-to-solution. Huang et al. [18] demonstrated early on that GPUs could not only speed up computational performance, but also increase power efficiency dramatically using CUDA. Qi et al. [19] show how OpenCL on a mobile GPU can increase performance of the discrete Fourier transform by 1.4 times and decrease the energy use by 37%. Dong et al. [20] analyze the energy efficiency of GPU BLAST which simulates compressible hydrodynamics using finite elements with CUDA and report a 2.5 times speedup and a 42% increase in energy efficiency. Klôh [21] report that there is a wide spread in terms of energy efficiency and performance when comparing 3D wave propagation and full waveform inversio...