OpenASIP  2.0
Functions | Variables
EstimatorCmdLineUI.cc File Reference
#include <iostream>
#include <cmath>
#include "EstimatorCmdLineOptions.hh"
#include "Machine.hh"
#include "ADFSerializer.hh"
#include "MachineImplementation.hh"
#include "IDFSerializer.hh"
#include "Program.hh"
#include "NullProgram.hh"
#include "Binary.hh"
#include "FileSystem.hh"
#include "BinaryStream.hh"
#include "BinaryReader.hh"
#include "TPEFProgramFactory.hh"
#include "ExecutionTrace.hh"
#include "Estimator.hh"
Include dependency graph for EstimatorCmdLineUI.cc:

Go to the source code of this file.

Functions

bool loadInputs (EstimatorCmdLineOptions &options)
 
void cleanup ()
 
int main (int argc, char *argv[])
 

Variables

bool energyEstimation = false
 this is set to true in case energy estimation can be performed with the given input files More...
 
TTAMachine::Machinemachine = NULL
 the architecture definition of the estimated processor More...
 
IDF::MachineImplementationimplementation = NULL
 the implementation definition of the estimated processor More...
 
TTAProgram::Programprogram = NULL
 the estimated program is stored in this variable (in case energy estimation is wanted More...
 
ExecutionTracetrace = NULL
 the execution trace database More...
 

Detailed Description

Implementation of estimate.

The command line user interface of cost estimator.

Author
Pekka Jääskeläinen 2005 (pjaaskel-no.spam-cs.tut.fi)
Note
rating: red

Definition in file EstimatorCmdLineUI.cc.

Function Documentation

◆ cleanup()

void cleanup ( )

Frees all allocated input resources.

Definition at line 179 of file EstimatorCmdLineUI.cc.

179  {
180 
181  delete machine;
182  machine = NULL;
183  delete implementation;
184  implementation = NULL;
185 
186  if (energyEstimation) {
187  delete program;
188  program = NULL;
189  delete trace;
190  trace = NULL;
191  }
192 }

References energyEstimation, implementation, machine, program, and trace.

Referenced by main().

◆ loadInputs()

bool loadInputs ( EstimatorCmdLineOptions options)

Loads the input files using the command line arguments.

Parameters
optionsThe command line arguments.
Returns
True in case there was no errors in the arguments.

Definition at line 75 of file EstimatorCmdLineUI.cc.

75  {
76 
77  if (options.numberOfArguments() < 2) {
78  std::cerr << "ADF and IDF are required." << std::endl;
79  return false;
80  }
81  else if (options.numberOfArguments() > 2) {
82  std::cerr << "Illegal command line arguments." << std::endl;
83  return false;
84  }
85 
86  std::string adfFile = options.argument(1);
87  std::string idfFile = options.argument(2);
88 
89  try {
90  ADFSerializer serializer;
91  serializer.setSourceFile(adfFile);
92  machine = serializer.readMachine();
93  } catch (const Exception& e) {
94  std::cerr << "Error while loading ADF. " << e.errorMessage()
95  << std::endl;
96  return false;
97  }
98 
99  try {
100  IDF::IDFSerializer serializer;
101  serializer.setSourceFile(idfFile);
103  } catch (const Exception& e) {
104  std::cerr << "Error while loading IDF. " << e.errorMessage()
105  << std::endl;
106  return false;
107  }
108 
109  if (options.TPEF() != "") {
110 
111  if (options.traceDB() == "") {
112  std::cerr << "Also TraceDB is required for energy estimation."
113  << std::endl;
114  return false;
115  }
116 
117  TPEF::Binary* tpef = NULL;
118  try {
119  const std::string tpefFileName = options.TPEF();
120  if (!FileSystem::fileExists(tpefFileName)) {
121  std::cerr << "Error while loading TPEF. "
122  << "Cannot open file '" << tpefFileName << "'."
123  << std::endl;
124  delete machine;
125  machine = NULL;
126  delete implementation;
127  implementation = NULL;
128  return EXIT_FAILURE;
129  }
130  TPEF::BinaryStream binaryStream(tpefFileName);
131 
132  // read first to a TPEF Handler Module
133  tpef = TPEF::BinaryReader::readBinary(binaryStream);
134 
135  assert(tpef != NULL);
136  assert(machine != NULL);
137 
138  // convert the loaded TPEF to POM
139  TTAProgram::TPEFProgramFactory factory(*tpef, *machine);
140  program = factory.build();
141  delete tpef;
142  tpef = NULL;
143  } catch (const Exception& e) {
144  std::cerr << "Error while loading TPEF. " << e.errorMessage()
145  << std::endl;
146  delete tpef;
147  tpef = NULL;
148  return false;
149  }
150  }
151 
152  if (options.traceDB() != "") {
153 
154  const std::string traceDBFileName = options.traceDB();
155  if (!FileSystem::fileExists(traceDBFileName)) {
156  std::cerr << "Error while loading TraceDB. "
157  << "Cannot open file '" << traceDBFileName << "'."
158  << std::endl;
159  return false;
160  }
161 
162  try {
163  trace = ExecutionTrace::open(traceDBFileName);
164  } catch (const Exception& e) {
165  std::cerr << "Error while loading TraceDB. " << e.errorMessage()
166  << std::endl;
167  return false;
168  }
169  if (program == NULL)
171  energyEstimation = true;
172  }
173  return true;
174 }

References CmdLineParser::argument(), assert, TTAProgram::TPEFProgramFactory::build(), energyEstimation, Exception::errorMessage(), FileSystem::fileExists(), implementation, TTAProgram::NullProgram::instance(), machine, CmdLineParser::numberOfArguments(), ExecutionTrace::open(), options, program, TPEF::BinaryReader::readBinary(), ADFSerializer::readMachine(), IDF::IDFSerializer::readMachineImplementation(), XMLSerializer::setSourceFile(), and trace.

Referenced by main().

Here is the call graph for this function:

◆ main()

int main ( int  argc,
char *  argv[] 
)

Main function.

Parses the command line and executes cost estimation functionality.

Parameters
argcThe command line argument count.
argvThe command line arguments (passed to the interpreter).
Returns
The return status.

Definition at line 204 of file EstimatorCmdLineUI.cc.

204  {
205 
207 
209  try {
210  options->parse(argv, argc);
212  } catch (ParserStopRequest) {
213  return EXIT_SUCCESS;
214  } catch (const IllegalCommandLine& i) {
215  std::cerr << i.errorMessage() << std::endl;
216  return EXIT_FAILURE;
217  }
218 
219  if (!loadInputs(*options)) {
220  cleanup();
221  return EXIT_FAILURE;
222  }
223 
224  Estimator estimator;
225  if (options->totalArea() || !options->runOnlyEstimations()) {
226  CostEstimator::AreaInGates totalArea = -1;
227  try {
228  totalArea = round(estimator.totalArea(*machine, *implementation));
229  } catch (const Exception& e) {
230  std::cerr << "estimation failed: " + e.errorMessage()
231  << std::endl;
232  }
233 
234  if (totalArea >= 0) {
235  std::cout << "total area: " << totalArea << " gates"
236  << std::endl;
237  }
238  }
239 
240  if (options->longestPath() || !options->runOnlyEstimations()) {
241  std::cout << "delay of the longest path: ";
242  try {
243  std::cout
244  << round(estimator.longestPath(*machine, *implementation))
245  << " ns" << std::endl;
246  } catch (const Exception& e) {
247  std::cerr << "estimation failed: " + e.errorMessage()
248  << std::endl;
249  }
250  }
251 
252  if (energyEstimation &&
253  (options->totalEnergy() || !options->runOnlyEstimations())) {
254  std::cout << "total consumed energy: ";
255  try {
256  std::cout
257  << estimator.totalEnergy(
259  << " mJ" << std::endl;
260  } catch (const Exception& e) {
261  std::cerr << "estimation failed: " + e.errorMessage()
262  << std::endl;
263  }
264  }
265 
266  cleanup();
267  return EXIT_SUCCESS;
268 }

References cleanup(), energyEstimation, Exception::errorMessage(), implementation, Application::initialize(), loadInputs(), CostEstimator::Estimator::longestPath(), machine, options, CmdLineOptions::parse(), program, Application::setCmdLineOptions(), CostEstimator::Estimator::totalArea(), CostEstimator::Estimator::totalEnergy(), and trace.

Here is the call graph for this function:

Variable Documentation

◆ energyEstimation

bool energyEstimation = false

this is set to true in case energy estimation can be performed with the given input files

Definition at line 57 of file EstimatorCmdLineUI.cc.

Referenced by cleanup(), loadInputs(), and main().

◆ implementation

IDF::MachineImplementation* implementation = NULL

the implementation definition of the estimated processor

Definition at line 61 of file EstimatorCmdLineUI.cc.

Referenced by ProGe::NetlistGenerator::addBaseRFToNetlist(), HDB::HDBManager::addBlockImplementationFiles(), IDF::MachineImplementation::addBusImplementation(), HDB::HDBManager::addDataPortsToImplementation(), HDB::HDBManager::addFUExternalPortsToImplementation(), IDF::MachineImplementation::addFUImplementation(), HDB::HDBManager::addFUParametersToImplementation(), IDF::MachineImplementation::addIUImplementation(), HDB::HDBManager::addOpcodesToImplementation(), HDB::HDBManager::addRFExternalPortsToImplementation(), IDF::MachineImplementation::addRFImplementation(), HDB::HDBManager::addRFImplementation(), HDB::HDBManager::addRFParametersToImplementation(), IDF::MachineImplementation::addSocketImplementation(), ProGe::ProcessorGenerator::checkIULatencies(), cleanup(), ProGe::BlockSourceCopier::copyBaseRFFiles(), ProGe::BlockSourceCopier::copyFiles(), HDB::HDBManager::createImplementationOfFU(), HDB::HDBManager::createImplementationOfRF(), DefaultICDecoderEstimator::delayOfBus(), DefaultICDecoderEstimator::delayOfSocket(), AddRFImplementationCmd::Do(), AddFUImplementationCmd::Do(), StrictMatchFUEstimator::estimateArea(), StrictMatchRFEstimator::estimateArea(), StrictMatchFUEstimator::estimateEnergy(), StrictMatchRFEstimator::estimateEnergy(), InterpolatingFUEstimator::estimateEnergy(), StrictMatchFUEstimator::estimateMaximumComputationDelay(), StrictMatchRFEstimator::estimateMaximumComputationDelay(), StrictMatchFUEstimator::estimatePortReadDelay(), StrictMatchRFEstimator::estimatePortReadDelay(), StrictMatchFUEstimator::estimatePortWriteDelay(), StrictMatchRFEstimator::estimatePortWriteDelay(), IDF::MachineImplementation::findImplementation(), HDB::HDBManager::fuByEntryID(), ProGeTestBenchGenerator::generate(), DefaultICDecoderGenerator::generate(), ProGe::ProcessorGenerator::generateProcessor(), PlatformIntegrator::loadFUExternalPorts(), loadInputs(), main(), ProGe::NetlistGenerator::opcodePortWidth(), readIdf(), IDF::IDFSerializer::readMachineImplementation(), IDF::MachineImplementation::removeBusImplementation(), IDF::MachineImplementation::removeFUImplementation(), IDF::MachineImplementation::removeIUImplementation(), IDF::MachineImplementation::removeRFImplementation(), IDF::MachineImplementation::removeSocketImplementation(), HDB::HDBManager::rfByEntryID(), ImplementationTester::simulateTestbench(), and IDF::IDFSerializer::writeMachineImplementation().

◆ machine

TTAMachine::Machine* machine = NULL

the architecture definition of the estimated processor

Definition at line 59 of file EstimatorCmdLineUI.cc.

Referenced by RegisterCopyAdder::addCandidateSetAnnotations(), FullyConnectedCheck::attachSocketToAllBusses(), ResourceBuildDirector::build(), MachineStateBuilder::build(), SimulationController::buildFUResourceConflictDetectors(), MachineStateBuilder::buildMachineState(), MinimalOpSetCheck::buildMinimalOpSet(), BUMoveNodeSelector::BUMoveNodeSelector(), BFOptimization::canBeScheduled(), MachineConnectivityCheck::canTransportMove(), MinimalOpSetCheck::check(), ProGe::ProcessorGenerator::checkIULatencies(), MinimalOpSetCheck::checkWithIgnore(), cleanup(), TTAMachine::FUPort::cleanupGuards(), CompiledSimCodeGenerator::CompiledSimCodeGenerator(), InstructionDictionary::compress(), FullyConnectedCheck::connectFUPort(), ADFSerializer::convertToMachineFormat(), TTAMachine::Machine::copyFromMachine(), MachineEditPartFactory::createEditPart(), POMDisassembler::createGuard(), POMDisassembler::createRegister(), FullyConnectedCheck::createSocket(), createTerminalFUPort(), CriticalPathBBMoveNodeSelector::CriticalPathBBMoveNodeSelector(), DefaultICDecoderGenerator::DefaultICDecoderGenerator(), AddFUArchFromADFCmd::Do(), BlocksConnectICCmd::Do(), VerifyMachineCmd::Do(), VLIWConnectICCmd::Do(), AddBridgeCmd::Do(), CallExplorerPluginCmd::Do(), ImplementMachineCmd::Do(), PasteComponentCmd::Do(), FullyConnectBussesCmd::Do(), DefaultICDecoderEstimator::estimateICArea(), DefaultICDecoderEstimator::estimateICEnergy(), CopyingDelaySlotFiller::fillDelaySlots(), CostEstimator::Estimator::findAllICPaths(), findBooleanGuard(), findBooleanRegisterFile(), findBus(), SimulationController::findExitPoints(), findFunctionUnit(), findFUPort(), MachineInfo::findLockUnits(), TTASimulationController::findProgramExitPoints(), findRegisterFile(), MachineInfo::findWidestOperand(), ProGe::ProcessorGenerator::generateGCUOpcodesPackage(), ProGe::ProcessorGenerator::generateGlobalsPackage(), generateHeader(), ProGe::ProcessorGenerator::generateProcessor(), MachineEditPartFactory::getBusChains(), getFunctionUnit(), getRegisterFile(), MachineEditPartFactory::getSockets(), BasicBlockScheduler::getTriggerOperand(), MachineEditPartFactory::getUnits(), CostEstimator::Estimator::icArea(), CostEstimator::Estimator::icEnergy(), FUGen::implement(), AddWatchDialog::initialize(), CopyingDelaySlotFiller::initialize(), ProGe::PortFactory::initializeContext(), ProGe::NetlistGenerator::instructionMemory(), ProGe::NetlistGenerator::instructionMemoryAddressWidth(), ProGe::NetlistGenerator::instructionMemoryWidth(), GenerateProcessor::listICDecPluginParameters(), loadInputs(), ProgramImageGenerator::loadMachine(), CostEstimator::Estimator::longestPath(), MachineAnalysis::MachineAnalysis(), main(), MinimalOpSetCheck::missingOperations(), MachineConnectivityCheck::needRegCopiesDueReadPortConflicts(), MachineInfo::numberOfRegisters(), AddIUFromHDBDialog::onAdd(), AddRFFromHDBDialog::onAdd(), AddFUFromHDBDialog::onAdd(), OTAFormatListDialog::onAddOTAFormat(), TemplateListDialog::onAddTemplate(), FUPortDialog::onOK(), RFDialog::onOK(), SRPortDialog::onOK(), SocketDialog::onOK(), FUDialog::onOK(), IUDialog::onOK(), BridgeDialog::onOK(), AddressSpaceDialog::onOK(), GCUDialog::onOK(), ProximMachineStateWindow::onProgramLoaded(), CallExplorerPluginWindow::onRun(), MDFView::OnUpdate(), printLatexAddressSpaceDescription(), printLatexFunctionUnitDescription(), ProgrammabilityValidator::ProgrammabilityValidator(), ProximMachineStateWindow::ProximMachineStateWindow(), MachineConnectivityCheck::raConnected(), RemoteController::RemoteController(), ProGe::ProcessorGenerator::removeUnconnectedSockets(), IDFValidator::removeUnknownImplementations(), MachineCheckSuite::run(), ProGe::RV32MicroCodeGenerator::RV32MicroCodeGenerator(), MachineCanvas::setMachine(), ProximMachineStateWindow::setUtilizationHighlights(), DesignSpaceExplorer::simulate(), SimulationController::SimulationController(), FullyConnectedCheck::socketAttachedToAllBusses(), MachineInfo::supportsBoolRegisterGuardedJumps(), MachineInfo::supportsPortGuardedJump(), MachineInfo::supportsPortGuardedJumps(), tandemSimulate(), MachineConnectivityCheck::tempRegisterFiles(), CostEstimator::Estimator::totalArea(), CostEstimator::Estimator::totalAreaOfFunctionUnits(), CostEstimator::Estimator::totalAreaOfRegisterFiles(), CostEstimator::Estimator::totalEnergy(), CostEstimator::Estimator::totalEnergyOfFunctionUnits(), CostEstimator::Estimator::totalEnergyOfRegisterFiles(), MachineInfo::triggerIndex(), validateIdf(), ProGe::ProcessorGenerator::validateMachine(), ADFSerializer::writeMachine(), and Model::~Model().

◆ program

TTAProgram::Program* program = NULL

the estimated program is stored in this variable (in case energy estimation is wanted

Definition at line 64 of file EstimatorCmdLineUI.cc.

Referenced by cleanup(), loadInputs(), and main().

◆ trace

ExecutionTrace* trace = NULL
CostEstimator::Estimator::totalArea
AreaInGates totalArea(const TTAMachine::Machine &machine, const IDF::MachineImplementation &machineImplementation)
area estimation functions
Definition: Estimator.cc:84
ParserStopRequest
Definition: Exception.hh:491
XMLSerializer::setSourceFile
void setSourceFile(const std::string &fileName)
Definition: XMLSerializer.cc:115
machine
TTAMachine::Machine * machine
the architecture definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:59
CmdLineParser::numberOfArguments
virtual int numberOfArguments() const
implementation
IDF::MachineImplementation * implementation
the implementation definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:61
TPEF::Binary
Definition: Binary.hh:49
IDF::IDFSerializer::readMachineImplementation
MachineImplementation * readMachineImplementation()
Definition: IDFSerializer.cc:148
CostEstimator::Estimator::totalEnergy
EnergyInMilliJoules totalEnergy(const TTAMachine::Machine &machine, const IDF::MachineImplementation &machineImplementation, const TTAProgram::Program &program, const ExecutionTrace &traceDB)
energy estimation functions
Definition: Estimator.cc:433
CostEstimator::Estimator::longestPath
DelayInNanoSeconds longestPath(const TTAMachine::Machine &machine, const IDF::MachineImplementation &machineImplementation)
delay estimation functions
Definition: Estimator.cc:915
TPEF::BinaryStream
Definition: BinaryStream.hh:59
ExecutionTrace::open
void open()
Definition: ExecutionTrace.cc:169
energyEstimation
bool energyEstimation
this is set to true in case energy estimation can be performed with the given input files
Definition: EstimatorCmdLineUI.cc:57
CostEstimator::Estimator
Definition: Estimator.hh:85
Application::setCmdLineOptions
static void setCmdLineOptions(CmdLineOptions *options_)
Definition: Application.cc:381
IllegalCommandLine
Definition: Exception.hh:438
CostEstimator::AreaInGates
double AreaInGates
type for area values in equivalent gates
Definition: CostEstimatorTypes.hh:35
EstimatorCmdLineOptions
Definition: EstimatorCmdLineOptions.hh:43
loadInputs
bool loadInputs(EstimatorCmdLineOptions &options)
Definition: EstimatorCmdLineUI.cc:75
TTAProgram::TPEFProgramFactory
Definition: TPEFProgramFactory.hh:87
TTAProgram::NullProgram::instance
static NullProgram & instance()
Definition: NullProgram.cc:72
assert
#define assert(condition)
Definition: Application.hh:86
ADFSerializer
Definition: ADFSerializer.hh:49
program
TTAProgram::Program * program
the estimated program is stored in this variable (in case energy estimation is wanted
Definition: EstimatorCmdLineUI.cc:64
Exception
Definition: Exception.hh:54
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
CmdLineOptions::parse
void parse(char *argv[], int argc)
Definition: CmdLineOptions.cc:107
options
static MachInfoCmdLineOptions options
Definition: MachInfo.cc:46
FileSystem::fileExists
static bool fileExists(const std::string fileName)
Application::initialize
static void initialize()
Definition: Application.cc:99
trace
ExecutionTrace * trace
the execution trace database
Definition: EstimatorCmdLineUI.cc:66
cleanup
void cleanup()
Definition: EstimatorCmdLineUI.cc:179
ADFSerializer::readMachine
TTAMachine::Machine * readMachine()
Definition: ADFSerializer.cc:275
IDF::IDFSerializer
Definition: IDFSerializer.hh:45
CmdLineParser::argument
virtual std::string argument(int index) const
TPEF::BinaryReader::readBinary
static Binary * readBinary(BinaryStream &stream)
Definition: BinaryReader.cc:88