环境是:
icc版本19.0.0.117(与gcc版本5.4.0兼容)
英特尔并行工作室XE集群版2019
英特尔(R)酷睿TM i7-4790 CPU @ 3.60GHz
Ubuntu 16.04
编译器标志为:
-std = gnu11 -Wall -xHost -xCORE-AVX2 -O2 -fma -qopenmp -qopenmp-simd -qopt-report = 5 -qopt-report-phase = all
我使用OpenMP simd或intel parama对循环进行矢量化以提高速度。在icc生成的优化报告中,我通常会看到以下结果:
LOOP BEGIN at get_forces.c(3668,3)
remark #15389: vectorization support: reference mon->fricforce[n1][d] has unaligned access [ get_forces.c(3669,4) ]
remark #15389: vectorization support: reference mon->vel[n1][d] has unaligned access [ get_forces.c(3669,36) ]
remark #15389: vectorization support: reference vel[n1][d] has unaligned access [ get_forces.c(3669,51) ]
remark #15389: vectorization support: reference mon->drag[n1][d] has unaligned access [ get_forces.c(3671,4) ]
remark #15389: vectorization support: reference mon->vel[n1][d] has unaligned access [ get_forces.c(3671,40) ]
remark #15389: vectorization support: reference vel[n1][d] has unaligned access [ get_forces.c(3671,57) ]
remark #15381: vectorization support: unaligned access used inside loop body
remark #15305: vectorization support: vector length 2
remark #15309: vectorization support: normalized vectorization overhead 0.773
remark #15300: LOOP WAS VECTORIZED
remark #15450: unmasked unaligned unit stride loads: 3
remark #15451: unmasked unaligned unit stride stores: 2
remark #15475: --- begin vector cost summary ---
remark #15476: scalar cost: 21
remark #15477: vector cost: 11.000
remark #15478: estimated potential speedup: 1.050
remark #15488: --- end vector cost summary ---
remark #25456: Number of Array Refs Scalar Replaced In Loop: 1
remark #25015: Estimate of max trip count of loop=1
LOOP END
我的问题是: 我不明白
是如何计算加速比的normalized vectorization overhead 0.773
scalar cost: 21
vector cost: 11.000
另一个更极端,更令人困惑的情况可能是
LOOP BEGIN at get_forces.c(2690,8)
<Distributed chunk3>
remark #15388: vectorization support: reference q12[j] has aligned access [ get_forces.c(2694,19) ]
remark #15388: vectorization support: reference q12[j] has aligned access [ get_forces.c(2694,26) ]
remark #15335: loop was not vectorized: vectorization possible but seems inefficient. Use vector always directive or -vec-threshold0 to override
remark #15305: vectorization support: vector length 2
remark #15309: vectorization support: normalized vectorization overhead 1.857
remark #15448: unmasked aligned unit stride loads: 1
remark #15475: --- begin vector cost summary ---
remark #15476: scalar cost: 7
remark #15477: vector cost: 3.500
remark #15478: estimated potential speedup: 0.770
remark #15488: --- end vector cost summary ---
remark #25436: completely unrolled by 3
LOOP END
现在,3.5 + 1.857 = 5.357 <7
因此,我仍然可以模拟该循环并获得加速,还是应该在报告中采用加速比0.770而不是模拟?
如何从icc编译器了解优化报告中的提速?
答案 0 :(得分:2)
“标量成本”是指“标量循环一次迭代的成本”。
“向量成本”是指“向量化循环的一次迭代的成本除以 vector_length * unroll_factor”,即成本大约等于一个标量迭代。
“向量化开销”表示循环之前/之后向量初始化/完成的标准化成本(按向量迭代成本)。
为整个循环执行计算“估计的潜在加速”。它显示了矢量化循环执行的标准化(按标量迭代成本)的潜在收益–包括估计的循环行程计数的剥离,余数和主循环。无法从上面显示的标量和向量成本中明确得出。