Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I compile *without* various instruction sets enabled?

I am attempting to recompile some software with various instruction sets, specifically, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, and AVX, and I would like to see how the code performs without these instruction sets to make sure I am getting the full effect of them.

For example, I want to compile it with just -O2 with a gnu compiler and see how it performs when restricting it to only SSE, to see which flags it is invoking by default. I also have an intel compiler that I am working with and I would like to isolate what each flag (or combination of flags) is doing to my code, so how can I specify exactly which flags are being invoked?

If it matters, I am working with C, C++, and Fortran on Linux.

like image 528
drjrm3 Avatar asked Jun 08 '15 18:06

drjrm3


1 Answers

For GCC compiler:
You have to use -mno-options for doing it.

These switches enable or disable the use of instructions in the MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, AVX, AVX2, AVX512F, AVX512PF, AVX512ER, AVX512CD, SHA, AES, PCLMUL, FSGSBASE, RDRND, F16C, FMA, SSE4A, FMA4, XOP, LWP, ABM, BMI, BMI2, FXSR, XSAVE, XSAVEOPT, LZCNT, RTM, or 3DNow! extended instruction sets. These extensions are also available as built-in functions: see X86 Built-in Functions, for details of the functions enabled and disabled by these switches.

More info you can find on official GCC site

For ICC compiler, you have to use combination of :

-march=”cpu” optimize for a specific cpu
-mtune=”cpu” produce code only for a specific cpu
-msse3,-msse4,-mavx, etc. level of SIMD and vector instructions

More info here

like image 65
Laser Avatar answered Dec 29 '22 00:12

Laser