@@ -13,25 +13,25 @@ extern gotoblas_t gotoblas_POWER10;
1313extern void openblas_warning (int verbose , const char * msg );
1414
1515static char * corename [] = {
16- "unknown" ,
17- "POWER6" ,
18- "POWER8" ,
19- "POWER9" ,
20- "POWER10"
16+ "unknown" ,
17+ "POWER6" ,
18+ "POWER8" ,
19+ "POWER9" ,
20+ "POWER10"
2121};
2222
2323#define NUM_CORETYPES 5
2424
2525char * gotoblas_corename (void ) {
26- if (gotoblas == & gotoblas_POWER6 ) return corename [1 ];
27- if (gotoblas == & gotoblas_POWER8 ) return corename [2 ];
26+ if (gotoblas == & gotoblas_POWER6 ) return corename [1 ];
27+ if (gotoblas == & gotoblas_POWER8 ) return corename [2 ];
2828#if (!defined __GNUC__ ) || ( __GNUC__ >= 6 )
29- if (gotoblas == & gotoblas_POWER9 ) return corename [3 ];
29+ if (gotoblas == & gotoblas_POWER9 ) return corename [3 ];
3030#endif
3131#ifdef HAVE_P10_SUPPORT
32- if (gotoblas == & gotoblas_POWER10 ) return corename [4 ];
32+ if (gotoblas == & gotoblas_POWER10 ) return corename [4 ];
3333#endif
34- return corename [0 ];
34+ return corename [0 ];
3535}
3636
3737#ifdef _AIX
@@ -90,98 +90,98 @@ static int __builtin_cpu_supports(char* arg)
9090
9191static gotoblas_t * get_coretype (void ) {
9292
93- if (__builtin_cpu_supports ("power6" ))
94- return & gotoblas_POWER6 ;
95- if (__builtin_cpu_supports ("power8" ))
96- return & gotoblas_POWER8 ;
93+ if (__builtin_cpu_supports ("power6" ))
94+ return & gotoblas_POWER6 ;
95+ if (__builtin_cpu_supports ("power8" ))
96+ return & gotoblas_POWER8 ;
9797#if (!defined __GNUC__ ) || ( __GNUC__ >= 6 )
98- if (__builtin_cpu_supports ("power9" ))
99- return & gotoblas_POWER9 ;
98+ if (__builtin_cpu_supports ("power9" ))
99+ return & gotoblas_POWER9 ;
100100#endif
101101#ifdef HAVE_P10_SUPPORT
102102#ifdef _AIX
103103 if (__builtin_cpu_supports ("power10" ))
104104#else
105105 if (__builtin_cpu_supports ("arch_3_1" ) && __builtin_cpu_supports ("mma" ))
106106#endif
107- return & gotoblas_POWER10 ;
107+ return & gotoblas_POWER10 ;
108108#endif
109- /* Fall back to the POWER9 implementation if the toolchain is too old or the MMA feature is not set */
109+ /* Fall back to the POWER9 implementation if the toolchain is too old or the MMA feature is not set */
110110#if (!defined __GNUC__ ) || ( __GNUC__ < 11 ) || (__GNUC__ == 10 && __GNUC_MINOR__ < 2 )
111- if (__builtin_cpu_supports ("power10" ))
112- return & gotoblas_POWER9 ;
113- #endif
114- return NULL ;
111+ if (__builtin_cpu_supports ("power10" ))
112+ return & gotoblas_POWER9 ;
113+ #endif
114+ return NULL ;
115115}
116116
117117static gotoblas_t * force_coretype (char * coretype ) {
118118
119- int i ;
120- int found = -1 ;
121- char message [128 ];
122-
123- for ( i = 0 ; i < NUM_CORETYPES ; i ++ )
124- {
125- if (!strncasecmp (coretype , corename [i ], 20 ))
126- {
127- found = i ;
128- break ;
129- }
130- }
131-
132- switch (found )
133- {
134- case 1 : return (& gotoblas_POWER6 );
135- case 2 : return (& gotoblas_POWER8 );
119+ int i ;
120+ int found = -1 ;
121+ char message [128 ];
122+
123+ for ( i = 0 ; i < NUM_CORETYPES ; i ++ )
124+ {
125+ if (!strncasecmp (coretype , corename [i ], 20 ))
126+ {
127+ found = i ;
128+ break ;
129+ }
130+ }
131+
132+ switch (found )
133+ {
134+ case 1 : return (& gotoblas_POWER6 );
135+ case 2 : return (& gotoblas_POWER8 );
136136#if (!defined __GNUC__ ) || ( __GNUC__ >= 6 )
137- case 3 : return (& gotoblas_POWER9 );
137+ case 3 : return (& gotoblas_POWER9 );
138138#endif
139139#ifdef HAVE_P10_SUPPORT
140- case 4 : return (& gotoblas_POWER10 );
140+ case 4 : return (& gotoblas_POWER10 );
141141#endif
142- default : return NULL ;
143- }
144- snprintf (message , 128 , "Core not found: %s\n" , coretype );
145- openblas_warning (1 , message );
142+ default : return NULL ;
143+ }
144+ snprintf (message , 128 , "Core not found: %s\n" , coretype );
145+ openblas_warning (1 , message );
146146}
147147
148148void gotoblas_dynamic_init (void ) {
149149
150- char coremsg [128 ];
151- char coren [22 ];
152- char * p ;
153-
154-
155- if (gotoblas ) return ;
156-
157- p = getenv ("OPENBLAS_CORETYPE" );
158- if ( p )
159- {
160- gotoblas = force_coretype (p );
161- }
162- else
163- {
164- gotoblas = get_coretype ();
165- }
166-
167- if (gotoblas == NULL )
168- {
169- snprintf (coremsg , 128 , "Falling back to POWER8 core\n" );
170- openblas_warning (1 , coremsg );
171- gotoblas = & gotoblas_POWER8 ;
172- }
173-
174- if (gotoblas && gotoblas -> init ) {
175- strncpy (coren ,gotoblas_corename (),20 );
176- sprintf (coremsg , "Core: %s\n" ,coren );
177- openblas_warning (2 , coremsg );
178- gotoblas -> init ();
179- } else {
180- openblas_warning (0 , "OpenBLAS : Architecture Initialization failed. No initialization function found.\n" );
181- exit (1 );
182- }
150+ char coremsg [128 ];
151+ char coren [22 ];
152+ char * p ;
153+
154+
155+ if (gotoblas ) return ;
156+
157+ p = getenv ("OPENBLAS_CORETYPE" );
158+ if ( p )
159+ {
160+ gotoblas = force_coretype (p );
161+ }
162+ else
163+ {
164+ gotoblas = get_coretype ();
165+ }
166+
167+ if (gotoblas == NULL )
168+ {
169+ snprintf (coremsg , 128 , "Falling back to POWER8 core\n" );
170+ openblas_warning (1 , coremsg );
171+ gotoblas = & gotoblas_POWER8 ;
172+ }
173+
174+ if (gotoblas && gotoblas -> init ) {
175+ strncpy (coren ,gotoblas_corename (),20 );
176+ sprintf (coremsg , "Core: %s\n" ,coren );
177+ openblas_warning (2 , coremsg );
178+ gotoblas -> init ();
179+ } else {
180+ openblas_warning (0 , "OpenBLAS : Architecture Initialization failed. No initialization function found.\n" );
181+ exit (1 );
182+ }
183183}
184184
185185void gotoblas_dynamic_quit (void ) {
186- gotoblas = NULL ;
186+ gotoblas = NULL ;
187187}
0 commit comments