intermediate

CppCon 2014 ...Scaling Visualization in concurrent C++ programs--Fedor G Pikus

While we wait for CppCon 2015 in September, we’re featuring videos of some of the 100+ talks from CppCon 2014. Here is today’s feature:

...Scaling Visualization in concurrent C++ programs

by Fedor G Pikus

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

High performance is one of the main reasons programmers choose C++ for their applications. If you are writing in C++, odds are you need every bit of computing power your hardware can provide. Today, this means writing multi-threaded programs to effectively utilize the multiple CPU cores that the hardware manufacturers keep adding. Everyone knows that writing multi-threaded programs is hard. Writing correct multi-threaded programs is even harder. Only after spending countless hours debugging race conditions and weird intermittent bugs do many programmers learn that writing efficient multi-threaded programs is harder yet. Have you ever wanted to see what are all your threads doing when they should be busy computing? This talk will show you how.

We begin by studying several techniques necessary for collecting large amounts of data from the running program very efficiently, with little overhead and minimal disruption to the program itself. We will cover efficient thread-safe memory management and efficient thread-safe disk I/O. Along the way we dabble in lock-free programming just enough to meet our needs, lest the subject will spiral into an hour-long talk of its own. With all these techniques put together, we can collect information about what each thread is doing, which threads are computing and what exactly, and which threads are slacking off waiting on locks, and do it at the time scale of tens of microseconds if necessary. Then we process the collected data and create a timeline that shows exactly what the program was doing at every moment in time.

CppCon 2014 Meta Techniques: Heterogeneous Polymorphism&Fast Prototyping at Facebook--Marcelo Juchem

While we wait for CppCon 2015 in September, we’re featuring videos of some of the 100+ talks from CppCon 2014. Here is today’s feature:

Meta Techniques: Heterogeneous Polymorphism & Fast Prototyping at Facebook

by Marcelo Juchem

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

As data driven systems evolve there's an ever growing demand for bringing new functionality into existing systems in an efficient, maintainable and least intrusive manner. When implementing features with different semantics or interfaces, virtual inheritance requires a compromise between design simplicity and performance. This implies a need for new techniques to achieve heterogeneous polymorphism efficiently. With C++11 and 14, type lists, type maps and variants can now be trivially implemented by the initiated. Facebook moves fast so we quickly adopted the new standards to further explore the capabilities of the type system. This talk demonstrates some meta-programming techniques like reflection and compile-time built structures to achieve heterogeneous polymorphism and fast prototyping.

Vector Hosted Lists--Thomas Young

Want perfomance and speed? Vectors are the solution:

Vector Hosted Lists

by Thomas Young

From the article:

Vectors are great when adding or removing elements at the end of a sequence, but not so hot when deleting elements at arbitrary positions.

If that's a requirement, you might find yourself reaching for a pointer-based list.

Not so fast!

Memory locality is important, contiguous buffers are a really good thing, and a standard vector will often out-perform pointer-based lists even where you perform non-contiguous, list-style modifications such as arbitrary element deletion.

And we can 'host' a list within a vector to get the advantages of a contiguous buffer at the same time as 0(1) complexity for these kinds of manipulations...

CppCon 2014 Overview of Parallel Programming in C++--Pablo Halpern

While we wait for CppCon 2015 in September, we’re featuring videos of some of the 100+ talks from CppCon 2014. Here is today’s feature:

Overview of Parallel Programming in C++

 

by Pablo Halpern

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

Parallel programming was once considered to be the exclusive realm of weather forecasters and particle physicists working on multi-million dollar super computers while the rest us relied on chip manufacturers to crank out faster CPUs every year. That era has come to an end. Clock speedups have been largely replaced by having more CPUs on a chip. Your typical smart phone now has 2 to 4 cores and your typical laptop or tablet has 4 to 8 cores. Servers have dozens of cores and supercomputers have thousands of cores.

If you want to speed up a computation on modern hardware, you need to take advantage of the multiple cores available. This talk is provides an overview of the parallelism landscape. We'll explore the what, why, and how of parallel programming, discuss the distinction between parallelism and concurrency and how they overlap, and learn about the problems that one runs into. We'll conclude with an overview of existing parallelism technologies in C++ and the future directions being considered for parallel programming in standard C++.

CppCon 2014 C++11 in the Wild: Techniques from a Real Codebase--Arthur O'Dwyer

While we wait for CppCon 2015 in September, we’re featuring videos of some of the 100+ talks from CppCon 2014. Here is today’s feature:

C++11 in the Wild: Techniques from a Real Codebase

by Arthur O'Dwyer

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

This talk presents several reusable constructs from a production C++11 codebase, each of which would not be possible without C++11's new features. Auto() is what Alexandrescu's ScopeGuard looks like after a dozen years of C++ evolution. make_iterable() constructs a container from a pair of iterators, enabling simple "foreach" iteration over legacy containers. spaceship() is an efficient "strcmp" for tuples. Time permitting, we'll look at some more arcane code samples.

Video Tutorial: Handle-based entity management -- Vittorio Romeo

Almost every C++ application and game deals with entity management.

Video Tutorial -- Handle-based entity management

By Vittorio Romeo

From the tutorial:

Entities are usually self-contained objects that...

  • ...store data and/or logic.
  • ...are tied a specific concept (e.g. an UI widget, or a 3D model).
  • ...we need to keep track of.
  • ...can either be alive or dead.
  • ...are extremely often used in groups.

Problem: we need to keep track of specific entity instances, and iterate on every instance. We also need to remove dead entities and add new entities.

Keeping track of specific instances is easily solved with pointers and smart pointers.
Fast-iteration of a group of objects with the same type is achieved with cache-friendly memory locality and no indirection.
Adding and removing entities stored in a cache-friendly manner invalidates existing pointers.

How can we facilitate instance tracking/addition/removal and still allow fast iteration?

In this video, we will create a generic container that stores objects in a cache-friendly way, allows to keep track of specific object instances and also allows addition and removal of entities. 
 

 

Common Algorithm Patterns -- Scott Prager

An interesting article concerning ranges, and how to make the ever useful algorithm header even more effective:

Common algorithm patterns

by Scott Prager

From the article:

Of the STL, <algorithm> may be the most well-used non-container library, but often requires a level of verbosity that requires just as much typing as the hand-written loop, making it not always feel so convenient. It benefits code that uses it with increased clarity and mathematical soundness, so reducing the syntactic overhead should be a goal of those using it. Today I will talk about these problems and demonstrate ways of making it more terse and sound.

CppCon 2014 Elevate Your Code to Modern C++11 with Automated Tooling--Peter Sommerlad

While we wait for CppCon 2015 in September, we’re featuring videos of some of the 100+ talks from CppCon 2014. Here is today’s feature:

Elevate Your Code to Modern C++11 with Automated Tooling

by Peter Sommerlad

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

This talk will motivate and demonstrate how to transform your existing C++ code into more modern style and better quality. A key to that is refactoring the code into better shape. While manual refactoring can be tedious and error prone the author demonstrates automated refactoring that was created by his students and assistants and himself over the last nine years on the basis of Eclipse CDT. The tooling works with all compilers, because it is independent of one.

For example, we will show how to eliminate unnecessary macros or replace them by type-safe C++11/14 alternative code automatically. Or, to replace pointers, plain arrays and manual memory management by references, smart pointers, std::string, std::array, or std::vector automatically. Also other transformations, such as introducing a template parameter to reduce a coupling to a single concrete type are demonstrated. All with the goal to modernize and hopefully simplify your C++ code. Even if you are not deeply interested in modernizing your code base, some helpful tooling, such as toggling function definitions into a single place, to change their signature, can be of great help. On the other hand, many of the proposed improvements can also be applied with your favorite code editor only more tediously.