-
Notifications
You must be signed in to change notification settings - Fork 0
/
profilecopasi
executable file
·107 lines (88 loc) · 2.41 KB
/
profilecopasi
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
#!/bin/bash
# script to profile CPU usage of CopasiSE
#
# depends on audria package https://github.com/scaidermern/audria
# PARAMETERS (edit as needed)
# the CopasiSE executable to profile
COPASISE=/usr/local/COPASI-DEVEL/bin/CopasiSE
# COPASI options
CLOPT="--nologo"
# time between samples. Set -1 for automatic value (likely to be 0.02).
# cannot be smaller than kernel clock tick rate (2 * 1/100 on most systems)
DELTA=0.1
# default number of iterations
RUNITER=20
# default number of threads
THREADS=4
#DON'T EDIT BELOW THIS LINE
# check that audria is available
if ! command -v audria &> /dev/null
then
printf "abort: this script needs the command 'audria', please install\n"
exit 1
fi
# check command line options
if [[ $# -ge 1 ]]; then
INFILE=$1
if [[ "$1" =~ ^-h$ ]]; then
printf "usage: profilecopasi infile [iterations [threads [outfile]]]\n"
exit 0
fi
else
printf "usage: profilecopasi infile [iterations [threads [outfile]]]\n"
exit 1
fi
if [[ $# -ge 2 ]]; then
if [[ "$2" =~ ^[0-9]+$ ]]; then
RUNITER=$2
else
printf "usage: profilecopasi infile [iterations [threads [outfile]]]\n"
printf "error: iterations must be an integer"
exit 1
fi
fi
if [[ $# -ge 3 ]]; then
if [[ "$3" =~ ^[0-9]+$ ]]; then
THREADS=$3
else
printf "usage: profilecopasi infile [iterations [threads [outfile]]]\n"
printf "error: threads must be an integer\n"
exit 1
fi
fi
if [[ $# -ge 4 ]]; then
OUTFILE=$4
else
OUTFILE="profile.csv"
fi
# OMP directives,number of threads to be used, etc
export OMP_THREAD_LIMIT=$THREADS
export OMP_NUM_THREADS=$OMP_THREAD_LIMIT
export OMP_SCHEDULE=guided
printf "started on "
date
# keep a backup of OUTFILE if it exists
if [[ -e $OUTFILE ]]; then
mv $OUTFILE $OUTFILE.bak
fi
#write a header
printf "# " >> $OUTFILE
date >> $OUTFILE
printf "# " >> $OUTFILE
printf '%s ' "$0 $@" >> $OUTFILE
printf "\n# " >> $OUTFILE
grep -m 1 "model name" /proc/cpuinfo >> $OUTFILE
printf "# " >> $OUTFILE
grep -m 1 "cpu cores" /proc/cpuinfo >> $OUTFILE
printf '# threads used\t: %s\n' "$OMP_THREAD_LIMIT" >> $OUTFILE
# run the profiling (the "!" is used to make sure script doesn't abort)
printf '%s\n' "running parallel PS $RUNITER times with $THREADS threads"
for ((i=1;i<=$RUNITER;i++));
do
# printf "# " >> $OUTFILE
printf '%s ' "$i"
! audria -d $DELTA -o $OUTFILE -e $COPASISE $CLOPT $INFILE 2>&1 > /dev/null
printf "\n" >> $OUTFILE
done
printf "ended on "
date