src/Sim/Pipeline/Renamer/Renamer.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_PIPELINE_RENAMER_RENAMER_H
00033 #define SIM_PIPELINE_RENAMER_RENAMER_H
00034 
00035 #include "Env/Param/ParamExchange.h"
00036 #include "Sim/Pipeline/PipelineNodeBase.h"
00037 #include "Sim/Foundation/Checkpoint/CheckpointMaster.h"
00038 #include "Sim/Foundation/Hook/HookDecl.h"
00039 #include "Utility/Collection/fixed_size_buffer.h"
00040 
00041 namespace Onikiri 
00042 {
00043     class RegDepPredIF;
00044     class MemDepPredIF;
00045     class CheckpointMaster;
00046     class MemOrderManager;
00047     class LatPred;
00048     class DispatchSteererIF;
00049 
00050     class Renamer:
00051         public PipelineNodeBase
00052     {
00053     public:
00054 
00055         BEGIN_PARAM_MAP("")
00056             BEGIN_PARAM_PATH( GetParamPath() )
00057                 PARAM_ENTRY( "@RenameLatency",  m_renameLatency );
00058             END_PARAM_PATH()
00059             BEGIN_PARAM_PATH( GetResultPath() )
00060                 BEGIN_PARAM_PATH( "NumStalledCycles/" )
00061                     RESULT_ENTRY( "@Total",                 m_stallCycles.total )
00062                     RESULT_ENTRY( "@RegDepPredFull",        m_stallCycles.regDepPred )
00063                     RESULT_ENTRY( "@MemDepPredFull",        m_stallCycles.memDepPred )
00064                     RESULT_ENTRY( "@MemOrderManagerFull",   m_stallCycles.memOrderManager )
00065                     RESULT_ENTRY( "@Others",                m_stallCycles.others )
00066                 END_PARAM_PATH()
00067                 RESULT_ENTRY( "@NumRenamedOps", m_numRenamedOps )
00068             END_PARAM_PATH()
00069         END_PARAM_MAP()
00070 
00071         BEGIN_RESOURCE_MAP()
00072             RESOURCE_ENTRY( Core, "core", m_core )
00073             RESOURCE_ENTRY( Thread, "thread", m_thread )
00074             RESOURCE_ENTRY( RegDepPredIF,   "regDepPred",   m_regDepPred )
00075             RESOURCE_ENTRY( MemDepPredIF,   "memDepPred",   m_memDepPred )
00076             RESOURCE_ENTRY( CheckpointMaster, "checkpointMaster", m_checkpointMaster )
00077             RESOURCE_ENTRY( MemOrderManager,  "memOrderManager", m_memOrderManager )
00078             RESOURCE_ENTRY( LatPred,        "latPred",      m_latPred )
00079             RESOURCE_ENTRY( DispatchSteererIF, "steerer", m_steerer )
00080             RESOURCE_SETTER_ENTRY( PipelineNodeIF,  "upperPipelineNode", SetUpperPipelineNode )
00081         END_RESOURCE_MAP()
00082 
00083         Renamer();
00084         virtual ~Renamer();
00085 
00086         virtual void Initialize( InitPhase phase );
00087         virtual void Finalize();
00088 
00089         // --- PipelineNodeIF
00090         virtual void Update();
00091         virtual void Commit( OpIterator op );
00092 
00093         // --- ClockedResourceIF
00094         virtual void Evaluate();
00095 
00096         DispatchSteererIF* GetSteerer() const { return m_steerer; }
00097 
00098         // --- Hook points
00099         
00100         // Prototype: void OnRenameEvaluate( OpIterator );
00101         // A hook point for evaluating a renamed op.
00102         // Ops passed to an attached method do not be 
00103         // renamed when a renamer is stalled.
00104         static HookPoint< Renamer > s_renameEvaluateHook;   
00105 
00106         // Prototype: void OnRenameUpdate( OpIterator );
00107         // A hook point for updating a actually renamed op.
00108         static HookPoint< Renamer > s_renameUpdateHook;
00109 
00110         static HookPoint< Renamer > s_steerHook;
00111 
00112     protected:
00113 
00114         typedef PipelineNodeBase BaseType;
00115 
00116         // l[Opi[z
00117         static const int MAX_RENAMING_OPS = 16;
00118         typedef fixed_sized_buffer<	OpIterator, MAX_RENAMING_OPS, Renamer > RenamingOpArray;
00119 
00120         // The latency of renaming
00121         int m_renameLatency;
00122 
00123         PhysicalResourceArray<RegDepPredIF>       m_regDepPred;     // WX^W 
00124         PhysicalResourceArray<MemDepPredIF>       m_memDepPred;     // W
00125         PhysicalResourceArray<CheckpointMaster>   m_checkpointMaster;
00126         PhysicalResourceArray<MemOrderManager>    m_memOrderManager;
00127 
00128         DispatchSteererIF* m_steerer;
00129         LatPred* m_latPred;
00130 
00131         struct StallCycles
00132         {
00133             s64 total;
00134 
00135             // Stalled by a register dependency predictor, which, it is typically a RMT. 
00136             // Typically, it is caused by the shortage of physical registers.
00137             s64 regDepPred;         
00138             // Stalled by a memory dependency predictor.
00139             s64 memDepPred;         
00140             // Stalled by th shortage of MemOrderManager(LSQ)
00141             s64 memOrderManager;    
00142             s64 others;
00143 
00144             StallCycles():
00145                 total(0), regDepPred(0), memDepPred(0), memOrderManager(0), others(0)
00146             {
00147             }
00148         } m_stallCycles;
00149         s64 m_numRenamedOps;
00150 
00151         // arrayopCo|C^os
00152         void ForEachOp( RenamingOpArray* c, void (Renamer::*func)(OpIterator) );
00153         
00154         template <typename T1>
00155         void ForEachOp1( RenamingOpArray* c, T1 arg1, void (Renamer::*func)(OpIterator, T1) );
00156 
00157         bool CanRename( RenamingOpArray* renamingOps );
00158         // l[s
00159         void Rename( OpIterator );
00160 
00161         // NOPs
00162         void ProcessNOP( OpIterator op );
00163 
00164         // Enter an op to a renmaer pipeline.
00165         // An op is send to a dispatcher automatically when the op exits a renamer pipeline.
00166         // A dispatcher is set to a renmaer by the dispatcher itself in SetUpperPipelineNode
00167         // that calls SetLowerPipelineNode of the renmaer.
00168         void EnterPipeline( OpIterator op );
00169         
00170         // Create an entry of MemOrderManager
00171         void CreateMemOrderManagerEntry( OpIterator op );
00172 
00173         // Process after renaming 
00174         // - Steer ops to schedulers.
00175         // - Predict latency of an op.
00176         //   Latency prediction is done on renaming stages.
00177         void Steer( OpIterator op );
00178 
00179         // l[O checkpoint obNAbv
00180         void BackupOnCheckpoint( OpIterator op, bool before );
00181     };
00182     
00183 }; // namespace Onikiri;
00184 
00185 #endif  // SIM_PIPELINE_RENAMER_RENAMER_H
00186 
00187 

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