-
Notifications
You must be signed in to change notification settings - Fork 1
/
gnuplot.go
133 lines (112 loc) · 4.45 KB
/
gnuplot.go
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
package main
import (
"io/ioutil"
"strconv"
"strings"
"github.com/jbreitbart/coBench/commands"
log "github.com/sirupsen/logrus"
)
func writeGNUPlotCATCoSchedFile(pairs [][2]string, filenames []string, perfNames []string, paired bool) {
if len(pairs) == 0 || len(filenames) == 0 {
return
}
if len(pairs) != len(filenames) {
log.Errorln("Not all apps have CAT data? Not supported atm. Skip creation of co-scheduling dat files")
return
}
log.WithField("paired", paired).Infoln("Creating plot file for co-scheduling CAT runs")
var ret string
if !paired {
ret += "set output 'co-sched-cat.pdf'\n"
} else {
ret += "set output 'co-sched-cat-paired.pdf'\n"
}
ret += gnuplotHeader()
if !paired {
ret += "set xlabel 'L3 Cache (MB)'\n"
} else {
ret += "set xlabel 'L3 Cache (MB) for app0'\n"
}
for i, pair := range pairs {
ret += "set title '" + gnuplotEscape(commands.Pretty(pair[0])) + " + " + gnuplotEscape(commands.Pretty(pair[1])) + "'\n"
ret += "set ylabel 'Runtime (s)'\n"
ret += "plot '" + filenames[i] + "' "
ret += "using 1:2:3 w yerrorbars ls 1 title '', "
ret += "'' using 1:2 with linespoints ls 1 title 'Ø runtime (" + gnuplotEscape(commands.Pretty(pair[0])) + ")',"
ret += "'' using 1:" + strconv.Itoa(3+len(perfNames)*2+1) + ":" + strconv.Itoa(3+len(perfNames)*2+2) + " w yerrorbars ls 2 title '', "
ret += "'' using 1:" + strconv.Itoa(3+len(perfNames)*2+1) + " with linespoints ls 2 title 'Ø runtime (" + gnuplotEscape(commands.Pretty(pair[1])) + ")'\n"
for k, perfName := range perfNames {
ret += "set ylabel '" + gnuplotEscape(perfName) + "'\n"
ret += "plot '" + filenames[i] + "' "
ret += "using 1:"
ret += strconv.Itoa(2*k+4) + ":" + strconv.Itoa(2*k+1+4) + " w yerrorbars ls 1 title '', "
ret += "'' using 1:"
ret += strconv.Itoa(2*k+4) + " with linespoints ls 1 title 'Ø "
ret += gnuplotEscape(perfName) + " (" + gnuplotEscape(commands.Pretty(pair[0])) + ")', "
ret += "'' using 1:" + strconv.Itoa(2*k+4+len(perfNames)*2+2) + ":" + strconv.Itoa(2*k+4+len(perfNames)*2+3) + " w yerrorbars ls 2 title '', "
ret += "'' using 1:" + strconv.Itoa(2*k+4+len(perfNames)*2+2) + " with linespoints ls 2 title 'Ø "
ret += gnuplotEscape(perfName) + " (" + gnuplotEscape(commands.Pretty(pair[1])) + ")' \n"
}
}
filename := "co-sched-cat.plot"
if paired {
filename = "co-sched-cat-paired.plot"
}
err := ioutil.WriteFile(filename, []byte(ret), 0644)
if err != nil {
log.WithError(err).WithField("filename", filename).Fatalln("Error while write file")
}
}
func writeGNUPlotCATIndvFile(apps []string, filename []string, perfNames []string) {
if len(apps) == 0 {
return
}
if len(apps) != len(filename) {
log.Errorln("Not all apps have CAT data? Not supported atm. Skip creation of individual dat files")
return
}
log.Infoln("Creating plot file for individual CAT runs.")
var ret string
ret += "set output 'indv-cat.pdf'\n"
ret += gnuplotHeader()
ret += "set xlabel 'L3 Cache (MB)'\n"
for i, app := range apps {
ret += "set title '" + gnuplotEscape(commands.Pretty(app)) + "'\n"
ret += "set ylabel 'Runtime (s)'\n"
ret += "plot '" + filename[i] + "' "
ret += "using 1:2:3 w yerrorbars ls 1 title '', "
ret += "'' using 1:2 with linespoints ls 1 title 'Ø runtime (" + gnuplotEscape(commands.Pretty(app)) + ")'\n"
for k, perfName := range perfNames {
ret += "set ylabel '" + gnuplotEscape(perfName) + "'\n"
ret += "plot '" + filename[i] + "' "
ret += "using 1:"
ret += strconv.Itoa(2*k+4) + ":" + strconv.Itoa(2*k+1+4) + " w yerrorbars ls 1 title '', "
ret += "'' using 1:"
ret += strconv.Itoa(2*k+4) + " with linespoints ls 1 title 'Ø "
ret += gnuplotEscape(perfName) + " (" + gnuplotEscape(commands.Pretty(app)) + ")'\n"
}
}
err := ioutil.WriteFile("indv-cat.plot", []byte(ret), 0644)
if err != nil {
log.WithError(err).Fatalln("Error while write file indv-cat.plot")
}
}
func gnuplotHeader() string {
ret := "set terminal pdf\n"
ret += "set yrange [0:*]\n"
ret += "set key right bottom\n"
ret += "unset x2tics\n"
ret += "unset y2tics\n"
ret += "set border 3\n"
//ret += "set ylabel 'Runtime (s)'\n"
ret += "set style line 1 lc rgb '#0060ad' lt 1 lw 2 pt 7 ps 0.1 # --- blue\n"
ret += "set style line 2 lc rgb '#dd181f' lt 1 lw 2 pt 5 ps 0.1 # --- red\n"
ret += "set pointintervalbox 3\n"
//ret += "shadecolor = '#80E0A080'\n"
return ret
}
// only supports some characters
func gnuplotEscape(s string) string {
ret := strings.Replace(s, "_", "\\_", -1)
return ret
}