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

This commit is contained in:
Martin Kroeker 2020-10-27 17:51:32 +01:00 committed by GitHub
parent 680f744abf
commit b937d78a6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 7 deletions

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;
}