After reading “SIMD at Insomniac Games – How we do the shuffle”  I realised I hadn’t done anything with my new Raspberry Pi 2 yet. First thing I decided was to try and figure out whether the NEON unit in it was any good, and so I choose a really simple example, calculating a ton of dot products on 4 element vectors, and wrote a bunch of different implementations to try and solve this.

The results are surprising - right enough I did manage (via using inline asm) to get a NEON version going faster than everything else - but what shocked me is that I couldn’t get clang to output faster vector code than the scalar version. I tried a ton of different methods (pragma unroll, manual unroll, inlining on and off) and yet the scalar implementation was always faster.

It seems that at least part of the slowdown is that all the vector versions use the vldn load instructions, whereas the scalar ones (and my fastest hand written version) use vldmia to do the calculation.

My best attempt was;

I do wonder if I could hide more of the cost of the loads/stores by double buffering the workload - only other thing I can think to try!

If you want to check out the rest of the code yourself, or run the examples here is the test file.

test.c