src/Sim/Pipeline/Scheduler/Scheduler.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 // Scheduler
00033 // This class schedules ops on processor back-end stages.
00034 // (from wakeup/select to write back).
00035 
00036 
00037 #ifndef SIM_PIPELINE_SCHEDULER_SCHEDULER_H
00038 #define SIM_PIPELINE_SCHEDULER_SCHEDULER_H
00039 
00040 #include "Env/Param/ParamExchange.h"
00041 
00042 #include "Sim/Pipeline/PipelineNodeBase.h"
00043 #include "Sim/Pipeline/Pipeline.h"
00044 #include "Sim/Foundation/Hook/HookUtil.h"
00045 
00046 #include "Sim/Op/OpArray/OpArray.h"
00047 #include "Sim/Op/OpContainer/OpExtraStateTable.h"
00048 #include "Sim/Op/OpContainer/OpBuffer.h"
00049 #include "Sim/Core/DataPredTypes.h"
00050 #include "Sim/Dependency/Dependency.h"
00051 
00052 namespace Onikiri 
00053 {
00054     
00055     struct IssueState;
00056     class Thread;
00057     class LatPred;
00058     class ExecUnitIF;
00059     class IssueSelectorIF;
00060 
00061     class Scheduler :
00062         public PipelineNodeBase
00063     {
00064     public:
00065 
00066         static const int MAX_SCHEDULING_OPS = 4096;
00067         typedef fixed_sized_buffer< OpIterator, MAX_SCHEDULING_OPS, Scheduler > SchedulingOps;
00068         //typedef pool_vector< OpIterator > SchedulingOps;
00069 
00070 
00071         // parameter mapping
00072         BEGIN_PARAM_MAP( GetParamPath() )
00073             PARAM_ENTRY("@Index",           m_index);
00074             PARAM_ENTRY("@IssueWidth",      m_issueWidth);
00075             PARAM_ENTRY("@IssueLatency" ,   m_issueLatency);
00076             PARAM_ENTRY("@WritebackLatency" ,m_writeBackLatency);
00077             PARAM_ENTRY("@CommunicationLatency",    m_communicationLatency);
00078             PARAM_ENTRY("@WindowCapacity",  m_windowCapacity);
00079             BEGIN_PARAM_BINDING(  "@RemovePolicy", m_removePolicyParam, SchedulerRemovePolicy )
00080                 PARAM_BINDING_ENTRY( "Core",    RP_FOLLOW_CORE )
00081                 PARAM_BINDING_ENTRY( "Remove",  RP_REMOVE )
00082                 PARAM_BINDING_ENTRY( "Retain",  RP_RETAIN )
00083                 PARAM_BINDING_ENTRY( "RemoveAfterFinish",   RP_REMOVE_AFTER_FINISH )
00084             END_PARAM_BINDING()
00085         END_PARAM_MAP()
00086 
00087         BEGIN_RESOURCE_MAP()
00088             RESOURCE_ENTRY( Core, "core", m_core )
00089             RESOURCE_ENTRY( Thread, "thread", m_thread )
00090             RESOURCE_SETTER_ENTRY( ExecUnitIF, "execUnits", SetExecUnit )
00091             RESOURCE_ENTRY( IssueSelectorIF, "selector", m_selector )
00092         END_RESOURCE_MAP()
00093 
00094         Scheduler();
00095         virtual ~Scheduler();
00096 
00097         void Initialize(InitPhase phase);
00098 
00099         // code ZZbg
00100         void SetExecUnit( PhysicalResourceArray<ExecUnitIF>& execUnits );
00101 
00102         // code Z
00103         ExecUnitIF* GetExecUnit(int code);
00104 
00105         // PipelineNodeIF
00106         virtual void Begin();
00107         virtual void Evaluate();
00108         virtual void Transition();
00109         virtual void Update();
00110 
00111         virtual void Commit( OpIterator op );
00112         virtual void Cancel( OpIterator op );
00113         virtual void Flush( OpIterator op );
00114         virtual void Retire( OpIterator op );
00115         virtual void ExitUpperPipeline( OpIterator op );
00116 
00117         // Set a dependency satisfied in this cycle.
00118         // This method is called from WakeupEvent::Evaluate().
00119         void EvaluateDependency( OpIterator op );
00120 
00121         // op wake up Cxgo^
00122         void RegisterWakeUpEvent( OpIterator op, int latencyFromOp );   
00123 
00124         // Returns whether 'op' can be selected in this cycle.
00125         // This method must be called only in a 'Evaluate' phase.
00126         bool CanSelect( OpIterator op );
00127 
00128         // Reserves 'op' to select in this cycle.
00129         // This method must be called only in a 'Evaluate' phase.
00130         void ReserveSelect( OpIterator op );
00131 
00132         // issue
00133         void Issue( OpIterator op );
00134 
00135         // Finish
00136         void Finished( OpIterator op );
00137 
00138         // Write Back
00139         void WriteBackBegin( OpIterator op );
00140         void WriteBackEnd( OpIterator op );
00141 
00142 
00143         // Re-schedule an op.
00144         // An op is returned to not issued state (DISPATCHED) and 
00145         // re-dcheduled.
00146         bool Reschedule( OpIterator op );
00147 
00148         // Return whether a scheduler can dispatch 'ops' or not.
00149         bool CanAllocate( int ops );
00150 
00151         // Check whether an op is in this scheduler.
00152         bool IsInScheduler( OpIterator op );
00153 
00154         // accessors
00155         int GetIndex() const            { return m_index;  }
00156         void SetIndex(int index)        { m_index = index; }
00157         const std::vector<ExecUnitIF*>& 
00158             GetExecUnitList() const     { return m_execUnit; }
00159         int GetIssueLatency() const     { return m_issueLatency; }
00160         int GetIssueWidth()   const     { return m_issueWidth; }
00161 
00162         const OpList& GetReadyOps()         const   {   return m_readyOp;       }
00163         const OpList& GetNotReadyOps()      const   {   return m_notReadyOp;    }
00164         const OpBuffer& GetIssuedOps()      const   {   return m_issuedOp;      }
00165         const SchedulingOps& GetWokeUpOps() const   {   return m_evaluated.wokeUp;      } // Woke up ops in this cycle.
00166 
00167 
00168         // Hooks
00169         struct RescheduleHookParam
00170         {
00171             bool canceled;      // If op is canceled, this parameter is set to true.
00172         };
00173 
00174         static HookPoint<Scheduler> s_dispatchedHook;
00175         static HookPoint<Scheduler> s_readySigHook;
00176         static HookPoint<Scheduler> s_wakeUpHook;
00177         static HookPoint<Scheduler> s_selectHook;
00178         static HookPoint<Scheduler> s_issueHook;
00179         static HookPoint<Scheduler, RescheduleHookParam> s_rescheduleHook;
00180 
00181     private:
00182         typedef PipelineNodeBase BaseType;
00183 
00184         OpList      m_notReadyOp;       // readyop
00185         OpList      m_readyOp;          // readyselectop
00186         OpBuffer    m_issuedOp;         // issueop
00187 
00188         struct Evaluated
00189         {
00190             DependencySet   deps;       // Dependencies satisfied in this cycle.
00191                                         // Waking-up is done with these dependencies.
00192             SchedulingOps   wokeUp; // Woke up ios in this cycle.
00193             SchedulingOps   selected;   // Selected ops in this cycle.
00194         } m_evaluated;
00195 
00196         int m_index;                // XPW[
00197         int m_issueWidth;           // s
00198         int m_issueLatency;         // sCeV
00199         int m_writeBackLatency;     // The latency of write back.
00200         std::vector<int> 
00201             m_communicationLatency; // XPW[MCeV
00202         int m_windowCapacity;       // EChETCY
00203 
00204         // Load pipeline model.
00205         // See comments in 'Core.h'
00206         LoadPipelineModel m_loadPipelineModel;
00207 
00208         // Whether forget or retain ops in a scheduler after issue.
00209         SchedulerRemovePolicy m_removePolicyParam;
00210         SchedulerRemovePolicy m_removePolicy;
00211 
00212         // Execution units.
00213         std::vector<ExecUnitIF*> m_execUnit;
00214         std::vector<ExecUnitIF*> m_execUnitCodeMap;
00215 
00216         // Selector
00217         IssueSelectorIF* m_selector;
00218 
00219         // XPW[NX^
00220         struct Cluster
00221         {
00222             Scheduler*   scheduler;
00223             int          issueLatency;          // sCeV
00224             int          communicationLatency;  // XPW[MCeV
00225         };
00226         std::vector<Cluster> m_clusters;
00227 
00228         // Clear evaluated conctext.
00229         void ClearEvaluated();
00230 
00231         // fBXpb`op
00232         void DispatchEnd(OpIterator op);
00233 
00234         // wake up
00235         void EvaluateWakeUp();
00236         void UpdateWakeUp();
00237         void WakeUp(OpIterator op);
00238         void CheckOnWakeUp(OpIterator op);
00239 
00240         // select
00241         void EvaluateSelect();
00242         void UpdateSelect();
00243         void Select(OpIterator op);
00244         void SelectBody(OpIterator op);
00245 
00246         // issue
00247         void IssueBody(OpIterator op);
00248 
00249         // Retire/Flush
00250         void Delete( OpIterator op );
00251 
00252         // XPW[
00253         int GetOpCount();
00254 
00255         // opタsCxgo^
00256         void RegisterExecuteEvent(OpIterator op, int latency);
00257 
00258     };
00259     
00260 }; // namespace Onikiri;
00261 
00262 #endif
00263 

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