[Openmp-commits] [openmp] r293315 - Printing OS thread id, when KMP_AFFINITY is set.

Jonathan Peyton via Openmp-commits openmp-commits at lists.llvm.org
Fri Jan 27 10:04:33 PST 2017


Author: jlpeyton
Date: Fri Jan 27 12:04:33 2017
New Revision: 293315

URL: http://llvm.org/viewvc/llvm-project?rev=293315&view=rev
Log:
Printing OS thread id, when KMP_AFFINITY is set.

Patch by Vishakha Agrawal

Differential Revision: https://reviews.llvm.org/D28873

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

Modified: openmp/trunk/runtime/src/i18n/en_US.txt
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/i18n/en_US.txt?rev=293315&r1=293314&r2=293315&view=diff
==============================================================================
--- openmp/trunk/runtime/src/i18n/en_US.txt (original)
+++ openmp/trunk/runtime/src/i18n/en_US.txt Fri Jan 27 12:04:33 2017
@@ -396,7 +396,7 @@ SyntaxErrorUsing             "%1$s: synt
 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."

Modified: openmp/trunk/runtime/src/kmp_affinity.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_affinity.cpp?rev=293315&r1=293314&r2=293315&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_affinity.cpp (original)
+++ openmp/trunk/runtime/src/kmp_affinity.cpp Fri Jan 27 12:04:33 2017
@@ -4326,8 +4326,7 @@ __kmp_affinity_set_init_mask(int gtid, i
         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 @@ __kmp_affinity_set_place(int gtid)
         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 @@ void __kmp_balanced_affinity( int tid, i
             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 @@ void __kmp_balanced_affinity( int tid, i
             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);

Modified: openmp/trunk/runtime/src/kmp_wrapper_getpid.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_wrapper_getpid.h?rev=293315&r1=293314&r2=293315&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_wrapper_getpid.h (original)
+++ openmp/trunk/runtime/src/kmp_wrapper_getpid.h Fri Jan 27 12:04:33 2017
@@ -21,6 +21,17 @@
     // 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
 
@@ -29,6 +40,7 @@
     // Let us simulate Unix.
     typedef int pid_t;
     #define getpid _getpid
+    #define __kmp_gettid() GetCurrentThreadId()
 
 #else
 




More information about the Openmp-commits mailing list