CMake detect CPU model

The Intel compilers have an undocumented -march=native or /arch:native flag parameter. Currently, this undocumented “native” flag parameter enables only Pentium 4 optimizations. Using the CPU generation noted in the “arch” documentation results in many CPU-specific flags being added.

CMake detect CPU

CMake can detect the host CPU arch to use with Intel compilers. For example using -march=icelake-client adds flags as revealed by -watch adds flags including:

-D__SSE3__
-D__SSSE3__
-D__SSE4_1__
-D__SSE4_2__
-D__POPCNT__
-D__PCLMUL__
-D__AES__
-D__AVX__
-D__F16C__
-D__AVX_I__
-D__RDRND__
-D__FMA__
-D__FP_FAST_FMA
-D__FP_FAST_FMAF
-D__BMI__
-D__LZCNT__
-D__AVX2__
-D__AVX512F__
-D__AVX512DQ__
-D__ADX__
-D__RDSEED__
-D__AVX512IFMA__
-D__AVX512CD__
-D__AVX512BW__
-D__AVX512VL__
-D__AVX512VBMI__
-D__AVX512VPOPCNTDQ__
-D__AVX512BITALG__
-D__AVX512VBMI2__
-D__GFNI__
-D__VAES__
-D__VPCLMUL__
-D__AVX512VNNI__
-D__CLWB__
-D__RDPID__
-D__icelake_client
-D__icelake_client__
-D__tune_icelake_client__