简体   繁体   English

向量化short到float转换?

[英]Vectorize short to float conversion?

I am trying to understand why Visual Studio 2012 (x64) doesn't want to vectorized a conversion from a short to a float . 我试图理解为什么Visual Studio 2012(x64)不想将从short转换为float向量化。 Does anybody have a reason or a way around? 有人有理由或解决方法吗?

//unsigned short* __restrict A,B,C,D    
for (int j = 0; j < H*W;j++) 
{
    float Gs = D[j]-B[j];
    float Gc = A[j]-C[j];
    in[j]=atan2f(Gs,Gc);
}

info C5002: loop not vectorized due to reason '1101' 信息C5002:由于原因'1101',循环未向量化

RESOLUTION 解析度

Runtime using shorts and not vectorizing is about 800ms 使用短裤而不进行矢量化的运行时间约为800ms

Runtime converting to all ints and auto vectorizing is about 140ms (!!!) 运行时转换为所有int并自动向量化约为140ms (!!!)

From this page , it appears that your "Loop contains a non-vectorizable conversion operation (may be implicit)". 此页面上 ,您的“循环包含不可向量化的转换操作(可能是隐式的)”。 Have you tried first converting to a type which is the same width as a float (such as int )? 您是否尝试过先将其转换为与float宽度相同的类型(例如int )?

For a more concrete reason, see here . 出于更具体的原因,请参见此处 Apparently, there is no direct way in SSE to convert an SSE register consisting of a vector of shorts to a vector of floats, however there is an instruction that converts 32-bit integers to floats. 显然,SSE中没有直接方法将包含短裤向量的SSE寄存器转换为浮点向量,但是有一条指令可将32位整数转换为浮点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM