Handle tool output
This commit is contained in:
@@ -11,5 +11,6 @@ object Global {
|
|||||||
lazy val BASE_DIR: Path = os.pwd
|
lazy val BASE_DIR: Path = os.pwd
|
||||||
def OUT_DIR: Path = Main.conf.outputDirectory()
|
def OUT_DIR: Path = Main.conf.outputDirectory()
|
||||||
def TMP_DIR: Path = OUT_DIR / "tmp"
|
def TMP_DIR: Path = OUT_DIR / "tmp"
|
||||||
|
def LOG_DIR: Path = OUT_DIR / "logs"
|
||||||
lazy val CORE_DATASHEETS: Path = HAMMER / "coreDatasheets"
|
lazy val CORE_DATASHEETS: Path = HAMMER / "coreDatasheets"
|
||||||
}
|
}
|
||||||
|
@@ -25,6 +25,7 @@ object Main {
|
|||||||
logger.trace(s"Creating output directory ${Global.OUT_DIR}")
|
logger.trace(s"Creating output directory ${Global.OUT_DIR}")
|
||||||
if (conf.emptyOutputDir()) os.remove.all(Global.OUT_DIR)
|
if (conf.emptyOutputDir()) os.remove.all(Global.OUT_DIR)
|
||||||
os.makeDir.all(Global.OUT_DIR)
|
os.makeDir.all(Global.OUT_DIR)
|
||||||
|
os.makeDir.all(Global.LOG_DIR)
|
||||||
logger.trace(s"Creating temp directory ${Global.TMP_DIR}")
|
logger.trace(s"Creating temp directory ${Global.TMP_DIR}")
|
||||||
os.makeDir.all(Global.TMP_DIR)
|
os.makeDir.all(Global.TMP_DIR)
|
||||||
conf.subcommand match {
|
conf.subcommand match {
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.minres.tgc.hammer.cli
|
package com.minres.tgc.hammer.cli
|
||||||
|
|
||||||
|
import com.minres.tgc.hammer.Global.LOG_DIR
|
||||||
import org.rogach.scallop.*
|
import org.rogach.scallop.*
|
||||||
import os.Path
|
import os.Path
|
||||||
import com.minres.tgc.hammer.util.FileUtils.*
|
import com.minres.tgc.hammer.util.FileUtils.*
|
||||||
@@ -8,6 +9,7 @@ class HammerConf(arguments: Seq[String]) extends ScallopConf(arguments) {
|
|||||||
val outputDirectory: ScallopOption[Path] = opt[Path](default = Some("output".path()), descr = "The base output directory")
|
val outputDirectory: ScallopOption[Path] = opt[Path](default = Some("output".path()), descr = "The base output directory")
|
||||||
val verbose: ScallopOption[Int] = tally(short = 'v', descr = "Controls the logging of tgc-hammer itself, using it multiple times (-vv) will print more. (0x => WARN, 1x => INFO, 2x => DEBUG, 3x => TRACE)")
|
val verbose: ScallopOption[Int] = tally(short = 'v', descr = "Controls the logging of tgc-hammer itself, using it multiple times (-vv) will print more. (0x => WARN, 1x => INFO, 2x => DEBUG, 3x => TRACE)")
|
||||||
val emptyOutputDir: ScallopOption[Boolean] = toggle(default = Some(true), descrYes = "Whether to empty the output directory at the start; defaults to true")
|
val emptyOutputDir: ScallopOption[Boolean] = toggle(default = Some(true), descrYes = "Whether to empty the output directory at the start; defaults to true")
|
||||||
|
val printToolOutput: ScallopOption[Boolean] = toggle(descrYes = s"Whether to directly print all output of the underlying tools to the terminal. Otherwise the output will be written to files in $LOG_DIR")
|
||||||
addSubcommand(new LongnailCommand)
|
addSubcommand(new LongnailCommand)
|
||||||
addSubcommand(new TreenailCommand)
|
addSubcommand(new TreenailCommand)
|
||||||
addSubcommand(new LongnailMergeCommand)
|
addSubcommand(new LongnailMergeCommand)
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.minres.tgc.hammer.tasks
|
package com.minres.tgc.hammer.tasks
|
||||||
|
|
||||||
|
import com.minres.tgc.hammer.Main
|
||||||
import com.minres.tgc.hammer.util.Logging
|
import com.minres.tgc.hammer.util.Logging
|
||||||
import os.{Path, Shellable}
|
import os.{Path, Shellable}
|
||||||
|
|
||||||
@@ -17,10 +18,14 @@ trait Task {
|
|||||||
|
|
||||||
trait TaskImpl[T <: Task : ClassTag] extends Task with Logging[T] {
|
trait TaskImpl[T <: Task : ClassTag] extends Task with Logging[T] {
|
||||||
|
|
||||||
def runExecutable(execPath: Path, args: Shellable*): os.CommandResult = {
|
def runExecutable(execPath: Path, args: Shellable*)(logFile: os.Path): os.CommandResult = {
|
||||||
val command = s"$execPath ${args.flatMap(_.value).mkString(" ")}"
|
val command = s"$execPath ${args.flatMap(_.value).mkString(" ")}"
|
||||||
log.info(s"Running external program: ")
|
log.info(s"Running external program: ")
|
||||||
log.info(command)
|
log.info(command)
|
||||||
os.proc("bash", "-c", command).call(stdout = os.Inherit)
|
val output: os.ProcessOutput = if (Main.conf.printToolOutput())
|
||||||
|
os.Inherit
|
||||||
|
else
|
||||||
|
logFile
|
||||||
|
os.proc("bash", "-c", command).call(stdout = output)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,17 +1,17 @@
|
|||||||
package com.minres.tgc.hammer.tasks
|
package com.minres.tgc.hammer.tasks
|
||||||
|
|
||||||
import com.minres.tgc.hammer.Global
|
import com.minres.tgc.hammer.Global.*
|
||||||
import com.minres.tgc.hammer.util.FileUtils.*
|
import com.minres.tgc.hammer.util.FileUtils.*
|
||||||
import os.*
|
import os.*
|
||||||
|
|
||||||
case class TreenailTask(coreDSLInput: Path, output: Path) extends TaskImpl[TreenailTask] {
|
case class TreenailTask(coreDSLInput: Path, output: Path) extends TaskImpl[TreenailTask] {
|
||||||
private val EXECUTABLE = Global.TREENAIL / "app" / "build" / "install" / "app" / "bin" / "app"
|
private val EXECUTABLE = TREENAIL / "app" / "build" / "install" / "app" / "bin" / "app"
|
||||||
|
|
||||||
override def validate(): Unit = {
|
override def validate(): Unit = {
|
||||||
assert(isFile(EXECUTABLE), "Treenail Executable is missing, build Treenail")
|
assert(isFile(EXECUTABLE), "Treenail Executable is missing, build Treenail")
|
||||||
assert(isCoreDSLFile(coreDSLInput), "Input file does not exist")
|
assert(isCoreDSLFile(coreDSLInput), "Input file does not exist")
|
||||||
}
|
}
|
||||||
override def execute(): Unit = {
|
override def execute(): Unit = {
|
||||||
runExecutable(EXECUTABLE, "-o", output, coreDSLInput)
|
runExecutable(EXECUTABLE, "-o", output, coreDSLInput)(LOG_DIR / "treenail.log")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.minres.tgc.hammer.tasks.longnail
|
package com.minres.tgc.hammer.tasks.longnail
|
||||||
|
|
||||||
|
import com.minres.tgc.hammer.Global.LOG_DIR
|
||||||
import com.minres.tgc.hammer.util.FileUtils.*
|
import com.minres.tgc.hammer.util.FileUtils.*
|
||||||
import os.*
|
import os.*
|
||||||
|
|
||||||
@@ -27,6 +28,6 @@ class LongnailHLSTask(schedulingSolutionFile: Path, schedulingSelectionFile: Opt
|
|||||||
"--hw-legalize-modules",
|
"--hw-legalize-modules",
|
||||||
s"--export-split-verilog=dir-name=$outDirectory",
|
s"--export-split-verilog=dir-name=$outDirectory",
|
||||||
schedulingSolutionFile
|
schedulingSolutionFile
|
||||||
)
|
)(LOG_DIR / "longnail_hls.log")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.minres.tgc.hammer.tasks.longnail
|
package com.minres.tgc.hammer.tasks.longnail
|
||||||
|
|
||||||
|
import com.minres.tgc.hammer.Global.LOG_DIR
|
||||||
import com.minres.tgc.hammer.util.FileUtils.*
|
import com.minres.tgc.hammer.util.FileUtils.*
|
||||||
import os.*
|
import os.*
|
||||||
|
|
||||||
@@ -17,6 +18,6 @@ class LongnailMergeTask(mlirFiles: Seq[Path], concatMLIR: Path, mergedMLIR: Path
|
|||||||
runExecutable(EXECUTABLE,
|
runExecutable(EXECUTABLE,
|
||||||
"--merge-multiple-isaxes", concatMLIR,
|
"--merge-multiple-isaxes", concatMLIR,
|
||||||
"-o", mergedMLIR
|
"-o", mergedMLIR
|
||||||
)
|
)(LOG_DIR / "longnail_merge.log")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.minres.tgc.hammer.tasks.longnail
|
package com.minres.tgc.hammer.tasks.longnail
|
||||||
|
|
||||||
|
import com.minres.tgc.hammer.Global.LOG_DIR
|
||||||
import com.minres.tgc.hammer.tasks.longnail.LongnailBaseTask
|
import com.minres.tgc.hammer.tasks.longnail.LongnailBaseTask
|
||||||
import com.minres.tgc.hammer.util.FileUtils.isMLIRFile
|
import com.minres.tgc.hammer.util.FileUtils.isMLIRFile
|
||||||
import os.*
|
import os.*
|
||||||
@@ -17,7 +18,7 @@ class LongnailScheduleTask(isaxMLIR: Path, coreDatasheet: Path, params: Scheduli
|
|||||||
"--lower-coredsl-to-lil",
|
"--lower-coredsl-to-lil",
|
||||||
params.getToolParameters,
|
params.getToolParameters,
|
||||||
isaxMLIR
|
isaxMLIR
|
||||||
)
|
)(LOG_DIR / "longnail_schedule.log")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user