Category: Science & Technology

Using Coroutines to Implement C++ Exceptions for Freestanding Environments – Eyal Zedaka – CppCon 21

  • Lobby
  • Science & Technology

https://cppcon.org/
https://github.com/CppCon/CppCon2020
---
The current design of C++ exceptions lead to many reasons and excuses to disable them. They require outstanding unwinding libraries, ABI specific support, slow failure paths, metadata that increases binary size, RTTI (run time type information), and many more. Putting costs and overhead aside, it is often impractical, or holds significant implementation barriers, to implement the necessary support for C++ exceptions in every environment - kernel, custom OS, hypervisors, embedded, or an arbitrary freestanding environment with limited or no C++ runtime libraries.

Writing code using exceptions is great though! The programmer gets to focus on the actual story of what the program is doing, and not worry too much about error propagation that happens automatically whenever an exception is thrown.

So how do we avoid the manual error propagation that is usually followed by turning off exceptions? We use Macros(!), of course, to propagate the errors via return value, such as CHECK_ERROR(expression), RIGHT? Well... Not in this talk.

In this session we are going to use the only tool I know of, that is both available in standard C++20, and gives us the ability to automatically propagate errors. If you read the title, you already know that this tool was not meant to be used for that purpose - that is C++20 Coroutines!

We are going to not only run without exceptions, we are turning off RTTI as well, as we get inspired by this alternative method of throwing exceptions, observe some cool optimizations such as memory allocation elisions, analyze the assembly code of coroutines, and more. We will even get the link to the open source library that I wrote for this talk, so that you could try it yourself!

This talk is for you if you want to get inspired on a unique usage of coroutines, not commonly seen before, or if you are working on kernel / freestanding code and like the use of exceptions. I hope that after this talk the audience plays with the thought that maybe in the future, exceptions could be implemented as a standard library feature, using a core language machinery such as coroutines, or some evolution or adaptation of it to this great use case.

How to prepare for the talk - please be familiar with C++20 coroutines, just the basic understanding is enough.

---
Eyal Zedaka

Eyal Zedaka is a technical leader. He is a C++ knowledge center, lecturer in various C++ courses, and an author of C++ open source software in the areas of low level OS, and pure C++ frameworks. Eyal is now working at Magic Leap, an Augmented Reality (AR) device company, as manager of device security engineering, where he leads secure C++ development and vulnerability research throughout the platform. Eyal has served in designing a C++ freestanding framework for trusted execution environments, and providing consultation to embedded teams regarding C++ use in lower level areas. He had previously been a software security architect in charge of the Magic Leap platform security architecture, and a senior engineer in various low level and security C++ positions in the market for the last 9-10 years.

---
Videos Filmed & Edited by Bash Films: http://www.BashFilms.com

YouTube Channel Managed by Digital Medium Ltd https://events.digital-medium.co.uk

The CppCon YouTube Channel Is Sponsored By:
JetBrains : http://jb.gg/cpptools
SonarSource: https://www.sonarsource.com/

Filed under: Science & Technology

Branchless Programming in C++ – Fedor Pikus – CppCon 2021

  • Lobby
  • Science & Technology

https://cppcon.org/
https://github.com/CppCon/CppCon2020
---
Have you ever written code like this:
void f(bool b, long x, long& s) { if (b) s += x; }
Probably you have. Would you like me to tell you how much performance you left on the table? With a small change, that function could be made 2.5 times faster.

What about this code:
if (a[i] && b[i]) do_something(); else do_something_else();
Would you believe me if I told you that, under some not-so-exotic conditions, this line runs four times slower than it could be? It’s true, and I’m going to show you when and why.

This presentation will explain how modern CPUs handle computations to ensure that the hardware is used efficiently (which is how you get high performance from the processor). We will then learn how conditional code disrupts the ideal flow of computations and the countermeasures employed by the CPU designers to retain good performance in the presence of such code. Sometimes these measures are sufficient, often with the help of the compiler. But when they aren’t, it is up to the programmer to recover lost performance by coding with fewer branches.

---
Fedor Pikus

Fedor G Pikus is a Chief Engineering Scientist in the Design to Silicon division of Mentor Graphics Corp (Siemens business). His earlier positions included a Senior Software Engineer at Google and a Chief Software Architect for Calibre PERC, LVS, DFM at Mentor Graphics. He joined Mentor Graphics in 1998 when he made a switch from academic research in computational physics to the software industry. Fedor is a recognized expert on high-performance computing and C++, he presented his works at CPPCon, SD West, DesignCon, in Software Development Journal, and is also an O’Reilly author. His responsibilities as a Chief Scientist include planning the long-term technical direction of Calibre products, directing and training the engineers who work on these products, design, and architecture of the software, and research in the new design and software technologies. Fedor has over 25 patents and over 100 papers and conference presentations on physics, EDA, software design, and C++ language.

---
Videos Filmed & Edited by Bash Films: http://www.BashFilms.com

YouTube Channel Managed by Digital Medium Ltd https://events.digital-medium.co.uk

The CppCon YouTube Channel Is Sponsored By:
JetBrains: http://jb.gg/cpptools
SonarSource: https://www.sonarsource.com/

Filed under: Science & Technology

Our Adventures With REST API in C++ : Making it Easy – Damien Buhl – CppCon 2021

  • Lobby
  • Science & Technology

https://cppcon.org/
https://github.com/CppCon/CppCon2020
---
Consuming webservices is a routine work in today software development, however the solutions requires developers to repeat themselves very often : parsing and serializing payloads in JSON manually, hardcoding HTTP REST route calls in their applications themselves.

In principle OpenAPI comes to the rescue, but this implies generating code in a custom build process step, with terrible tooling leading to reduced code quality.

In this talk we present a clean and modern C++ solution to REST, JSON and OpenAPI with a bit of magic.

---
Damien Buhl

Damien (aka daminetreg) co-founder and CEO tipi.build is an enthusiast C++ developer. Opensource entrepreneur, GameMaker.fr community founder, Qt for Android contributor, Boost.Fusion maintainer since 2014.

---
Videos Streamed & Edited by Digital Medium: http://online.digital-medium.co.uk

The CppCon YouTube Channel Is Sponsored By:
JetBrains : http://jb.gg/cpptools
SonarSource: https://www.sonarsource.com/

Filed under: Science & Technology

Conquering C++20 Ranges – Tristan Brindle – CppCon 2021

  • Lobby
  • Science & Technology

https://cppcon.org/
https://github.com/CppCon/CppCon2020
---

This is the final part in a trilogy of talks covering the new Ranges functionality in C++20. Following the format of “C++20 Ranges in Practice” (CppCon 2020), in this installment we’ll look at three more everyday programming problems and discover how Ranges can be used to solve them cleanly, elegantly and concisely. In particular, in this talk we’ll focus on how we can implement our own custom range adaptors, often seen as the “final hurdle” on the road to conquering Ranges. Time permitting, we’ll also take a brief look at the new ranges additions currently in the planning stages for C++23.

---

Tristan Brindle

---

Videos Streamed & Edited by Digital Medium: http://online.digital-medium.co.uk

The CppCon YouTube Channel Is Sponsored By:
JetBrains : http://jb.gg/cpptools
SonarSource: https://www.sonarsource.com/

Filed under: Science & Technology

C++ Standard Parallelism – Bryce Adelstein Lelbach – CppCon 2021

  • Lobby
  • Science & Technology

https://cppcon.org/
https://github.com/CppCon/CppCon2020
---
Imagine writing parallel code that can run on any platform - CPUs, GPUs, DPUs, specialized accelerators, etc. It's no longer just a dream - you can do it in Standard C++!

Parallelism is increasingly common in software, from supercomputer simulations to mobile applications. But writing parallel code is increasingly challenging, due to an explosion of diversity in hardware, a trend that's likely to continue into the future. To meet this challenge, the Standard C++ Committee has developed a roadmap for C++ Standard Parallelism, a parallel programming model that will be portable to all platforms while delivering reasonable performance and efficiency for most use cases.

Our vision of C++ Standard Parallelism consists of three key components:

* Common parallel algorithms that dispatch to vendor-optimized parallel libraries
* Tools to write your own parallel algorithms that run anywhere.
* Mechanisms for composing parallel invocations of algorithms into task graphs.

In this talk, we'll dive into this roadmap - we'll discuss what we already have that you can use today, what's coming down the line, and where the future may lead us.

---
Bryce Lelbach

Bryce Adelstein Lelbach has spent over a decade developing software libraries and programming languages. He is the HPC Programming Models Architect at NVIDIA, where he leads programming language standardization efforts and drives the technical roadmap for NVIDIA's HPC compilers and libraries. Bryce is passionate about C++ and is one of the leaders of the C++ community. He is the
chair of INCITS/PL22, the US standards committee for programming languages and the Standard C++ Library Evolution group. Bryce is the program chair for the C++Now and CppCon conferences, and the chief organizer of the Bay Area C++ User Group. On the C++ Committee, he has personally worked on the C++17 parallel algorithms, executors, futures, senders/receivers, multidimensional arrays, and modules. He is one of the initial developers of the HPX parallel runtime system. He also helped start the LLVMLinux initiative and has occasionally contributed to the Boost C++ libraries.

---
Videos Streamed & Edited by Digital Medium: http://online.digital-medium.co.uk

The CppCon YouTube Channel Is Sponsored By:
JetBrains : http://jb.gg/cpptools
SonarSource: https://www.sonarsource.com/

Filed under: Science & Technology

Back to Basics: Compiling and Linking – Ben Saks – CppCon 2021

  • Lobby
  • Science & Technology

https://cppcon.org/
https://github.com/CppCon/CppCon2020
---

Most C and C++ programmers know the conventions for distributing declarations and definitions among headers and source files. However, there are exceptions to these conventions that we often chalk up to “linker magic”. If the linker can’t deal with multiply-defined symbols, how does it handle inline and constexpr functions? Why do explicit template specializations go into source files when most template code goes into headers? And what can embedded developers do to tell the linker to map certain code and data into specific memory regions?

This session answers these questions by taking a detailed look at how the traditional C/C++ build model works with headers and source files. It describes what happens during each stage of the build process: preprocessing, compiling, instantiation, and linking. It explains what information the compiler records from declarations and definitions – including exceptional cases like inline and templates – and how the linker uses that information to generate an executable. It also shows how you can use explicit instantiation to control memory layout and reduce build times. Finally, this session walks an example program through the entire build process to demonstrate how everything fits together.

This is **not** a session on C++20 Modules. However, it explains terms such as “translation unit” and “linkage” that are also part of the Modules framework, providing a solid foundation for understanding Modules.

---
Ben Saks

---

Videos Streamed & Edited by Digital Medium: http://online.digital-medium.co.uk

The CppCon YouTube Channel Is Sponsored By:
JetBrains : http://jb.gg/cpptools
SonarSource: https://www.sonarsource.com/

Filed under: Science & Technology

Handling a Family of Hardware Devices with a Single Implementation – Ben Saks – CppCon 2021

  • Lobby
  • Science & Technology

https://cppcon.org/
https://github.com/CppCon/CppCon2020
---

Embedded software typically uses memory-mapped registers to communicate with hardware. These registers are often finicky and demanding. Software that accesses a hardware register in the wrong way often produces bugs that are hard to diagnose and fix. In this session, we’ll look at ways to use operator overloading, enumeration types, and other C++ features to craft interfaces that protect against such misuses. We’ll then look at techniques for generalizing that code so that one implementation works for many variations of the hardware.

Using real-world examples of 8-bit and 16-bit hardware timers, we’ll begin by constructing a safe interface for a specific hardware timer. From there, we’ll use templates to generalize the implementation to cover more timer variations. By isolating and extracting the differences between the timers, we’ll minimize the need for code duplication. We’ll also be able to write application code that works equally well with any of the timers. Along the way, we’ll deal with smaller problems, such as dealing with non-contiguous register layouts and guaranteeing that large values are locked during accesses.

This session uses concrete examples of timers in the ARM7 and Arduino MEGA 2560 architectures. However, the techniques from this session apply to a wide variety of platforms and hardware devices such as serial ports or I/O pins.

---

Ben Saks
Chief Engineer, Saks & Associates

---

Videos Streamed & Edited by Digital Medium: http://online.digital-medium.co.uk

The CppCon YouTube Channel Is Sponsored By:
JetBrains : http://jb.gg/cpptools
SonarSource: https://www.sonarsource.com/

Filed under: Science & Technology

A Hash Map for Graph Processing Workloads & a Methodology for Transactional Data Structures – CppCon

  • Lobby
  • Science & Technology

https://cppcon.org/
https://github.com/CppCon/CppCon2020
---
Emerging byte-addressable Non-Volatile Memories (NVMs) provide higher densities and data persistence where process state can be recovered after crashes. Graph analytic applications such as search and ranking, pattern matching, and clustering benefit from the large capacity available with persistent memory since the data sets are very large with up to trillions of vertices and edges. A hash map is fundamental for graph analytics because it associatively map keys to values, offering constant time lookup for graph updates. While lock-free persistent hash maps have been developed, most perform poorly due to a heavy use of pointer dereferences. Additionally, it is often desirable to perform a composition of graph updates as a transaction. Although persistent data structures enable applications to rely on persistent data with failure-atomic operations, they lack the ability to allow users to execute a sequence of operations as transactions. Meanwhile, persistent transactional memory (PTM) has been proposed by adding durability to Software Transactional Memory (STM). However, PTM suffers from high performance overheads and low scalability due to false aborts, logging, and ordering constraints on persistence.

In this talk, we present PMap, a persistent concurrent hash map with open addressing and non-blocking parallel resizing to cater to large graph processing workloads. Our PMap achieves lock-freedom using compare_exchange_strong from the C++11 Atomic Operations Library. To provide persistence, our design uses a modified version of the link-and-persist approach. While this approach is traditionally used to persist pointers, our modification enables link-and-persist to be used in-place, persisting keys and values directly. This is crucial, as logs, or separate object allocations may require pointer dereferences, which undermines the cache locality benefits of pure open addressing. The PMap uses the C++11 alignas specifier to ensure data can be aligned and flushed on a per-cacheline basis into persistent memory. To accommodate durable transactions, we present PETRA, a new approach for constructing persistent transactional non-blocking linked data structures. PETRA natively supports transactions, but unlike PTM, relies on the high-level information from the data structure semantics. This gives PETRA unique advantages in the form of high performance and high scalability. We present diagrams detailing the PMap design and PETRA methodology for the C++ programming language, and illustrate how to keep the number of cache line flushes and memory fences low through the use of descriptor objects, which are commonly used in the design of lock-free data structures.

We showcase the performance of our proposed persistent data structures by presenting a live demonstration of PMap and PETRA data structures including a linked list, skiplist, map, and multi-dimensional list. We compare PMap to clevel, OneFile, STL, and PMDK, tested on a micro-benchmark and on files from Recursive Model for graph mining (R-MAT). We compare the PETRA data structures to OneFile, Romulus, and PMDK, tested on a micro-benchmark and the Telecommunication Application Transaction Processing (TATP) benchmark. The live demonstration illustrates how PMap outperforms state-of-the-art alternatives averaging 3122x faster under Intel Optane DC, and PETRA outperforms the state-of-the-art PTMs by an order of magnitude in transactions of size greater than one, and demonstrates superior performance in transactions of size one.

---
Kenneth Lamar

Kenneth Lamar received his Bachelor of Science (2017) from the University of Central Florida. He is currently pursuing his PhD in Computer Science at UCF. His research interests include concurrent data structures and distributed computing. His work is currently focused on HPC scheduling, transactional data structures, and persistent memory.

Christina Peterson

Dr. Christina Peterson is a Postdoctoral Associate at the University of Central Florida. Dr. Peterson completed her dissertation work under the supervision of Dr. Damian Dechev with a focus on correctness and progress guarantees of multiprocessor algorithms and data structures. Her published work includes the development of a durable linearizable correctness tool, concurrent correctness conditions defined in vector space, a transactional correctness tool for abstract data types, a correctness condition specification tool, a framework to verify progress guarantees, and an extension of combinatorial topology theory for wait-free computability to support the instructions Compare-And-Swap and Load-Link-Store-Conditional. She also co-authored a publication that provides a read-uncommitted view for blockchain transactions.

---
Filmed & Edited by Bash Films: http://www.BashFilms.com

The CppCon YouTube Channel Is Sponsored By:
JetBrains : http://jb.gg/cpptools
SonarSource: https://www.sonarsource.com/

Filed under: Science & Technology

Embracing PODs Safely Until They Die – Alisdair Meredith & Nina Ranns – CppCon 2021

  • Lobby
  • Science & Technology

https://cppcon.org/
https://github.com/CppCon/CppCon2020
---
How do you change the active member of a union? Can you copy an object without a publicly callable copy constructor? Can you pass classes having private data to a function implemented in C? What is the use case for the library type trait `std::is_trivially_move_assignable`? All these questions and more will be answered in this session.

PODs --- Plain Old Data --- are neither plain nor old in C++11, and continued to evolve in every published standard since, until they were finally banished in C++20. In researching the deconstruction of PODs for the upcoming book, "Embracing Modern C++ Safely" Alisdair Meredith (and the other authors including John Lakos, Vittorio Romeo, and Rostislav Khlebnikov) discovered that many of the intuitive properties and capabilities of trivial and standard layout types did not behave quite as expected, and there are many subtleties waiting to catch the unwary. Nina Ranns, as an active member of the Core working group, stepped in to explain and resolve many concerns, while pointing out further bad assumptions. Together they will present the use cases, pitfalls, and annoyances of these features as now properly understood, giving a flavor of the presentation style of each of the 57 C++11/14 features presented in the book.

---

Alisdair Meredith
Alisdair Meredith is a software developer at BloombergLP in New York, and a previous chair of the C++ Standard Committee Library Working Group. He has been an active member of the C++ committee for almost two decades, and by a lucky co-incidence his first meeting was the kick-off meeting for the project that would become C++11, and also fixed the contents of the original library TR. He is currently working on the BDE project, BloombergLP's open source libraries that offer a foundation for C++ development, including a standard library implementation supporting the polymorphic allocator model that was ultimately adopted by C++17.

Nina Ranns
Nina Ranns has been a member of the C++ standard committee since 2013, focusing mostly on the core part of the language, and committee secretary since 2018. Throughout her career she has worked for Siemens, Motorola, Datasift, and Symantec on everything from parts of the UMTS network to cloud based antivirus products. Currently an independent consultant with contracts for EDG, QT, and most recently Bloomberg, where she is eagerly extending her library knowledge and helping create new polymorphic-allocator friendly library types.

---

Videos Streamed & Edited by Digital Medium: http://online.digital-medium.co.uk

The CppCon YouTube Channel Is Sponsored By:
JetBrains : http://jb.gg/cpptools
SonarSource: https://www.sonarsource.com/

Filed under: Science & Technology

A (Short) Tour of C++ Modules – Daniela Engert – CppCon 2021

  • Lobby
  • Science & Technology

https://cppcon.org/
https://github.com/CppCon/CppCon2020
---
Modules are probably the most impactful and most transformative recent major addition to the C++ language. From a user perspective, Modules are conceptually simple and the idea is easy to grasp. And with the C++20 ecosystem maturing, using Modules and adopting them into every-day programming is both feasable and advantageous.

But what is the motivation that lead to the invention of Modules and their inclusion into the standard? How do they look like? Which are the three key features of C++ Modules that exist since the inception of the language, that are mostly irrelevant in the typical usage of 'classical' C++ such that hardly any programmer needs to know much about them but a Modules developer does? What surprises might lie on the path of transforming a classical library into a Module? Are there still any issues, loose ends or open questions regarding Modules?

The talk will try to give a comprehensive answer to those questions. The audience shall get enough information to decide when the right time has come for them to take the plunge and move their codebase to Modules wherever it is advantageous.

---
Daniela Engert

Daniela has a degree in electrical engineering and has been working for more than 30 years in small innovative companies in the field of software and hardware development. She has spent her youth with exploring the very first microprocessors since the late 70's, and has been creating software professionally for 40 years now. After a long time using many different programming languages, C++ has now been the exclusive workhorse throughout the last two decades. With great pleasure Daniela is now also a member of the ISO C++ committee. For the better part of her career, the domain was applied digital signal processing (medicine, metrology, reconnaissance), but during the last decade the focus shifted onto special engineering in the field of industrial non-destructive testing of semi-finished and finished steel products using ultrasound. Besides that, she loves to relax with hard metal and soft cheese, hot curries and cool jazz.

---
Videos Streamed & Edited by Digital Medium: http://online.digital-medium.co.uk

The CppCon YouTube Channel Is Sponsored By:
JetBrains : http://jb.gg/cpptools
SonarSource: https://www.sonarsource.com/

Filed under: Science & Technology