Index: openmp/trunk/runtime/src/kmp.h =================================================================== --- openmp/trunk/runtime/src/kmp.h +++ openmp/trunk/runtime/src/kmp.h @@ -3170,6 +3170,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: openmp/trunk/runtime/src/kmp_affinity.cpp =================================================================== --- openmp/trunk/runtime/src/kmp_affinity.cpp +++ openmp/trunk/runtime/src/kmp_affinity.cpp @@ -4534,6 +4534,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; @@ -4557,11 +4570,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)) { @@ -4597,11 +4606,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)) { @@ -4637,11 +4642,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: openmp/trunk/runtime/src/kmp_ftn_entry.h =================================================================== --- openmp/trunk/runtime/src/kmp_ftn_entry.h +++ openmp/trunk/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 }