From ad9752793bbb7134e14483553766ab3d36e02366 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 18 Apr 2012 11:18:21 -0700 Subject: volk: added xgetbv stuff from volk_work to maint This ensures that the compiler has support for xgetbv. This also fixes MSVC by checking for _xgetbv. Also, restored copy of cpuid.h, this should not be modified. --- volk/gen/make_cpuid_c.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'volk/gen') diff --git a/volk/gen/make_cpuid_c.py b/volk/gen/make_cpuid_c.py index c6bb5059e..674b4fb2e 100644 --- a/volk/gen/make_cpuid_c.py +++ b/volk/gen/make_cpuid_c.py @@ -41,11 +41,32 @@ struct VOLK_CPU volk_cpu; #include #define cpuid_x86(op, r) __get_cpuid(op, (unsigned int *)r+0, (unsigned int *)r+1, (unsigned int *)r+2, (unsigned int *)r+3) + /* Return Intel AVX extended CPU capabilities register. + * This function will bomb on non-AVX-capable machines, so + * check for AVX capability before executing. + */ + #if defined(__GNUC_PREREQ) && __GNUC_PREREQ(4, 4) + static inline unsigned long long _xgetbv(unsigned int index){ + unsigned int eax, edx; + __asm__ __volatile__("xgetbv" : "=a"(eax), "=d"(edx) : "c"(index)); + return ((unsigned long long)edx << 32) | eax; + } + #define __xgetbv() _xgetbv(0) + #else + #define __xgetbv() 0 + #endif + //implement get cpuid for MSVC compilers using __cpuid intrinsic #elif defined(_MSC_VER) #include #define cpuid_x86(op, r) __cpuid(r, op) + #if defined(_XCR_XFEATURE_ENABLED_MASK) + #define __xgetbv() _xgetbv(_XCR_XFEATURE_ENABLED_MASK) + #else + #define __xgetbv() 0 + #endif + #else #error "A get cpuid for volk is not available on this compiler..." #endif -- cgit From ef97a9935853b928cefe0bf27273e935c0df7552 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 18 Apr 2012 13:32:36 -0700 Subject: volk: gcc version check without __GNUC_PREREQ --- volk/gen/make_cpuid_c.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'volk/gen') diff --git a/volk/gen/make_cpuid_c.py b/volk/gen/make_cpuid_c.py index 674b4fb2e..49b216677 100644 --- a/volk/gen/make_cpuid_c.py +++ b/volk/gen/make_cpuid_c.py @@ -45,7 +45,7 @@ struct VOLK_CPU volk_cpu; * This function will bomb on non-AVX-capable machines, so * check for AVX capability before executing. */ - #if defined(__GNUC_PREREQ) && __GNUC_PREREQ(4, 4) + #if __GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 static inline unsigned long long _xgetbv(unsigned int index){ unsigned int eax, edx; __asm__ __volatile__("xgetbv" : "=a"(eax), "=d"(edx) : "c"(index)); -- cgit