forked from arbor-sim/nsuite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-bench.sh
executable file
·185 lines (153 loc) · 4.83 KB
/
run-bench.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#!/usr/bin/env bash
usage() {
cat <<_end_
Usage: run-bench.sh [OPTIONS] SIMULATOR
Run NSuite benchmarks for SIMULATOR.
Options:
--help Print this help mesage.
--prefix=PATH Use PATH as base for working directories.
--model=MODEL Run benchmark MODEL.
--config=CONFIG Run benchmarks with configuration CONFIG.
--output=FORMAT Override default path to benchmark outputs.
SIMULATOR One of: arbor, neuron, or coreneuron.
--model and --config can be supplied multiple times. If omitted, the ring
benchmark will be run with the small configuration.
The output FORMAT is a pattern that is used to determine the output
directory for any given simulator, model and parameter set. If the
resulting path is not absolute, it will be taken relative to
the path PREFIX/output/benchmark.
Fields in FORMAT are substituted as follows:
%T Timestamp of invocation of install-local.sh.
%H Git commit hash of nsuite (with + on end if modified).
%h Git commit short hash of nsuite (with + on end if modified).
%S System name (if defined in system environment script) or host name.
%s Simulator name.
%m Model name.
%p Config name.
%% Literal '%'.
If no --output option is provided, the default FORMAT %m/%p/%s is used.
_end_
exit 0
}
argerror() {
cat >&2 <<_end_
run-bench.sh: $1
Try 'run-bench.sh --help' for more information.
_end_
exit 1
}
# Determine NSuite root and default ns_prefix.
unset CDPATH
ns_base_path=$(cd "${BASH_SOURCE[0]%/*}"; pwd)
ns_prefix=${NS_PREFIX:-$(pwd)}
# Parse arguments.
run_arb=false
run_nrn=false
run_corenrn=false
unset ns_bench_output_format
while [ "$1" != "" ]
do
case $1 in
arbor )
run_arb=true
;;
neuron )
run_nrn=true
;;
coreneuron )
run_corenrn=true
;;
--help )
usage
;;
--prefix=* )
ns_prefix="${1#--prefix=}"
;;
--prefix )
shift
ns_prefix=$1
;;
--output=* )
ns_bench_output_format="${1#--output=}"
;;
--output )
shift
ns_bench_output_format=$1
;;
--model )
shift
models="$models $1"
;;
--model=* )
models="$models ${1#--model=}"
;;
--model )
shift
models="$models $1"
;;
--config=* )
configs="$configs ${1#--config=}"
;;
--config )
shift
configs="$configs $1"
;;
* )
argerror "unknown option '$1'"
esac
shift
done
models=${models:-ring}
configs=${configs:-small}
# Load utility functions and set up default environment.
source "$ns_base_path/scripts/util.sh"
mkdir -p "$ns_prefix"
ns_prefix=$(full_path "$ns_prefix")
source "$ns_base_path/scripts/environment.sh"
default_environment
export PATH="$ns_base_path/common/bin:$PATH"
# Grab timestamp and sysname from build directory for export.
ns_timestamp=$(< "$ns_build_path/timestamp")
ns_sysname=$(< "$ns_build_path/sysname")
export ns_timestamp
export ns_sysname
# Check simulator installation status.
if [ "$run_arb" == "true" ]; then
[ ! -f "$ns_prefix/config/env_arbor.sh" ] && err "Arbor must be installed to run Arbor benchmarks." && run_arb=false
fi
if [ "$run_nrn" == "true" ]; then
[ ! -f "$ns_prefix/config/env_neuron.sh" ] && err "NEURON must be installed to run NEURON benchmarks." && run_nrn=false
fi
if [ "$run_corenrn" == "true" ]; then
[ ! -f "$ns_prefix/config/env_coreneuron.sh" ] && err "CoreNeuron must be installed to run CoreNeuron benchmarks." && run_corenrn=false
fi
# TODO: this has to go into the configuration environment setup scripts
export ARB_NUM_THREADS=$[ $ns_threads_per_core * $ns_cores_per_socket ]
msghi "NSuite benchmark runner"
echo
msg "models: $models"
msg "configs: $configs"
echo
mkdir -p "$ns_bench_input_path"
for model in $models
do
model_config_path="$ns_base_path/benchmarks/models/$model"
cd "$model_config_path"
for config in $configs
do
model_input_path="$ns_bench_input_path/$model/$config"
"$model_config_path/config.sh" "$model" "$config" "$ns_base_path" "$ns_config_path" "$ns_bench_input_path" "$ns_bench_output" "${ns_bench_output_format:-%m/%p/%s}"
if [ "$run_arb" == "true" ]; then
msghi benchmark: arbor $model-$config
"$model_input_path/run_arb.sh"
fi
if [ "$run_nrn" == "true" ]; then
msghi benchmark: neuron $model-$config
"$model_input_path/run_nrn.sh"
fi
if [ "$run_corenrn" == "true" ]; then
msghi benchmark: coreneuron $model-$config
"$model_input_path/run_corenrn.sh"
fi
done
done