In my blog about sanitizers (runtime safety checking) in C++Builder 12.3, I said:
The new C++ Modern toolchain … is something we’ve talked about as a ‘foundation for the future.’ ‘We can build things we could not before,’ we’ve said. ‘Having it will let us deliver real value to you.’
You can see where this is going.
We’re making good on that.
Last release, it was CMake and incredible compiler performance (which we increased by up to 20% more this release, by the way.)
This release, we have multiple new things we could not deliver before.
Despite 12.3 being mainly a quality-focused release, the new toolchain is letting us deliver new things. One of those is sanitizers. The other: performance, through new CPU instruction sets. This is something I personally am very excited about.
Table of Contents
Instruction Sets
New generations of CPUs often have new capabilities, new assembly language instructions, which let them do new things. Usually this is to do with processing data faster, and a lot of the performance of modern apps, other than just running on more efficient silicon, is being able to vectorise processing.
Vectorisation is a fancy word for handling multiple pieces of data a time. Suppose you are searching through a string for a character: you might do it character by character. Vectorisation would do it by processing four or eight characters at a time. You can see the clear speedup this offers!
(Vectorisation is a kind of parallelisation, but it is not parallelization as in threads; it is any individual thread processing more data at once. It is a kind of parallelisation, but it’s important to keep distinct from multi-threading which is how we often use the term. If you have multiple threads, then each one can benefit!)
Over the years, there have been many instruction sets added. These focus on floating point math, integer math (where strings are long sets of integers), bit manipulation, and more.
However, for a long time we stayed on a single base instruction set, SSE2. This is the foundational instruction set for all Windows 64-bit apps.
There’s been lots of progress since it was introduced. And we want to offer you the chance to speed up your apps on modern hardware. You can — with C++Builder 12.3.
New in 12.3
In C++Builder 12.3, we have added support for six new instruction sets.
They are:
- SSE3
- SSSE3 (not a typo)
- SSE 4.1 and 4.2
- AVX
- AVX2
These are the most common instruction sets used today. AVX2, although introduced a few years ago, only became standard on CPUs within the past couple of years.
To use one, go into the Project Options, Building, C++ Compiler, and then choose an option in ‘Instruction set (COFF only)’ where COFF means the new Modern bcc64x compiler. Choosing any one of them enables it plus older sets as well. It’s important to be careful here since your customers need to have a computer than can support them. Check not the dates they were introduced, but dates they were standard.
Vectorisation
The new Modern clang compiler can indeed automatically vectorise your code. You can assist it (for Clang, the keyword is __restrict__) but even without that when you turn optimisation up, it will endeavour to use the new instruction sets whenever it detects data can be processed with multiple elements at a time. It will use the most appropriate instructions for the kind of data you have. Things like C++ STL algorithms often vectorise very nicely.
Performance!
This is a leap forward by something like a decade and a half of CPU development in just one point release! It’s a great example of what’s possible with the new compiler. And in terms of what’s commonly supported, it brings us to very recent CPUs. From here, it’s only forward, with the new toolchain!
We hope you find this useful, and are able to provide your own customers with speedy, efficient, super-fast applications.
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition