@@ -2915,7 +2915,9 @@ static bool __kmp_affinity_create_cpuinfo_map(int *line,
2915
2915
kmp_i18n_id_t *const msg_id) {
2916
2916
*msg_id = kmp_i18n_null;
2917
2917
2918
- #ifndef KMP_OS_AIX
2918
+ #if KMP_OS_AIX
2919
+ unsigned num_records = __kmp_xproc;
2920
+ #else
2919
2921
const char *filename = __kmp_cpuinfo_get_filename ();
2920
2922
const char *envvar = __kmp_cpuinfo_get_envvar ();
2921
2923
@@ -2976,9 +2978,7 @@ static bool __kmp_affinity_create_cpuinfo_map(int *line,
2976
2978
*msg_id = kmp_i18n_str_CantRewindCpuinfo;
2977
2979
return false ;
2978
2980
}
2979
- #else // KMP_OS_AIX
2980
- unsigned num_records = __kmp_xproc;
2981
- #endif
2981
+ #endif // KMP_OS_AIX
2982
2982
2983
2983
// Allocate the array of records to store the proc info in. The dummy
2984
2984
// element at the end makes the logic in filling them out easier to code.
@@ -3008,7 +3008,99 @@ static bool __kmp_affinity_create_cpuinfo_map(int *line,
3008
3008
INIT_PROC_INFO (threadInfo[i]);
3009
3009
}
3010
3010
3011
- #ifndef KMP_OS_AIX
3011
+ #if KMP_OS_AIX
3012
+ int smt_threads;
3013
+ lpar_info_format1_t cpuinfo;
3014
+ unsigned num_avail = __kmp_xproc;
3015
+
3016
+ if (__kmp_affinity.flags .verbose )
3017
+ KMP_INFORM (AffParseFilename, " KMP_AFFINITY" , " system info for topology" );
3018
+
3019
+ // Get the number of SMT threads per core.
3020
+ int retval =
3021
+ lpar_get_info (LPAR_INFO_FORMAT1, &cpuinfo, sizeof (lpar_info_format1_t ));
3022
+ if (!retval)
3023
+ smt_threads = cpuinfo.smt_threads ;
3024
+ else {
3025
+ CLEANUP_THREAD_INFO;
3026
+ *msg_id = kmp_i18n_str_UnknownTopology;
3027
+ return false ;
3028
+ }
3029
+
3030
+ // Allocate a resource set containing available system resourses.
3031
+ rsethandle_t sys_rset = rs_alloc (RS_SYSTEM);
3032
+ if (sys_rset == NULL ) {
3033
+ CLEANUP_THREAD_INFO;
3034
+ *msg_id = kmp_i18n_str_UnknownTopology;
3035
+ return false ;
3036
+ }
3037
+ // Allocate a resource set for the SRAD info.
3038
+ rsethandle_t srad = rs_alloc (RS_EMPTY);
3039
+ if (srad == NULL ) {
3040
+ rs_free (sys_rset);
3041
+ CLEANUP_THREAD_INFO;
3042
+ *msg_id = kmp_i18n_str_UnknownTopology;
3043
+ return false ;
3044
+ }
3045
+
3046
+ // Get the SRAD system detail level.
3047
+ int sradsdl = rs_getinfo (NULL , R_SRADSDL, 0 );
3048
+ if (sradsdl < 0 ) {
3049
+ rs_free (sys_rset);
3050
+ rs_free (srad);
3051
+ CLEANUP_THREAD_INFO;
3052
+ *msg_id = kmp_i18n_str_UnknownTopology;
3053
+ return false ;
3054
+ }
3055
+ // Get the number of RADs at that SRAD SDL.
3056
+ int num_rads = rs_numrads (sys_rset, sradsdl, 0 );
3057
+ if (num_rads < 0 ) {
3058
+ rs_free (sys_rset);
3059
+ rs_free (srad);
3060
+ CLEANUP_THREAD_INFO;
3061
+ *msg_id = kmp_i18n_str_UnknownTopology;
3062
+ return false ;
3063
+ }
3064
+
3065
+ // Get the maximum number of procs that may be contained in a resource set.
3066
+ int max_procs = rs_getinfo (NULL , R_MAXPROCS, 0 );
3067
+ if (max_procs < 0 ) {
3068
+ rs_free (sys_rset);
3069
+ rs_free (srad);
3070
+ CLEANUP_THREAD_INFO;
3071
+ *msg_id = kmp_i18n_str_UnknownTopology;
3072
+ return false ;
3073
+ }
3074
+
3075
+ int cur_rad = 0 ;
3076
+ int num_set = 0 ;
3077
+ for (int srad_idx = 0 ; cur_rad < num_rads && srad_idx < VMI_MAXRADS;
3078
+ ++srad_idx) {
3079
+ // Check if the SRAD is available in the RSET.
3080
+ if (rs_getrad (sys_rset, srad, sradsdl, srad_idx, 0 ) < 0 )
3081
+ continue ;
3082
+
3083
+ for (int cpu = 0 ; cpu < max_procs; cpu++) {
3084
+ // Set the info for the cpu if it is in the SRAD.
3085
+ if (rs_op (RS_TESTRESOURCE, srad, NULL , R_PROCS, cpu)) {
3086
+ threadInfo[cpu][osIdIndex] = cpu;
3087
+ threadInfo[cpu][pkgIdIndex] = cur_rad;
3088
+ threadInfo[cpu][coreIdIndex] = cpu / smt_threads;
3089
+ ++num_set;
3090
+ if (num_set >= num_avail) {
3091
+ // Done if all available CPUs have been set.
3092
+ break ;
3093
+ }
3094
+ }
3095
+ }
3096
+ ++cur_rad;
3097
+ }
3098
+ rs_free (sys_rset);
3099
+ rs_free (srad);
3100
+
3101
+ // The topology is already sorted.
3102
+
3103
+ #else // !KMP_OS_AIX
3012
3104
unsigned num_avail = 0 ;
3013
3105
*line = 0 ;
3014
3106
#if KMP_ARCH_S390X
@@ -3256,98 +3348,6 @@ static bool __kmp_affinity_create_cpuinfo_map(int *line,
3256
3348
qsort (threadInfo, num_avail, sizeof (*threadInfo),
3257
3349
__kmp_affinity_cmp_ProcCpuInfo_phys_id);
3258
3350
3259
- #else // KMP_OS_AIX
3260
- int smt_threads;
3261
- lpar_info_format1_t cpuinfo;
3262
- unsigned num_avail = __kmp_xproc;
3263
-
3264
- if (__kmp_affinity.flags .verbose )
3265
- KMP_INFORM (AffParseFilename, " KMP_AFFINITY" , " system info for topology" );
3266
-
3267
- // Get the number of SMT threads per core.
3268
- int retval =
3269
- lpar_get_info (LPAR_INFO_FORMAT1, &cpuinfo, sizeof (lpar_info_format1_t ));
3270
- if (!retval)
3271
- smt_threads = cpuinfo.smt_threads ;
3272
- else {
3273
- CLEANUP_THREAD_INFO;
3274
- *msg_id = kmp_i18n_str_UnknownTopology;
3275
- return false ;
3276
- }
3277
-
3278
- // Allocate a resource set containing available system resourses.
3279
- rsethandle_t sys_rset = rs_alloc (RS_SYSTEM);
3280
- if (sys_rset == NULL ) {
3281
- CLEANUP_THREAD_INFO;
3282
- *msg_id = kmp_i18n_str_UnknownTopology;
3283
- return false ;
3284
- }
3285
- // Allocate a resource set for the SRAD info.
3286
- rsethandle_t srad = rs_alloc (RS_EMPTY);
3287
- if (srad == NULL ) {
3288
- rs_free (sys_rset);
3289
- CLEANUP_THREAD_INFO;
3290
- *msg_id = kmp_i18n_str_UnknownTopology;
3291
- return false ;
3292
- }
3293
-
3294
- // Get the SRAD system detail level.
3295
- int sradsdl = rs_getinfo (NULL , R_SRADSDL, 0 );
3296
- if (sradsdl < 0 ) {
3297
- rs_free (sys_rset);
3298
- rs_free (srad);
3299
- CLEANUP_THREAD_INFO;
3300
- *msg_id = kmp_i18n_str_UnknownTopology;
3301
- return false ;
3302
- }
3303
- // Get the number of RADs at that SRAD SDL.
3304
- int num_rads = rs_numrads (sys_rset, sradsdl, 0 );
3305
- if (num_rads < 0 ) {
3306
- rs_free (sys_rset);
3307
- rs_free (srad);
3308
- CLEANUP_THREAD_INFO;
3309
- *msg_id = kmp_i18n_str_UnknownTopology;
3310
- return false ;
3311
- }
3312
-
3313
- // Get the maximum number of procs that may be contained in a resource set.
3314
- int max_procs = rs_getinfo (NULL , R_MAXPROCS, 0 );
3315
- if (max_procs < 0 ) {
3316
- rs_free (sys_rset);
3317
- rs_free (srad);
3318
- CLEANUP_THREAD_INFO;
3319
- *msg_id = kmp_i18n_str_UnknownTopology;
3320
- return false ;
3321
- }
3322
-
3323
- int cur_rad = 0 ;
3324
- int num_set = 0 ;
3325
- for (int srad_idx = 0 ; cur_rad < num_rads && srad_idx < VMI_MAXRADS;
3326
- ++srad_idx) {
3327
- // Check if the SRAD is available in the RSET.
3328
- if (rs_getrad (sys_rset, srad, sradsdl, srad_idx, 0 ) < 0 )
3329
- continue ;
3330
-
3331
- for (int cpu = 0 ; cpu < max_procs; cpu++) {
3332
- // Set the info for the cpu if it is in the SRAD.
3333
- if (rs_op (RS_TESTRESOURCE, srad, NULL , R_PROCS, cpu)) {
3334
- threadInfo[cpu][osIdIndex] = cpu;
3335
- threadInfo[cpu][pkgIdIndex] = cur_rad;
3336
- threadInfo[cpu][coreIdIndex] = cpu / smt_threads;
3337
- ++num_set;
3338
- if (num_set >= num_avail) {
3339
- // Done if all available CPUs have been set.
3340
- break ;
3341
- }
3342
- }
3343
- }
3344
- ++cur_rad;
3345
- }
3346
- rs_free (sys_rset);
3347
- rs_free (srad);
3348
-
3349
- // The topology is already sorted.
3350
-
3351
3351
#endif // KMP_OS_AIX
3352
3352
3353
3353
// The table is now sorted by pkgId / coreId / threadId, but we really don't
@@ -4941,7 +4941,7 @@ void __kmp_affinity_uninitialize(void) {
4941
4941
}
4942
4942
if (__kmp_affin_origMask != NULL ) {
4943
4943
if (KMP_AFFINITY_CAPABLE ()) {
4944
- #ifdef KMP_OS_AIX
4944
+ #if KMP_OS_AIX
4945
4945
// Uninitialize by unbinding the thread.
4946
4946
bindprocessor (BINDTHREAD, thread_self (), PROCESSOR_CLASS_ANY);
4947
4947
#else
@@ -5705,7 +5705,7 @@ extern "C"
5705
5705
" set full mask for thread %d\n " ,
5706
5706
gtid));
5707
5707
KMP_DEBUG_ASSERT (__kmp_affin_fullMask != NULL );
5708
- #ifdef KMP_OS_AIX
5708
+ #if KMP_OS_AIX
5709
5709
return bindprocessor (BINDTHREAD, thread_self (), PROCESSOR_CLASS_ANY);
5710
5710
#else
5711
5711
return __kmp_set_system_affinity (__kmp_affin_fullMask, FALSE );
0 commit comments