Refs #241. Add Haswell support (using sandybridge optimizations)
authorDan Luu <danluu@gmail.com>
Sat, 29 Jun 2013 22:26:56 +0000 (17:26 -0500)
committerZhang Xianyi <traits.zhang@gmail.com>
Sun, 30 Jun 2013 14:35:14 +0000 (22:35 +0800)
cpuid.h
cpuid_x86.c
driver/others/dynamic.c

diff --git a/cpuid.h b/cpuid.h
index c52d503..030b2f3 100644 (file)
--- a/cpuid.h
+++ b/cpuid.h
 #define CORE_SANDYBRIDGE 20
 #define CORE_BOBCAT     21
 #define CORE_BULLDOZER  22
+#define CORE_HASWELL CORE_SANDYBRIDGE
 
 #define HAVE_SSE      (1 <<  0)
 #define HAVE_SSE2     (1 <<  1)
@@ -196,4 +197,7 @@ typedef struct {
 #define CPUTYPE_SANDYBRIDGE             44
 #define CPUTYPE_BOBCAT                  45
 #define CPUTYPE_BULLDOZER               46
+// this define is because BLAS doesn't have haswell specific optimizations yet
+#define CPUTYPE_HASWELL CPUTYPE_SANDYBRIDGE 
+
 #endif
index d66ec5a..d7e5075 100644 (file)
@@ -41,6 +41,8 @@
 #include "cpuid.h"
 
 #ifdef NO_AVX
+#define CPUTYPE_HASWELL CPUTYPE_NEHALEM
+#define CORE_HASWELL CORE_NEHALEM
 #define CPUTYPE_SANDYBRIDGE CPUTYPE_NEHALEM
 #define CORE_SANDYBRIDGE CORE_NEHALEM
 #define CPUTYPE_BULLDOZER CPUTYPE_BARCELONA
@@ -1050,8 +1052,22 @@ int get_cpuname(void){
            return CPUTYPE_SANDYBRIDGE;
          else
            return CPUTYPE_NEHALEM;
+        case 12:
+          if(support_avx())
+            return CPUTYPE_HASWELL;
+          else
+           return CPUTYPE_NEHALEM;
        }
        break;
+      case 4:
+        switch (model) {
+        case 5:
+          if(support_avx())
+            return CPUTYPE_HASWELL;
+          else
+           return CPUTYPE_NEHALEM;
+        }
+        break;      
       }
       break;
     case 0x7:
@@ -1424,8 +1440,22 @@ int get_coretype(void){
            return CORE_SANDYBRIDGE;
          else
            return CORE_NEHALEM; //OS doesn't support AVX
+        case 12:
+          if(support_avx())
+            return CORE_HASWELL;
+          else
+           return CORE_NEHALEM;
        }
        break;
+      case 4:
+        switch (model) {
+        case 5:
+          if(support_avx())
+            return CORE_HASWELL;
+          else
+           return CORE_NEHALEM;
+        }
+        break;      
       }
       break;
 
index 425733a..562172c 100644 (file)
@@ -69,7 +69,8 @@ extern gotoblas_t  gotoblas_BULLDOZER;
 #define gotoblas_SANDYBRIDGE gotoblas_NEHALEM
 #define gotoblas_BULLDOZER gotoblas_BARCELONA
 #endif
-
+//Use sandy bridge kernels for haswell.
+#define gotoblas_HASWELL gotoblas_SANDYBRIDGE
 
 #define VENDOR_INTEL      1
 #define VENDOR_AMD        2
@@ -190,6 +191,26 @@ static gotoblas_t *get_coretype(void){
            return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels.
          }
        }
+       //Intel Haswell
+       if (model == 12) {
+         if(support_avx())
+           return &gotoblas_HASWELL;
+         else{
+           fprintf(stderr, "OpenBLAS : Your OS does not support AVX instructions. OpenBLAS is using Nehalem kernels as a fallback, which may give poorer performance.\n");
+           return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels.
+         }
+       }
+       return NULL;
+      case 4:
+               //Intel Haswell
+       if (model == 5) {
+         if(support_avx())
+           return &gotoblas_HASWELL;
+         else{
+           fprintf(stderr, "OpenBLAS : Your OS does not support AVX instructions. OpenBLAS is using Nehalem kernels as a fallback, which may give poorer performance.\n");
+           return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels.
+         }
+       }
        return NULL;
       }
       case 0xf: