Browse Source

Try to read cpu information from /sys/devices/system/cpu/cpu0 if HWCAP_CPUID fails

tags/v0.3.13^2
Martin Kroeker GitHub 5 years ago
parent
commit
b937d78a6d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 7 deletions
  1. +21
    -7
      driver/others/dynamic_arm64.c

+ 21
- 7
driver/others/dynamic_arm64.c View 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;
}


Loading…
Cancel
Save