Siunits The Library, Walter E. Brown, Ph. D · 2001
While scientific programmers typically make heavy use of a programming language's native numeric data types, such practice has been a common source of errors: it obscures the diverse intentions (e.g., distances, masses, energies, momenta, etc.) that any such purely numeric value could represent. Limitations in programming language expressiveness and compiler technology have historically made it difficult to address commensuration in a programming context. However, SIUNITS provides, in C++, a convenient means of computing with numeric values that have attached units.
Cited by 0
Alexis Pereda, David R.C. Hill, Claude Mazel et al. · HAL (Le Centre pour la Communication Scientifique Directe) · 2019
International audience
Cited by 0Open access
Li Wei · Auerbach Publications eBooks · 2020
Using the implementation of a deep learning framework as an example, C++ Template Metaprogramming in Practice: A Deep Learning Framework explains the application of metaprogramming in a relatively large project and emphasizes ways to optimize systems performance. The book is suitable for developers with a basic knowledge of C++. Developers familiar with mainstream deep learning frameworks can also refer to this book to compare the differences between the deep learning framework implemented with metaprogramming and compile-time computing with deep learning frameworks using object-oriented methods. Consisting of eight chapters, the book starts with two chapters discussing basic techniques of metaprogramming and compile-time computing. The rest of the book’s chapters focus on the practical application of metaprogramming in a deep learning framework. It examines rich types and systems, expression templates, and writing complex meta-functions, as well as such topics as: Heterogeneous dictionaries and policy templates An introduction to deep learning Type system and basic data types Operations and expression templates Basic layers Composite and recurrent layers Evaluation and its optimization Metaprogramming can construct flexible and efficient code. For C++ developers who are familiar with object-oriented programming, the main difficulty in learning and mastering C++ metaprogramming is establishing the thinking mode of functional programming. The meta-programming approach involved at compile time is functional, which means that the intermediate results of the construction cannot be changed, and the impact may be greater than expected. This book enables C++ programmers to develop a functional mindset and metaprogramming skills. The book also discusses the development cost and use cost of metaprogramming and provides workarounds for minimizing these costs.
Cited by 0
PANI, Giovanni, COVINO, Emanuele · CINECA IRIS Institutional Research Information System (University of Bari Aldo Moro) · 2008
Any partial recursive function can be computed at compile time, using \nC++ templates to define primitive recursion, composition, and minimalization. \nWe define a sub-language based on C++ templates, and we prove that it characterizes \nthe set of polynomial-time functions, that is the set of functions computable \nby a Turing machine with time bounded by a polynomial.
Cited by 0
Luc Touraille, Mamadou Kaba Traoré, David R.C. Hill · HAL (Le Centre pour la Communication Scientifique Directe) · 2010
For several years, the DEVS community has been developing many tools for simulating DEVS models, ranging from local sequential to massively distributed and parallel simulation. In this paper, we present an innovative approach to local DEVS simulation. By using template metaprogramming, we developed the DEVS-MetaSimulator (DEVS-MS); instead of proposing one simulator meant to be used with every DEVS models, our library provides several metaclasses defining families of simulators. This way, each simulator instantiation is really specialized for a particular model. Doing so, we increase the detection of errors at compile-time, and we greatly reduce the execution time by removing several runtime computations that are instead performed by the compiler.
Cited by 0Open access
Lombardelli, Fabio · Electronic Theses and Dissertations Repository (University of Pisa) · 2005
La riflessione (reflection) è la capacità di un programma di ispezionare la propria struttura e il proprio stato durante l’esecuzione, possibilmente modificandolo, ed è una caratteristica importante dei sistemi software moderni. Per introspezione si intende l’ispezione della struttura e dello stato del programma, ed è basata su oggetti contenenti le informazioni necessarie per descrivere classi. Programmi scritti in Java [3] o C# [13] hanno accesso a questo tipo di servizi mediante la Reflection API (un insieme di oggetti e metodi che rappresentano la struttura del programma consentendo l’analisi e la modifica, almeno in parte, del suo stato). Il C++ è invece molto limitato in questo senso. Perché ciò possa avvenire il programma deve avere, durante la sua esecuzione, una rappresentazione di sé, nella forma di un insieme di informazioni che vanno sotto il nome di metadati. Nell’ambito dei linguaggi che supportano il paradigma di programmazione orientata agli oggetti è naturale esporre i metadati sotto forma di oggetti, anche chiamati metaoggetti. La tesi discute l'implementazione di due approcci per aggiungere il supporto della reflection al linguaggio C++ mediante la tecnica di template metaprogramming.
Cited by 0Open access
Philipp S. Käsgen, Markus Weinhardt · Universitätsbibliothek Tübingen · 2018
When designing digital systems, the Design Space is explored well in advance to rule out as many infeasible design options as possible, as a complete enumeration would be infeasible. Still, in the end, the designer is mostly left with several similar design options, i.e. actual choice of adder, Floating Point Unit etc. In such cases, a direct comparison cannot be avoided - at least in simulation. Even though the designer might have some module descriptions to be examined at hand, it might take a while to put them to work because of differing ports and control signals. But why should a system designer make the effort to adapt many modules to his design if he is only interested in a few aspects for a quick survey: overall power consumption, area occupation, timing, and correctness of results? This is the reason why we need a hardware description solely based on parameters. Such a description requires Metaprogramming Techniques because said parameters need to be translated to hardware behaviours. Hence, in this work we propose a parameter based hardware design paradigm based on SystemC and C++: Hardware Metadescription.
Cited by 0Open access
Михаил Михайлович Краснов · Keldysh Institute of Applied Mathematics eBooks · 2017
Метапрограммирование шаблонов C++ в задачах математической физики
Cited by 9Open access
Emanuele Covino, Giovanni Pani · CINECA IRIS Institutional Research Information System (University of Bari Aldo Moro)
In this paper we investigate the relationship between template metaprogramming and implicit complexity, defining a recursive metalanguage by means of C++ templates; we show that the language captures the set of polynomial-time computable functions, that is, functions computable by a Turing machine in which the number of moves - the time complexity - is bounded by a polynomial. We also show that our approach can be extended to recursion schemes that are more general than those used in ICC; this implies that we are able to capture more natural algorithms.
Cited by 0
Bruno Bachelet, Antoine Mahul, Loïc Yon · HAL (Le Centre pour la Communication Scientifique Directe) · 2013
In generic programming, software components are parameterized on types. When available, a static specialization mechanism allows selecting, for a given set of parameters, a more suitable version of a generic component than its primary version. The normal C++ template specialization mechanism is based on the type pattern of the parameters, which is not always the best way to guide the specialization process: type patterns are missing some information on types that could be relevant to define specializations. The notion of a concept, which represents a set of requirements (including syntactic and semantic aspects) for a type, is known to be an interesting approach to control template specialization. For many reasons, concepts were dropped from C++11 standard, this article therefore describes template metaprogramming techniques for declaring concepts, modeling relationships (meaning that a type fulfills the requirements of a concept), and refinement relationships (meaning that a concept refines the requirements of another concept). From a taxonomy of concepts and template specializations based on concepts, an automatic mechanism selects the most appropriate version of a generic component for a given instantiation. Our purely library-based solution is also open for retroactive extension: new concepts, relationships, and template specializations can be defined at any time; such additions will then be picked up by the specialization mechanism.
Cited by 0Open access
Vivek Patel, Piyush Mishra, Jagdish Chandra Patni et al. · Communications in computer and information science · 2018
Cited by 1
PANI, Giovanni, COVINO, Emanuele · CINECA IRIS Institutional Research Information System (University of Bari Aldo Moro) · 2009
Any partial recursive function can be computed at compile time, using \nC++ templates to define primitive recursion, composition, and minimalization. \nIn this paper, we define a restricted language based on C++ templates, and we \nprove that it characterizes the set of polynomial-time computable functions, that \nis the set of functions computed by a Turing machine with time bounded by a \npolynomial.
Cited by 0
Abel Sinkovics · 2014
Template metaprogramming is an emerging new direction of gen-erative programming: with the clever denitions of templates we can enforce the C++ compiler to execute algorithms at compilation time. Among the application areas of template metaprograms are the expression templates, static interface checking, code optimiza-tion with adaption, language embedding and active libraries. How-ever, as this capability of C++ was not a primary design goal, the language is not capable of clean expression of template metapro-grams. The complicated syntax leads to the creation of code that is hard to write, understand and maintain. Despite that template metaprogramming has a strong relationship with functional pro-gramming paradigm, existing libraries do not follow these require-ments. In this paper we discuss the possibility to enhance the syn-tactical expressiveness of template metaprograms using an embed-ded functional language. Programmers can write metaprograms in Haskell syntax embedded in native C++ code and a translator tool transfers it to template metaprograms. The Haskell code snippets inter-operate with their C++ environment.
Cited by 0
Wei Li · CERN Document Server (European Organization for Nuclear Research) · 2020
Cited by 0
SHETTY, NIRDHARSH · Tampere University Institutional Repository (Tampere University) · 2013
Cited by 0
Michael C. Burton, William G. Griswold, Andrew D. Mcculloch et al. · 2002
C++ is decidedly asymmetric in its approach to the static and dynamic aspects of the language. As a consequence, techniques that we develop using one aspect (e.g., for loops with STL iterators) will not work with the other (Template Metaprogramming for the static side of C++) due to syntax differences in the way each is defined and used [Veldhuizen, 2000]. These incompatibilities complicate switching between dynamic and static implementations of a behavior. Thus, for example, it is difficult to optimize a bottleneck by making a straightforward dynamic implementation static.
Cited by 0
David Pfander, Malte Brunn, Dirk Pflüger · 2018
Careful tuning of code is crucial to obtain near-optimal runtime performance on the hardware at hand. How-ever, current hardware platforms pose plenty of challenges: multiple levels of cache, many cores and increasingly wider vector units render manual tuning time-consuming and cumbersome. Thus, algorithms have to be able to automatically tune themselves to the underlying hardware platform to maximize performance and to ensure performance portability. In this work, we present AutoTuneTMP, a novel C++-based auto-tuning library. Its unique strength is to combine template metaprogramming and just-in-time (JIT) compilation so that templates can be instantiated at runtime. We use this runtime metaprogramming approach to provide an extensible set of parameterized template-based optimizations and data structures for writing tunable kernels. Together with convenience functionality for parameter tuning, this lightweight approach can be used to implement algorithms with near-optimal and portable performance. We demonstrate the applicability, usefulness and performance of AutoTuneTMP at the example of matrix multiplication. It is well-suited as a demonstrator, being a well-known compute kernel and exhibiting a rather large set of (nine) tunable parameters to be optimized. With simple search algorithms, AutoTuneTMP is able to automatically achieve up to 90% of the peak performance on a Xeon Silver 4116 processor and up to 34% on a Xeon Phi 7210. Starting from an already parallelized and vectorized baseline, we obtained a speedup of up to 3.1x on the Xeon Silver platform and up to 6.7x on the Xeon Phi platform.
Cited by 2
Karl Rupp · 2010
In the area of scientific computing, abstraction was long said to be achievable only in exchange for run time efficiency. With the rise of template metaprogramming [1] in C++ in the 1990s, run time efficiency comparable to hand tuned code could be achieved for isolated operations such as matrix-vector multiplication [2]. In more complex scenarios such as large finite element simulation packages, traditional object oriented programming is used for most abstractions, so the resulting code usually suffers from reduced run time efficiency. We have applied rigorous template metaprogramming to both the mesh handling and the mathematical algorithms acting on top, and obtain a high level of abstraction at a run time efficiency comparable to that of hand-tuned code. Since the weak formulation of the underlying mathematical problem is directly transferred to code, the code effectively meets the abstraction of the mathematical description, including an eventual independence from the underlying spatial dimension.
Cited by 1
Sinkovics Ábel · ELTE Digital Institutional Repository (EDIT) (Eötvös Loránd University) · 2013
Cited by 0Open access
VYSKOČIL, Jiří · CERN Document Server (European Organization for Nuclear Research) · 2016
<!--HTML-->Large scale scientific computing raises questions on different levels ranging from the fomulation of the problems to the choice of the best algorithms and their implementation for a specific platform. There are similarities in these different topics that can be exploited by modern-style C++ template metaprogramming techniques to produce readable, maintainable and generic code. Traditional low-level code tend to be fast but platform-dependent, and it obfuscates the meaning of the algorithm. On the other hand, object-oriented approach is nice to read, but may come with an inherent performance penalty.\n\nThese lectures aim to present he basics of the Expression Template (ET) idiom which allows us to keep the object-oriented approach without sacrificing performance. We will in particular show to to enhance ET to include SIMD vectorization. We will then introduce techniques for abstracting iteration, and introduce thread-level parallelism for use in heavy data-centric loads. We will show to to apply these methods in a way which keeps the "front end" code very readable.\n---\nLECTURE 1\nIn this lecture, we will have a quick look at the basics of Template Metaprogramming - how does the computing handle "types", and how these types map more or less naturally to physical quantities. We will then introduce the idea of using Expression Templates (ET) as a means to bride the gap between the low-level high-performance approach, and the object-oriented, readable but often severely under-performing approach. We will study the structure of the ETs, and show the basic steps needed to build them.
Cited by 0