src/Sim/Memory/Cache/CacheSystem.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 //
00033 // A cache system class.
00034 //
00035 
00036 #ifndef SIM_MEMORY_CACHE_CACHE_SYSTEM_H
00037 #define SIM_MEMORY_CACHE_CACHE_SYSTEM_H
00038 
00039 #include "Env/Param/ParamExchange.h"
00040 
00041 #include "Sim/Foundation/Resource/ResourceNode.h"
00042 #include "Sim/Op/OpArray/OpArray.h"
00043 #include "Sim/Memory/Cache/CacheTypes.h"
00044 
00045 namespace Onikiri
00046 {
00047     class Cache;
00048     class Thread;
00049 
00050     class CacheSystem :
00051         public PhysicalResourceNode
00052     {
00053     public:
00054     
00055         BEGIN_PARAM_MAP("")
00056             BEGIN_PARAM_PATH( GetParamPath() )
00057             END_PARAM_PATH()
00058             BEGIN_PARAM_PATH( GetResultPath() )
00059 
00060                 PARAM_ENTRY( "@DataCacheHierarchy",     m_dataCacheHierarchyStr )
00061                 PARAM_ENTRY( "@InsnCacheHierarchy",     m_insnCacheHierarchyStr )
00062 
00063                 // Load instructions
00064                 BEGIN_PARAM_PATH( "Load" )
00065                     PARAM_ENTRY( "@NumStoreForwarding",     m_numRetiredStoreForwarding )
00066                     PARAM_ENTRY( "@NumRetiredLoadAccess",   m_numRetiredLoadAccess )
00067                     PARAM_ENTRY( 
00068                         "@CacheAccessCoverage", 
00069                         m_loadAccessCoverage 
00070                     )
00071                     PARAM_ENTRY( 
00072                         "@CacheAccessDispersion", 
00073                         m_loadAccessDispersion 
00074                     )
00075                     PARAM_ENTRY( "@MissesPerKiloInstructions", m_loadMPKI );
00076                 END_PARAM_PATH()
00077                 
00078                 // Store instructions
00079                 BEGIN_PARAM_PATH( "Store" )
00080                     PARAM_ENTRY( "@NumRetiredStoreAccess",  m_numRetiredStoreAccess )
00081                     PARAM_ENTRY( 
00082                         "@CacheAccessCoverage", 
00083                         m_storeAccessCoverage 
00084                     )
00085                     PARAM_ENTRY( 
00086                         "@CacheAccessDispersion", 
00087                         m_storeAccessDispersion 
00088                     )
00089                     PARAM_ENTRY( "@MissesPerKiloInstructions", m_storeMPKI );
00090                 END_PARAM_PATH()
00091 
00092                 // Load + Store instructions
00093                 BEGIN_PARAM_PATH( "Total" )
00094                     PARAM_ENTRY( "@NumRetiredMemoryAccess", m_numRetiredMemoryAccess )
00095                     PARAM_ENTRY( 
00096                         "@CacheAccessCoverage", 
00097                         m_memoryAccessCoverage 
00098                     )
00099                     PARAM_ENTRY( 
00100                         "@CacheAccessDispersion", 
00101                         m_memoryAccessDispersion 
00102                     )
00103                     PARAM_ENTRY( "@MissesPerKiloInstructions", m_totalMPKI );
00104                 END_PARAM_PATH()
00105             END_PARAM_PATH()
00106         END_PARAM_MAP()
00107 
00108         BEGIN_RESOURCE_MAP()
00109             RESOURCE_ENTRY( Cache,  "firstLevelDataCache",  m_firstLvDataCache )
00110             RESOURCE_ENTRY( Cache,  "firstLevelInsnCache",  m_firstLvInsnCache )
00111             RESOURCE_ENTRY( Thread, "thread",   m_thread   )
00112         END_RESOURCE_MAP()
00113 
00114         CacheSystem();
00115         virtual ~CacheSystem();
00116 
00117         //
00118         // --- PhysicalResourceNode
00119         //
00120         
00121         virtual void Initialize( InitPhase phase );
00122         virtual void Finalize();
00123 
00124         // This method is called when a simulation mode is changed.
00125         virtual void ChangeSimulationMode( PhysicalResourceNode::SimulationMode mode );
00126 
00127         void Commit( OpIterator op );
00128         void Cancel( OpIterator op ){};
00129         void Retire( OpIterator op ){};
00130         void Flush( OpIterator op ){};
00131 
00132         Cache* GetFirstLevelDataCache() const { return m_firstLvDataCache; }
00133         Cache* GetFirstLevelInsnCache() const { return m_firstLvInsnCache; }
00134 
00135     protected:
00136 
00137         Cache*  m_firstLvDataCache;
00138         Cache*  m_firstLvInsnCache;
00139         PhysicalResourceArray<Thread> m_thread;
00140         SimulationMode m_mode;
00141 
00142         // Cache hierarchy information
00143         std::vector< Cache* > m_dataCacheHierarchy;
00144         std::vector< Cache* > m_insnCacheHierarchy;
00145         std::vector< std::string > m_dataCacheHierarchyStr;
00146         std::vector< std::string > m_insnCacheHierarchyStr;
00147 
00148         // Dispersion of where retired load instructions accessed to.
00149         // 0:L1, 1:L2, 2...
00150         std::vector< s64 >    m_loadAccessDispersion;
00151         std::vector< s64 >    m_storeAccessDispersion;
00152         std::vector< s64 >    m_memoryAccessDispersion;
00153 
00154         // The coverage of accesses for each cache hierarchy.
00155         // This is calculated from dispersions.
00156         std::vector< double > m_loadAccessCoverage;
00157         std::vector< double > m_storeAccessCoverage;
00158         std::vector< double > m_memoryAccessCoverage;
00159 
00160         // Miss per kilo instructions.
00161         std::vector< double > m_loadMPKI;
00162         std::vector< double > m_storeMPKI;
00163         std::vector< double > m_totalMPKI;
00164 
00165         s64 m_numRetiredStoreForwarding;
00166         s64 m_numRetiredLoadAccess;
00167         s64 m_numRetiredStoreAccess;
00168         s64 m_numRetiredMemoryAccess;
00169 
00170         // Get cache hierarchy information from a passed top level cache.
00171         void InitCacheHierarchy( 
00172             std::vector< Cache* >* hierarchy, 
00173             std::vector< std::string >* hierarchyStr,
00174             Cache* top 
00175         );
00176         
00177         // Get a cache level in the m_dataCacheHierarcy.
00178         int GetDataCacheLevel( Cache* cache );
00179 
00180         // Calculate coverage from the number of raw accesses.
00181         void CalculateCoverage(
00182             std::vector< double >* coverage, 
00183             const std::vector< s64 >& dispersion 
00184         );
00185 
00186         // Calculate MPKI from the number of raw accesses.
00187         void CalculateMissPerKiloInsns(
00188             std::vector< double >* mpki, 
00189             const std::vector< s64 >& dispersion,
00190             s64 retiredInsns
00191         );
00192     };
00193 
00194 }; // namespace Onikiri
00195 
00196 #endif // SIM_MEMORY_CACHE_CACHE_SYSTEM_H
00197 

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