Using the functional programming library for solving numerical problems on graphics accelerators with CUDA technology
https://doi.org/10.15514/ISPRAS-2021-33(5)-10
Abstract
Modern graphics accelerators (GPUs) can significantly speed up the execution of numerical tasks. However, porting programs to graphics accelerators is not an easy task. Sometimes the transfer of programs to such accelerators is carried out by almost completely rewriting them (for example, when using the OpenCL technology). This raises the daunting task of maintaining two independent source codes. However, CUDA graphics accelerators, thanks to technology developed by NVIDIA, allow you to have a single source code for both conventional processors (CPUs) and CUDA. The machine code generated when compiling this single text depends on which compiler it is compiled with (the usual one, such as gcc, icc and msvc, or the compiler for CUDA, nvcc). However, in this single source code, you need to somehow tell the compiler which parts of this code to parallelize on shared memory. For the CPU, this is usually done using OpenMP and special pragmas to the compiler. For CUDA, parallelization is done in a completely different way. The use of the functional programming library developed by the authors allows you to hide the use of one or another parallelization mechanism on shared memory within the library and make the user source code completely independent of the computing device used (CPU or CUDA). This article shows how this can be done.
About the Authors
Mikhail Mikhailovich KRASNOVRussian Federation
PhD in Physics and Mathematics, Senior Researcher at KIAM RAS, Associate Professor of the Department of Informatics of MIPT
Olga Borisovna FEODORITOVA
Russian Federation
Senior Researcher at KIAM RAS
References
1. TOP500. URL: https://www.top500.org/
2. OpenCL. URL: https://www.khronos.org/opencl/
3. OpenACC. URL: https://www.openacc.org/
4. NVIDIA CUDA. URL: https://developer.nvidia.com/language-solutions
5. М.М. Краснов. Библиотека функционального программирования для языка C++. Программирование, том 46, no. 5, 2020 г., стр. 47-59 / M.M. Krasnov. Functional Programming Library for C++. Programming and Computer Software, vol. 46, no. 5, 2020, pp. 330-340.
6. J.O. Coplien. Curiously recurring template patterns. C++ Report, vol. 7, issue 2, 1995, pp. 24–27.
7. D. Abrahams, A. Gurtovoy. C++ Template Metaprogramming: Concepts, Tools, and Techniques from Boost and Beyond. Addison-Wesley, 2004, 408 p.
8. M.M. Krasnov. C++ templates metaprogramming in problems of mathematical physics. KIAM RAS, 2017, 84 p. DOI: 10.20948/mono-2017-krasnov.
9. T. Veldhuizen. Expression Templates. C++ Report, vol. 7, issue 5, 1995, pp. 26-31.
10. B. Stroustrup. The C++ Programming Language. Fourth Edition. Addison-Wesley, 2013, 1376 p.
11. B. Stroustrup. Programming: Principles and Practice Using C++. Second Edition. Addison-Wesley, 2014, 1312 p.
12. B. Stroustrup. A Tour of C++. Addison-Wesley, 2014, 192 p.
13. B. Stroustrup. The Design and Evolution of C++. Addison-Wesley, 1994, 480 p.
14. The C++ Resources Network. URL: http://www.cplusplus.com/.
Review
For citations:
KRASNOV M.M., FEODORITOVA O.B. Using the functional programming library for solving numerical problems on graphics accelerators with CUDA technology. Proceedings of the Institute for System Programming of the RAS (Proceedings of ISP RAS). 2021;33(5):167-180. https://doi.org/10.15514/ISPRAS-2021-33(5)-10