An Efficient Method for Defining Multivariate Functions Using Expression Templates for Arrays in C++ and CUDA

Autor: Hossein Mahmoodi Darian
Jazyk: perština
Rok vydání: 2018
Předmět:
Zdroj: مجله مدل سازی در مهندسی, Vol 16, Iss 55, Pp 113-131 (2018)
Druh dokumentu: article
ISSN: 2008-4854
2783-2538
DOI: 10.22075/jme.2018.10901.1045
Popis: In this paper an efficient method for defining multi-variable functions using expression templates for array computations in computational fluid dynamics simulations in C++ is introduced. The method is implemented using variadic templates which is a new feature in C++. One of the advantages of the method is its easy of use for users of computational fields. The user can define and use his own function with any number of input arguments without having knowledge of templates programming concepts. The present method may replace conventional expression templates in developing numerical libraries. For three different functions, including arithmetic operations and trigonometric functions, the efficiency of the proposed method for arrays of different sizes is compared with that of the conventional expression templates, two different C++ syntax and Fortran language. Furthermore, the performance of the method in terms of the compilation time and executable file size is demonstrated. A similar comparison on Graphic Processing Units (GPU) using CUDA is made and the efficiency of the method is shown. The results indicate that, for any array size, the present method has a very good performance in terms of computational time, compilation time and executable file size. Finally, as an application of the proposed method, a numerical simulation is done.
Databáze: Directory of Open Access Journals