Merge pull request #99 from ucb-bar/mask_penalty

Macrocompiler should prioritize memories with no masks with DefaultCostMetric
This commit is contained in:
Jerry Zhao
2021-03-11 17:57:15 -08:00
committed by GitHub

View File

@@ -126,6 +126,10 @@ object DefaultMetric extends CostMetric with CostMetricCompanion {
else (mem.src.width / p) * m //Waste the extra maskbits
}
}
val maskPenalty = (memMask, libMask) match {
case (None, Some(m)) => 0.001
case (_, _) => 0
}
val depthCost = math.ceil(mem.src.depth.toDouble / lib.src.depth.toDouble)
val widthCost = math.ceil(memWidth.toDouble / lib.src.width.toDouble)
val bitsCost = (lib.src.depth * lib.src.width).toDouble
@@ -134,7 +138,7 @@ object DefaultMetric extends CostMetric with CostMetricCompanion {
val bitsWasted = depthCost * widthCost * bitsCost - requestedBits
val wastedConst = 0.05 // 0 means waste as few bits with no regard for instance count
val costPerInst = wastedConst * depthCost * widthCost
Some(1.0 * bitsWasted / requestedBits + costPerInst)
Some(1.0 * bitsWasted / requestedBits + costPerInst + maskPenalty)
}
override def commandLineParams = Map()