Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script for building LC TPLs with Uberenv #252

Merged
merged 7 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions scripts/setupLC-TPL-uberenv-helper.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

## Builds the TPLs for a specific system and host config.
## Usage ./setupLC-TPL-uberenv-helper.bash pathToInstallDirectory machine compiler spackSpecToBuild commandToGetANode
INSTALL_DIR=$1
MACHINE=$2
COMPILER=$3
SPEC=\"${4}\"
GET_A_NODE=$5

## Eat up the command line arguments so the rest can be forwarded to config-build.
shift
shift
shift
shift
shift

CONFIG=$MACHINE-$COMPILER
LOG_FILE=$CONFIG.log

echo "Building the TPLs on $MACHINE for $COMPILER to be installed at $INSTALL_DIR. Progress will be written to $LOG_FILE."

ssh $MACHINE -t "
. /etc/profile &&
cd $PWD/tempGEOS &&
$GET_A_NODE ./scripts/uberenv/uberenv.py --spec ${SPEC} --prefix ${INSTALL_DIR}/${CONFIG}_tpls --spack-env-name ${CONFIG}_env &&
exit" > $LOG_FILE 2>&1

## Check the last ten lines of the log file.
## A successful install should show up on one of the final lines.
tail -10 $LOG_FILE | grep -E "Successfully installed geos" > /dev/null
if [ $? -eq 0 ]; then
chmod g+rx -R $INSTALL_DIR
chgrp GEOS -R $INSTALL_DIR
echo "Build of ${CONFIG} completed successfully."
exit 0
else
echo "Build of ${CONFIG} seemed to fail, check $LOG_FILE."
exit 1
fi
76 changes: 76 additions & 0 deletions scripts/setupLC-TPL-uberenv.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/bash

## Builds the TPLs on all LC systems. Must be run from the top level TPL directory.
## Usage ./setupLC-TPL.bash branchToBuild pathToInstallDirectory
GEOS_BRANCH=$1
INSTALL_DIR=$2

## Eat up the command line arguments so the rest can be forwarded to setupLC-TPL-helper.
shift
shift

## Trap the interupt signal and kill all children.
trap 'killall' INT

killall() {
trap '' INT TERM # ignore INT and TERM while shutting down
echo "**** Shutting down. Killing chid processes ****" # added double quotes
kill -TERM 0 # fixed order, send TERM not INT
wait
echo DONE
}

# Check if branch exists
branch_exists=$(git ls-remote https://github.com/GEOS-DEV/GEOS.git $GEOS_BRANCH | wc -l)

if [[ $branch_exists != 1 ]] ; then
echo "Branch $GEOS_BRANCH does not exist in GEOS repository"
exit
fi

if [[ -z $INSTALL_DIR ]]; then
echo "No installation directory path was provided"
exit
fi

if [[ ! -d $INSTALL_DIR ]]; then
echo "Installation directory $INSTALL_DIR does not exist. Please initialize first."
exit
fi

if [[ ! "$INSTALL_DIR" = /* ]]; then
echo "Installation directory $INSTALL_DIR must be an absolute path."
exit
fi

# Clone GEOS repo to build with uberenv
echo "Cloning branch $GEOS_BRANCH in temporary GEOS repo directory tempGEOS to build TPLs with uberenv..."
rm -rf tempGEOS
git clone -b $GEOS_BRANCH https://github.com/GEOS-DEV/GEOS.git tempGEOS

cd tempGEOS
git submodule init scripts/uberenv
git submodule update
cd ..

echo "Building all LC TPLs from $GEOS_BRANCH to be installed at $INSTALL_DIR..."
chmod -R g+rx $INSTALL_DIR
chgrp -R GEOS $INSTALL_DIR
./scripts/setupLC-TPL-uberenv-helper.bash $INSTALL_DIR quartz clang-14 "%[email protected] +docs" "salloc -N 1 -t 150 " $@ &
./scripts/setupLC-TPL-uberenv-helper.bash $INSTALL_DIR quartz gcc-12 "%[email protected] +docs" "salloc -N 1 -t 150 " $@ &
./scripts/setupLC-TPL-uberenv-helper.bash $INSTALL_DIR lassen gcc-8-cuda-11 "%[email protected]+cuda~uncrustify cuda_arch=70 ^[email protected]+allow-unsupported-compilers" "lalloc 1 -W 150" $@ &
./scripts/setupLC-TPL-uberenv-helper.bash $INSTALL_DIR lassen clang-13-cuda-11 "%[email protected]+cuda~uncrustify cuda_arch=70 ^[email protected]+allow-unsupported-compilers" "lalloc 1 -W 150" $@ &
./scripts/setupLC-TPL-uberenv-helper.bash $INSTALL_DIR lassen clang-10-cuda-11 "%[email protected]+cuda~uncrustify cuda_arch=70 ^[email protected]+allow-unsupported-compilers" "lalloc 1 -W 150" $@ &

# Note: Estimated completion time is ~90 minutes.
# Check log files for unreported completion of jobs.
wait

echo "Copying generated host-configs from tempGEOS directory..."
cd tempGEOS && cp *.cmake ..

echo "Removing temporary GEOS repo tempGEOS..."
rm -rf tempGEOS

echo "Complete"