【发布时间】:2017-11-16 01:26:18
【问题描述】:
我想在 ARM 处理器上处理大量浮点数, 使用 Neon 技术一次计算四个。像加法和乘法这样的操作一切都很好,但是如果我的计算进入一个 IF 块我该怎么办?示例:
// In the non-vectorized original code, A is an array of many floating-point
// numbers, which are calculated one at a time. Now they're packed
// into a vector and processed four at a time
...calculate A...
if (A > 10.f)
{
A = A+5.f;
}
else
{
A = A+10.f;
}
现在,我应该执行哪个 IF 分支?如果正在处理的向量中的某些值大于 10 而某些值小于 10 怎么办?甚至可以像这样矢量化代码吗?
【问题讨论】: