小编tom*_*mto的帖子

霓虹灯浮动乘法比预期慢

我有两个浮标选项卡.我需要将第一个选项卡中的元素与第二个选项卡中的相应元素相乘,并将结果存储在第三个选项卡中.

我想使用NEON来并行化浮点乘法:同时进行四次浮点乘法而不是一次.

我预计会有显着的加速,但我的执行时间减少了大约20%.这是我的代码:

#include <stdlib.h>
#include <iostream>
#include <arm_neon.h>

const int n = 100; // table size

/* fill a tab with random floats */
void rand_tab(float *t) {
    for (int i = 0; i < n; i++)
        t[i] = (float)rand()/(float)RAND_MAX;
}

/* Multiply elements of two tabs and store results in third tab
 - STANDARD processing. */
void mul_tab_standard(float *t1, float *t2, float *tr) {
    for (int i = 0; i < n; i++)
         tr[i] = t1[i] * t2[i]; …
Run Code Online (Sandbox Code Playgroud)

c++ gcc arm simd neon

5
推荐指数
1
解决办法
3745
查看次数

标签 统计

arm ×1

c++ ×1

gcc ×1

neon ×1

simd ×1