Commit 4b7d9357 authored by Noric Couderc's avatar Noric Couderc
Browse files

Gracefully handle when some counters are missing

We just de-activate the counters that are not avaiable.
parent 4ed3300e
......@@ -13,7 +13,10 @@ class EventSetBuilder : FeatureVisitor {
private var counterSet : LinkedHashSet<PAPICounter> = java.util.LinkedHashSet()
override fun visitPAPICounter(c: PAPICounter) {
counterSet.add(c)
// If the counter is de-activated we skip it
if (c.isActive) {
counterSet.add(c)
}
}
override fun visitConstant(constantFeature: ConstantFeature) {
......
......@@ -17,6 +17,8 @@ class PAPICounter(val counter : String) : Feature() {
return CounterSpecification.allCounters.contains(counter)
}
var isActive : Boolean = false
fun check() {
Papi.init()
try {
......@@ -29,10 +31,12 @@ class PAPICounter(val counter : String) : Feature() {
// }
// eventSet.stop()
// eventSet.destroy()
isActive = true
} catch (e : PapiException) {
val msg = "Creating eventSet for single counter '%s' failed: is it available on this machine?"
.format(counter)
throw RuntimeException(msg)
val msg = "Creating eventSet for single counter $counter failed: is it available on this machine? Deactivating..."
System.err.println("[WARNING]: $msg")
isActive = false
}
}
......
......@@ -210,13 +210,20 @@ open class PapiTracerRunner() : PapiRunner() {
class MockupPapiTracerRunner() : PapiTracerRunner() {
override fun runIteration(syntheticBenchmark: BCBenchmarkPackage<*>): List<TraceRecord> {
val counter = PAPICounter("PAPI_TOT_CYC")
return syntheticBenchmark.trace.map { method ->
val counters = listOf(PAPICounter("PAPI_TOT_CYC"),
PAPICounter("PAPI_BR_MSP"),
PAPICounter("PAPI_BR_CN"),
PAPICounter("PAPI_L1_DCM"),
PAPICounter("PAPI_L1_DCA"))
return syntheticBenchmark.trace.flatMap { method ->
val methodOtherFormat = methodNameTable2.inverseBidiMap()[method]
TraceRecord("alloc1", counter.toHexa(), 1000,
syntheticBenchmark.dataStructureName.removeSuffix("Tracer"),
methodOtherFormat ?: method
)
counters.map { counter ->
TraceRecord(
"alloc1", counter.toHexa(), 1000,
syntheticBenchmark.dataStructureName.removeSuffix("Tracer"),
methodOtherFormat ?: method
)
}
}
}
}
......@@ -58,8 +58,11 @@ class Experiment(val numberIterations : Int,
var currentIterationResults : MutableMap<Feature, Double> = mutableMapOf()
override fun visitPAPICounter(c: PAPICounter) {
if (!c.isActive) {
return
}
if (currentIterationResults.containsKey(c)) {
return;
return
}
val values = currentIteration.filter { it.featureName == c.toHexa() }
......@@ -93,10 +96,12 @@ class Experiment(val numberIterations : Int,
featureRatio.f1.accept(this)
featureRatio.f2.accept(this)
val f1Value = currentIterationResults[featureRatio.f1]!!
val f2Value = currentIterationResults[featureRatio.f2]!!
val f1Value = currentIterationResults[featureRatio.f1]
val f2Value = currentIterationResults[featureRatio.f2]
currentIterationResults[featureRatio] = f1Value / f2Value
if (f1Value != null && f2Value != null) {
currentIterationResults[featureRatio] = f1Value / f2Value
}
}
override fun visitFeatureSet(featureSet: FeatureSet) {
......
......@@ -92,7 +92,7 @@ class EventSetBuilderTest {
Assertions.assertEquals(expected.toSet(), builder.getCounterSet())
}
@Disabled("PAPI_L1_DCA is not available on the machine")
// @Disabled("PAPI_L1_DCA is not available on the machine")
@Test
fun testEventBuildInvalidEvents() {
val features = listOf(
......@@ -103,6 +103,7 @@ class EventSetBuilderTest {
// Oh no! empty list of PAPI events!
val builder = EventSetBuilder()
Assertions.assertThrows(RuntimeException::class.java, { spec.accept(builder) })
spec.accept(builder)
// Assertions.assertThrows(RuntimeException::class.java, { spec.accept(builder) })
}
}
\ No newline at end of file
......@@ -79,14 +79,20 @@ class ExperimentTest {
}
}
@Disabled("PAPI_L1_DCA was not available on my machine, so it wouldn't work")
// @Disabled("PAPI_L1_DCA was not available on my machine, so it wouldn't work")
@Test
fun testExperimentBrainyFeatures() {
val bench = BCBenchmarkPackage.LIST(1234, 100, 0, ArrayList<Int>())
val exp = Experiment(10, bench, brainyFeatures(), runner)
val features = brainyFeatures()
val exp = Experiment(10, bench, features,runner)
val results = exp.run()
Assertions.assertEquals(listOf<Map<Feature, Double>>(), results)
for (iteration in results) {
Assertions.assertEquals(bench, iteration.benchmark)
Assertions.assertTrue(iteration.values.values.all { it > 0 })
}
}
}
\ No newline at end of file
No preview for this file type
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