Skip to content

Commit

Permalink
Merge pull request ucb-bar#99 from ucb-bar/mask_penalty
Browse files Browse the repository at this point in the history
Macrocompiler should prioritize memories with no masks with DefaultCostMetric
  • Loading branch information
jerryz123 authored Mar 12, 2021
2 parents 12d0c25 + bca3896 commit c8f3d34
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion macros/src/main/scala/barstools/macros/CostMetric.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down

0 comments on commit c8f3d34

Please sign in to comment.