Visual Studio 2010 and SSE 4.2
I would like to know, what is necessary to set in Visual Studio 2010, to have SSE 4.2 enabled? I would like to use it because of optimized POPCNT...
How can I test, if all settings are ok?
thanks
well, I tried to use your solution, however <nmmintric.h>
is not included in vstudio2010 and standard __popcnt
requires int
instead of std::bitset<>
:(
any idea?
Thx for the hint w开发者_如何学Goith the correct header. However, it seems that: error C3861: '_mm_popcnt_u64': identifier not found
, I found only _mm_popcnt_u32
, however I don't know, how to use it with bitset
, or should I use just bitset<>.count
? It can't work without anz settings of compiler, can it?
nobody knows ?
you have to write _mm_popcnt_u64 in your code. Also better check it the cpu you run on supports the instruction. And build for x64.
#include <stdio.h>
#include <nmmintrin.h>
int main ()
{
unsigned __int64 a = 0x123456789ABCDEF0;
int res = _mm_popcnt_u64(a);
printf_s("Result res should be 32: %d\n", res);
return 0;
}
MSDN example for __popcnt
:
http://msdn.microsoft.com/en-us/library/bb385231.aspx
There is nothing special required for this to work.
You may use intrinsics mm* and include the appropriate header file, and it will compile if your system support the given features.
The compiler does not inspect or touch inline assembly, so whatever you put in there will go through the build, although your application will crash if your system does not support an instruction.
Other than that, the VS2010 optimizer only targets SSE2.
精彩评论