src/Sim/Memory/Prefetcher/StridePrefetcher.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 // Stride prefetcher implementation.
00034 //
00035 
00036 #ifndef SIM_MEMORY_PREFETCHER_STRIDE_PREFETCHER_H
00037 #define SIM_MEMORY_PREFETCHER_STRIDE_PREFETCHER_H
00038 
00039 #include "Sim/Memory/Prefetcher/PrefetcherBase.h"
00040 #include "Sim/Memory/Cache/CacheExtraStateTable.h"
00041 
00042 namespace Onikiri
00043 {
00044     
00045     class StridePrefetcher : public PrefetcherBase
00046     {
00047         int m_distance;
00048         int m_degree;
00049         int m_streamTableSize;
00050 
00051         // Statistics
00052         s64 m_numPrefetchingStream;
00053         double m_numAvgPrefetchStreamLength;
00054 
00055         enum StreamStatus
00056         {
00057             SS_INVALID,
00058             SS_ALLOCATED,
00059             SS_PREFETCHING
00060         };
00061 
00062         // A confidence counter has hysteresis characteristics.
00063         static const int CONFIDENCE_INIT = 0;
00064         static const int CONFIDENCE_MIN  = 0;
00065         static const int CONFIDENCE_MAX  = 7;
00066         static const int CONFIDENCE_INC  = 1;
00067         static const int CONFIDENCE_DEC  = 4;
00068         static const int CONFIDENCE_PREDICTION_THREASHOLD = 7;
00069 
00070         // stride access stream
00071         struct Stream
00072         {
00073             StreamStatus status;    // Stream status
00074 
00075             Addr pc;        // An address of an instruction that begins a stream.
00076 
00077             Addr orig;      // An first accessed address of a stride 
00078             Addr addr;      // A current address of a stream 
00079             s64  stride;    // A stride 
00080 
00081             int  count;                 // Access count of this stream.
00082             int  streamLength;          // The length of stride access stream.
00083             shttl::counter<> confidence;    // Prediction confidence.
00084 
00085             Stream()
00086             {
00087                 Reset();
00088                 confidence.set(
00089                     CONFIDENCE_INIT,
00090                     CONFIDENCE_MIN,
00091                     CONFIDENCE_MAX,
00092                     CONFIDENCE_INC,
00093                     CONFIDENCE_DEC,
00094                     CONFIDENCE_PREDICTION_THREASHOLD
00095                 );
00096             }
00097 
00098             void Reset()
00099             {
00100                 status = SS_INVALID;
00101                 stride = 0;
00102 
00103                 count = 0;
00104                 streamLength = 0;
00105                 confidence.reset();
00106             }
00107 
00108             String ToString() const;
00109         };
00110 
00111         typedef 
00112             shttl::table< Stream > 
00113             StreamTable;
00114 
00115         StreamTable m_streamTable;
00116 
00117         // Do prefetch an address specified by a stream and update a stream. 
00118         void Prefetch( OpIterator op, Stream* stream );
00119 
00120     public:
00121         
00122         StridePrefetcher();
00123         ~StridePrefetcher();
00124 
00125         // --- PrefetcherIF
00126         virtual void OnCacheAccess( Cache* cache, const CacheAccess& access, bool hit );
00127 
00128         // --- PhysicalResourceNode
00129         virtual void Initialize(InitPhase phase);
00130 
00131         BEGIN_PARAM_MAP("")
00132             BEGIN_PARAM_PATH( GetParamPath() )
00133                 PARAM_ENTRY( "@Distance",        m_distance );
00134                 PARAM_ENTRY( "@Degree",          m_degree );
00135                 PARAM_ENTRY( "@StreamTableSize", m_streamTableSize );
00136             END_PARAM_PATH()
00137             BEGIN_PARAM_PATH( GetResultPath() )
00138                 PARAM_ENTRY( "@NumPrefetchingStream",   m_numPrefetchingStream );
00139                 PARAM_ENTRY( "@NumAvgPrefetchStreamLength", m_numAvgPrefetchStreamLength );
00140             END_PARAM_PATH()
00141             CHAIN_BASE_PARAM_MAP( PrefetcherBase )
00142         END_PARAM_MAP()
00143 
00144         BEGIN_RESOURCE_MAP()
00145             CHAIN_BASE_RESOURCE_MAP( PrefetcherBase )
00146         END_RESOURCE_MAP()
00147     };
00148 
00149 
00150 }; // namespace Onikiri
00151 
00152 #endif // SIM_MEMORY_PREFETCHER_STRIDE_PREFETCHER_H
00153 

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