[Openmp-commits] [PATCH] D28873: Printing os thread id, when KMP_AFFINITY is set.

Jonathan Peyton via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Fri Jan 27 10:15:56 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL293315: Printing OS thread id, when KMP_AFFINITY is set. (authored by jlpeyton).

Changed prior to commit:
  https://reviews.llvm.org/D28873?vs=84890&id=86070#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28873

Files:
  openmp/trunk/runtime/src/i18n/en_US.txt
  openmp/trunk/runtime/src/kmp_affinity.cpp
  openmp/trunk/runtime/src/kmp_wrapper_getpid.h


Index: openmp/trunk/runtime/src/kmp_affinity.cpp
===================================================================
--- openmp/trunk/runtime/src/kmp_affinity.cpp
+++ openmp/trunk/runtime/src/kmp_affinity.cpp
@@ -4326,8 +4326,7 @@
         char buf[KMP_AFFIN_MASK_PRINT_LEN];
         __kmp_affinity_print_mask(buf, KMP_AFFIN_MASK_PRINT_LEN,
           th->th.th_affin_mask);
-        KMP_INFORM(BoundToOSProcSet, "KMP_AFFINITY", (kmp_int32)getpid(), gtid,
-          buf);
+        KMP_INFORM(BoundToOSProcSet, "KMP_AFFINITY", (kmp_int32)getpid(),__kmp_gettid(), gtid, buf);
     }
 
 # if KMP_OS_WINDOWS
@@ -4389,8 +4388,7 @@
         char buf[KMP_AFFIN_MASK_PRINT_LEN];
         __kmp_affinity_print_mask(buf, KMP_AFFIN_MASK_PRINT_LEN,
           th->th.th_affin_mask);
-        KMP_INFORM(BoundToOSProcSet, "OMP_PROC_BIND", (kmp_int32)getpid(),
-          gtid, buf);
+        KMP_INFORM(BoundToOSProcSet, "OMP_PROC_BIND", (kmp_int32)getpid(), __kmp_gettid(), gtid, buf);
     }
     __kmp_set_system_affinity(th->th.th_affin_mask, TRUE);
 }
@@ -4708,7 +4706,7 @@
             char buf[KMP_AFFIN_MASK_PRINT_LEN];
             __kmp_affinity_print_mask(buf, KMP_AFFIN_MASK_PRINT_LEN, mask);
             KMP_INFORM(BoundToOSProcSet, "KMP_AFFINITY", (kmp_int32)getpid(),
-              tid, buf);
+            __kmp_gettid(), tid, buf);
         }
         __kmp_set_system_affinity( mask, TRUE );
         KMP_CPU_FREE_FROM_STACK(mask);
@@ -4869,7 +4867,7 @@
             char buf[KMP_AFFIN_MASK_PRINT_LEN];
             __kmp_affinity_print_mask(buf, KMP_AFFIN_MASK_PRINT_LEN, mask);
             KMP_INFORM(BoundToOSProcSet, "KMP_AFFINITY", (kmp_int32)getpid(),
-              tid, buf);
+            __kmp_gettid(), tid, buf);
         }
         __kmp_set_system_affinity( mask, TRUE );
         KMP_CPU_FREE_FROM_STACK(mask);
Index: openmp/trunk/runtime/src/i18n/en_US.txt
===================================================================
--- openmp/trunk/runtime/src/i18n/en_US.txt
+++ openmp/trunk/runtime/src/i18n/en_US.txt
@@ -396,7 +396,7 @@
 AdaptiveNotSupported         "%1$s: Adaptive locks are not supported; using queuing."
 EnvSyntaxError               "%1$s: Invalid symbols found. Check the value \"%2$s\"."
 EnvSpacesNotAllowed          "%1$s: Spaces between digits are not allowed \"%2$s\"."
-BoundToOSProcSet             "%1$s: pid %2$d thread %3$d bound to OS proc set %4$s"
+BoundToOSProcSet             "%1$s: pid %2$d tid %3$d thread %4$d bound to OS proc set %5$s"
 CnsLoopIncrIllegal           "%1$s error: parallel loop increment and condition are inconsistent."
 NoGompCancellation           "libgomp cancellation is not currently supported."
 AffHWSubsetNonUniform        "KMP_HW_SUBSET ignored: non-uniform topology."
Index: openmp/trunk/runtime/src/kmp_wrapper_getpid.h
===================================================================
--- openmp/trunk/runtime/src/kmp_wrapper_getpid.h
+++ openmp/trunk/runtime/src/kmp_wrapper_getpid.h
@@ -21,14 +21,26 @@
     // On Unix-like systems (Linux* OS and OS X*) getpid() is declared in standard headers.
     #include <sys/types.h>
     #include <unistd.h>
+    #include <sys/syscall.h>
+    #if KMP_OS_DARWIN
+    //OS X
+    #define __kmp_gettid() syscall(SYS_thread_selfid)
+    #elif defined(SYS_gettid)
+    // Hopefully other Unix systems define SYS_gettid syscall for getting os thread id
+    #define __kmp_gettid() syscall(SYS_gettid)
+    #else
+    #warning No gettid found, use getpid instead
+    #define __kmp_gettid() getpid()
+    #endif
 
 #elif KMP_OS_WINDOWS
 
     // On Windows* OS _getpid() returns int (not pid_t) and is declared in "process.h".
     #include <process.h>
     // Let us simulate Unix.
     typedef int pid_t;
     #define getpid _getpid
+    #define __kmp_gettid() GetCurrentThreadId()
 
 #else
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28873.86070.patch
Type: text/x-patch
Size: 3821 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20170127/a4687ee6/attachment.bin>


More information about the Openmp-commits mailing list