From 2ba5d820e2b0e5016ec706e324060a329f9a83a3 Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Thu, 2 Jun 2022 17:10:29 +0100 Subject: [OpenMP] omp_get_proc_id uses sched_getcpu fallback on FreeBSD 13.1 and above. Reviewers: jlpeyton, jdoerfert Reviewed-By: jlpeyton Differential-Revision: https://reviews.llvm.org/D126408 --- openmp/runtime/src/kmp_os.h | 6 ++++++ openmp/runtime/src/ompt-general.cpp | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'openmp/runtime') diff --git a/openmp/runtime/src/kmp_os.h b/openmp/runtime/src/kmp_os.h index 5806635..5db97bb 100644 --- a/openmp/runtime/src/kmp_os.h +++ b/openmp/runtime/src/kmp_os.h @@ -87,6 +87,12 @@ #define KMP_GROUP_AFFINITY 0 #endif +#if (KMP_OS_LINUX || (KMP_OS_FREEBSD && __FreeBSD_version >= 1301000)) +#define KMP_HAVE_SCHED_GETCPU 1 +#else +#define KMP_HAVE_SCHED_GETCPU 0 +#endif + /* Check for quad-precision extension. */ #define KMP_HAVE_QUAD 0 #if KMP_ARCH_X86 || KMP_ARCH_X86_64 diff --git a/openmp/runtime/src/ompt-general.cpp b/openmp/runtime/src/ompt-general.cpp index 1bc3bea..0bee7e7 100644 --- a/openmp/runtime/src/ompt-general.cpp +++ b/openmp/runtime/src/ompt-general.cpp @@ -790,7 +790,7 @@ OMPT_API_ROUTINE int ompt_get_partition_place_nums(int place_nums_size, OMPT_API_ROUTINE int ompt_get_proc_id(void) { if (!ompt_enabled.enabled || __kmp_get_gtid() < 0) return -1; -#if KMP_OS_LINUX +#if KMP_HAVE_SCHED_GETCPU return sched_getcpu(); #elif KMP_OS_WINDOWS PROCESSOR_NUMBER pn; -- cgit v1.1