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 __DUMPER_H__
00033 #define __DUMPER_H__
00034
00035 #include "Types.h"
00036 #include "Sim/Op/OpArray/OpArray.h"
00037 #include "Sim/Foundation/Resource/ResourceNode.h"
00038 #include "Sim/Dumper/DumpState.h"
00039
00040
00041 namespace Onikiri
00042 {
00043 class Thread;
00044 class TraceDumper;
00045 class CountDumper;
00046 class VisualizationDumper;
00047 class Core;
00048
00049 class Dumper : public ParamExchange
00050 {
00051 struct ThreadDumper
00052 {
00053 TraceDumper* traceDumper;
00054 VisualizationDumper* visDumper;
00055 CountDumper* countDumper;
00056 };
00057
00058 typedef unordered_map<Thread*, ThreadDumper> DumperMap;
00059 typedef std::vector<ThreadDumper> DumperList;
00060 DumperMap m_dumperMap;
00061 DumperList m_dumperList;
00062
00063 bool m_dumpEnabled;
00064 bool m_dumpEachThread;
00065 bool m_dumpEachCore;
00066
00067 void DumpImpl(DUMP_STATE state, OpIterator op, int detail);
00068 void DumpStallBeginImpl(OpIterator op);
00069 void DumpStallEndImpl(OpIterator op);
00070 void SetCurrentCycleImpl( Thread* thread, s64 cycle );
00071 void SetCurrentInsnCountImpl( Thread* thread, s64 count );
00072 void DumpOpDependencyImpl( const OpIterator producerOp, const OpIterator consumerOp, DumpDependency type );
00073 void DumpRawStageImpl( OpIterator op, bool begin, const char*stage, DumpLane lane );
00074 void SetEnabledImpl( bool enabled );
00075
00076 void CreateThreadDumper(
00077 ThreadDumper* threadDumper,
00078 const String& suffix,
00079 PhysicalResourceArray<Core>& coreList
00080 );
00081 void ReleaseDumper();
00082 public:
00083 BEGIN_PARAM_MAP("/Session/Environment/Dumper/")
00084 PARAM_ENTRY("@DumpEachThread", m_dumpEachThread)
00085 PARAM_ENTRY("@DumpEachCore", m_dumpEachCore)
00086 END_PARAM_MAP()
00087
00088 Dumper();
00089 virtual ~Dumper();
00090 void Initialize(
00091 PhysicalResourceArray<Core>& coreList,
00092 PhysicalResourceArray<Thread>& threadList
00093 );
00094 void Finalize();
00095
00096 bool IsEnabled()
00097 {
00098 return m_dumpEnabled;
00099 }
00100
00101 void Dump(DUMP_STATE state, OpIterator op, int detail = -1)
00102 {
00103 if(!m_dumpEnabled)
00104 return;
00105 DumpImpl(state, op, detail);
00106 }
00107
00108 void DumpStallBegin(OpIterator op)
00109 {
00110 if(!m_dumpEnabled)
00111 return;
00112 DumpStallBeginImpl(op);
00113 }
00114
00115 void DumpStallEnd(OpIterator op)
00116 {
00117 if(!m_dumpEnabled)
00118 return;
00119 DumpStallEndImpl(op);
00120 }
00121
00122 void SetCurrentCycle( Thread* thread, s64 cycle )
00123 {
00124 if(!m_dumpEnabled)
00125 return;
00126 SetCurrentCycleImpl( thread, cycle );
00127 }
00128
00129 void SetCurrentInsnCount( Thread* thread, s64 count )
00130 {
00131 if(!m_dumpEnabled)
00132 return;
00133 SetCurrentInsnCountImpl( thread, count );
00134 }
00135
00136
00137
00138 void DumpOpDependency(
00139 const OpIterator producerOp,
00140 const OpIterator consumerOp,
00141 DumpDependency type = DDT_WAKEUP
00142 ){
00143 if(!m_dumpEnabled)
00144 return;
00145 DumpOpDependencyImpl( producerOp, consumerOp, type );
00146 }
00147
00148
00149
00150 void DumpRawStage( OpIterator op, bool begin, const char*stage, DumpLane lane )
00151 {
00152 if(!m_dumpEnabled)
00153 return;
00154 DumpRawStageImpl( op, begin, stage, lane );
00155 }
00156
00157 void SetEnabled( bool enabled )
00158 {
00159 SetEnabledImpl( enabled );
00160 }
00161 };
00162
00163 extern Dumper g_dumper;
00164
00165 };
00166
00167 #endif // __DUMPER_H__
00168