From ce528acf0d04d80b3a284ba3c2dd281ce706e15e Mon Sep 17 00:00:00 2001 From: Jonas Hahnfeld Date: Fri, 8 Dec 2017 15:07:05 +0000 Subject: Fix thread affinity on non-x86 Linux To make thread affinity 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 AArch64 and 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!). Differential Revision: https://reviews.llvm.org/D40357 llvm-svn: 320151 --- openmp/runtime/src/kmp_affinity.cpp | 2 +- openmp/runtime/src/kmp_os.h | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'openmp/runtime/src') diff --git a/openmp/runtime/src/kmp_affinity.cpp b/openmp/runtime/src/kmp_affinity.cpp index c2813970a12..d7a0eda0d92 100644 --- a/openmp/runtime/src/kmp_affinity.cpp +++ b/openmp/runtime/src/kmp_affinity.cpp @@ -2030,7 +2030,7 @@ static int __kmp_affinity_create_cpuinfo_map(AddrUnsPair **address2os, 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), diff --git a/openmp/runtime/src/kmp_os.h b/openmp/runtime/src/kmp_os.h index 79b3fe2f31e..fbd3513a42f 100644 --- a/openmp/runtime/src/kmp_os.h +++ b/openmp/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 @@ typedef void (*microtask_t)(int *gtid, int *npr, ...); #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 -- cgit v1.2.3