src/Sim/Pipeline/Dispatcher/Dispatcher.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_DISPATCHER_DISPATCHER_H
00033 #define SIM_PIPELINE_DISPATCHER_DISPATCHER_H
00034 
00035 #include "Env/Param/ParamExchange.h"
00036 #include "Sim/Pipeline/PipelineNodeBase.h"
00037 #include "Sim/Op/OpContainer/OpExtraStateTable.h"
00038 #include "Sim/Op/OpContainer/OpList.h"
00039 #include "Sim/Foundation/Hook/HookDecl.h"
00040 #include "Utility/Collection/fixed_size_buffer.h"
00041 
00042 namespace Onikiri 
00043 {
00044 
00045     class Scheduler;
00046     class DispatchSteererIF;
00047 
00048     class Dispatcher:
00049         public PipelineNodeBase
00050     {
00051         
00052     public:
00053         // An array of the numbers of dispatching ops.
00054         // Each array element corresponds to each scheduler.
00055         static const int MAX_SCHEDULER_NUM = 8;
00056         typedef 
00057             fixed_sized_buffer< int, MAX_SCHEDULER_NUM, Dispatcher >
00058             DispatchingOpNums;
00059 
00060         BEGIN_PARAM_MAP("")
00061 
00062             BEGIN_PARAM_PATH( GetParamPath() )
00063                 PARAM_ENTRY( "@DispatchLatency", m_dispatchLatency );
00064             END_PARAM_PATH()
00065 
00066             BEGIN_PARAM_PATH( GetResultPath() )
00067                 BEGIN_PARAM_PATH( "NumStalledCycles/" )
00068                     RESULT_ENTRY( "@Total",         GetStalledCycles() )
00069                     RESULT_ENTRY( "@SchedulerFull", m_stallCylcles )
00070                 END_PARAM_PATH()
00071                 RESULT_ENTRY( "@SchedulerName", m_schedulerName )
00072                 RESULT_ENTRY( "@NumDispatchedOps",  m_numDispatchedOps )
00073                 
00074                 // CHAIN_PARAM_MAP can treat 'std::vector<SchedulerInfo>'
00075                 CHAIN_PARAM_MAP( "Scheduler", m_schedInfo ) 
00076             END_PARAM_PATH()
00077 
00078         END_PARAM_MAP()
00079 
00080         BEGIN_RESOURCE_MAP()
00081             RESOURCE_ENTRY( Core,   "core",   m_core )
00082             RESOURCE_ENTRY( Thread, "thread", m_thread )
00083             RESOURCE_SETTER_ENTRY(
00084                 PipelineNodeIF, "upperPipelineNode", SetUpperPipelineNode 
00085             )
00086         END_RESOURCE_MAP()
00087 
00088         Dispatcher();
00089         virtual ~Dispatcher();
00090 
00091         // PipelineNodeBase
00092         virtual void Initialize( InitPhase phase );
00093         virtual void Finalize();
00094 
00095         virtual void Evaluate();
00096         virtual void Update();
00097         virtual void ExitLowerPipeline( OpIterator op );
00098         
00099         virtual void Retire( OpIterator op );
00100         virtual void Flush( OpIterator op );
00101 
00102         // Accessors
00103         int GetDispatchLatency() const { return m_dispatchLatency; }
00104 
00105         //
00106         // --- Hook
00107         //
00108 
00109         struct DispatchHookParam
00110         {
00111             // The number of dispatching ops;
00112             const DispatchingOpNums* dispatchingOps;
00113             
00114             // It this flag is false, a corresponding op is not dispatched.
00115             bool dispatch;
00116         };
00117 
00118         // Prototype: void OnDispatchEvaluate( OpIterator, DispatchHookParam );
00119         // A hook point for evaluating a dispatched op.
00120         // Ops passed to an attached method are not dispatched
00121         // when a dispatcher is stalled.
00122         static HookPoint<Dispatcher, DispatchHookParam> s_dispatchEvaluateHook;
00123 
00124         // Prototype: void OnDispatchUpdate( OpIterator );
00125         // A hook point for updating an actually dispatched op.
00126         static HookPoint<Dispatcher, DispatchHookParam> s_dispatchUpdateHook;
00127 
00128 
00129     protected:
00130 
00131         typedef PipelineNodeBase BaseType;
00132 
00133         struct SchedulerInfo : public ParamExchangeChild
00134         {
00135             int index;
00136             s64 saturateCount;
00137             Scheduler* scheduler;
00138             OpList dispatchingOps;
00139             s64 numDispatchedOps;
00140 
00141             SchedulerInfo();
00142 
00143             BEGIN_PARAM_MAP( "" )
00144             END_PARAM_MAP()
00145         };
00146 
00147         int m_numScheduler;
00148         int m_dispatchLatency;
00149 
00150         std::vector< SchedulerInfo > m_schedInfo;
00151         std::vector< s64 > m_stallCylcles;
00152         std::vector< s64 > m_numDispatchedOps;
00153         std::vector< std::string > m_schedulerName;
00154 
00155         SchedulerInfo* GetSchedulerInfo( OpIterator op );
00156         void Dispatch( OpIterator op );
00157         void Delete( OpIterator op, bool flush );
00158     };
00159     
00160 }; // namespace Onikiri;
00161 
00162 #endif // SIM_PIPELINE_DISPATCHER_DISPATCHER_H
00163 

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