Skip to content

Commit 2207a16

Browse files
authored
Merge pull request #2952 from martin-frbg/issue2931
Try to read cpu ID from /sys/devices/.../cpu0 if HWCAP_CPUID fails
2 parents 5d64392 + b937d78 commit 2207a16

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

driver/others/dynamic_arm64.c

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,19 +139,30 @@ static gotoblas_t *force_coretype(char *coretype) {
139139

140140
static gotoblas_t *get_coretype(void) {
141141
int implementer, variant, part, arch, revision, midr_el1;
142+
char coremsg[128];
143+
144+
#if (!defined OS_LINUX && !defined OS_ANDROID)
145+
return NULL;
146+
#endif
142147

143-
#if (defined OS_LINUX || defined OS_ANDROID)
144148
if (!(getauxval(AT_HWCAP) & HWCAP_CPUID)) {
145-
char coremsg[128];
149+
#ifdef __linux
150+
FILE *infile;
151+
char buffer[512], *p, *cpu_part = NULL, *cpu_implementer = NULL;
152+
p = (char *) NULL ;
153+
infile = fopen("/sys/devices/system/cpu/cpu0/regs/identification/midr_el1","r");
154+
if (!infile) return NULL;
155+
fgets(buffer, sizeof(buffer), infile);
156+
midr_el1=strtoul(buffer,NULL,16);
157+
fclose(infile);
158+
#else
146159
snprintf(coremsg, 128, "Kernel lacks cpuid feature support. Auto detection of core type failed !!!\n");
147160
openblas_warning(1, coremsg);
148161
return NULL;
149-
}
150-
#else
151-
return NULL;
152162
#endif
153-
154-
get_cpu_ftr(MIDR_EL1, midr_el1);
163+
} else {
164+
get_cpu_ftr(MIDR_EL1, midr_el1);
165+
}
155166
/*
156167
* MIDR_EL1
157168
*
@@ -219,6 +230,9 @@ static gotoblas_t *get_coretype(void) {
219230
return &gotoblas_FALKOR;
220231
}
221232
break;
233+
default:
234+
snprintf(coremsg, 128, "Unknown CPU model - implementer %x part %x\n",implementer,part);
235+
openblas_warning(1, coremsg);
222236
}
223237
return NULL;
224238
}

0 commit comments

Comments
 (0)