This repository has been archived by the owner on Mar 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess_experiments_results.sc
326 lines (313 loc) · 14.5 KB
/
process_experiments_results.sc
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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
import $file.generate_experiments
import java.time.format.DateTimeFormatter
import java.time.LocalDateTime
import java.nio.file.Files
import java.nio.file.Paths
import java.nio.file.StandardOpenOption
import java.time.temporal.ChronoUnit
import scala.collection.mutable.Buffer
import scala.util.matching.Regex
import java.time.Duration
val idesydeBenchmark = Paths.get("idesyde_benchmark.csv")
val idesydeScalBenchmark = Paths.get("idesyde_scal_benchmark.csv")
val desydeBenchmark = Paths.get("desyde_benchmark.csv")
val desydeDateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
val idesydeDateTimeFormatter =
DateTimeFormatter.ofPattern("yyyy.MM.dd HH:mm:ss:SSS")
val combinationsExp1Names = Vector(
"RaJp",
"SoSuRa",
"SoSuJp",
"SoRaJp",
"SuRaJp",
"SoSuRaJp",
"So",
"Syn"
)
val timeoutPattern =
"ChocoExplorer - setting total exploration timeout to ([0-9]+) seconds".r
def recompute_idesyde_1(): Unit = {
if (!Files.exists(idesydeBenchmark)) {
Files.createFile(idesydeBenchmark)
}
Files.writeString(
idesydeBenchmark,
"plat, actors, svr, exp, firings, start, first, runtime_first, last, runtime_last, stop, runtime, mean_time_to_improvement, nsols, convergence_time\n",
StandardOpenOption.WRITE,
StandardOpenOption.TRUNCATE_EXISTING
)
for (
actors <- generate_experiments.actorRange1;
svr <- generate_experiments.svrMultiplicationRange1;
cores <- generate_experiments.coreRange1;
exp <- 1 to generate_experiments.dataPointsPerTuple
) {
// println((actors, cores, exp).toString())
val outFile =
(os.pwd / "sdfComparison" / s"actors_${actors}" / s"svr_${(svr * 100).toInt}" / s"plat_${cores}" / s"exp_$exp" / "idesyde_output.log").toNIO
if (Files.exists(outFile)) {
var startingTime = LocalDateTime.now()
var firstTime = LocalDateTime.now()
var lastTime = LocalDateTime.now()
var endTime = LocalDateTime.now()
var bestSolutions = Buffer[(Duration, Int, Double)]()
var timesToImprovement = Buffer[Long]()
Files
.lines(outFile)
.forEach(l => {
if (l.contains("decision model(s) and explorer(s) chosen")) {
startingTime = LocalDateTime
.parse(l.subSequence(0, 23), idesydeDateTimeFormatter)
} else if (l.contains("solution: ")) {
val now = LocalDateTime
.parse(l.subSequence(0, 23), idesydeDateTimeFormatter)
for (m <- solsPattern.findAllMatchIn(l)) {
bestSolutions.addOne(
(
Duration.between(startingTime, now),
m.group(1).toInt,
m.group(2).toDouble / m.group(3).toDouble
)
)
}
timesToImprovement += ChronoUnit.MILLIS.between(lastTime, now)
lastTime = now
// now take away domninants
} else if (l.contains("Finished exploration")) {
endTime = LocalDateTime
.parse(l.subSequence(0, 23), idesydeDateTimeFormatter)
}
})
val runtimeFirst = ChronoUnit.MILLIS.between(startingTime, firstTime)
val runtimeLast = ChronoUnit.MILLIS.between(startingTime, lastTime)
val runtime = ChronoUnit.MILLIS.between(startingTime, endTime)
val firstSol = bestSolutions.minByOption((time, _, _) => time.toMillis()).getOrElse((Duration.ZERO, 0, 0.0))
val bestForCores = bestSolutions.minByOption((time, n, l) => (n, l, time)).getOrElse((Duration.ZERO, 0, 0.0))
val bestForTh = bestSolutions.minByOption((time, n, l) => (l, n, time)).getOrElse((Duration.ZERO, 0, 0.0))
val convergenceTime = if (bestForTh._1.compareTo(bestForCores._1) > 0) then bestForTh._1 else bestForCores._1
val meanTimeToImprovement =
if (!bestSolutions.isEmpty) then
bestSolutions.map(_._1.toMillis()).max / bestSolutions.size
else 0L
if (ChronoUnit.DAYS.between(startingTime, endTime) >= 5) println(s"$cores, $actors, ${(svr * 100).toInt}, $exp, ${(actors * svr).toInt} has timed-out")
Files.writeString(
idesydeBenchmark,
s"$cores, $actors, ${(svr * 100).toInt}, $exp, ${(actors * svr).toInt}, $startingTime, $firstTime, $runtimeFirst, $lastTime, $runtimeLast, $endTime, $runtime, $meanTimeToImprovement, ${timesToImprovement.size}, ${convergenceTime.toMillis()}\n",
StandardOpenOption.WRITE,
StandardOpenOption.APPEND
)
}
}
}
def recompute_idesyde_2(): Unit = {
if (!Files.exists(idesydeScalBenchmark)) {
Files.createFile(idesydeScalBenchmark)
}
Files.writeString(
idesydeScalBenchmark,
"plat, actors, svr, exp, firings, start, first, runtime_first, last, runtime_last, stop, runtime, mean_time_to_improvement, nsols, convergence_time\n",
StandardOpenOption.WRITE,
StandardOpenOption.TRUNCATE_EXISTING
)
var biggestFiringsNonZero = 0
var totalScanned = 0
var totalScannedInconclusive = 0
var totalHasSolution = 0
var totalOptimal = 0
for (
actors <- generate_experiments.actorRange2;
svr <- generate_experiments.svrMultiplicationRange2;
cores <- generate_experiments.coreRange2;
exp <- 1 to generate_experiments.dataPointsPerTuple
) {
// println((actors, cores, exp).toString())
val outFile =
(os.pwd / "sdfScalability" / s"actors_${actors}" / s"svr_${(svr * 100).toInt}" / s"plat_${cores}" / s"exp_$exp" / "idesyde_output.log").toNIO
if (Files.exists(outFile)) {
var isFirst = true
var startingTime = LocalDateTime.now()
var firstTime = LocalDateTime.now()
var lastTime = LocalDateTime.now()
var endTime = LocalDateTime.now()
var bestSolutions = Buffer[(Duration, Int, Double)]()
var timesToImprovement = Buffer[Long]()
Files
.lines(outFile)
.forEach(l => {
if (l.contains("decision model(s) and explorer(s) chosen")) {
startingTime = LocalDateTime
.parse(l.subSequence(0, 23), idesydeDateTimeFormatter)
} else if (l.contains("solution: ")) {
val now = LocalDateTime
.parse(l.subSequence(0, 23), idesydeDateTimeFormatter)
for (m <- solsPattern.findAllMatchIn(l)) {
bestSolutions.addOne(
(
Duration.between(startingTime, now),
m.group(1).toInt,
m.group(2).toDouble / m.group(3).toDouble
)
)
}
timesToImprovement += ChronoUnit.MILLIS.between(lastTime, now)
lastTime = now
// now take away domninants
} else if (l.contains("Finished exploration")) {
endTime = LocalDateTime
.parse(l.subSequence(0, 23), idesydeDateTimeFormatter)
}
})
val runtime = ChronoUnit.MILLIS.between(startingTime, endTime)
val runtimeFirst = if (firstTime.compareTo(endTime) <= 0) then ChronoUnit.MILLIS.between(startingTime, firstTime) else runtime
val runtimeLast = if(lastTime.compareTo(endTime) <= 0) then ChronoUnit.MILLIS.between(startingTime, lastTime) else runtime
val bestForCores = bestSolutions.minByOption((time, n, l) => (n, l, time)).getOrElse((Duration.ZERO, 0, 0.0))
val bestForTh = bestSolutions.minByOption((time, n, l) => (l, n, time)).getOrElse((Duration.ZERO, 0, 0.0))
val maxBest = if (bestForTh._1.compareTo(bestForCores._1) > 0) then bestForTh._1 else bestForCores._1
val convergenceTime = maxBest.toMillis()
val meanTimeToImprovement =
if (!bestSolutions.isEmpty) then
bestSolutions.map(_._1.toMillis()).max / bestSolutions.size
else 0L
// if (intermediateSolutions.isEmpty) println(s"empty: $cores, $actors, ${(svr * 100).toInt}, $exp, ${(actors * svr).toInt}")
if (!bestSolutions.isEmpty && biggestFiringsNonZero < (actors * svr).toInt) then biggestFiringsNonZero = (actors * svr).toInt
Files.writeString(
idesydeScalBenchmark,
s"$cores, $actors, ${(svr * 100).toInt}, $exp, ${(actors * svr).toInt}, $startingTime, $firstTime, $runtimeFirst, $lastTime, $runtimeLast, $endTime, $runtime, $meanTimeToImprovement, ${bestSolutions.size}, ${convergenceTime}\n",
StandardOpenOption.WRITE,
StandardOpenOption.APPEND
)
totalScanned += 1
if (bestSolutions.isEmpty && ChronoUnit.MINUTES.between(startingTime, endTime) >= 30) then totalScannedInconclusive += 1
if (!bestSolutions.isEmpty) then totalHasSolution += 1
if (!bestSolutions.isEmpty && ChronoUnit.MINUTES.between(startingTime, endTime) < 30) then totalOptimal += 1
}
}
println(s"biggest non zero is ${biggestFiringsNonZero}")
println(s"ratio of inconclusive is 1 - ${totalScannedInconclusive} / ${totalScanned} = 1 - ${totalScannedInconclusive.toDouble / totalScanned.toDouble} = ${1.0 - totalScannedInconclusive.toDouble / totalScanned.toDouble}")
println(s"ratio of optimal is 1 - ${totalOptimal} / ${totalHasSolution} = 1 - ${totalOptimal.toDouble / totalHasSolution.toDouble} = ${1.0 - totalOptimal.toDouble / totalHasSolution.toDouble}")
}
val solsPattern =
"nUsedPEs = ([0-9]*), globalInvThroughput = ([0-9]*) / ([0-9]*)".r
private def formatDuration(d: Duration): String = {
val h = d.getSeconds() / 3600
val m = (d.getSeconds() % 3600)/60
if (h > 0) {
f"$h%01d:$m%02d:${d.getSeconds() % 60}%02d:${d.getNano() / 1000000}"
} else if (m > 0) {
f"$m%02d:${d.getSeconds() % 60}%02d:${d.getNano() / 1000000}"
} else {
f"${d.getSeconds() % 60}%02d:${d.getNano() / 1000000}"
}
}
@main
def recompute_idesyde_3_table(): Unit = {
for ((comb, i) <- generate_experiments.combinationsExp1.zipWithIndex) {
val aggName = comb.map(_.split("\\.").head).reduce(_ + "_" + _)
val expFolder = os.pwd / "caseStudies" / aggName
val outFile = (expFolder / "idesyde_output.log").toNIO
if (Files.exists(outFile)) {
var startingTime = LocalDateTime.now()
var firstTime = LocalDateTime.now()
var lastTime = LocalDateTime.now()
var endTime = LocalDateTime.now()
var isTimeOut = false
var bestSolutions = Buffer[(Duration, Int, Double)]()
Files
.lines(outFile)
.forEach(l => {
if (l.contains("decision model(s) and explorer(s) chosen")) {
startingTime = LocalDateTime
.parse(l.subSequence(0, 23), idesydeDateTimeFormatter)
} else if (l.contains("solution: ")) {
lastTime = LocalDateTime
.parse(l.subSequence(0, 23), idesydeDateTimeFormatter)
for (m <- solsPattern.findAllMatchIn(l)) {
bestSolutions.addOne(
(
Duration.between(startingTime, lastTime),
m.group(1).toInt,
m.group(2).toDouble / m.group(3).toDouble
)
)
}
// now take away domninants
} else if (l.contains("Finished exploration")) {
endTime = LocalDateTime
.parse(l.subSequence(0, 23), idesydeDateTimeFormatter)
isTimeOut = ChronoUnit.SECONDS.between(startingTime, endTime) >= 3600*6
}
})
val totalElapsed = Duration.between(startingTime, endTime)
val firstSol = bestSolutions.minByOption((time, _, _) => time).getOrElse((Duration.ZERO, 0, 0.0))
val bestForCores = bestSolutions.minByOption((time, n, l) => (n, l, time)).getOrElse((Duration.ZERO, 0, 0.0))
val bestForTh = bestSolutions.minByOption((time, n, l) => (l, n, time)).getOrElse((Duration.ZERO, 0, 0.0))
println(f" ${combinationsExp1Names(i)}${if (isTimeOut) then "" else "$^*$"} & ${firstSol._3}%.0f & ${ bestForCores._3}%.0f & ${bestForTh._3}%.0f \\\\")
println(s" ${bestSolutions.size} solutions & ${firstSol._2} ${if (firstSol._2 == 1) then "tile" else "tiles"} & ${bestForCores._2} ${if (bestForCores._2 == 1) then "tile" else "tiles"} & ${bestForTh._2} ${if (bestForTh._2 == 1) then "tile" else "tiles"} \\\\")
println(s" ${formatDuration(totalElapsed)} & ${formatDuration(firstSol._1)} & ${formatDuration(bestForCores._1)} & ${formatDuration(bestForTh._1)} \\\\[0.5em]")
}
}
}
@main
def recomputeAll(): Unit = {
recompute_idesyde_1()
recompute_idesyde_2()
// recompute_desyde_1()
}
@deprecated
def recompute_desyde_1(): Unit = {
if (!Files.exists(desydeBenchmark)) {
Files.createFile(desydeBenchmark)
}
Files.writeString(
desydeBenchmark,
"plat, actors, svr, exp, firings, start, first, runtime_first, last, runtime_last, stop, runtime\n",
StandardOpenOption.WRITE,
StandardOpenOption.TRUNCATE_EXISTING
)
for (
actors <- generate_experiments.actorRange1;
svr <- generate_experiments.svrMultiplicationRange1;
cores <- generate_experiments.coreRange1;
exp <- 1 to generate_experiments.dataPointsPerTuple
) {
// println((actors, cores, exp).toString())
var bestSolutions = Buffer[(Duration, Int, Double)]()
val outFile =
(os.pwd / "sdfComparison" / s"actors_${actors}" / s"svr_${(svr * 100).toInt}" / s"plat_${cores}" / s"exp_$exp" / "desyde_output.log").toNIO
if (Files.exists(outFile)) {
var startingTime = LocalDateTime.now()
var firstTime = LocalDateTime.now()
var lastTime = LocalDateTime.now()
var endTime = LocalDateTime.now()
Files
.lines(outFile)
.forEach(l => {
if (l.contains("PRESOLVER executing full model - finding 1")) {
startingTime =
LocalDateTime.parse(l.subSequence(0, 19), desydeDateTimeFormatter)
} else if (l.contains("PRESOLVER executing full model - finding 2")) {
// println(l)
firstTime =
LocalDateTime.parse(l.subSequence(0, 19), desydeDateTimeFormatter)
lastTime =
LocalDateTime.parse(l.subSequence(0, 19), desydeDateTimeFormatter)
} else if (l.contains("solution found so far.")) {
lastTime =
LocalDateTime.parse(l.subSequence(0, 19), desydeDateTimeFormatter)
} else if (l.contains("End of exploration")) {
endTime =
LocalDateTime.parse(l.subSequence(0, 19), desydeDateTimeFormatter)
}
})
val runtimeFirst = ChronoUnit.MILLIS.between(startingTime, firstTime)
val runtimeLast = ChronoUnit.MILLIS.between(startingTime, lastTime)
val runtime = ChronoUnit.MILLIS.between(startingTime, endTime)
Files.writeString(
desydeBenchmark,
s"$cores, $actors, ${(svr * 100).toInt}, $exp, ${(actors * svr).toInt}, $startingTime, $firstTime, $runtimeFirst, $lastTime, $runtimeLast, $endTime, $runtime\n",
StandardOpenOption.WRITE,
StandardOpenOption.APPEND
)
}
}
}