From d4f1c488a358e0d024efae1e9ff7982c67fed98f Mon Sep 17 00:00:00 2001 From: Christoph Niethammer Date: Wed, 6 Jul 2011 21:19:40 +0000 Subject: [PATCH] Added configurable compiler selection for different platforms. --- etc/platform-configs/hermit/compiler/cray | 3 + etc/platform-configs/hermit/compiler/gnu | 3 + etc/platform-configs/hermit/compiler/intel | 3 + etc/platform-configs/hermit/compiler/pgi | 3 + etc/platform-configs/hermit/compiler/system | 3 + etc/platform-configs/laki/compiler/gnu | 3 + etc/platform-configs/laki/compiler/intel | 3 + etc/platform-configs/laki/compiler/pgi | 3 + etc/platform-configs/laki/compiler/system | 1 + sit | 97 ++++++++++++--------- 10 files changed, 83 insertions(+), 39 deletions(-) create mode 100644 etc/platform-configs/hermit/compiler/cray create mode 100644 etc/platform-configs/hermit/compiler/gnu create mode 100644 etc/platform-configs/hermit/compiler/intel create mode 100644 etc/platform-configs/hermit/compiler/pgi create mode 100644 etc/platform-configs/hermit/compiler/system create mode 100644 etc/platform-configs/laki/compiler/gnu create mode 100644 etc/platform-configs/laki/compiler/intel create mode 100644 etc/platform-configs/laki/compiler/pgi create mode 120000 etc/platform-configs/laki/compiler/system diff --git a/etc/platform-configs/hermit/compiler/cray b/etc/platform-configs/hermit/compiler/cray new file mode 100644 index 0000000..7c98f53 --- /dev/null +++ b/etc/platform-configs/hermit/compiler/cray @@ -0,0 +1,3 @@ +#!/bin/bash +COMPILER_OPTS="CC=cc CXX=CC FC=ftn F77=tfn" +COMPILER_VERSION_CMD="cc -V 2>&1| awk '/Version/{ print \$5; }'" diff --git a/etc/platform-configs/hermit/compiler/gnu b/etc/platform-configs/hermit/compiler/gnu new file mode 100644 index 0000000..c0af6aa --- /dev/null +++ b/etc/platform-configs/hermit/compiler/gnu @@ -0,0 +1,3 @@ +#!/bin/bash +COMPILER_OPTS="CC=cc CXX=CC FC=ftn F77=tfn" +COMPILER_VERSION_CMD="cc -dumpversion" diff --git a/etc/platform-configs/hermit/compiler/intel b/etc/platform-configs/hermit/compiler/intel new file mode 100644 index 0000000..c0af6aa --- /dev/null +++ b/etc/platform-configs/hermit/compiler/intel @@ -0,0 +1,3 @@ +#!/bin/bash +COMPILER_OPTS="CC=cc CXX=CC FC=ftn F77=tfn" +COMPILER_VERSION_CMD="cc -dumpversion" diff --git a/etc/platform-configs/hermit/compiler/pgi b/etc/platform-configs/hermit/compiler/pgi new file mode 100644 index 0000000..e5c81fd --- /dev/null +++ b/etc/platform-configs/hermit/compiler/pgi @@ -0,0 +1,3 @@ +#!/bin/bash +COMPILER_OPTS="CC=cc CXX=CC FC=ftn F77=ftn" +COMPILER_VERSION_CMD="cc -V 2> /dev/null | awk '/pgcc/{print \$2}' | sed -e 's/-/./'" diff --git a/etc/platform-configs/hermit/compiler/system b/etc/platform-configs/hermit/compiler/system new file mode 100644 index 0000000..918f7db --- /dev/null +++ b/etc/platform-configs/hermit/compiler/system @@ -0,0 +1,3 @@ +#!/bin/bash +COMPILER_OPTS="CC=gcc CXX=g++ FC=gfortran F77=gfortran" +COMPILER_VERSION_CMD="gcc -dumpversion" diff --git a/etc/platform-configs/laki/compiler/gnu b/etc/platform-configs/laki/compiler/gnu new file mode 100644 index 0000000..918f7db --- /dev/null +++ b/etc/platform-configs/laki/compiler/gnu @@ -0,0 +1,3 @@ +#!/bin/bash +COMPILER_OPTS="CC=gcc CXX=g++ FC=gfortran F77=gfortran" +COMPILER_VERSION_CMD="gcc -dumpversion" diff --git a/etc/platform-configs/laki/compiler/intel b/etc/platform-configs/laki/compiler/intel new file mode 100644 index 0000000..c4539a1 --- /dev/null +++ b/etc/platform-configs/laki/compiler/intel @@ -0,0 +1,3 @@ +#!/bin/bash +COMPILER_OPTS="CC=icc CXX=icpc++ FC=ifort F77=ifort" +COMPILER_VERSION_CMD="icc -dumpversion" diff --git a/etc/platform-configs/laki/compiler/pgi b/etc/platform-configs/laki/compiler/pgi new file mode 100644 index 0000000..4b3e753 --- /dev/null +++ b/etc/platform-configs/laki/compiler/pgi @@ -0,0 +1,3 @@ +#!/bin/bash +COMPILER_OPTS="CC=pgcc CXX=pgCC FC=pgf95 F77=pgf77" +COMPILER_VERSION_CMD="pgcc -V | awk '/pgcc/{print \$2}' | sed -e 's/-/./'" diff --git a/etc/platform-configs/laki/compiler/system b/etc/platform-configs/laki/compiler/system new file mode 120000 index 0000000..9893768 --- /dev/null +++ b/etc/platform-configs/laki/compiler/system @@ -0,0 +1 @@ +gnu \ No newline at end of file diff --git a/sit b/sit index e6fe48f..157e5e4 100755 --- a/sit +++ b/sit @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh -l # # Install script inspired by the ebuild system of Gentoo Linux # @@ -17,6 +17,21 @@ if [[ -e $SIT_CONFIG_FILE ]] ; then fi source "$SIT_PATH/functions.sh" +# check platform +# TODO: add ip addresses for identification? +case $HOSTNAME in + cl3fr1|cl3fr2|imager) + PLATFORM="laki" + ;; + xe601) + PLATFORM="hermit" + ;; + *) + sit_fail "Unknown host $HOSTNAME" + ;; +esac + +sit_info "Platform: $PLATFORM" # compiler to use # (gnu|intel|pgi) @@ -30,51 +45,53 @@ PACKAGE_DESCRIPTOR=${PACKAGE_DESCRIPTOR:+-$PACKAGE_DESCRIPTOR} # Compiler specifications - -if [ "$COMPILER" == "system" ] ; then - echo "Using system default compiler" -else - if [ -z "$COMPILER_VERSION" ] ; then - COMPILER_MODULE=compiler/${COMPILER} - else - COMPILER_MODULE=compiler/${COMPILER}/${COMPILER_VERSION} - fi - - echo "Loading compiler module ${COMPILER_MODULE}" - module load ${COMPILER_MODULE} +COMPILER_CONFIG_FILE="$SIT_PATH/etc/platform-configs/${PLATFORM}/compiler/${COMPILER}" +if [ -e $COMPILER_CONFIG_FILE ] ; then + source $COMPILER_CONFIG_FILE +else + sit_fail "Could not find configuration file for compiler '${COMPILER}' on platform '${PLATFORM}'." fi -case ${COMPILER} in - system) - COMPILER="" # prevent any compiler specs in the prefix - ;; - gnu) - COMPILER_OPTS="CC=gcc CXX=g++ FC=gfortran F77=gfortran" - if [ "x${COMPILER_VERSION}" == "x" ] ; then - COMPILER_VERSION=$(gcc -dumpversion) - fi - ;; - intel) - COMPILER_OPTS="CC=icc CXX=icpc FC=ifort F77=ifort" - if [ "x${COMPILER_VERSION}" == "x" ] ; then - COMPILER_VERSION=$(icc -dumpversion) - fi - ;; - pgi) - COMPILER_OPTS="CC=pgcc CXX=pgCC FC=pgf95 F77=pgf77" - if [ "x${COMPILER_VERSION}" == "x" ] ; then - COMPILER_VERSION=$(pgcc -V | awk '/pgcc/{print $2}') - fi - ;; - *) - echo "Unknown compiler ${COMPILER}." - ;; + +case $PLATFORM in + hermit) + if [ "$COMPILER" == "system" ] ; then + echo "Using system default compiler" + COMPILER="" # prevent any compiler specs in the prefix + else + module swap $(module list -l 2>&1 | awk '/^PrgEnv-/{print $1}') PrgEnv-${COMPILER} + if [ ! -z "$COMPILER_VERSION" ] ; then + if [ "${COMPILER}" == "gnu" ] ; then + module swap gcc gcc/$COMPILER_VERSION + else + module swap $COMPILER $COMPILER/$COMPILER_VERSION + fi + fi + fi + ;; + laki|*) + if [ "$COMPILER" == "system" ] ; then + echo "Using system default compiler" + COMPILER="" # prevent any compiler specs in the prefix + else + if [ -z "$COMPILER_VERSION" ] ; then + COMPILER_MODULE=compiler/${COMPILER} + else + COMPILER_MODULE=compiler/${COMPILER}/${COMPILER_VERSION} + fi + echo "Loading compiler module ${COMPILER_MODULE}" + module load ${COMPILER_MODULE} + fi + ;; esac +# reevaluate compiler version +COMPILER_VERSION=$(eval "$COMPILER_VERSION_CMD") # make the compiler variables CC, CXX, FC and F77 available if [ ! -z "$COMPILER_OPTS" ] ; then export ${COMPILER_OPTS} fi +echo "Using compiler: $COMPILER version: $COMPILER_VERSION" if [ ! -z "$MPI" ] ; then MPI_MODULE="mpi/$MPI" @@ -97,6 +114,7 @@ else sit_fail "Could not find file $SCLASS_DIR/$SCLASSFILE" fi +PACKAGENAME=${PACKAGENAME:=$PACKAGE} # construct the final installation directory path PREFIX="${PREFIX_BASE}/${CATEGORY}/${PACKAGE}/${VERSION}" @@ -125,13 +143,14 @@ LOGDIR=${WORKDIR} # the class file like CATEGORY or PACKAGE) source $SCLASS_DIR/$SCLASSFILE +echo "Package name: $PACKAGENAME" echo "Installation PREFIX: $PREFIX" echo "Working dir: $WORKDIR" echo "Source dir: $SRCDIR" echo "Build dir: $BUILDDIR" echo "Logfile dir: $LOGDIR" -sit_countdown 2 +sit_countdown 3 if [ -d ${WORKDIR} ] ; then sit_info "Removing existing working directory ${WORKDIR}"