简体   繁体   English

如何使用SSE指令?

[英]How can I use SSE instruction?

I have some problem with SSE on ubuntu linux system. 我在ubuntu linux系统上的SSE有问题。

example source code on msdn(sse4) use sse4.1 operation on linux msdn(sse4)上的示例源代码在linux上使用sse4.1操作

gcc -o test test.c -msse4.1

then error message: 然后错误信息:

error: request for member 'm128i_u16' in something not a structure or union

How can I use this example code? 如何使用此示例代码? Or any example code can use? 还是可以使用任何示例代码?

The title of the code sample is "Microsoft Specific". 该代码示例的标题是“ Microsoft Specific”。 This means that those functions are specific to the microsoft implementation of c++, and aren't cross-platform. 这意味着这些功能特定于C ++的Microsoft实现,并且不是跨平台的。 Here are some Intel-specific guides to SSE instructions. 这是一些针对SSE指令的特定于Intel的指南。 Here is gcc documentation concerning command-line flags for specific assembly optimizations, including SSE. 这是gcc文档,涉及用于特定程序集优化(包括SSE)的命令行标志。 Good luck, SSE can get a bit hairy. 祝您好运,上证所可能会变得毛茸茸。

This is not so much about Microsoft-specific intrinsic functions, it is about the datatype. 这与Microsoft特定的内在函数无关,而与数据类型有关。 The actual intrinsics are 100% identical in both compilers, and are de facto standard (stemming from Intel). 两种编译器中的实际内在函数都是100%相同的,并且是事实上的标准(源自Intel)。

The problem you are facing is that the __m128i type is -- as a convenience feature -- a union under MSVC, which includes fields such as m128i_u16 . 您面临的问题是__m128i类型是(为了方便起见)MSVC下的union ,其中包括诸如m128i_u16字段。 The code sample you link to assumes this. 您链接到的代码示例假定了这一点。

Under gcc, __m128i is not a union and therefore, unsurprisingly, does not have these fields. 在gcc下, __m128i 不是联合,因此毫不奇怪,它没有这些字段。 This is not really a downside, because accessing fields in an union like this anihilates any gains you might have from using SSE in the first place, so other than in demo snippets like the above, you will (almost) never want to use such a thing. 这并不是真正的弊端,因为这样访问联合体中的字段会首先抵消您使用SSE可能获得的任何收益,因此除了上面的演示片段外,您(几乎)永远不会想要使用事情。

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

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