该研究使用更贴近实际代码的 TSVC2 套件,评估 GCC、ICX、Clang、ACFL 在 x86 与 ARM 上的自动向量化表现,发现各编译器差异有限且向量化不必然提升性能。
摘要:
大多数现代处理器都包含向量单元,可同时对多组操作数执行相同的算术运算。编译器自动向量化代码的能力,对于有效利用这些单元至关重要。对于任何编写计算密集型、高性能且可移植代码的人来说,理解这一能力都很重要。我们测试了若干编译器在 x86 和 ARM 上对代码进行向量化的能力。我们使用了 TSVC2 测试套件,并对其进行修改,使其更能代表实际代码。在 x86 上,GCC 报告套件中 54% 的循环已被向量化,ICX 报告为 50%,Clang 为 46%。在 ARM 上,GCC 报告 56% 的循环已被向量化,ACFL 报告为 54%,Clang 为 47%。我们发现,向量化代码并不总是优于未向量化代码。在某些情况下,对于两个非常相似且可向量化的循环,编译器会向量化其中一个,却不向量化另一个。我们还报告了编译器仅在两个平台之一上向量化某个循环的情况。基于实验,我们无法明确断定在任一给定平台上,是否有某个编译器在代码向量化方面显著优于其他编译器。
英文摘要:
Most modern processors contain vector units that simultaneously perform the same arithmetic operation over multiple sets of operands. The ability of compilers to automatically vectorize code is critical to effectively using these units. Understanding this capability is important for anyone writing compute-intensive, high-performance, and portable code. We tested the ability of several compilers to vectorize code on x86 and ARM. We used the TSVC2 suite, with modifications that made it more representative of real-world code. On x86, GCC reported 54% of the loops in the suite as having been vectorized, ICX reported 50%, and Clang, 46%. On ARM, GCC reported 56% of the loops as having been vectorized, ACFL reported 54%, and Clang, 47%. We found that the vectorized code did not always outperform the unvectorized code. In some cases, given two very similar vectorizable loops, a compiler would vectorize one but not the other. We also report cases where a compiler vectorized a loop on only one of the two platforms. Based on our experiments, we cannot definitively say if any one compiler is significantly better than the others at vectorizing code on any given platform.
BaCO: A Fast and Portable Bayesian Compiler Optimization Framework
Lund University(隆德大学);Federal University of Minas Gerais(米纳斯吉拉斯联邦大学);University of Münster(明斯特大学);Stanford University(斯坦福大学);University of Illinois UC(伊利诺伊大学厄巴纳-香槟分校);University of Edinburgh(爱丁堡大学)