#include #define INSN_LOOP_LO(insn, reg) do { \ asm volatile( \ "mov $1<<24,%%rcx;" \ ".align 32;" \ "1:" \ #insn " " "%%" #reg "0" "," "%%" #reg "0" "," "%%" #reg "0" ";" \ #insn " " "%%" #reg "1" "," "%%" #reg "1" "," "%%" #reg "1" ";" \ #insn " " "%%" #reg "2" "," "%%" #reg "2" "," "%%" #reg "2" ";" \ #insn " " "%%" #reg "3" "," "%%" #reg "3" "," "%%" #reg "3" ";" \ "dec %%rcx;" \ "jnz 1b;" \ ::: "rcx" \ ); \ } while(0); #define INSN_LOOP_HI(insn, reg) do { \ asm volatile( \ "mov $1<<24,%%rcx;" \ ".align 32;" \ "1:" \ #insn " " "%%" #reg "31" "," "%%" #reg "31" "," "%%" #reg "31" ";" \ #insn " " "%%" #reg "30" "," "%%" #reg "30" "," "%%" #reg "30" ";" \ #insn " " "%%" #reg "29" "," "%%" #reg "29" "," "%%" #reg "29" ";" \ #insn " " "%%" #reg "28" "," "%%" #reg "28" "," "%%" #reg "28" ";" \ "dec %%rcx;" \ "jnz 1b;" \ ::: "rcx" \ ); \ } while(0); int main(int argc, char ** argv) { int x = strtoul(argv[1], 0, 10); asm volatile("vzeroall"); switch(x) { case 0: INSN_LOOP_LO(vpmuludq, zmm); break; case 1: INSN_LOOP_HI(vpmuludq, zmm); break; case 2: INSN_LOOP_LO(vpmuludq, ymm); break; case 3: INSN_LOOP_HI(vpmuludq, ymm); break; case 4: INSN_LOOP_LO(vpmuludq, xmm); break; case 5: INSN_LOOP_HI(vpmuludq, xmm); break; case 6: INSN_LOOP_LO(vpaddq, zmm); break; case 7: INSN_LOOP_HI(vpaddq, zmm); break; case 8: INSN_LOOP_LO(vpaddq, ymm); break; case 9: INSN_LOOP_HI(vpaddq, ymm); break; case 10: INSN_LOOP_LO(vpaddq, xmm); break; case 11: INSN_LOOP_HI(vpaddq, xmm); break; } return 0; }