Index: openmp/trunk/runtime/src/kmp.h =================================================================== --- openmp/trunk/runtime/src/kmp.h +++ openmp/trunk/runtime/src/kmp.h @@ -781,6 +781,11 @@ #if KMP_AFFINITY_SUPPORTED #define KMP_PLACE_ALL (-1) #define KMP_PLACE_UNDEFINED (-2) +// Is KMP_AFFINITY is being used instead of OMP_PROC_BIND/OMP_PLACES? +#define KMP_AFFINITY_NON_PROC_BIND \ + ((__kmp_nested_proc_bind.bind_types[0] == proc_bind_false || \ + __kmp_nested_proc_bind.bind_types[0] == proc_bind_intel) && \ + (__kmp_affinity_num_masks > 0 || __kmp_affinity_type == affinity_balanced)) #endif /* KMP_AFFINITY_SUPPORTED */ extern int __kmp_affinity_num_places; Index: openmp/trunk/runtime/src/kmp_affinity.cpp =================================================================== --- openmp/trunk/runtime/src/kmp_affinity.cpp +++ openmp/trunk/runtime/src/kmp_affinity.cpp @@ -3957,8 +3957,20 @@ KMP_ASSERT(__kmp_affinity_type == affinity_none); \ KMP_ASSERT(address2os == NULL); \ __kmp_apply_thread_places(NULL, 0); \ + __kmp_create_affinity_none_places(); \ return; +// Create a one element mask array (set of places) which only contains the +// initial process's affinity mask +static void __kmp_create_affinity_none_places() { + KMP_ASSERT(__kmp_affin_fullMask != NULL); + KMP_ASSERT(__kmp_affinity_type == affinity_none); + __kmp_affinity_num_masks = 1; + KMP_CPU_ALLOC_ARRAY(__kmp_affinity_masks, __kmp_affinity_num_masks); + kmp_affin_mask_t *dest = KMP_CPU_INDEX(__kmp_affinity_masks, 0); + KMP_CPU_COPY(dest, __kmp_affin_fullMask); +} + static int __kmp_affinity_cmp_Address_child_num(const void *a, const void *b) { const Address *aa = &(((const AddrUnsPair *)a)->first); const Address *bb = &(((const AddrUnsPair *)b)->first); @@ -4295,6 +4307,7 @@ KMP_WARNING(ErrorInitializeAffinity); } __kmp_affinity_type = affinity_none; + __kmp_create_affinity_none_places(); KMP_AFFINITY_DISABLE(); return; } @@ -4578,7 +4591,7 @@ int i; #if OMP_40_ENABLED - if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_intel) + if (KMP_AFFINITY_NON_PROC_BIND) #endif { if ((__kmp_affinity_type == affinity_none) || @@ -4589,7 +4602,7 @@ } #endif KMP_ASSERT(__kmp_affin_fullMask != NULL); - i = KMP_PLACE_ALL; + i = 0; mask = __kmp_affin_fullMask; } else { KMP_DEBUG_ASSERT(__kmp_affinity_num_masks > 0); 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 @@ -691,6 +691,9 @@ } if (!KMP_AFFINITY_CAPABLE()) return 0; + if (KMP_AFFINITY_NON_PROC_BIND) { + return 1; + } gtid = __kmp_entry_gtid(); thread = __kmp_thread_from_gtid(gtid); first_place = thread->th.th_first_place; @@ -718,6 +721,10 @@ return; gtid = __kmp_entry_gtid(); thread = __kmp_thread_from_gtid(gtid); + if (KMP_AFFINITY_NON_PROC_BIND) { + place_nums[0] = thread->th.th_current_place; + return; + } first_place = thread->th.th_first_place; last_place = thread->th.th_last_place; if (first_place < 0 || last_place < 0) Index: openmp/trunk/runtime/src/kmp_settings.cpp =================================================================== --- openmp/trunk/runtime/src/kmp_settings.cpp +++ openmp/trunk/runtime/src/kmp_settings.cpp @@ -5407,6 +5407,8 @@ KMP_DEBUG_ASSERT(__kmp_affinity_type != affinity_default); #if OMP_40_ENABLED KMP_DEBUG_ASSERT(__kmp_nested_proc_bind.bind_types[0] != proc_bind_default); + K_DIAG(1, ("__kmp_nested_proc_bind.bind_types[0] == %d\n", + __kmp_nested_proc_bind.bind_types[0])); #endif }