Compiler Support for Profiling C++ Template Metaprograms József Mihalicza, Norbert Pataki, Zoltán Porkoláb Eötvös Loránd University Faculty of Informatics.

Slides:



Advertisements
Similar presentations
Sml2java a source to source translator Justin Koser, Haakon Larsen, Jeffrey Vaughan PLI 2003 DP-COOL.
Advertisements

Boost Writing better code faster with Boost. Boost Introduction Collection of C++ libraries Boost includes 52 libraries, 1.31 will have at least.
.NET Technology. Introduction Overview of.NET What.NET means for Developers, Users and Businesses Two.NET Research Projects:.NET Generics AsmL.
1 An anomaly of subtype relations at component refinement and a generative solution in C++ Zoltán Porkoláb, István Zólyomi {gsd | Eötvös.
Model Driven Generative Programming Reza Azimi February 6, 2003 ECE1770: Trends in Middleware Systems.
Functional Image Synthesis. Pan An image synthesis “language” Images are functions Continuous and infinite Embedded in a functional host language Reusable.
IPS: Implementation of Protocol Stacks for Embedded Systems Yan Wang Halmstad University, Sweden The Second Internal EPC Workshop IPS, Halmstad University,
Software & Services Group, Developer Products Division Copyright© 2010, Intel Corporation. All rights reserved. *Other brands and names are the property.
© Chinese University, CSE Dept. Software Engineering / Software Engineering Topic 1: Software Engineering: A Preview Your Name: ____________________.
UBlas: Boost High Performance Vector and Matrix Classes Juan José Gómez Cadenas University of Geneve and University of Valencia (thanks to: Joerg Walter,
The Path to Multi-core Tools Paul Petersen. Multi-coreToolsThePathTo 2 Outline Motivation Where are we now What is easy to do next What is missing.
CPSC Compiler Tutorial 9 Review of Compiler.
Perl Practical Extraction and Report Language Senior Projects II Jeff Wilson.
1/18 CS 693/793 Lecture 09 Special Topics in Domain Specific Languages CS 693/793-1C Spring 2004 Mo, We, Fr 10:10 – 11:00 CH 430.
Chapter 3.2 C++, Java, and Scripting Languages. 2 C++ C used to be the most popular language for games Today, C++ is the language of choice for game development.
An Evaluation of BLAST John Gallagher CS4117. Overview BLAST incorporates new, fascinating and complex technology. The engine and external components.
Chapter 3.2 C++, Java, and Scripting Languages “The major programming languages used in game development.”
The Structure of the GNAT Compiler. A target-independent Ada95 front-end for GCC Ada components C components SyntaxSemExpandgigiGCC AST Annotated AST.
Chapter 3.2 C++, Java, and Scripting Languages hacked by jeffery.
Generative Programming. Generic vs Generative Generic Programming focuses on representing families of domain concepts Generic Programming focuses on representing.
1 1 Profiling & Optimization David Geldreich (DREAM)
Foundations of Programming Languages – Course Overview Xinyu Feng Acknowledgments: some slides taken or adapted from lecture notes of Stanford CS242
Introduction 01_intro.ppt
Groovy WHAT IS IT? HOW DOES IT WORK? IS IT USEFUL?
Classes Mark Hennessy Dept. Computer Science NUI Maynooth C++ Workshop 18 th – 22 nd Spetember 2006.
Workshop on Integrated Application of Formal Languages, Geneva J.Fischer Mappings, Use of MOF for Language Families Joachim Fischer Workshop on.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Purpose  This training course describes how to configure the the C/C++ compiler options.
Sumant Tambe, et. al LEESA DSPD 2008 An Embedded Declarative Language for Hierarchical Object Structure Traversal Sumant Tambe* Aniruddha Gokhale Vanderbilt.
Distributed Object Computing Laboratory Washington University St. Louis, MO Rate-Monotonic Analysis in the C++ Type System Morgan Deters Model-Driven Embedded.
Visual Linker Final presentation.
Paradigm Independent Software Complexity Metrics Dr. Zoltán Porkoláb Department of Programming Languages and Compilers Eötvös Loránd University, Faculty.
C++ Template Metaprogramming Why, When and How? Zoltán Porkoláb Dept. of Programming Languages and Compilers, Faculty of Informatics Eötvös.
Comp 245 Data Structures Linked Lists. An Array Based List Usually is statically allocated; may not use memory efficiently Direct access to data; faster.
Generative Programming. Automated Assembly Lines.
Metaprogramming from University to Industry Zoltán Porkoláb Dept. of Programming Languages and Compilers, Faculty of.
Programming Language Support for Generic Libraries Jeremy Siek and Walid Taha Abstract The generic programming methodology is revolutionizing the way we.
Applied Computing Technology Laboratory QuickStart C# Learning to Program in C# Amy Roberge & John Linehan November 7, 2005.
GPCE'04, Vancouver 1 Towards a General Template Introspection Library in C++ István Zólyomi, Zoltán Porkoláb Department of Programming Languages and Compilers.
Visual Linker Prototype presentation.
Boost.Geometry Introduction to Boost.Geometry presented by Mateusz Loskot (Cadcorp Ltd.) at FOSS4G 2010.
Meta IFL 2007 Freiburg1 Meta - Towards a Functional-Style Interface for C++ Template Metaprograms * Ádám Sipos, Zoltán Porkoláb, Norbert Pataki, Viktória.
Data Structures Using C++ 2E1 Inheritance An “is-a” relationship –Example: “every employee is a person” Allows new class creation from existing classes.
Version 5. ¿What is PAF? PAF is a tool to easily and quickly implement… …distributed analysis over ROOT trees. …by hiding as much as possible the inherent.
6/3/2005C++ Template HENPC Group Meeting (LBNL)1 C++ Template Meta-Programming Igor A. Gaponenko (LBNL/NERSC)
Standard Template Library The Standard Template Library was recently added to standard C++. –The STL contains generic template classes. –The STL permits.
Debugging C++ template metaprograms. Structure Template metaprogramming (TMP) Debugging –In general –TMP Templight framework –Idea –implementation Results.
Determina, Inc. Persisting Information Across Application Executions Derek Bruening Determina, Inc.
Programming Fundamentals Lecture No. 2. Course Objectives Objectives of this course are three fold 1. To appreciate the need for a programming language.
Design of an Integrated Robot Simulator for Learning Applications Brendon Wilson April 15th, 1999.
SSQSA present and future Gordana Rakić, Zoran Budimac Department of Mathematics and Informatics Faculty of Sciences University of Novi Sad
Modern C++ in practice.
Introduction to Yan Cui Aspect Oriented Programming by
CSCI-383 Object-Oriented Programming & Design Lecture 25.
The Development Process Compilation. Compilation - Dr. Craig A. Struble 2 Programming Process Problem Solving Phase We will spend significant time on.
© 2015 Wind River. All Rights Reserved. Integrating FACE™ Aligned Componentry Larry Kinnan Principal Technologist, Wind River.
Portability Operating System and Architecture Independence Solaris - Ultra Sparc Linux - PPC/Pentium VxWorks - PPC-Altivec MAC OS X - PPC-Altivec Windows.
1 Asstt. Prof Navjot Kaur Computer Dept PRESENTED BY.
Chapter 3 Part II. 3.8 Placing a Class in a Separate File for Reusability.cpp file is known as a source-code file. Header files ◦ Separate files in which.
ECE 750 Topic 8 Meta-programming languages, systems, and applications Automatic Program Specialization for J ava – U. P. Schultz, J. L. Lawall, C. Consel.
PYTHON FOR HIGH PERFORMANCE COMPUTING. OUTLINE  Compiling for performance  Native ways for performance  Generator  Examples.
Csontos Péter, Porkoláb Zoltán Eötvös Loránd Tudományegyetem, Budapest ECOOP 2001 On the complexity of exception handling.
1 Titanium Review: Language and Compiler Amir Kamil Titanium Language and Compiler Changes Amir Kamil U.C. Berkeley September.
1 Programming and problem solving in C, Maxima, and Excel.
DGrid: A Library of Large-Scale Distributed Spatial Data Structures Pieter Hooimeijer,
Visual Linker ADD presentation. slide 2  Project Overview And Vision  Project System View  The System Life Cycle  Data Model and.
5th MaCS Debrecen On the Turing-Completeness of Generative Metaprograms Zoltán Porkoláb, István Zólyomi Dept. of Programming.
Tool Support for Testing
Week 3-4 Control flow (review) Function definition Program Structures
Towards a Multi-paradigm Complexity Measure
Combining Compile-Time and Run-Time Components
Presentation transcript:

Compiler Support for Profiling C++ Template Metaprograms József Mihalicza, Norbert Pataki, Zoltán Porkoláb Eötvös Loránd University Faculty of Informatics Dept. Of Programming Languages and Compilers

SPLST’11 Outline Templates in C++ Templates in C++ Template metaprograms Template metaprograms Efficiency problems with C++ templates Efficiency problems with C++ templates Earlier efforts / Related works Earlier efforts / Related works Our solution Our solution Examples Examples

SPLST’11 C++ templates Parametric polymorphism Parametric polymorphism Fundamental tools for generic programming Fundamental tools for generic programming Unconstrained Unconstrained Implemented by instantiation Implemented by instantiation Typical solution: multiply header files Typical solution: multiply header files Examples: standard library, inlc. STL Examples: standard library, inlc. STL

SPLST’11 Template metaprograms Unruh 1994: prime numbers Unruh 1994: prime numbers Has been proved to be Turing-complete Has been proved to be Turing-complete Functional programming paradigm Functional programming paradigm Recursion + pattern matching Recursion + pattern matching Referential transparency Referential transparency No assignment No assignment (Almost) no i/o (Almost) no i/o

SPLST’11 Template metaprograms 2 template template struct Factorial { enum { value = Factorial ::value * N }; enum { value = Factorial ::value * N };}; template <> struct Factorial struct Factorial { enum { value = 1 }; enum { value = 1 };}; int main() { int fact5 = Factorial ::value; int fact5 = Factorial ::value;}

SPLST’11 Template metaprogram usage Expression templates (blitz++, …) Expression templates (blitz++, …) Parser generators (boost::spirit, …) Parser generators (boost::spirit, …) Static interface checking (boost::concept, …) Static interface checking (boost::concept, …) Configuration management (boost::math, …) Configuration management (boost::math, …) Active libraries (…) Active libraries (…) DSL integration (Porkolab-Sinkovics,GPCE2010) DSL integration (Porkolab-Sinkovics,GPCE2010)

SPLST’11 Efficiency issues Recursive header inclusions Recursive header inclusions Data structures (recursive templates) Data structures (recursive templates) Imitating data manipulations Imitating data manipulations Complex, unclear syntax Complex, unclear syntax Compilers was not optimized for TMPs Compilers was not optimized for TMPs Hard to predict compilation time and memory usage Hard to predict compilation time and memory usage

SPLST’11 Earlier efforts Veldhuizen (1996- ) Veldhuizen (1996- ) Ad-hoc measurement, non-standard tools Ad-hoc measurement, non-standard tools Gurtovoy – Abrahams (2004) Gurtovoy – Abrahams (2004) Measuring full programs to identify idioms Measuring full programs to identify idioms Porkolab-Mihalicza Porkolab-Mihalicza Debugging (GPCE 2006) + Profiling (Splst 2007) Debugging (GPCE 2006) + Profiling (Splst 2007) Steven Watanabe (2008) Steven Watanabe (2008) Boost library extension Boost library extension Compilers was not optimized for TMPs Compilers was not optimized for TMPs Hard to predict compilation time and memory usage Hard to predict compilation time and memory usage

SPLST’11 Measuring compilation units Advantages Advantages Easy, platform and compiler independent Easy, platform and compiler independent Get the big picture, understand behaviour Get the big picture, understand behaviour Statistically correct Statistically correct Drawbacks Drawbacks Artificial problems Artificial problems Not revealing details in complex programs Not revealing details in complex programs Overheads (code generation, preprocessor) Overheads (code generation, preprocessor)

SPLST’11 Preprocessor overhead

Instrumentation framework

Code instrumentation

Code instrumentation 2

Warning generation Overhead Deviation of overhead

Modified compiler

Summary We have to measure template metaprograms We have to measure template metaprograms (and perhaps all large projects with many templates) Measuring compilation units are not feasible in real-world industrial projects Measuring compilation units are not feasible in real-world industrial projects Preprocessing step has a significant overhead Preprocessing step has a significant overhead Instrumentation has a linear distortion Instrumentation has a linear distortion Modification of compiler can eliminate warning overhead Modification of compiler can eliminate warning overhead Template metaprogram profiling is still learned Template metaprogram profiling is still learned

Thank you for your attention! Questions? József Mihalicza, Norbert Pataki, Zoltán Porkoláb