-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjob.sh
executable file
·67 lines (57 loc) · 1.82 KB
/
job.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
## Common code executed by the Slurm file for each configuration
# Stop the script if any part fails
set -e
# Uncomment these two lines if we ask you for debugging information
# echo "DEBUG: All Slurm environment variables for this job"
# printenv | grep SLURM
# Debug info for where the job is running
# We use srun to run this on all nodes allocated to us
srun bash -c 'echo "Job is running on $(hostname), started at $(date)"'
# Set debug level to 0 if we didn't pass any environment variables
DEBUG=${DEBUG:-0}
# Set the "use sequential" condition to 0 if we didn't pass any env vars
SEQ=${SEQ:-0}
# Compile the code at the appropriate debug level
echo "Running make to compile your code..."
make
# Choose the right executable to run
if [ "$SEQ" -eq 1 ]; then
# Use the sequential executable
EXECUTABLE="distr-sched-seq"
else
# Choose the right executable based on the DEBUG level
case "$DEBUG" in
0)
EXECUTABLE="distr-sched"
;;
1)
EXECUTABLE="distr-sched-debug1"
;;
2)
EXECUTABLE="distr-sched-debug2"
;;
*)
echo "Invalid value for DEBUG: $DEBUG"
exit 1
;;
esac
fi
# Creating temp job file
TMP_JOB_FILE="/tmp/$SLURM_JOB_ID.txt"
touch $TMP_JOB_FILE
chmod 700 $TMP_JOB_FILE
echo "Created temporary file on $(hostname) for job output evaluation after this run at $TMP_JOB_FILE"
# Run your executable and pass all arguments to it
echo "Running..."
set -x
perf stat -- mpirun --map-by core --bind-to core ./$EXECUTABLE $@ | tee $TMP_JOB_FILE
set +x
# Evaluate the results, default is to evaluate
EVALUATE=${EVALUATE:-1}
if [ "$EVALUATE" -eq 1 ]; then
echo "Evaluating your results...";
./check.py $@ < $TMP_JOB_FILE;
fi
# Remove the tmp file if it exists
rm -f $TMP_JOB_FILE