Try to read cpu information from /sys/devices/system/cpu/cpu0 if HWCAP_CPUID fails
authorMartin Kroeker <martin@ruby.chemie.uni-freiburg.de>
Tue, 27 Oct 2020 16:51:32 +0000 (17:51 +0100)
committerGitHub <noreply@github.com>
Tue, 27 Oct 2020 16:51:32 +0000 (17:51 +0100)
driver/others/dynamic_arm64.c

index be22b24..007a221 100644 (file)
@@ -139,19 +139,30 @@ static gotoblas_t *force_coretype(char *coretype) {
 
 static gotoblas_t *get_coretype(void) {
   int implementer, variant, part, arch, revision, midr_el1;
+  char coremsg[128];
+
+#if (!defined OS_LINUX && !defined OS_ANDROID)
+  return NULL;
+#endif
 
-#if (defined OS_LINUX || defined OS_ANDROID)
   if (!(getauxval(AT_HWCAP) & HWCAP_CPUID)) {
-    char coremsg[128];
+#ifdef __linux
+        FILE *infile;
+        char buffer[512], *p, *cpu_part = NULL, *cpu_implementer = NULL;
+        p = (char *) NULL ;
+       infile = fopen("/sys/devices/system/cpu/cpu0/regs/identification/midr_el1","r");
+       if (!infile) return NULL;
+       fgets(buffer, sizeof(buffer), infile);
+       midr_el1=strtoul(buffer,NULL,16);
+       fclose(infile);
+#else
     snprintf(coremsg, 128, "Kernel lacks cpuid feature support. Auto detection of core type failed !!!\n");
     openblas_warning(1, coremsg);
     return NULL;
-  }
-#else
-   return NULL;
 #endif
-
-  get_cpu_ftr(MIDR_EL1, midr_el1);
+  } else {
+    get_cpu_ftr(MIDR_EL1, midr_el1);
+  }
   /*
    * MIDR_EL1
    *
@@ -219,6 +230,9 @@ static gotoblas_t *get_coretype(void) {
           return &gotoblas_FALKOR;
       }
       break;
+    default:
+      snprintf(coremsg, 128, "Unknown CPU model - implementer %x part %x\n",implementer,part);
+      openblas_warning(1, coremsg);
   }
   return NULL;
 }