Commit 876c234f authored by Noric Couderc's avatar Noric Couderc
Browse files

Gather cycles per class of operation in one pass

We removed the need of a StopWatchRunner by making sure we only run the
benchmark once, even for getting the number of cycles per operation
type.
parent 70f7925b
......@@ -2,20 +2,19 @@ package se.lth.cs
import se.lth.cs.bcgen.BCBenchmarkPackage
import se.lth.cs.papicounters.PapiBenchmarkAnalyzer
import se.lth.cs.timing.OperationTypeTable
import se.lth.cs.timing.StopWatchRunner
import java.io.Writer
import java.util.*
class SyntheticBenchmarkFeaturePrinter(out: Writer,
papiRunner: PapiRunner,
stopWatchRunner : StopWatchRunner,
methodPrintFormat: String,
normalizeFeatures: Boolean)
: SyntheticBenchmarkDataPrinter(out, methodPrintFormat) {
private val papiRunner: PapiRunner = papiRunner
private val stopWatchRunner : StopWatchRunner = stopWatchRunner
private val normalizeFeatures = normalizeFeatures
private var benchmarkResults : Map<String, List<PapiBenchmarkAnalyzer.BenchmarkRunData>> = mapOf()
......@@ -52,15 +51,11 @@ class SyntheticBenchmarkFeaturePrinter(out: Writer,
private fun printStopWatchCounters(runData: PapiBenchmarkAnalyzer.BenchmarkRunData) {
val identifier = runData.benchmark.benchmarkIdentifier
val counters = stopWatchRunner.getStopWatchCounters(runData.benchmark)
val counters = TreeMap(runData.cyclesPerOpType)
for (c in counters) {
val value = when (normalizeFeatures) {
true -> c.normalized
false -> c.absolute
}
printer.printRecord(identifier, runData.iteration, c.stopWatchType, "hardware", value)
val featureName = OperationTypeTable.getOperationTypeFeatureName(c.key)
printer.printRecord(identifier, runData.iteration, featureName, "hardware", c.value)
}
}
......
......@@ -2,6 +2,7 @@ package se.lth.cs.papicounters
import papi.EventSet
import se.lth.cs.bcgen.BCBenchmarkPackage
import se.lth.cs.timing.OperationType
interface PapiBenchmarkAnalyzer {
class RunSpec(val numRuns: Int,
......@@ -31,7 +32,8 @@ interface PapiBenchmarkAnalyzer {
class BenchmarkRunData(val benchmark : BCBenchmarkPackage<*>,
val iteration : Int,
val samples : List<BenchmarkRunSample>) {
val samples : List<BenchmarkRunSample>,
val cyclesPerOpType : Map<OperationType, Double>) {
fun normalizationCounter(): String {
return "PAPI_TOT_CYC"
......@@ -44,11 +46,15 @@ interface PapiBenchmarkAnalyzer {
BenchmarkRunSample(it.counter, it.value / cycles)
}
return BenchmarkRunData(this.benchmark, this.iteration, newSamples)
val newCycles = this.cyclesPerOpType.mapValues {
it.value / cycles
}
return BenchmarkRunData(this.benchmark, this.iteration, newSamples, newCycles)
}
}
fun runSpec(spec : RunSpec) : List<List<BenchmarkRunSample>>
fun runSpec(spec : RunSpec) : List<BenchmarkRunData>
fun runApplications(syntheticBenchmarks: List<BCBenchmarkPackage<*>>): List<BenchmarkRunData>
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ import papi.EventSet
import papi.Papi
import se.lth.cs.bcgen.BCBenchmarkPackage
import se.lth.cs.papicounters.PapiBenchmarkAnalyzer
import se.lth.cs.timing.OperationType
import java.io.FileWriter
open class PapiRunner(val numRuns: Int, counters: CounterSpecification) : PapiBenchmarkAnalyzer {
......@@ -70,10 +71,11 @@ open class PapiRunner(val numRuns: Int, counters: CounterSpecification) : PapiBe
return specification.toList()
}
override fun runSpec(spec : PapiBenchmarkAnalyzer.RunSpec): List<List<PapiBenchmarkAnalyzer.BenchmarkRunSample>> {
override fun runSpec(spec : PapiBenchmarkAnalyzer.RunSpec): List<PapiBenchmarkAnalyzer.BenchmarkRunData> {
// println("Running benchmark: " + spec.syntheticBenchmark.benchmarkIdentifier)
val writer = FileWriter("/dev/null")
val samples = mutableListOf<List<PapiBenchmarkAnalyzer.BenchmarkRunSample>>()
val samples = mutableListOf<PapiBenchmarkAnalyzer.BenchmarkRunData>()
for (i in 0 until spec.numRuns) {
val app = spec.syntheticBenchmark
val evset = spec.eventSet
......@@ -92,9 +94,15 @@ open class PapiRunner(val numRuns: Int, counters: CounterSpecification) : PapiBe
writer.write(accumulator)
writer.write(resultDataStructure.toString())
// We record the data
val runData = spec.counters.zip(evset.counters.toList()).map {
val runSamples = spec.counters.zip(evset.counters.toList()).map {
PapiBenchmarkAnalyzer.BenchmarkRunSample(it.first, it.second.toDouble())
}
val runData = PapiBenchmarkAnalyzer.BenchmarkRunData(
spec.syntheticBenchmark,
i,
runSamples,
mapOf()
)
samples.add(runData)
}
writer.close()
......@@ -157,25 +165,14 @@ open class PapiRunner(val numRuns: Int, counters: CounterSpecification) : PapiBe
val specs = createRunSpecs(syntheticBenchmarks)
val numberBenchmarks = specs.size
var i = 0
val samples = specs.map {
val samples = specs.flatMap {
print("Running spec: $i / $numberBenchmarks\r")
i++
runSpec(it) }
val spectToSamples = specs.zip(samples)
println("Finished running specs.")
// We create a report for a run for each individual sample
return spectToSamples.flatMap {
it.second.mapIndexed { index, sample ->
PapiBenchmarkAnalyzer.BenchmarkRunData(
it.first.syntheticBenchmark,
index,
sample)
}
}
return samples
}
fun runApplicationsNormalized(syntheticBenchmarks: List<BCBenchmarkPackage<*>>) : List<PapiBenchmarkAnalyzer.BenchmarkRunData> {
......@@ -203,8 +200,7 @@ open class PapiRunner(val numRuns: Int, counters: CounterSpecification) : PapiBe
* A mockup class which returns deterministic results when you "run" a spec.
*/
class MockupPapiRunner(numRuns : Int, counters : CounterSpecification) : PapiRunner(numRuns, counters) {
override fun runSpec(spec : PapiBenchmarkAnalyzer.RunSpec) : List<List<PapiBenchmarkAnalyzer.BenchmarkRunSample>> {
val seed = spec.syntheticBenchmark.seed
override fun runSpec(spec : PapiBenchmarkAnalyzer.RunSpec) : List<PapiBenchmarkAnalyzer.BenchmarkRunData> {
// We map the counters to integers
// val counterToInt = mapOf<String, Long>(
// Pair("PAPI_CA_ITV", 0),
......@@ -213,12 +209,20 @@ class MockupPapiRunner(numRuns : Int, counters : CounterSpecification) : PapiRun
// Pair("PAPI_TOT_INS", 3)
// )
// val n = seed + counterToInt[spec.counter]!!
val n = seed
val iterations = 0 until spec.numRuns
return iterations.map {
spec.counters.map {
PapiBenchmarkAnalyzer.BenchmarkRunSample(it, n.toDouble())
val samples = spec.counters.map {
PapiBenchmarkAnalyzer.BenchmarkRunSample(it, 10000.0)
}
val cyclesPerOpType = mapOf(
Pair(OperationType.DELETE, 1000.0),
Pair(OperationType.INSERT, 1000.0),
Pair(OperationType.ITERATE, 1000.0),
Pair(OperationType.SEARCH, 1000.0)
)
PapiBenchmarkAnalyzer.BenchmarkRunData(spec.syntheticBenchmark, it, samples, cyclesPerOpType )
}
}
}
......@@ -133,15 +133,16 @@ class PapiTracerRunner(numRuns : Int, counters : CounterSpecification) : PapiRun
return makeRecords(stream.toString())
}
override fun runSpec(spec: PapiBenchmarkAnalyzer.RunSpec): List<List<PapiBenchmarkAnalyzer.BenchmarkRunSample>> {
override fun runSpec(spec: PapiBenchmarkAnalyzer.RunSpec): List<PapiBenchmarkAnalyzer.BenchmarkRunData> {
if (!spec.canBeSampled()) {
throw RuntimeException("Specification cannot be sampled")
}
val result = mutableListOf<List<PapiBenchmarkAnalyzer.BenchmarkRunSample>>()
val result = mutableListOf<PapiBenchmarkAnalyzer.BenchmarkRunData>()
val iterations = runIterations(spec)
var iterationIndex = 0
iterations.forEach {
// Analyze text for this iteration
val g = analyzeOutput(it)
......@@ -159,47 +160,47 @@ class PapiTracerRunner(numRuns : Int, counters : CounterSpecification) : PapiRun
PapiBenchmarkAnalyzer.BenchmarkRunSample(counter, value.get().toDouble())
}
result.add(counterSamples)
val report = PapiBenchmarkAnalyzer.BenchmarkRunData(spec.syntheticBenchmark, iterationIndex,
counterSamples, getCyclesPerOpType(it) )
result.add(report)
}
return result
}
fun getCyclesPerOpType(iterations : List<List<TraceRecord>>): List<Triple<Int, String, Double>> {
var result = mutableListOf<Triple<Int, String, Double>>()
fun getCyclesPerOpType(iteration : List<TraceRecord>): Map<OperationType, Double> {
// There should be only one allocation site for all records
// Because we only record one iteration of one benchmark.
assert(iteration.map { it.allocationSite }.toSet().size == 1)
var result = mutableMapOf<OperationType, Double>()
val siteToCycles = mutableMapOf<Pair<OperationType, String>, Int>()
val siteToCycles = mutableMapOf<OperationType, Int>()
val featureNumber = String.format("0x%x", counterSpec.getCounter("PAPI_TOT_CYC"))
// We need to total number of cycles for each alloc site / operation type
for (iteration in iterations) {
for (record in iteration) {
if (featureNumber == record.featureName) {
val opType = OperationTypeTable.getType(record.method)
if (opType.isPresent) {
val key = Pair(opType.get(), record.allocationSite)
val cyclesForOpType = siteToCycles.getOrDefault(key, 0)
siteToCycles.put(key, cyclesForOpType + record.featureValue)
}
for (record in iteration) {
if (featureNumber == record.featureName) {
val opType = OperationTypeTable.getType(record.method)
if (opType.isPresent) {
val key = opType.get()
val cyclesForOpType = siteToCycles.getOrDefault(key, 0)
siteToCycles[key] = cyclesForOpType + record.featureValue
}
}
}
var runId = 0
for (iteration in iterations) {
for (record in iteration) {
if (record.featureName == featureNumber) {
val opType = OperationTypeTable.getType(record.method)
if (opType.isPresent) {
val key = Pair(opType.get(), record.allocationSite)
val featureName = OperationTypeTable.getOperationTypeFeatureName(opType.get())!!
val value = record.featureValue.toDouble() / siteToCycles.get(key)!!
result.add(Triple(runId, featureName, value))
}
for (record in iteration) {
if (record.featureName == featureNumber) {
val opType = OperationTypeTable.getType(record.method)
if (opType.isPresent) {
val key = opType.get()
val value = record.featureValue.toDouble() / siteToCycles.get(key)!!
result[key] = value
}
}
runId++
}
return result
......
......@@ -30,12 +30,8 @@ class SyntheticBenchmarkFeaturePrinterTest {
val methodOutputFormat = "JAVA-STANDARD-FORMAT"
val normalizeFeatures = false
val papiRunner = MockupPapiRunner( 3, counterSpec)
val stopWatchRunner = MockupStopWatchRunner()
@Test
fun testEmptyBenchmark() {
val benchmark =
......@@ -43,7 +39,7 @@ class SyntheticBenchmarkFeaturePrinterTest {
val writer = StringWriter()
val csvPrinter = SyntheticBenchmarkFeaturePrinter(writer, papiRunner,
stopWatchRunner, methodOutputFormat, normalizeFeatures)
methodOutputFormat, normalizeFeatures)
val toPrint : List<BCBenchmarkPackage<*>> = listOf<BCBenchmarkPackage<*>>(benchmark)
csvPrinter.printToCSV(toPrint)
......@@ -98,7 +94,7 @@ class SyntheticBenchmarkFeaturePrinterTest {
val writer = StringWriter()
val csvPrinter = SyntheticBenchmarkFeaturePrinter(writer, papiRunner,
stopWatchRunner, "SYNTHETIC-RUN-FORMAT", normalizeFeatures)
"SYNTHETIC-RUN-FORMAT", normalizeFeatures)
csvPrinter.printToCSV(listOf<BCBenchmarkPackage<*>>(benchmark))
......@@ -116,10 +112,10 @@ class SyntheticBenchmarkFeaturePrinterTest {
Synth:POLYA:0:10:Map:0:HashMap,0,cyclesDeletions,hardware,1000.0
Synth:POLYA:0:10:Map:0:HashMap,0,cyclesSearches,hardware,1000.0
Synth:POLYA:0:10:Map:0:HashMap,0,cyclesIterations,hardware,1000.0
Synth:POLYA:0:10:Map:0:HashMap,0,PAPI_L1_DCM,hardware,0.0
Synth:POLYA:0:10:Map:0:HashMap,0,PAPI_L2_DCM,hardware,0.0
Synth:POLYA:0:10:Map:0:HashMap,0,PAPI_TOT_CYC,hardware,0.0
Synth:POLYA:0:10:Map:0:HashMap,0,PAPI_TOT_INS,hardware,0.0
Synth:POLYA:0:10:Map:0:HashMap,0,PAPI_L1_DCM,hardware,10000.0
Synth:POLYA:0:10:Map:0:HashMap,0,PAPI_L2_DCM,hardware,10000.0
Synth:POLYA:0:10:Map:0:HashMap,0,PAPI_TOT_CYC,hardware,10000.0
Synth:POLYA:0:10:Map:0:HashMap,0,PAPI_TOT_INS,hardware,10000.0
Synth:POLYA:0:10:Map:0:HashMap,1,collection,collection,HashMap
Synth:POLYA:0:10:Map:0:HashMap,1,runContainsValue,software,2
Synth:POLYA:0:10:Map:0:HashMap,1,runClear,software,1
......@@ -132,10 +128,10 @@ class SyntheticBenchmarkFeaturePrinterTest {
Synth:POLYA:0:10:Map:0:HashMap,1,cyclesDeletions,hardware,1000.0
Synth:POLYA:0:10:Map:0:HashMap,1,cyclesSearches,hardware,1000.0
Synth:POLYA:0:10:Map:0:HashMap,1,cyclesIterations,hardware,1000.0
Synth:POLYA:0:10:Map:0:HashMap,1,PAPI_L1_DCM,hardware,0.0
Synth:POLYA:0:10:Map:0:HashMap,1,PAPI_L2_DCM,hardware,0.0
Synth:POLYA:0:10:Map:0:HashMap,1,PAPI_TOT_CYC,hardware,0.0
Synth:POLYA:0:10:Map:0:HashMap,1,PAPI_TOT_INS,hardware,0.0
Synth:POLYA:0:10:Map:0:HashMap,1,PAPI_L1_DCM,hardware,10000.0
Synth:POLYA:0:10:Map:0:HashMap,1,PAPI_L2_DCM,hardware,10000.0
Synth:POLYA:0:10:Map:0:HashMap,1,PAPI_TOT_CYC,hardware,10000.0
Synth:POLYA:0:10:Map:0:HashMap,1,PAPI_TOT_INS,hardware,10000.0
Synth:POLYA:0:10:Map:0:HashMap,2,collection,collection,HashMap
Synth:POLYA:0:10:Map:0:HashMap,2,runContainsValue,software,2
Synth:POLYA:0:10:Map:0:HashMap,2,runClear,software,1
......@@ -148,10 +144,10 @@ class SyntheticBenchmarkFeaturePrinterTest {
Synth:POLYA:0:10:Map:0:HashMap,2,cyclesDeletions,hardware,1000.0
Synth:POLYA:0:10:Map:0:HashMap,2,cyclesSearches,hardware,1000.0
Synth:POLYA:0:10:Map:0:HashMap,2,cyclesIterations,hardware,1000.0
Synth:POLYA:0:10:Map:0:HashMap,2,PAPI_L1_DCM,hardware,0.0
Synth:POLYA:0:10:Map:0:HashMap,2,PAPI_L2_DCM,hardware,0.0
Synth:POLYA:0:10:Map:0:HashMap,2,PAPI_TOT_CYC,hardware,0.0
Synth:POLYA:0:10:Map:0:HashMap,2,PAPI_TOT_INS,hardware,0.0
Synth:POLYA:0:10:Map:0:HashMap,2,PAPI_L1_DCM,hardware,10000.0
Synth:POLYA:0:10:Map:0:HashMap,2,PAPI_L2_DCM,hardware,10000.0
Synth:POLYA:0:10:Map:0:HashMap,2,PAPI_TOT_CYC,hardware,10000.0
Synth:POLYA:0:10:Map:0:HashMap,2,PAPI_TOT_INS,hardware,10000.0
""".trimIndent()
......@@ -169,7 +165,6 @@ class SyntheticBenchmarkFeaturePrinterTest {
val writer = StringWriter()
val csvPrinter = SyntheticBenchmarkFeaturePrinter(writer,
papiRunner,
stopWatchRunner,
"SYNTHETIC-RUN-FORMAT",
true)
......@@ -227,7 +222,6 @@ class SyntheticBenchmarkFeaturePrinterTest {
val writer = StringWriter()
val csvPrinter = SyntheticBenchmarkFeaturePrinter(writer, papiRunner,
stopWatchRunner,
"SYNTHETIC-RUN-FORMAT",
false)
......@@ -247,10 +241,10 @@ class SyntheticBenchmarkFeaturePrinterTest {
Synth:POLYA:0:10:List:0:ArrayList,0,cyclesDeletions,hardware,1000.0
Synth:POLYA:0:10:List:0:ArrayList,0,cyclesSearches,hardware,1000.0
Synth:POLYA:0:10:List:0:ArrayList,0,cyclesIterations,hardware,1000.0
Synth:POLYA:0:10:List:0:ArrayList,0,PAPI_L1_DCM,hardware,0.0
Synth:POLYA:0:10:List:0:ArrayList,0,PAPI_L2_DCM,hardware,0.0
Synth:POLYA:0:10:List:0:ArrayList,0,PAPI_TOT_CYC,hardware,0.0
Synth:POLYA:0:10:List:0:ArrayList,0,PAPI_TOT_INS,hardware,0.0
Synth:POLYA:0:10:List:0:ArrayList,0,PAPI_L1_DCM,hardware,10000.0
Synth:POLYA:0:10:List:0:ArrayList,0,PAPI_L2_DCM,hardware,10000.0
Synth:POLYA:0:10:List:0:ArrayList,0,PAPI_TOT_CYC,hardware,10000.0
Synth:POLYA:0:10:List:0:ArrayList,0,PAPI_TOT_INS,hardware,10000.0
Synth:POLYA:0:10:List:0:ArrayList,1,collection,collection,ArrayList
Synth:POLYA:0:10:List:0:ArrayList,1,runToString,software,1
Synth:POLYA:0:10:List:0:ArrayList,1,runIndexOf,software,1
......@@ -262,10 +256,10 @@ class SyntheticBenchmarkFeaturePrinterTest {
Synth:POLYA:0:10:List:0:ArrayList,1,cyclesDeletions,hardware,1000.0
Synth:POLYA:0:10:List:0:ArrayList,1,cyclesSearches,hardware,1000.0
Synth:POLYA:0:10:List:0:ArrayList,1,cyclesIterations,hardware,1000.0
Synth:POLYA:0:10:List:0:ArrayList,1,PAPI_L1_DCM,hardware,0.0
Synth:POLYA:0:10:List:0:ArrayList,1,PAPI_L2_DCM,hardware,0.0
Synth:POLYA:0:10:List:0:ArrayList,1,PAPI_TOT_CYC,hardware,0.0
Synth:POLYA:0:10:List:0:ArrayList,1,PAPI_TOT_INS,hardware,0.0
Synth:POLYA:0:10:List:0:ArrayList,1,PAPI_L1_DCM,hardware,10000.0
Synth:POLYA:0:10:List:0:ArrayList,1,PAPI_L2_DCM,hardware,10000.0
Synth:POLYA:0:10:List:0:ArrayList,1,PAPI_TOT_CYC,hardware,10000.0
Synth:POLYA:0:10:List:0:ArrayList,1,PAPI_TOT_INS,hardware,10000.0
Synth:POLYA:0:10:List:0:ArrayList,2,collection,collection,ArrayList
Synth:POLYA:0:10:List:0:ArrayList,2,runToString,software,1
Synth:POLYA:0:10:List:0:ArrayList,2,runIndexOf,software,1
......@@ -277,10 +271,10 @@ class SyntheticBenchmarkFeaturePrinterTest {
Synth:POLYA:0:10:List:0:ArrayList,2,cyclesDeletions,hardware,1000.0
Synth:POLYA:0:10:List:0:ArrayList,2,cyclesSearches,hardware,1000.0
Synth:POLYA:0:10:List:0:ArrayList,2,cyclesIterations,hardware,1000.0
Synth:POLYA:0:10:List:0:ArrayList,2,PAPI_L1_DCM,hardware,0.0
Synth:POLYA:0:10:List:0:ArrayList,2,PAPI_L2_DCM,hardware,0.0
Synth:POLYA:0:10:List:0:ArrayList,2,PAPI_TOT_CYC,hardware,0.0
Synth:POLYA:0:10:List:0:ArrayList,2,PAPI_TOT_INS,hardware,0.0
Synth:POLYA:0:10:List:0:ArrayList,2,PAPI_L1_DCM,hardware,10000.0
Synth:POLYA:0:10:List:0:ArrayList,2,PAPI_L2_DCM,hardware,10000.0
Synth:POLYA:0:10:List:0:ArrayList,2,PAPI_TOT_CYC,hardware,10000.0
Synth:POLYA:0:10:List:0:ArrayList,2,PAPI_TOT_INS,hardware,10000.0
Synth:POLYA:1:10:List:0:ArrayList,0,collection,collection,ArrayList
Synth:POLYA:1:10:List:0:ArrayList,0,runToArray2,software,1
Synth:POLYA:1:10:List:0:ArrayList,0,runRetainAll,software,2
......@@ -294,10 +288,10 @@ class SyntheticBenchmarkFeaturePrinterTest {
Synth:POLYA:1:10:List:0:ArrayList,0,cyclesDeletions,hardware,1000.0
Synth:POLYA:1:10:List:0:ArrayList,0,cyclesSearches,hardware,1000.0
Synth:POLYA:1:10:List:0:ArrayList,0,cyclesIterations,hardware,1000.0
Synth:POLYA:1:10:List:0:ArrayList,0,PAPI_L1_DCM,hardware,1.0
Synth:POLYA:1:10:List:0:ArrayList,0,PAPI_L2_DCM,hardware,1.0
Synth:POLYA:1:10:List:0:ArrayList,0,PAPI_TOT_CYC,hardware,1.0
Synth:POLYA:1:10:List:0:ArrayList,0,PAPI_TOT_INS,hardware,1.0
Synth:POLYA:1:10:List:0:ArrayList,0,PAPI_L1_DCM,hardware,10000.0
Synth:POLYA:1:10:List:0:ArrayList,0,PAPI_L2_DCM,hardware,10000.0
Synth:POLYA:1:10:List:0:ArrayList,0,PAPI_TOT_CYC,hardware,10000.0
Synth:POLYA:1:10:List:0:ArrayList,0,PAPI_TOT_INS,hardware,10000.0
Synth:POLYA:1:10:List:0:ArrayList,1,collection,collection,ArrayList
Synth:POLYA:1:10:List:0:ArrayList,1,runToArray2,software,1
Synth:POLYA:1:10:List:0:ArrayList,1,runRetainAll,software,2
......@@ -311,10 +305,10 @@ class SyntheticBenchmarkFeaturePrinterTest {
Synth:POLYA:1:10:List:0:ArrayList,1,cyclesDeletions,hardware,1000.0
Synth:POLYA:1:10:List:0:ArrayList,1,cyclesSearches,hardware,1000.0
Synth:POLYA:1:10:List:0:ArrayList,1,cyclesIterations,hardware,1000.0
Synth:POLYA:1:10:List:0:ArrayList,1,PAPI_L1_DCM,hardware,1.0
Synth:POLYA:1:10:List:0:ArrayList,1,PAPI_L2_DCM,hardware,1.0
Synth:POLYA:1:10:List:0:ArrayList,1,PAPI_TOT_CYC,hardware,1.0
Synth:POLYA:1:10:List:0:ArrayList,1,PAPI_TOT_INS,hardware,1.0
Synth:POLYA:1:10:List:0:ArrayList,1,PAPI_L1_DCM,hardware,10000.0
Synth:POLYA:1:10:List:0:ArrayList,1,PAPI_L2_DCM,hardware,10000.0
Synth:POLYA:1:10:List:0:ArrayList,1,PAPI_TOT_CYC,hardware,10000.0
Synth:POLYA:1:10:List:0:ArrayList,1,PAPI_TOT_INS,hardware,10000.0
Synth:POLYA:1:10:List:0:ArrayList,2,collection,collection,ArrayList
Synth:POLYA:1:10:List:0:ArrayList,2,runToArray2,software,1
Synth:POLYA:1:10:List:0:ArrayList,2,runRetainAll,software,2
......@@ -328,10 +322,10 @@ class SyntheticBenchmarkFeaturePrinterTest {
Synth:POLYA:1:10:List:0:ArrayList,2,cyclesDeletions,hardware,1000.0
Synth:POLYA:1:10:List:0:ArrayList,2,cyclesSearches,hardware,1000.0
Synth:POLYA:1:10:List:0:ArrayList,2,cyclesIterations,hardware,1000.0
Synth:POLYA:1:10:List:0:ArrayList,2,PAPI_L1_DCM,hardware,1.0
Synth:POLYA:1:10:List:0:ArrayList,2,PAPI_L2_DCM,hardware,1.0
Synth:POLYA:1:10:List:0:ArrayList,2,PAPI_TOT_CYC,hardware,1.0
Synth:POLYA:1:10:List:0:ArrayList,2,PAPI_TOT_INS,hardware,1.0
Synth:POLYA:1:10:List:0:ArrayList,2,PAPI_L1_DCM,hardware,10000.0
Synth:POLYA:1:10:List:0:ArrayList,2,PAPI_L2_DCM,hardware,10000.0
Synth:POLYA:1:10:List:0:ArrayList,2,PAPI_TOT_CYC,hardware,10000.0
Synth:POLYA:1:10:List:0:ArrayList,2,PAPI_TOT_INS,hardware,10000.0
""".trimIndent()
......@@ -362,7 +356,6 @@ class SyntheticBenchmarkFeaturePrinterTest {
val sw = StringWriter()
val syntheticBenchmarkFeaturePrinter = SyntheticBenchmarkFeaturePrinter(sw,
PapiRunner(100, counterSpec),
stopWatchRunner,
methodOutputFormat,
true)
......
......@@ -10,6 +10,7 @@ import se.lth.cs.bcgen.BCBenchmarkPackage
import se.lth.cs.papicounters.PapiBenchmarkAnalyzer
import se.lth.cs.papicounters.PapiTracerRunner
import se.lth.cs.smartmodules.tracer.Tracer
import se.lth.cs.timing.OperationType
import se.lth.util.ArrayListTracer
import java.io.ByteArrayOutputStream
import java.io.File
......@@ -159,10 +160,10 @@ class TracingCollectionRunnerTest {
Assertions.assertEquals(10, iterations.size)
for (iteration in iterations) {
for (sample in iteration) {
for (sample in iteration.samples) {
Assertions.assertEquals("PAPI_TOT_CYC", sample.counter)
Assertions.assertTrue(sample.value > 0)
Assertions.assertTrue(sample.value < 500000)
Assertions.assertTrue(sample.value < 1000000)
}
}
}
......@@ -180,12 +181,13 @@ class TracingCollectionRunnerTest {
runner!!.runIterations(it)
}
val cycles = runner!!.getCyclesPerOpType(samples)
val cycles = samples.map { runner!!.getCyclesPerOpType(it) }
val expectedCounters = setOf("cyclesInsertions", "cyclesSearches", "cyclesDeletions", "cyclesIterations")
val expectedCounters = OperationType.values().toSet()
Assertions.assertEquals((0 until runner!!.numRuns).toSet(), cycles.map { it.first }.toSet())
Assertions.assertEquals(expectedCounters, cycles.map { it.second }.toSet())
Assertions.assertEquals(runner!!.numRuns, cycles.size)
Assertions.assertEquals(expectedCounters, cycles.flatMap { it.keys }.toSet())
}
}
\ No newline at end of file
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