Commit d793fd45 authored by Noric Couderc's avatar Noric Couderc
Browse files

Fix: Fixed errors in tests for PapiTracerRunner

Some tests failed because the way we handle counters wasn't correct.
parent 6b6c07c7
......@@ -74,6 +74,8 @@ open class PapiTracerRunner() : PapiRunner() {
*/
private fun analyzeOutput(records : List<TraceRecord>): ValueGraph<String, Int> {
// We can analyze the output to get what we want.
assert(!records.isEmpty())
val g: MutableValueGraph<String, Int> = ValueGraphBuilder.directed().build()
for (r in records) {
......@@ -137,7 +139,8 @@ open class PapiTracerRunner() : PapiRunner() {
// We get the output from the run
val stream = ByteArrayOutputStream()
Tracer.printRecords(1, PrintStream(stream))
Tracer.printRecords(0, PrintStream(stream))
return makeRecords(stream.toString())
}
......@@ -181,6 +184,7 @@ open class PapiTracerRunner() : PapiRunner() {
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.isEmpty())
assert(iteration.map { it.allocationSite }.toSet().size == 1)
val result = OperationType.values().associate {
......@@ -229,6 +233,8 @@ class MockupPapiTracerRunner() : PapiTracerRunner() {
val collection = createTracerCollection(syntheticBenchmark)
syntheticBenchmark.datastructure = collection
Tracer.stopAll()
return syntheticBenchmark.trace.flatMap { method ->
val methodOtherFormat = methodNameTable2.inverseBidiMap()[method]
counters.map { counter ->
......
......@@ -7,7 +7,7 @@ import org.junit.jupiter.params.provider.ValueSource
import org.openjdk.jmh.infra.Blackhole
import papi.Constants
import papi.EventSet
import se.lth.cs.average
import papi.Papi
import se.lth.cs.bcgen.BCBenchmarkPackage
import se.lth.cs.papicounters.PAPICounter
import se.lth.cs.papicounters.PapiBenchmarkAnalyzer
......@@ -15,17 +15,19 @@ import se.lth.cs.papicounters.PapiTracerRunner
import se.lth.cs.smartmodules.tracer.Tracer
import se.lth.cs.timing.OperationType
import se.lth.cs.util.FeatureSet
import se.lth.cs.variance
import se.lth.util.ArrayListTracer
import java.io.ByteArrayOutputStream
import java.io.File
import java.io.PrintStream
import java.util.*
import kotlin.collections.ArrayList
import kotlin.collections.HashMap
import kotlin.collections.HashSet
import kotlin.system.measureTimeMillis
class TracingCollectionRunnerTest {
// In this file, we will test running benchmarks with tracing collections
// We create a benchmark, run it with tracing collections, and obtain the counters afterwards
companion object {
val blackhole = Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.")
......@@ -34,13 +36,17 @@ class TracingCollectionRunnerTest {
@BeforeAll()
@JvmStatic
fun initTracer() {
System.out.println("Initialize PAPI")
Tracer.JPAPI = true
Tracer.addCounter(Constants.PAPI_TOT_CYC)
Tracer.addCounter(Constants.PAPI_TOT_INS)
// EventSet.logCalls = false
}
}
@BeforeEach
fun setup() {
val papiAvailableCounters = File("../papi_avail")
Assertions.assertTrue(papiAvailableCounters.exists())
runner = PapiTracerRunner()
}
@Test
@Disabled("Results differ depending of Java version")
fun testOneBenchmark() {
......@@ -120,12 +126,7 @@ class TracingCollectionRunnerTest {
// What we need: A drop-in replacement for PapiRunner, which uses these collections instead.
@BeforeEach
fun setup() {
val papiAvailableCounters = File("../papi_avail")
Assertions.assertTrue(papiAvailableCounters.exists())
runner = PapiTracerRunner()
}
@Test
fun testRunner() {
......@@ -209,6 +210,7 @@ class TracingCollectionRunnerTest {
val results = runner!!.runApplications(10, FeatureSet(), listOf(bench))
// We reset numberRuns for each iteration, so the benchmarks is run "once".
for (r in results) {
Assertions.assertEquals(1, r.benchmark.numberRuns)
}
......
No preview for this file type
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