Commit d0169b2d authored by Jens Korinth's avatar Jens Korinth
Browse files

Closes #52 - Import: Check re-run condition for task

* missing report now correctly triggers re-evaluation of the core
* moved core.description file into 'ipcore' subdirectory
* fixed problem with relative paths for import file
parent ddd478c7
...@@ -58,53 +58,52 @@ object Import { ...@@ -58,53 +58,52 @@ object Import {
// extract version and name from VLNV, create Core // extract version and name from VLNV, create Core
val c = Core( val c = Core(
descPath = zip.resolveSibling("core.description"), descPath = zip.resolveSibling("core.description"),
_zipPath = zip, _zipPath = zip.getFileName,
name = vlnv.name, name = vlnv.name,
id = id, id = id,
version = vlnv.version.toString, version = vlnv.version.toString,
_target = t, _target = t,
Some("imported from %s on %s".format(zip.toString, java.time.LocalDateTime.now().toString)), Some("imported from %s on %s".format(zip.toAbsolutePath.toString, java.time.LocalDateTime.now().toString)),
acc) acc)
// write core.description to output directory (as per config) // write core.description to output directory (as per config)
val p = cfg.outputDir(c, t).resolve("core.description") val p = cfg.outputDir(c, t).resolve("ipcore").resolve("core.description")
if (! p.toFile.exists) { importCore(c, t, p)
importCore(zip, c, t, p)
} else {
logger.info("core already exists in {}, skipping", p)
true
}
} }
/** /**
* Imports the IP-XACT .zip to the default path structure (ipcore/) and performs * Imports the IP-XACT .zip to the default path structure (ipcore/) and performs
* out-of-context synthesis (if no report from HLS was found). * out-of-context synthesis (if no report from HLS was found).
* @param zip Path to IP-XACT .zip.
* @param c Core description. * @param c Core description.
* @param t Target platform and architecture. * @param t Target platform and architecture.
* @param p Output path for core description file. * @param p Output path for core description file.
* @param cfg Implicit [[Configuration]]. * @param cfg Implicit [[Configuration]].
**/ **/
private def importCore(zip: Path, c: Core, t: Target, p: Path)(implicit cfg: Configuration): Boolean = { private def importCore(c: Core, t: Target, p: Path)(implicit cfg: Configuration): Boolean = {
Files.createDirectories(p.getParent) Files.createDirectories(p.getParent)
logger.trace("created directories: {}", p.getParent.toString) logger.trace("created output directories: {}", p.getParent.toString)
// add link to original .zip in the 'ipcore' subdir // add link to original .zip in the 'ipcore' subdir
val linkp = cfg.outputDir(c, t).resolve("ipcore").resolve(c.zipPath.toString) val linkp = cfg.outputDir(c, t).resolve("ipcore").resolve(c.zipPath.getFileName.toString)
if (! linkp.toFile.equals(zip.toAbsolutePath.toFile)) { if (! linkp.toFile.equals(c.zipPath.toAbsolutePath.toFile)) {
Files.createDirectories(linkp.getParent) Files.createDirectories(linkp.getParent)
logger.trace("created directories: {}", linkp.getParent.toString) logger.trace("created directories: {}", linkp.getParent.toString)
if (linkp.toFile.exists) linkp.toFile.delete() if (linkp.toFile.exists) {
try { logger.debug("file {} already exists, skipping copy/link step")
java.nio.file.Files.createSymbolicLink(linkp, zip.toAbsolutePath) } else {
} catch { case ex: java.nio.file.FileSystemException => { logger.trace("creating symbolic link {} -> {}", linkp: Any, c.zipPath.toAbsolutePath)
logger.warn("cannot create link " + linkp + " -> " + zip + ", copying data") try { java.nio.file.Files.createSymbolicLink(linkp, c.zipPath.toAbsolutePath) }
java.nio.file.Files.copy(zip, linkp, java.nio.file.StandardCopyOption.REPLACE_EXISTING) catch { case ex: java.nio.file.FileSystemException => {
}} logger.warn("cannot create link {} -> {}, copying data", linkp: Any, c.zipPath)
java.nio.file.Files.copy(c.zipPath, linkp, java.nio.file.StandardCopyOption.REPLACE_EXISTING)
}}
}
} else {
logger.debug("{} is the same as {}, no copy/link required", linkp: Any, c.zipPath.toAbsolutePath)
} }
// finally, evaluate the ip core and store the report with the link // finally, evaluate the ip core and store the report with the link
val res = evaluateCore(zip, c, t) val res = evaluateCore(c, t)
// write core.description // write core.description
logger.debug("writing core description: {}", p.toString) logger.debug("writing core description: {}", p.toString)
...@@ -115,12 +114,11 @@ object Import { ...@@ -115,12 +114,11 @@ object Import {
/** /**
* Searches for an existing synthesis report, otherwise performs out-of-context synthesis and * Searches for an existing synthesis report, otherwise performs out-of-context synthesis and
* place-and-route to produce area and Fmax estimates * place-and-route to produce area and Fmax estimates
* @param zip Path to IP-XACT .zip.
* @param c Core description. * @param c Core description.
* @param t Target Architecture + Platform combination. * @param t Target Architecture + Platform combination.
* @param cfg Implicit [[Configuration]]. * @param cfg Implicit [[Configuration]].
**/ **/
private def evaluateCore(zip: Path, c: Core, t: Target)(implicit cfg: Configuration): Boolean = { private def evaluateCore(c: Core, t: Target)(implicit cfg: Configuration): Boolean = {
logger.trace("looking for SynthesisReport ...") logger.trace("looking for SynthesisReport ...")
val period = 1000.0 / t.pd.supportedFrequencies.sortWith(_>_).head val period = 1000.0 / t.pd.supportedFrequencies.sortWith(_>_).head
val report = cfg.outputDir(c, t).resolve("ipcore").resolve("%s_export.xml".format(c.name)) val report = cfg.outputDir(c, t).resolve("ipcore").resolve("%s_export.xml".format(c.name))
...@@ -132,7 +130,7 @@ object Import { ...@@ -132,7 +130,7 @@ object Import {
true true
} getOrElse { } getOrElse {
logger.info("SynthesisReport for {} not found, starting evaluation ...", c.name) logger.info("SynthesisReport for {} not found, starting evaluation ...", c.name)
EvaluateIP(zip, period, t.pd.part, report) EvaluateIP(c.zipPath, period, t.pd.part, report)
} }
} }
} }
...@@ -36,7 +36,7 @@ case class Core ( ...@@ -36,7 +36,7 @@ case class Core (
description: Option[String], description: Option[String],
averageClockCycles: Option[Int] averageClockCycles: Option[Int]
) extends Description(descPath) { ) extends Description(descPath) {
val zipPath: Path = resolve(_zipPath) val zipPath: Path = resolve(_zipPath).toAbsolutePath
require(mustExist(zipPath), "zip file %s does not exist".format(zipPath.toString)) require(mustExist(zipPath), "zip file %s does not exist".format(zipPath.toString))
lazy val target: Target = _target lazy val target: Target = _target
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment