Skip to content

Commit e5ffb7c

Browse files
authored
Fix ARMV9SME target and add support_sme1 code for MacOS
1 parent 39718cd commit e5ffb7c

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

driver/others/dynamic_arm64.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@
4343
#include <sys/auxv.h>
4444
#endif
4545

46+
#ifdef __APPLE__
47+
#include <sys/sysctl.h>
48+
int32_t value;
49+
size_t length=sizeof(value);
50+
int64_t value64;
51+
size_t length64=sizeof(value64);
52+
#endif
53+
4654
extern gotoblas_t gotoblas_ARMV8;
4755
#ifdef DYNAMIC_LIST
4856
#ifdef DYN_CORTEXA53
@@ -168,7 +176,7 @@ extern void openblas_warning(int verbose, const char * msg);
168176
#define FALLBACK_VERBOSE 1
169177
#define NEOVERSEN1_FALLBACK "OpenBLAS : Your OS does not support SVE instructions. OpenBLAS is using Neoverse N1 kernels as a fallback, which may give poorer performance.\n"
170178

171-
#define NUM_CORETYPES 18
179+
#define NUM_CORETYPES 19
172180

173181
/*
174182
* In case asm/hwcap.h is outdated on the build system, make sure
@@ -207,6 +215,7 @@ static char *corename[] = {
207215
"cortexa55",
208216
"armv8sve",
209217
"a64fx",
218+
"armv9sme",
210219
"unknown"
211220
};
212221

@@ -229,6 +238,7 @@ char *gotoblas_corename(void) {
229238
if (gotoblas == &gotoblas_CORTEXA55) return corename[15];
230239
if (gotoblas == &gotoblas_ARMV8SVE) return corename[16];
231240
if (gotoblas == &gotoblas_A64FX) return corename[17];
241+
if (gotoblas == &gotoblas_ARMV9SME) return corename[18];
232242
return corename[NUM_CORETYPES];
233243
}
234244

@@ -277,6 +287,11 @@ static gotoblas_t *get_coretype(void) {
277287
char coremsg[128];
278288

279289
#if defined (OS_DARWIN)
290+
//future #if !defined(NO_SME)
291+
// if (support_sme1) {
292+
// return &gotoblas_ARMV9SME;
293+
// }
294+
// #endif
280295
return &gotoblas_NEOVERSEN1;
281296
#endif
282297

@@ -439,15 +454,16 @@ static gotoblas_t *get_coretype(void) {
439454
}
440455
break;
441456
case 0x61: // Apple
457+
//future if (support_sme1) return &gotoblas_ARMV9SME;
442458
return &gotoblas_NEOVERSEN1;
443459
break;
444460
default:
445461
snprintf(coremsg, 128, "Unknown CPU model - implementer %x part %x\n",implementer,part);
446462
openblas_warning(1, coremsg);
447463
}
448464

449-
#if !defined(NO_SME) && defined(HWCAP2_SME)
450-
if ((getauxval(AT_HWCAP2) & HWCAP2_SME)) {
465+
#if !defined(NO_SME)
466+
if (support_sme1) {
451467
return &gotoblas_ARMV9SME;
452468
}
453469
#endif
@@ -511,6 +527,10 @@ int support_sme1(void) {
511527
if(getauxval(AT_HWCAP2) & HWCAP2_SME){
512528
ret = 1;
513529
}
530+
#endif
531+
#if defined(__APPLE__)
532+
sysctlbyname("hw.optional.arm.FEAT_SME",&value64,&length64,NULL,0);
533+
ret = value64;
514534
#endif
515535
return ret;
516536
}

0 commit comments

Comments
 (0)