[Openmp-commits] [openmp] ea99c09 - [OpenMP] affinity little fix for FreeBSD
David Carlier via Openmp-commits
openmp-commits at lists.llvm.org
Mon Jan 20 10:53:37 PST 2020
Author: David Carlier
Date: 2020-01-20T18:52:10Z
New Revision: ea99c09963488130ec0a61ef39df3fd0fcecad3c
URL: https://github.com/llvm/llvm-project/commit/ea99c09963488130ec0a61ef39df3fd0fcecad3c
DIFF: https://github.com/llvm/llvm-project/commit/ea99c09963488130ec0a61ef39df3fd0fcecad3c.diff
LOG: [OpenMP] affinity little fix for FreeBSD
- pthread affinity np has different semantic than sched affinity counterpart. On success returns strictly 0.
Reviewers: chandlerc, AndreyChurbanov, jdoerfert
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D72132
Added:
Modified:
openmp/runtime/src/kmp_affinity.h
openmp/runtime/src/z_Linux_util.cpp
Removed:
################################################################################
diff --git a/openmp/runtime/src/kmp_affinity.h b/openmp/runtime/src/kmp_affinity.h
index f270bb6dbb8d..664a42393191 100644
--- a/openmp/runtime/src/kmp_affinity.h
+++ b/openmp/runtime/src/kmp_affinity.h
@@ -303,8 +303,9 @@ class KMPNativeAffinity : public KMPAffinity {
int retval =
syscall(__NR_sched_getaffinity, 0, __kmp_affin_mask_size, mask);
#elif KMP_OS_FREEBSD
- int retval =
+ int r =
pthread_getaffinity_np(pthread_self(), __kmp_affin_mask_size, reinterpret_cast<cpuset_t *>(mask));
+ int retval = (r == 0 ? 0 : -1);
#endif
if (retval >= 0) {
return 0;
@@ -322,8 +323,9 @@ class KMPNativeAffinity : public KMPAffinity {
int retval =
syscall(__NR_sched_setaffinity, 0, __kmp_affin_mask_size, mask);
#elif KMP_OS_FREEBSD
- int retval =
+ int r =
pthread_setaffinity_np(pthread_self(), __kmp_affin_mask_size, reinterpret_cast<cpuset_t *>(mask));
+ int retval = (r == 0 ? 0 : -1);
#endif
if (retval >= 0) {
return 0;
diff --git a/openmp/runtime/src/z_Linux_util.cpp b/openmp/runtime/src/z_Linux_util.cpp
index 1daa3d31047e..5e2d1bd4a2fe 100644
--- a/openmp/runtime/src/z_Linux_util.cpp
+++ b/openmp/runtime/src/z_Linux_util.cpp
@@ -164,7 +164,7 @@ void __kmp_affinity_determine_capable(const char *env_var) {
if (gCode > 0) { // Linux* OS only
// The optimal situation: the OS returns the size of the buffer it expects.
//
- // A verification of correct behavior is that Isetaffinity on a NULL
+ // A verification of correct behavior is that setaffinity on a NULL
// buffer with the same size fails with errno set to EFAULT.
sCode = syscall(__NR_sched_setaffinity, 0, gCode, NULL);
KA_TRACE(30, ("__kmp_affinity_determine_capable: "
@@ -286,7 +286,7 @@ void __kmp_affinity_determine_capable(const char *env_var) {
if (gCode == 0) {
KMP_AFFINITY_ENABLE(KMP_CPU_SET_SIZE_LIMIT);
KA_TRACE(10, ("__kmp_affinity_determine_capable: "
- "affinity supported (mask size %d)\n"<
+ "affinity supported (mask size %d)\n",
(int)__kmp_affin_mask_size));
KMP_INTERNAL_FREE(buf);
return;
More information about the Openmp-commits
mailing list