auto considered awesome -- Jarryd Beck

Today's op-ed from our Australian correspondent:

auto considered awesome

by Jarryd Beck

From the article:

 

My last post about why you might not want to use auto may have left some people thinking that I think you shouldn’t use it. In fact I think you should almost always use it...

 

CppCon Program Highlights, 13 of N: Performance, Performance, and Parallel Performance

The CppCon 2014 conference program has been posted for the upcoming September conference. We've received requests that the program continue to be posted in "bite-sized" posts, a few sessions at a time, to make the 100+ sessions easier to absorb, so here is another set of talks. This series of posts will conclude once the entire conference program has been posted in this way.

 

Many CppCon talks touch on efficiency and performance optimization, with good reason. Here are five specific talks that focus on this topic, from algorithmic efficiency to full-throttle performance on modern parallel hardware, and how support for the latest mainstream architectures is coming quickly to a standard near you. As always, these talks are by Those Who Know and Those Who Do -- several of these speakers are personally leading the work on high performance and parallelism at major C++ compiler companies and in the C++ standards process.

In this post:

  • Efficiency with Algorithms, Performance with Data Structures
  • It's About Time
  • Parallelism in the Standard C++: What to Expect in C++ 17
  • Overview of Parallel Programming in C++
  • Decomposing a Problem for Parallel Execution

 

Efficiency with Algorithms, Performance with Data Structures

Why do you write C++ code? There is a good chance it is in part because of concerns about the performance of your software. Whether they stem from needing to run on every smaller mobile devices, squeezing the last few effects into video game, or because every watt of power in your data center costs too much, C++ programmers throughout the industry have an insatiable desire for writing high performance code.

Unfortunately, even with C++, this can be really challenging. Over the past twenty years processors, memory, software libraries, and even compilers have radically changed what makes C++ code fast. Even measuring the performance of your code can be a daunting task. This talk will dig into how modern processors work, what makes them fast, and how to exploit them effectively with modern C++ code. It will teach you how modern C++ optimizers see your code today, and how that is likely to change in the coming years. It will teach you how to reason better about the performance of your code, and how to write your code so that it performs better. You will even learn some tricks about how to measure the performance of your code.

Speaker: Chandler Carruth, Google and Member of Board of Directors, Standard C++ Foundation. Chandler Carruth leads the Clang team at Google, building better diagnostics, tools, and more. Previously, he worked on several pieces of Google’s distributed build system. He makes guest appearances helping to maintain a few core C++ libraries across Google’s codebase, and is active in the LLVM and Clang open source communities. He received his M.S. and B.S. in Computer Science from Wake Forest University, but disavows all knowledge of the contents of his Master’s thesis. He is regularly found drinking Cherry Coke Zero in the daytime and pontificating over a single malt scotch in the evening.

 

It's About Time

This session will build up your mental model about time at the very small scale.

We'll examine progressively smaller units of time and what modern computers can accomplish in these units of time. We'll put these in perspective with human factors on these scales. For example, we'll consider how fast a computer must respond in order for a human to consider it "instantaneous."

Then we'll build up our mental model of how expensive it is for us to use specific data types, containers, and operations in our code.

We'll close by looking at why and how we should measure, always measure.

Speaker: Jon Kalb. Jon has been programming in C++ for over twenty years. During the last two decades he has written C++ for Apple, Dow Chemical, Intuit, Lotus, Microsoft, Netscape, Sun, Yahoo! and some less well­‐known companies. He taught C++ in the graduate school at Golden Gate University for three years and is a founding moderator of the Boost‐User and Boost‐Interest mailing lists. Jon is active in the Silicon Valley chapter of the ACCU and programs the C++ track at the Silicon Valley Code Camp. Jon blogs at http://slashshlash.info@_JonKalb JonKalb on G+ LinkedIn

 

Parallelism in the Standard C++: What to Expect in C++ 17

It is 2014 and parallel programming has entered the mainstream. No longer is it the domain of the few highly trained experts. The tools available in the C++ today make parallelism accessible - if not yet easy - to average developers.

However, writing efficient cross-platform parallel code in C++ is still hard. The standard constructs available in C++ 11/14 are too basic and too low-level. More advanced tools exist, but most are either vendor-specific or don't work on all platforms.

In this presentation, we'll talk about the joint effort spearheaded by several members of the ISO C++ Committee to bring parallelism into the C++ Standard Template Library. The project known as the "Parallel STL" aims to bring muliticore and SIMD parallelism into the next revision of the ISO C++ Standard.

Speaker: Artur Laksberg, Microsoft. Artur Laksberg leads the Visual C++ Libraries development team at Microsoft. His interests include concurrency, programming language and library design, and modern C++. Artur is one of the co-authors of the Parallel STL proposal; his team is now working on the prototype implementation of the proposal.

 

Overview of Parallel Programming in C++

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++.

 

Decomposing a Problem for Parallel Execution

So you want to speed up your computation using multicore parallel execution and you've picked a parallelism framework. What now? Parallelism frameworks give you the tools you need, but they don't actually parallelize the code; that's your job. To take advantage of parallel hardware, you must decompose your computation into tasks that can be computed in parallel. In this session, I'll present a real-world problem (the n-bodies problem) and guide you through several different ways in which it can be decomposed for parallel execution. We'll look at how to achieve scalability, resolve data races, and avoid negative multi-core cache effects. At the end of this session, you should have a conceptual understanding of parallel programming fundamentals that can be applied to a wide range of problems using a variety of frameworks.

Speaker: Pablo Halpern, Parallel Programming Languages Architect, Intel. Pablo Halpern has been programming in C++ since 1989 and has been a member of the C++ Standards Committee since 2007. He is currently the Parallel Programming Languages Architect at Intel Corp., where he coordinates the efforts of teams working on Cilk Plus, TBB, OpenMP, and other parallelism languages, frameworks, and tools targeted to C++, C, and Fortran users. Pablo came to Intel from Cilk Arts, Inc., which was acquired by Intel in 2009. During his time at Cilk Arts, he co-authored the paper "Reducers and other Cilk++ Hyperobjects", which won best paper at the SPAA 2009 conference. His current work is focused on creating simpler and more powerful parallel programming languages and tools for Intel's customers and promoting adoption of parallel constructs into the C++ and C standards. He lives with his family in southern New Hampshire, USA. When not working on parallel programming, he enjoys studying the viola, skiing, snowboarding, and watching opera. Twitter handle: @PabloGHalpern

A visitor’s guide to C++ allocators -- Thomas Köppe

The standard library allocators are one of the more mysterious parts of namespace std, as well as one of the more flexible parts. In this "under construction" article and GitHub repo, Thomas Köppe undertakes to demystify the feature.

A visitor’s guide to C++ allocators (repo)

by Thomas Köppe

From the README:

This repository contains a collection of documents that describe the allocator concept in the standard library of C++11 and beyond. The main guide covers the following topics.

  • Allocator traits
  • Statefulness
  • Fancy pointers
  • Allocator propagation in breadth (container copy, POC{CA,MA,S}) and depth (scoped_allocator_adaptor)

Start reading with the main guide.

Furthermore, there are several worked-out end-to-end examples:

The code for the end-to-end examples is available separately in the example_code directory.
 

Thoughts on C++14 -- Jens Weller

Jens Weller gives a nice perspective on the C++ landscape in 2014.

Thoughts on C++14

by Jens Weller

From the article:

Yesterday we could read on isocpp.org that C++14 has been approved and will now become a valid ISO Standard. Great news for everyone in the C++ land! ...

But there is something else that makes C++14 for me special...

CppCon Free Friday, Final Plenary Session -- Boris Kolpackov

CppCon is less than three weeks away! Announced today:

Free Friday, Final Plenary Session

by Boris Kolpackov 

From the announcement:

We previously announced that CppCon 2014 evening content (Mon-Thu 8:30pm onward) and early morning breakfast sessions (Tue-Fri 8:00-8:45) do not require registration. In addition, this year, we are making the whole of Friday free as well. If you’re in the Seattle area, you’ll want to swing by and enjoy the Friday end-note plenary session and the final panel with us. And the final plenary session will be:

Herb Sutter: "Back to the Basics! Essentials of Modern C++ Style"

This talk revisits basic questions, such as how to declare and initialize a variable, how to pass a value to a function, how to write a simple loop, and how to use smart pointers, in the light of experience with C++11 and the latest C++14 refinements. This involves examining auto, rvalue references, range-for loops, uniform initialization, lambda expressions, unique_ptr and shared_ptr, and more.

Using Varadic Templates for a Signals and Slots Implementation in C++ -- Paul Cook

Fresh on GameDev.net:

Using Varadic Templates for a Signals and Slots Implementation in C++

By Paul Cook

From the article:

Abstract

Connecting object instances to each other in a type-safe manner is a well-solved problem in C++ and many good implementations of signals and slots systems exist. However, prior to the new varadic templates introduced in C++0x, accomplishing this has traditionally been complex and required some awkward repetition of code and limitations.

Varadic templates allow for this system to be implemented in a far more elegant and concise manner and a signals/slots system is a good example of how the power of varadic templates can be used to simplify generic systems that were previously difficult to express. ...

We have C++14!

C++14 is done!

Following the Issaquah meeting in February, we launched the Draft International Standard (DIS) ballot for the next C++ standard. That ballot closed on Friday.

Today, we received the notification that the ballot was unanimously successful, and therefore we can proceed to publication. We will perform some final editorial tweaks, on the order of fixing a few spelling typos and accidentally dropped words, and then transmit the document to ISO for publication this year as the brand new International Standard ISO/IEC 14882:2014(E) Programming Language C++, a.k.a. C++14.

C++ creator Bjarne Stroustrup writes: "C++14 was delivered on schedule and implementations are already shipping by major suppliers. This is exceptional! It is a boon to people wanting to use C++ as a modern language."

Thanks very much to our tireless C++14 project editor Stefanus DuToit and his helpers, and to all the members of the C++ standards committee, for bringing in this work on time and at high quality with a record low number of issues and corrections in the CD and DIS ballots!

Not only is this the fastest turnaround for a new standard in the history of C++, but as Bjarne noted this is historic in another way: There are already multiple substantially or entirely conforming implementations (modulo bugs) of C++14 available already today or in the near future -- at the same time C++14 is published. That has never happened before for a C++ (or I believe C) standard. For C++98, the delta between publishing the standard and the first fully conforming implementation being available was about 5 years. For C++11, it was two years. For C++14, the two have merged and we have achieved "time on target."

Thanks again, everyone. This was a team effort.