Modified SSE4.1 and 4.2 checks with _may_i_use_cpu_feature()

This commit is contained in:
Karthik Gururaj 2014-03-06 08:49:52 -08:00
parent 6166d08183
commit 27e640d640
3 changed files with 18 additions and 17 deletions

View File

@ -33,7 +33,6 @@ using namespace std;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
cout << "AVX supported? " << _may_i_use_cpu_feature(_FEATURE_AVX) << endl ;
#define BATCH_SIZE 10000 #define BATCH_SIZE 10000
if(argc < 2) if(argc < 2)
{ {

View File

@ -59,26 +59,28 @@ bool is_avx_supported()
bool is_sse41_supported() bool is_sse41_supported()
{ {
int ecx = 0, edx = 0, ebx = 0; return (_may_i_use_cpu_feature(_FEATURE_SSE4_1) > 0);
__asm__("cpuid" //int ecx = 0, edx = 0, ebx = 0;
: "=b" (ebx), //__asm__("cpuid"
"=c" (ecx), //: "=b" (ebx),
"=d" (edx) //"=c" (ecx),
: "a" (1) //"=d" (edx)
); //: "a" (1)
return ((ecx >> 19)&1) == 1; //);
//return ((ecx >> 19)&1) == 1;
} }
bool is_sse42_supported() bool is_sse42_supported()
{ {
int ecx = 0, edx = 0, ebx = 0; return (_may_i_use_cpu_feature(_FEATURE_SSE4_2) > 0);
__asm__("cpuid" //int ecx = 0, edx = 0, ebx = 0;
: "=b" (ebx), //__asm__("cpuid"
"=c" (ecx), //: "=b" (ebx),
"=d" (edx) //"=c" (ecx),
: "a" (1) //"=d" (edx)
); //: "a" (1)
return ((ecx >> 20)&1) == 1; //);
//return ((ecx >> 20)&1) == 1;
} }
uint64_t get_machine_capabilities() uint64_t get_machine_capabilities()