Skip to content

Commit

Permalink
added --noCPU/-0 and --techReport/-tr, removed --fixLimit/-L
Browse files Browse the repository at this point in the history
  • Loading branch information
squell committed Oct 24, 2013
2 parents 79ffc49 + 78d6a88 commit 807b946
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 25 deletions.
3 changes: 2 additions & 1 deletion doc/examples/fixtest3.eca
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
Stub::raise increases the power level of the radio (max: 100)
Stub::lower decreases the power level of the radio

Our analysis says this program consumed 100 power, but this is not an over-estimate.
Using the TR-analysis, this loop consumes much less power.
But using strict synchronizing, the situation is better still.

*)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,13 @@ class EnergyAnalysis(program: Program, components: Set[ComponentModel], eh: Erro
else
G3 max G4

case While(pred, rf, consq) // this is the *OLD* while routine
if config.fixLimit => val Gpre = if (config.beforeSync) G.sync else G
case While(pred, rf, consq)
if config.techReport => val Gpre = if (config.beforeSync) G.sync else G
val G2 = analyse(Gpre,pred).update("CPU","w")
val G3 = analyse(G2,consq)
val G3fix = (fixPoint(G3.gamma, pred, consq), G3.t)
val G4 = analyse(analyse(G3fix, pred), consq)
val G4 = analyse(analyse(G3fix, pred).update("CPU","w"), consq)
//val G4 = analyse(analyse(G3fix, pred), consq) // this is bug-compatible with the TR
val iters = resolve(foldConstants(rf, env))
if(config.afterSync)
computeEnergyBound_TR(G4.sync, G3.sync, Gpre, iters).timeshift
Expand Down Expand Up @@ -232,7 +233,7 @@ object EnergyAnalysis {
checker.variableReferenceHygiene()
errorHandler.successOrElse("Semantic errors; please fix these.")

val components = Set(StubComponent, BadComponent, Sensor, Radio, CPU)
val components = Set(StubComponent, BadComponent, Sensor, Radio, if(config.Options.noCPU) StubComponent else CPU)

val consumptionAnalyser = new EnergyAnalysis(program, components, errorHandler)
println(consumptionAnalyser().toString)
Expand Down
45 changes: 25 additions & 20 deletions src/main/scala/nl/ru/cs/ecalogic/config/Options.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,17 @@ package nl.ru.cs.ecalogic
package config

import util.{Positional, Position}
import scala.collection.mutable.Queue
import scala.collection.mutable.ArrayBuilder
import scala.collection.mutable

/*
Stub.
TODO: adds some code that reads cmdline flags here.
*/

object Options {
/* Disable the simulated CPU; this switch should be deprecated in the future */
var noCPU = false

/* NOTE: there may be some interplay between these options; also, some
options may be unnecessary if you enable other options. */

Expand Down Expand Up @@ -85,44 +87,47 @@ object Options {
/* How long should we attempt to find fixpoint? Note that 10000 is a high setting */
var fixPatience = 10000

/* If the ranking function is a concrete value, take that instead of the above global value?
This will produce better estimates in exotic cases.
/* Should we use the while-rule mentioned in the tech-report, or the simplified one
mentioned in the paper?
Technical report: true */
var techReport = false

Technical report: false? -- but not clear on this point */
var fixLimit = false
}

def apply(args: Array[String]): Array[String] = {
import Analysis._
import Model._

val argHandler: Queue[String=>Unit] = Queue.empty
val newArgs = new ArrayBuilder.ofRef[String]
val argHandler: mutable.Queue[String=>Unit] = mutable.Queue.empty
val newArgs = Array.newBuilder[String]

args.foreach {
case "-L" | "--fixLimit"
=> fixLimit = true
case "-P" | "--fixPatience"
case "-0" | "--noCPU"
=> noCPU = true
case "-tr" | "--techReport"
=> techReport = true
case "-P" | "--fixPatience"
=> argHandler += (s => fixPatience = s.toInt)
case "-s0" | "--beforeSync"
case "-s0" | "--beforeSync"
=> beforeSync = true
case "-s1" | "--afterSync"
case "-s1" | "--afterSync"
=> afterSync = true
case "-s" | "--sync"
case "-s" | "--sync"
=> beforeSync = true; afterSync = true
case "-u0" | "--alwaysUpdate"
case "-u0" | "--alwaysUpdate"
=> alwaysUpdate = true
case "-u1" | "--alwaysForwardTime"
case "-u1" | "--alwaysForwardTime"
=> alwaysForwardTime = true
case "-u" | "--update"
case "-u" | "--update"
=> alwaysUpdate = true; alwaysForwardTime = true
case "-?" | "--help"
case "-?" | "--help"
=> friendlyHelpMsg(); return Array.empty
case s if s.startsWith("-")
=> throw new ECAException(s"unknown flag: $s")
case s if argHandler.nonEmpty
=> argHandler.dequeue()(s)
case s
case s
=> newArgs += s
}

Expand All @@ -133,7 +138,7 @@ object Options {
println("...")
}

def main(args: Array[String]) =
def main(args: Array[String]) =
println(apply(args).reduce(_+", "+_))

}
Expand Down

0 comments on commit 807b946

Please sign in to comment.