[Openmp-commits] [openmp] [OpenMP] Rename worker threads for improved debuggability (PR #102065)
via Openmp-commits
openmp-commits at lists.llvm.org
Tue Aug 6 14:54:48 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/2] 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/2] 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)) {
More information about the Openmp-commits
mailing list