diff options
author | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2016-06-13 17:01:26 +0000 |
---|---|---|
committer | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2016-06-13 17:01:26 +0000 |
commit | 34c72c4773989d65460542f6425fda8b5d509586 (patch) | |
tree | fd132de6f1a97b8069b425518426f23ac83a13a4 /openmp | |
parent | 5a299da55d1dce1b2b23a708893e25f62330d9b3 (diff) | |
download | bcm5719-llvm-34c72c4773989d65460542f6425fda8b5d509586.tar.gz bcm5719-llvm-34c72c4773989d65460542f6425fda8b5d509586.zip |
Fix bitmask complement operation
The bitmask complement operation doesn't consider the max proc id which means
something like !{0} will be translated to {1,2,3,4,...,600,601,...,1023} on a
Linux system even though there aren't 600 processors on said system. This
change has the complement bitmask and-ed with the fullmask so that it will only
contain valid processors.
Differential Revision: http://reviews.llvm.org/D21245
llvm-svn: 272561
Diffstat (limited to 'openmp')
-rw-r--r-- | openmp/runtime/src/kmp.h | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h index aa72a0c71d7..02c97f84b79 100644 --- a/openmp/runtime/src/kmp.h +++ b/openmp/runtime/src/kmp.h @@ -536,6 +536,7 @@ typedef hwloc_cpuset_t kmp_affin_mask_t; # define KMP_CPU_CLR(i,mask) hwloc_bitmap_clr((hwloc_cpuset_t)mask, (unsigned)i) # define KMP_CPU_ZERO(mask) hwloc_bitmap_zero((hwloc_cpuset_t)mask) # define KMP_CPU_COPY(dest, src) hwloc_bitmap_copy((hwloc_cpuset_t)dest, (hwloc_cpuset_t)src) +# define KMP_CPU_AND(dest, src) hwloc_bitmap_and((hwloc_cpuset_t)dest, (hwloc_cpuset_t)dest, (hwloc_cpuset_t)src) # define KMP_CPU_COMPLEMENT(max_bit_number, mask) \ { \ unsigned i; \ @@ -546,6 +547,8 @@ typedef hwloc_cpuset_t kmp_affin_mask_t; hwloc_bitmap_set((hwloc_cpuset_t)mask, i); \ } \ } \ + hwloc_bitmap_and((hwloc_cpuset_t)mask, (hwloc_cpuset_t)mask, \ + (hwloc_cpuset_t)__kmp_affinity_get_fullMask()); \ } \ # define KMP_CPU_UNION(dest, src) hwloc_bitmap_or((hwloc_cpuset_t)dest, (hwloc_cpuset_t)dest, (hwloc_cpuset_t)src) @@ -638,6 +641,15 @@ typedef unsigned char kmp_affin_mask_t; } \ } +# define KMP_CPU_AND(dest, src) \ + { \ + size_t __i; \ + for (__i = 0; __i < __kmp_affin_mask_size; __i++) { \ + ((kmp_affin_mask_t *)(dest))[__i] \ + &= ((kmp_affin_mask_t *)(src))[__i]; \ + } \ + } + # define KMP_CPU_COMPLEMENT(max_bit_number, mask) \ { \ size_t __i; \ @@ -645,6 +657,7 @@ typedef unsigned char kmp_affin_mask_t; ((kmp_affin_mask_t *)(mask))[__i] \ = ~((kmp_affin_mask_t *)(mask))[__i]; \ } \ + KMP_CPU_AND(mask, __kmp_affinity_get_fullMask()); \ } # define KMP_CPU_UNION(dest, src) \ @@ -717,6 +730,15 @@ extern int __kmp_num_proc_groups; } \ } +# define KMP_CPU_AND(dest, src) \ + { \ + int __i; \ + for (__i = 0; __i < __kmp_num_proc_groups; __i++) { \ + ((kmp_affin_mask_t *)(dest))[__i] \ + &= ((kmp_affin_mask_t *)(src))[__i]; \ + } \ + } + # define KMP_CPU_COMPLEMENT(max_bit_number, mask) \ { \ int __i; \ @@ -724,6 +746,7 @@ extern int __kmp_num_proc_groups; ((kmp_affin_mask_t *)(mask))[__i] \ = ~((kmp_affin_mask_t *)(mask))[__i]; \ } \ + KMP_CPU_AND(mask, __kmp_affinity_get_fullMask()); \ } # define KMP_CPU_UNION(dest, src) \ @@ -758,7 +781,8 @@ typedef DWORD kmp_affin_mask_t; /* for compatibility with older winbase.h */ # define KMP_CPU_CLR(i,mask) (*(mask) &= ~(((kmp_affin_mask_t)1) << (i))) # define KMP_CPU_ZERO(mask) (*(mask) = 0) # define KMP_CPU_COPY(dest, src) (*(dest) = *(src)) -# define KMP_CPU_COMPLEMENT(max_bit_number, mask) (*(mask) = ~*(mask)) +# 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_UNION(dest, src) (*(dest) |= *(src)) # endif /* KMP_GROUP_AFFINITY */ @@ -863,9 +887,7 @@ extern int __kmp_get_system_affinity(kmp_affin_mask_t *mask, int abort_on_error) extern int __kmp_set_system_affinity(kmp_affin_mask_t const *mask, int abort_on_error); extern void __kmp_affinity_bind_thread(int which); -# if KMP_OS_LINUX extern kmp_affin_mask_t *__kmp_affinity_get_fullMask(); -# endif /* KMP_OS_LINUX */ extern char const * __kmp_cpuinfo_file; #endif /* KMP_AFFINITY_SUPPORTED */ |