89 lines
3.1 KiB
Bash
89 lines
3.1 KiB
Bash
#!/usr/bin/env bash
|
|
# this job file is a template file for starbench jobs
|
|
git_repos_url="$1" # eg "https://github.com/hibridon/hibridon"
|
|
git_user="$2" # eg 'g-raffy'
|
|
git_pass_file="$3" # eg "$HOME/.github/personal_access_tokens/bench.hibridon.cluster.ipr.univ-rennes1.fr.pat"
|
|
code_version="$4" # git branch id or commit id eg : 'a3bed1c3ccfbca572003020d3e3d3b1ff3934fad'
|
|
cmake_options="$5" # eg '-DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON'
|
|
benchmark_command="$6" # eg 'ctest -L ^arch4_quick$'
|
|
env_vars_bash_commands="$7" # defines extra environment variables prior to launch starbench. eg "export MKLROOT=/opt/intel/compilers_and_libraries_2020.1.217/linux/mkl"
|
|
|
|
cmake_path='/opt/cmake/cmake-3.23.0/bin/cmake'
|
|
executed_by_sge=''
|
|
|
|
if [ "${JOB_ID}" = '' ]
|
|
then
|
|
executed_by_sge='false'
|
|
# this script is not executed by sge... set dummy values for test
|
|
TMPDIR=/tmp
|
|
JOB_ID=666666
|
|
NSLOTS=2
|
|
else
|
|
executed_by_sge='true'
|
|
fi
|
|
|
|
launch_dir="$(pwd)"
|
|
|
|
echo "Executing job ${JOB_ID} on $(hostname) from ${launch_dir}"
|
|
echo "date: $(date --iso-8601=seconds)"
|
|
temp_dir=${TMPDIR}/$(whoami)/${JOB_ID}
|
|
if [ -d "${temp_dir}" ]
|
|
then
|
|
rm -Rf "${temp_dir}"
|
|
fi
|
|
mkdir -p "${temp_dir}"
|
|
|
|
# extract starbench.py from this job script
|
|
starbench_path="${temp_dir}/starbench.py"
|
|
|
|
output_dir="${temp_dir}"
|
|
num_cores=${NSLOTS}
|
|
|
|
# the starbench.py code is expected to be included in the job script as a replacement of the tag include:starbench.py
|
|
cat <<-'EOF' > "${starbench_path}"
|
|
<include:starbench.py>
|
|
EOF
|
|
|
|
chmod a+x "$starbench_path"
|
|
|
|
# set environment variables
|
|
|
|
echo "env_vars_bash_commands=$env_vars_bash_commands"
|
|
eval $env_vars_bash_commands
|
|
|
|
# launch starbench
|
|
|
|
command="${starbench_path}"
|
|
command="${command} --git-repos-url ${git_repos_url}"
|
|
command="${command} --git-user ${git_user}"
|
|
command="${command} --git-pass-file ${git_pass_file}"
|
|
command="${command} --num-cores ${num_cores}"
|
|
command="${command} --output-dir ${output_dir}"
|
|
command="${command} --code-version ${code_version}"
|
|
command="${command} --cmake-path ${cmake_path}"
|
|
# echo "cmake_options: @$cmake_options@"
|
|
for cmake_option in ${cmake_options}
|
|
do
|
|
command="${command} --cmake-option=${cmake_option}"
|
|
done
|
|
command="${command} --benchmark-command=\"${benchmark_command}\""
|
|
|
|
echo "command: ${command}"
|
|
eval ${command}
|
|
if [ "$?" = '0' ]
|
|
then
|
|
echo "the command ${command} succeeded"
|
|
rsync -va --exclude 'build' --exclude 'source.git' "${output_dir}/" ${launch_dir}/ # exclude the source.git and build directories (one for each worker) because they are big and not that precious
|
|
# TMPDIR will be deleted by sge at the end of the job
|
|
else
|
|
if [ ${executed_by_sge} = 'true' ]
|
|
then
|
|
# TMPDIR will be deleted by sge at the end of the job. Backup data for investigation
|
|
backup_dir="/opt/ipr/cluster/work.local/$(whoami)/${JOB_ID}"
|
|
echo "moving ${output_dir} to ${backup_dir} to that it doesn't get deleted by sge at the end of the job. This way, data gets a chance to be investagated then manually deleted."
|
|
mv "${output_dir}" "${backup_dir}"
|
|
fi
|
|
echo "the command ${command} failed... the output data dir (${output_dir}) is expected to be cleaned up manually after investigation"
|
|
exit 1
|
|
fi
|