3
3
4
4
extern gotoblas_t gotoblas_POWER6 ;
5
5
extern gotoblas_t gotoblas_POWER8 ;
6
- #if (!defined __GNUC__ ) || ( __GNUC__ >= 6 )
6
+ #if (( !defined __GNUC__ ) || ( __GNUC__ >= 6 )) || defined( __clang__ )
7
7
extern gotoblas_t gotoblas_POWER9 ;
8
8
#endif
9
9
#ifdef HAVE_P10_SUPPORT
@@ -20,14 +20,14 @@ static char *corename[] = {
20
20
"POWER10"
21
21
};
22
22
23
- #define NUM_CORETYPES 4
23
+ #define NUM_CORETYPES 5
24
24
25
25
char * gotoblas_corename (void ) {
26
26
#ifndef C_PGI
27
27
if (gotoblas == & gotoblas_POWER6 ) return corename [1 ];
28
28
#endif
29
29
if (gotoblas == & gotoblas_POWER8 ) return corename [2 ];
30
- #if (!defined __GNUC__ ) || ( __GNUC__ >= 6 )
30
+ #if (( !defined __GNUC__ ) || ( __GNUC__ >= 6 )) || defined( __clang__ )
31
31
if (gotoblas == & gotoblas_POWER9 ) return corename [3 ];
32
32
#endif
33
33
#ifdef HAVE_P10_SUPPORT
@@ -36,13 +36,37 @@ char *gotoblas_corename(void) {
36
36
return corename [0 ];
37
37
}
38
38
39
- #if defined(__clang__ )
40
- static int __builtin_cpu_supports (char * arg )
39
+ #define CPU_UNKNOWN 0
40
+ #define CPU_POWER5 5
41
+ #define CPU_POWER6 6
42
+ #define CPU_POWER8 8
43
+ #define CPU_POWER9 9
44
+ #define CPU_POWER10 10
45
+
46
+ #ifdef _AIX
47
+ #include <sys/systemcfg.h>
48
+
49
+ static int cpuid (void )
41
50
{
42
- return 0 ;
43
- }
51
+ int arch = _system_configuration .implementation ;
52
+ #ifdef POWER_6
53
+ if (arch == POWER_6 ) return CPU_POWER6 ;
44
54
#endif
45
-
55
+ #ifdef POWER_7
56
+ else if (arch == POWER_7 ) return CPU_POWER6 ;
57
+ #endif
58
+ #ifdef POWER_8
59
+ else if (arch == POWER_8 ) return CPU_POWER8 ;
60
+ #endif
61
+ #ifdef POWER_9
62
+ else if (arch == POWER_9 ) return CPU_POWER9 ;
63
+ #endif
64
+ #ifdef POWER_10
65
+ else if (arch == POWER_10 ) return CPU_POWER10 ;
66
+ #endif
67
+ return CPU_UNKNOWN ;
68
+ }
69
+ #else
46
70
#if defined(C_PGI ) || defined(__clang__ )
47
71
/*
48
72
* NV HPC compilers do not yet implement __builtin_cpu_is().
@@ -53,21 +77,12 @@ static int __builtin_cpu_supports(char* arg)
53
77
* what was requested.
54
78
*/
55
79
56
- #include <string.h>
57
-
58
80
/*
59
81
* Define POWER processor version table.
60
82
*
61
83
* NOTE NV HPC SDK compilers only support POWER8 and POWER9 at this time
62
84
*/
63
85
64
- #define CPU_UNKNOWN 0
65
- #define CPU_POWER5 5
66
- #define CPU_POWER6 6
67
- #define CPU_POWER8 8
68
- #define CPU_POWER9 9
69
- #define CPU_POWER10 10
70
-
71
86
static struct {
72
87
uint32_t pvr_mask ;
73
88
uint32_t pvr_value ;
@@ -160,7 +175,8 @@ static struct {
160
175
},
161
176
};
162
177
163
- static int __builtin_cpu_is (const char * cpu ) {
178
+ static int cpuid (void )
179
+ {
164
180
int i ;
165
181
uint32_t pvr ;
166
182
uint32_t cpu_type ;
@@ -178,15 +194,42 @@ static int __builtin_cpu_is(const char *cpu) {
178
194
pvrPOWER [i ].cpu_name , pvrPOWER [i ].cpu_type );
179
195
#endif
180
196
cpu_type = pvrPOWER [i ].cpu_type ;
197
+ return (int )(cpu_type );
198
+ }
199
+ #endif /* C_PGI */
200
+ #endif /* _AIX */
201
+
202
+ #ifndef __BUILTIN_CPU_SUPPORTS__
203
+ #include <string.h>
181
204
182
- if (!strcmp (cpu , "power8" ))
183
- return cpu_type == CPU_POWER8 ;
184
- if (!strcmp (cpu , "power9" ))
185
- return cpu_type == CPU_POWER9 ;
186
- return 0 ;
205
+ static int __builtin_cpu_is (const char * arg )
206
+ {
207
+ static int ipinfo = -1 ;
208
+ if (ipinfo < 0 ) {
209
+ ipinfo = cpuid ();
210
+ }
211
+ #ifdef HAVE_P10_SUPPORT
212
+ if (ipinfo == CPU_POWER10 ) {
213
+ if (!strcmp (arg , "power10" )) return 1 ;
214
+ }
215
+ #endif
216
+ if (ipinfo == CPU_POWER9 ) {
217
+ if (!strcmp (arg , "power9" )) return 1 ;
218
+ } else if (ipinfo == CPU_POWER8 ) {
219
+ if (!strcmp (arg , "power8" )) return 1 ;
220
+ #ifndef C_PGI
221
+ } else if (ipinfo == CPU_POWER6 ) {
222
+ if (!strcmp (arg , "power6" )) return 1 ;
223
+ #endif
224
+ }
225
+ return 0 ;
187
226
}
188
227
189
- #endif /* C_PGI */
228
+ static int __builtin_cpu_supports (const char * arg )
229
+ {
230
+ return 0 ;
231
+ }
232
+ #endif
190
233
191
234
static gotoblas_t * get_coretype (void ) {
192
235
@@ -196,19 +239,23 @@ static gotoblas_t *get_coretype(void) {
196
239
#endif
197
240
if (__builtin_cpu_is ("power8" ))
198
241
return & gotoblas_POWER8 ;
199
- #if (!defined __GNUC__ ) || ( __GNUC__ >= 6 )
242
+ #if (( !defined __GNUC__ ) || ( __GNUC__ >= 6 )) || defined( __clang__ )
200
243
if (__builtin_cpu_is ("power9" ))
201
244
return & gotoblas_POWER9 ;
202
245
#endif
203
246
#ifdef HAVE_P10_SUPPORT
247
+ #if defined(_AIX ) || defined(__clang__ )
248
+ if (__builtin_cpu_is ("power10" ))
249
+ #else
204
250
if (__builtin_cpu_supports ("arch_3_1" ) && __builtin_cpu_supports ("mma" ))
251
+ #endif
205
252
return & gotoblas_POWER10 ;
206
253
#endif
207
254
/* Fall back to the POWER9 implementation if the toolchain is too old or the MMA feature is not set */
208
255
#if (!defined __GNUC__ ) || ( __GNUC__ >= 11 ) || (__GNUC__ == 10 && __GNUC_MINOR__ >= 2 )
209
256
if (__builtin_cpu_is ("power10" ))
210
257
return & gotoblas_POWER9 ;
211
- #endif
258
+ #endif
212
259
return NULL ;
213
260
}
214
261
@@ -233,7 +280,7 @@ static gotoblas_t *force_coretype(char * coretype) {
233
280
case 1 : return (& gotoblas_POWER6 );
234
281
#endif
235
282
case 2 : return (& gotoblas_POWER8 );
236
- #if (!defined __GNUC__ ) || ( __GNUC__ >= 6 )
283
+ #if (( !defined __GNUC__ ) || ( __GNUC__ >= 6 )) || defined( __clang__ )
237
284
case 3 : return (& gotoblas_POWER9 );
238
285
#endif
239
286
#ifdef HAVE_P10_SUPPORT
0 commit comments