-
Notifications
You must be signed in to change notification settings - Fork 11
/
submit.sh
executable file
·128 lines (114 loc) · 3.9 KB
/
submit.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
function echo_good
{
echo -e "\033[32m$1\033[0m\c"
}
function echo_bad
{
echo -e "\033[31m$1\033[0m\c"
}
function echo_success
{
echo_good "[SUCCESS]"
echo " $1"
}
function echo_failure
{
echo_bad "[FAILURE]"
echo " $1"
exit -1
}
# Function taken from Meta Stack Overflow (https://meta.stackoverflow.com)
# Author: Glenn Jackman (profile: https://stackoverflow.com/users/7552/glenn-jackman)
# Original article: https://stackoverflow.com/a/14367368
function is_in_array
{
local array="$1[@]"
local seeking=$2
local in=1
for element in "${!array}"; do
if [[ $element == $seeking ]]; then
in=0
break
fi
done
return $in
}
###########################################
# Check that the right modules are loaded #
###########################################
if ! type "pgcc" > /dev/null 2>&1; then \
clear; \
echo -e "\n . "; \
echo -e " / \\"; \
echo -e " / ! \\ It looks like the PGI compiler is not loaded."; \
echo -e " /_____\\ On Bridges please issue 'module load cuda/9.2 mpi/pgi_openmpi/19.4-nongpu'. You can now make again :)\n"; \
exit -1; \
fi
######################
# Display quick help #
######################
clear;
echo "Quick help:";
echo " - This script is meant to be submit as follows: './submit.sh LANGUAGE IMPLEMENTATION SIZE OUTPUT_FILE'";
echo " - LANGUAGE = 'C' | 'FORTRAN'";
echo " - IMPLEMENTATION = 'serial' | 'openmp' | 'mpi' | 'hybrid_cpu' | 'openacc' | 'hybrid_gpu'";
echo " - SIZE = 'small' | 'big'";
echo " - OUTPUT_FILE = the path to the file in which store the output.";
echo " - Example: to submit the C serial version on the small grid, submit './submit.sh C serial small'.";
echo "";
#################################
# Check the number of arguments #
#################################
if [ "$#" -eq "4" ]; then
echo_success "Correct number of arguments received."
else
echo_failure "Incorrect number of arguments received; $# passed whereas 4 are expected. Please refer to the quick help above."
fi
#############################################
# Check that the language passed is correct #
#############################################
languages=("C" "FORTRAN");
all_languages=`echo ${languages[@]}`;
is_in_array languages $1
language_retrieved=$?;
if [ "${language_retrieved}" == "0" ]; then
echo_success "The language passed is correct.";
else
echo_failure "The language '$1' is unknown. It must be one of: ${all_languages}.";
fi
###################################################
# Check that the implementation passed is correct #
###################################################
implementations=("serial" "openmp" "mpi" "hybrid_cpu" "openacc" "hybrid_gpu");
all_implementations=`echo ${implementations[@]}`;
is_in_array implementations $2
implementation_retrieved=$?;
if [ "${implementation_retrieved}" == "0" ]; then
echo_success "The implementation passed is correct.";
else
echo_failure "The implementation '$2' is unknown. It must be one of: ${all_implementations}.";
fi
#########################################
# Check that the size passed is correct #
#########################################
sizes=("small" "big");
all_sizes=`echo ${sizes[@]}`;
is_in_array sizes $3
size_retrieved=$?;
if [ "${size_retrieved}" == "0" ]; then
echo_success "The size passed is correct.";
else
echo_failure "The size '$3' is unknown. It must be one of: ${all_sizes}.";
fi
#########################################################
# Check that the corresponding submission script exists #
#########################################################
slurm_scripts_path="./slurm_scripts";
slurm_script_to_submit="${slurm_scripts_path}/$2_$3.slurm";
if [ -f "${slurm_script_to_submit}" ]; then
echo_success "The corresponding submission script \"${slurm_script_to_submit}\" has been found."
else
echo_failure "The corresponding submission script \"${slurm_script_to_submit}\"has not been found."
fi
sbatch ${slurm_script_to_submit} $1 $4