什么是量化呢? [英] What does vectorization mean?

查看:224
本文介绍了什么是量化呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是个好主意,矢量化code?什么是在什么时候做方面的良好做法?下面会发​​生什么?

Is it a good idea to vectorize the code? What are good practices in terms of when to do it? What happens underneath?

推荐答案

矢量意味着编译器检测到您的独立指令​​为一体的 SIMD指令。通常的例子是,如果你做类似

Vectorization means that the compiler detects that your independent instructions can be executed as one SIMD instruction. Usual example is that if you do something like

for(i=0; i<N; i++){
  a[i] = a[i] + b[i];
}

这将作为矢量(使用矢量标记)

It will be vectorized as (using vector notation)

for (i=0; i<(N-N%VF); i+=VF){
  a[i:i+VF] = a[i:i+VF] + b[i:i+VF];
}

基本上编译挑选一人操作,可以对数组的元素VF在同一时间进行,这是否N / VF倍,而不是做单一的操作N次。

Basically the compiler picks one operation that can be done on VF elements of the array at the same time and does this N/VF times instead of doing the single operation N times.

这提高了性能,但穿上体系结构的详细要求。

It increases performance, but puts more requirement on the architecture.

这篇关于什么是量化呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆