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

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 m...

Ausführliche Beschreibung

Gespeichert in:
Bibliographische Detailangaben
Veröffentlicht in:مجله مدل سازی در مهندسی 2018-12, Vol.16 (55), p.113-131
1. Verfasser: Hossein Mahmoodi Darian
Format: Artikel
Sprache:per
Schlagworte:
Online-Zugang:Volltext
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
Beschreibung
Zusammenfassung: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.
ISSN:2008-4854
2783-2538
DOI:10.22075/jme.2018.10901.1045