src/Sim/Dumper/Dumper.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 __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         // Dump dependencies from producerOp to consumerOp.
00137         // See comments for DUMP_DEPENDENCY_TYPE.
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         // Dump user defined stages.
00149         // See comments for VisualizationDumper::DumpRawStage and DumpLane.
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 }; // namespace Onikiri
00166 
00167 #endif // __DUMPER_H__
00168 

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