PrettyPrinter.scala 4.19 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    PrettyPrinter.scala
 * @brief   Implements pretty printing for Description subclasses.
 * @authors J. Korinth, TU Darmstadt (jk@esa.cs.tu-darmstadt.de)
 **/
24
package de.tu_darmstadt.cs.esa.tapasco.base
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import  scala.util.Properties.{lineSeparator => NL}

private object PrettyPrinter {
  def printArchitecture(a: Architecture): String = List(
      "[Architecture @" + a.descPath + "]",
      "Name = " + a.name,
      "TclLibrary = " + a.tclLibrary,
      "Description = " + a.description,
      "valueArgTemplate = " + a.valueArgTemplate,
      "referenceArgTemplate = " + a.referenceArgTemplate,
      "additionalSteps = " + a.additionalSteps.mkString(" ")
    ) mkString NL

  def printPlatform(p: Platform): String = List(
      "[Platform @" + p.descPath + "]",
      "Name = " + p.name,
      "Description = " + p.description,
      "TclLibrary = " + p.tclLibrary,
      "Part = " + p.part,
      "BoardPart = " + p.boardPart,
      "BoardPreset = " + p.boardPreset,
      "TargetUtilization = " + p.targetUtilization + "%",
47
48
49
      "SlotCount = " + p.slotCount,
      "HostFrequency = " + p.hostFrequency,
      "MemFrequency = " + p.memFrequency
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
    ) mkString NL

  def printKernelArg(ka: Kernel.Argument): String = ka.name + " " + ka.passingConvention

  def printKernel(k: Kernel): String = List(
      "[Kernel @" + k.descPath + "]",
      "Name = " + k.name,
      "TopFunction = " + k.topFunction,
      "Version = " + k.version,
      "Files = " + k.files.mkString(" "),
      "TestbenchFiles = " + k.testbenchFiles.mkString(" "),
      "CompilerFlags = " + k.compilerFlags.mkString(" "),
      "TestbenchCompilerFlags = " + k.testbenchCompilerFlags.mkString(" "),
      "Args = " + k.args.map(printKernelArg).mkString(" "),
      "OtherDirectives = " + k.otherDirectives
    ) mkString NL

  def printCompositionEntry(ce: Composition.Entry): String =
    List(ce.kernel, " x ", ce.count) mkString NL

  def printComposition(c: Composition): String = List(
      "[Composition @ " + c.id + "]",
      "Description = " + c.description,
      "Composition = " + (c.composition map { ce => ce.kernel + " x " + ce.count } mkString ", ")
    ) mkString NL

  def printConfiguration(c: Configuration): String = List(
      "[Configuration @" + c.descPath + "]",
      "KernelDir = " + c.kernelDir,
      "CoreDir = " + c.coreDir,
      "ArchDir = " + c.archDir,
      "PlatformDir = " + c.platformDir,
      "Slurm = " + c.slurm,
Jens Korinth's avatar
Jens Korinth committed
83
      "Parallel = " + c.parallel,
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
      "Jobs = " + c.jobs
    ) mkString NL

  def printCore(c: Core): String = List(
    "[Core @" + c.zipPath + "]",
    "Name = " + c.name,
    "ID = " + c.id,
    "Version = " + c.version,
    "Target = " + c.target,
    "Description = " + c.description,
    "Avg.CC = " + c.averageClockCycles
  ) mkString NL

  def printBenchmark(b: Benchmark): String = Seq(
    "[Benchmark @" + b.descPath.toString + "]",
    "Timestamp = " + b.timestamp.toString,
    "Host = " + b.host.toString,
    "LibVersions = " + b.libraryVersions.toString,
    "TransferSpeed = " + b.transferSpeed.toString,
    "IRQ latency = " + b.interruptLatency.toString
  ) mkString NL

  def print(d: Description): String = d match {
    case a: Architecture => printArchitecture(a)
    case p: Platform => printPlatform(p)
    case k: Kernel => printKernel(k)
    case c: Composition => printComposition(c)
    case c: Configuration => printConfiguration(c)
    case c: Core => printCore(c)
    case b: Benchmark => printBenchmark(b)
    case _ => "Unknown description"
  }
}