00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
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
00053 class VisualizationDumper : public ParamExchange
00054 {
00055 public:
00056
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
00066 VisualizationDumper();
00067 ~VisualizationDumper();
00068
00069 void Initialize( const String& suffix, PhysicalResourceArray<Core>& coreList );
00070 void Finalize();
00071 bool IsEnabled();
00072
00073
00074
00075
00076 void SetCurrentCycle( const s64 cycle );
00077 void SetCurrentInsnCount( Thread* thread, const s64 count );
00078
00079
00080 void PrintOpState( OpIterator op, DUMP_STATE state );
00081
00082
00083 void PrintStallBegin( OpIterator op );
00084 void PrintStallEnd ( OpIterator op );
00085
00086
00087
00088 void PrintOpDependency(
00089 const OpIterator producerOp,
00090 const OpIterator consumerOp,
00091 DumpDependency type
00092 );
00093
00094
00095
00096
00097
00098
00099
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
00107 struct OpState
00108 {
00109 DUMP_STATE dumpState;
00110 u64 visSerialID;
00111 bool inPipeline;
00112 bool stalled;
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
00128
00129
00130 struct CoreState
00131 {
00132 OpExtraStateTable<OpState> opState;
00133 };
00134
00135 struct ThreadState
00136 {
00137 s64 retiredInsnCount;
00138 };
00139
00140
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;
00155 bool m_gzipEnabled;
00156 int m_gzipLevel;
00157
00158 std::string m_visFileName;
00159 boost::iostreams::filtering_ostream m_visStream;
00160
00161 s64 m_visCurrentCycle;
00162 s64 m_visLastPrintCycle;
00163 s64 m_skipInsns;
00164
00165 u64 m_visSerialID;
00166
00167
00168 bool IsDumpSkipped( OpIterator op );
00169
00170
00171 const char* ToStringFromDumpState( DUMP_STATE state );
00172
00173
00174
00175 void PrintOpInit( const OpIterator op );
00176 void PrintOpInitLabel( const OpIterator op );
00177
00178
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
00186 void PrintCycle();
00187
00188
00189 void PrintLastPipelineStage( const OpIterator op, DUMP_STATE lastState );
00190
00191
00192 void PrintOpEnd( const OpIterator op, DUMP_STATE lastState );
00193 void PrintOpEndLabel( const OpIterator op );
00194
00195
00196 void PrintNextPipelineStage( const OpIterator op, DUMP_STATE state );
00197
00198
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