-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.sh
executable file
·118 lines (97 loc) · 3.06 KB
/
run.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
#! /bin/bash
#
# Copyright (C) 2020 ETH Zurich. All rights reserved.
#
# Author: Tibor Schneider, ETH Zurich
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the License); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an AS IS BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
PLATFORM="gvsoc"
RUN=true
GTKWAVE=false
TRAIN=false
CHIP="wolfe"
while getopts "bvp:nwtfde:h" name; do
case "$name" in
b) PLATFORM="board";;
v) CHIP="vega";;
p) PLATFORM=$OPTARG;;
n) RUN=false;;
w) GTKWAVE=true;;
t) TRAIN=true;;
h) printf "Usage: %s [-b] [-p platform] [-h] [-n] [-w]\n" $0
printf " -b build on the board, equivalent to -p board\n"
printf " -p <platform> build on the desired platform [board | gvsoc], default is gvsoc\n"
printf " -v use vega instead of mr. wolf\n"
printf " -n do not run the program, just build it\n"
printf " -w generate GTK wave files\n"
printf " -h show this help message\n"
exit 0;;
?) printf "Usage: %s [-b] [-p platform] root_folder\n" $0
exit 2;;
esac
done
# to be able to use conda activate in bash scripts
source $CONDA_BASE_PREFIX/etc/profile.d/conda.sh
if [ "$TRAIN" = true ]; then
printf "Training the network...\n\n"
# enter python bci directory
cd multiscale_bci_python
# activate the environment for python3.8
conda activate mrc
# train the network (for one subject only) and export the data to the ../data directory
python3.8 main_riemannian.py -e -f ../data
# deactivate pyhon3.8 env and go with python2.7 and python3.5/3.6 env
conda deactivate
# go back to the root hdirectory
cd ..
fi
printf "Running MRC on Platform: %s\n\n" $PLATFORM
# set the platform
PULP_CURRENT_CONFIG_ARGS="platform=$PLATFORM"
# build python utils
cd python_utils
make
cd ..
# add python_utils to the python path
export PYTHONPATH=$(pwd)/python_utils:$(pwd)/multiscale_bci_python:$PYTHONPATH
# enter data directory
cd data
conda activate mrc
# generate net header file
python3.8 generate_mrbci_header.py
python3.8 generate_input_header.py
conda deactivate
# leave data directory
cd ..
# deactivate the virtual environment and reset the pythonpath
# deactivate
# build everything
if [ "$CHIP" = "vega" ] ; then
make clean all PMSIS_OS=pulp-os platform=gvsoc
else
make clean all
fi
# run if requested
if [ "$GTKWAVE" = true ] ; then
make run runner_args="--vcd --event=.*"
else
if [ "$RUN" = true ] ; then
if [ "$CHIP" = "vega" ] ; then
make run platform=gvsoc
else
make run
fi
fi
fi