Commit 64e118dc authored by Noric Couderc's avatar Noric Couderc
Browse files

Implemented debug mode with mockup papi runner

In debug mode, the printed PAPI features are a deterministic value,
which should be easy enough for classification.

I will probably change what the value for each counter is, but it
helps making sure that the data printed is not complete garbage.
parent 5fd9e116
......@@ -210,3 +210,22 @@ open class PapiRunner(private val numRuns: Int, counters: CounterSpecification)
}
}
}
/**
* 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 : RunSpec) : List<Long> {
val seed = spec.syntheticBenchmark.seed
// We map the counters to integers
// val counterToInt = mapOf<String, Long>(
// Pair("PAPI_CA_ITV", 0),
// Pair("PAPI_L1_DCM", 1),
// Pair("PAPI_TOT_CYC", 2),
// Pair("PAPI_TOT_INS", 3)
// )
// val n = seed + counterToInt[spec.counter]!!
val n = seed
return listOf(n, n, n)
}
}
......@@ -52,6 +52,9 @@ class PapiCommandLine : CliktCommand() {
help = "Activate or deactivate normalization of features")
.flag("normalize features", default = false)
val debugMode : Boolean by option("--debug",
help = "Debugging mode (uses a fake Papi Runner)").flag("debug mode ", default = false)
fun checkFileExists(file: File) {
if (!file.exists()) {
......@@ -74,10 +77,11 @@ class PapiCommandLine : CliktCommand() {
"SOFTWARE-TRACES" -> SyntheticBenchmarkTracePrinter(writer, methodOutputFormat)
"SOFTWARE-COUNTERS" -> SyntheticBenchmarkHistPrinter(writer, methodOutputFormat)
"FEATURE-VECTORS" -> {
val runner = PapiRunner(
numberRuns,
CounterSpecification.fromFile(countersFile)
)
val runner = if (debugMode) {
MockupPapiRunner(numberRuns, CounterSpecification.fromFile(countersFile))
} else {
PapiRunner(numberRuns, CounterSpecification.fromFile(countersFile))}
SyntheticBenchmarkFeaturePrinter(writer, runner, methodOutputFormat, normalizeFeatures)
}
"SUGGESTIONS" -> { // This is different...
......
......@@ -4,6 +4,7 @@ import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import se.lth.cs.CounterSpecification
import se.lth.cs.MockupPapiRunner
import se.lth.cs.PapiRunner
import se.lth.cs.SyntheticBenchmarkFeaturePrinter
import se.lth.cs.bcgen.BCBenchmarkPackage
......@@ -29,23 +30,7 @@ class SyntheticBenchmarkFeaturePrinterTest {
val methodOutputFormat = "JAVA-STANDARD-FORMAT"
val normalizeFeatures = false
/**
* 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 : RunSpec) : List<Long> {
val seed = spec.syntheticBenchmark.seed
// We map the counters to integers
val counterToInt = mapOf<String, Long>(
Pair("PAPI_CA_ITV", 0),
Pair("PAPI_L1_DCM", 1),
Pair("PAPI_TOT_CYC", 2),
Pair("PAPI_TOT_INS", 3)
)
val n = seed + counterToInt[spec.counter]!!
return listOf(n, n, n)
}
}
val runner = MockupPapiRunner( 10, counterSpec)
......
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