【发布时间】:2019-07-03 12:44:50
【问题描述】:
我目前正在从源代码构建一个对我来说性能至关重要的软件。因此,我想优化它以在我的特定 Intel CPU 上运行。构建过程需要我设置 -march 和 -mtune 标志。
如果在我的处理器节点上我使用
gcc -march=native -Q --help=target|grep march
gcc -mtune=native -Q --help=target|grep mtune
我得到了 March 的“core-avx2”和 mtune 的“generic”。然而与
cat /proc/cpuinfo
我明白了:
processor : 23
vendor_id : GenuineIntel
cpu family : 6
model : 63
model name : Intel(R) Xeon(R) CPU E5-2670 v3 @ 2.30GHz
stepping : 2
microcode : 0x3d
cpu MHz : 2599.993
cache size : 30720 KB
physical id : 1
siblings : 12
core id : 13
cpu cores : 12
apicid : 58
initial apicid : 58
fpu : yes
fpu_exception : yes
cpuid level : 15
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt xsave avx f16c rdrand lahf_lm abm epb intel_ppin ssbd ibrs ibpb tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm xsaveopt cqm_llc cqm_occup_llc dtherm ida arat pln pts
bogomips : 4599.35
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
通过访问 Intel(R) Xeon(R) CPU E5-2670 v3 @ 2.30GHz (https://ark.intel.com/content/www/de/de/ark/products/81709/intel-xeon-processor-e5-2670-v3-30m-cache-2-30-ghz.html) 的主页,我发现: 代号 -> 以前的产品 haswell
如果我使用
gcc -march=haswell -Q --help=target|grep march
gcc -mtune=haswell -Q --help=target|grep mtune
我对两者都有“haswell”。 那么我真的不应该使用 haswell 作为 March 而不是 core-avx2 吗?最好的选择是什么?
顺便说一句,我在 CentOS7 上使用 GCC 4.8.5。
谢谢!
编辑:
gcc -march=native -Q --help=target | grep -- '-march=' | cut -f3
-> 核心-avx2
gcc -mtune=native -Q --help=target | grep -- '-mtune=' | cut -f3
-> 通用
【问题讨论】:
-
在 x86 处理器上,只需使用
-march=native。 GCC 将通过将arch和tune设置为相同的值来处理其余部分。 ARM 比较棘手,因为 GCC 在使用-march=native时有时会出现段错误。您还应该使用现代 GCC 或 Clang。 Clang 使用一些 SIMD 源代码创建了比 GCC 更好的代码。您需要进行基准测试以确定哪个对您的代码表现最好。 -
您好,感谢您的回复!不幸的是,我必须使用 Docker 容器在我的本地机器上构建软件(由于缺少集群上稍后执行代码的权限),因此原生对我来说不是选择,因为它会针对我的本地机器进行优化。另外我必须坚持使用 GCC 4.8.5,因为很多人都在从事这个项目,他们曾经尝试升级 gcc,这导致项目中出现大量不兼容问题。
-
那么听起来这句话是不正确的:“...我想优化它以在我的特定 Intel CPU 上运行”。您可能应该更新您的问题。
-
是的,我很抱歉,我的意思是我要在其上部署我的软件的 CPU。上面列出的规格是我要优化的目标平台的规格。
标签: performance gcc x86 intel compiler-optimization