GCC optimization flags for matrix / vector operations

I perform matrix operations using C. I would like to know which different compiler optimization flags improve the speed of these matrix operations for double and int64 data - for example, Multiplication, Inverse, etc. I'm not looking for manually optimized ones, I just want to make my own code faster using compiler flags and learn more about these flags.

Flags that I have found so far that improve matrix code.

-O3/O4
-funroll-loops
-ffast-math
+3
source share
1 answer

First of all, I do not recommend using it -ffast-mathfor the following reasons:

  • , , ( ) . , " " .

  • IEEE , .

  • , . "" ( ) : , OS, . , , .

  • - , , , (IEEE-) , , .

  • , .

-Ofast ( -ffast-math). :

-Ofast

. -Ofast -O3. , . -ffast-math Fortran-specific -fno-protect-parens -fstack-arrays.

, -O4. , , GCC . , - -O3, , , .

-funroll-loops - , / , ( ).

2 : -march=native -mfpmath=sse. -O3, -march=native , . -mfpmath=sse XMM ( x87).

, , , , , / . SIMD, SSE Intrinsics Vectorization, , . / ( ) .

, , . GCC , -ftree-vectorize, , -O3 ( -ftree-vectorize ). , GCC , -. ( ), . . .

, Eigen, ++, . , . -, . - , , , , , , .. Eigen ( SSE, Vectorization ..), .

+14

All Articles