Index: runtime/src/kmp.h =================================================================== --- runtime/src/kmp.h +++ runtime/src/kmp.h @@ -548,7 +548,7 @@ } \ } \ hwloc_bitmap_and((hwloc_cpuset_t)mask, (hwloc_cpuset_t)mask, \ - (hwloc_cpuset_t)__kmp_affinity_get_fullMask()); \ + (hwloc_cpuset_t)fullMask); \ } \ # define KMP_CPU_UNION(dest, src) hwloc_bitmap_or((hwloc_cpuset_t)dest, (hwloc_cpuset_t)dest, (hwloc_cpuset_t)src) @@ -657,7 +657,7 @@ ((kmp_affin_mask_t *)(mask))[__i] \ = ~((kmp_affin_mask_t *)(mask))[__i]; \ } \ - KMP_CPU_AND(mask, __kmp_affinity_get_fullMask()); \ + KMP_CPU_AND(mask, fullMask); \ } # define KMP_CPU_UNION(dest, src) \ @@ -746,7 +746,7 @@ ((kmp_affin_mask_t *)(mask))[__i] \ = ~((kmp_affin_mask_t *)(mask))[__i]; \ } \ - KMP_CPU_AND(mask, __kmp_affinity_get_fullMask()); \ + KMP_CPU_AND(mask, fullMask); \ } # define KMP_CPU_UNION(dest, src) \ @@ -782,7 +782,7 @@ # define KMP_CPU_ZERO(mask) (*(mask) = 0) # define KMP_CPU_COPY(dest, src) (*(dest) = *(src)) # define KMP_CPU_AND(dest, src) (*(dest) &= *(src)) -# define KMP_CPU_COMPLEMENT(max_bit_number, mask) (*(mask) = ~*(mask)); KMP_CPU_AND(mask, __kmp_affinity_get_fullMask()) +# define KMP_CPU_COMPLEMENT(max_bit_number, mask) (*(mask) = ~*(mask)); KMP_CPU_AND(mask, fullMask) # define KMP_CPU_UNION(dest, src) (*(dest) |= *(src)) # endif /* KMP_GROUP_AFFINITY */ @@ -887,7 +887,7 @@ extern int __kmp_set_system_affinity(kmp_affin_mask_t const *mask, int abort_on_error); extern void __kmp_affinity_bind_thread(int which); -extern kmp_affin_mask_t *__kmp_affinity_get_fullMask(); +extern kmp_affin_mask_t *fullMask; extern char const * __kmp_cpuinfo_file; #endif /* KMP_AFFINITY_SUPPORTED */ Index: runtime/src/kmp_affinity.cpp =================================================================== --- runtime/src/kmp_affinity.cpp +++ runtime/src/kmp_affinity.cpp @@ -242,11 +242,7 @@ // restore the mask, and it could be needed later, so saving it is just an // optimization to avoid calling kmp_get_system_affinity() again. // -static kmp_affin_mask_t *fullMask = NULL; - -kmp_affin_mask_t * -__kmp_affinity_get_fullMask() { return fullMask; } - +kmp_affin_mask_t *fullMask = NULL; static int nCoresPerPkg, nPackages; static int __kmp_nThreadsPerCore; @@ -3325,17 +3321,17 @@ if (! KMP_CPU_ISSET(j, previousMask)) { continue; } - else if ((j+stride > maxOsId) || (j+stride < 0) || + if ((j+stride > maxOsId) || (j+stride < 0) || + (! KMP_CPU_ISSET(j, fullMask)) || (! KMP_CPU_ISSET(j+stride, KMP_CPU_INDEX(osId2Mask, j+stride)))) { if ((__kmp_affinity_verbose || (__kmp_affinity_warnings && (__kmp_affinity_type != affinity_none))) && i < count - 1) { KMP_WARNING(AffIgnoreInvalidProcID, j+stride); } + continue; } - else { - KMP_CPU_SET(j+stride, tempMask); - setSize++; - } + KMP_CPU_SET(j+stride, tempMask); + setSize++; } } KMP_CPU_ZERO(tempMask); @@ -4275,14 +4271,13 @@ int num_procs = 0; KMP_CPU_SET_ITERATE(proc, ((kmp_affin_mask_t*)(*mask))) { + if (! KMP_CPU_ISSET(proc, fullMask)) { + KMP_FATAL(AffinityInvalidMask, "kmp_set_affinity"); + } if (! KMP_CPU_ISSET(proc, (kmp_affin_mask_t *)(*mask))) { continue; } num_procs++; - if (! KMP_CPU_ISSET(proc, fullMask)) { - KMP_FATAL(AffinityInvalidMask, "kmp_set_affinity"); - break; - } } if (num_procs == 0) { KMP_FATAL(AffinityInvalidMask, "kmp_set_affinity"); Index: runtime/src/kmp_ftn_entry.h =================================================================== --- runtime/src/kmp_ftn_entry.h +++ runtime/src/kmp_ftn_entry.h @@ -718,8 +718,10 @@ return 0; kmp_affin_mask_t *mask = KMP_CPU_INDEX(__kmp_affinity_masks, place_num); KMP_CPU_SET_ITERATE(i, mask) { - if ( !KMP_CPU_ISSET(i, mask) ) + if ((! KMP_CPU_ISSET(i, fullMask)) || + (!KMP_CPU_ISSET(i, mask))) { continue; + } ++retval; } return retval; @@ -741,8 +743,10 @@ kmp_affin_mask_t *mask = KMP_CPU_INDEX(__kmp_affinity_masks, place_num); j = 0; KMP_CPU_SET_ITERATE(i, mask) { - if ( !KMP_CPU_ISSET(i, mask) ) + if ((! KMP_CPU_ISSET(i, fullMask)) || + (!KMP_CPU_ISSET(i, mask))) { continue; + } ids[j++] = i; } #endif Index: runtime/src/kmp_runtime.c =================================================================== --- runtime/src/kmp_runtime.c +++ runtime/src/kmp_runtime.c @@ -4424,7 +4424,7 @@ ); } } - __kmp_set_system_affinity( __kmp_affinity_get_fullMask(), TRUE ); + __kmp_set_system_affinity( fullMask, TRUE ); } } #endif