Configuration.scala 3.17 KB
Newer Older
1
2
3
//
// Copyright (C) 2014 Jens Korinth, TU Darmstadt
//
4
// This file is part of Tapasco (TPC).
5
//
6
// Tapasco is free software: you can redistribute it and/or modify
7
8
9
10
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
11
// Tapasco is distributed in the hope that it will be useful,
12
13
14
15
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
17
// along with Tapasco.  If not, see <http://www.gnu.org/licenses/>.
18
19
20
21
22
23
//
/**
 * @file    Configuration.scala
 * @brief   Model: TPC Configuration.
 * @authors J. Korinth, TU Darmstadt (jk@esa.cs.tu-darmstadt.de)
 **/
24
package de.tu_darmstadt.cs.esa.tapasco.base
25
import  de.tu_darmstadt.cs.esa.tapasco.dse._
26
import  de.tu_darmstadt.cs.esa.tapasco.jobs._
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import  java.nio.file._
import  builder._

trait Configuration {
  def descPath: Path
  def descPath(p: Path): Configuration
  def archDir: Path
  def archDir(p: Path): Configuration
  def platformDir: Path
  def platformDir(p: Path): Configuration
  def kernelDir: Path
  def kernelDir(p: Path): Configuration
  def coreDir: Path
  def coreDir(p: Path): Configuration
  def compositionDir: Path
  def compositionDir(p: Path): Configuration
  def jobs: Seq[Job]
  def jobs(js: Seq[Job]): Configuration
  def logFile: Option[Path]
  def logFile(p: Option[Path]): Configuration
  def slurm: Boolean
  def slurm(enabled: Boolean): Configuration
Jens Korinth's avatar
Jens Korinth committed
49
50
  def parallel: Boolean
  def parallel(enabled: Boolean): Configuration
51

52
  /** Returns the default output directory for the given kernel and target. */
53
54
  def outputDir(kernel: Kernel, target: Target): Path =
    coreDir.resolve(kernel.name.toString).resolve(target.ad.name).resolve(target.pd.name)
55
56

  /** Returns the default output directory for the given composition, target and frequency.
57
   *  _Example_: `arrayinit__counter/020_042/075.0/axi4mm/pynq`
58
   */
59
60
  def outputDir(composition: Composition, target: Target, freq: Heuristics.Frequency,
                features: Seq[Feature] = Seq()): Path = compositionDir
61
62
    .resolve(target.ad.name)
    .resolve(target.pd.name)
63
64
    .resolve(composition.composition map (_.kernel.replaceAll(" ", "_")) mkString "__")
    .resolve(composition.composition map (ce => "%03d".format(ce.count)) mkString "_")
65
    .resolve("%05.1f%s".format(freq, (features filter (_.enabled) map ("+" + _.shortName)).sorted mkString ""))
66
67

  /** Returns the default output directory for the given core and target. */
68
69
  def outputDir(core: Core, target: Target): Path =
    coreDir.resolve(core.name.toString).resolve(target.ad.name).resolve(target.pd.name)
70
71

  /** Returns the default output directory for the given core/kernel name and target. */
72
73
74
75
76
77
78
79
  def outputDir(name: String, target: Target): Path =
    coreDir.resolve(name).resolve(target.ad.name).resolve(target.pd.name)
}

object Configuration extends Builds[Configuration] {
  /** Return default implementation for [[Configuration]]. */
  def apply(): Configuration = ConfigurationImpl()
}