使用内部函数时出现未处理的异常
我有一个使用 VC++ 创建的应用程序,想要通过向量化一些操作来探索优化机会。
首先,我正在尝试以下代码:
__m128i p1;
p1.m128i_u32[0] = 1;
p1.m128i_u32[1] = 2;
p1.m128i_u32[2] = 3;
p1.m128i_u32[3] = 4;
__m128i p2;
p2.m128i_u32[0] = 1;
p2.m128i_u32[1] = 2;
p2.m128i_u32[2] = 3;
p2.m128i_u32[3] = 4;
__m128i res2= _mm_mul_epi32(p1,p2);
但是,当执行 _mm_mul_epi32 时,我收到未处理的异常或非法操作错误,我不知道为什么会发生。 有人可以告诉我出了什么问题吗?
I have an application created using VC++, and wanted to explore optimization opprtunity by vectorizing some operations.
To begin with, I am trying the following code :
__m128i p1;
p1.m128i_u32[0] = 1;
p1.m128i_u32[1] = 2;
p1.m128i_u32[2] = 3;
p1.m128i_u32[3] = 4;
__m128i p2;
p2.m128i_u32[0] = 1;
p2.m128i_u32[1] = 2;
p2.m128i_u32[2] = 3;
p2.m128i_u32[3] = 4;
__m128i res2= _mm_mul_epi32(p1,p2);
However, I am getting unhandled exception or illegal operation error when _mm_mul_epi32 is executed, I have no clue why it occurs.
Can someone please tell what is wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
_mm_mul_epi32
映射到PMULDQ
指令,该指令仅在 SSE4 和 AVX 中可用。您需要有一个相当新的 Intel CPU 才能拥有 SSE4 或 AVX,例如 Nehalem、Sandy Bridge(Core i5、i7)。另请注意,您可能会发现使用内在函数来初始化 SIMD 向量更容易、更简洁,例如
_mm_mul_epi32
maps to thePMULDQ
instruction, which is only available in SSE4 and AVX. You need to have a reasonably recent Intel CPU in order to have SSE4 or AVX, e.g. Nehalem, Sandy Bridge (Core i5, i7).Note also that you might find it easier and more succinct to use intrinsics to initialise SIMD vectors, e.g.
您不应该使用成员
m128i_i32
而不是m128i_u32
吗?来自 MSDN。
如果您确实需要
m128i_u32
,那么您必须使用_mm_mul_epu32()
。Shouldn't you be using the member
m128i_i32
instead ofm128i_u32
?From MSDN.
If you really need
m128i_u32
then you must use_mm_mul_epu32()
instead.