Commit 0ad3ab91 authored by Noric Couderc's avatar Noric Couderc
Browse files

Implemented automatic detection of cache block size

Doesn't work on windows
parent ffe758ff
......@@ -221,20 +221,40 @@ fun normalize(featureSet : FeatureSet): FeatureSet {
return FeatureSet(*features)
}
fun cacheLineSizeFeature(): HardwareConstantFeature? {
val processBuilder = ProcessBuilder()
processBuilder.command("getconf", "LEVEL1_DCACHE_LINESIZE")
val process = processBuilder.start()
val input = process.inputStream
val lines = input.bufferedReader().lines()
// "orElse(null)" :C
val cacheSize : HardwareConstantFeature? = lines.findFirst().map { Integer.parseInt(it) }
.map { HardwareConstantFeature("Cache Block Size", it.toDouble()) }.orElse(null)
return cacheSize
}
fun brainyFeatures() : FeatureSet {
// We need to get the cache block size on this machine
val dataSizeFeature = SoftwareConstantFeature("Data Size", Integer.BYTES.toDouble())
val cacheSize = cacheLineSizeFeature()
val sizesRatioFeature = if (cacheSize == null) { dataSizeFeature }
else {
FeatureRatio(
dataSizeFeature,
cacheSize
)
}
return FeatureSet(
PAPICounter("PAPI_BR_MSP"),
PAPICounter("PAPI_BR_MSP"),
PAPICounter("PAPI_L1_DCM"),
FeatureRatio(
PAPICounter("PAPI_L1_DCM"),
PAPICounter("PAPI_L1_DCA")
),
FeatureRatio(
SoftwareConstantFeature("Data Size", Integer.BYTES.toDouble()),
// Type "getconf -a | grep "CACHE" to find this.
// TODO: Make this automatic
HardwareConstantFeature("Cache Block Size", 64.0)
),
sizesRatioFeature,
FeatureRatio(
PAPICounter("PAPI_BR_MSP"),
PAPICounter("PAPI_BR_CN")
......
......@@ -92,6 +92,12 @@ class ExperimentTest {
}
}
@Test
fun cacheSizeFeatures() {
val f = cacheLineSizeFeature()
Assertions.assertFalse(f == null)
}
@Test
fun testNormalizationBrainyFeatures() {
val bench = BCBenchmarkPackage.LIST(1234, 100, 0, ArrayList<Int>())
......
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