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
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef __STREAM_PREFETCHER_H__
00043 #define __STREAM_PREFETCHER_H__
00044
00045 #include "Sim/Memory/Prefetcher/PrefetcherBase.h"
00046 #include "Sim/Memory/Cache/CacheExtraStateTable.h"
00047
00048 namespace Onikiri
00049 {
00050
00051 class StreamPrefetcher : public PrefetcherBase
00052 {
00053 protected:
00054
00055 int m_distance;
00056 int m_degree;
00057 int m_streamTableSize;
00058 int m_trainingWindowSize;
00059 int m_trainingThreshold;
00060
00061 u64 m_effectiveDistance;
00062
00063 u64 m_effectiveTrainingWindow;
00064
00065
00066 s64 m_numAllocatedStream;
00067 s64 m_numMonitioredStream;
00068 s64 m_numAscendingMonitioredStream;
00069 s64 m_numDesscendingMonitioredStream;
00070 double m_numAvgMonitoredStreamLength;
00071 s64 m_numTrainingAccess;
00072 s64 m_numAlocatingAccess;
00073
00074 enum StreamStatus
00075 {
00076 SS_INVALID,
00077 SS_TRAINING,
00078 SS_MONITOR
00079 };
00080
00081 struct Stream
00082 {
00083 StreamStatus status;
00084
00085 Addr orig;
00086 Addr addr;
00087
00088 int count;
00089 bool ascending;
00090
00091 Stream()
00092 {
00093 Reset();
00094 }
00095
00096 void Reset()
00097 {
00098 status = SS_INVALID;
00099 ascending = true;
00100 count = 0;
00101 }
00102
00103 String ToString() const;
00104 };
00105
00106 typedef
00107 shttl::table< Stream >
00108 StreamTable;
00109
00110 StreamTable m_streamTable;
00111
00112
00113 void Prefetch( const CacheAccess& kickerAccess, Stream* stream );
00114
00115
00116
00117 bool IsInWindow( const Addr& addr, const Addr& start, u64 windowSize, bool ascending );
00118 bool IsInWindow( u64 addr, u64 start, u64 windowSize, bool ascending );
00119
00120
00121
00122 bool UpdateMonitorStream( const CacheAccess& access );
00123
00124
00125 bool UpdateTrainingStream( const CacheAccess& access );
00126
00127
00128 void AllocateStream( const CacheAccess& access );
00129
00130 public:
00131
00132 StreamPrefetcher();
00133 ~StreamPrefetcher();
00134
00135
00136 virtual void OnCacheAccess( Cache* cache, const CacheAccess& access, bool hit );
00137
00138
00139 virtual void Initialize(InitPhase phase);
00140
00141 BEGIN_PARAM_MAP("")
00142 BEGIN_PARAM_PATH( GetParamPath() )
00143 PARAM_ENTRY( "@Distance", m_distance );
00144 PARAM_ENTRY( "@Degree", m_degree );
00145 PARAM_ENTRY( "@StreamTableSize", m_streamTableSize );
00146 PARAM_ENTRY( "@TrainingWindowSize", m_trainingWindowSize );
00147 PARAM_ENTRY( "@TrainingThreashold", m_trainingThreshold );
00148 END_PARAM_PATH()
00149 BEGIN_PARAM_PATH( GetResultPath() )
00150 PARAM_ENTRY( "@NumAllocatedStream", m_numAllocatedStream );
00151 PARAM_ENTRY( "@NumMonitioredStream", m_numMonitioredStream );
00152 PARAM_ENTRY( "@NumAscendingMonitioredStream", m_numAscendingMonitioredStream );
00153 PARAM_ENTRY( "@NumDesscendingMonitioredStream", m_numDesscendingMonitioredStream );
00154 PARAM_ENTRY( "@NumAvgMonitoredStreamLength", m_numAvgMonitoredStreamLength );
00155 PARAM_ENTRY( "@NumTrainingAccess", m_numTrainingAccess );
00156 PARAM_ENTRY( "@NumAlocatingAccess", m_numAlocatingAccess );
00157 END_PARAM_PATH()
00158 CHAIN_BASE_PARAM_MAP( PrefetcherBase )
00159 END_PARAM_MAP()
00160
00161 BEGIN_RESOURCE_MAP()
00162 CHAIN_BASE_RESOURCE_MAP( PrefetcherBase )
00163 END_RESOURCE_MAP()
00164 };
00165
00166
00167 };
00168
00169 #endif // __STREAM_PREFETCHER_H__
00170