Index: runtime/src/kmp.h =================================================================== --- runtime/src/kmp.h +++ runtime/src/kmp.h @@ -3164,6 +3164,7 @@ extern void __kmp_affinity_determine_capable( const char *env_var ); extern int __kmp_aux_set_affinity(void **mask); extern int __kmp_aux_get_affinity(void **mask); +extern int __kmp_aux_get_affinity_max_proc(); extern int __kmp_aux_set_affinity_mask_proc(int proc, void **mask); extern int __kmp_aux_unset_affinity_mask_proc(int proc, void **mask); extern int __kmp_aux_get_affinity_mask_proc(int proc, void **mask); Index: runtime/src/kmp_affinity.cpp =================================================================== --- runtime/src/kmp_affinity.cpp +++ runtime/src/kmp_affinity.cpp @@ -4509,6 +4509,19 @@ } int +__kmp_aux_get_affinity_max_proc() { + if (! KMP_AFFINITY_CAPABLE()) { + return 0; + } +#if KMP_GROUP_AFFINITY + if ( __kmp_num_proc_groups > 1 ) { + return (int)(__kmp_num_proc_groups*sizeof(DWORD_PTR)*CHAR_BIT); + } +#endif + return __kmp_xproc; +} + +int __kmp_aux_set_affinity_mask_proc(int proc, void **mask) { int retval; @@ -4532,11 +4545,7 @@ } } - if ((proc < 0) -# if !KMP_USE_HWLOC - || ((unsigned)proc >= KMP_CPU_SETSIZE) -# endif - ) { + if ((proc < 0) || (proc >= __kmp_aux_get_affinity_max_proc())) { return -1; } if (! KMP_CPU_ISSET(proc, __kmp_affin_fullMask)) { @@ -4572,11 +4581,7 @@ } } - if ((proc < 0) -# if !KMP_USE_HWLOC - || ((unsigned)proc >= KMP_CPU_SETSIZE) -# endif - ) { + if ((proc < 0) || (proc >= __kmp_aux_get_affinity_max_proc())) { return -1; } if (! KMP_CPU_ISSET(proc, __kmp_affin_fullMask)) { @@ -4612,11 +4617,7 @@ } } - if ((proc < 0) -# if !KMP_USE_HWLOC - || ((unsigned)proc >= KMP_CPU_SETSIZE) -# endif - ) { + if ((proc < 0) || (proc >= __kmp_aux_get_affinity_max_proc())) { return -1; } if (! KMP_CPU_ISSET(proc, __kmp_affin_fullMask)) { Index: runtime/src/kmp_ftn_entry.h =================================================================== --- runtime/src/kmp_ftn_entry.h +++ runtime/src/kmp_ftn_entry.h @@ -266,16 +266,7 @@ if ( ! TCR_4(__kmp_init_middle) ) { __kmp_middle_initialize(); } - if ( ! ( KMP_AFFINITY_CAPABLE() ) ) { - return 0; - } - - #if KMP_GROUP_AFFINITY - if ( __kmp_num_proc_groups > 1 ) { - return (int)(__kmp_num_proc_groups*sizeof(DWORD_PTR)*CHAR_BIT); - } - #endif /* KMP_GROUP_AFFINITY */ - return __kmp_xproc; + return __kmp_aux_get_affinity_max_proc(); #endif }