aboutsummaryrefslogtreecommitdiff
path: root/openmp/runtime
diff options
context:
space:
mode:
authorDavid CARLIER <devnexen@gmail.com>2022-06-02 17:10:29 +0100
committerDavid CARLIER <devnexen@gmail.com>2022-06-02 17:10:29 +0100
commit2ba5d820e2b0e5016ec706e324060a329f9a83a3 (patch)
treedfbb4309be39f955e5541fb26fc5c9ac7e634c7b /openmp/runtime
parente27ce281399dca8b08b6ca593172a1bd5dbdd5c1 (diff)
downloadllvm-2ba5d820e2b0e5016ec706e324060a329f9a83a3.zip
llvm-2ba5d820e2b0e5016ec706e324060a329f9a83a3.tar.gz
llvm-2ba5d820e2b0e5016ec706e324060a329f9a83a3.tar.bz2
[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
Diffstat (limited to 'openmp/runtime')
-rw-r--r--openmp/runtime/src/kmp_os.h6
-rw-r--r--openmp/runtime/src/ompt-general.cpp2
2 files changed, 7 insertions, 1 deletions
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;