[Openmp-commits] [openmp] 2ba5d82 - [OpenMP] omp_get_proc_id uses sched_getcpu fallback on FreeBSD 13.1 and above.
David CARLIER via Openmp-commits
openmp-commits at lists.llvm.org
Thu Jun 2 09:12:20 PDT 2022
Author: David CARLIER
Date: 2022-06-02T17:10:29+01:00
New Revision: 2ba5d820e2b0e5016ec706e324060a329f9a83a3
URL: https://github.com/llvm/llvm-project/commit/2ba5d820e2b0e5016ec706e324060a329f9a83a3
DIFF: https://github.com/llvm/llvm-project/commit/2ba5d820e2b0e5016ec706e324060a329f9a83a3.diff
LOG: [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
Added:
Modified:
openmp/runtime/src/kmp_os.h
openmp/runtime/src/ompt-general.cpp
Removed:
################################################################################
diff --git a/openmp/runtime/src/kmp_os.h b/openmp/runtime/src/kmp_os.h
index 580663560104e..5db97bb421396 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 1bc3beabc6a5a..0bee7e77c8174 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;
More information about the Openmp-commits
mailing list