OpenASIP 2.2
Loading...
Searching...
No Matches
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.
 
ExecutingOperationfindFreeExecutingOperation ()
 

Private Attributes

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

Additional Inherited Members

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

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
76 eop.iostorage_.resize(operandCount);
77 executingOps_.resize(hwOp.latency(), eop);
78
79}
ExecutingOperation * freeExecOp_
If non-NULL, points to a known free ExecutingOperation slot.
TTAMachine::HWOperation * hwOperation_
The hardware operation this executor simulates.
Operation * operation_
The OSAL operation.
DetailedOperationSimulator * opSimulator_
If non-NULL, points to a detailed cycle-by-cycle simulation model for the operation simulated by this...
std::vector< ExecutingOperation > executingOps_
The operations "on flight" in this operation executor.
OperationContext * context_
Operation context.
bool hasPendingOperations_
This is set to true if the OperationExecutor is not in 'idle' mode.
FUState & parent() const
Operation & operation(const char *name)
virtual int numberOfInputs() const
Definition Operation.cc:192
virtual int numberOfOutputs() const
Definition Operation.cc:202
const std::string & name() const

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) {
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)
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}
static std::ostream & logStream()
virtual bool simulateStage(ExecutingOperation &operation)=0
const Operation & operation() const
std::vector< SimValue * > iovec_
OSAL simulateTrigger() compatible I/O vector for fast execution.
virtual TCEString name() const
Definition Operation.cc:93
virtual bool simulateTrigger(SimValue **, OperationContext &context) const
Definition Operation.cc:555

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.

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}
#define assert(condition)

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) {
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();
162}
std::vector< PendingResult > pendingResults_
std::vector< SimValue > iostorage_
PortState & binding(int io) const
virtual const SimValue & value() const

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: