fix defaults
This commit is contained in:
@@ -12,12 +12,12 @@ trait BaseOption[T](using conv: ValueConverter[T]) extends ConfigElement {
|
||||
scallop = createScallop(scallopConf, group)
|
||||
}
|
||||
|
||||
def default: () => T
|
||||
def default: () => Option[T]
|
||||
|
||||
def get: T = scallop.getOrElse(default())
|
||||
def apply(): T = get
|
||||
def get: Option[T] = scallop.toOption.orElse(default())
|
||||
def apply(): T = get.get
|
||||
|
||||
def getToolParameters: Seq[Shellable] = if (scallop.isDefined) Seq(s"$toolName", getToolArg) else Seq()
|
||||
def getToolParameters: Seq[Shellable] = if (get.isDefined) Seq(s"$toolName", getToolArg) else Seq()
|
||||
|
||||
def toolName: String
|
||||
def getToolArg: String = get.toString
|
||||
|
@@ -5,7 +5,7 @@ import org.rogach.scallop.*
|
||||
enum Color:
|
||||
case Red, Green, Blue
|
||||
|
||||
class ChoiceOption(choices: Seq[String], cliName: String, val toolName: String, descr: String, val default: () => String, required: Boolean, cliShort: Char) extends BaseOption[String] {
|
||||
class ChoiceOption(choices: Seq[String], cliName: String, val toolName: String, descr: String, val default: () => Option[String], required: Boolean, cliShort: Char) extends BaseOption[String] {
|
||||
override protected def createScallop(conf: ScallopConf, group: ScallopOptionGroup): ScallopOption[String] = {
|
||||
conf.choice(choices, name = cliName, short = cliShort, descr = descr, required = required, group = group)
|
||||
}
|
||||
|
@@ -34,19 +34,19 @@ trait BaseGroup extends ConfigElement with ValidationBase[BaseOption] with Valid
|
||||
}
|
||||
}
|
||||
|
||||
def value[T](cliName: String, toolName: String, descr: String = "", default: () => T, required: Boolean = false, cliShort: Char = '\u0000')(using conv: ValueConverter[T]): ValueOption[T] = add(ValueOption(cliName, toolName, descr, default, required, cliShort))
|
||||
def valueS[T](name: String, descr: String = "", default: () => T, required: Boolean = false, cliShort: Char = '\u0000')(using conv: ValueConverter[T]): ValueOption[T] = add(ValueOption(name, name, descr, default, required, cliShort))
|
||||
def value[T](cliName: String, toolName: String, descr: String = "", default: () => Option[T] = () => None, required: Boolean = false, cliShort: Char = '\u0000')(using conv: ValueConverter[T]): ValueOption[T] = add(ValueOption(cliName, toolName, descr, default, required, cliShort))
|
||||
def valueS[T](name: String, descr: String = "", default: () => Option[T] = () => None, required: Boolean = false, cliShort: Char = '\u0000')(using conv: ValueConverter[T]): ValueOption[T] = add(ValueOption(name, name, descr, default, required, cliShort))
|
||||
|
||||
def trail[T](toolName: String, descr: String = "", default: () => T, required: Boolean = false)(using conv: ValueConverter[T]): TrailOption[T] = add(TrailOption(toolName, descr, default, required))
|
||||
def trail[T](toolName: String, descr: String = "", default: () => Option[T] = () => None, required: Boolean = false)(using conv: ValueConverter[T]): TrailOption[T] = add(TrailOption(toolName, descr, default, required))
|
||||
|
||||
def choice(choices: Seq[String], cliName: String, toolName: String, descr: String = "", default: () => String, required: Boolean = false, cliShort: Char = '\u0000'): ChoiceOption = add(ChoiceOption(choices, cliName, toolName, descr, default, required, cliShort))
|
||||
def choiceS(choices: Seq[String], name: String, descr: String = "", default: () => String, required: Boolean = false, cliShort: Char = '\u0000'): ChoiceOption = add(ChoiceOption(choices, name, name, descr, default, required, cliShort))
|
||||
def choice(choices: Seq[String], cliName: String, toolName: String, descr: String = "", default: () => Option[String] = () => None, required: Boolean = false, cliShort: Char = '\u0000'): ChoiceOption = add(ChoiceOption(choices, cliName, toolName, descr, default, required, cliShort))
|
||||
def choiceS(choices: Seq[String], name: String, descr: String = "", default: () => Option[String] = () => None, required: Boolean = false, cliShort: Char = '\u0000'): ChoiceOption = add(ChoiceOption(choices, name, name, descr, default, required, cliShort))
|
||||
|
||||
def tally(cliName: String, toolName: String, descr: String = "", required: Boolean = false, cliShort: Char = '\u0000'): TallyOption = add(TallyOption(cliName, toolName, descr, required, cliShort))
|
||||
def tallyS(name: String, descr: String = "", required: Boolean = false, cliShort: Char = '\u0000'): TallyOption = add(TallyOption(name, name, descr, required, cliShort))
|
||||
|
||||
def toggle(cliName: String, toolName: String, descr: String = "", default: () => Boolean = () => false, required: Boolean = false, cliShort: Char = '\u0000'): ToggleOption = add(ToggleOption(cliName, toolName, descr, default, required, cliShort))
|
||||
def toggleS(name: String, descr: String = "", default: () => Boolean, required: Boolean = false, cliShort: Char = '\u0000'): ToggleOption = add(ToggleOption(name, name, descr, default, required, cliShort))
|
||||
def toggle(cliName: String, toolName: String, descr: String = "", default: () => Option[Boolean] = () => None, required: Boolean = false, cliShort: Char = '\u0000'): ToggleOption = add(ToggleOption(cliName, toolName, descr, default, required, cliShort))
|
||||
def toggleS(name: String, descr: String = "", default: () => Option[Boolean] = () => None, required: Boolean = false, cliShort: Char = '\u0000'): ToggleOption = add(ToggleOption(name, name, descr, default, required, cliShort))
|
||||
}
|
||||
|
||||
trait OptionGroup extends BaseGroup {
|
||||
|
@@ -7,5 +7,5 @@ class TallyOption(cliName: String, val toolName: String, descr: String, required
|
||||
conf.tally(name = cliName, short = cliShort, descr = descr, group = group)
|
||||
}
|
||||
|
||||
override def default: () => Int = () => 0
|
||||
override def default: () => Option[Int] = () => None
|
||||
}
|
@@ -2,7 +2,7 @@ package com.minres.tgc.hammer.options
|
||||
|
||||
import org.rogach.scallop.*
|
||||
|
||||
class ToggleOption(cliName: String, val toolName: String, descr: String, val default: () => Boolean, required: Boolean, cliShort: Char) extends BaseOption[Boolean] {
|
||||
class ToggleOption(cliName: String, val toolName: String, descr: String, val default: () => Option[Boolean], required: Boolean, cliShort: Char) extends BaseOption[Boolean] {
|
||||
|
||||
override protected def createScallop(conf: ScallopConf, group: ScallopOptionGroup): ScallopOption[Boolean] = {
|
||||
conf.toggle(name = cliName, short = cliShort, descrYes = descr, required = required, group = group)
|
||||
|
@@ -2,7 +2,7 @@ package com.minres.tgc.hammer.options
|
||||
|
||||
import org.rogach.scallop.*
|
||||
|
||||
class TrailOption[T](val toolName: String, descr: String, val default: () => T, required: Boolean)(using conv: ValueConverter[T]) extends BaseOption[T] {
|
||||
class TrailOption[T](val toolName: String, descr: String, val default: () => Option[T], required: Boolean)(using conv: ValueConverter[T]) extends BaseOption[T] {
|
||||
override protected def createScallop(conf: ScallopConf, group: ScallopOptionGroup): ScallopOption[T] = {
|
||||
conf.trailArg[T](descr = descr, required = required, group = group)
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ package com.minres.tgc.hammer.options
|
||||
|
||||
import org.rogach.scallop.*
|
||||
|
||||
class ValueOption[T](cliName: String, val toolName: String, descr: String, val default: () => T, required: Boolean, cliShort: Char)(using conv: ValueConverter[T]) extends BaseOption[T] {
|
||||
class ValueOption[T](cliName: String, val toolName: String, descr: String, val default: () => Option[T], required: Boolean, cliShort: Char)(using conv: ValueConverter[T]) extends BaseOption[T] {
|
||||
override protected def createScallop(conf: ScallopConf, group: ScallopOptionGroup): ScallopOption[T] = {
|
||||
conf.opt[T](name = cliName, short = cliShort, descr = descr, required = required, group = group)
|
||||
}
|
||||
|
@@ -10,25 +10,25 @@ class SchedulingParameters extends OptionGroup {
|
||||
override def name: String = "Longnail Scheduling Args"
|
||||
|
||||
class PrepareOptions extends CommandGroup("--prepare-schedule-lil") {
|
||||
val schedulingAlgo = choiceS(Seq("LEGACY", "MS", "PAMS", "PARAMS", "MI_MS", "MI_PAMS", "MI_PARAMS"), name = "schedulingAlgo", default = () => "LEGACY", descr =
|
||||
val schedulingAlgo = choiceS(Seq("LEGACY", "MS", "PAMS", "PARAMS", "MI_MS", "MI_PAMS", "MI_PARAMS"), name = "schedulingAlgo", default = () => Some("LEGACY"), descr =
|
||||
"Scheduling algorithm used by Longnail; Modulo Scheduling (MS) can be extended with Predicate-aware (PA) and Resource-aware (RA), Inter-Instruction sharing is activated in the MI variants")
|
||||
val cellLibrary = value[Path](cliName = "cellLibrary", toolName = "library", descr = "The cell library used by Longnail (example: longnail/test/LILToHW/longnail*.yaml", default = () => Path(""))
|
||||
val opTyLibrary = valueS[Path](name = "opTyLibrary", descr = "The operator type model used for detailed data (e.g. from OL SKY130 in longnail/opTyLibraries/OL2.yaml)", default = () => Path(""))
|
||||
val cellLibrary = value[Path](cliName = "cellLibrary", toolName = "library", descr = "The cell library used by Longnail (example: longnail/test/LILToHW/longnail*.yaml")
|
||||
val opTyLibrary = valueS[Path](name = "opTyLibrary", descr = "The operator type model used for detailed data (e.g. from OL SKY130 in longnail/opTyLibraries/OL2.yaml)")
|
||||
check(cellLibrary)(checkPathIsFile)
|
||||
check(opTyLibrary)(checkPathIsFile)
|
||||
}
|
||||
val prepare = add(new PrepareOptions)
|
||||
|
||||
class ScheduleOptions extends CommandGroup("--schedule-lil") {
|
||||
val schedulingTimeout = valueS[Int](name = "schedulingTimeout", default = () => 10, descr = "Longnail scheduling timeout in seconds")
|
||||
val schedulingRefineTimeout = value[Int](cliName = "schedulingRefineTimeout", toolName = "schedRefineTimeout", default = () => 10, descr = "Longnail schedule refinement timeout in seconds")
|
||||
val schedulingSelectionFile = value[Path](cliName = "schedulingKconf", toolName = "solSelKconfPath", default = () => OUT_DIR / "scheduling.KConfig", descr = "Path for the created KConfig file for selecting a scheduling solution")
|
||||
val ilpSolver = choice(Seq("CBC", "GLPK", "SCIP", "HIGHS", "GUROBI", "CPLEX", "XPRESS", "COPT"), cliName = "ilpSolver", toolName = "solver", default = () => "CBC", descr = "The ILP solver used by Longnail; currently only CBC is tested")
|
||||
val schedulingTimeout = valueS[Int](name = "schedulingTimeout", default = () => Some(10), descr = "Longnail scheduling timeout in seconds")
|
||||
val schedulingRefineTimeout = value[Int](cliName = "schedulingRefineTimeout", toolName = "schedRefineTimeout", default = () => Some(10), descr = "Longnail schedule refinement timeout in seconds")
|
||||
val schedulingSelectionFile = value[Path](cliName = "schedulingKconf", toolName = "solSelKconfPath", default = () => Some(OUT_DIR / "scheduling.KConfig"), descr = "Path for the created KConfig file for selecting a scheduling solution")
|
||||
val ilpSolver = choice(Seq("CBC", "GLPK", "SCIP", "HIGHS", "GUROBI", "CPLEX", "XPRESS", "COPT"), cliName = "ilpSolver", toolName = "solver", default = () => Some("CBC"), descr = "The ILP solver used by Longnail; currently only CBC is tested")
|
||||
val verboseSched = toggle(cliName = "verboseSched", toolName = "verbose", descr = "Enable verbose ILP solver messages")
|
||||
val clockPeriod = value[Int](cliName = "clockPeriod", toolName = "clockTime", descr = "The target clock period; uses same time unit as delays in opTyLibrary", default = () => 10)
|
||||
val clockPeriod = value[Int](cliName = "clockPeriod", toolName = "clockTime", descr = "The target clock period; uses same time unit as delays in opTyLibrary", default = () => Some(10))
|
||||
}
|
||||
val schedule = add(new ScheduleOptions)
|
||||
|
||||
val maxLoopUnrollFactor = value[Int](cliName = "--maxLoopUnrollFactor", toolName = "max-unroll-factor", default = () => 16, descr = "Longnail max loop unroll factor")
|
||||
val schedulingSolutionFile = value[Path](cliName = "--schedulingMLIR", toolName = "o", default = () => OUT_DIR / "scheduling_solutions.mlir", descr = "Output file with different scheduling solutions")
|
||||
val maxLoopUnrollFactor = value[Int](cliName = "--maxLoopUnrollFactor", toolName = "max-unroll-factor", default = () => Some(16), descr = "Longnail max loop unroll factor")
|
||||
val schedulingSolutionFile = value[Path](cliName = "--schedulingMLIR", toolName = "o", default = () => Some(OUT_DIR / "scheduling_solutions.mlir"), descr = "Output file with different scheduling solutions")
|
||||
}
|
||||
|
Reference in New Issue
Block a user