-
Notifications
You must be signed in to change notification settings - Fork 1
/
capture_metadata.sh
executable file
·176 lines (154 loc) · 4.12 KB
/
capture_metadata.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
#!/bin/bash
# Script for to get machine information before doing the experiment
set +e # Don't fail fast since some information is maybe not available
title="Experiment results"
starpu_build=""
host="$(hostname | sed 's/[0-9]*//g' | cut -d'.' -f1)"
help_script()
{
cat << EOF
Usage: $0 [options] outputfile.org
Script for to get machine information before doing the experiment
OPTIONS:
-h Show this message
-t Title of the output file
-s Path to the StarPU installation
EOF
}
# Parsing options
while getopts "t:s:h" opt; do
case $opt in
t)
title="$OPTARG"
;;
s)
starpu_build="$OPTARG"
;;
h)
help_script
exit 4
;;
\?)
echo "Invalid option: -$OPTARG"
help_script
exit 3
;;
esac
done
shift $((OPTIND - 1))
info=$1
if [[ $# != 1 ]]; then
echo 'ERROR!'
help_script
exit 2
fi
starpu_src="$starpu_build/.."
##################################################
# Preambule of the output file
echo "#+TITLE: $title" > $info
echo "#+DATE: $(eval date)" >> $info
echo "#+AUTHOR: $(eval whoami)" >> $info
echo "#+MACHINE: $(eval hostname)" >> $info
echo "#+FILE: $info" >> $info
echo " " >> $info
##################################################
# Collecting metadata
echo "* MACHINE INFO" >> $info
echo "** PEOPLE LOGGED WHEN EXPERIMENT STARTED" >> $info
echo "#+BEGIN_EXAMPLE" >> $info
who >> $info
echo "#+END_EXAMPLE" >> $info
echo "** ENVIRONMENT VARIABLES" >> $info
echo "#+BEGIN_EXAMPLE" >> $info
env >> $info
echo "#+END_EXAMPLE" >> $info
echo "** HOSTNAME" >> $info
echo "#+BEGIN_EXAMPLE" >> $info
hostname >> $info
echo "#+END_EXAMPLE" >> $info
if [[ -n $(command -v lstopo) ]];
then
echo "** HWLOC MEMORY HIERARCHY" >> $info
echo "#+BEGIN_EXAMPLE" >> $info
lstopo --of console >> $info
echo "#+END_EXAMPLE" >> $info
fi
if [[ -n "$starpu_build" ]];
then
echo "** STARPU MACHINE DISPLAY" >> $info
echo "#+BEGIN_EXAMPLE" >> $info
$starpu_build/tools/starpu_machine_display 1> tmp 2> /dev/null
cat tmp >> $info
rm -f tmp
echo "#+END_EXAMPLE" >> $info
fi
if [ -f /proc/cpuinfo ];
then
echo "** CPU INFO" >> $info
echo "#+BEGIN_EXAMPLE" >> $info
cat /proc/cpuinfo >> $info
echo "#+END_EXAMPLE" >> $info
fi
if [ -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ];
then
echo "** CPU GOVERNOR" >> $info
echo "#+BEGIN_EXAMPLE" >> $info
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor >> $info
echo "#+END_EXAMPLE" >> $info
fi
if [ -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq ];
then
echo "** CPU FREQUENCY" >> $info
echo "#+BEGIN_EXAMPLE" >> $info
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq >> $info
echo "#+END_EXAMPLE" >> $info
fi
if [[ -n $(command -v nvidia-smi) ]];
then
echo "** GPU INFO FROM NVIDIA-SMI" >> $info
echo "#+BEGIN_EXAMPLE" >> $info
nvidia-smi -q >> $info
echo "#+END_EXAMPLE" >> $info
fi
if [ -f /proc/version ];
then
echo "** LINUX AND GCC VERSIONS" >> $info
echo "#+BEGIN_EXAMPLE" >> $info
cat /proc/version >> $info
echo "#+END_EXAMPLE" >> $info
fi
if [[ -n $(command -v module) ]];
then
echo "** MODULES" >> $info
echo "#+BEGIN_EXAMPLE" >> $info
module list 2>> $info
echo "#+END_EXAMPLE" >> $info
fi
##################################################
# Collecting revisions info
echo "* CODE REVISIONS" >> $info
git_exists=`git rev-parse --is-inside-work-tree`
if [ "${git_exists}" ]
then
echo "** GIT REVISION OF REPOSITORY" >> $info
echo "#+BEGIN_EXAMPLE" >> $info
git log -1 >> $info
echo "#+END_EXAMPLE" >> $info
fi
svn_exists=`svn info . 2> /dev/null`
if [ -n "${svn_exists}" ]
then
echo "** SVN REVISION OF REPOSITORY" >> $info
echo "#+BEGIN_EXAMPLE" >> $info
svn info >> $info
echo "#+END_EXAMPLE" >> $info
fi
##################################################
# Part specific to the StarPU
if [[ -n "$starpu_build" ]];
then
echo "** SVN REVISION OF ORIGINAL STARPU CODE" >> $info
echo "#+BEGIN_EXAMPLE" >> $info
svn info $starpu_src >> $info
echo "#+END_EXAMPLE" >> $info
fi