-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
The C++ Programmer's Mindset
By :
Many processors have extensions that provide instructions that operate on several values at once. These are the SIMD extensions. These instructions can dramatically reduce the number of instructions necessary to perform a calculation on large arrays of data, increasing the throughput of the processor (providing the memory can keep up). We’ve already mentioned that the compiler can generate these vector instructions where appropriate and where the necessary features are enabled. This process is called auto-vectorization.
Auto-vectorization does not always produce the desired effect. For instance, the compiler might fail to vectorize loops that involve seemingly complicated logic, even if this logic does resolve to something very simple. There are no hard rules here, but the best results are usually observed in loops that simply use pointers (or very simple iterators) and indexing with integers. If auto-vectorization does not yield the desired instruction sequence, you...