SlideShare ist ein Scribd-Unternehmen logo
1 von 83
Downloaden Sie, um offline zu lesen
Debugging and Profiling
C++ Template Metaprograms
Zoltán Porkoláb
gsd@elte.hu
Ericsson Hungary
Eötvös Loránd University, Budapest
2015.02.27. C++ Russia 2015 2
● C++ Template Metaprogramming
● Possible debugging and profiling techiques
● Templight back-end tool
● Front-end tools
●
3rd
party applications – please, contribute!
● Vision
Agenda
2015.02.27. C++ Russia 2015 3
C++ Template Metaprograms
● Expression templates (since 1995!)
● Active libraries, compile-time adaption
● Static interface checking
● Simulating language extensions
● DSL embedding
● Many other areas ...
2015.02.27. C++ Russia 2015 4
Motivation – a personal view
template <class T, class S>
? max( T a, S b) // How to define the return value?
{
if ( a > b )
return a;
else
return b;
}
int main()
{
short is = 3; long il = 2; double d = 3.14;
cout << max( il, is);
cout << max( is, d);
}
2015.02.27. C++ Russia 2015 5
Compile-time vs. Run-time
Compile-time Run-timeCompile-time
2015.02.27. C++ Russia 2015 6
Compile-time vs. Run-time
Compile-time Run-timeCompile-time
3 < 3.14
2015.02.27. C++ Russia 2015 7
Compile-time vs. Run-time
Compile-time Run-timeCompile-time
3 > 2L
3 < 3.14
-1.0 < 0
2015.02.27. C++ Russia 2015 8
Compile-time vs. Run-time
Compile-time Run-timeCompile-time
3 > 2L
3 < 3.14
-1.0 < 0
int
std::string
double
long
2015.02.27. C++ Russia 2015 9
Motivation
template <class T, class S>
? max( T a, S b) // How to define the return value?
{
if ( a > b )
return a;
else
return b;
}
int main()
{
short is = 3; long il = 2; double d = 3.14;
cout << max( il, is); // long is ''better'' than short
cout << max( is, d); // double is ''better'' than short
}
2015.02.27. C++ Russia 2015 10
Compile-time vs. Run-time
Run-time
3 > 2L
3 < 3.14
-1.0 < 0
int
std::string
double
long
Template
design time
Compile-time
Template Instantiation
2015.02.27. C++ Russia 2015 11
Compile-time vs. Run-time
Run-timeCompile-time
Template Instantiation
3 > 2L
3 < 3.14
-1.0 < 0
int
std::string
double
long
T
S
Template
design time
2015.02.27. C++ Russia 2015 12
Compile-time vs. Run-time
Run-time
3 > 2L
3 < 3.14
-1.0 < 0
int
std::string
double
long
T
S
sizeof(T) < sizeof(S)
Template
design time
Compile-time
Template Instantiation
2015.02.27. C++ Russia 2015 13
Compile-time vs. Run-time
Run-time
3 > 2L
3 < 3.14
-1.0 < 0
int
std::string
double
long
T
S
sizeof(T) < sizeof(S)
Template
design time
Compile-time
Template Instantiation
2015.02.27. C++ Russia 2015 14
Motivation
template <class T, class S>
? max( T a, S b) // How to define the return value?
{
if ( a > b )
return a;
else
return b;
}
int main()
{
short is = 3; long il = 2; double d = 3.14;
cout << max( il, is); // long is ''better'' than short
cout << max( is, d); // double is ''better'' than short
}
2015.02.27. C++ Russia 2015 15
(de)Motivation
template <class T, class S>
auto max( T a, S b) -> decltype(a+b) // C++11
{
if ( a > b )
return a;
else
return b;
}
int main()
{
short is = 3; long il = 2; double d = 3.14;
cout << max( il, is); // -> long
cout << max( is, d); // -> double
}
2015.02.27. C++ Russia 2015 16
(de)Motivation
template <class T, class S>
typename std::common_type<T,S>::value max( T a, S b) // C++11
{
if ( a > b )
return a;
else
return b;
}
int main()
{
short is = 3; long il = 2; double d = 3.14;
cout << max( il, is); // -> long
cout << max( is, d); // -> double
}
2015.02.27. C++ Russia 2015 17
● Run-time ● Compile-time
2015.02.27. C++ Russia 2015 18
● Functions
● Values, literals
● Data structures
● If/else
● Loop
● Assignment
● May depend on input
● Run-time ● Compile-time
2015.02.27. C++ Russia 2015 19
● Functions
● Values, literals
● Data structures
● If/else
● Loop
● Assignment
● May depend on input
● Metafunctions (type)
● Const, enum,constexpr
● Typelist (type)
● Pattern matching
● Recursion
● Ref. Transparency
● Deterministic
● Run-time ● Compile-time
2015.02.27. C++ Russia 2015 20
● Imperative
● Object-oriented
● Generative
● (some) Functional
● Run-time ● Compile-time
2015.02.27. C++ Russia 2015 21
● Imperative
● Object-oriented
● Generative
● (some) Functional
● Pure Functional
● Run-time ● Compile-time
2015.02.27. C++ Russia 2015 22
The usual factorial program ...
template <int N>
struct Factorial
{
enum { value = Factorial<N-1>::value * N };
};
template <>
struct Factorial<0>
{
enum { value = 1 };
};
int main()
{
const int fact5 = Factorial<5>::value;
}
2015.02.27. C++ Russia 2015 23
Bugs!!! ...
2015.02.27. C++ Russia 2015 24
The java programmer ...
template <int N>
struct Factorial
{
enum { value = Factorial<N-1>::value * N };
};
template <>
struct Factorial<0>
{
enum { value = 1 };
} //;
int main()
{
const int fact5 = Factorial<5>::value;
}
2015.02.27. C++ Russia 2015 25
The java programmer ...
template <int N>
struct Factorial
{
enum { value = Factorial<N-1>::value * N };
};
template <>
struct Factorial<0>
{
enum { value = 1 };
} //;
int main()
{
const int fact5 = Factorial<5>::value;
}
$ clang++ fact.cpp
fact.cpp:14:2: error: expected ';' after class
}
^
;
1 error generated.
2015.02.27. C++ Russia 2015 26
The vim user ...
template <int N>
struct Factorial
{
enum { value = Factorial<N-1>::value * N };
};
template <>
struct Factorial<0>
{
enum { ivalue = 1 };
};
int main()
{
const int fact5 = Factorial<5>::value;
}
2015.02.27. C++ Russia 2015 27
The vim user ...
template <int N>
struct Factorial
{
enum { value = Factorial<N-1>::value * N };
};
template <>
struct Factorial<0>
{
enum { ivalue = 1 };
};
int main()
{
const int fact5 = Factorial<5>::value;
}
$ clang++ fact.cpp
fact.cpp:5:34: error: no member named 'value' in 'Factorial<0>'
enum { value = Factorial<N-1>::value * N };
~~~~~~~~~~~~~~~~^
fact.cpp:5:18: note: in instantiation of template class 'Factorial<1>'
requested here
enum { value = Factorial<N-1>::value * N };
^
fact.cpp:5:18: note: in instantiation of template class 'Factorial<2>'
requested here
enum { value = Factorial<N-1>::value * N };
^
fact.cpp:5:18: note: in instantiation of template class 'Factorial<3>'
requested here
enum { value = Factorial<N-1>::value * N };
^
fact.cpp:5:18: note: in instantiation of template class 'Factorial<4>'
requested here
enum { value = Factorial<N-1>::value * N };
^
fact.cpp:16:21: note: in instantiation of template class 'Factorial<5>'
requested here
const int fact5 = Factorial<5>::value;
^
1 error generated.
2015.02.27. C++ Russia 2015 28
The negative approach ...
template <int N>
struct Factorial
{
enum { value = Factorial<N-1>::value * N };
};
template <>
struct Factorial<0>
{
enum { value = 1 };
};
int main()
{
const int fact5 = Factorial<-5>::value;
}
2015.02.27. C++ Russia 2015 29
The negative approach ...
template <int N>
struct Factorial
{
enum { value = Factorial<N-1>::value * N };
};
template <>
struct Factorial<0>
{
enum { value = 1 };
};
int main()
{
const int fact5 = Factorial<-5>::value;
}
$ clang++ fact4.cpp
fact4.cpp:6:18: fatal error: recursive template instantiation exceeded
maximum
depth of 512
enum { value = Factorial<N-1>::value * N };
^
fact4.cpp:6:18: note: in instantiation of template class 'Factorial<-517>'
requested here
enum { value = Factorial<N-1>::value * N };
Fact4.cpp:6:18: note: (skipping 503 contexts in backtrace; use
-ftemplate-backtrace-limit=0 to see all)
fact4.cpp:18:21: note: in instantiation of template class 'Factorial<-5>'
requested here
const int fact5 = Factorial<-5>::value;
^
fact4.cpp:6:18: note: use -ftemplate-depth=N to increase recursive
template
instantiation depth
enum { value = Factorial<N-1>::value * N };
^
1 error generated.
2015.02.27. C++ Russia 2015 30
The greedy ...
template <int N>
struct Factorial
{
enum { value = Factorial<N-1>::value * N };
};
template <>
struct Factorial<0>
{
enum { value = 1 };
};
int main()
{
const int fact5 = Factorial<-5>::value;
}
$ clang++ -ftemplate-depth=10000 fact4.cpp
2015.02.27. C++ Russia 2015 31
The greedy ...
template <int N>
struct Factorial
{
enum { value = Factorial<N-1>::value * N };
};
template <>
struct Factorial<0>
{
enum { value = 1 };
};
int main()
{
const int fact5 = Factorial<-5>::value;
}
$ clang++ -ftemplate-depth=10000 fact4.cpp$ clang++ -ftemplate-depth=10000 fact4.cpp
clang: error: unable to execute command: Segmentation fault
clang: error: clang frontend command failed due to signal (use -v to
see invocation)
clang version 3.2 (branches/release_32 180710)
Target: x86_64-unknown-linux-gnu
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed
source, and associated run script.
clang: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/fact4-iy6zKp.cpp
clang: note: diagnostic msg: /tmp/fact4-iy6zKp.sh
clang: note: diagnostic msg:
********************
2015.02.27. C++ Russia 2015 32
We need tools
● C++ syntax is not designed for metaprogramming
● Compilers are not optimised for detecting and
reporting template metaprogram errors
● Compilers are not optimised for template
metaprogram execution
● Compiler internals are black box for most
programmers
● Programmers have less experience with template
metaprograms
2015.02.27. C++ Russia 2015 33
Tool support
● Pretty good support for run-time C++
2015.02.27. C++ Russia 2015 34
Tool support
● Pretty good support for run-time C++
● Static analyzers, lint-like tools
● Debuggers
● Profilers
● Code comprehension tools
● Style checkers
2015.02.27. C++ Russia 2015 35
Tool support
● Pretty good support for run-time C++
● Static analyzers, lint-like tools
● Debuggers
● Profilers
● Code comprehension tools
● Style checkers
● Tools for template metaprogramming
2015.02.27. C++ Russia 2015 36
Tool support
● Pretty good support for run-time C++
● Static analyzers, lint-like tools
● Debuggers
● Profilers
● Code comprehension tools
● Style checkers
● Tools for template metaprogramming
● ?
2015.02.27. C++ Russia 2015 37
Tool support
Run-time Compile-time
2015.02.27. C++ Russia 2015 38
Tool support
Run-time Compile-time
2015.02.27. C++ Russia 2015 39
Tool support
Run-time Compile-time
2015.02.27. C++ Russia 2015 40
Tool support
Run-time Compile-time
2015.02.27. C++ Russia 2015 41
Tool support
Run-time Compile-time
2015.02.27. C++ Russia 2015 42
Related work
● Debugging
● Static assert/Concept check (Siek-Lumsdaine,
McNamara-Smaragdakis, Alexandrescu, others...)
● Warning generation (many attempt)
● Instrumentation
● Profiling
● Measuring full compilation (Gurtovoy-Abrahams)
● Measuring warning apperance (Watanabe)
● Visualize
● Source execution
● Instantiation graph
2015.02.27. C++ Russia 2015 43
Preprocessor
Instrumentator
Compiler
Warning parser
Positioner
#line mapping
Trace file
Position correct trace
Instrumented source
Preprocessed source
template<int i>
struct Factorial
{
/* ---------------- begin inserted ----------- */
struct _TEMPLIGHT_0s { int a; };
enum { _TEMPLIGHT_0 =
Templight::ReportTemplateBegin<_TEMPLIGHT_0s,
&_TEMPLIGHT_0s::a>::Value
};
/* ----------------- end inserted ------------ */
enum { value = Factorial<i-1>::value };
/* ---------------- begin inserted ----------- */
struct _TEMPLIGHT_1s { int a; };
enum { _TEMPLIGHT_1 =
Templight::ReportTemplateEnd<_TEMPLIGHT_1s,
&_TEMPLIGHT_1s::a>::Value
};
/* ----------------- end inserted ------------ */
};
template<>
struct Factorial<1>
{
/* ---------------- begin inserted ----------- */
struct _TEMPLIGHT_2s { int a; };
enum { _TEMPLIGHT_2 =
Templight::ReportTemplateBegin<_TEMPLIGHT_2s,
&_TEMPLIGHT_2s::a>::Value
};
/* ----------------- end inserted ------------ */
enum { value = 1 };
/* ---------------- begin inserted ----------- */
struct _TEMPLIGHT_3s { int a; };
enum { _TEMPLIGHT_3 =
Templight::ReportTemplateEnd<
_TEMPLIGHT_3s, &_TEMPLIGHT_3s::a>::Value
};
/* ----------------- end inserted ------------ */
};
GPCE 2006: Porkoláb, Mihalicza, Sipos:
Debugging C++ template metaprograms
2015.02.27. C++ Russia 2015 44
Instrumentation
● Advantages
● Light-way approach (compared to compiler hack)
● Grammar support (we used wave)
● Easier to port: just change the warning generator
2015.02.27. C++ Russia 2015 45
Instrumentation
● Advantages
● Light-way approach (compared to compiler hack)
● Grammar support (we used wave)
● Easier to port: just change the warning generator
● Disadvantages
● Complex constructs are hard (e.g. inheritance)
● Serious distortion in profiling information
● Memoization not detected
2015.02.27. C++ Russia 2015 46
Templight 2.0
● Based on LLVM/Clang compiler infrastructure
● Patch to
● Detect/measure instantiation
● Detect memoization
● Put timestamp on events
● Measure memory consumption (optional)
● Emit trace in various formats (txt, YAML, XML)
● Front-end tools
● Visual debugger
● Profiler data viewer
2015.02.27. C++ Russia 2015 47
Templight 2.0
Trace
C++
C++
C++
Templight patch
3rd party tools
Clang source
Interactive
debugger/
visualizer
Instantiation time
and memory
profiler
2015.02.27. C++ Russia 2015 48
Installation
● Visit http://plc.inf.elte.hu/templight
● Download templight-<timestamp>.tar.gz
● Contains clang patch and the two frontends
● Download Clang source
● Patch and build clang
● Build front-end tools (optional)
● >=Qt 4.6 and >=Graphviz 2.28.0 required
● $ qmake; make
2015.02.27. C++ Russia 2015 49
How to use
template<int N>
struct Fib
{
static const int value = Fib<N-2>::value + Fib<N-1>::value;
};
template<>
struct Fib<0>
{
static const int value = 0;
};
template<>
struct Fib<1>
{
static const int value = 1;
};
int main()
{
static const int fib5 = Fib<5>::value;
}
2015.02.27. C++ Russia 2015 50
How to use
$ clang++ -templight fib.cpp
$ ls
fib.cpp.trace.xml
$ wc fib.cpp.trace.xml
123 275 3838 fib.cpp.trace.xml
$ head fib.cpp.trace.xml
<?xml version="1.0" standalone="yes"?>
<Trace>
<TemplateBegin>
<Kind>TemplateInstantiation</Kind>
<Context context = "Fib&lt;5&gt;"/>
<PointOfInstantiation>fib.cpp|22|
14</PointOfInstantiation>
<TimeStamp time = "421998401.188854"/>
<MemoryUsage bytes = "0"/>
</TemplateBegin>
<TemplateBegin>
2015.02.27. C++ Russia 2015 51
2015.02.27. C++ Russia 2015 52
2015.02.27. C++ Russia 2015 53
2015.02.27. C++ Russia 2015 54
2015.02.27. C++ Russia 2015 55
2015.02.27. C++ Russia 2015 56
2015.02.27. C++ Russia 2015 57
2015.02.27. C++ Russia 2015 58
2015.02.27. C++ Russia 2015 59
2015.02.27. C++ Russia 2015 60
2015.02.27. C++ Russia 2015 61
2015.02.27. C++ Russia 2015 62
2015.02.27. C++ Russia 2015 63
2015.02.27. C++ Russia 2015 64
Filters
#include <iostream>
template<int N>
struct Fib
{
static const int value = Fib<N-2>::value + Fib<N-1>::value;
};
template<>
struct Fib<0>
{
static const int value = 0;
};
template<>
struct Fib<1>
{
static const int value = 1;
};
int main()
{
std::cout << Fib<5>::value << std::endl;
return 0;
}
2015.02.27. C++ Russia 2015 65
Filters
$ clang++ -templight fib.cpp
$ ls
fib.cpp.trace.xml
$ wc fib.cpp.trace.xml
18291 41765 738233 fib.cpp.trace.xml
$ head fib.cpp.trace.xml
<?xml version="1.0" standalone="yes"?>
<Trace>
<TemplateBegin>
<Kind>DefaultTemplateArgumentInstantiation</Kind>
<Context context = "std::basic_string"/>
<PointOfInstantiation>/usr/lib64/gcc/x86_64-suse-
linux/4.7/../../../../include/c++/4.7/bits/stringfwd.h|64|
11</PointOfInstantiation>
<TimeStamp time = "421999330.595354"/>
2015.02.27. C++ Russia 2015 66
2015.02.27. C++ Russia 2015 67
2015.02.27. C++ Russia 2015 68
2015.02.27. C++ Russia 2015 69
2015.02.27. C++ Russia 2015 70
2015.02.27. C++ Russia 2015 71
2015.02.27. C++ Russia 2015 72
2015.02.27. C++ Russia 2015 73
2015.02.27. C++ Russia 2015 74
2015.02.27. C++ Russia 2015 75
Memory usage
$ clang++ -templight-memory fib.cpp
$ ls
fib.cpp.memory.trace.xml
$ wc fib.cpp.memory.trace.xml
18291 41765 756365 fib5.cpp.memory.trace.xml
0$ head fib.cpp.trace.xml
<?xml version="1.0" standalone="yes"?>
<Trace>
<TemplateBegin>
<Kind>TemplateInstantiation</Kind>
<Context context = "Fib&lt;5&gt;"/>
<PointOfInstantiation>fib.cpp|22|
14</PointOfInstantiation>
<TimeStamp time = "421998401.188854"/>
<MemoryUsage bytes = "647664"/>
</TemplateBegin>
<TemplateBegin>
2015.02.27. C++ Russia 2015 76
Distortion
● Safe-mode is installed
● Invalid profiling info
● Flush messages even the compiler crashes
● Internal buffer collects events
● Heap allocated, not growing, size = 500.000
● Flush at end of compilation
● Distorsion < 3%
● clang++ -templight -trace-capacity=1000000
2015.02.27. C++ Russia 2015 77
Forks, Applications
● Martin Schulze modified client tools
http://github.com/schulmar/Templar
● Malte Skarupke's blog: comparing instantiation
time of unique_ptr, boost::flat_map, etc.
http://probablydance.com/2014/04/05/reinventing
-the-wheel-for-better-compile-time/
● Ábel Sinkovics: comparing lazy and greedy
metaprograms
2015.02.27. C++ Russia 2015 78
Evaluation of lazyness
● Ábel Sinkovics
2015.02.27. C++ Russia 2015 79
Metashell – interactive TMP REPL
● Ábel Sinkovics and András Kucsma
● Metashell https://github.com/sabel83/metashell
● Online demo: http://abel.web.elte.hu/shell
2015.02.27. C++ Russia 2015 80
Mikael Persson's Templight fork
● https://github.com/mikael-s-persson/templight
● https://github.com/mikael-s-persson/templight-tools
● Refactored and greatly
improved Templight
● Patch is under review
● Tools: KCacheGrind format
2015.02.27. C++ Russia 2015 81
Our vision
Trace
3rd party tools
Debugger/
visualizer
Other tools
2015.02.27. C++ Russia 2015 82
Summary
● Tool support for C++ metaprogramming
● Debugger/profiler requires compiler support
● Templight 2.0 based on clang
● Mikael's patch for clang is under review
● Please use it, give us feadback
● Compiler vendors, will you support Templight?
2015.02.27. C++ Russia 2015 83
Debugging and Profiling C++ Template Metaprograms
http://plc.inf.elte.hu/templight
gsd@elte.hu
Thank you!

Weitere ähnliche Inhalte

Was ist angesagt?

Perspective in Informatics 3 - Assignment 2 - Answer Sheet
Perspective in Informatics 3 - Assignment 2 - Answer SheetPerspective in Informatics 3 - Assignment 2 - Answer Sheet
Perspective in Informatics 3 - Assignment 2 - Answer SheetHoang Nguyen Phong
 
Graphs in Data Structure
 Graphs in Data Structure Graphs in Data Structure
Graphs in Data Structurehafsa komal
 
All pair shortest path by Sania Nisar
All pair shortest path by Sania NisarAll pair shortest path by Sania Nisar
All pair shortest path by Sania NisarSania Nisar
 
some basic C programs with outputs
some basic C programs with outputssome basic C programs with outputs
some basic C programs with outputsKULDEEPSING PATIL
 
Tutorial: Context-awareness In Information Retrieval and Recommender Systems
Tutorial: Context-awareness In Information Retrieval and Recommender SystemsTutorial: Context-awareness In Information Retrieval and Recommender Systems
Tutorial: Context-awareness In Information Retrieval and Recommender SystemsYONG ZHENG
 
Analysis and Design of Algorithms -Sorting Algorithms and analysis
Analysis and Design of Algorithms -Sorting Algorithms and analysisAnalysis and Design of Algorithms -Sorting Algorithms and analysis
Analysis and Design of Algorithms -Sorting Algorithms and analysisRadhika Talaviya
 
Intermediate code generation
Intermediate code generationIntermediate code generation
Intermediate code generationRamchandraRegmi
 
Counting sort(Non Comparison Sort)
Counting sort(Non Comparison Sort)Counting sort(Non Comparison Sort)
Counting sort(Non Comparison Sort)Hossain Md Shakhawat
 
Recursion tree method
Recursion tree methodRecursion tree method
Recursion tree methodRajendran
 
15 puzzle problem using branch and bound
15 puzzle problem using branch and bound15 puzzle problem using branch and bound
15 puzzle problem using branch and boundAbhishek Singh
 
Function template
Function templateFunction template
Function templateKousalya M
 
Dag representation of basic blocks
Dag representation of basic blocksDag representation of basic blocks
Dag representation of basic blocksJothi Lakshmi
 
Algorithm analysis
Algorithm analysisAlgorithm analysis
Algorithm analysissumitbardhan
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)swapnac12
 
SCSJ3553 - Artificial Intelligence Final Exam paper - UTM
SCSJ3553 - Artificial Intelligence Final Exam paper - UTMSCSJ3553 - Artificial Intelligence Final Exam paper - UTM
SCSJ3553 - Artificial Intelligence Final Exam paper - UTMAbdul Khaliq
 
UNIT I LINEAR DATA STRUCTURES – LIST
UNIT I 	LINEAR DATA STRUCTURES – LIST 	UNIT I 	LINEAR DATA STRUCTURES – LIST
UNIT I LINEAR DATA STRUCTURES – LIST Kathirvel Ayyaswamy
 

Was ist angesagt? (20)

Perspective in Informatics 3 - Assignment 2 - Answer Sheet
Perspective in Informatics 3 - Assignment 2 - Answer SheetPerspective in Informatics 3 - Assignment 2 - Answer Sheet
Perspective in Informatics 3 - Assignment 2 - Answer Sheet
 
Graphs in Data Structure
 Graphs in Data Structure Graphs in Data Structure
Graphs in Data Structure
 
Practical Data Science 
Use-cases in Retail & eCommerce
Practical Data Science 
Use-cases in Retail & eCommercePractical Data Science 
Use-cases in Retail & eCommerce
Practical Data Science 
Use-cases in Retail & eCommerce
 
All pair shortest path by Sania Nisar
All pair shortest path by Sania NisarAll pair shortest path by Sania Nisar
All pair shortest path by Sania Nisar
 
some basic C programs with outputs
some basic C programs with outputssome basic C programs with outputs
some basic C programs with outputs
 
Binary Search
Binary SearchBinary Search
Binary Search
 
Tutorial: Context-awareness In Information Retrieval and Recommender Systems
Tutorial: Context-awareness In Information Retrieval and Recommender SystemsTutorial: Context-awareness In Information Retrieval and Recommender Systems
Tutorial: Context-awareness In Information Retrieval and Recommender Systems
 
Analysis and Design of Algorithms -Sorting Algorithms and analysis
Analysis and Design of Algorithms -Sorting Algorithms and analysisAnalysis and Design of Algorithms -Sorting Algorithms and analysis
Analysis and Design of Algorithms -Sorting Algorithms and analysis
 
Intermediate code generation
Intermediate code generationIntermediate code generation
Intermediate code generation
 
Introduction to data structure and algorithms
Introduction to data structure and algorithmsIntroduction to data structure and algorithms
Introduction to data structure and algorithms
 
Counting sort(Non Comparison Sort)
Counting sort(Non Comparison Sort)Counting sort(Non Comparison Sort)
Counting sort(Non Comparison Sort)
 
Recursion tree method
Recursion tree methodRecursion tree method
Recursion tree method
 
15 puzzle problem using branch and bound
15 puzzle problem using branch and bound15 puzzle problem using branch and bound
15 puzzle problem using branch and bound
 
Function template
Function templateFunction template
Function template
 
Dag representation of basic blocks
Dag representation of basic blocksDag representation of basic blocks
Dag representation of basic blocks
 
Algorithm analysis
Algorithm analysisAlgorithm analysis
Algorithm analysis
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)
 
SCSJ3553 - Artificial Intelligence Final Exam paper - UTM
SCSJ3553 - Artificial Intelligence Final Exam paper - UTMSCSJ3553 - Artificial Intelligence Final Exam paper - UTM
SCSJ3553 - Artificial Intelligence Final Exam paper - UTM
 
UNIT I LINEAR DATA STRUCTURES – LIST
UNIT I 	LINEAR DATA STRUCTURES – LIST 	UNIT I 	LINEAR DATA STRUCTURES – LIST
UNIT I LINEAR DATA STRUCTURES – LIST
 
Graph
GraphGraph
Graph
 

Andere mochten auch

Inline function in C++
Inline function in C++Inline function in C++
Inline function in C++Jenish Patel
 
High quality library from scratch
High quality library from scratchHigh quality library from scratch
High quality library from scratchPlatonov Sergey
 
Конверсия управляемых языков в неуправляемые
Конверсия управляемых языков в неуправляемыеКонверсия управляемых языков в неуправляемые
Конверсия управляемых языков в неуправляемыеPlatonov Sergey
 
Address/Thread/Memory Sanitizer
Address/Thread/Memory SanitizerAddress/Thread/Memory Sanitizer
Address/Thread/Memory SanitizerPlatonov Sergey
 
Практика Lock-free. RealTime-сервер
Практика Lock-free. RealTime-серверПрактика Lock-free. RealTime-сервер
Практика Lock-free. RealTime-серверPlatonov Sergey
 
Асинхронность и сопрограммы
Асинхронность и сопрограммыАсинхронность и сопрограммы
Асинхронность и сопрограммыPlatonov Sergey
 
С++ without new and delete
С++ without new and deleteС++ without new and delete
С++ without new and deletePlatonov Sergey
 
Конкурентные ассоциативные контейнеры
Конкурентные ассоциативные контейнерыКонкурентные ассоциативные контейнеры
Конкурентные ассоциативные контейнерыPlatonov Sergey
 
Multithreading done right
Multithreading done rightMultithreading done right
Multithreading done rightPlatonov Sergey
 

Andere mochten auch (11)

Inline function in C++
Inline function in C++Inline function in C++
Inline function in C++
 
Metaprogramming
MetaprogrammingMetaprogramming
Metaprogramming
 
High quality library from scratch
High quality library from scratchHigh quality library from scratch
High quality library from scratch
 
Конверсия управляемых языков в неуправляемые
Конверсия управляемых языков в неуправляемыеКонверсия управляемых языков в неуправляемые
Конверсия управляемых языков в неуправляемые
 
Address/Thread/Memory Sanitizer
Address/Thread/Memory SanitizerAddress/Thread/Memory Sanitizer
Address/Thread/Memory Sanitizer
 
Практика Lock-free. RealTime-сервер
Практика Lock-free. RealTime-серверПрактика Lock-free. RealTime-сервер
Практика Lock-free. RealTime-сервер
 
Асинхронность и сопрограммы
Асинхронность и сопрограммыАсинхронность и сопрограммы
Асинхронность и сопрограммы
 
С++ without new and delete
С++ without new and deleteС++ without new and delete
С++ without new and delete
 
Конкурентные ассоциативные контейнеры
Конкурентные ассоциативные контейнерыКонкурентные ассоциативные контейнеры
Конкурентные ассоциативные контейнеры
 
Multithreading done right
Multithreading done rightMultithreading done right
Multithreading done right
 
Arrays In C++
Arrays In C++Arrays In C++
Arrays In C++
 

Ähnlich wie Debugging and Profiling C++ Template Metaprograms

4Developers 2018: Beyond c++17 (Mateusz Pusz)
4Developers 2018: Beyond c++17 (Mateusz Pusz)4Developers 2018: Beyond c++17 (Mateusz Pusz)
4Developers 2018: Beyond c++17 (Mateusz Pusz)PROIDEA
 
Cpp17 and Beyond
Cpp17 and BeyondCpp17 and Beyond
Cpp17 and BeyondComicSansMS
 
UoN-Lec_12_Control_Structure.pdf
UoN-Lec_12_Control_Structure.pdfUoN-Lec_12_Control_Structure.pdf
UoN-Lec_12_Control_Structure.pdfmadihamaqbool6
 
U19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).pptU19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).pptManivannan837728
 
Csc1100 lecture03 ch03-pt2-s14
Csc1100 lecture03 ch03-pt2-s14Csc1100 lecture03 ch03-pt2-s14
Csc1100 lecture03 ch03-pt2-s14IIUM
 
Csc1100 lecture03 ch03-pt2-s14
Csc1100 lecture03 ch03-pt2-s14Csc1100 lecture03 ch03-pt2-s14
Csc1100 lecture03 ch03-pt2-s14IIUM
 
C++ Concepts and Ranges - How to use them?
C++ Concepts and Ranges - How to use them?C++ Concepts and Ranges - How to use them?
C++ Concepts and Ranges - How to use them?Mateusz Pusz
 
Story of static code analyzer development
Story of static code analyzer developmentStory of static code analyzer development
Story of static code analyzer developmentAndrey Karpov
 
Review chapter 1 2-3
Review chapter 1 2-3Review chapter 1 2-3
Review chapter 1 2-3ahmed22dg
 
C++ lab assignment
C++ lab assignmentC++ lab assignment
C++ lab assignmentSaket Pathak
 
PVS-Studio. Static code analyzer. Windows/Linux, C/C++/C#. 2017
PVS-Studio. Static code analyzer. Windows/Linux, C/C++/C#. 2017PVS-Studio. Static code analyzer. Windows/Linux, C/C++/C#. 2017
PVS-Studio. Static code analyzer. Windows/Linux, C/C++/C#. 2017Andrey Karpov
 
Object Oriented Technologies
Object Oriented TechnologiesObject Oriented Technologies
Object Oriented TechnologiesUmesh Nikam
 
Value Objects, Full Throttle (to be updated for spring TC39 meetings)
Value Objects, Full Throttle (to be updated for spring TC39 meetings)Value Objects, Full Throttle (to be updated for spring TC39 meetings)
Value Objects, Full Throttle (to be updated for spring TC39 meetings)Brendan Eich
 
Introduction to C#
Introduction to C#Introduction to C#
Introduction to C#ANURAG SINGH
 
The First C# Project Analyzed
The First C# Project AnalyzedThe First C# Project Analyzed
The First C# Project AnalyzedPVS-Studio
 

Ähnlich wie Debugging and Profiling C++ Template Metaprograms (20)

Beyond C++17
Beyond C++17Beyond C++17
Beyond C++17
 
report
reportreport
report
 
4Developers 2018: Beyond c++17 (Mateusz Pusz)
4Developers 2018: Beyond c++17 (Mateusz Pusz)4Developers 2018: Beyond c++17 (Mateusz Pusz)
4Developers 2018: Beyond c++17 (Mateusz Pusz)
 
Cpp17 and Beyond
Cpp17 and BeyondCpp17 and Beyond
Cpp17 and Beyond
 
UoN-Lec_12_Control_Structure.pdf
UoN-Lec_12_Control_Structure.pdfUoN-Lec_12_Control_Structure.pdf
UoN-Lec_12_Control_Structure.pdf
 
U19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).pptU19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).ppt
 
CS4961-L9.ppt
CS4961-L9.pptCS4961-L9.ppt
CS4961-L9.ppt
 
Csc1100 lecture03 ch03-pt2-s14
Csc1100 lecture03 ch03-pt2-s14Csc1100 lecture03 ch03-pt2-s14
Csc1100 lecture03 ch03-pt2-s14
 
Csc1100 lecture03 ch03-pt2-s14
Csc1100 lecture03 ch03-pt2-s14Csc1100 lecture03 ch03-pt2-s14
Csc1100 lecture03 ch03-pt2-s14
 
C++ Concepts and Ranges - How to use them?
C++ Concepts and Ranges - How to use them?C++ Concepts and Ranges - How to use them?
C++ Concepts and Ranges - How to use them?
 
Story of static code analyzer development
Story of static code analyzer developmentStory of static code analyzer development
Story of static code analyzer development
 
Review chapter 1 2-3
Review chapter 1 2-3Review chapter 1 2-3
Review chapter 1 2-3
 
Python Manuel-R2021.pdf
Python Manuel-R2021.pdfPython Manuel-R2021.pdf
Python Manuel-R2021.pdf
 
C++ lab assignment
C++ lab assignmentC++ lab assignment
C++ lab assignment
 
PVS-Studio. Static code analyzer. Windows/Linux, C/C++/C#. 2017
PVS-Studio. Static code analyzer. Windows/Linux, C/C++/C#. 2017PVS-Studio. Static code analyzer. Windows/Linux, C/C++/C#. 2017
PVS-Studio. Static code analyzer. Windows/Linux, C/C++/C#. 2017
 
Object Oriented Technologies
Object Oriented TechnologiesObject Oriented Technologies
Object Oriented Technologies
 
Value Objects, Full Throttle (to be updated for spring TC39 meetings)
Value Objects, Full Throttle (to be updated for spring TC39 meetings)Value Objects, Full Throttle (to be updated for spring TC39 meetings)
Value Objects, Full Throttle (to be updated for spring TC39 meetings)
 
Introduction to C#
Introduction to C#Introduction to C#
Introduction to C#
 
The First C# Project Analyzed
The First C# Project AnalyzedThe First C# Project Analyzed
The First C# Project Analyzed
 
C++ manual Report Full
C++ manual Report FullC++ manual Report Full
C++ manual Report Full
 

Mehr von Platonov Sergey

Евгений Зуев, С++ в России: Стандарт языка и его реализация
Евгений Зуев, С++ в России: Стандарт языка и его реализацияЕвгений Зуев, С++ в России: Стандарт языка и его реализация
Евгений Зуев, С++ в России: Стандарт языка и его реализацияPlatonov Sergey
 
Алексей Кутумов, C++ без исключений, часть 3
Алексей Кутумов,  C++ без исключений, часть 3Алексей Кутумов,  C++ без исключений, часть 3
Алексей Кутумов, C++ без исключений, часть 3Platonov Sergey
 
Евгений Рыжков, Андрей Карпов Как потратить 10 лет на разработку анализатора ...
Евгений Рыжков, Андрей Карпов Как потратить 10 лет на разработку анализатора ...Евгений Рыжков, Андрей Карпов Как потратить 10 лет на разработку анализатора ...
Евгений Рыжков, Андрей Карпов Как потратить 10 лет на разработку анализатора ...Platonov Sergey
 
Евгений Крутько, Многопоточные вычисления, современный подход.
Евгений Крутько, Многопоточные вычисления, современный подход.Евгений Крутько, Многопоточные вычисления, современный подход.
Евгений Крутько, Многопоточные вычисления, современный подход.Platonov Sergey
 
Тененёв Анатолий, Boost.Asio в алгоритмической торговле
Тененёв Анатолий, Boost.Asio в алгоритмической торговлеТененёв Анатолий, Boost.Asio в алгоритмической торговле
Тененёв Анатолий, Boost.Asio в алгоритмической торговлеPlatonov Sergey
 
Павел Беликов, Опыт мигрирования крупного проекта с Windows-only на Linux
Павел Беликов, Опыт мигрирования крупного проекта с Windows-only на LinuxПавел Беликов, Опыт мигрирования крупного проекта с Windows-only на Linux
Павел Беликов, Опыт мигрирования крупного проекта с Windows-only на LinuxPlatonov Sergey
 
Дмитрий Кашицын, Вывод типов в динамических и не очень языках II
Дмитрий Кашицын, Вывод типов в динамических и не очень языках IIДмитрий Кашицын, Вывод типов в динамических и не очень языках II
Дмитрий Кашицын, Вывод типов в динамических и не очень языках IIPlatonov Sergey
 
Дмитрий Кашицын, Вывод типов в динамических и не очень языках I
Дмитрий Кашицын, Вывод типов в динамических и не очень языках IДмитрий Кашицын, Вывод типов в динамических и не очень языках I
Дмитрий Кашицын, Вывод типов в динамических и не очень языках IPlatonov Sergey
 
QML\Qt Quick на практике
QML\Qt Quick на практикеQML\Qt Quick на практике
QML\Qt Quick на практикеPlatonov Sergey
 
Визуализация автомобильных маршрутов
Визуализация автомобильных маршрутовВизуализация автомобильных маршрутов
Визуализация автомобильных маршрутовPlatonov Sergey
 
Функциональный микроскоп: линзы в C++
Функциональный микроскоп: линзы в C++Функциональный микроскоп: линзы в C++
Функциональный микроскоп: линзы в C++Platonov Sergey
 
Как мы уменьшили количество ошибок в Unreal Engine с помощью статического ана...
Как мы уменьшили количество ошибок в Unreal Engine с помощью статического ана...Как мы уменьшили количество ошибок в Unreal Engine с помощью статического ана...
Как мы уменьшили количество ошибок в Unreal Engine с помощью статического ана...Platonov Sergey
 
HPX: C++11 runtime система для параллельных и распределённых вычислений
HPX: C++11 runtime система для параллельных и распределённых вычисленийHPX: C++11 runtime система для параллельных и распределённых вычислений
HPX: C++11 runtime система для параллельных и распределённых вычисленийPlatonov Sergey
 
Ranges calendar-novosibirsk-2015-08
Ranges calendar-novosibirsk-2015-08Ranges calendar-novosibirsk-2015-08
Ranges calendar-novosibirsk-2015-08Platonov Sergey
 
Использование maven для сборки больших модульных c++ проектов на примере Odin...
Использование maven для сборки больших модульных c++ проектов на примере Odin...Использование maven для сборки больших модульных c++ проектов на примере Odin...
Использование maven для сборки больших модульных c++ проектов на примере Odin...Platonov Sergey
 
Дракон в мешке: от LLVM к C++ и проблемам неопределенного поведения
Дракон в мешке: от LLVM к C++ и проблемам неопределенного поведенияДракон в мешке: от LLVM к C++ и проблемам неопределенного поведения
Дракон в мешке: от LLVM к C++ и проблемам неопределенного поведенияPlatonov Sergey
 
One definition rule - что это такое, и как с этим жить
One definition rule - что это такое, и как с этим житьOne definition rule - что это такое, и как с этим жить
One definition rule - что это такое, и как с этим житьPlatonov Sergey
 
DI в C++ тонкости и нюансы
DI в C++ тонкости и нюансыDI в C++ тонкости и нюансы
DI в C++ тонкости и нюансыPlatonov Sergey
 
Аскетичная разработка браузера
Аскетичная разработка браузераАскетичная разработка браузера
Аскетичная разработка браузераPlatonov Sergey
 

Mehr von Platonov Sergey (20)

Евгений Зуев, С++ в России: Стандарт языка и его реализация
Евгений Зуев, С++ в России: Стандарт языка и его реализацияЕвгений Зуев, С++ в России: Стандарт языка и его реализация
Евгений Зуев, С++ в России: Стандарт языка и его реализация
 
Алексей Кутумов, C++ без исключений, часть 3
Алексей Кутумов,  C++ без исключений, часть 3Алексей Кутумов,  C++ без исключений, часть 3
Алексей Кутумов, C++ без исключений, часть 3
 
Евгений Рыжков, Андрей Карпов Как потратить 10 лет на разработку анализатора ...
Евгений Рыжков, Андрей Карпов Как потратить 10 лет на разработку анализатора ...Евгений Рыжков, Андрей Карпов Как потратить 10 лет на разработку анализатора ...
Евгений Рыжков, Андрей Карпов Как потратить 10 лет на разработку анализатора ...
 
Евгений Крутько, Многопоточные вычисления, современный подход.
Евгений Крутько, Многопоточные вычисления, современный подход.Евгений Крутько, Многопоточные вычисления, современный подход.
Евгений Крутько, Многопоточные вычисления, современный подход.
 
Тененёв Анатолий, Boost.Asio в алгоритмической торговле
Тененёв Анатолий, Boost.Asio в алгоритмической торговлеТененёв Анатолий, Boost.Asio в алгоритмической торговле
Тененёв Анатолий, Boost.Asio в алгоритмической торговле
 
Павел Беликов, Опыт мигрирования крупного проекта с Windows-only на Linux
Павел Беликов, Опыт мигрирования крупного проекта с Windows-only на LinuxПавел Беликов, Опыт мигрирования крупного проекта с Windows-only на Linux
Павел Беликов, Опыт мигрирования крупного проекта с Windows-only на Linux
 
Дмитрий Кашицын, Вывод типов в динамических и не очень языках II
Дмитрий Кашицын, Вывод типов в динамических и не очень языках IIДмитрий Кашицын, Вывод типов в динамических и не очень языках II
Дмитрий Кашицын, Вывод типов в динамических и не очень языках II
 
Дмитрий Кашицын, Вывод типов в динамических и не очень языках I
Дмитрий Кашицын, Вывод типов в динамических и не очень языках IДмитрий Кашицын, Вывод типов в динамических и не очень языках I
Дмитрий Кашицын, Вывод типов в динамических и не очень языках I
 
QML\Qt Quick на практике
QML\Qt Quick на практикеQML\Qt Quick на практике
QML\Qt Quick на практике
 
Визуализация автомобильных маршрутов
Визуализация автомобильных маршрутовВизуализация автомобильных маршрутов
Визуализация автомобильных маршрутов
 
Функциональный микроскоп: линзы в C++
Функциональный микроскоп: линзы в C++Функциональный микроскоп: линзы в C++
Функциональный микроскоп: линзы в C++
 
C++ exceptions
C++ exceptionsC++ exceptions
C++ exceptions
 
Как мы уменьшили количество ошибок в Unreal Engine с помощью статического ана...
Как мы уменьшили количество ошибок в Unreal Engine с помощью статического ана...Как мы уменьшили количество ошибок в Unreal Engine с помощью статического ана...
Как мы уменьшили количество ошибок в Unreal Engine с помощью статического ана...
 
HPX: C++11 runtime система для параллельных и распределённых вычислений
HPX: C++11 runtime система для параллельных и распределённых вычисленийHPX: C++11 runtime система для параллельных и распределённых вычислений
HPX: C++11 runtime система для параллельных и распределённых вычислений
 
Ranges calendar-novosibirsk-2015-08
Ranges calendar-novosibirsk-2015-08Ranges calendar-novosibirsk-2015-08
Ranges calendar-novosibirsk-2015-08
 
Использование maven для сборки больших модульных c++ проектов на примере Odin...
Использование maven для сборки больших модульных c++ проектов на примере Odin...Использование maven для сборки больших модульных c++ проектов на примере Odin...
Использование maven для сборки больших модульных c++ проектов на примере Odin...
 
Дракон в мешке: от LLVM к C++ и проблемам неопределенного поведения
Дракон в мешке: от LLVM к C++ и проблемам неопределенного поведенияДракон в мешке: от LLVM к C++ и проблемам неопределенного поведения
Дракон в мешке: от LLVM к C++ и проблемам неопределенного поведения
 
One definition rule - что это такое, и как с этим жить
One definition rule - что это такое, и как с этим житьOne definition rule - что это такое, и как с этим жить
One definition rule - что это такое, и как с этим жить
 
DI в C++ тонкости и нюансы
DI в C++ тонкости и нюансыDI в C++ тонкости и нюансы
DI в C++ тонкости и нюансы
 
Аскетичная разработка браузера
Аскетичная разработка браузераАскетичная разработка браузера
Аскетичная разработка браузера
 

Kürzlich hochgeladen

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 

Kürzlich hochgeladen (20)

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 

Debugging and Profiling C++ Template Metaprograms

  • 1. Debugging and Profiling C++ Template Metaprograms Zoltán Porkoláb gsd@elte.hu Ericsson Hungary Eötvös Loránd University, Budapest
  • 2. 2015.02.27. C++ Russia 2015 2 ● C++ Template Metaprogramming ● Possible debugging and profiling techiques ● Templight back-end tool ● Front-end tools ● 3rd party applications – please, contribute! ● Vision Agenda
  • 3. 2015.02.27. C++ Russia 2015 3 C++ Template Metaprograms ● Expression templates (since 1995!) ● Active libraries, compile-time adaption ● Static interface checking ● Simulating language extensions ● DSL embedding ● Many other areas ...
  • 4. 2015.02.27. C++ Russia 2015 4 Motivation – a personal view template <class T, class S> ? max( T a, S b) // How to define the return value? { if ( a > b ) return a; else return b; } int main() { short is = 3; long il = 2; double d = 3.14; cout << max( il, is); cout << max( is, d); }
  • 5. 2015.02.27. C++ Russia 2015 5 Compile-time vs. Run-time Compile-time Run-timeCompile-time
  • 6. 2015.02.27. C++ Russia 2015 6 Compile-time vs. Run-time Compile-time Run-timeCompile-time 3 < 3.14
  • 7. 2015.02.27. C++ Russia 2015 7 Compile-time vs. Run-time Compile-time Run-timeCompile-time 3 > 2L 3 < 3.14 -1.0 < 0
  • 8. 2015.02.27. C++ Russia 2015 8 Compile-time vs. Run-time Compile-time Run-timeCompile-time 3 > 2L 3 < 3.14 -1.0 < 0 int std::string double long
  • 9. 2015.02.27. C++ Russia 2015 9 Motivation template <class T, class S> ? max( T a, S b) // How to define the return value? { if ( a > b ) return a; else return b; } int main() { short is = 3; long il = 2; double d = 3.14; cout << max( il, is); // long is ''better'' than short cout << max( is, d); // double is ''better'' than short }
  • 10. 2015.02.27. C++ Russia 2015 10 Compile-time vs. Run-time Run-time 3 > 2L 3 < 3.14 -1.0 < 0 int std::string double long Template design time Compile-time Template Instantiation
  • 11. 2015.02.27. C++ Russia 2015 11 Compile-time vs. Run-time Run-timeCompile-time Template Instantiation 3 > 2L 3 < 3.14 -1.0 < 0 int std::string double long T S Template design time
  • 12. 2015.02.27. C++ Russia 2015 12 Compile-time vs. Run-time Run-time 3 > 2L 3 < 3.14 -1.0 < 0 int std::string double long T S sizeof(T) < sizeof(S) Template design time Compile-time Template Instantiation
  • 13. 2015.02.27. C++ Russia 2015 13 Compile-time vs. Run-time Run-time 3 > 2L 3 < 3.14 -1.0 < 0 int std::string double long T S sizeof(T) < sizeof(S) Template design time Compile-time Template Instantiation
  • 14. 2015.02.27. C++ Russia 2015 14 Motivation template <class T, class S> ? max( T a, S b) // How to define the return value? { if ( a > b ) return a; else return b; } int main() { short is = 3; long il = 2; double d = 3.14; cout << max( il, is); // long is ''better'' than short cout << max( is, d); // double is ''better'' than short }
  • 15. 2015.02.27. C++ Russia 2015 15 (de)Motivation template <class T, class S> auto max( T a, S b) -> decltype(a+b) // C++11 { if ( a > b ) return a; else return b; } int main() { short is = 3; long il = 2; double d = 3.14; cout << max( il, is); // -> long cout << max( is, d); // -> double }
  • 16. 2015.02.27. C++ Russia 2015 16 (de)Motivation template <class T, class S> typename std::common_type<T,S>::value max( T a, S b) // C++11 { if ( a > b ) return a; else return b; } int main() { short is = 3; long il = 2; double d = 3.14; cout << max( il, is); // -> long cout << max( is, d); // -> double }
  • 17. 2015.02.27. C++ Russia 2015 17 ● Run-time ● Compile-time
  • 18. 2015.02.27. C++ Russia 2015 18 ● Functions ● Values, literals ● Data structures ● If/else ● Loop ● Assignment ● May depend on input ● Run-time ● Compile-time
  • 19. 2015.02.27. C++ Russia 2015 19 ● Functions ● Values, literals ● Data structures ● If/else ● Loop ● Assignment ● May depend on input ● Metafunctions (type) ● Const, enum,constexpr ● Typelist (type) ● Pattern matching ● Recursion ● Ref. Transparency ● Deterministic ● Run-time ● Compile-time
  • 20. 2015.02.27. C++ Russia 2015 20 ● Imperative ● Object-oriented ● Generative ● (some) Functional ● Run-time ● Compile-time
  • 21. 2015.02.27. C++ Russia 2015 21 ● Imperative ● Object-oriented ● Generative ● (some) Functional ● Pure Functional ● Run-time ● Compile-time
  • 22. 2015.02.27. C++ Russia 2015 22 The usual factorial program ... template <int N> struct Factorial { enum { value = Factorial<N-1>::value * N }; }; template <> struct Factorial<0> { enum { value = 1 }; }; int main() { const int fact5 = Factorial<5>::value; }
  • 23. 2015.02.27. C++ Russia 2015 23 Bugs!!! ...
  • 24. 2015.02.27. C++ Russia 2015 24 The java programmer ... template <int N> struct Factorial { enum { value = Factorial<N-1>::value * N }; }; template <> struct Factorial<0> { enum { value = 1 }; } //; int main() { const int fact5 = Factorial<5>::value; }
  • 25. 2015.02.27. C++ Russia 2015 25 The java programmer ... template <int N> struct Factorial { enum { value = Factorial<N-1>::value * N }; }; template <> struct Factorial<0> { enum { value = 1 }; } //; int main() { const int fact5 = Factorial<5>::value; } $ clang++ fact.cpp fact.cpp:14:2: error: expected ';' after class } ^ ; 1 error generated.
  • 26. 2015.02.27. C++ Russia 2015 26 The vim user ... template <int N> struct Factorial { enum { value = Factorial<N-1>::value * N }; }; template <> struct Factorial<0> { enum { ivalue = 1 }; }; int main() { const int fact5 = Factorial<5>::value; }
  • 27. 2015.02.27. C++ Russia 2015 27 The vim user ... template <int N> struct Factorial { enum { value = Factorial<N-1>::value * N }; }; template <> struct Factorial<0> { enum { ivalue = 1 }; }; int main() { const int fact5 = Factorial<5>::value; } $ clang++ fact.cpp fact.cpp:5:34: error: no member named 'value' in 'Factorial<0>' enum { value = Factorial<N-1>::value * N }; ~~~~~~~~~~~~~~~~^ fact.cpp:5:18: note: in instantiation of template class 'Factorial<1>' requested here enum { value = Factorial<N-1>::value * N }; ^ fact.cpp:5:18: note: in instantiation of template class 'Factorial<2>' requested here enum { value = Factorial<N-1>::value * N }; ^ fact.cpp:5:18: note: in instantiation of template class 'Factorial<3>' requested here enum { value = Factorial<N-1>::value * N }; ^ fact.cpp:5:18: note: in instantiation of template class 'Factorial<4>' requested here enum { value = Factorial<N-1>::value * N }; ^ fact.cpp:16:21: note: in instantiation of template class 'Factorial<5>' requested here const int fact5 = Factorial<5>::value; ^ 1 error generated.
  • 28. 2015.02.27. C++ Russia 2015 28 The negative approach ... template <int N> struct Factorial { enum { value = Factorial<N-1>::value * N }; }; template <> struct Factorial<0> { enum { value = 1 }; }; int main() { const int fact5 = Factorial<-5>::value; }
  • 29. 2015.02.27. C++ Russia 2015 29 The negative approach ... template <int N> struct Factorial { enum { value = Factorial<N-1>::value * N }; }; template <> struct Factorial<0> { enum { value = 1 }; }; int main() { const int fact5 = Factorial<-5>::value; } $ clang++ fact4.cpp fact4.cpp:6:18: fatal error: recursive template instantiation exceeded maximum depth of 512 enum { value = Factorial<N-1>::value * N }; ^ fact4.cpp:6:18: note: in instantiation of template class 'Factorial<-517>' requested here enum { value = Factorial<N-1>::value * N }; Fact4.cpp:6:18: note: (skipping 503 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all) fact4.cpp:18:21: note: in instantiation of template class 'Factorial<-5>' requested here const int fact5 = Factorial<-5>::value; ^ fact4.cpp:6:18: note: use -ftemplate-depth=N to increase recursive template instantiation depth enum { value = Factorial<N-1>::value * N }; ^ 1 error generated.
  • 30. 2015.02.27. C++ Russia 2015 30 The greedy ... template <int N> struct Factorial { enum { value = Factorial<N-1>::value * N }; }; template <> struct Factorial<0> { enum { value = 1 }; }; int main() { const int fact5 = Factorial<-5>::value; } $ clang++ -ftemplate-depth=10000 fact4.cpp
  • 31. 2015.02.27. C++ Russia 2015 31 The greedy ... template <int N> struct Factorial { enum { value = Factorial<N-1>::value * N }; }; template <> struct Factorial<0> { enum { value = 1 }; }; int main() { const int fact5 = Factorial<-5>::value; } $ clang++ -ftemplate-depth=10000 fact4.cpp$ clang++ -ftemplate-depth=10000 fact4.cpp clang: error: unable to execute command: Segmentation fault clang: error: clang frontend command failed due to signal (use -v to see invocation) clang version 3.2 (branches/release_32 180710) Target: x86_64-unknown-linux-gnu Thread model: posix clang: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script. clang: note: diagnostic msg: ******************** PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: clang: note: diagnostic msg: /tmp/fact4-iy6zKp.cpp clang: note: diagnostic msg: /tmp/fact4-iy6zKp.sh clang: note: diagnostic msg: ********************
  • 32. 2015.02.27. C++ Russia 2015 32 We need tools ● C++ syntax is not designed for metaprogramming ● Compilers are not optimised for detecting and reporting template metaprogram errors ● Compilers are not optimised for template metaprogram execution ● Compiler internals are black box for most programmers ● Programmers have less experience with template metaprograms
  • 33. 2015.02.27. C++ Russia 2015 33 Tool support ● Pretty good support for run-time C++
  • 34. 2015.02.27. C++ Russia 2015 34 Tool support ● Pretty good support for run-time C++ ● Static analyzers, lint-like tools ● Debuggers ● Profilers ● Code comprehension tools ● Style checkers
  • 35. 2015.02.27. C++ Russia 2015 35 Tool support ● Pretty good support for run-time C++ ● Static analyzers, lint-like tools ● Debuggers ● Profilers ● Code comprehension tools ● Style checkers ● Tools for template metaprogramming
  • 36. 2015.02.27. C++ Russia 2015 36 Tool support ● Pretty good support for run-time C++ ● Static analyzers, lint-like tools ● Debuggers ● Profilers ● Code comprehension tools ● Style checkers ● Tools for template metaprogramming ● ?
  • 37. 2015.02.27. C++ Russia 2015 37 Tool support Run-time Compile-time
  • 38. 2015.02.27. C++ Russia 2015 38 Tool support Run-time Compile-time
  • 39. 2015.02.27. C++ Russia 2015 39 Tool support Run-time Compile-time
  • 40. 2015.02.27. C++ Russia 2015 40 Tool support Run-time Compile-time
  • 41. 2015.02.27. C++ Russia 2015 41 Tool support Run-time Compile-time
  • 42. 2015.02.27. C++ Russia 2015 42 Related work ● Debugging ● Static assert/Concept check (Siek-Lumsdaine, McNamara-Smaragdakis, Alexandrescu, others...) ● Warning generation (many attempt) ● Instrumentation ● Profiling ● Measuring full compilation (Gurtovoy-Abrahams) ● Measuring warning apperance (Watanabe) ● Visualize ● Source execution ● Instantiation graph
  • 43. 2015.02.27. C++ Russia 2015 43 Preprocessor Instrumentator Compiler Warning parser Positioner #line mapping Trace file Position correct trace Instrumented source Preprocessed source template<int i> struct Factorial { /* ---------------- begin inserted ----------- */ struct _TEMPLIGHT_0s { int a; }; enum { _TEMPLIGHT_0 = Templight::ReportTemplateBegin<_TEMPLIGHT_0s, &_TEMPLIGHT_0s::a>::Value }; /* ----------------- end inserted ------------ */ enum { value = Factorial<i-1>::value }; /* ---------------- begin inserted ----------- */ struct _TEMPLIGHT_1s { int a; }; enum { _TEMPLIGHT_1 = Templight::ReportTemplateEnd<_TEMPLIGHT_1s, &_TEMPLIGHT_1s::a>::Value }; /* ----------------- end inserted ------------ */ }; template<> struct Factorial<1> { /* ---------------- begin inserted ----------- */ struct _TEMPLIGHT_2s { int a; }; enum { _TEMPLIGHT_2 = Templight::ReportTemplateBegin<_TEMPLIGHT_2s, &_TEMPLIGHT_2s::a>::Value }; /* ----------------- end inserted ------------ */ enum { value = 1 }; /* ---------------- begin inserted ----------- */ struct _TEMPLIGHT_3s { int a; }; enum { _TEMPLIGHT_3 = Templight::ReportTemplateEnd< _TEMPLIGHT_3s, &_TEMPLIGHT_3s::a>::Value }; /* ----------------- end inserted ------------ */ }; GPCE 2006: Porkoláb, Mihalicza, Sipos: Debugging C++ template metaprograms
  • 44. 2015.02.27. C++ Russia 2015 44 Instrumentation ● Advantages ● Light-way approach (compared to compiler hack) ● Grammar support (we used wave) ● Easier to port: just change the warning generator
  • 45. 2015.02.27. C++ Russia 2015 45 Instrumentation ● Advantages ● Light-way approach (compared to compiler hack) ● Grammar support (we used wave) ● Easier to port: just change the warning generator ● Disadvantages ● Complex constructs are hard (e.g. inheritance) ● Serious distortion in profiling information ● Memoization not detected
  • 46. 2015.02.27. C++ Russia 2015 46 Templight 2.0 ● Based on LLVM/Clang compiler infrastructure ● Patch to ● Detect/measure instantiation ● Detect memoization ● Put timestamp on events ● Measure memory consumption (optional) ● Emit trace in various formats (txt, YAML, XML) ● Front-end tools ● Visual debugger ● Profiler data viewer
  • 47. 2015.02.27. C++ Russia 2015 47 Templight 2.0 Trace C++ C++ C++ Templight patch 3rd party tools Clang source Interactive debugger/ visualizer Instantiation time and memory profiler
  • 48. 2015.02.27. C++ Russia 2015 48 Installation ● Visit http://plc.inf.elte.hu/templight ● Download templight-<timestamp>.tar.gz ● Contains clang patch and the two frontends ● Download Clang source ● Patch and build clang ● Build front-end tools (optional) ● >=Qt 4.6 and >=Graphviz 2.28.0 required ● $ qmake; make
  • 49. 2015.02.27. C++ Russia 2015 49 How to use template<int N> struct Fib { static const int value = Fib<N-2>::value + Fib<N-1>::value; }; template<> struct Fib<0> { static const int value = 0; }; template<> struct Fib<1> { static const int value = 1; }; int main() { static const int fib5 = Fib<5>::value; }
  • 50. 2015.02.27. C++ Russia 2015 50 How to use $ clang++ -templight fib.cpp $ ls fib.cpp.trace.xml $ wc fib.cpp.trace.xml 123 275 3838 fib.cpp.trace.xml $ head fib.cpp.trace.xml <?xml version="1.0" standalone="yes"?> <Trace> <TemplateBegin> <Kind>TemplateInstantiation</Kind> <Context context = "Fib&lt;5&gt;"/> <PointOfInstantiation>fib.cpp|22| 14</PointOfInstantiation> <TimeStamp time = "421998401.188854"/> <MemoryUsage bytes = "0"/> </TemplateBegin> <TemplateBegin>
  • 64. 2015.02.27. C++ Russia 2015 64 Filters #include <iostream> template<int N> struct Fib { static const int value = Fib<N-2>::value + Fib<N-1>::value; }; template<> struct Fib<0> { static const int value = 0; }; template<> struct Fib<1> { static const int value = 1; }; int main() { std::cout << Fib<5>::value << std::endl; return 0; }
  • 65. 2015.02.27. C++ Russia 2015 65 Filters $ clang++ -templight fib.cpp $ ls fib.cpp.trace.xml $ wc fib.cpp.trace.xml 18291 41765 738233 fib.cpp.trace.xml $ head fib.cpp.trace.xml <?xml version="1.0" standalone="yes"?> <Trace> <TemplateBegin> <Kind>DefaultTemplateArgumentInstantiation</Kind> <Context context = "std::basic_string"/> <PointOfInstantiation>/usr/lib64/gcc/x86_64-suse- linux/4.7/../../../../include/c++/4.7/bits/stringfwd.h|64| 11</PointOfInstantiation> <TimeStamp time = "421999330.595354"/>
  • 75. 2015.02.27. C++ Russia 2015 75 Memory usage $ clang++ -templight-memory fib.cpp $ ls fib.cpp.memory.trace.xml $ wc fib.cpp.memory.trace.xml 18291 41765 756365 fib5.cpp.memory.trace.xml 0$ head fib.cpp.trace.xml <?xml version="1.0" standalone="yes"?> <Trace> <TemplateBegin> <Kind>TemplateInstantiation</Kind> <Context context = "Fib&lt;5&gt;"/> <PointOfInstantiation>fib.cpp|22| 14</PointOfInstantiation> <TimeStamp time = "421998401.188854"/> <MemoryUsage bytes = "647664"/> </TemplateBegin> <TemplateBegin>
  • 76. 2015.02.27. C++ Russia 2015 76 Distortion ● Safe-mode is installed ● Invalid profiling info ● Flush messages even the compiler crashes ● Internal buffer collects events ● Heap allocated, not growing, size = 500.000 ● Flush at end of compilation ● Distorsion < 3% ● clang++ -templight -trace-capacity=1000000
  • 77. 2015.02.27. C++ Russia 2015 77 Forks, Applications ● Martin Schulze modified client tools http://github.com/schulmar/Templar ● Malte Skarupke's blog: comparing instantiation time of unique_ptr, boost::flat_map, etc. http://probablydance.com/2014/04/05/reinventing -the-wheel-for-better-compile-time/ ● Ábel Sinkovics: comparing lazy and greedy metaprograms
  • 78. 2015.02.27. C++ Russia 2015 78 Evaluation of lazyness ● Ábel Sinkovics
  • 79. 2015.02.27. C++ Russia 2015 79 Metashell – interactive TMP REPL ● Ábel Sinkovics and András Kucsma ● Metashell https://github.com/sabel83/metashell ● Online demo: http://abel.web.elte.hu/shell
  • 80. 2015.02.27. C++ Russia 2015 80 Mikael Persson's Templight fork ● https://github.com/mikael-s-persson/templight ● https://github.com/mikael-s-persson/templight-tools ● Refactored and greatly improved Templight ● Patch is under review ● Tools: KCacheGrind format
  • 81. 2015.02.27. C++ Russia 2015 81 Our vision Trace 3rd party tools Debugger/ visualizer Other tools
  • 82. 2015.02.27. C++ Russia 2015 82 Summary ● Tool support for C++ metaprogramming ● Debugger/profiler requires compiler support ● Templight 2.0 based on clang ● Mikael's patch for clang is under review ● Please use it, give us feadback ● Compiler vendors, will you support Templight?
  • 83. 2015.02.27. C++ Russia 2015 83 Debugging and Profiling C++ Template Metaprograms http://plc.inf.elte.hu/templight gsd@elte.hu Thank you!