UPD:我错过了你提到的编译指示。据我所知,选项 1 是一个操作的快速数学运算。我不确定是否会冲洗次正常值,我希望它不会受到影响。
我没有找到每个函数的选项,但我确实找到了 2 个可以提供帮助的编译指示。
假设我们想要点积。
选项1。
float innerProductF32(const float* a, const float* b, std::size_t size) {
float res = 0.f;
for (std::size_t i = 0; i != size; ++i) {
#pragma float_control(precise, off)
res += a[i] * b[i];
}
return res;
}
Run Code Online (Sandbox Code Playgroud)
选项2:
float innerProductF32(const float* a, const float* b, std::size_t size) {
float res = 0.f;
_Pragma("clang loop vectorize(enable) interleave(enable)")
for (std::size_t i = 0; i != size; ++i) {
res += a[i] * b[i];
}
return res;
}
Run Code Online (Sandbox Code Playgroud)
第二个功能较弱,它不生成fma指令,但也许这不是您想要的。
| 归档时间: |
|
| 查看次数: |
1103 次 |
| 最近记录: |