[OpenMP] Support setting POSIX thread name on *BSD's and Solaris (#106489)
This commit is contained in:
parent
ec58817537
commit
37e109c6f8
@ -23,8 +23,8 @@ function(libomp_get_definitions_flags cppflags)
|
|||||||
else()
|
else()
|
||||||
libomp_append(cppflags_local "-D _GNU_SOURCE")
|
libomp_append(cppflags_local "-D _GNU_SOURCE")
|
||||||
libomp_append(cppflags_local "-D _REENTRANT")
|
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_PTHREAD_SETNAME_NP" LIBOMP_HAVE_PTHREAD_SETNAME_NP)
|
||||||
libomp_append(cppflags_local "-D LIBOMP_HAVE_LINUX_PTHREAD_SETNAME" LIBOMP_HAVE_LINUX_PTHREAD_SETNAME)
|
libomp_append(cppflags_local "-D LIBOMP_HAVE_PTHREAD_SET_NAME_NP" LIBOMP_HAVE_PTHREAD_SET_NAME_NP)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# CMake doesn't include CPPFLAGS from environment, but we will.
|
# CMake doesn't include CPPFLAGS from environment, but we will.
|
||||||
|
@ -102,9 +102,8 @@ if(${LIBOMP_FORTRAN_MODULES})
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Check non-posix pthread API here before CMAKE_REQUIRED_DEFINITIONS gets messed up
|
# 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_PTHREAD_SETNAME_NP)
|
||||||
check_symbol_exists(pthread_setname_np "pthread.h" LIBOMP_HAVE_LINUX_PTHREAD_SETNAME)
|
check_symbol_exists(pthread_set_name_np "pthread.h;pthread_np.h" LIBOMP_HAVE_PTHREAD_SET_NAME_NP)
|
||||||
endif()
|
|
||||||
|
|
||||||
# Check for Unix shared memory
|
# Check for Unix shared memory
|
||||||
check_symbol_exists(shm_open "sys/mman.h" LIBOMP_HAVE_SHM_OPEN_NO_LRT)
|
check_symbol_exists(shm_open "sys/mman.h" LIBOMP_HAVE_SHM_OPEN_NO_LRT)
|
||||||
|
@ -71,6 +71,9 @@
|
|||||||
#if KMP_OS_NETBSD
|
#if KMP_OS_NETBSD
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#endif
|
#endif
|
||||||
|
#if KMP_OS_OPENBSD
|
||||||
|
#include <pthread_np.h>
|
||||||
|
#endif
|
||||||
#elif KMP_OS_SOLARIS
|
#elif KMP_OS_SOLARIS
|
||||||
#include <libproc.h>
|
#include <libproc.h>
|
||||||
#include <procfs.h>
|
#include <procfs.h>
|
||||||
@ -878,12 +881,18 @@ void __kmp_create_worker(int gtid, kmp_info_t *th, size_t stack_size) {
|
|||||||
KMP_SYSFAIL("pthread_create", status);
|
KMP_SYSFAIL("pthread_create", status);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LIBOMP_HAVE_LINUX_PTHREAD_SETNAME
|
|
||||||
// Rename worker threads for improved debuggability
|
// Rename worker threads for improved debuggability
|
||||||
if (!KMP_UBER_GTID(gtid)) {
|
if (!KMP_UBER_GTID(gtid)) {
|
||||||
|
#if defined(LIBOMP_HAVE_PTHREAD_SET_NAME_NP)
|
||||||
|
pthread_set_name_np(handle, "openmp_worker");
|
||||||
|
#elif defined(LIBOMP_HAVE_PTHREAD_SETNAME_NP) && !KMP_OS_DARWIN
|
||||||
|
#if KMP_OS_NETBSD
|
||||||
|
pthread_setname_np(handle, "%s", const_cast<char *>("openmp_worker"));
|
||||||
|
#else
|
||||||
pthread_setname_np(handle, "openmp_worker");
|
pthread_setname_np(handle, "openmp_worker");
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
th->th.th_info.ds.ds_thread = handle;
|
th->th.th_info.ds.ds_thread = handle;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user