-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresult2tex.rb
More file actions
288 lines (255 loc) · 10.1 KB
/
result2tex.rb
File metadata and controls
288 lines (255 loc) · 10.1 KB
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
#!/usr/bin/ruby
=begin
## Usage
```
$ tree results
results
├── Sakura Koukaryoku
│ ├── 20200413_1319.log
│ ├── 20200414_0315.log
│ └── 20200504_1700.log
├── c5.metal
│ ├── 20200502_0618.log
│ └── 20200504_1929.log
└── n1-standard-96
├── 20200429_2235.log
└── 20200430_0045.log
3 directories, 15 files
$ ruby result2tex.rb results
% machine & w/ super-scalar & w/ CMUX Memory & program & # of cycles & runtime & sec./cycle\\
n1-standard-96 w/ V100x8 & Y & Y & Fibonacci & 38 & 151.29 & 3.98 \\
n1-standard-96 w/ V100x8 & Y & Y & Hamming & 832 & 2108.73 & 2.53 \\
n1-standard-96 w/ V100x8 & Y & Y & Brainf*ck & 1982 & 4900.34 & 2.47 \\
n1-standard-96 w/ V100x4 & Y & Y & Fibonacci & 38 & 137.75 & 3.63 \\
n1-standard-96 w/ V100x4 & Y & Y & Hamming & 832 & 2091.07 & 2.51 \\
n1-standard-96 w/ V100x4 & Y & Y & Brainf*ck & 1982 & 4968.43 & 2.51 \\
c5.metal & Y & Y & Fibonacci & 38 & 167.42 & 4.41 \\
c5.metal & Y & Y & Hamming & 832 & 3604.01 & 4.33 \\
c5.metal & Y & Y & Brainf*ck & 1982 & 8592.38 & 4.34 \\
Sakura Koukaryoku w/ V100x1 & N & Y & Fibonacci & 57 & 218.04 & 3.83 \\
Sakura Koukaryoku w/ V100x1 & N & Y & Hamming & 1179 & 4442.22 & 3.77 \\
Sakura Koukaryoku w/ V100x1 & N & Y & Brainf*ck & 2464 & 9258.25 & 3.76 \\
Sakura Koukaryoku w/ V100x1 & Y & Y & Fibonacci & 38 & 163.49 & 4.3 \\
Sakura Koukaryoku w/ V100x1 & Y & Y & Hamming & 832 & 3397.68 & 4.08 \\
Sakura Koukaryoku w/ V100x1 & Y & Y & Brainf*ck & 1982 & 8077.28 & 4.08 \\
```
## Support
This tool supports automatic parsing of all versions below:
v11_01_fib_gpu,emu,0.277184335,2020-04-13 13:19:38 +0000
v11_01_fib_gpu,num_cycles,38,2020-04-13 13:19:38 +0000
v11_01_fib_gpu,genkey,0.014748779,2020-04-13 13:19:38 +0000
v11_01_fib_gpu,enc,58.301425305,2020-04-13 13:20:36 +0000
v11_01_fib_gpu,run,166.038401777,2020-04-13 13:23:22 +0000
v11_01_fib_gpu,dec,0.128921507,2020-04-13 13:23:22 +0000
v11_01_fib_gpu,ctxt_size,2596634717,2020-04-13 13:23:22 +0000
v11_01_fib_cpu,num_cycles,38,2020-04-19 13:45:53 +0000
v11_01_fib_cpu,genkey,0.003651032,2020-04-19 13:45:53 +0000
v11_01_fib_cpu,enc,63.825753363,2020-04-19 13:46:57 +0000
v11_01_fib_cpu,run,329.225690856,2020-04-19 13:52:26 +0000
v11_01_fib_cpu,dec,0.049495426,2020-04-19 13:52:26 +0000
v11_01_fib_cpu,ctxt_size,2596634717,2020-04-19 13:52:26 +0000
v12_01_fib_8gpu,emu,0.1957048,2020-04-29 07:54:26 +0000
v12_01_fib_8gpu,num_cycles,38,2020-04-29 07:54:26 +0000
v12_01_fib_8gpu,genkey,0.006129351,2020-04-29 07:54:26 +0000
v12_01_fib_8gpu,enc,74.333132715,2020-04-29 07:55:41 +0000
v12_01_fib_8gpu,run,151.29088248,2020-04-29 07:58:12 +0000
v12_01_fib_8gpu,dec,0.095654218,2020-04-29 07:58:12 +0000
v12_01_fib_8gpu,ctxt_size,2596634717,2020-04-29 07:58:12 +0000
v14_emerald_1gpus_01_fib,cc,0.06127331,2020-05-01 22:01:03 +0900
v14_emerald_1gpus_01_fib,elf_text_size,47,2020-05-01 22:01:03 +0900
v14_emerald_1gpus_01_fib,emu,0.215687883,2020-05-01 22:01:03 +0900
v14_emerald_1gpus_01_fib,num_cycles,38,2020-05-01 22:01:03 +0900
v14_emerald_1gpus_01_fib,genkey,0.008537429,2020-05-01 22:01:03 +0900
v14_emerald_1gpus_01_fib,enc,49.95133539,2020-05-01 22:01:53 +0900
v14_emerald_1gpus_01_fib,run,163.095014726,2020-05-01 22:04:36 +0900
v14_emerald_1gpus_01_fib,dec,0.081968135,2020-05-01 22:04:36 +0900
v14_emerald_1gpus_01_fib,ctxt_size,2596634717,2020-05-01 22:04:36 +0900
v14_emerald_1gpu_01_fib,cc,0.06334036,2020-05-02 12:57:13 +0900
v14_emerald_1gpu_01_fib,elf_text_size,47,2020-05-02 12:57:13 +0900
v14_emerald_1gpu_01_fib,emu,0.174886335,2020-05-02 12:57:13 +0900
v14_emerald_1gpu_01_fib,num_cycles,38,2020-05-02 12:57:13 +0900
v14_emerald_1gpu_01_fib,genkey,0.007853714,2020-05-02 12:57:13 +0900
v14_emerald_1gpu_01_fib,enc,51.148494565,2020-05-02 12:58:04 +0900
v14_emerald_1gpu_01_fib,run,165.447091338,2020-05-02 13:00:49 +0900
v14_emerald_1gpu_01_fib,dec,0.091747761,2020-05-02 13:00:49 +0900
v14_emerald_1gpu_01_fib,ctxt_size,2596634717,2020-05-02 13:00:49 +0900
v15_emerald_1gpu_wCM_01_fib,cc,0.085423988,2020-05-04 17:00:07 +0900
v15_emerald_1gpu_wCM_01_fib,elf_text_size,47,2020-05-04 17:00:07 +0900
v15_emerald_1gpu_wCM_01_fib,emu,0.193619438,2020-05-04 17:00:07 +0900
v15_emerald_1gpu_wCM_01_fib,num_cycles,38,2020-05-04 17:00:07 +0900
v15_emerald_1gpu_wCM_01_fib,genkey,0.008822996,2020-05-04 17:00:07 +0900
v15_emerald_1gpu_wCM_01_fib,enc,50.486236335,2020-05-04 17:00:58 +0900
v15_emerald_1gpu_wCM_01_fib,run,162.875772665,2020-05-04 17:03:41 +0900
v15_emerald_1gpu_wCM_01_fib,dec,0.081024659,2020-05-04 17:03:41 +0900
v15_emerald_1gpu_wCM_01_fib,ctxt_size,2613051560,2020-05-04 17:03:41 +0900
=end
require "csv"
require "pretty_round"
# Thanks to: https://stackoverflow.com/a/7749613
module Enumerable
def sum
self.inject(0) { |accum, i| accum + i }
end
def mean
self.sum / self.length.to_f
end
def sample_variance
m = self.mean
sum = self.inject(0) { |accum, i| accum + (i - m) ** 2 }
sum / (self.length - 1).to_f
end
def standard_deviation
Math.sqrt(self.sample_variance)
end
end
# Thanks to ActiveSupport
class Hash
# File activesupport/lib/active_support/core_ext/hash/slice.rb, line 23
def slice(*keys)
keys.each_with_object(Hash.new) { |k, hash| hash[k] = self[k] if has_key?(k) }
end
end
def yn(b)
if b then "Yes" else "No" end
end
def log2csv(machine_name, filepaths)
# Normalize data
# [
# {
# kvsp_version: positive number,
# gpus: zero or positive number,
# program: "01_fib" | "02_hamming" | "03_bf",
# processor: :diamond | :emerald,
# cmuxmem: boolean,
# }
# ]
#
normalized_data = []
filepaths.each do |filepath|
CSV.foreach(filepath) do |row|
normalized_row = case row[0]
when /^v11_([0-9]+_[a-z]+)_(gpu|cpu)$/
{
kvsp_version: 11,
gpus: $2 == "cpu" ? 0 : 1,
program: $1,
processor: :emerald,
cmuxmem: true,
}
when /^v12_([0-9]+_[a-z]+)_(cpu|([0-9]+)gpu)$/
{
kvsp_version: 12,
gpus: $2 == "cpu" ? 0 : $3.to_i,
program: $1,
processor: :emerald,
cmuxmem: true,
}
when /^v([0-9]+)_(emerald|diamond|ruby|pearl)_([0-9]+)gpus?(?:_(wCM|woCM))?_([0-9]+_[a-z]+)$/
{
kvsp_version: $1.to_i,
gpus: $3.to_i,
program: $5,
processor: $2.to_sym,
cmuxmem: $4 != "woCM",
}
else
next
end
normalized_row[:action] = row[1]
normalized_row[:data] = row[2..]
normalized_data.push normalized_row
end
end
# Non-trivial selection of data.
# 1. <=v23 have different architectures, so doesn't matter.
# 2. only cahp-pearl and cahp-ruby does matter.
normalized_data.select! do |row|
# 1. <=v23 have different architectures, so doesn't matter.
next false if row[:kvsp_version] <= 23
# 2. only cahp-pearl and cahp-ruby does matter.
next false unless [:pearl, :ruby].include? row[:processor]
# All tests passed.
true
end
# Make table from data
table = {}
normalized_data.each do |row|
key = row.slice(:gpus, :processor, :cmuxmem, :program)
table[key] ||= {
num_cycles: nil,
runtime: [],
}
case row[:action]
when "num_cycles"
ncycles = row[:data][0].to_i
table[key][:num_cycles] ||= ncycles
unless table[key][:num_cycles] == ncycles
raise "Invalid data: inconsistent # of cycles"
end
when "run"
table[key][:runtime].push(row[:data][0].to_f)
end
end
# Sort table
table = table.sort do |l, r|
# :gpus
next 1 if l[0][:gpus] > r[0][:gpus]
next -1 if l[0][:gpus] < r[0][:gpus]
# :processor
tbl = { diamond: 0, emerald: 1, ruby: 3, pearl: 2 }
next 1 if tbl[l[0][:processor]] > tbl[r[0][:processor]]
next -1 if tbl[l[0][:processor]] < tbl[r[0][:processor]]
# :cmuxmem
tbl = { false => 0, true => 1 }
next 1 if tbl[l[0][:cmuxmem]] > tbl[r[0][:cmuxmem]]
next -1 if tbl[l[0][:cmuxmem]] < tbl[r[0][:cmuxmem]]
l[0][:program] <=> r[0][:program]
end.to_h
sio = StringIO.new
table.each do |key, value|
machine = machine_name
pipeline = yn(key[:processor] == :ruby)
cmuxmem = yn(key[:cmuxmem])
program = case key[:program]
when "01_fib"
"Fibonacci"
when "02_hamming"
"Hamming"
when "03_bf"
"Brainf*ck"
else
raise "Invalid program"
end
num_cycles = value[:num_cycles]
ntries = value[:runtime].size
if value[:runtime].length == 1 then
runtime = sprintf("$%.1f \\pm NaN$", value[:runtime].mean)
sec_per_cycle = sprintf("$%.02f \\pm NaN$", value[:runtime].mean / value[:num_cycles])
else
runtimestdv = value[:runtime].standard_deviation
runtimemean = value[:runtime].mean
runtimedigit = (Math.log10(runtimemean)-Math.log10(runtimestdv)).floor + 1
runtime = sprintf("$%.1f \\pm %.1f$", runtimemean.sround(runtimedigit+1),runtimestdv)
sec_per_cycle = sprintf("$%.03f \\pm %.3f$", runtimemean / num_cycles,runtimestdv/num_cycles)
end
sio.print [
machine,
key[:gpus],
pipeline,
cmuxmem,
program,
num_cycles,
runtime,
sec_per_cycle,
].join(" & ")
sio.print " \\\\"
sio.puts "%\t#{value[:runtime].standard_deviation}\t#{ntries} #{if ntries == 1 then "try" else "tries" end}"
end
sio.string
end
puts "% Machine & \\# of V100 & Pipelining? & CMUX Memory? & Program & \\# of cycles & Runtime & sec./cycle\\\\"
Dir.each_child(ARGV[0]) do |machine_name|
filepaths = Dir.glob("#{ARGV[0]}/#{machine_name}/*.log")
s = log2csv(machine_name, filepaths)
puts s unless s.empty?
end