#!/bin/bash -l set -ev # exit on any error; echo commands # this script requires two variables $GIT_COMMIT and $TARGET. # The former spcifies with git commit to install, the latter # specifies the target system, ie "laki" or "hermit". if [ -z ${GIT_COMMIT} ]; then echo "Need to define variable GIT_COMMIT on commandline .. exiting."; exit 1; fi if [ -z ${TARGET} ]; then echo "Need to define variable TARGET on commandline .. exiting."; exit 1; fi if [ ${TARGET} = "laki" ]; then echo "Building for laki." else if [ ${TARGET} = "hermit" ]; then echo "Building for hermit." else if [ ${TARGET} = "hermit_cray" ]; then echo "Building for hermit with Cray compiler." else echo "TARGET needs to be laki, hermit or hermit_cray... exiting." exit 1 fi fi fi # you *may* also specigy a git repository if [ -z ${GIT_REPO} ]; then GIT_REPO=hlrs-gitolite:hlrs-text fi echo "Getting source for repository $GIT_REPO" COMPILER=gnu-4.5 if [ ${TARGET} = "hermit_cray" ]; then COMPILER=cray TARGET=hermit fi # ok, we are good to go STARSS_OPT_DIR=/sw/${TARGET}/hlrs/StarSs STARSS_VERSION=2.4_c${GIT_COMMIT}-${COMPILER} STARSS_DIR=${STARSS_OPT_DIR}/${STARSS_VERSION} WORK_DIR=${HOME}/src # clean up mess from previous builds cd ${WORK_DIR}; rm -rf hlrs-text StarSs_c${GIT_COMMIT} Ayudame_c${GIT_COMMIT} rm -rf $STARSS_DIR if [ ${TARGET} = "laki" ]; then rm -f StarSs_c${GIT_COMMIT}.tar Ayudame_c${GIT_COMMIT}.tar fi # load modules if [ ${TARGET} = "laki" ]; then module load compiler/gnu/4.5 module use /opt/amtopt/autotools/modulefiles module load local module load system/perfctr system/papi/4.1.2.1a PAPI_DIR=/sw/laki/hlrs/system/papi/4.1.2.1a fi if [ ${TARGET} = "hermit" ]; then if [ ${COMPILER} = "cray" ]; then module swap $(module list -l 2>&1 | awk '/^PrgEnv-/{print $1}') PrgEnv-cray module load gcc else module swap $(module list -l 2>&1 | awk '/^PrgEnv-/{print $1}') PrgEnv-gnu fi fi # prep git repo, needs hlrs-gitolite in .ssh/config and ssh key cd ${WORK_DIR} if [ ${TARGET} = "laki" ]; then git clone ${GIT_REPO} hlrs-text cd hlrs-text git checkout -b ayudame origin/ayudame cd ProgModel/SMPSs_repository/starss git archive --format=tar --prefix=StarSs_c${GIT_COMMIT}/ -o ${WORK_DIR}/StarSs_c${GIT_COMMIT}.tar ${GIT_COMMIT} . cd ../../../Tools/Ayudame git archive --format=tar --prefix=Ayudame_c${GIT_COMMIT}/ -o ${WORK_DIR}/Ayudame_c${GIT_COMMIT}.tar ${GIT_COMMIT} . fi # unpack, configure and build cd ${WORK_DIR} tar xvf StarSs_c${GIT_COMMIT}.tar tar xvf Ayudame_c${GIT_COMMIT}.tar cd StarSs_c${GIT_COMMIT} if [ ${COMPILER} = "cray" ]; then tar xvf ../StarSs_patch_cray.tar cat c-metadriver/SMPCompiler.cc | \ sed 's/compiler.addArgument(std::string("--cpp=") + m_options.m_compiler/compiler.addArgument(std::string("--cpp=gcc")/' > c-metadriver/SMPCompiler.cc_next mv c-metadriver/SMPCompiler.cc_next c-metadriver/SMPCompiler.cc fi # install dependencies first tar xvjf $WORK_DIR/libbitmask-2.0.tar.bz2 tar xvjf $WORK_DIR/libcpuset-1.0.tar.bz2 cd libbitmask && autoreconf -fiv && ./configure --prefix=$STARSS_DIR && make install cd ../libcpuset && autoreconf -fiv && ./configure CFLAGS=-I$STARSS_DIR/include LDFLAGS=-L$STARSS_DIR/lib --prefix=$STARSS_DIR && make install cd .. # ok, now StarSs autoreconf -fiv 2>&1 | tee autoreconf.log PAPI_CONF= if [ ${TARGET} = "laki" ]; then PAPI_CONF="--enable-papi --with-papi=$PAPI_DIR" fi if [ ${COMPILER} = "cray" ]; then ./configure CC=gcc SMPFC=ftn SMPCC=cc SMPFPP=gfortran SMPCXX=g++ \ --prefix=$STARSS_DIR \ --with-flavour=smp \ --enable-comm-thread \ --with-libcpuset=$STARSS_DIR \ --with-ayudame-include=${WORK_DIR}/Ayudame_c${GIT_COMMIT}/include \ ${PAPI_CONF} \ # empty line else ./configure \ --prefix=$STARSS_DIR \ --with-flavour=smp \ --enable-comm-thread \ --with-libcpuset=$STARSS_DIR \ --with-ayudame-include=${WORK_DIR}/Ayudame_c${GIT_COMMIT}/include \ ${PAPI_CONF} \ # empty line fi make 2>&1 | tee make.log make install 2>&1 | tee make_install.log # save logs gzip autoreconf.log; gzip config.log; gzip make.log ; gzip make_install.log cp -a autoreconf.log.gz config.log.gz make.log.gz make_install.log.gz $STARSS_DIR # copy header files #mkdir $STARSS_DIR/include/master #cp -a master/*.h $STARSS_DIR/include/master/ cd .. # do Ayudame cd Ayudame_c${GIT_COMMIT} #cat makefile | \ # sed "s/INCLUDE =.*/INCLUDE = ${WORK_DIR}/StarSs_c${GIT_COMMIT}/master/" \ # makefile_new #mv makefile_new makefile #make SMPSS_DIR=${WORK_DIR}/StarSs_c${GIT_COMMIT}/master/ make cd .. # hacky install of Temanejo/Ayudame cd Ayudame_c${GIT_COMMIT} mkdir $STARSS_DIR/temanejo cp -a *.py resources libayudame.so $STARSS_DIR/temanejo ln -s $STARSS_DIR/temanejo/temanejo.py $STARSS_DIR/bin cd ../StarSs_c${GIT_COMMIT} # setup smpss-cc.conf if [ ${TARGET} = "hermit" ]; then cd $STARSS_DIR/etc cp -a smpss-cc.conf smpss-cc.conf_orig cat smpss-cc.conf | \ sed "s/^compiler =.*/compiler = cc/" | \ sed "s/^linker =.*/linker = CC/" | \ sed "s/^linker_parameters =.*/\0 -dynamic/" | \ sed "s/^fortran_compiler =.*/fortran_compiler = ftn/" | \ sed "s/^fortran_libs =.*/#\0\nfortran_libs = -lm/" \ > smpss-cc.conf_next mv smpss-cc.conf_next smpss-cc.conf if [ ${COMPILER} = "cray" ]; then cat smpss-cc.conf | \ sed "s/mf95ss_variables = .*/mf95ss_variables = --variable=int_size:4 --variable=size_t_size:8 --variable=void_p_size:8 --variable=long_size:8/" \ > smpss-cc.conf_next mv smpss-cc.conf_next smpss-cc.conf cd ../share/mcxx/config.d cat config.superscalar | \ sed "s/{gcc} compiler_options = .*/#\0\n{gcc} compiler_options = -hgnu/" \ > config.superscalar_next mv config.superscalar_next config.superscalar fi fi # do module cd $STARSS_OPT_DIR chmod -R g=u $STARSS_VERSION chmod -R o=u-w $STARSS_VERSION cd modulefiles cat 2.4_testing-${COMPILER} | \ sed "s/set VERSION.*/set VERSION ${STARSS_VERSION}/" | \ sed "s/ Installed.*/ Installed `date`/" > ${STARSS_VERSION}_next mv ${STARSS_VERSION}_next ${STARSS_VERSION} chmod 664 ${STARSS_VERSION} rm 2.4_testing-${COMPILER} ln -s ${STARSS_VERSION} 2.4_testing-${COMPILER}