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+
4654extern gotoblas_t gotoblas_ARMV8 ;
4755#ifdef DYNAMIC_LIST
4856#ifdef DYN_CORTEXA53
@@ -120,7 +128,7 @@ extern gotoblas_t gotoblas_ARMV9SME;
120128#else
121129#define gotoblas_ARMV9SME gotoblas_ARMV8
122130#endif
123- #ifdef DYN_CORTEX_A55
131+ #ifdef DYN_CORTEXA55
124132extern gotoblas_t gotoblas_CORTEXA55 ;
125133#else
126134#define gotoblas_CORTEXA55 gotoblas_ARMV8
@@ -147,17 +155,17 @@ extern gotoblas_t gotoblas_NEOVERSEV1;
147155extern gotoblas_t gotoblas_NEOVERSEN2 ;
148156extern gotoblas_t gotoblas_ARMV8SVE ;
149157extern gotoblas_t gotoblas_A64FX ;
158+ #ifndef NO_SME
159+ extern gotoblas_t gotoblas_ARMV9SME ;
160+ #else
161+ #define gotoblas_ARMV9SME gotoblas_ARMV8SVE
162+ #endif
150163#else
151164#define gotoblas_NEOVERSEV1 gotoblas_ARMV8
152165#define gotoblas_NEOVERSEN2 gotoblas_ARMV8
153166#define gotoblas_ARMV8SVE gotoblas_ARMV8
154167#define gotoblas_A64FX gotoblas_ARMV8
155- #endif
156-
157- #ifndef NO_SME
158- extern gotoblas_t gotoblas_ARMV9SME ;
159- #else
160- #define gotoblas_ARMV9SME gotoblas_ARMV8SVE
168+ #define gotoblas_ARMV9SME gotoblas_ARMV8
161169#endif
162170
163171extern gotoblas_t gotoblas_THUNDERX3T110 ;
@@ -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
@@ -266,6 +276,7 @@ static gotoblas_t *force_coretype(char *coretype) {
266276 case 15 : return (& gotoblas_CORTEXA55 );
267277 case 16 : return (& gotoblas_ARMV8SVE );
268278 case 17 : return (& gotoblas_A64FX );
279+ case 18 : return (& gotoblas_ARMV9SME );
269280 }
270281 snprintf (message , 128 , "Core not found: %s\n" , coretype );
271282 openblas_warning (1 , message );
@@ -277,6 +288,11 @@ static gotoblas_t *get_coretype(void) {
277288 char coremsg [128 ];
278289
279290#if defined (OS_DARWIN )
291+ //future #if !defined(NO_SME)
292+ // if (support_sme1()) {
293+ // return &gotoblas_ARMV9SME;
294+ // }
295+ // #endif
280296 return & gotoblas_NEOVERSEN1 ;
281297#endif
282298
@@ -439,15 +455,16 @@ static gotoblas_t *get_coretype(void) {
439455 }
440456 break ;
441457 case 0x61 : // Apple
458+ //future if (support_sme1()) return &gotoblas_ARMV9SME;
442459 return & gotoblas_NEOVERSEN1 ;
443460 break ;
444461 default :
445462 snprintf (coremsg , 128 , "Unknown CPU model - implementer %x part %x\n" ,implementer ,part );
446463 openblas_warning (1 , coremsg );
447464 }
448465
449- #if !defined(NO_SME ) && defined( HWCAP2_SME )
450- if (( getauxval ( AT_HWCAP2 ) & HWCAP2_SME )) {
466+ #if !defined(NO_SME )
467+ if (support_sme1 ( )) {
451468 return & gotoblas_ARMV9SME ;
452469 }
453470#endif
@@ -511,6 +528,10 @@ int support_sme1(void) {
511528 if (getauxval (AT_HWCAP2 ) & HWCAP2_SME ){
512529 ret = 1 ;
513530 }
531+ #endif
532+ #if defined(__APPLE__ )
533+ sysctlbyname ("hw.optional.arm.FEAT_SME" ,& value64 ,& length64 ,NULL ,0 );
534+ ret = value64 ;
514535#endif
515536 return ret ;
516537}
0 commit comments