src/Sim/Dumper/VisualizationDumper.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_DUMPER_VISUALIZATION_DUMPER_H
00033 #define SIM_DUMPER_VISUALIZATION_DUMPER_H
00034 
00035 #include <fstream>
00036 #include <string>
00037 
00038 #include "Utility/String.h"
00039 
00040 #include "Sim/Op/OpArray/OpArray.h"
00041 #include "Sim/Op/OpContainer/OpExtraStateTable.h"
00042 #include "Sim/Foundation/Resource/ResourceNode.h"
00043 
00044 #include "Env/Param/ParamExchange.h"
00045 #include "Sim/Dumper/DumpState.h"
00046 
00047 namespace Onikiri
00048 {
00049     class Core;
00050     class Thread;
00051 
00052     // simulationVisualizeNX
00053     class VisualizationDumper : public ParamExchange
00054     {
00055     public:
00056         // parameter mapping
00057         BEGIN_PARAM_MAP( "/Session/Environment/Dumper/VisualizationDumper/" )
00058             PARAM_ENTRY( "@FileName",   m_visFileName )
00059             PARAM_ENTRY( "@EnableDump", m_enabled )
00060             PARAM_ENTRY( "@EnableGzip", m_gzipEnabled )
00061             PARAM_ENTRY( "@GzipLevel",  m_gzipLevel )
00062             PARAM_ENTRY( "@SkipInsns",  m_skipInsns )
00063         END_PARAM_MAP()
00064 
00065         // constructor/destructor
00066         VisualizationDumper();
00067         ~VisualizationDumper();
00068 
00069         void Initialize( const String& suffix, PhysicalResourceArray<Core>& coreList );
00070         void Finalize();
00071         bool IsEnabled();
00072 
00073         // VisDumpO
00074 
00075         // VisualizationDumpercycle/insn
00076         void SetCurrentCycle( const s64 cycle );
00077         void SetCurrentInsnCount( Thread* thread, const s64 count );
00078 
00079         // opState(PipelineStage/Retire/Flush)\ヲ
00080         void PrintOpState( OpIterator op, DUMP_STATE state );
00081 
00082         // Dump the begin/end of stall.
00083         void PrintStallBegin( OpIterator op );
00084         void PrintStallEnd  ( OpIterator op );
00085 
00086         // Print dependency arrows from producerOp to consumerOp.
00087         // This method is typically used for printing wakeup.
00088         void PrintOpDependency(
00089             const OpIterator producerOp, 
00090             const OpIterator consumerOp, 
00091             DumpDependency type 
00092         );
00093 
00094         // Print user defined stages. 
00095         // See comments for DumpLane.
00096         //   op:    Dumped op.
00097         //   begin: The stage is begun or not.
00098         //   stage: User defined stage string.
00099         //   lane:  A lane of the stage.
00100         void PrintRawOutput( OpIterator op, bool begin, const char* stage, DumpLane lane );
00101 
00102     private:
00103         
00104         static const u64 INVALID_VIS_SERIAL = ~((u64)0);
00105         
00106         // Each op has OpState, a extra state for dump.
00107         struct OpState 
00108         {
00109             DUMP_STATE dumpState;   // OpState
00110             u64 visSerialID;        // ot@CVA
00111             bool inPipeline;        // iKanata\ヲ\jpCvC
00112             bool stalled;           // Op is stalled or not.
00113 
00114             struct Stage
00115             {
00116                 bool in;
00117                 std::string name;
00118                 Stage() : in(false)
00119                 {
00120                 }
00121             };
00122             std::map< DumpLane, Stage > lastRawStages;
00123 
00124             OpState();
00125         };
00126 
00127         // OpState can be retrieved from CoreState like the following:
00128         // GetOpState() or 
00129         // m_coreStateTable[ op->GetCore() ]->opState[ op ]
00130         struct CoreState
00131         {
00132             OpExtraStateTable<OpState> opState;
00133         };
00134 
00135         struct ThreadState
00136         {
00137             s64 retiredInsnCount;
00138         };
00139         
00140         // Each core/thread has extra information for dump.
00141         typedef unordered_map< Core*, CoreState >       CoreStateMap;
00142         typedef unordered_map< Thread*, ThreadState >   ThreadStateMap;
00143         CoreStateMap    m_coreStateTable; 
00144         ThreadStateMap  m_threadStateTable;
00145 
00146         OpState*   GetOpState( OpIterator op );
00147         DUMP_STATE GetLastState( OpIterator op );
00148         void SetLastState  ( OpIterator op, DUMP_STATE state );
00149         u64  GetVisSerialID( OpIterator op );
00150         void SetVisSerialID( OpIterator op, u64 visSerialID );
00151         
00152         s64 GetTotalRetiredInsnCount();
00153 
00154         bool m_enabled;     // VisDump
00155         bool m_gzipEnabled; // VisDumpgzipk
00156         int  m_gzipLevel;   // gzipkx
00157 
00158         std::string m_visFileName; // visDumpot@C
00159         boost::iostreams::filtering_ostream m_visStream;    // visDumpot@CXg[
00160 
00161         s64 m_visCurrentCycle;  // V~[^
00162         s64 m_visLastPrintCycle;
00163         s64 m_skipInsns;        // The count of insns for skipping dump.
00164 
00165         u64 m_visSerialID;      // Ot@CVAID
00166 
00167         // _vXLbv
00168         bool IsDumpSkipped( OpIterator op );
00169 
00170         // DUMP_STATE <> \ヲ
00171         const char* ToStringFromDumpState( DUMP_STATE state );
00172 
00173         // Print initialization of 'op'.
00174         // PrintOpInitLabel is only called from PrintOpInit.
00175         void PrintOpInit( const OpIterator op );
00176         void PrintOpInitLabel( const OpIterator op );
00177 
00178         // Print a label text.
00179         enum OpLabelType{
00180             POLT_LABEL  = 0,
00181             POLT_DETAIL = 1
00182         };
00183         void PrintOpLabel( const OpIterator op, OpLabelType type, const std::string& label );
00184 
00185         // TCN\ヲ
00186         void PrintCycle();
00187 
00188         // opOPipelineStageo\ヲ
00189         void PrintLastPipelineStage( const OpIterator op, DUMP_STATE lastState );
00190 
00191         // opRetire/Flush\ヲ
00192         void PrintOpEnd( const OpIterator op, DUMP_STATE lastState );
00193         void PrintOpEndLabel( const OpIterator op );
00194 
00195         // opVPipelineStage\ヲ
00196         void PrintNextPipelineStage( const OpIterator op, DUMP_STATE state );
00197         
00198         // Print stall states.
00199         void PrintStallBody( const OpIterator op, bool stall );
00200         void PrintStall( const OpIterator op, bool stall );
00201 
00202     };
00203 
00204 };
00205 
00206 #endif //SIM_DUMPER_VIS_DUMPER_H
00207 
00208 

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