Commit 99b95be3 authored by Noric Couderc's avatar Noric Couderc
Browse files

Optimizations to papi-java

Christoph implemented some optimizations to avoid stopping counters when
it's not needed

I updated the client code to use the new API.
parent a5bf5a0d
......@@ -66,7 +66,9 @@ public class CollectionTimer {
}
public long getCycles(OperationType operationType) {
return getEventSet(operationType).getCounters()[0];
long[] readings = new long[getEventSet(operationType).size()];
getEventSet(operationType).read(readings);
return readings[0];
}
public long getTotalTime() { return mainStopWatch.getNanoTime(); }
......@@ -139,8 +141,7 @@ public class CollectionTimer {
if (isTopLevel()) {
suspendStopWatch(operationType);
EventSet ev = getEventSet(operationType);
ev.stop();
cycles += ev.getCounters()[0];
cycles += ev.stop()[0];
}
}
}
......@@ -47,9 +47,8 @@ open class PapiRunner() : PapiBenchmarkAnalyzer {
b[i] = acc
}
}
evset.stop()
// Get data
val currentData = evset.counters
val currentData = evset.stop()
current.addAll(currentData.toList())
}
data.set(counter, current)
......@@ -84,14 +83,14 @@ open class PapiRunner() : PapiBenchmarkAnalyzer {
var accumulator = 0
evset.start()
app.runBenchmark(blackhole)
evset.stop()
val readings = evset.stop()
val resultDataStructure = app.getDatastructure()
// Write the result somewhere to prevent dead code elimination
writer.write(accumulator)
writer.write(resultDataStructure.toString())
// We record the data
val runSamples = spec.counters().zip(evset.counters.toList()).map {
val runSamples = spec.counters().zip(readings.toList()).map {
PapiBenchmarkAnalyzer.BenchmarkRunSample(it.first, it.second.toDouble())
}
val runData = PapiBenchmarkAnalyzer.BenchmarkRunData(
......
......@@ -48,15 +48,19 @@ open class PapiTracerRunner() : PapiRunner() {
fun makeRecords(text : String): List<TraceRecord> {
val cleanedLines = text.lines().filter { !it.isEmpty() }
val header = text.lines().first()
val columnIndex = header.trim().split("\t").mapIndexed { index, column -> Pair(column, index) }
.toMap()
val cleanedLines = text.lines().drop(1).filter { !it.isEmpty() }
return cleanedLines.map { line ->
val splitted = line.split("\t")
TraceRecord(splitted[0].intern(),
splitted[1].intern(),
Integer.parseInt(splitted[2]),
splitted[3].intern(),
splitted[4].intern()
TraceRecord(splitted[columnIndex["location"]!!].intern(),
splitted[columnIndex["feature"]!!].intern(),
Integer.parseInt(splitted[columnIndex["feature_value"]!!]),
splitted[columnIndex["collection"]!!].intern(),
splitted[columnIndex["method"]!!].intern()
)
}
}
......@@ -133,7 +137,7 @@ open class PapiTracerRunner() : PapiRunner() {
// We get the output from the run
val stream = ByteArrayOutputStream()
Tracer.printRecords(PrintStream(stream))
Tracer.printRecords(1, PrintStream(stream))
return makeRecords(stream.toString())
}
......
......@@ -316,8 +316,7 @@ public class SyntheticBenchmarkTest {
}
// done with the code
evset.stop();
long[] data = evset.getCounters();
long[] data = evset.stop();
// only print the 10th run
if (warmup == 0) {
......
......@@ -51,7 +51,7 @@ class TracingCollectionRunnerTest {
b.runBenchmark(blackhole)
val s = ByteArrayOutputStream()
Tracer.printRecords(PrintStream(s))
Tracer.printRecords(1, PrintStream(s))
// We're gonna clean up the lines where we have 0 invocations
val partitioned = s.toString().lines().partition {
it.contains("invocations\t0")
......
No preview for this file type
No preview for this file type
Subproject commit 16c467d838f2fedcfaa1b51659b98f4c031ab025
Subproject commit 80d072309714821134720a126a46a8bd64ca88f0
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment