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

Refactoring: moved counterSpec to its own class

The hardware counter specification is now passed as an argument of the
papirunner class.
parent 87ffa967
package se.lth.cs
import papi.Constants
import papi.EventSet
import papi.Papi
import papi.PapiException
import se.lth.cs.ApplicationGeneration.ListApplicationGenerator
import java.io.File
val counterSpec =
sortedMapOf(
"PAPI_L1_DCM" to Constants.PAPI_L1_DCM,
"PAPI_L1_ICM" to Constants.PAPI_L1_ICM,
"PAPI_L2_DCM" to Constants.PAPI_L2_DCM,
"PAPI_L2_ICM" to Constants.PAPI_L2_ICM,
"PAPI_L1_TCM" to Constants.PAPI_L1_TCM,
"PAPI_L2_TCM" to Constants.PAPI_L2_TCM,
"PAPI_L3_TCM" to Constants.PAPI_L3_TCM,
"PAPI_CA_SNP" to Constants.PAPI_CA_SNP,
"PAPI_CA_SHR" to Constants.PAPI_CA_SHR,
"PAPI_CA_CLN" to Constants.PAPI_CA_CLN,
"PAPI_CA_ITV" to Constants.PAPI_CA_ITV,
"PAPI_L3_LDM" to Constants.PAPI_L3_LDM,
"PAPI_TLB_DM" to Constants.PAPI_TLB_DM,
"PAPI_TLB_IM" to Constants.PAPI_TLB_IM,
"PAPI_L1_LDM" to Constants.PAPI_L1_LDM,
"PAPI_L1_STM" to Constants.PAPI_L1_STM,
"PAPI_L2_LDM" to Constants.PAPI_L2_LDM,
"PAPI_L2_STM" to Constants.PAPI_L2_STM,
"PAPI_PRF_DM" to Constants.PAPI_PRF_DM,
"PAPI_MEM_WCY" to Constants.PAPI_MEM_WCY,
"PAPI_STL_ICY" to Constants.PAPI_STL_ICY,
"PAPI_FUL_ICY" to Constants.PAPI_FUL_ICY,
"PAPI_STL_CCY" to Constants.PAPI_STL_CCY,
"PAPI_FUL_CCY" to Constants.PAPI_FUL_CCY,
"PAPI_BR_UCN" to Constants.PAPI_BR_UCN,
"PAPI_BR_CN" to Constants.PAPI_BR_CN,
"PAPI_BR_TKN" to Constants.PAPI_BR_TKN,
"PAPI_BR_NTK" to Constants.PAPI_BR_NTK,
"PAPI_BR_MSP" to Constants.PAPI_BR_MSP,
"PAPI_BR_PRC" to Constants.PAPI_BR_PRC,
"PAPI_TOT_INS" to Constants.PAPI_TOT_INS,
"PAPI_LD_INS" to Constants.PAPI_LD_INS,
"PAPI_SR_INS" to Constants.PAPI_SR_INS,
"PAPI_BR_INS" to Constants.PAPI_BR_INS,
"PAPI_RES_STL" to Constants.PAPI_RES_STL,
"PAPI_TOT_CYC" to Constants.PAPI_TOT_CYC,
"PAPI_LST_INS" to Constants.PAPI_LST_INS,
"PAPI_L2_DCA" to Constants.PAPI_L2_DCA,
"PAPI_L3_DCA" to Constants.PAPI_L3_DCA,
"PAPI_L2_DCR" to Constants.PAPI_L2_DCR,
"PAPI_L3_DCR" to Constants.PAPI_L3_DCR,
"PAPI_L2_DCW" to Constants.PAPI_L2_DCW,
"PAPI_L3_DCW" to Constants.PAPI_L3_DCW,
"PAPI_L2_ICH" to Constants.PAPI_L2_ICH,
"PAPI_L2_ICA" to Constants.PAPI_L2_ICA,
"PAPI_L3_ICA" to Constants.PAPI_L3_ICA,
"PAPI_L2_ICR" to Constants.PAPI_L2_ICR,
"PAPI_L3_ICR" to Constants.PAPI_L3_ICR,
"PAPI_L2_TCA" to Constants.PAPI_L2_TCA,
"PAPI_L3_TCA" to Constants.PAPI_L3_TCA,
"PAPI_L2_TCR" to Constants.PAPI_L2_TCR,
"PAPI_L3_TCR" to Constants.PAPI_L3_TCR,
"PAPI_L2_TCW" to Constants.PAPI_L2_TCW,
"PAPI_L3_TCW" to Constants.PAPI_L3_TCW,
"PAPI_SP_OPS" to Constants.PAPI_SP_OPS,
"PAPI_DP_OPS" to Constants.PAPI_DP_OPS,
"PAPI_VEC_SP" to Constants.PAPI_VEC_SP,
"PAPI_VEC_DP" to Constants.PAPI_VEC_DP,
"PAPI_REF_CYC" to Constants.PAPI_REF_CYC
)
val counters = counterSpec.values.toIntArray()
class PapiRunner() {
class PapiRunner(counters : CounterSpecification) {
init {
Papi.init()
}
val counterSpec = counters
/**
* Empty benchmark:
* Test to see if the results are stable.
......@@ -85,7 +22,7 @@ class PapiRunner() {
// we store the values for each run (10 runs)
var data : MutableMap<String, List<Long>> = mutableMapOf()
for (kvp in counterSpec) {
for (kvp in counterSpec.currentSpec) {
val evset = EventSet.create(kvp.value)
val current : MutableList<Long> = mutableListOf()
......@@ -132,7 +69,7 @@ class PapiRunner() {
val function = labelAndFunction.second
val label = labelAndFunction.first
val values : MutableMap<String, List<Long>> = mutableMapOf()
for (counter in counterSpec.keys) {
for (counter in counterSpec.currentSpec.keys) {
values.put(counter, runFunction(numRuns, counter, function))
}
for (counterAndValues in values) {
......@@ -148,7 +85,7 @@ class PapiRunner() {
* @return A map from PAPI counter names to list of values
*/
inline fun runFunction(numRuns : Int, counter : String, function : () -> Unit): MutableList<Long> {
val counterId = counterSpec[counter]!!
val counterId = counterSpec.getCounter(counter)!!
// We record only one counter
var evset = EventSet.create()
try {
......@@ -188,7 +125,7 @@ class PapiRunner() {
}
// For each counter that is available
for (kvp in counterSpec) {
for (kvp in counterSpec.currentSpec) {
val counterName = kvp.key
println("Streamlined mode: '$counterName'")
......@@ -321,7 +258,7 @@ class PapiRunner() {
Map<String, List<Long>> {
var data : MutableMap<BenchmarkId, MutableList<Long>> = mutableMapOf()
for (kvp in counterSpec) {
for (kvp in counterSpec.currentSpec) {
val evset = EventSet.create(kvp.value)
println("Interleaved mode: " + "'" + kvp.key + "'")
......@@ -353,7 +290,7 @@ class PapiRunner() {
}
fun main(args : Array<String>) {
val r = PapiRunner()
val r = PapiRunner(CounterSpecification.fromFile(File("PAPI_FLAGS")))
val apps = // ListApplicationGenerator().createApplications(0, 100, 100)
ApplicationRunner().createListApplicationsSpread(20, 100, ListApplicationGenerator())
val data = r.getFeatures(20, apps.map { it.application })
......
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