From a97bbf4fba1108b4c38d3721087bf8db25c45b8c Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Sat, 29 Jan 2011 06:04:58 +0000
Subject: [PATCH] 04_Cray-autoconf-rules.diff

select/cray: update compile-time and runtime support for Cray build

These changes update build support for Cray XT/XE:
 1. renamed '--cray-xt' into '--cray' since also XE systems are supported;
 2. autoconf rules to cover the various possible build cases:
    a) --enable-cray=off: HAVE_CRAY/HAVE_NATIVE_CRAY undefined,
    b) --enable-cray=on:  HAVE_CRAY defined
       b1) local host is a native Cray system: HAVE_NATIVE_CRAY defined
           (requires installation of mysql-devel and libexpat-devel packages),
       b2) local host is not a native Cray system: the conditionally built
           parts (basil_interface.c, libalps.la) are not built;
 3. updated configure logic:
    - since Cray support depends on mySQL, reordered tests in configure.ac,
    - reordered logic with regard to changes in (2),
    - an AM_CONDITIONAL to build native-Cray parts conditionally,
    - updated configure messages (XT/XE);
 4. run-time read_conf test to ensure use of select/cray is properly supported,
 5. an update of the NEWS file due to the change in (1) ==> may have a conflict
    in case you have a locally-updated copy.

I have compile-tested the three possible scenarios in (2).
---
 NEWS                     |  4 +++
 auxdir/x_ac_cray.m4      | 61 +++++++++++++++++++++++++---------------
 configure.ac             |  4 ++-
 src/common/read_config.c | 10 +++++++
 4 files changed, 56 insertions(+), 23 deletions(-)

diff --git a/NEWS b/NEWS
index 98186578f3e..bd860e6cc3d 100644
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,10 @@ documents those changes that are of interest to users and admins.
     02_Bug-fix_no-script-on-interactive-job.diff
  -- Preserve NodeHostName when reordering nodes due to system topology.
     03_Bug-fix_slurmctld-swap-both-NodeAddr-and-NodeHostname-when-reordering.diff
+ -- Updated configure option "--enable-cray" to support interaction with Cray
+    XT/XE systems, and build on native Cray XT/XE systems (auto-detected).
+    Building on native Cray systems requires the cray-MySQL-devel-enterprise
+    rpm and expat XML parser library/headers. 04_Cray-autoconf-rules.diff
 
 * Changes in SLURM 2.3.0.pre1
 =============================
diff --git a/auxdir/x_ac_cray.m4 b/auxdir/x_ac_cray.m4
index a76b8a4a875..3c9b0c00e66 100644
--- a/auxdir/x_ac_cray.m4
+++ b/auxdir/x_ac_cray.m4
@@ -6,43 +6,60 @@
 #    X_AC_CRAY
 #
 #  DESCRIPTION:
-#    Test for Cray systems including XT with 3-D interconnect
-#    Also test for the apbasil client (Cray's Batch Application Scheduler 
-#    Interface Layer interface)
-##*****************************************************************************
+#    Test for Cray XT and XE systems with 2-D/3-D interconnects.
+#    Tests for required libraries (native Cray systems only):
+#    * mySQL (relies on testing for mySQL presence earlier);
+#    * libexpat, needed for XML-RPC calls to Cray's BASIL
+#      (Batch Application  Scheduler Interface Layer) interface.
+#*****************************************************************************
 
 AC_DEFUN([X_AC_CRAY], [
-  AC_MSG_CHECKING([whether this is a native Cray XT or XE system])
+  x_ac_cray="no"
+  ac_have_native_cray="no"
+
+  AC_MSG_CHECKING([whether support for Cray XT/XE is enabled])
   AC_ARG_ENABLE(
-    [cray-xt],
-    AS_HELP_STRING(--enable-cray-xt,enable Cray XT system support),
+    [cray],
+    AS_HELP_STRING(--enable-cray,enable Cray XT/XE system support),
     [ case "$enableval" in
-        yes) x_ac_cray_xt=yes ;;
-         no) x_ac_cray_xt=no ;;
-          *) AC_MSG_RESULT([doh!])
-             AC_MSG_ERROR([bad value "$enableval" for --enable-cray-xt]) ;;
+        yes) x_ac_cray="yes" ;;
+         no) x_ac_cray="no"  ;;
+          *) AC_MSG_ERROR([bad value "$enableval" for --enable-cray]) ;;
       esac
-    ],
-    [x_ac_cray_xt=no]
+    ]
   )
+  AC_MSG_RESULT([$x_ac_cray])
 
-  if test "$x_ac_cray_xt" = yes; then
+  if test "$x_ac_cray" = "yes"; then
     AC_DEFINE(HAVE_CRAY, 1, [Define to 1 for basic support of Cray XT/XE systems])
-    # Check whether we are on a native Cray host:
+
+    AC_MSG_CHECKING([whether this is a native Cray XT or XE system])
+    # Check for a Cray-specific file:
     #  * older XT systems use an /etc/xtrelease file
     #  * newer XT/XE systems use an /etc/opt/cray/release/xtrelease file
     #  * both have an /etc/xthostname
     if test -f /etc/xtrelease  || test -d /etc/opt/cray/release ; then
+      ac_have_native_cray="yes"
+    fi
+    AC_MSG_RESULT([$ac_have_native_cray])
+  fi
+
+  if test "$ac_have_native_cray" = "yes"; then
+      if test -z "$MYSQL_CFLAGS" || test -z "$MYSQL_LIBS"; then
+        AC_MSG_ERROR([BASIL requires the cray-MySQL-devel-enterprise rpm])
+      fi
+      ALPS_LIBS="$MYSQL_LIBS"
+
+      AC_CHECK_HEADER(expat.h, [],
+                    AC_MSG_ERROR([BASIL requires expat headers/rpm])
+      AC_CHECK_LIB(expat, XML_ParserCreate, [ALPS_LIBS="$ALPS_LIBS -lexpat"],
+                    AC_MSG_ERROR([BASIL requires libexpat.so/rpm])
+      AC_SUBST(ALPS_LIBS)
+
       AC_DEFINE(HAVE_NATIVE_CRAY,  1, [Define to 1 for native Cray XT/XE system])
       AC_DEFINE(HAVE_3D,           1, [Define to 1 if 3-dimensional architecture])
       AC_DEFINE(SYSTEM_DIMENSIONS, 3, [3-dimensional architecture])
       AC_DEFINE(HAVE_FRONT_END,    1, [Define to 1 if running slurmd on front-end only])
-      AC_MSG_RESULT([yes])
-    else
-      AC_MSG_RESULT([no])
-    fi
-  else
-    AC_MSG_RESULT([no])
   fi
+  AM_CONDITIONAL(HAVE_NATIVE_CRAY, test "$ac_have_native_cray" = "yes")
 ])
-
diff --git a/configure.ac b/configure.ac
index 230f7a3c60f..f65c5f6ed12 100644
--- a/configure.ac
+++ b/configure.ac
@@ -180,7 +180,6 @@ LDFLAGS="$LDFLAGS "
 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
 LIBS="$PTHREAD_LIBS $LIBS"
 
-X_AC_CRAY
 X_AC_SUN_CONST
 X_AC_DIMENSIONS
 
@@ -224,6 +223,9 @@ fi
 
 X_AC_DATABASES
 
+dnl Cray ALPS/Basil support depends on mySQL
+X_AC_CRAY
+
 dnl checks for system services.
 dnl
 
diff --git a/src/common/read_config.c b/src/common/read_config.c
index 6934a32bc58..25ef9e966a4 100644
--- a/src/common/read_config.c
+++ b/src/common/read_config.c
@@ -2775,6 +2775,16 @@ _validate_and_set_defaults(slurm_ctl_conf_t *conf, s_p_hashtbl_t *hashtbl)
 
 	if (!s_p_get_string(&conf->select_type, "SelectType", hashtbl))
 		conf->select_type = xstrdup(DEFAULT_SELECT_TYPE);
+#ifndef HAVE_NATIVE_CRAY
+	if (strcmp(conf->select_type, "select/cray") == 0)
+#ifdef HAVE_CRAY
+		fatal("Use of SelectType=select/cray in slurm.conf "
+		      "on a non-native Cray system.");
+#else
+		fatal("Requested SelectType=select/cray in slurm.conf, "
+		      "but slurm was built without --enable-cray.");
+#endif
+#endif
 
 	if (s_p_get_string(&temp_str,
 			   "SelectTypeParameters", hashtbl)) {
-- 
GitLab