Does anyone have example of code that tends to generate avx or other simd instructions in the resulting compiled assembly file?
I'm on linux, g++, but can switch to clang if it's more likely to produce simd instructions...
I'm certainly curious if there's simple code in which these instructions tend to occur (A kind of hello world SIMD).
Is it as simple as adding two vectors, or is there more to it than that?
Would they have to be vectors of doubles, or could it also handle floats and ints?
Should I be careful about how many elements are in the vector/array, or is it more arbitrary than that?
Also, do they need to be enabled by the command line at compile time? <- I'm seeing -mtune=native as an option if I can guarantee that the client computer is not less than my own in capabilities.
You'd have to pick one that supports AVX, so that, at least potentially, the compiler may generate AVX instructions. But the resulting binary will then require AVX support from both, the CPU and the OS.
Probably you want to use -O3 (or at least -O2) too, so that the compiler will extensively optimize your code.
If you want to know if a binary does actually contain AVX instructions, you can do something like this: objdump -d my_program > disassembled.asm