src/Sim/Pipeline/Retirer/Retirer.h

説明を見る。
00001 // 
00002 // Copyright (c) 2005-2008 Kenichi Watanabe.
00003 // Copyright (c) 2005-2008 Yasuhiro Watari.
00004 // Copyright (c) 2005-2008 Hironori Ichibayashi.
00005 // Copyright (c) 2008-2009 Kazuo Horio.
00006 // Copyright (c) 2009-2013 Naruki Kurata.
00007 // Copyright (c) 2005-2013 Ryota Shioya.
00008 // Copyright (c) 2005-2013 Masahiro Goshima.
00009 // 
00010 // This software is provided 'as-is', without any express or implied
00011 // warranty. In no event will the authors be held liable for any damages
00012 // arising from the use of this software.
00013 // 
00014 // Permission is granted to anyone to use this software for any purpose,
00015 // including commercial applications, and to alter it and redistribute it
00016 // freely, subject to the following restrictions:
00017 // 
00018 // 1. The origin of this software must not be misrepresented; you must not
00019 // claim that you wrote the original software. If you use this software
00020 // in a product, an acknowledgment in the product documentation would be
00021 // appreciated but is not required.
00022 // 
00023 // 2. Altered source versions must be plainly marked as such, and must not be
00024 // misrepresented as being the original software.
00025 // 
00026 // 3. This notice may not be removed or altered from any source
00027 // distribution.
00028 // 
00029 // 
00030 
00031 
00032 #ifndef SIM_PIPLINE_RETIRER_RETIRER_H
00033 #define SIM_PIPLINE_RETIRER_RETIRER_H
00034 
00035 #include "Types.h"
00036 #include "Sim/Foundation/Hook/HookDecl.h"
00037 #include "Sim/Op/OpArray/OpArray.h"
00038 #include "Sim/Op/OpStatus.h"
00039 #include "Sim/Pipeline/PipelineNodeBase.h"
00040 #include "Utility/Collection/fixed_size_buffer.h"
00041 
00042 namespace Onikiri
00043 {
00044     class Thread;
00045     class ForwardEmulator;
00046     class InorderList;
00047 
00048     class Retirer : public PipelineNodeBase
00049     {
00050     public:
00051 
00052         // A hook parameter for s_commitSteeringHook.
00053         struct CommitSteeringHookParam
00054         {   
00055             PhysicalResourceArray<Thread>* threadList;
00056             Thread* targetThread;
00057         };
00058 
00059         // A hook parameter for s_commitDecisionHook.
00060         struct CommitDecisionHookParam
00061         {   
00062             OpIterator op;
00063             bool canCommit;
00064         };
00065 
00066 
00067         BEGIN_PARAM_MAP("")
00068 
00069             BEGIN_PARAM_PATH( GetParamPath() )
00070 
00071                 PARAM_ENTRY( "@CommitWidth",    m_commitWidth )
00072                 PARAM_ENTRY( "@RetireWidth",    m_retireWidth )
00073                 PARAM_ENTRY( "@NoRetireLimit",  m_noCommitLimit )
00074                 PARAM_ENTRY( "@CommitLatency",  m_commitLatency )
00075                 PARAM_ENTRY( "@FixCommitLatency",   m_fixCommitLatency )
00076 
00077                 BEGIN_PARAM_BINDING( "@CommittableStatus", m_committableStatus, OpStatus )
00078                     PARAM_BINDING_ENTRY( "WRITTENBACK", OpStatus::OS_WRITTEN_BACK )
00079                     PARAM_BINDING_ENTRY( "COMPLETED",   OpStatus::OS_COMPLETED )
00080                 END_PARAM_BINDING()
00081 
00082             END_PARAM_PATH()
00083 
00084             BEGIN_PARAM_PATH( GetResultPath() )
00085                 PARAM_ENTRY( "@NumCommittedOps",    m_numCommittedOps )
00086                 PARAM_ENTRY( "@NumCommittedInsns",  m_numCommittedInsns )
00087                 PARAM_ENTRY( "@NumRetiredOps",      m_numRetiredOps )
00088                 PARAM_ENTRY( "@NumRetiredInsns",    m_numRetiredInsns )
00089                 PARAM_ENTRY( "@NumStorePortFullStalledCycles",  m_numStorePortFullStalledCycles )
00090             END_PARAM_PATH()
00091 
00092         END_PARAM_MAP()
00093 
00094         BEGIN_RESOURCE_MAP()
00095             RESOURCE_ENTRY( Thread, "thread",   m_thread )
00096             RESOURCE_ENTRY( Core,   "core",     m_core )
00097             RESOURCE_ENTRY( EmulatorIF,         "emulator",         m_emulator )
00098             RESOURCE_ENTRY( ForwardEmulator,    "forwardEmulator",  m_forwardEmulator )
00099         END_RESOURCE_MAP()
00100 
00101 
00102         Retirer();
00103         virtual ~Retirer();
00104 
00105         virtual void Initialize(InitPhase phase);
00106 
00107         // PipelineNodeIF
00108         virtual void Evaluate();
00109         virtual void Transition();
00110         virtual void Update();
00111 
00112         // accessors
00113         bool IsEndOfProgram()       const { return m_endOfProgram;      }
00114         s64 GetNumRetiredOp()       const { return m_numRetiredOps;     }
00115         s64 GetNumRetiredInsns()    const { return m_numRetiredInsns;   }
00116 
00117         // Set the number of retired ops/insns.
00118         // This is called when a simulation mode is changed from an emulation mode.
00119         void SetInitialNumRetiredOp( s64 numInsns, s64 numOp, s64 simulationEndInsns );
00120 
00121         // Called when the op is retired from OpRetireEvent.
00122         // Caution: this method is not called from InorderList because
00123         // the retirement of an op is triggered from this method.
00124         void Retire( OpIterator op );
00125 
00126         // Called when the op is flushed from InorderList.
00127         void Flush( OpIterator op );
00128 
00129         //
00130         // --- Hook
00131         //
00132         typedef HookPoint<Retirer> CommitHookPoint;
00133         static CommitHookPoint s_commitHook;
00134         
00135         // The hook point of 'GetComittableThread()'
00136         // Prototype : void Method( HookParameter<Retireer, SteeringHookParam>* param )
00137         typedef HookPoint<Retirer, CommitSteeringHookParam> CommitSteeringHookPoint;
00138         static CommitSteeringHookPoint s_commitSteeringHook;
00139 
00140         // The hook point of 'CanRetire()'
00141         // Prototype : void Method( HookParameter<Retireer,CommitDecisionHookPoint>* param )
00142         typedef HookPoint<Retirer, CommitDecisionHookParam> CommitDecisionHookPoint;
00143         static CommitDecisionHookPoint s_commitDecisionHook;
00144 
00145         typedef HookPoint<Retirer> RetireHookPoint;
00146         static RetireHookPoint s_retireHook;
00147 
00148 
00149     protected:
00150         typedef PipelineNodeBase BaseType;
00151 
00152         // Parameters
00153         int m_commitWidth;
00154         int m_retireWidth;
00155         int m_noCommitLimit;
00156         int m_commitLatency;
00157         bool m_fixCommitLatency;
00158         OpStatus m_committableStatus;
00159 
00160         // Statistics
00161         s64 m_numCommittedOps;
00162         s64 m_numCommittedInsns;
00163         s64 m_numRetiredOps;
00164         s64 m_numRetiredInsns;
00165         
00166         // Stalled cycles when commitment is stalled for store ports full.
00167         s64 m_numStorePortFullStalledCycles;    
00168 
00169         int m_noCommittedCycle;
00170         s64 m_numSimulationEndInsns;
00171 
00172         // The index of a retireable thread in attached threads.
00173         int m_currentRetireThread;
00174         bool m_endOfProgram;
00175 
00176         EmulatorIF*         m_emulator;         // Emulator
00177         ForwardEmulator*    m_forwardEmulator;  // Forward Emulator.
00178         
00179         // Committed ops decided by Evaluate() in this cycle
00180         
00181         typedef pool_list< OpIterator > CommitingOps;
00182         struct Evaluated
00183         {
00184             CommitingOps    committing;
00185 
00186             bool            exceptionOccur;
00187             OpIterator      exceptionCauser;
00188             bool evaluated;
00189             bool storePortFull;
00190 
00191             void Reset();
00192         }
00193         m_evaluated;
00194 
00195 
00196         // --- Commit
00197 
00198         // Returns whether 'op' can commit or not.
00199         bool CanCommitOp( OpIterator op );
00200 
00201         // Returns whether 'ops' that belongs to the same instruction can commit or not.
00202         bool CanCommitInsn( OpIterator op );
00203 
00204         // Decide a thread that commits ops in this cycle.
00205         Thread* GetCommitableThread();
00206 
00207         void Commit( OpIterator op );
00208         void EvaluateCommit();
00209         void UpdateCommit();
00210         void UpdateException();
00211 
00212         // Update counters related to retirement.
00213         void CheckCommitCounters( int retiredOps, InorderList* inorderList );
00214 
00215         // Finish a thread.
00216         void FinishThread( Thread* tread );
00217 
00218     };
00219 
00220 }; // namespace Onikiri
00221 
00222 #endif // SIM_PIPLINE_RETIRER_RETIRER_H
00223 

Onikiri2に対してTue Jun 18 14:34:24 2013に生成されました。  doxygen 1.4.7