@@ -57,9 +57,11 @@ size_t length64=sizeof(value64);
57
57
#define CPU_CORTEXA57 3
58
58
#define CPU_CORTEXA72 4
59
59
#define CPU_CORTEXA73 5
60
+ #define CPU_CORTEXA76 23
60
61
#define CPU_NEOVERSEN1 11
61
62
#define CPU_NEOVERSEV1 16
62
63
#define CPU_NEOVERSEN2 17
64
+ #define CPU_NEOVERSEV2 24
63
65
#define CPU_CORTEXX1 18
64
66
#define CPU_CORTEXX2 19
65
67
#define CPU_CORTEXA510 20
@@ -104,7 +106,9 @@ static char *cpuname[] = {
104
106
"CORTEXX2" ,
105
107
"CORTEXA510" ,
106
108
"CORTEXA710" ,
107
- "FT2000"
109
+ "FT2000" ,
110
+ "CORTEXA76" ,
111
+ "NEOVERSEV2"
108
112
};
109
113
110
114
static char * cpuname_lower [] = {
@@ -130,7 +134,9 @@ static char *cpuname_lower[] = {
130
134
"cortexx2" ,
131
135
"cortexa510" ,
132
136
"cortexa710" ,
133
- "ft2000"
137
+ "ft2000" ,
138
+ "cortexa76" ,
139
+ "neoversev2"
134
140
};
135
141
136
142
static int cpulowperf = 0 ;
@@ -140,7 +146,7 @@ static int cpuhiperf=0;
140
146
int get_feature (char * search )
141
147
{
142
148
143
- #ifdef __linux
149
+ #if defined( __linux ) || defined( __NetBSD__ )
144
150
FILE * infile ;
145
151
char buffer [2048 ], * p ,* t ;
146
152
p = (char * ) NULL ;
@@ -179,7 +185,7 @@ static int cpusort(const void *model1, const void *model2)
179
185
int detect (void )
180
186
{
181
187
182
- #ifdef __linux
188
+ #if defined( __linux ) || defined( __NetBSD__ )
183
189
int n ,i ,ii ;
184
190
int midr_el1 ;
185
191
int implementer ;
@@ -243,8 +249,8 @@ int detect(void)
243
249
break ;
244
250
} else {
245
251
(void )fgets (buffer , sizeof (buffer ), infile );
246
- midr_el1 = strtoul (buffer ,NULL ,16 );
247
- fclose (infile );
252
+ midr_el1 = strtoul (buffer ,NULL ,16 );
253
+ fclose (infile );
248
254
implementer = (midr_el1 >> 24 ) & 0xFF ;
249
255
cpucores [i ] = (midr_el1 >> 4 ) & 0xFFF ;
250
256
sprintf (buffer ,"/sys/devices/system/cpu/cpu%d/cpu_capacity" ,i );
@@ -304,6 +310,10 @@ int detect(void)
304
310
return CPU_CORTEXX2 ;
305
311
else if (strstr (cpu_part , "0xd4e" )) //X3
306
312
return CPU_CORTEXX2 ;
313
+ else if (strstr (cpu_part , "0xd4f" )) //NVIDIA Grace et al.
314
+ return CPU_NEOVERSEV2 ;
315
+ else if (strstr (cpu_part , "0xd0b" ))
316
+ return CPU_CORTEXA76 ;
307
317
}
308
318
// Qualcomm
309
319
else if (strstr (cpu_implementer , "0x51" ) && strstr (cpu_part , "0xc00" ))
@@ -361,9 +371,20 @@ int detect(void)
361
371
}
362
372
#else
363
373
#ifdef __APPLE__
374
+ sysctlbyname ("hw.ncpu" ,& value64 ,& length64 ,NULL ,0 );
375
+ cpulowperf = value64 ;
376
+ sysctlbyname ("hw.nperflevels" ,& value64 ,& length64 ,NULL ,0 );
377
+ if (value64 > 1 ) {
378
+ sysctlbyname ("hw.perflevel0.cpusperl" ,& value64 ,& length64 ,NULL ,0 );
379
+ cpuhiperf = value64 ;
380
+ sysctlbyname ("hw.perflevel1.cpusperl" ,& value64 ,& length64 ,NULL ,0 );
381
+ cpulowperf = value64 ;
382
+ }
364
383
sysctlbyname ("hw.cpufamily" ,& value64 ,& length64 ,NULL ,0 );
365
384
if (value64 == 131287967 || value64 == 458787763 ) return CPU_VORTEX ; //A12/M1
366
385
if (value64 == 3660830781 ) return CPU_VORTEX ; //A15/M2
386
+ if (value64 == 2271604202 ) return CPU_VORTEX ; //A16/M3
387
+ if (value64 == 1867590060 ) return CPU_VORTEX ; //M4
367
388
#endif
368
389
return CPU_ARMV8 ;
369
390
#endif
@@ -396,7 +417,7 @@ void get_cpucount(void)
396
417
{
397
418
int n = 0 ;
398
419
399
- #ifdef __linux
420
+ #if defined( __linux ) || defined( __NetBSD__ )
400
421
FILE * infile ;
401
422
char buffer [2048 ], * p ,* t ;
402
423
p = (char * ) NULL ;
@@ -423,6 +444,12 @@ int n=0;
423
444
#ifdef __APPLE__
424
445
sysctlbyname ("hw.physicalcpu_max" ,& value ,& length ,NULL ,0 );
425
446
printf ("#define NUM_CORES %d\n" ,value );
447
+ if (cpulowperf > 0 )
448
+ printf ("#define NUM_CORES_LP %d\n" ,cpulowperf );
449
+ if (cpumidperf > 0 )
450
+ printf ("#define NUM_CORES_MP %d\n" ,cpumidperf );
451
+ if (cpuhiperf > 0 )
452
+ printf ("#define NUM_CORES_HP %d\n" ,cpuhiperf );
426
453
#endif
427
454
}
428
455
@@ -489,6 +516,8 @@ void get_cpuconfig(void)
489
516
break ;
490
517
491
518
case CPU_NEOVERSEV1 :
519
+ printf ("#define HAVE_SVE 1\n" );
520
+ case CPU_CORTEXA76 :
492
521
printf ("#define %s\n" , cpuname [d ]);
493
522
printf ("#define L1_CODE_SIZE 65536\n" );
494
523
printf ("#define L1_CODE_LINESIZE 64\n" );
@@ -516,12 +545,32 @@ void get_cpuconfig(void)
516
545
printf ("#define L2_ASSOCIATIVE 8\n" );
517
546
printf ("#define DTB_DEFAULT_ENTRIES 48\n" );
518
547
printf ("#define DTB_SIZE 4096\n" );
548
+ printf ("#define HAVE_SVE 1\n" );
519
549
break ;
550
+ case CPU_NEOVERSEV2 :
551
+ printf ("#define ARMV9\n" );
552
+ printf ("#define HAVE_SVE 1\n" );
553
+ printf ("#define %s\n" , cpuname [d ]);
554
+ printf ("#define L1_CODE_SIZE 65536\n" );
555
+ printf ("#define L1_CODE_LINESIZE 64\n" );
556
+ printf ("#define L1_CODE_ASSOCIATIVE 4\n" );
557
+ printf ("#define L1_DATA_SIZE 65536\n" );
558
+ printf ("#define L1_DATA_LINESIZE 64\n" );
559
+ printf ("#define L1_DATA_ASSOCIATIVE 4\n" );
560
+ printf ("#define L2_SIZE 1048576\n" );
561
+ printf ("#define L2_LINESIZE 64\n" );
562
+ printf ("#define L2_ASSOCIATIVE 8\n" );
563
+ // L1 Data TLB = 48 entries
564
+ // L2 Data TLB = 2048 entries
565
+ printf ("#define DTB_DEFAULT_ENTRIES 48\n" );
566
+ printf ("#define DTB_SIZE 4096\n" ); // Set to 4096 for symmetry with other configs.
567
+ break ;
520
568
case CPU_CORTEXA510 :
521
569
case CPU_CORTEXA710 :
522
570
case CPU_CORTEXX1 :
523
571
case CPU_CORTEXX2 :
524
572
printf ("#define ARMV9\n" );
573
+ printf ("#define HAVE_SVE 1\n" );
525
574
printf ("#define %s\n" , cpuname [d ]);
526
575
printf ("#define L1_CODE_SIZE 65536\n" );
527
576
printf ("#define L1_CODE_LINESIZE 64\n" );
@@ -638,6 +687,7 @@ void get_cpuconfig(void)
638
687
break ;
639
688
case CPU_A64FX :
640
689
printf ("#define A64FX\n" );
690
+ printf ("#define HAVE_SVE 1\n" );
641
691
printf ("#define L1_CODE_SIZE 65535\n" );
642
692
printf ("#define L1_DATA_SIZE 65535\n" );
643
693
printf ("#define L1_DATA_LINESIZE 256\n" );
@@ -670,7 +720,7 @@ void get_libname(void)
670
720
void get_features (void )
671
721
{
672
722
673
- #ifdef __linux
723
+ #if defined( __linux ) || defined( __NetBSD__ )
674
724
FILE * infile ;
675
725
char buffer [2048 ], * p ,* t ;
676
726
p = (char * ) NULL ;
0 commit comments