Skip to content

Commit 29f14a6

Browse files
author
ndenoyelle
committed
add tool and tests for binding threads according to a set of locations
1 parent 7076d1e commit 29f14a6

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

config/hwloc_internal.m4

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,34 @@ EOF
355355
AC_CHECK_FUNCS([clock_gettime])
356356
])
357357
358+
# Check for ptrace support
359+
hwloc_have_ptrace=1
360+
AC_CHECK_HEADERS([sys/ptrace.h],, [hwloc_have_ptrace=0])
361+
AC_CHECK_FUNCS([ptrace],, [hwloc_have_ptrace=0])
362+
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
363+
#include "sys/ptrace.h"
364+
int main(void){
365+
return ptrace(PTRACE_SEIZE,
366+
-1,
367+
0,
368+
(void*)(PTRACE_O_TRACECLONE|PTRACE_O_TRACEFORK));
369+
}
370+
]])],, [hwloc_have_ptrace=0])
371+
AM_CONDITIONAL([HWLOC_HAVE_PTRACE],[test $hwloc_have_ptrace -eq 1])
372+
AC_DEFINE_UNQUOTED([HWLOC_HAVE_PTRACE], [$hwloc_have_ptrace], [Whether ptrace is present and supports PTRACE_SEIZE or not])
373+
374+
# Check if syscall gettid is available.
375+
hwloc_have_sys_gettid=1
376+
AC_CHECK_HEADERS([sys/syscall.h],, [hwloc_have_sys_gettid=0])
377+
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
378+
#include "sys/syscall.h"
379+
#ifndef SYS_gettid
380+
#error "syscall SYS_gettid not found"
381+
#endif
382+
int main(void){ return syscall(SYS_gettid) > 0;}
383+
]])],,[hwloc_have_sys_gettid=0])
384+
AC_DEFINE_UNQUOTED([HWLOC_HAVE_SYS_GETTID], [$hwloc_have_sys_gettid], [Whether syscall header is present and SYS_gettid macro is defined or not])
385+
358386
# Only generate this if we're building the utilities
359387
# Even the netloc library Makefile is here because
360388
# we don't embed libnetloc yet, it's useless without tools
@@ -385,7 +413,11 @@ AC_DEFUN([HWLOC_SETUP_TESTS],[
385413
###
386414
EOF
387415
388-
AC_CHECK_LIB([pthread], [pthread_self], [hwloc_have_pthread=yes])
416+
# Check thread support.
417+
AC_CHECK_LIB([pthread], [pthread_self], [hwloc_have_pthread=1], [hwloc_have_pthread=0])
418+
AC_DEFINE_UNQUOTED([HWLOC_HAVE_PTHREAD], [$hwloc_have_pthread], [Whether we have the pthread library or not])
419+
AM_CONDITIONAL([HWLOC_HAVE_PTHREAD], [test $hwloc_have_pthread -eq 1]) AC_CHECK_LIB([pthread], [pthread_self], [hwloc_have_pthread=yes])
420+
AC_OPENMP
389421
390422
HWLOC_PKG_CHECK_MODULES([NUMA], [numa], [numa_available], [numa.h],
391423
[hwloc_have_linux_libnuma=yes],

utils/hwloc/test-hwloc-thread-bind.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ static int check_strategy_pthread(int prebind)
213213
/* Check sequential, parallel, fork */
214214
/***************************************************************************/
215215

216-
static void test_attach_parallel(int (*check_fn)(int))
216+
static void test_attach(int (*check_fn)(int))
217217
{
218218
pid_t pid = fork();
219219
assert(pid >= 0);
@@ -284,15 +284,15 @@ int main(void)
284284
#if HWLOC_HAVE_PTRACE
285285
#ifdef _OPENMP
286286
test_parallel(check_strategy_openmp);
287-
test_attach_parallel(check_strategy_openmp);
287+
//test_attach(check_strategy_openmp);
288288
// OpenMP doesn't like to fork and hangs..
289289
/* test_attach_parallel(check_strategy_openmp, cpuaffinity_round_robin); */
290290
// OpenMP doesn't like to fork and hangs..
291291
/* test_attach_parallel(check_strategy_openmp, cpuaffinity_scatter); */
292292
#endif // _OPENMP
293293
#if HWLOC_HAVE_PTHREAD
294294
test_parallel(check_strategy_pthread);
295-
test_attach_parallel(check_strategy_pthread);
295+
test_attach(check_strategy_pthread);
296296
#endif // HWLOC_HAVE_PTHREAD
297297
#endif // HWLOC_HAVE_PTRACE
298298
#endif // HWLOC_HAVE_SYS_GETTID

0 commit comments

Comments
 (0)