fix defaults
This commit is contained in:
@@ -12,7 +12,9 @@ trait BaseOption[T](using conv: ValueConverter[T]) extends ConfigElement {
|
|||||||
scallop = createScallop(scallopConf, group)
|
scallop = createScallop(scallopConf, group)
|
||||||
}
|
}
|
||||||
|
|
||||||
def get: T = scallop()
|
def default: () => T
|
||||||
|
|
||||||
|
def get: T = scallop.getOrElse(default())
|
||||||
def apply(): T = get
|
def apply(): T = get
|
||||||
|
|
||||||
def getToolParameters: Seq[Shellable] = if (scallop.isDefined) Seq(s"$toolName", getToolArg) else Seq()
|
def getToolParameters: Seq[Shellable] = if (scallop.isDefined) Seq(s"$toolName", getToolArg) else Seq()
|
||||||
|
@@ -5,8 +5,8 @@ import org.rogach.scallop.*
|
|||||||
enum Color:
|
enum Color:
|
||||||
case Red, Green, Blue
|
case Red, Green, Blue
|
||||||
|
|
||||||
class ChoiceOption(choices: Seq[String], cliName: String, val toolName: String, descr: String, default: () => Option[String], required: Boolean, cliShort: Char) extends BaseOption[String] {
|
class ChoiceOption(choices: Seq[String], cliName: String, val toolName: String, descr: String, val default: () => String, required: Boolean, cliShort: Char) extends BaseOption[String] {
|
||||||
override protected def createScallop(conf: ScallopConf, group: ScallopOptionGroup): ScallopOption[String] = {
|
override protected def createScallop(conf: ScallopConf, group: ScallopOptionGroup): ScallopOption[String] = {
|
||||||
conf.choice(choices, name = cliName, short = cliShort, descr = descr, default = default(), required = required, group = group)
|
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: () => Option[T] = () => None, required: Boolean = false, cliShort: Char = '\u0000')(using conv: ValueConverter[T]): ValueOption[T] = add(ValueOption(cliName, toolName, descr, default, required, cliShort))
|
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: () => Option[T] = () => None, required: Boolean = false, cliShort: Char = '\u0000')(using conv: ValueConverter[T]): ValueOption[T] = add(ValueOption(name, name, 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 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 trail[T](toolName: String, descr: String = "", default: () => T, 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: () => Option[String] = () => None, required: Boolean = false, cliShort: Char = '\u0000'): ChoiceOption = add(ChoiceOption(choices, cliName, toolName, descr, default, required, cliShort))
|
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: () => Option[String] = () => None, required: Boolean = false, cliShort: Char = '\u0000'): ChoiceOption = add(ChoiceOption(choices, name, name, 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 tally(cliName: String, toolName: String, descr: String = "", required: Boolean = false, cliShort: Char = '\u0000'): TallyOption = add(TallyOption(cliName, toolName, descr, 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 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: () => Option[Boolean] = () => None, required: Boolean = false, cliShort: Char = '\u0000'): ToggleOption = add(ToggleOption(cliName, toolName, descr, default, 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: () => Option[Boolean] = () => None, required: Boolean = false, cliShort: Char = '\u0000'): ToggleOption = add(ToggleOption(name, name, 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))
|
||||||
}
|
}
|
||||||
|
|
||||||
trait OptionGroup extends BaseGroup {
|
trait OptionGroup extends BaseGroup {
|
||||||
|
@@ -6,4 +6,6 @@ class TallyOption(cliName: String, val toolName: String, descr: String, required
|
|||||||
override protected def createScallop(conf: ScallopConf, group: ScallopOptionGroup): ScallopOption[Int] = {
|
override protected def createScallop(conf: ScallopConf, group: ScallopOptionGroup): ScallopOption[Int] = {
|
||||||
conf.tally(name = cliName, short = cliShort, descr = descr, group = group)
|
conf.tally(name = cliName, short = cliShort, descr = descr, group = group)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override def default: () => Int = () => 0
|
||||||
}
|
}
|
@@ -2,9 +2,9 @@ package com.minres.tgc.hammer.options
|
|||||||
|
|
||||||
import org.rogach.scallop.*
|
import org.rogach.scallop.*
|
||||||
|
|
||||||
class ToggleOption(cliName: String, val toolName: String, descr: String, default: () => Option[Boolean], required: Boolean, cliShort: Char) extends BaseOption[Boolean] {
|
class ToggleOption(cliName: String, val toolName: String, descr: String, val default: () => Boolean, required: Boolean, cliShort: Char) extends BaseOption[Boolean] {
|
||||||
|
|
||||||
override protected def createScallop(conf: ScallopConf, group: ScallopOptionGroup): ScallopOption[Boolean] = {
|
override protected def createScallop(conf: ScallopConf, group: ScallopOptionGroup): ScallopOption[Boolean] = {
|
||||||
conf.toggle(name = cliName, short = cliShort, descrYes = descr, default = default(), required = required, group = group)
|
conf.toggle(name = cliName, short = cliShort, descrYes = descr, required = required, group = group)
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -2,8 +2,8 @@ package com.minres.tgc.hammer.options
|
|||||||
|
|
||||||
import org.rogach.scallop.*
|
import org.rogach.scallop.*
|
||||||
|
|
||||||
class TrailOption[T](val toolName: String, descr: String, default: () => Option[T], required: Boolean)(using conv: ValueConverter[T]) extends BaseOption[T] {
|
class TrailOption[T](val toolName: String, descr: String, val default: () => T, required: Boolean)(using conv: ValueConverter[T]) extends BaseOption[T] {
|
||||||
override protected def createScallop(conf: ScallopConf, group: ScallopOptionGroup): ScallopOption[T] = {
|
override protected def createScallop(conf: ScallopConf, group: ScallopOptionGroup): ScallopOption[T] = {
|
||||||
conf.trailArg[T](descr = descr, default = default(), required = required, group = group)
|
conf.trailArg[T](descr = descr, required = required, group = group)
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -2,8 +2,8 @@ package com.minres.tgc.hammer.options
|
|||||||
|
|
||||||
import org.rogach.scallop.*
|
import org.rogach.scallop.*
|
||||||
|
|
||||||
class ValueOption[T](cliName: String, val toolName: String, descr: String, default: () => Option[T], required: Boolean, cliShort: Char)(using conv: ValueConverter[T]) extends BaseOption[T] {
|
class ValueOption[T](cliName: String, val toolName: String, descr: String, val default: () => T, required: Boolean, cliShort: Char)(using conv: ValueConverter[T]) extends BaseOption[T] {
|
||||||
override protected def createScallop(conf: ScallopConf, group: ScallopOptionGroup): ScallopOption[T] = {
|
override protected def createScallop(conf: ScallopConf, group: ScallopOptionGroup): ScallopOption[T] = {
|
||||||
conf.opt[T](name = cliName, short = cliShort, descr = descr, default = default(), required = required, group = group)
|
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"
|
override def name: String = "Longnail Scheduling Args"
|
||||||
|
|
||||||
class PrepareOptions extends CommandGroup("--prepare-schedule-lil") {
|
class PrepareOptions extends CommandGroup("--prepare-schedule-lil") {
|
||||||
val schedulingAlgo = choiceS(Seq("LEGACY", "MS", "PAMS", "PARAMS", "MI_MS", "MI_PAMS", "MI_PARAMS"), name = "schedulingAlgo", default = () => Some("LEGACY"), descr =
|
val schedulingAlgo = choiceS(Seq("LEGACY", "MS", "PAMS", "PARAMS", "MI_MS", "MI_PAMS", "MI_PARAMS"), name = "schedulingAlgo", default = () => "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")
|
"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")
|
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)")
|
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(""))
|
||||||
check(cellLibrary)(checkPathIsFile)
|
check(cellLibrary)(checkPathIsFile)
|
||||||
check(opTyLibrary)(checkPathIsFile)
|
check(opTyLibrary)(checkPathIsFile)
|
||||||
}
|
}
|
||||||
val prepare = add(new PrepareOptions)
|
val prepare = add(new PrepareOptions)
|
||||||
|
|
||||||
class ScheduleOptions extends CommandGroup("--schedule-lil") {
|
class ScheduleOptions extends CommandGroup("--schedule-lil") {
|
||||||
val schedulingTimeout = valueS[Int](name = "schedulingTimeout", default = () => Some(10), descr = "Longnail scheduling timeout in seconds")
|
val schedulingTimeout = valueS[Int](name = "schedulingTimeout", default = () => 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 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 = () => Some(OUT_DIR / "scheduling.KConfig"), descr = "Path for the created KConfig file for selecting a scheduling solution")
|
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 = () => Some("CBC"), descr = "The ILP solver used by Longnail; currently only CBC is tested")
|
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 verboseSched = toggle(cliName = "verboseSched", toolName = "verbose", descr = "Enable verbose ILP solver messages")
|
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")
|
val clockPeriod = value[Int](cliName = "clockPeriod", toolName = "clockTime", descr = "The target clock period; uses same time unit as delays in opTyLibrary", default = () => 10)
|
||||||
}
|
}
|
||||||
val schedule = add(new ScheduleOptions)
|
val schedule = add(new ScheduleOptions)
|
||||||
|
|
||||||
val maxLoopUnrollFactor = value[Int](cliName = "--maxLoopUnrollFactor", toolName = "max-unroll-factor", default = () => Some(16), descr = "Longnail max loop unroll factor")
|
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 = () => Some(OUT_DIR / "scheduling_solutions.mlir"), descr = "Output file with different scheduling solutions")
|
val schedulingSolutionFile = value[Path](cliName = "--schedulingMLIR", toolName = "o", default = () => OUT_DIR / "scheduling_solutions.mlir", descr = "Output file with different scheduling solutions")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user