相关编译选项
-march=cpu-type
用于指定CPU架构,自动使能对应的指令集
例如-march=broadwell
通常我们使用-march=native让编译器自动识别当前编译环境的CPU架构
-mxxx & -mno-xxx
使能开启/关闭特定指令集
例子
根据编译环境自动选定指令集
~: gcc -march=native -Q --help=target
The following options are target specific:
-mavx [enabled]
-mavx2 [enabled]
-mavx256-split-unaligned-load [disabled]
- 指定关闭avx2~: gcc -march=native -mno-avx2 -Q --help=target
The following options are target specific:
-mavx [enabled]
-mavx2 [disabled]
-mavx256-split-unaligned-load [disabled] - 指定开启avx256~: gcc -march=native -mavx256-split-unaligned-load -Q --help=target
The following options are target specific:
-mavx [enabled]
-mavx2 [enabled]
-mavx256-split-unaligned-load [enabled]