C++ 如何在 Visual Studio 2008(使用 CMake)中启用 SSE/SSE2 指令集?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1480916/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 20:08:30  来源:igfitidea点击:

How do I enable the SSE/SSE2 instruction set in Visual Studio 2008 (using CMake)?

c++visual-studio-2008cmake

提问by Angelo

In Visual Studio 2005 I went in:

在 Visual Studio 2005 中,我进入了:

View --> Property Pages --> C/C++ --> Code Generation --> Enable Enhanced Instruction Set

查看 --> 属性页 --> C/C++ --> 代码生成 --> 启用增强指令集

But in Visual Studio 2008?

但是在 Visual Studio 2008 中呢?

Thanks in advance

提前致谢

回答by Cat Plus Plus

If you're looking for SSE/SSE2: Project > Properties > Configuration Properties > C/C++ > Code Generation > Enable Enhanced Instruction Set, or append /arch:SSE(or /arch:SSE2) in Command Line > Additional Options.

如果你正在寻找SSE / SSE2: Project > Properties > Configuration Properties > C/C++ > Code Generation > Enable Enhanced Instruction Set,或追加/arch:SSE(或/arch:SSE2)的Command Line > Additional Options

You need to have a native project, and at least one .cpp file added to access this, though.

不过,您需要有一个本机项目,并且至少添加了一个 .cpp 文件才能访问它。

回答by larsmoa

Using CMake you could add the following to CMakeLists.txt:

使用 CMake,您可以将以下内容添加到 CMakeLists.txt:

IF(MSVC)
   ADD_DEFINITIONS(/arch:SSE)
ENDIF(MSVC)

or /arch:SSE2.

/arch:SSE2

回答by Naveen

It is Project->Properties... (same path as above)

它是 Project->Properties...(与上面相同的路径)

回答by Naveen

If you are using inline assembler __asm { .... }you don't need to enable it.

如果您使用内联汇编器__asm { .... },则不需要启用它。

But if you enable SSE you have to be careful. It may be that the code is slower than normal FPU code.

但是,如果您启用 SSE,则必须小心。可能是代码比普通 FPU 代码慢。