[Openmp-commits] [openmp] 0160d81 - [OpenMP] Rename worker threads for improved debuggability (#102065)
via Openmp-commits
openmp-commits at lists.llvm.org
Tue Aug 13 22:20:14 PDT 2024
Author: HighW4y2H3ll
Date: 2024-08-13T22:20:11-07:00
New Revision: 0160d817c2c1bd3f32986d9cf8b938e613ac3d12
URL: https://github.com/llvm/llvm-project/commit/0160d817c2c1bd3f32986d9cf8b938e613ac3d12
DIFF: https://github.com/llvm/llvm-project/commit/0160d817c2c1bd3f32986d9cf8b938e613ac3d12.diff
LOG: [OpenMP] Rename worker threads for improved debuggability (#102065)
Rename the worker threads "openmp_worker"
---------
Co-authored-by: h2h <h2h at meta.com>
Co-authored-by: Matthias Braun <matze at braunis.de>
Added:
Modified:
openmp/runtime/cmake/LibompDefinitions.cmake
openmp/runtime/cmake/config-ix.cmake
openmp/runtime/src/z_Linux_util.cpp
Removed:
################################################################################
diff --git a/openmp/runtime/cmake/LibompDefinitions.cmake b/openmp/runtime/cmake/LibompDefinitions.cmake
index 46beec79f701b1..c894be5870f705 100644
--- a/openmp/runtime/cmake/LibompDefinitions.cmake
+++ b/openmp/runtime/cmake/LibompDefinitions.cmake
@@ -23,6 +23,8 @@ function(libomp_get_definitions_flags cppflags)
else()
libomp_append(cppflags_local "-D _GNU_SOURCE")
libomp_append(cppflags_local "-D _REENTRANT")
+ # or use HAVE_PTHREAD_SETNAME_NP from top-level cmake/config-ix.cmake
+ libomp_append(cppflags_local "-D LIBOMP_HAVE_LINUX_PTHREAD_SETNAME" LIBOMP_HAVE_LINUX_PTHREAD_SETNAME)
endif()
# CMake doesn't include CPPFLAGS from environment, but we will.
diff --git a/openmp/runtime/cmake/config-ix.cmake b/openmp/runtime/cmake/config-ix.cmake
index 0568474f1d74ed..3adaf5bed68f33 100644
--- a/openmp/runtime/cmake/config-ix.cmake
+++ b/openmp/runtime/cmake/config-ix.cmake
@@ -101,6 +101,11 @@ if(${LIBOMP_FORTRAN_MODULES})
libomp_check_fortran_flag(-m32 LIBOMP_HAVE_M32_FORTRAN_FLAG)
endif()
+# Check non-posix pthread API here before CMAKE_REQUIRED_DEFINITIONS gets messed up
+if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
+ check_symbol_exists(pthread_setname_np "pthread.h" LIBOMP_HAVE_LINUX_PTHREAD_SETNAME)
+endif()
+
# Check for Unix shared memory
check_symbol_exists(shm_open "sys/mman.h" LIBOMP_HAVE_SHM_OPEN_NO_LRT)
if (NOT LIBOMP_HAVE_SHM_OPEN_NO_LRT)
diff --git a/openmp/runtime/src/z_Linux_util.cpp b/openmp/runtime/src/z_Linux_util.cpp
index 7c90740ae5bdef..337a34518da2f6 100644
--- a/openmp/runtime/src/z_Linux_util.cpp
+++ b/openmp/runtime/src/z_Linux_util.cpp
@@ -878,6 +878,13 @@ void __kmp_create_worker(int gtid, kmp_info_t *th, size_t stack_size) {
KMP_SYSFAIL("pthread_create", status);
}
+#ifdef LIBOMP_HAVE_LINUX_PTHREAD_SETNAME
+ // Rename worker threads for improved debuggability
+ if (!KMP_UBER_GTID(gtid)) {
+ pthread_setname_np(handle, "openmp_worker");
+ }
+#endif
+
th->th.th_info.ds.ds_thread = handle;
#ifdef KMP_THREAD_ATTR
More information about the Openmp-commits
mailing list