[CMake] Choosing SSE / AVX Flag Advice

Stephen McDowell sjm324 at cornell.edu
Wed Mar 21 15:34:37 EDT 2018


Hello,

I was originally using -march=native for non-windows, but in my attempts to support embedded architectures learned that this flag is broken and/or does nothing for many compilers (fixed for ARM in gcc 8 I think though).  Enter the glorious work of the folks at Vc: https://github.com/VcDevel/Vc/blob/master/cmake/OptimizeForArchitecture.cmake <https://github.com/VcDevel/Vc/blob/master/cmake/OptimizeForArchitecture.cmake>

It’s quite comprehensive, and though it may not be ready for cross-compiling (still testing that, but I have to learn how to cross compile first!), it does appear to support native optimizations for embedded architectures.  Here is my concern, the following flags are generated:

-march=haswell;-msse2;-msse3;-mssse3;-msse4.1;-msse4.2;-mavx;-mfma;-mbmi2;-mavx2;-mno-sse4a;-mno-xop;-mno-fma4;-mno-avx512f;-mno-avx512vl;-mno-avx512pf;-mno-avx512er;-mno-avx512cd;-mno-avx512dq;-mno-avx512bw

I am concerned only because these flags will be a part of the PUBLIC compile features of a library, Eigen is the main math library backend as well as there are some templated image conversion routines that use SSE2 intrinsics to operate in my library.  Having that many additional flags could ultimately lead to undesirable consequences such as command line arguments being too long?

I’m currently reworking it so that just the highest version (e.g. -mavx2) is used, but I’m not sure if I should even be worried about this.

Thanks for any thoughts!

-Stephen

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180321/16e7ebc7/attachment.html>


More information about the CMake mailing list