From ae61700a45dd0db6f8faa8c8da88a085819af98f Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Thu, 6 Nov 2008 21:54:51 +0000
Subject: [PATCH] Add configuration option "--with-cpusetdir=PATH" for
 non-standard locations.

---
 NEWS                                         |  3 +-
 auxdir/x_ac_affinity.m4                      | 21 +++---
 config.h.in                                  |  3 +
 configure                                    | 78 ++++++++++++--------
 src/plugins/priority/Makefile.in             |  1 +
 src/plugins/priority/basic/Makefile.in       |  1 +
 src/plugins/priority/multifactor/Makefile.in |  1 +
 src/plugins/task/affinity/affinity.h         |  2 +
 src/sshare/Makefile.in                       |  1 +
 9 files changed, 70 insertions(+), 41 deletions(-)

diff --git a/NEWS b/NEWS
index 134e1727649..36d61760a21 100644
--- a/NEWS
+++ b/NEWS
@@ -3,10 +3,11 @@ documents those changes that are of interest to users and admins.
 
 * Changes in SLURM 1.4.0-pre5
 =============================
- -- Correction inf setting of SLURM_CPU_BIND environment variable.
+ -- Correction in setting of SLURM_CPU_BIND environment variable.
  -- Rebuild slurmctld's job select_jobinfo->node_bitmap on restart/reconfigure
     of the daemon rather than restoring the bitmap since the nodes in a system
     can change (be added or removed).
+ -- Add configuration option "--with-cpusetdir=PATH" for non-standard locations.
 
 * Changes in SLURM 1.4.0-pre4
 =============================
diff --git a/auxdir/x_ac_affinity.m4 b/auxdir/x_ac_affinity.m4
index 3e191de9d04..acbbd7d50e0 100644
--- a/auxdir/x_ac_affinity.m4
+++ b/auxdir/x_ac_affinity.m4
@@ -60,16 +60,19 @@ AC_DEFUN([X_AC_AFFINITY], [
   fi
 
 #
-# Test for cpusets
-#
-  if test -d "/dev/cpuset" ; then
-     have_sched_setaffinity=yes
-  fi
-
-#
-# Test for other affinity functions as appropriate
-# TBD
+# Test for cpuset directory
 #
+  cpuset_default_dir="/dev/cpuset"
+  AC_ARG_WITH([cpusetdir],
+              AS_HELP_STRING(--with-cpusetdir=PATH,specify path to cpuset directory default is /dev/cpuset),
+              [try_path=$withval])
+  for cpuset_dir in $try_path "" $cpuset_default_dir; do
+    if test -d "$cpuset_dir" ; then
+      AC_DEFINE_UNQUOTED(CPUSET_DIR, "$cpuset_dir", [Define location of cpuset directory])
+      have_sched_setaffinity=yes
+      break
+    fi
+  done
 
 #
 # Set HAVE_SCHED_SETAFFINITY if any task affinity supported
diff --git a/config.h.in b/config.h.in
index 64933974e8a..68f66989145 100644
--- a/config.h.in
+++ b/config.h.in
@@ -9,6 +9,9 @@
 /* Define the BG_SERIAL value */
 #undef BG_SERIAL
 
+/* Define location of cpuset directory */
+#undef CPUSET_DIR
+
 /* Define to 1 if licensed under terms of the GNU General Public License. */
 #undef GPL_LICENSED
 
diff --git a/configure b/configure
index a8c297b822b..0c720174948 100755
--- a/configure
+++ b/configure
@@ -1595,6 +1595,8 @@ Optional Packages:
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-tags[=TAGS]      include additional configurations [automatic]
+  --with-cpusetdir=PATH   specify path to cpuset directory default is
+                          /dev/cpuset
   --with-db2-dir=PATH     Specify path to DB2 librarys parent directory
   --with-bg-serial=NAME   set BG_SERIAL value
 
@@ -7124,7 +7126,7 @@ ia64-*-hpux*)
   ;;
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 7127 "configure"' > conftest.$ac_ext
+  echo '#line 7129 "configure"' > conftest.$ac_ext
   if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -9230,11 +9232,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:9233: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:9235: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:9237: \$? = $ac_status" >&5
+   echo "$as_me:9239: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -9520,11 +9522,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:9523: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:9525: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:9527: \$? = $ac_status" >&5
+   echo "$as_me:9529: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -9624,11 +9626,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:9627: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:9629: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:9631: \$? = $ac_status" >&5
+   echo "$as_me:9633: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -12001,7 +12003,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 12004 "configure"
+#line 12006 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12101,7 +12103,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 12104 "configure"
+#line 12106 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -14502,11 +14504,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:14505: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:14507: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:14509: \$? = $ac_status" >&5
+   echo "$as_me:14511: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -14606,11 +14608,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:14609: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:14611: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:14613: \$? = $ac_status" >&5
+   echo "$as_me:14615: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -16204,11 +16206,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:16207: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:16209: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:16211: \$? = $ac_status" >&5
+   echo "$as_me:16213: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -16308,11 +16310,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:16311: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:16313: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:16315: \$? = $ac_status" >&5
+   echo "$as_me:16317: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -18528,11 +18530,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:18531: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:18533: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:18535: \$? = $ac_status" >&5
+   echo "$as_me:18537: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -18818,11 +18820,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:18821: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:18823: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:18825: \$? = $ac_status" >&5
+   echo "$as_me:18827: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -18922,11 +18924,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:18925: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:18927: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:18929: \$? = $ac_status" >&5
+   echo "$as_me:18931: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -22772,16 +22774,30 @@ echo "$as_me: WARNING: Unable to locate PLPA processor affinity functions" >&2;}
   fi
 
 #
-# Test for cpusets
+# Test for cpuset directory
 #
-  if test -d "/dev/cpuset" ; then
-     have_sched_setaffinity=yes
-  fi
+  cpuset_default_dir="/dev/cpuset"
 
-#
-# Test for other affinity functions as appropriate
-# TBD
-#
+# Check whether --with-cpuset_dir was given.
+if test "${with_cpuset_dir+set}" = set; then
+  withval=$with_cpuset_dir; try_path=$withval
+fi
+
+  for cpuset_dir in $try_path "" $cpuset_default_dir; do
+{ echo "$as_me:$LINENO: WARNING: cpuset_dir $cpuset_dir testing" >&5
+echo "$as_me: WARNING: cpuset_dir $cpuset_dir testing" >&2;}
+    if test -d "$cpuset_dir" ; then
+{ echo "$as_me:$LINENO: WARNING: cpuset $cpuset_dir found" >&5
+echo "$as_me: WARNING: cpuset $cpuset_dir found" >&2;}
+
+cat >>confdefs.h <<_ACEOF
+#define CPUSET_DIR "$cpuset_dir"
+_ACEOF
+
+      have_sched_setaffinity=yes
+      break
+    fi
+  done
 
 #
 # Set HAVE_SCHED_SETAFFINITY if any task affinity supported
diff --git a/src/plugins/priority/Makefile.in b/src/plugins/priority/Makefile.in
index 1d979f5c67f..a41b7087170 100644
--- a/src/plugins/priority/Makefile.in
+++ b/src/plugins/priority/Makefile.in
@@ -182,6 +182,7 @@ SLURM_API_VERSION = @SLURM_API_VERSION@
 SLURM_MAJOR = @SLURM_MAJOR@
 SLURM_MICRO = @SLURM_MICRO@
 SLURM_MINOR = @SLURM_MINOR@
+SLURM_PREFIX = @SLURM_PREFIX@
 SLURM_VERSION = @SLURM_VERSION@
 SO_LDFLAGS = @SO_LDFLAGS@
 SSL_CPPFLAGS = @SSL_CPPFLAGS@
diff --git a/src/plugins/priority/basic/Makefile.in b/src/plugins/priority/basic/Makefile.in
index 34904a8f168..95fc851d760 100644
--- a/src/plugins/priority/basic/Makefile.in
+++ b/src/plugins/priority/basic/Makefile.in
@@ -202,6 +202,7 @@ SLURM_API_VERSION = @SLURM_API_VERSION@
 SLURM_MAJOR = @SLURM_MAJOR@
 SLURM_MICRO = @SLURM_MICRO@
 SLURM_MINOR = @SLURM_MINOR@
+SLURM_PREFIX = @SLURM_PREFIX@
 SLURM_VERSION = @SLURM_VERSION@
 SO_LDFLAGS = @SO_LDFLAGS@
 SSL_CPPFLAGS = @SSL_CPPFLAGS@
diff --git a/src/plugins/priority/multifactor/Makefile.in b/src/plugins/priority/multifactor/Makefile.in
index 304b0ee2e6d..0425a28fbac 100644
--- a/src/plugins/priority/multifactor/Makefile.in
+++ b/src/plugins/priority/multifactor/Makefile.in
@@ -203,6 +203,7 @@ SLURM_API_VERSION = @SLURM_API_VERSION@
 SLURM_MAJOR = @SLURM_MAJOR@
 SLURM_MICRO = @SLURM_MICRO@
 SLURM_MINOR = @SLURM_MINOR@
+SLURM_PREFIX = @SLURM_PREFIX@
 SLURM_VERSION = @SLURM_VERSION@
 SO_LDFLAGS = @SO_LDFLAGS@
 SSL_CPPFLAGS = @SSL_CPPFLAGS@
diff --git a/src/plugins/task/affinity/affinity.h b/src/plugins/task/affinity/affinity.h
index 4ee3d27db12..a64cb51c6b2 100644
--- a/src/plugins/task/affinity/affinity.h
+++ b/src/plugins/task/affinity/affinity.h
@@ -92,7 +92,9 @@
 #include "src/common/util-net.h"
 #include "src/common/slurm_resource_info.h"
 
+#ifndef CPUSET_DIR
 #define CPUSET_DIR "/dev/cpuset"
+#endif
 
 /*** from affinity.c ***/
 void	slurm_chkaffinity(cpu_set_t *mask, slurmd_job_t *job, int statval);
diff --git a/src/sshare/Makefile.in b/src/sshare/Makefile.in
index 476a006bf19..fc1f4cc4f6b 100644
--- a/src/sshare/Makefile.in
+++ b/src/sshare/Makefile.in
@@ -199,6 +199,7 @@ SLURM_API_VERSION = @SLURM_API_VERSION@
 SLURM_MAJOR = @SLURM_MAJOR@
 SLURM_MICRO = @SLURM_MICRO@
 SLURM_MINOR = @SLURM_MINOR@
+SLURM_PREFIX = @SLURM_PREFIX@
 SLURM_VERSION = @SLURM_VERSION@
 SO_LDFLAGS = @SO_LDFLAGS@
 SSL_CPPFLAGS = @SSL_CPPFLAGS@
-- 
GitLab