OpenASIP  2.0
Public Member Functions | Static Public Member Functions | List of all members
ProgramPass Class Reference

#include <ProgramPass.hh>

Inheritance diagram for ProgramPass:
Inheritance graph
Collaboration diagram for ProgramPass:
Collaboration graph

Public Member Functions

 ProgramPass (InterPassData &data)
 
virtual ~ProgramPass ()
 
virtual void handleProgram (TTAProgram::Program &program, const TTAMachine::Machine &targetMachine)
 
- Public Member Functions inherited from SchedulerPass
 SchedulerPass (InterPassData &data)
 
virtual ~SchedulerPass ()
 
InterPassDatainterPassData ()
 
virtual std::string shortDescription () const =0
 
virtual std::string longDescription () const
 

Static Public Member Functions

static void executeProcedurePass (TTAProgram::Program &program, const TTAMachine::Machine &targetMachine, ProcedurePass &procedurePass)
 

Detailed Description

Interface for scheduler passes that handle fully-linked programs.

Definition at line 52 of file ProgramPass.hh.

Constructor & Destructor Documentation

◆ ProgramPass()

ProgramPass::ProgramPass ( InterPassData data)

Constructor.

Definition at line 48 of file ProgramPass.cc.

48  :
49  SchedulerPass(data) {
50 }

◆ ~ProgramPass()

ProgramPass::~ProgramPass ( )
virtual

Destructor.

Definition at line 55 of file ProgramPass.cc.

55  {
56 }

Member Function Documentation

◆ executeProcedurePass()

void ProgramPass::executeProcedurePass ( TTAProgram::Program program,
const TTAMachine::Machine targetMachine,
ProcedurePass procedurePass 
)
static

Executes the given procedure pass on each procedure of the given program in the original program order.

A helper function for implementing most simplest types of program passes.

Parameters
programThe program to handle.
machineThe target machine if any. (NullMachine::instance() if target machine is irrelevant).
procedurePassThe procedure pass to execute.
Exceptions
Incase handling is unsuccesful for any reason (cfg might still get modified).

Definition at line 72 of file ProgramPass.cc.

74  {
75  boost::timer totalTime;
76 
77  FunctionNameList proceduresToProcess, proceduresToIgnore;
78  if (procedurePass.interPassData().hasDatum("FUNCTIONS_TO_PROCESS")) {
79  proceduresToProcess =
80  dynamic_cast<FunctionNameList&>(
81  procedurePass.interPassData().datum("FUNCTIONS_TO_PROCESS"));
82  } else if (procedurePass.interPassData().hasDatum("FUNCTIONS_TO_IGNORE")) {
83  proceduresToIgnore =
84  dynamic_cast<FunctionNameList&>(
85  procedurePass.interPassData().datum("FUNCTIONS_TO_IGNORE"));
86  }
87 
88  std::size_t proceduresDone = 0;
89  // always call procedureCount() again because a pass might have
90  // added a new procedure to the program that needs to be handled
91  for (int procIndex = 0; procIndex < program.procedureCount();
92  ++procIndex) {
93  TTAProgram::Procedure& proc = program.procedure(procIndex);
94 
95  if (proceduresToProcess.size() > 0 &&
96  proceduresToProcess.find(proc.name()) ==
97  proceduresToProcess.end())
98  continue;
99 
100  if (proceduresToIgnore.size() > 0 &&
101  proceduresToIgnore.find(proc.name()) !=
102  proceduresToIgnore.end())
103  continue;
104 
105 
106  boost::timer currentTime;
107  std::size_t totalProcedures = 0;
108  if (Application::verboseLevel() > 0) {
109 
110  if (proceduresToProcess.size() > 0) {
111  totalProcedures = proceduresToProcess.size();
112  } else {
113  totalProcedures = program.procedureCount();
114  }
115 
116  totalProcedures -= proceduresToIgnore.size();
118  << std::endl
119  << "procedure: " << proc.name()
120  << (boost::format(" (%d/%d)")
121  % (proceduresDone + 1) % totalProcedures).str();
122  }
123  procedurePass.handleProcedure(proc, targetMachine);
124  ++proceduresDone;
125 
126  if (Application::verboseLevel() > 0) {
127  double cur = currentTime.elapsed();
128  double tot = totalTime.elapsed();
129  long currentElapsed = static_cast<long>(cur);
130  long totalElapsed = static_cast<long>(tot);
131  long eta =
132  static_cast<long>(
133  (tot / proceduresDone) *
134  (totalProcedures - proceduresDone));
136  << (boost::format(
137  " %d min %d s. Total %d min %d s. ETA in %d min %d s")
138  % (currentElapsed / 60) % (currentElapsed % 60)
139  % (totalElapsed / 60) % (totalElapsed % 60)
140  % (eta / 60) % (eta % 60)).str()
141  << std::endl;
142  }
143  }
144 }

References InterPassData::datum(), ProcedurePass::handleProcedure(), InterPassData::hasDatum(), SchedulerPass::interPassData(), Application::logStream(), TTAProgram::Procedure::name(), program, and Application::verboseLevel().

Referenced by SimpleIfConverter::handleProgram(), handleProgram(), PreOptimizer::handleProgram(), and BBSchedulerController::handleProgram().

Here is the call graph for this function:

◆ handleProgram()

void ProgramPass::handleProgram ( TTAProgram::Program program,
const TTAMachine::Machine targetMachine 
)
virtual

Reimplemented in BBSchedulerController, PreOptimizer, and SimpleIfConverter.

Definition at line 147 of file ProgramPass.cc.

148  {
149  ProcedurePass* procPass = dynamic_cast<ProcedurePass*>(this);
150  if (procPass != NULL) {
151  executeProcedurePass(program, targetMachine, *procPass);
152  } else {
153  abortWithError("Program pass is not also a procedure pass so you "
154  "must overload handleProgram method!");
155  }
156 }

References abortWithError, executeProcedurePass(), and program.

Here is the call graph for this function:

The documentation for this class was generated from the following files:
ProcedurePass
Definition: ProcedurePass.hh:53
SimpleInterPassDatum
Definition: InterPassDatum.hh:64
Application::verboseLevel
static int verboseLevel()
Definition: Application.hh:176
Application::logStream
static std::ostream & logStream()
Definition: Application.cc:155
SchedulerPass::SchedulerPass
SchedulerPass(InterPassData &data)
Definition: SchedulerPass.cc:40
ProcedurePass::handleProcedure
virtual void handleProcedure(TTAProgram::Procedure &procedure, const TTAMachine::Machine &targetMachine)
Definition: ProcedurePass.cc:73
abortWithError
#define abortWithError(message)
Definition: Application.hh:72
InterPassData::hasDatum
bool hasDatum(const std::string &key) const
Definition: InterPassData.cc:75
SchedulerPass::interPassData
InterPassData & interPassData()
Definition: SchedulerPass.cc:53
TTAProgram::Procedure::name
TCEString name() const
Definition: Procedure.hh:66
program
find Finds info of the inner loops in the program
Definition: InnerLoopFinder.cc:80
InterPassData::datum
InterPassDatum & datum(const std::string &key)
Definition: InterPassData.cc:62
TTAProgram::Procedure
Definition: Procedure.hh:55
ProgramPass::executeProcedurePass
static void executeProcedurePass(TTAProgram::Program &program, const TTAMachine::Machine &targetMachine, ProcedurePass &procedurePass)
Definition: ProgramPass.cc:72