advanced

Do You Prefer Fast or Precise?--Jim Hogg

A nice article explaining the troubles of float numbers, and what effects it can have. It is talking in the case of Visual C++, but the problems are the same for other compilers.

Do You Prefer Fast or Precise?

by Jim Hogg

From the article:

Floating Point Basics

In C++, a float can store a value in the 3 (approximate) disjoint ranges { [-E+38, -E-38], 0, [E-38, E+38] }. Each float consumes 32 bits of memory. In this limited space, a float can only store approximately 4 billion different values. It does this in a cunning way, where adjacent values for small numbers lie close together; while adjacent values for big numbers lie far apart. You can count on each float value being accurate to about 7 decimal digits.

Floating Point Calculations

We all understand how a computer calculates with ints. But what about floats? One obvious effect is that if I add a big number and a small number, the small one may simply get lost. For example, E+20 + E-20 results in E+20 – there are not enough bits of precision within a float to represent the precise/exact/correct value...

AllocatorAwareContainer: Introduction and pitfalls...--Jonathan Müller

An interesting article about some dangerous allocators:

AllocatorAwareContainer: Introduction and pitfalls of propagate_on_container_XXX defaults

by Jonathan Müller

From the article:

While I was writing the std_allocator adapter of foonathan/memory I've learned some not so well-known facts about the STL Allocator and AllocatorAwareContainer concepts I'd like to share. Let's take a deep breath and dive in into an aspect of the STL containers that isn't that well covered: Allocator storage.

I will explain the comparison properties of Allocators, show the C++11 propagate_on_container_XXX traits and how the combination of the two can lead to an unnecessary pessimization and a probably not widely known case of undefined behavior...

Video available: Chandler Carruth, "Tuning C++: Benchmarks, and CPUs, and Compilers!" -- CppCon

Chandler's talk about benchmarking, cheating the compiler's optimizer and optimizing code from the recent CppCon is online.

Tuning C++: Benchmarks, and CPUs, and Compilers! Oh My! (YouTube)

by Chandler Carruth, CppCon 2015

From the talk's outline:

A primary use case for C++ is low latency, low overhead, high performance code. But C++ does not give you these things for free, it gives you the tools to control these things and achieve them where needed. How do you realize this potential of the language? How do you tune your C++ code and achieve the necessary performance metrics?

This talk will walk through the process of tuning C++ code from benchmarking to performance analysis. It will focus on small scale performance problems ranging from loop kernels to data structures and algorithms. It will show you how to write benchmarks that effectively measure different aspects of performance even in the face of advanced compiler optimizations and bedeviling modern CPUs. It will also show how to analyze the performance of your benchmark, understand its behavior as well as the CPUs behavior, and use a wide array of tools available to isolate and pinpoint performance problems. The tools and some processor details will be Linux and x86 specific, but the techniques and concepts should be broadly applicable.

CppCon 2014 C++ in Huge AAA Games--Nicolas Fleury

Have you registered for CppCon 2015 in September? Don’t delay – Registration is open now.

While we wait for this year’s event, we’re featuring videos of some of the 100+ talks from CppCon 2014 for you to enjoy. Here is today’s feature:

C++ in Huge AAA Games

by Nicolas Fleury

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

Video games like Assassin's Creed or Rainbow Six are among the biggest code bases with a single static linking. Iteration-time is critical to develop a great game and keeping a complete compilation-time of a few minutes is a constant challenge. This talk will explain the C++ usage reality at Ubisoft Montreal for huge projects. Ideas will be shared regarding performance, debugging and iteration time.

CppCon 2014 Embarcadero Case Study: Bringing CLANG/LLVM To Windows--John "JT" Thomas

Have you registered for CppCon 2015 in September? Don’t delay – Registration is open now.

While we wait for this year’s event, we’re featuring videos of some of the 100+ talks from CppCon 2014 for you to enjoy. Here is today’s feature:

Embarcadero Case Study: Bringing CLANG/LLVM To Windows

by John "JT" Thomas

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

CLANG/LLVM delivers a highly conforming C++ compiler and architecture for targeting multiple CPUs, and, as such, has seen success in iOS and other operating systems. Embarcadero has successfully delivered the first commercial compiler for Windows based on CLANG/LLVM. This session describes the benefits of CLANG/LLVM as well as the challenges in bringing it to the Windows operating system. Particular emphasis is placed on the managing the changes in CLANG as well as the additional features added to enable Windows development.

A third way to use boost::serialization

The 10th installment in my series about writing applications with Qt and boost:

A third way to use boost::serialization

by Jens Weller

From the article:

The 10th part of my series about writing applications with Qt and boost is about using boost::serialization. The last part was about how to create the basic structure for a project with boost::filesystem, and how to use boost::filesystem to index folders. But there is a lot of data that just isn't able to be represented as single files, how to store it?

Originally I planned to use a database, as I already have some code handling the SQL queries nicely for me and most of my other applications currently also use this to store their data. Thats why most of my classes from the first day on had an id field, just to enable them to refer to an instance stored in a database. But then, if I could get around using a database, by simply just storing my data in a file, things would be easier, and my code wouldn't need to be scattered with SQL queries. If I couldn't find a reasonable approach, I still could opt for a database anyways.

Integrating an HTML Editor into Qt using Javascript and QWebView

Part 8 of my series about writing applications in C++ using Qt and boost:

Integrating an HTML Editor into Qt using Javascript and QWebView

by Jens Weller

From the article:

This time its about integrating an HTML Editor into Qt using QWebView and Javascript! I'll start with text editors in general, and then continue to the integration, based on QWebkit and TinyMCE3. The end result is a little bit of hackery, but it is a working solution...

Messaging and signaling in C++

The 7th part of my series on writing applications in C++ using Qt and boost:

Messaging and Signaling in C++

by Jens Weller

From the article:

This time it is about how to notify one part of our application that something has happened somewhere else. I will start with Qt, as it brings with signals and slots a mechanism to do exactly that. But, as I have the goal not to use Qt mainly in the UI Layer, I will also look on how to notify other parts of the application, when things are changing.

QWidgets and data

The sixt part of my series takes a look at QWidgets and how to exchange data:

QWidgets and data

by Jens Weller

From the article:

The sixt part of my series about writing applications in C++ using Qt and boost is about my thoughts on widgets and how to interact with data from them.

The Dos and Don'ts of Multithreading -- Hubert Matthews

Hubert Matthews talked at the this year's ACCU conference in Bristol with lot's of examples and detailed insight about:

The Dos and Don'ts of Multithreading

by Hubert Matthews

From the conference's schedule:

Multithreading is a popular subject and we've all been led to believe that we need to write threaded programs as single-threaded performance hits a ceiling. However, multithreading is no panacea and may cause more problems than it solves. This talk, suitable for programmers of any level and language, seeks to describe some of these problems and also how to avoid them through appropriate design choices.