Archive for July, 2010

Threading In Qt 4

In this quick post we’ll take a look at Qt’s elegant and simple QFuture, QtConcurrentRun, and QFutureWatcher interfaces. Using these classes allows us to consume a QThreadPool thread for a specific function.

This is handy for many operations, and while simplistic in that we’re not synchronizing data, still has many uses, from processing large blocks of images to streaming chunks of data.

In this post we’ll check out some sample code for implementing QFuture.

Read More

C++ Performance – Counting Clocks

Performance computing can be an interesting task to undertake, as it lets us get under the hood of a complex abstraction (C++) and talk to the machine directly.

In the next two posts we’ll take a look at the Fibonacci algorithm used in a few other posts and see just how fast we can make it by looking at loop implementation, data type usage, and assembly code optimizations. In this first post we’ll take a look at some basic timing code, what gcc will do for us using the -O2 flag, then in the second post, see what we can do (if anything) to improve upon the generated code.

Read More

C++ 64-bit Inline Assembly Primer – Part 2

In this series we examine the relationship and implementations of C++ and raw assembly code. In this post we create our own add function in gcc extended assembly.

In the previous post we wrote a short C++ program that loaded two numbers. Despite its simplicity in C++, we saw how the assembly version was comprised of several dozen individual instructions in a rather cryptic format. Much of this complexity stems from the fact that in our sample program we called a function to perform our addition. Calling functions means dealing with a stack, base pointers, and the setup and maintenance of that stack. It means dealing with memory offsets, relative positions, and several other factors. The good news is that at this point we can safely ignore these details. In fact, we will do well to ignore them and focus on just the core competencies of function implementation code. In other words, we’ll let gcc create the function shells, calls, and stack management, we’ll focus on the core logic.

Read More