Commit 1a6e9485 authored by Noric Couderc's avatar Noric Couderc
Browse files

Fix: Bugs with running experiments

Added tests to expose bugs in running experiments several times in a
row, and fixed them.
parent d793fd45
...@@ -5,6 +5,7 @@ import se.lth.cs.papicounters.EventSetBuilder ...@@ -5,6 +5,7 @@ import se.lth.cs.papicounters.EventSetBuilder
import se.lth.cs.papicounters.PAPICounter import se.lth.cs.papicounters.PAPICounter
import se.lth.cs.papicounters.PapiBenchmarkAnalyzer import se.lth.cs.papicounters.PapiBenchmarkAnalyzer
import se.lth.cs.papicounters.PapiTracerRunner import se.lth.cs.papicounters.PapiTracerRunner
import se.lth.cs.smartmodules.tracer.Tracer
import se.lth.cs.timing.OperationTypeTable import se.lth.cs.timing.OperationTypeTable
import java.util.stream.Stream import java.util.stream.Stream
......
import org.junit.FixMethodOrder
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.junit.runners.MethodSorters
import papi.Constants
import papi.EventSet
import se.lth.cs.bcgen.BCBenchmarkPackage import se.lth.cs.bcgen.BCBenchmarkPackage
import se.lth.cs.papicounters.MockupPapiTracerRunner
import se.lth.cs.papicounters.PAPICounter import se.lth.cs.papicounters.PAPICounter
import se.lth.cs.papicounters.PapiTracerRunner import se.lth.cs.papicounters.PapiTracerRunner
import se.lth.cs.smartmodules.tracer.Tracer
import se.lth.cs.timing.OperationType import se.lth.cs.timing.OperationType
import se.lth.cs.util.* import se.lth.cs.util.*
import java.util.stream.Collectors import java.util.stream.Collectors
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
class ExperimentTest { class ExperimentTest {
val runner = MockupPapiTracerRunner() val runner = PapiTracerRunner()
@Test @Test
fun testExperimentNoFeatures() { fun testExperimentNoFeatures() {
...@@ -38,7 +42,7 @@ class ExperimentTest { ...@@ -38,7 +42,7 @@ class ExperimentTest {
IntRange(0, 9).toList(), IntRange(0, 9).toList(),
results.map { it.iterationNumber } results.map { it.iterationNumber }
) )
Assertions.assertTrue(results.all { it.values[PAPICounter("PAPI_TOT_CYC")] == 100000.0 }) Assertions.assertTrue(results.all { it.values[PAPICounter("PAPI_TOT_CYC")]!! > 0.0 })
Assertions.assertEquals(setOf(PAPICounter("PAPI_TOT_CYC")), Assertions.assertEquals(setOf(PAPICounter("PAPI_TOT_CYC")),
results.flatMap{ it.values.keys }.toSet()) results.flatMap{ it.values.keys }.toSet())
} }
...@@ -86,6 +90,12 @@ class ExperimentTest { ...@@ -86,6 +90,12 @@ class ExperimentTest {
val results = exp.run() val results = exp.run()
// Fails for some reason. I don't understand why
// Throws an exception with number -8
val eventSet = EventSet.create(Constants.PAPI_TOT_CYC)
eventSet.start()
eventSet.stop()
for (iteration in results) { for (iteration in results) {
Assertions.assertEquals(bench, iteration.benchmark) Assertions.assertEquals(bench, iteration.benchmark)
Assertions.assertTrue(iteration.values.values.all { it > 0 }) Assertions.assertTrue(iteration.values.values.all { it > 0 })
......
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import papi.Constants
import papi.EventSet
import se.lth.cs.SyntheticBenchmarkExperimentPrinter import se.lth.cs.SyntheticBenchmarkExperimentPrinter
import se.lth.cs.bcgen.BCBenchmarkPackage import se.lth.cs.bcgen.BCBenchmarkPackage
import se.lth.cs.matchFunction import se.lth.cs.matchFunction
...@@ -35,6 +37,31 @@ class SyntheticBenchmarkExperimentPrinterTest { ...@@ -35,6 +37,31 @@ class SyntheticBenchmarkExperimentPrinterTest {
writer.toString()) writer.toString())
} }
@Test
fun testTracingAfterPrinting() {
val writer = StringWriter()
val features = FeatureSet(
PAPICounter("PAPI_TOT_CYC"),
CostFeature(OperationType.INSERT),
MethodInvocations("runAdd", "JAVA-STANDARD-FORMAT")
)
val printer = SyntheticBenchmarkExperimentPrinter(writer,
"",
10,
features, MockupPapiTracerRunner())
val benchmarks = listOf(
BCBenchmarkPackage.LIST(1234L, 100, 0, ArrayList<Integer>())
)
printer.printToCSV(benchmarks)
// We check we can still gather counters after that
val eventSet = EventSet.create(Constants.PAPI_TOT_CYC)
eventSet.start()
eventSet.stop()
}
@Test @Test
fun testListBenchmarks() { fun testListBenchmarks() {
val writer = StringWriter() val writer = StringWriter()
......
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