addps r0, r1 # (r0 = r0 + r1)
vaddps r0, r1, r2 # (r0 = r1 + r2)
This new encoding is not only used for the new 256 bit instructions, but also for the 128 bit AVX versions of all the old SSE instructions. This means that existing SSE code can improved without requiring a switch to 256 bit registers. Finally, AVX introduces some new data movement instructions, which should help improve code efficiency.
I decided to see what kind of performance difference using AVX could make in qcms with minimal effort. If you use SSE compiler intrinsics, like qcms does, switching to AVX is very easy; simply recompile with -mavx. In addition to using -mavx, I also took advantage of some of the new data movement instructions by replacing the following:
vec_r = _mm_load_ss(r);
vec_r = _mm_shuffle_ps(vec_r, vec_r, 0);
with the the new vbroadcastss instruction:
vec_r = _mm_broadcast(r);
Overall, this change reduces the inner loop by 3 instructions.
The performance results were positive, but not what I expected. Here's what the timings were:
|AVX (-mavx):||69687 usecs|
|AVX w/ vbroadcastss:||72917 usecs|
vbroadcastssinstruction, in addition to the AVX encoding, not only doesn't help, but actually makes things worse. I tried analyzing the code with the Intel Architecture Code Analyzer, but the analyzer also thought that using
vbroadcastssshould be faster. If anyone has any ideas why
vbroadcastsswould be slower, I'd love to hear them.
Despite this weird performance problem, AVX seems like a good step forward and should provide good opportunities for improving performance beyond what's possible with SSE. For more information, check out this presentation which gives a good overview of how to take advantage AVX.