Cost of C++ Abstractions in C++ Embedded Systems
Talkat CppCon 2024 · on Friday, 2024-09-20· at 09:00· Cottonwood 2/3, 6700 North Gaylord Rockies Boulevard·
summary
Measures on an STM32 breadboard with two ADCs and LEDs show concrete results: a minimal firmware starts at 2 kilobytes base firmware, replacing runtime bitmasking with templates concepts immediate functions and constexpr if moves work to compile time, restores binary size to the C baseline for many cases and yields ~20% runtime savings (reported as up to ~30% in the demo). The project compiles, flashes, and benchmarks actual iterations, demonstrates static polymorphism via concepts vs. virtual calls, and pinpoints when templated code bloats binaries.
AI-written summary · about
chapters (25)
- 0:00C++ in embedded systems
- 1:30Motivation for C++ abstractions
- 2:55Hardware abstraction layer analysis
- 3:38Research methodology
- 5:02Firmware binary size
- 6:27Current HAL implementation
- 7:35Abstraction layers with encapsulation
- 10:51Register overhead of encapsulation
- 13:20Static member functions impact
- 15:28Templated static member functions
- 17:15Inheritance in hardware abstraction layers
- 18:37Polymorphism for hardware interfaces
- 20:44Dynamic polymorphism overhead
- 24:32Virtual function call overhead
- 26:38Static polymorphism with concepts
- 30:31Firmware architecture performance
- 34:51Inefficiencies in traditional hardware abstraction layers
- 36:16Compile-time nature of embedded
- 38:04Optimizing HAL with C++
- 40:53C++ type system tools
- 43:38Compile-time optimizations
- 44:43Optimized firmware results
- 45:49Code bloat trade-offs
- 46:31Key conclusions on abstractions
- 47:56Future of C++ in embedded
related talks
01h 00mModern C++: C++ Patterns to Make Embedded Programming More Productive
55mC++ on small micro controllers
57mDeeply Embedded C++
55mC++ in the World of Embedded Systems
31mReally Small Rust
01h 00mBuilding Effective Embedded Systems in C++: Architectural Best Practices
01h 03mUnlocking the value of C++20
01h 00mIntroduction to Hardware Efficiency in Cpp
