INVESTIGATION OF C plus plus VARIADIC TEMPLATES FOR NUMERICAL METHODS AND FINITE DIFFERENCE SCHEMES

被引:0
|
作者
Darian, Hossein Mahmoodi [1 ]
机构
[1] Univ Tehran, Coll Engn, Sch Engn Sci, Tehran, Iran
来源
SIAM JOURNAL ON SCIENTIFIC COMPUTING | 2021年 / 43卷 / 01期
关键词
expression templates; variadic templates; C plus; graphics processing unit; CUDA; finite difference schemes; EXPRESSION TEMPLATES; IMPLEMENTATION; ORDER;
D O I
10.1137/19M1282581
中图分类号
O29 [应用数学];
学科分类号
070104 ;
摘要
In this paper we investigate the utilization of variadic templates for numerical methods and finite difference schemes. Specifically, an efficient method for defining multivariate functions in the framework of expression templates for array-based computations in C++ and CUDA is introduced. One of the advantages of the method is its ease of use for users of computational fields. The user can define and use his own function with any number of input arguments without having the knowledge of templates programming. For three different functions, the efficiency of the proposed method for arrays of different sizes is compared with that of the other implementations in C++ and also that of Fortran. The Roofline analysis is presented for the C++ implementations. Furthermore, for different compilers, the performance of the method in terms of the compilation time and executable file size and also the vectorization status are demonstrated. A similar comparison on graphics processing units (GPUs) using CUDA is made and the efficiency of the method is shown. The results indicate that, for any array size, the present method has very good performance in terms of the computational time, compilation time, and executable file size. Also, the variadic templates are utilized to define linear and nonlinear finite difference schemes. The performance of three finite difference schemes is compared with that of the plain C implementation. The results show the method proposed for nonlinear schemes has the same performance as that of the plain C implementation. Finally, as a practical application, two numerical simulations, the simulation of the discharge process of a lead-acid battery cell on a CPU and the simulation of a two-dimensional Riemann problem using high-order weighted ENO schemes on a GPU, are carried out.
引用
收藏
页码:C89 / C125
页数:37
相关论文
共 50 条
  • [1] Variadic Templates for C plus
    Gregor, Douglas
    Jaervi, Jaakko
    [J]. APPLIED COMPUTING 2007, VOL 1 AND 2, 2007, : 1101 - +
  • [2] Translating Lambda Calculus into C plus plus Templates
    Sefl, Vit
    [J]. TRENDS IN FUNCTIONAL PROGRAMMING (TFP 2021), 2021, 12834 : 95 - 115
  • [3] Numerical investigation of finite difference schemes for nonconservative hyperbolic systems
    Castro, Manuel J.
    LeFloch, Philippe G.
    Luz Munoz-Ruiz, Maria
    Pares, Carlos
    [J]. HYPERBOLIC PROBLEMS: THEORY, NUMERICS AND APPLICATIONS, PART 2, 2009, 67 : 465 - +
  • [4] Simple and safe SQL queries with C plus plus templates
    Gil, Joseph
    Lenz, Keren
    [J]. SCIENCE OF COMPUTER PROGRAMMING, 2010, 75 (07) : 573 - 595
  • [5] Early Detection of Type Errors in C plus plus Templates
    Chen, Sheng
    Erwig, Martin
    [J]. PEPM '14: PROCEEDINGS OF THE ACM SIGPLAN WORKSHOP ON PARTIAL EVALUATION AND PROGRAM MANIPULATION, 2014, : 133 - 144
  • [6] GTMesh: A Highly Efficient C plus plus Template Library for Numerical Schemes on General Topology Meshes
    Jakubec, Tomas
    Strachota, Pavel
    [J]. APPLIED SCIENCES-BASEL, 2023, 13 (15):
  • [7] Employing C plus plus Templates in the Design of a Computer Algebra Library
    Brandt, Alexander
    Moir, Robert H. C.
    Maza, Marc Moreno
    [J]. MATHEMATICAL SOFTWARE - ICMS 2020, 2020, 12097 : 342 - 352
  • [8] FELICITY: A MATLAB/C plus plus TOOLBOX FOR DEVELOPING FINITE ELEMENT METHODS AND SIMULATION MODELING
    Walker, Shawn W.
    [J]. SIAM JOURNAL ON SCIENTIFIC COMPUTING, 2018, 40 (02): : C234 - C257
  • [9] Multisymplectic structure of numerical methods derived using nonstandard finite difference schemes
    Kosmas, Odysseas
    Papadopoulos, Dimitrios
    [J]. 2ND INTERNATIONAL CONFERENCE ON MATHEMATICAL MODELING IN PHYSICAL SCIENCES 2013 (IC-MSQUARE 2013), 2014, 490
  • [10] Investigation of Finite-Difference Schemes for the Numerical Solution of a Fractional Nonlinear Equation
    Tverdyi, Dmitriy
    Parovik, Roman
    [J]. FRACTAL AND FRACTIONAL, 2022, 6 (01)