Skip to content

Commit

Permalink
add tool and tests for binding threads according to a set of locations
Browse files Browse the repository at this point in the history
  • Loading branch information
ndenoyelle committed Jun 19, 2019
1 parent 7076d1e commit 29f14a6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
34 changes: 33 additions & 1 deletion config/hwloc_internal.m4
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,34 @@ EOF
AC_CHECK_FUNCS([clock_gettime])
])
# Check for ptrace support
hwloc_have_ptrace=1
AC_CHECK_HEADERS([sys/ptrace.h],, [hwloc_have_ptrace=0])
AC_CHECK_FUNCS([ptrace],, [hwloc_have_ptrace=0])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include "sys/ptrace.h"
int main(void){
return ptrace(PTRACE_SEIZE,
-1,
0,
(void*)(PTRACE_O_TRACECLONE|PTRACE_O_TRACEFORK));
}
]])],, [hwloc_have_ptrace=0])
AM_CONDITIONAL([HWLOC_HAVE_PTRACE],[test $hwloc_have_ptrace -eq 1])
AC_DEFINE_UNQUOTED([HWLOC_HAVE_PTRACE], [$hwloc_have_ptrace], [Whether ptrace is present and supports PTRACE_SEIZE or not])
# Check if syscall gettid is available.
hwloc_have_sys_gettid=1
AC_CHECK_HEADERS([sys/syscall.h],, [hwloc_have_sys_gettid=0])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include "sys/syscall.h"
#ifndef SYS_gettid
#error "syscall SYS_gettid not found"
#endif
int main(void){ return syscall(SYS_gettid) > 0;}
]])],,[hwloc_have_sys_gettid=0])
AC_DEFINE_UNQUOTED([HWLOC_HAVE_SYS_GETTID], [$hwloc_have_sys_gettid], [Whether syscall header is present and SYS_gettid macro is defined or not])
# Only generate this if we're building the utilities
# Even the netloc library Makefile is here because
# we don't embed libnetloc yet, it's useless without tools
Expand Down Expand Up @@ -385,7 +413,11 @@ AC_DEFUN([HWLOC_SETUP_TESTS],[
###
EOF
AC_CHECK_LIB([pthread], [pthread_self], [hwloc_have_pthread=yes])
# Check thread support.
AC_CHECK_LIB([pthread], [pthread_self], [hwloc_have_pthread=1], [hwloc_have_pthread=0])
AC_DEFINE_UNQUOTED([HWLOC_HAVE_PTHREAD], [$hwloc_have_pthread], [Whether we have the pthread library or not])
AM_CONDITIONAL([HWLOC_HAVE_PTHREAD], [test $hwloc_have_pthread -eq 1]) AC_CHECK_LIB([pthread], [pthread_self], [hwloc_have_pthread=yes])
AC_OPENMP
HWLOC_PKG_CHECK_MODULES([NUMA], [numa], [numa_available], [numa.h],
[hwloc_have_linux_libnuma=yes],
Expand Down
6 changes: 3 additions & 3 deletions utils/hwloc/test-hwloc-thread-bind.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ static int check_strategy_pthread(int prebind)
/* Check sequential, parallel, fork */
/***************************************************************************/

static void test_attach_parallel(int (*check_fn)(int))
static void test_attach(int (*check_fn)(int))
{
pid_t pid = fork();
assert(pid >= 0);
Expand Down Expand Up @@ -284,15 +284,15 @@ int main(void)
#if HWLOC_HAVE_PTRACE
#ifdef _OPENMP
test_parallel(check_strategy_openmp);
test_attach_parallel(check_strategy_openmp);
//test_attach(check_strategy_openmp);
// OpenMP doesn't like to fork and hangs..
/* test_attach_parallel(check_strategy_openmp, cpuaffinity_round_robin); */
// OpenMP doesn't like to fork and hangs..
/* test_attach_parallel(check_strategy_openmp, cpuaffinity_scatter); */
#endif // _OPENMP
#if HWLOC_HAVE_PTHREAD
test_parallel(check_strategy_pthread);
test_attach_parallel(check_strategy_pthread);
test_attach(check_strategy_pthread);
#endif // HWLOC_HAVE_PTHREAD
#endif // HWLOC_HAVE_PTRACE
#endif // HWLOC_HAVE_SYS_GETTID
Expand Down

0 comments on commit 29f14a6

Please sign in to comment.