【问题标题】:How to optimize a C++ program with intel compiler on AMD chips如何在 AMD 芯片上使用英特尔编译器优化 C++ 程序
【发布时间】:2013-05-02 03:57:06
【问题描述】:

这里是新手。我有一个需要高性能计算运行的大型有限分析代码。人们一直告诉我英特尔编译器通常会提供更好的速度(我以前使用过 gcc)。我发现在我们的英特尔集群上确实如此。但最近我们有了一个新的 AMD 集群。我对如何使用icpc 的编译选项来优化程序感到困惑。

基本上,我有两个问题:

问题 1

这是带有 AMD 芯片的集群:

processor       : 63
vendor_id       : AuthenticAMD
cpu family      : 21
model           : 2
model name      : AMD Opteron(tm) Processor 6378                 
stepping        : 0
cpu MHz         : 2399.837
cache size      : 2048 KB
physical id     : 2
siblings        : 16
core id         : 7
cpu cores       : 8
apicid          : 79
initial apicid  : 79
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nonstop_tsc extd_apicid amd_dcm aperfmperf pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 popcnt aes xsave avx f16c lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs xop skinit wdt lwp fma4 nodeid_msr tbm topoext perfctr_core cpb npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold
bogomips        : 4799.73
TLB size        : 1536 4K pages
clflush size    : 64
cache_alignment : 64
address sizes   : 48 bits physical, 48 bits virtual
power management: ts ttp tm 100mhzsteps hwpstate [9] [10]

当我使用icpc hello.cpp -O3 -xP 编译一个小代码时,我不知道应该使用哪些选项?我发现错误是:

$ /usr/bin/time -p ./a.out
Fatal Error: This program was not built to run on the processor in your system.
The allowed processors are: Intel(R) Pentium(R) 4 and compatible Intel processors with Intel(R) Streaming SIMD Extensions 3 (Intel(R) SSE3) instruction support.

real 0.00
user 0.00
sys 0.00

问题 2

如果我希望二进制文件同时用于 Intel 芯片集群和 AMD 芯片集群,我应该使用不同的选项来编译代码吗?

【问题讨论】:

    标签: optimization intel amd-processor icc


    【解决方案1】:

    Intel 编译器并不总是适用于 AMD 芯片,尤其是带有某些标志,如 -xP(现在是 -xSSE3,请参阅 here)。具体来说 -xSSE3/-xP 告诉编译器:May generate Intel® SSE3, SSE2, and SSE instructions for Intel® processors. Optimizes for Intel processors that support Intel® SSE3 instructions. For OS X* systems, this value is only supported on IA-32 architecture. This replaces value P, which is deprecated.

    该文档也有这句话:Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

    您可以尝试使用 icc 和 icpc 进行优化,但我不确定它是否适用于 AMD 芯片。对于 gcc 以外的编译器,您可以查看 clang、PGI 或 Cray 编译器(如果您在 Cray 系统上)。

    如果您尝试为两种架构创建二进制文件,由于缓存行大小和其他架构特定设置的差异,我不确定您是否能够进行大量优化。

    【讨论】:

    • 您是在暗示icpc -A -B -C -D ...,这些 A B C D 选项甚至取决于我的“缓存行大小和其他体系结构特定设置”?如果有,能举个例子吗?
    猜你喜欢
    • 1970-01-01
    • 2017-09-10
    • 1970-01-01
    • 2011-02-14
    • 1970-01-01
    • 2021-11-07
    • 1970-01-01
    • 2013-04-29
    • 2012-08-08
    相关资源
    最近更新 更多