[Openmp-commits] [openmp] [OpenMP] Rename worker threads for improved debuggability (PR #102065)

via Openmp-commits openmp-commits at lists.llvm.org
Wed Aug 7 09:55:14 PDT 2024


https://github.com/HighW4y2H3ll updated https://github.com/llvm/llvm-project/pull/102065

>From fe3bf2df926c90afe6bc9b2aa7253c63bee89771 Mon Sep 17 00:00:00 2001
From: h2h <h2h at meta.com>
Date: Mon, 5 Aug 2024 14:18:38 -0700
Subject: [PATCH 1/3] Rename worker threads for improved debuggability

---
 openmp/runtime/src/z_Linux_util.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/openmp/runtime/src/z_Linux_util.cpp b/openmp/runtime/src/z_Linux_util.cpp
index 7c90740ae5bde..91d97372ff534 100644
--- a/openmp/runtime/src/z_Linux_util.cpp
+++ b/openmp/runtime/src/z_Linux_util.cpp
@@ -878,6 +878,15 @@ void __kmp_create_worker(int gtid, kmp_info_t *th, size_t stack_size) {
     KMP_SYSFAIL("pthread_create", status);
   }
 
+#ifdef _GNU_SOURCE
+ #if ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 12)))
+  // Rename worker threads for improved debuggability
+  if (!KMP_UBER_GTID(gtid)) {
+    pthread_setname_np(handle, "openmp_worker");
+  }
+ #endif
+#endif
+
   th->th.th_info.ds.ds_thread = handle;
 
 #ifdef KMP_THREAD_ATTR

>From 115e97e1750d649b5edb30c806293ce1ad37e694 Mon Sep 17 00:00:00 2001
From: h2h <h2h at meta.com>
Date: Tue, 6 Aug 2024 14:54:33 -0700
Subject: [PATCH 2/3] use KMP macro

---
 openmp/runtime/src/z_Linux_util.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/openmp/runtime/src/z_Linux_util.cpp b/openmp/runtime/src/z_Linux_util.cpp
index 91d97372ff534..3c65ae89446c3 100644
--- a/openmp/runtime/src/z_Linux_util.cpp
+++ b/openmp/runtime/src/z_Linux_util.cpp
@@ -878,7 +878,7 @@ void __kmp_create_worker(int gtid, kmp_info_t *th, size_t stack_size) {
     KMP_SYSFAIL("pthread_create", status);
   }
 
-#ifdef _GNU_SOURCE
+#ifdef KMP_OS_LINUX
  #if ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 12)))
   // Rename worker threads for improved debuggability
   if (!KMP_UBER_GTID(gtid)) {

>From 6bb262646a5a5b6f9d1c16d45133d3ca0083bc51 Mon Sep 17 00:00:00 2001
From: h2h <h2h at meta.com>
Date: Wed, 7 Aug 2024 09:55:00 -0700
Subject: [PATCH 3/3] fix indent

---
 openmp/runtime/src/z_Linux_util.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/openmp/runtime/src/z_Linux_util.cpp b/openmp/runtime/src/z_Linux_util.cpp
index 3c65ae89446c3..dc97f2baedd56 100644
--- a/openmp/runtime/src/z_Linux_util.cpp
+++ b/openmp/runtime/src/z_Linux_util.cpp
@@ -879,12 +879,12 @@ void __kmp_create_worker(int gtid, kmp_info_t *th, size_t stack_size) {
   }
 
 #ifdef KMP_OS_LINUX
- #if ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 12)))
+#if ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 12)))
   // Rename worker threads for improved debuggability
   if (!KMP_UBER_GTID(gtid)) {
     pthread_setname_np(handle, "openmp_worker");
   }
- #endif
+#endif
 #endif
 
   th->th.th_info.ds.ds_thread = handle;



More information about the Openmp-commits mailing list