Commit 1631673c authored by Noric Couderc's avatar Noric Couderc
Browse files

Implemented caching of eventSets in EventSetBuilder

Not strictly necessary, since we don't use the generated EventSet in
Experiment. But might be useful later.
parent 059d2e80
......@@ -43,25 +43,33 @@ class EventSetBuilder : FeatureVisitor {
// Do nothing
}
private var eventSet : EventSet? = null
override fun visitFeatureSet(featureSet: FeatureSet) {
for (f in featureSet) {
f.accept(this)
}
val counters = counterSet.map { it.toPAPIConstant()!! }.toIntArray()
eventSet = EventSet.create(*counters)
}
fun getCounterSet() : Set<PAPICounter> {
return counterSet.toSet()
}
companion object {
val eventSetCache : MutableMap<Set<PAPICounter>, EventSet> = mutableMapOf()
}
fun getEventSet() : EventSet {
if (eventSet == null) {
throw RuntimeException("EventSet not created! Did you call accept() on the builder?")
if (counterSet.isEmpty()) {
throw RuntimeException("Counter set is empty! Did you call accept() on the builder?")
}
return if (eventSetCache.containsKey(counterSet)) {
val eventSet = eventSetCache.get(counterSet)!!
eventSet.reset()
eventSet
} else {
val counters = counterSet.map { it.toPAPIConstant()!! }.toIntArray()
val eventSet = EventSet.create(*counters)
eventSetCache.put(counterSet, eventSet!!)
eventSet!!
}
return eventSet!!
}
}
\ No newline at end of file
......@@ -29,16 +29,14 @@ class Experiment(val numberIterations : Int,
fun getIterations(): List<List<PapiTracerRunner.TraceRecord>> {
val eventSetBuilder = EventSetBuilder()
eventSetBuilder.visitFeatureSet(features)
val counters = eventSetBuilder.getCounterSet()
val counters = eventSetBuilder.getCounterSet()
val evSet = eventSetBuilder.getEventSet()
val iterations = papiRunner.runIterations(
PapiBenchmarkAnalyzer.RunSpec(numberIterations, counters.toList(), evSet, benchmark)
)
evSet.destroy()
return iterations
}
......
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