summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-05-06 14:27:48 -0700
committerJosh Blum <josh@joshknows.com>2011-05-06 14:27:48 -0700
commitc40ef84defaeed0c9ec70e45a7e4019fa6d6e1b2 (patch)
treec90f168fda80a883ee0120fec938eb75a13c2663
parent5b4c7d27e9d49ab58df1f1d9350dcaf64c60a1ce (diff)
volk: various backports from MSVC building
1) Added support for __cpuid intrinsic under MSVC 2) Fixed disambiguation for std::abs overload in qa code 3) Fixed bit128 union, the ifdefs were completely wrong
-rw-r--r--volk/gen/make_cpuid_c.py12
-rw-r--r--volk/include/volk/volk_common.h22
-rw-r--r--volk/lib/qa_utils.cc2
3 files changed, 30 insertions, 6 deletions
diff --git a/volk/gen/make_cpuid_c.py b/volk/gen/make_cpuid_c.py
index 20621769b8..2fdbaf3046 100644
--- a/volk/gen/make_cpuid_c.py
+++ b/volk/gen/make_cpuid_c.py
@@ -31,9 +31,21 @@ HEADER_TEMPL = """\
struct VOLK_CPU volk_cpu;
#if defined(__i386__) || (__x86_64__)
+
+//implement get cpuid for gcc compilers using a copy of cpuid.h
+#if defined(__GNUC__)
#include <gcc_x86_cpuid.h>
#define cpuid_x86(op, r) __get_cpuid(op, r+0, r+1, r+2, r+3)
+//implement get cpuid for MSVC compilers using __cpuid intrinsic
+#elif defined(_MSC_VER)
+#include <intrin.h>
+#define cpuid(op, r) __cpuid(r, op)
+
+#else
+#error "A get cpuid for volk is not available on this compiler..."
+#endif
+
static inline unsigned int cpuid_eax(unsigned int op) {
unsigned int regs[4];
cpuid_x86 (op, regs);
diff --git a/volk/include/volk/volk_common.h b/volk/include/volk/volk_common.h
index 1e868561e2..12623073c3 100644
--- a/volk/include/volk/volk_common.h
+++ b/volk/include/volk/volk_common.h
@@ -57,18 +57,30 @@
////////////////////////////////////////////////////////////////////////
// The bit128 union used by some
////////////////////////////////////////////////////////////////////////
-#include<inttypes.h>
-#ifdef LV_HAVE_MMX
-#include<xmmintrin.h>
+#include <inttypes.h>
+
+#ifdef LV_HAVE_SSE
+#include <xmmintrin.h>
+#endif
+
+#ifdef LV_HAVE_SSE2
+#include <emmintrin.h>
+#endif
+
union bit128{
uint16_t i16[8];
uint32_t i[4];
float f[4];
double d[2];
- __m128i int_vec;
+
+ #ifdef LV_HAVE_SSE
__m128 float_vec;
+ #endif
+
+ #ifdef LV_HAVE_SSE2
+ __m128i int_vec;
__m128d double_vec;
+ #endif
};
-#endif /*LV_HAVE_MMX*/
#endif /*INCLUDED_LIBVOLK_COMMON_H*/
diff --git a/volk/lib/qa_utils.cc b/volk/lib/qa_utils.cc
index b195ab365f..fa091ad0d0 100644
--- a/volk/lib/qa_utils.cc
+++ b/volk/lib/qa_utils.cc
@@ -219,7 +219,7 @@ bool icompare(t *in1, t *in2, unsigned int vlen, unsigned int tol) {
bool fail = false;
int print_max_errs = 10;
for(int i=0; i<vlen; i++) {
- if(abs(((t *)(in1))[i] - ((t *)(in2))[i]) > tol) {
+ if(abs(int(((t *)(in1))[i]) - int(((t *)(in2))[i])) > tol) {
fail=true;
if(print_max_errs-- > 0) {
std::cout << "offset " << i << " in1: " << static_cast<int>(t(((t *)(in1))[i])) << " in2: " << static_cast<int>(t(((t *)(in2))[i])) << std::endl;