OpenASIP  2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
MultiLatencyOperationExecutor Class Reference

#include <MultiLatencyOperationExecutor.hh>

Inheritance diagram for MultiLatencyOperationExecutor:
Inheritance graph
Collaboration diagram for MultiLatencyOperationExecutor:
Collaboration graph

Public Member Functions

 MultiLatencyOperationExecutor (FUState &parent, TTAMachine::HWOperation &hwOp)
 
 MultiLatencyOperationExecutor ()
 
virtual ~MultiLatencyOperationExecutor ()
 
virtual void startOperation (Operation &op)
 
virtual void advanceClock ()
 
virtual OperationExecutorcopy ()
 
virtual void setContext (OperationContext &context)
 
virtual void reset ()
 
virtual void setOperationSimulator (DetailedOperationSimulator &sim)
 
- Public Member Functions inherited from OperationExecutor
 OperationExecutor ()
 
 OperationExecutor (FUState &parent)
 
virtual ~OperationExecutor ()
 
FUStateparent () const
 
void setParent (FUState &parent)
 
void addBinding (int io, PortState &port)
 
PortStatebinding (int io) const
 
bool hasPendingOperations () const
 

Private Member Functions

MultiLatencyOperationExecutoroperator= (const MultiLatencyOperationExecutor &)
 Assignment not allowed. More...
 
ExecutingOperationfindFreeExecutingOperation ()
 

Private Attributes

OperationContextcontext_
 Operation context. More...
 
TTAMachine::HWOperationhwOperation_
 The hardware operation this executor simulates. More...
 
Operationoperation_
 The OSAL operation. More...
 
std::vector< ExecutingOperationexecutingOps_
 The operations "on flight" in this operation executor. More...
 
ExecutingOperationfreeExecOp_
 If non-NULL, points to a known free ExecutingOperation slot. More...
 
bool execOperationsInitialized_
 
DetailedOperationSimulatoropSimulator_
 If non-NULL, points to a detailed cycle-by-cycle simulation model for the operation simulated by this executor. More...
 

Additional Inherited Members

- Protected Attributes inherited from OperationExecutor
std::vector< PortState * > bindings_
 PortStates that are bound to a certain input or output operand. More...
 
bool hasPendingOperations_
 This is set to true if the OperationExecutor is not in 'idle' mode. More...
 

Detailed Description

OperationExecutor that supports multi-output operation pipelines with different latencies for results.

Can be also used for cycle-accurate modeling of the operation pipeline. In addition to simulate the execution of operations with multiple outputs with different latencies in the standalone TTA simulation, this execution model is used in the SystemC TTA core function unit simulation model.

See also
tce_systemc.hh

Definition at line 61 of file MultiLatencyOperationExecutor.hh.

Constructor & Destructor Documentation

◆ MultiLatencyOperationExecutor() [1/2]

MultiLatencyOperationExecutor::MultiLatencyOperationExecutor ( FUState parent,
TTAMachine::HWOperation hwOp 
)

Constructor.

Parameters
parentParent of the OperationExecutor.
hwOpThe hardware operation to simulate.

Initialize a list of pending executing operations that is the size of the maximum on flight operations. Each element in the list is initialized to contain a large enough I/O vector for inputs and outputs. In addition, the models for simulating the output latencies are initialized so it's as fast as possible to trigger new operations.

Definition at line 54 of file MultiLatencyOperationExecutor.cc.

55  :
58  opSimulator_(NULL) {
59 
60  OperationPool ops;
61  operation_ = &ops.operation(hwOp.name().c_str());
62  /**
63  * Initialize a list of pending executing operations that is the
64  * size of the maximum on flight operations. Each element in the
65  * list is initialized to contain a large enough I/O vector for
66  * inputs and outputs. In addition, the models for simulating the
67  * output latencies are initialized so it's as fast as possible
68  * to trigger new operations.
69  */
70  const std::size_t inputOperands = operation_->numberOfInputs();
71  const std::size_t outputOperands = operation_->numberOfOutputs();
72  const std::size_t operandCount = inputOperands + outputOperands;
73 
74  hasPendingOperations_ = true;
76  eop.iostorage_.resize(operandCount);
77  executingOps_.resize(hwOp.latency(), eop);
78 
79 }

References executingOps_, OperationExecutor::hasPendingOperations_, ExecutingOperation::iostorage_, TTAMachine::HWOperation::latency(), TTAMachine::HWOperation::name(), Operation::numberOfInputs(), Operation::numberOfOutputs(), OperationPool::operation(), and operation_.

Here is the call graph for this function:

◆ MultiLatencyOperationExecutor() [2/2]

MultiLatencyOperationExecutor::MultiLatencyOperationExecutor ( )
inline

Definition at line 65 of file MultiLatencyOperationExecutor.hh.

65 : hwOperation_(NULL) {}

Referenced by copy().

◆ ~MultiLatencyOperationExecutor()

MultiLatencyOperationExecutor::~MultiLatencyOperationExecutor ( )
virtual

Destructor.

Definition at line 84 of file MultiLatencyOperationExecutor.cc.

84  {
85 }

Member Function Documentation

◆ advanceClock()

void MultiLatencyOperationExecutor::advanceClock ( )
virtual

Advances clock by one cycle.

Implements OperationExecutor.

Reimplemented in ConflictDetectingOperationExecutor.

Definition at line 168 of file MultiLatencyOperationExecutor.cc.

168  {
169 
170  bool foundActiveOperation = false;
171  size_t executingOpCount = executingOps_.size();
172  for (std::size_t i = 0; i < executingOpCount; ++i) {
173  ExecutingOperation& execOp = executingOps_[i];
174  if (execOp.free_) {
175  freeExecOp_ = &execOp;
176  continue;
177  }
178 
179  foundActiveOperation = true;
180  bool customSimulated =
181  opSimulator_ != NULL && opSimulator_->simulateStage(execOp);
182  if (execOp.stage_ == 0 && !customSimulated)
183  operation_->simulateTrigger(&execOp.iovec_[0], *context_);
184  execOp.advanceCycle();
185 
186  if (execOp.stage_ == hwOperation_->latency()) {
187 #ifdef DEBUG_OPERATION_SIMULATION
189  << &execOp << " (" << execOp.operation().name()
190  << ") finished" << std::endl;
191 #endif
192  execOp.stop();
193  }
194  }
195  hasPendingOperations_ = foundActiveOperation;
196 }

References ExecutingOperation::advanceCycle(), context_, executingOps_, ExecutingOperation::free_, freeExecOp_, OperationExecutor::hasPendingOperations_, hwOperation_, ExecutingOperation::iovec_, TTAMachine::HWOperation::latency(), Application::logStream(), Operation::name(), ExecutingOperation::operation(), operation_, opSimulator_, DetailedOperationSimulator::simulateStage(), Operation::simulateTrigger(), ExecutingOperation::stage_, and ExecutingOperation::stop().

Referenced by ConflictDetectingOperationExecutor::advanceClock().

Here is the call graph for this function:

◆ copy()

OperationExecutor * MultiLatencyOperationExecutor::copy ( )
virtual

Copies OperationExecutor.

Returns
The copied OperationExecutor.

Implements OperationExecutor.

Reimplemented in ConflictDetectingOperationExecutor.

Definition at line 204 of file MultiLatencyOperationExecutor.cc.

204  {
205  return new MultiLatencyOperationExecutor(*this);
206 }

References MultiLatencyOperationExecutor().

Here is the call graph for this function:

◆ findFreeExecutingOperation()

ExecutingOperation & MultiLatencyOperationExecutor::findFreeExecutingOperation ( )
private

Definition at line 89 of file MultiLatencyOperationExecutor.cc.

89  {
90  ExecutingOperation* execOp = NULL;
91  if (freeExecOp_ != NULL) {
92  execOp = freeExecOp_;
93  freeExecOp_ = NULL;
94  } else {
95  for (std::size_t i = 0; i < executingOps_.size(); ++i) {
96  execOp = &executingOps_[i];
97  if (execOp->free_) {
98  break;
99  }
100  }
101  }
102  assert(execOp != NULL &&
103  "Did not find a free ExecutingOperation.");
104  return *execOp;
105 }

References assert, executingOps_, ExecutingOperation::free_, and freeExecOp_.

Referenced by startOperation().

◆ operator=()

MultiLatencyOperationExecutor& MultiLatencyOperationExecutor::operator= ( const MultiLatencyOperationExecutor )
private

Assignment not allowed.

◆ reset()

void MultiLatencyOperationExecutor::reset ( )
virtual

Resets the state to allow simulation restart. hasPendingOperations_ is resetted because otherwise some operations could be left in middle of execution if there was a runtime error during operation.

Reimplemented from OperationExecutor.

Definition at line 225 of file MultiLatencyOperationExecutor.cc.

225  {
226  hasPendingOperations_ = false;
227 }

References OperationExecutor::hasPendingOperations_.

◆ setContext()

void MultiLatencyOperationExecutor::setContext ( OperationContext context)
virtual

Sets the OperationContext for the OperationExecutor.

Parameters
contextNew OperationContext.

Implements OperationExecutor.

Definition at line 214 of file MultiLatencyOperationExecutor.cc.

214  {
215  context_ = &context;
216 }

References context_.

◆ setOperationSimulator()

virtual void MultiLatencyOperationExecutor::setOperationSimulator ( DetailedOperationSimulator sim)
inlinevirtual

Definition at line 74 of file MultiLatencyOperationExecutor.hh.

75  {
76  opSimulator_ = &sim;
77  }

References opSimulator_.

Referenced by FUState::setOperationSimulator().

◆ startOperation()

void MultiLatencyOperationExecutor::startOperation ( Operation op)
virtual

Starts new operation.

First original inputs and outputs are stored. Then outputs of the operation are stored. Then operation is triggered.

Parameters
opOperation to be triggered.
Todo:
This can be optimized a lot: try to initialize the vector as rarely as possible.

Implements OperationExecutor.

Reimplemented in ConflictDetectingOperationExecutor.

Definition at line 118 of file MultiLatencyOperationExecutor.cc.

118  {
119 
120  const std::size_t inputOperands = operation_->numberOfInputs();
121  const std::size_t outputOperands = operation_->numberOfOutputs();
122  const std::size_t operandCount = inputOperands + outputOperands;
124 
126  // cannot initialize in the constructor as the
127  // FUPort -> operand bindings have not been initialized at
128  // that point
129  for (std::size_t i = 0; i < executingOps_.size(); ++i) {
130  ExecutingOperation& execOp = executingOps_[i];
131  execOp.initIOVec();
132  // set the widths of the storage values to enforce correct
133  // clipping of values
134  for (std::size_t o = 1; o <= operandCount; ++o) {
135  execOp.iostorage_[o - 1].setBitWidth(
136  binding(o).value().width());
137  }
138  // set operation output storages to point to the corresponding
139  // output ports and setup their delayed appearance
140  for (std::size_t o = inputOperands + 1; o <= operandCount; ++o) {
141  PortState& port = binding(o);
142  const int resultLatency = hwOperation_->latency(o);
143 
145  execOp.iostorage_[o - 1], port, resultLatency);
146  execOp.pendingResults_.push_back(res);
147  }
148  }
150  }
151  // copy the input values to the on flight operation executor model
152  for (std::size_t i = 1; i <= inputOperands; ++i) {
153  execOp.iostorage_[i - 1] = binding(i).value();
154  }
155 #ifdef DEBUG_OPERATION_SIMULATION
157  << &execOp << " (" << execOp.operation().name()
158  << ") started" << std::endl;
159 #endif
160  execOp.start();
161  hasPendingOperations_ = true;
162 }

References OperationExecutor::binding(), execOperationsInitialized_, executingOps_, findFreeExecutingOperation(), OperationExecutor::hasPendingOperations_, hwOperation_, ExecutingOperation::initIOVec(), ExecutingOperation::iostorage_, TTAMachine::HWOperation::latency(), Application::logStream(), Operation::name(), Operation::numberOfInputs(), Operation::numberOfOutputs(), ExecutingOperation::operation(), operation_, ExecutingOperation::pendingResults_, ExecutingOperation::start(), and RegisterState::value().

Referenced by ConflictDetectingOperationExecutor::startOperation().

Here is the call graph for this function:

Member Data Documentation

◆ context_

OperationContext* MultiLatencyOperationExecutor::context_
private

Operation context.

Definition at line 87 of file MultiLatencyOperationExecutor.hh.

Referenced by advanceClock(), and setContext().

◆ execOperationsInitialized_

bool MultiLatencyOperationExecutor::execOperationsInitialized_
private

Definition at line 96 of file MultiLatencyOperationExecutor.hh.

Referenced by startOperation().

◆ executingOps_

std::vector<ExecutingOperation> MultiLatencyOperationExecutor::executingOps_
private

The operations "on flight" in this operation executor.

Definition at line 93 of file MultiLatencyOperationExecutor.hh.

Referenced by advanceClock(), findFreeExecutingOperation(), MultiLatencyOperationExecutor(), and startOperation().

◆ freeExecOp_

ExecutingOperation* MultiLatencyOperationExecutor::freeExecOp_
private

If non-NULL, points to a known free ExecutingOperation slot.

Definition at line 95 of file MultiLatencyOperationExecutor.hh.

Referenced by advanceClock(), and findFreeExecutingOperation().

◆ hwOperation_

TTAMachine::HWOperation* MultiLatencyOperationExecutor::hwOperation_
private

The hardware operation this executor simulates.

Definition at line 89 of file MultiLatencyOperationExecutor.hh.

Referenced by advanceClock(), and startOperation().

◆ operation_

Operation* MultiLatencyOperationExecutor::operation_
private

The OSAL operation.

Definition at line 91 of file MultiLatencyOperationExecutor.hh.

Referenced by advanceClock(), MultiLatencyOperationExecutor(), and startOperation().

◆ opSimulator_

DetailedOperationSimulator* MultiLatencyOperationExecutor::opSimulator_
private

If non-NULL, points to a detailed cycle-by-cycle simulation model for the operation simulated by this executor.

Definition at line 99 of file MultiLatencyOperationExecutor.hh.

Referenced by advanceClock(), and setOperationSimulator().


The documentation for this class was generated from the following files:
MultiLatencyOperationExecutor::executingOps_
std::vector< ExecutingOperation > executingOps_
The operations "on flight" in this operation executor.
Definition: MultiLatencyOperationExecutor.hh:93
OperationPool::operation
Operation & operation(const char *name)
Definition: OperationPool.cc:99
ExecutingOperation::PendingResult
Definition: ExecutingOperation.hh:90
DetailedOperationSimulator::simulateStage
virtual bool simulateStage(ExecutingOperation &operation)=0
MultiLatencyOperationExecutor::execOperationsInitialized_
bool execOperationsInitialized_
Definition: MultiLatencyOperationExecutor.hh:96
ExecutingOperation::stage_
int stage_
Definition: ExecutingOperation.hh:134
ExecutingOperation::operation
const Operation & operation() const
Definition: ExecutingOperation.hh:63
OperationExecutor::OperationExecutor
OperationExecutor()
Definition: OperationExecutor.hh:51
ExecutingOperation::iostorage_
std::vector< SimValue > iostorage_
Definition: ExecutingOperation.hh:125
Operation::numberOfInputs
virtual int numberOfInputs() const
Definition: Operation.cc:192
MultiLatencyOperationExecutor::findFreeExecutingOperation
ExecutingOperation & findFreeExecutingOperation()
Definition: MultiLatencyOperationExecutor.cc:89
Application::logStream
static std::ostream & logStream()
Definition: Application.cc:155
ExecutingOperation::free_
bool free_
Definition: ExecutingOperation.hh:138
ExecutingOperation::initIOVec
void initIOVec()
Definition: ExecutingOperation.hh:116
Operation::name
virtual TCEString name() const
Definition: Operation.cc:93
assert
#define assert(condition)
Definition: Application.hh:86
RegisterState::value
virtual const SimValue & value() const
Definition: RegisterState.cc:92
OperationExecutor::hasPendingOperations_
bool hasPendingOperations_
This is set to true if the OperationExecutor is not in 'idle' mode.
Definition: OperationExecutor.hh:73
TTAMachine::HWOperation::name
const std::string & name() const
Definition: HWOperation.cc:141
MultiLatencyOperationExecutor::freeExecOp_
ExecutingOperation * freeExecOp_
If non-NULL, points to a known free ExecutingOperation slot.
Definition: MultiLatencyOperationExecutor.hh:95
PortState
Definition: PortState.hh:51
MultiLatencyOperationExecutor::MultiLatencyOperationExecutor
MultiLatencyOperationExecutor()
Definition: MultiLatencyOperationExecutor.hh:65
ExecutingOperation
Definition: ExecutingOperation.hh:48
MultiLatencyOperationExecutor::opSimulator_
DetailedOperationSimulator * opSimulator_
If non-NULL, points to a detailed cycle-by-cycle simulation model for the operation simulated by this...
Definition: MultiLatencyOperationExecutor.hh:99
OperationExecutor::parent
FUState & parent() const
MultiLatencyOperationExecutor::operation_
Operation * operation_
The OSAL operation.
Definition: MultiLatencyOperationExecutor.hh:91
Operation::simulateTrigger
virtual bool simulateTrigger(SimValue **, OperationContext &context) const
Definition: Operation.cc:555
MultiLatencyOperationExecutor::hwOperation_
TTAMachine::HWOperation * hwOperation_
The hardware operation this executor simulates.
Definition: MultiLatencyOperationExecutor.hh:89
ExecutingOperation::stop
void stop()
Definition: ExecutingOperation.cc:65
TTAMachine::HWOperation::latency
int latency() const
Definition: HWOperation.cc:216
OperationPool
Definition: OperationPool.hh:52
ExecutingOperation::advanceCycle
void advanceCycle()
Definition: ExecutingOperation.cc:73
ExecutingOperation::pendingResults_
std::vector< PendingResult > pendingResults_
Definition: ExecutingOperation.hh:132
Operation::numberOfOutputs
virtual int numberOfOutputs() const
Definition: Operation.cc:202
OperationExecutor::binding
PortState & binding(int io) const
MultiLatencyOperationExecutor::context_
OperationContext * context_
Operation context.
Definition: MultiLatencyOperationExecutor.hh:87
ExecutingOperation::start
void start()
Definition: ExecutingOperation.cc:51
ExecutingOperation::iovec_
std::vector< SimValue * > iovec_
OSAL simulateTrigger() compatible I/O vector for fast execution.
Definition: ExecutingOperation.hh:127