简体   繁体   English

至强的 gcc 优化标志?

[英]gcc optimization flags for Xeon?

I'd want your input which gcc compiler flags to use when optimizing for Xeons?我希望您的输入在针对至强进行优化时使用哪些 gcc 编译器标志?

There's no 'xeon' in mtune or march so which is the closest match? mtune 或 March 中没有“至强”,那么哪个是最接近的匹配?

An update for recent GCC / Xeon.最近 GCC / Xeon 的更新。

  • Sandy-Bridge-based Xeon (E3-12xx series, E5-14xx/24xx series, E5-16xx/26xx/46xx series).基于 Sandy-Bridge 的Xeon (E3-12xx 系列、E5-14xx/24xx 系列、E5-16xx/26xx/46xx 系列)。

    -march=corei7-avx for GCC < 4.9.0 or -march=sandybridge for GCC >= 4.9.0. -march=corei7-avx对于 GCC < 4.9.0 或-march=sandybridge对于 GCC >= 4.9.0。

    This enables the Advanced Vector Extensions support as well as the AES and PCLMUL instruction sets for Sandy Bridge.这将启用高级矢量扩展支持以及 Sandy Bridge 的 AES 和PCLMUL指令集。 Here's the overview from the GCC i386/x86_64 options page:以下是 GCC i386/x86_64 选项页面的概述:

    Intel Core i7 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AES and PCLMUL instruction set support.具有 64 位扩展的 Intel Core i7 CPU,支持 MMX、SSE、SSE2、SSE3、SSSE3、SSE4.1、SSE4.2、AVX、AES 和 PCLMUL 指令集。

  • Ivy-Bridge-based Xeon (E3-12xx v2-series, E5-14xx v2/24xx v2-series, E5-16xx v2/26xx v2/46xx v2-series, E7-28xx v2/48xx v2/88xx v2-series). 基于 Ivy-Bridge 的Xeon (E3-12xx v2 系列、E5-14xx v2/24xx v2 系列、E5-16xx v2/26xx v2/46xx v2 系列、E7-28xx v2/48xx v2/88xx v2 系列) .

    -march=core-avx-i for GCC < 4.9.0 or -march=ivybridge for GCC >= 4.9.0. -march=core-avx-i对于 GCC < 4.9.0 或-march=ivybridge对于 GCC >= 4.9.0。

    This includes the Sandy Bridge (corei7-avx) options while also tacking in support for the new Ivy instruction sets: FSGSBASE, RDRND and F16C .这包括 Sandy Bridge (corei7-avx) 选项,同时还支持新的 Ivy 指令集:FSGSBASE、 RDRNDF16C From GCC options page:从 GCC 选项页面:

    Intel Core CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AES, PCLMUL, FSGSBASE, RDRND and F16C6 instruction set support.具有 64 位扩展的 Intel Core CPU,支持 MMX、SSE、SSE2、SSE3、SSSE3、SSE4.1、SSE4.2、AVX、AES、PCLMUL、FSGSBASE、RDRND 和 F16C6 指令集。

  • Haswell-based Xeon (E3-1xxx v3-series, E5-1xxx v3-series, E5-2xxx v3-series). 基于 Haswell 的Xeon (E3-1xxx v3 系列、E5-1xxx v3 系列、E5-2xxx v3 系列)。

    -march=core-avx2 for GCC 4.8.2/4.8.3 or -march=haswell for GCC >= 4.9.0. -march=core-avx2对于 GCC 4.8.2/4.8.3 或-march=haswell对于 GCC >= 4.9.0。

    From GCC options page:从 GCC 选项页面:

    Intel Haswell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, AVX, AVX2, AES, PCLMUL, FSGSBASE, RDRND, FMA, BMI, BMI2 and F16C instruction set support.具有 64 位扩展的 Intel Haswell CPU、MOVBE、MMX、SSE、SSE2、SSE3、SSSE3、SSE4.1、SSE4.2、POPCNT、AVX、AVX2、AES、PCLMUL、FSGSBASE、RDRND、FMA、BMI、BMI2 和 F16C指令集支持。

  • Broadwell-based Xeon (E3-12xx v4 series, E5-16xx v4 series) 基于 Broadwell 的Xeon (E3-12xx v4 系列、E5-16xx v4 系列)

    -march=core-avx2 for GCC 4.8.x or -march=broadwell for GCC >= 4.9.0. -march=core-avx2对于 GCC 4.8.x 或-march=broadwell对于 GCC >= 4.9.0。

    From GCC options page:从 GCC 选项页面:

    Intel Broadwell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, AVX, AVX2, AES, PCLMUL, FSGSBASE, RDRND, FMA, BMI, BMI2, F16C, RDSEED, ADCX and PREFETCHW instruction set support.具有 64 位扩展的 Intel Broadwell CPU、MOVBE、MMX、SSE、SSE2、SSE3、SSSE3、SSE4.1、SSE4.2、POPCNT、AVX、AVX2、AES、PCLMUL、FSGSBASE、RDRND、FMA、BMI、BMI2、F16C 、RDSEED、ADCX 和 PREFETCHW 指令集支持。

  • Skylake-based Xeon (E3-12xx v5 series) and KabyLake-based Xeon (E3-12xx v6 series): 基于 Skylake 的Xeon (E3-12xx v5 系列)和基于 KabyLake 的Xeon (E3-12xx v6 系列):

    -march=core-avx2 for GCC 4.8.x or -march=skylake for GCC 4.9.x or -march=skylake-avx512 for GCC >= 5.x -march=core-avx2用于 GCC 4.8.x 或-march=skylake用于 GCC 4.9.x 或-march=skylake-avx512用于 GCC >= 5.x

    AVX-512 are 512-bit extensions to the 256-bit Advanced Vector Extensions SIMD instructions. AVX-512是 256 位高级矢量扩展 SIMD 指令的 512 位扩展。

    From GCC options page:从 GCC 选项页面:

    Intel Skylake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, PKU, AVX, AVX2, AES, PCLMUL, FSGSBASE, RDRND, FMA, BMI, BMI2, F16C, RDSEED, ADCX, PREFETCHW, CLFLUSHOPT, XSAVEC, XSAVES, AVX512F, AVX512VL, AVX512BW, AVX512DQ and AVX512CD instruction set support.具有 64 位扩展的 Intel Skylake 服务器 CPU、MOVBE、MMX、SSE、SSE2、SSE3、SSSE3、SSE4.1、SSE4.2、POPCNT、PKU、AVX、AVX2、AES、PCLMUL、FSGSBASE、RDRND、FMA、BMI、 BMI2、F16C、RDSEED、ADCX、PREFETCHW、CLFLUSHOPT、XSAVEC、XSAVES、AVX512F、AVX512VL、AVX512BW、AVX512DQ 和 AVX512CD 指令集支持。

  • Coffee Lake-based Xeon (E-21xx): -march=skylake-avx512 . 基于 Coffee Lake 的Xeon (E-21xx): -march=skylake-avx512

  • Cascade Lake-based Xeon (Platinum 8200/9200 series, Gold 5200/6200 series, Silver 4100/4200 series, Bronze 3100/3200 series): -march=cascade-lake (requires gcc 9.x ). 基于 Cascade Lake 的Xeon (Platinum 8200/9200 系列、Gold 5200/6200 系列、Silver 4100/4200 系列、Bronze 3100/3200 系列):-march -march=cascade-lake (需要gcc 9.x )。

    From GCC options page:从 GCC 选项页面:

    enables MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, PKU, AVX, AVX2, AES, PCLMUL, FSGSBASE, RDRND, FMA, BMI, BMI2, F16C, RDSEED, ADCX, PREFETCHW, CLFLUSHOPT, XSAVEC, XSAVES, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ, AVX512CD and AVX512VNNI.启用 MOVBE、MMX、SSE、SSE2、SSE3、SSSE3、SSE4.1、SSE4.2、POPCNT、PKU、AVX、AVX2、AES、PCLMUL、FSGSBASE、RDRND、FMA、BMI、BMI2、F16C、RDSEED、ADCX、PREFETCHW 、CLFLUSHOPT、XSAVEC、XSAVES、AVX512F、CLWB、AVX512VL、AVX512BW、AVX512DQ、AVX512CD 和 AVX512VNNI。

    AVX-512 Vector Neural Network Instructions (AVX512 VNNI) is an x86 extension, part of the AVX-512, designed to accelerate convolutional neural network-based algorithms. AVX-512 矢量神经网络指令(AVX512 VNNI) 是 x86 扩展,是 AVX-512 的一部分,旨在加速基于卷积神经网络的算法。

  • Cooper Lake-based Xeon (Platinum, Gold, Silver, Bronze): -march=cooperlake (requires gcc 10.1 ). 基于 Cooper Lake 的Xeon (白金、金、银、铜):- -march=cooperlake (需要gcc 10.1 )。

    The switch enables the AVX512BF16 ISA extensions.该开关启用 AVX512BF16 ISA 扩展。


To find out what the compiler will do with the -march=native option you can use:要了解编译器将如何使用-march=native选项,您可以使用:

gcc -march=native -Q --help=target

较新版本的 gcc 具有-march=native可让编译器自动确定最佳的-march标志。

Xeon is a marketing term, as such it covers a long list of processors with very different internals. Xeon 是一个营销术语,因此它涵盖了一长串内部结构截然不同的处理器。

If you meant the newer Nehalem processors (Core i7) then this slide indicates that as of 4.3.1 gcc should be use -march=generic (though your own testing of your own app may find other settings that outperform this).如果您指的是较新的 Nehalem 处理器(Core i7),那么这张幻灯片表明从 4.3.1 gcc 开始应该使用 -march=generic(尽管您自己的应用程序测试可能会发现其他设置优于此)。 The 4.3 series also added -msse4.2 if you wish to optimize that aspect of FP maths.如果您希望优化 FP 数学的该方面,4.3 系列还添加了 -msse4.2。

Here is some discussion comparing tuning in Intel's compiler versus some gcc flags.这里有一些讨论比较英特尔编译器和一些 gcc 标志的调整。

The following will show you all the flags your processor supports:以下将向您显示处理器支持的所有标志:

cat /proc/cpuinfo | grep flags | head -1

Best way to determine what optimizations exist for your proccesor specifically depends not only on the model, but what version of gcc you have on the system you are compiling.确定您的处理器存在哪些优化的最佳方法不仅取决于模型,还取决于您正在编译的系统上的 gcc 版本。 Make sure to check what version of gcc you have, and cross reference on their documentation:确保检查您拥有的 gcc 版本,并交叉参考他们的文档:

https://gcc.gnu.org/onlinedocs https://gcc.gnu.org/onlinedocs

ie I have Slackware 14.1 x64, which has gcc 4.8.2, so I would go here:即我有 Slackware 14.1 x64,它有 gcc 4.8.2,所以我会去这里:

https://gcc.gnu.org/onlinedocs/gcc-4.8.2/gcc/i386-and-x86-64-Options.html#i386-and-x86-64-Options https://gcc.gnu.org/onlinedocs/gcc-4.8.2/gcc/i386-and-x86-64-Options.html#i386-and-x86-64-Options

march=native is okay for your own machine but bad for binary releases. March=native 适用于您自己的机器,但不适用于二进制版本。

-march=nocona is suggested for atom 330 (p4/64bit) -march=core2 is for core2 -march=nocona 建议用于 atom 330 (p4/64bit) -march=core2 用于 core2

I'm assuming you're going 64bit.我假设你要去 64 位。

My experience with Intel CPUs and x86_64 has been that every time I tried to tell gcc to optimize for a specific CPU type, the performance got worse than with -march=generic, not better.我使用 Intel CPU 和 x86_64 的经验是,每次我试图告诉 gcc 针对特定 CPU 类型进行优化时,性能都会比使用 -march=generic 更差,而不是更好。 YMMV, of course, but I've been playing around with stuff like this lots of times over the years, and it has always been like that. YMMV,当然,但这些年来我一直在玩这样的东西很多次,而且一直都是这样。

OTOH, on i386 it might make sense to target at least i686 or, if you want SSE math, at least Pentium 4. OTOH,在 i386 上,目标至少是 i686 可能是有意义的,或者,如果您想要 SSE 数学,至少是奔腾 4。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM