x_ac_affinity.m4 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. ##*****************************************************************************
  2. # AUTHOR:
  3. # Morris Jette <jette1@llnl.gov>
  4. #
  5. # SYNOPSIS:
  6. # X_AC_AFFINITY
  7. #
  8. # DESCRIPTION:
  9. # Test for various task affinity functions and set the definitions.
  10. #
  11. # WARNINGS:
  12. # This macro must be placed after AC_PROG_CC or equivalent.
  13. ##*****************************************************************************
  14. AC_DEFUN([X_AC_AFFINITY], [
  15. # Test if sched_setaffinity function exists and argument count (it can vary)
  16. AC_CHECK_FUNCS(sched_setaffinity, [have_sched_setaffinity=yes])
  17. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#define _GNU_SOURCE
  18. #include <sched.h>]], [[cpu_set_t mask;
  19. sched_getaffinity(0, sizeof(cpu_set_t), &mask);]])],[AC_DEFINE(SCHED_GETAFFINITY_THREE_ARGS, 1,
  20. [Define to 1 if sched_getaffinity takes three arguments.])],[])
  21. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#define _GNU_SOURCE
  22. #include <sched.h>]], [[cpu_set_t mask;
  23. sched_getaffinity(0, &mask);]])],[AC_DEFINE(SCHED_GETAFFINITY_TWO_ARGS, 1,
  24. [Define to 1 if sched_getaffinity takes two arguments.])],[])
  25. #
  26. # Test for NUMA memory afffinity functions and set the definitions
  27. #
  28. AC_CHECK_LIB([numa],
  29. [numa_available],
  30. [ac_have_numa=yes; NUMA_LIBS="-lnuma"])
  31. AC_SUBST(NUMA_LIBS)
  32. AM_CONDITIONAL(HAVE_NUMA, test "x$ac_have_numa" = "xyes")
  33. if test "x$ac_have_numa" = "xyes"; then
  34. AC_DEFINE(HAVE_NUMA, 1, [define if numa library installed])
  35. CFLAGS="-DNUMA_VERSION1_COMPATIBILITY $CFLAGS"
  36. else
  37. AC_MSG_WARN([unable to locate NUMA memory affinity functions])
  38. fi
  39. #
  40. # Test for cpuset directory
  41. #
  42. cpuset_default_dir="/dev/cpuset"
  43. AC_ARG_WITH([cpusetdir],
  44. AS_HELP_STRING(--with-cpusetdir=PATH,specify path to cpuset directory default is /dev/cpuset),
  45. [try_path=$withval])
  46. for cpuset_dir in $try_path "" $cpuset_default_dir; do
  47. if test -d "$cpuset_dir" ; then
  48. AC_DEFINE_UNQUOTED(CPUSET_DIR, "$cpuset_dir", [Define location of cpuset directory])
  49. have_sched_setaffinity=yes
  50. break
  51. fi
  52. done
  53. #
  54. # Set HAVE_SCHED_SETAFFINITY if any task affinity supported
  55. AM_CONDITIONAL(HAVE_SCHED_SETAFFINITY, test "x$have_sched_setaffinity" = "xyes")
  56. ])