我目前正在尝试使用g ++进行自动向量化。 为此,我使用以下最小示例:
#include <array>
int main()
{
std::array<double, 16> x;
for (unsigned int i = 0; i < 16; i++) x[i] = i;
return x[15];
}
我编译:
g++-4.7 -Wall -Wextra -std=c++11 -O3 -ftree-vectorizer-verbose=9 tests.cpp -o tests
结果是:
Analyzing loop at tests.cpp:5
5: ===== analyze_loop_nest =====
5: === vect_analyze_loop_form ===
5: === get_loop_niters ===
5: ==> get_loop_niters:16
5: === vect_analyze_data_refs ===
5: not vectorized: no vectype for stmt: MEM[(value_type &)&x]._M_instance[i_21] = D.21296_5;
scalar_type: value_type
5: bad data references.
tests.cpp:2: note: vectorized 0 loops in function.
问题是什么以及如何解决?
编辑: 结果与:
相同#include <array>
int main()
{
std::array<int, 16> x;
for (int i = 0; i < 16; i++) x[i] = i;
return x[15];
}
答案 0 :(得分:10)
检查编译标志no vectype for stmt
表示您的体系结构不支持这些说明。
设置-march=native
或-march=corei7