[Openmp-commits] [PATCH] D72132: [OpenMP] affinity little fix for FreeBSD

David CARLIER via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Fri Jan 3 02:09:26 PST 2020


devnexen created this revision.
devnexen added reviewers: chandlerc, AndreyChurbanov.
devnexen created this object with edit policy "Administrators".
Herald added subscribers: openmp-commits, jfb, guansong.
Herald added a reviewer: jdoerfert.
Herald added a project: OpenMP.

- pthread affinity np has different semantic than sched affinity counterpart. On success returns strictly 0.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72132

Files:
  openmp/runtime/src/kmp_affinity.h
  openmp/runtime/src/z_Linux_util.cpp


Index: openmp/runtime/src/z_Linux_util.cpp
===================================================================
--- openmp/runtime/src/z_Linux_util.cpp
+++ openmp/runtime/src/z_Linux_util.cpp
@@ -164,7 +164,7 @@
   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: "
Index: openmp/runtime/src/kmp_affinity.h
===================================================================
--- openmp/runtime/src/kmp_affinity.h
+++ openmp/runtime/src/kmp_affinity.h
@@ -303,8 +303,9 @@
       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 @@
       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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72132.236004.patch
Type: text/x-patch
Size: 1604 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20200103/9dae10d1/attachment.bin>


More information about the Openmp-commits mailing list