[Openmp-commits] [PATCH] D40357: Enable thread affinity for Power

Jonas Hahnfeld via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Wed Nov 22 07:41:20 PST 2017


Hahnfeld created this revision.

To make this work according to the OpenMP spec, the runtime needs
information about the hardware topology. On Linux the default way
is to parse /proc/cpuinfo which contains this information for x86
machines but (at least) not for Power architectures.

Fortunately, there is a different code path which is able to get
that data from sysfs. The needed patch has landed in 2006 for
Linux 2.6.16 which is safe to assume nowadays (even RHEL 5 had
a kernel version derived from 2.6.18, and we are now at RHEL 7!).


https://reviews.llvm.org/D40357

Files:
  runtime/src/kmp_affinity.cpp
  runtime/src/kmp_os.h


Index: runtime/src/kmp_os.h
===================================================================
--- runtime/src/kmp_os.h
+++ runtime/src/kmp_os.h
@@ -61,7 +61,7 @@
 #error Unknown compiler
 #endif
 
-#if (KMP_OS_LINUX || KMP_OS_WINDOWS) && !KMP_OS_CNK && !KMP_ARCH_PPC64
+#if (KMP_OS_LINUX || KMP_OS_WINDOWS) && !KMP_OS_CNK
 #define KMP_AFFINITY_SUPPORTED 1
 #if KMP_OS_WINDOWS && KMP_ARCH_X86_64
 #define KMP_GROUP_AFFINITY 1
@@ -859,9 +859,6 @@
 #endif
 
 // Switches for OSS builds
-#ifndef USE_SYSFS_INFO
-#define USE_SYSFS_INFO 0
-#endif
 #ifndef USE_CMPXCHG_FIX
 #define USE_CMPXCHG_FIX 1
 #endif
Index: runtime/src/kmp_affinity.cpp
===================================================================
--- runtime/src/kmp_affinity.cpp
+++ runtime/src/kmp_affinity.cpp
@@ -1836,7 +1836,7 @@
         if (threadInfo[num_avail][osIdIndex] != UINT_MAX)
           goto dup_field;
         threadInfo[num_avail][osIdIndex] = val;
-#if KMP_OS_LINUX && USE_SYSFS_INFO
+#if KMP_OS_LINUX && !(KMP_ARCH_X86 || KMP_ARCH_X86_64)
         char path[256];
         KMP_SNPRINTF(
             path, sizeof(path),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40357.123944.patch
Type: text/x-patch
Size: 1103 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20171122/c53da708/attachment.bin>


More information about the Openmp-commits mailing list