クラス Onikiri::StreamPrefetcher

#include <StreamPrefetcher.h>

Onikiri::StreamPrefetcherに対する継承グラフ

Inheritance graph
[凡例]
Onikiri::StreamPrefetcherのコラボレーション図

Collaboration graph
[凡例]
すべてのメンバ一覧

Public メソッド

 BEGIN_PARAM_PATH (GetResultPath()) PARAM_ENTRY("@NumAllocatedStream"
 BEGIN_PARAM_PATH (GetParamPath()) PARAM_ENTRY("@Distance"
virtual void Initialize (InitPhase phase)
virtual void OnCacheAccess (Cache *cache, const CacheAccess &access, bool hit)
 PARAM_ENTRY ("@NumAlocatingAccess", m_numAlocatingAccess)
 PARAM_ENTRY ("@NumTrainingAccess", m_numTrainingAccess)
 PARAM_ENTRY ("@NumAvgMonitoredStreamLength", m_numAvgMonitoredStreamLength)
 PARAM_ENTRY ("@NumDesscendingMonitioredStream", m_numDesscendingMonitioredStream)
 PARAM_ENTRY ("@NumAscendingMonitioredStream", m_numAscendingMonitioredStream)
 PARAM_ENTRY ("@NumMonitioredStream", m_numMonitioredStream)
 PARAM_ENTRY ("@TrainingThreashold", m_trainingThreshold)
 PARAM_ENTRY ("@TrainingWindowSize", m_trainingWindowSize)
 PARAM_ENTRY ("@StreamTableSize", m_streamTableSize)
 PARAM_ENTRY ("@Degree", m_degree)
 StreamPrefetcher ()
 ~StreamPrefetcher ()

Public 変数

 m_distance
 m_numAllocatedStream

Protected 型

 SS_INVALID
 SS_MONITOR
 SS_TRAINING
enum  StreamStatus { SS_INVALID, SS_TRAINING, SS_MONITOR }
typedef shttl::table< StreamStreamTable

Protected メソッド

void AllocateStream (const CacheAccess &access)
bool IsInWindow (u64 addr, u64 start, u64 windowSize, bool ascending)
bool IsInWindow (const Addr &addr, const Addr &start, u64 windowSize, bool ascending)
void Prefetch (const CacheAccess &kickerAccess, Stream *stream)
bool UpdateMonitorStream (const CacheAccess &access)
bool UpdateTrainingStream (const CacheAccess &access)

Protected 変数

int m_degree
int m_distance
u64 m_effectiveDistance
u64 m_effectiveTrainingWindow
s64 m_numAllocatedStream
s64 m_numAlocatingAccess
s64 m_numAscendingMonitioredStream
double m_numAvgMonitoredStreamLength
s64 m_numDesscendingMonitioredStream
s64 m_numMonitioredStream
s64 m_numTrainingAccess
StreamTable m_streamTable
int m_streamTableSize
int m_trainingThreshold
int m_trainingWindowSize

構成

struct  Stream

説明

StreamPrefetcher.h51 行で定義されています。


型定義

typedef shttl::table< Stream > Onikiri::StreamPrefetcher::StreamTable [protected]

StreamPrefetcher.h108 行で定義されています。


列挙型

enum Onikiri::StreamPrefetcher::StreamStatus [protected]

列挙型の値:
SS_INVALID 
SS_TRAINING 
SS_MONITOR 

StreamPrefetcher.h74 行で定義されています。

00075         {
00076             SS_INVALID,
00077             SS_TRAINING,    // Including 'Allocated' state as 'trainingCount' == 0.
00078             SS_MONITOR
00079         };


コンストラクタとデストラクタ

StreamPrefetcher::StreamPrefetcher (  ) 

StreamPrefetcher.cpp75 行で定義されています。

参照先 m_degreem_distancem_effectiveDistancem_effectiveTrainingWindowm_numAllocatedStreamm_numAlocatingAccessm_numAscendingMonitioredStreamm_numAvgMonitoredStreamLengthm_numDesscendingMonitioredStreamm_numMonitioredStreamm_numTrainingAccessm_streamTableSizem_trainingThresholdm_trainingWindowSize.

00076 {
00077     m_distance = 0;
00078     m_degree = 0;
00079     m_trainingWindowSize = 0;
00080     m_trainingThreshold = 0;
00081     m_streamTableSize = 0;
00082     m_effectiveDistance = 0;
00083     m_effectiveTrainingWindow = 0;
00084 
00085     m_numMonitioredStream = 0;
00086     m_numAllocatedStream = 0;
00087     m_numTrainingAccess = 0;
00088     m_numAlocatingAccess = 0;
00089                 
00090     m_numAscendingMonitioredStream = 0;
00091     m_numDesscendingMonitioredStream = 0;
00092     
00093     m_numAvgMonitoredStreamLength = 0.0;
00094 }

StreamPrefetcher::~StreamPrefetcher (  ) 

StreamPrefetcher.cpp97 行で定義されています。

参照先 m_numAvgMonitoredStreamLengthm_numMonitioredStreamOnikiri::PrefetcherBase::m_numPrefetchOnikiri::PhysicalResourceNode::ReleaseParam().

00098 {
00099     if( m_numMonitioredStream ){
00100         m_numAvgMonitoredStreamLength = 
00101             (double)m_numPrefetch / (double)m_numMonitioredStream;
00102     }
00103 
00104     ReleaseParam();
00105 }

関数の呼び出しグラフ:


関数

void StreamPrefetcher::AllocateStream ( const CacheAccess access  )  [protected]

StreamPrefetcher.cpp304 行で定義されています。

参照先 Onikiri::StreamPrefetcher::Stream::addrOnikiri::Addr::addressOnikiri::MemAccess::addressOnikiri::StreamPrefetcher::Stream::countOnikiri::g_envm_numAllocatedStreamm_numAlocatingAccessm_streamTableOnikiri::PrefetcherBase::MaskLineOffset()Onikiri::StreamPrefetcher::Stream::origOnikiri::Environment::Print()shttl::table< type, replacer >::replacement_target()SS_TRAININGOnikiri::StreamPrefetcher::Stream::statusOnikiri::StreamPrefetcher::Stream::ToString()Onikiri::Addr::ToString()shttl::table< type, replacer >::touch().

参照元 OnCacheAccess().

00305 {
00306     Addr missAddr = access.address;
00307     missAddr.address = MaskLineOffset( missAddr.address );
00308 
00309     Stream stream;
00310     stream.addr = missAddr;
00311     stream.orig = missAddr;
00312     stream.status = SS_TRAINING;
00313     stream.count = 0;
00314 
00315     int target = (int)m_streamTable.replacement_target();
00316     m_streamTable[ target ] = stream;
00317     m_streamTable.touch( target );
00318     m_numAlocatingAccess++;
00319     m_numAllocatedStream++;
00320 
00321 #ifdef STREAM_PREFETCHER_DEBUG
00322     g_env.Print( ( String( "  alloc\t" ) + missAddr.ToString() + " " + stream.ToString() + "\n" ).c_str() );
00323 #endif
00324 }

関数の呼び出しグラフ:

Here is the caller graph for this function:

Onikiri::StreamPrefetcher::BEGIN_PARAM_PATH ( GetResultPath()   ) 

Onikiri::PrefetcherBaseを再定義しています。

Onikiri::StreamPrefetcher::BEGIN_PARAM_PATH ( GetParamPath()   ) 

Onikiri::PrefetcherBaseを再定義しています。

void StreamPrefetcher::Initialize ( InitPhase  phase  )  [virtual]

Onikiri::PrefetcherBaseを再定義しています。

StreamPrefetcher.cpp109 行で定義されています。

参照先 shttl::table< type, replacer >::construct()Onikiri::PhysicalResourceNode::INIT_POST_CONNECTIONOnikiri::PhysicalResourceNode::INIT_PRE_CONNECTIONOnikiri::PrefetcherBase::Initialize()Onikiri::ParamExchange::LoadParam()m_distancem_effectiveDistancem_effectiveTrainingWindowOnikiri::PrefetcherBase::m_lineSizem_streamTablem_streamTableSizem_trainingWindowSize.

00110 {
00111     PrefetcherBase::Initialize( phase );
00112 
00113     if(phase == INIT_PRE_CONNECTION){
00114         
00115         LoadParam();
00116 
00117         // Setup remaining members from loaded parameters.
00118         m_streamTable.construct( m_streamTableSize );
00119         m_effectiveDistance = m_distance * m_lineSize;
00120         m_effectiveTrainingWindow = m_lineSize * m_trainingWindowSize;
00121 
00122     }
00123     else if(phase == INIT_POST_CONNECTION){
00124     
00125     }
00126 }

関数の呼び出しグラフ:

bool StreamPrefetcher::IsInWindow ( u64  addr,
u64  start,
u64  windowSize,
bool  ascending 
) [protected]

StreamPrefetcher.cpp132 行で定義されています。

00133 {
00134     if( ascending ){
00135         return ( start <= addr && addr < start + windowSize );
00136     }
00137     else{
00138         return ( start - windowSize <= addr && addr < start );
00139     }
00140 }

bool StreamPrefetcher::IsInWindow ( const Addr addr,
const Addr start,
u64  windowSize,
bool  ascending 
) [protected]

StreamPrefetcher.cpp143 行で定義されています。

参照先 Onikiri::Addr::addressOnikiri::PrefetcherBase::MaskLineOffset()Onikiri::LogicalData::pid.

参照元 UpdateMonitorStream()UpdateTrainingStream().

00144 {
00145     if( addr.pid != start.pid )
00146         return false;
00147     
00148     u64 rawAddr  = MaskLineOffset( addr.address  );
00149     u64 rawStart = MaskLineOffset( start.address );
00150     return IsInWindow( rawAddr, rawStart, windowSize, ascending );
00151 }

関数の呼び出しグラフ:

Here is the caller graph for this function:

void StreamPrefetcher::OnCacheAccess ( Cache cache,
const CacheAccess access,
bool  hit 
) [virtual]

Onikiri::PrefetcherBaseを実装しています。

StreamPrefetcher.cpp328 行で定義されています。

参照先 Onikiri::MemAccess::addressAllocateStream()Onikiri::g_envOnikiri::PrefetcherBase::m_enabledOnikiri::Environment::Print()Onikiri::Addr::ToString()UpdateMonitorStream()UpdateTrainingStream().

00332  {
00333     if( !m_enabled ){
00334         return;
00335     }
00336 
00337 #ifdef STREAM_PREFETCHER_DEBUG
00338     g_env.Print( ( String( "access\t" ) + access.address.ToString() + "\n" ).c_str() );
00339 #endif
00340 
00341     bool streamTableHit = false;
00342 
00343     // Update monitor streams.
00344     if( UpdateMonitorStream( access ) ){
00345         streamTableHit = true;
00346     }
00347 
00348     // Training and allocation are done by a cache missed access only.
00349     if( hit ){
00350         return;
00351     }
00352 
00353     // Update training streams.
00354     if( UpdateTrainingStream( access ) ){   
00355         streamTableHit = true;
00356     }
00357 
00358     // Allocate a new stream.
00359     if( !streamTableHit ){
00360         AllocateStream( access );
00361     }
00362 }

関数の呼び出しグラフ:

Onikiri::StreamPrefetcher::PARAM_ENTRY ( "@NumAlocatingAccess"  ,
m_numAlocatingAccess   
)

Onikiri::StreamPrefetcher::PARAM_ENTRY ( "@NumTrainingAccess"  ,
m_numTrainingAccess   
)

Onikiri::StreamPrefetcher::PARAM_ENTRY ( "@NumAvgMonitoredStreamLength"  ,
m_numAvgMonitoredStreamLength   
)

Onikiri::StreamPrefetcher::PARAM_ENTRY ( "@NumDesscendingMonitioredStream"  ,
m_numDesscendingMonitioredStream   
)

Onikiri::StreamPrefetcher::PARAM_ENTRY ( "@NumAscendingMonitioredStream"  ,
m_numAscendingMonitioredStream   
)

Onikiri::StreamPrefetcher::PARAM_ENTRY ( "@NumMonitioredStream"  ,
m_numMonitioredStream   
)

Onikiri::StreamPrefetcher::PARAM_ENTRY ( "@TrainingThreashold"  ,
m_trainingThreshold   
)

Onikiri::StreamPrefetcher::PARAM_ENTRY ( "@TrainingWindowSize"  ,
m_trainingWindowSize   
)

Onikiri::StreamPrefetcher::PARAM_ENTRY ( "@StreamTableSize"  ,
m_streamTableSize   
)

Onikiri::StreamPrefetcher::PARAM_ENTRY ( "@Degree"  ,
m_degree   
)

void StreamPrefetcher::Prefetch ( const CacheAccess kickerAccess,
Stream stream 
) [protected]

StreamPrefetcher.cpp155 行で定義されています。

参照先 Onikiri::StreamPrefetcher::Stream::addrOnikiri::Addr::addressOnikiri::StreamPrefetcher::Stream::ascendingOnikiri::g_envOnikiri::PrefetcherBase::IncrementPrefetchNum()m_degreem_effectiveDistanceOnikiri::PrefetcherBase::m_lineSizeOnikiri::CacheAccess::opOnikiri::CacheAccess::OT_PREFETCHOnikiri::PrefetcherBase::Prefetch()Onikiri::Environment::Print().

参照元 UpdateMonitorStream().

00156 {
00157     for( int i = 0; i < m_degree; i++ ){
00158 
00159         CacheAccess prefetch;
00160         prefetch.op = kickerAccess.op;
00161         prefetch.type = CacheAccess::OT_PREFETCH;
00162         
00163         // Prefetch 'end' point of a window.
00164         prefetch.address = stream->addr;
00165         if( stream->ascending )
00166             prefetch.address.address += m_effectiveDistance;
00167         else
00168             prefetch.address.address -= m_effectiveDistance;
00169 
00170         PrefetcherBase::Prefetch( prefetch );
00171         //m_prefetchTarget->Read( prefetch, NULL );
00172 
00173 #ifdef STREAM_PREFETCHER_DEBUG
00174         g_env.Print( ( String( "  prefetch\t" ) + prefetch.address.ToString() + "\n" ).c_str() );
00175 #endif
00176 
00177         // Update a stream
00178         stream->addr.address += 
00179             stream->ascending ? m_lineSize : -m_lineSize;
00180 
00181     }
00182 
00183     IncrementPrefetchNum();
00184 }

関数の呼び出しグラフ:

Here is the caller graph for this function:

bool StreamPrefetcher::UpdateMonitorStream ( const CacheAccess access  )  [protected]

StreamPrefetcher.cpp189 行で定義されています。

参照先 Onikiri::Addr::addressOnikiri::MemAccess::addressOnikiri::g_envIsInWindow()m_effectiveDistancem_streamTableOnikiri::PrefetcherBase::MaskLineOffset()Prefetch()Onikiri::Environment::Print()shttl::table< type, replacer >::size()SS_MONITORshttl::table< type, replacer >::touch().

参照元 OnCacheAccess().

00190 {
00191     Addr missAddr = access.address;
00192     missAddr.address = MaskLineOffset( missAddr.address );
00193 
00194     // Monitor
00195     for( size_t i = 0; i < m_streamTable.size(); i++ ){
00196         Stream* stream = &m_streamTable[i];
00197         if( stream->status != SS_MONITOR )
00198             continue;
00199 
00200         // Check a missed address is in a prefetch window.
00201         if( !IsInWindow( missAddr, stream->addr, m_effectiveDistance, stream->ascending ) ){
00202             continue;
00203         }
00204 
00205 #ifdef STREAM_PREFETCHER_DEBUG
00206         g_env.Print( 
00207             ( String( "  monitor\t" ) + stream->ToString() + "\n" ).c_str() 
00208             );
00209 #endif
00210 
00211         // Prefetch
00212         // Note: The 'Prefetch' method may update a entry in the stream table.
00213         Prefetch( access, stream );
00214 
00215         // Update the table
00216         m_streamTable.touch( i );
00217         stream->count++;
00218 
00219         return true; // A prefetch process is finished.
00220     }
00221 
00222     return false;
00223 }

関数の呼び出しグラフ:

Here is the caller graph for this function:

bool StreamPrefetcher::UpdateTrainingStream ( const CacheAccess access  )  [protected]

StreamPrefetcher.cpp227 行で定義されています。

参照先 Onikiri::Addr::addressOnikiri::MemAccess::addressOnikiri::g_envIsInWindow()m_effectiveTrainingWindowm_numAscendingMonitioredStreamm_numDesscendingMonitioredStreamm_numMonitioredStreamm_numTrainingAccessm_streamTablem_trainingThresholdOnikiri::PrefetcherBase::MaskLineOffset()Onikiri::Environment::Print()shttl::table< type, replacer >::size()SS_MONITORSS_TRAININGOnikiri::Addr::ToString()shttl::table< type, replacer >::touch().

参照元 OnCacheAccess().

00228 {
00229     Addr missAddr = access.address;
00230     missAddr.address = MaskLineOffset( missAddr.address );
00231 
00232     for( size_t i = 0; i < m_streamTable.size(); i++ ){
00233         Stream* stream = &m_streamTable[i];
00234         if( stream->status != SS_TRAINING )
00235             continue;
00236 
00237         u64 window = m_effectiveTrainingWindow;
00238         const Addr& start = stream->orig;
00239 
00240         // Check a missed address is in a training window.
00241         bool inWindow  = false;
00242         bool ascending = false;
00243         if( IsInWindow( missAddr, start, window, true ) ){
00244             inWindow  = true;
00245             ascending = true;
00246         }
00247         else if( IsInWindow( missAddr, start, window, false ) ){
00248             inWindow  = true;
00249             ascending = false;
00250         }
00251 
00252         if( !inWindow )
00253             continue;
00254 
00255 #ifdef STREAM_PREFETCHER_DEBUG
00256         g_env.Print( ( String( "  train\t" ) + missAddr.ToString() + " " + stream->ToString() + "\n" ).c_str() );
00257 #endif
00258 
00259         // Decide a stream direction of a stream when 
00260         // an access is a first access (stream->count == 0)
00261         // in a training mode.
00262         if( stream->count == 0 ){
00263             stream->ascending = ascending;
00264         }
00265 
00266         if( stream->ascending == ascending ){
00267             // Update the training count.
00268             stream->count++;
00269         }
00270         else{
00271             // Reset a counter and a direction flag.
00272             stream->ascending = ascending;
00273             stream->count = 0;
00274             continue;   // A prefetch process is continued.
00275         }
00276 
00277         // State transition to MONITOR status.
00278         if( stream->count >= m_trainingThreshold ){
00279             stream->status = SS_MONITOR;
00280             m_numMonitioredStream++;
00281             if( ascending )
00282                 m_numAscendingMonitioredStream++;
00283             else
00284                 m_numDesscendingMonitioredStream++;
00285 
00286 #ifdef STREAM_PREFETCHER_DEBUG
00287             g_env.Print( ( String( "  to monitor\t" ) + missAddr.ToString() + " " + stream->ToString() + "\n" ).c_str() );
00288 #endif
00289         }
00290 
00291         // Training
00292         m_numTrainingAccess++;
00293         m_streamTable.touch( i );
00294         //stream->addr = missAddr;
00295 
00296         return true; // A prefetch process is finished.
00297     }
00298 
00299     return false;
00300 }

関数の呼び出しグラフ:

Here is the caller graph for this function:


変数

int Onikiri::StreamPrefetcher::m_degree [protected]

StreamPrefetcher.h56 行で定義されています。

参照元 Prefetch()StreamPrefetcher().

Onikiri::StreamPrefetcher::m_distance

StreamPrefetcher.h143 行で定義されています。

int Onikiri::StreamPrefetcher::m_distance [protected]

StreamPrefetcher.h55 行で定義されています。

参照元 Initialize()StreamPrefetcher().

u64 Onikiri::StreamPrefetcher::m_effectiveDistance [protected]

StreamPrefetcher.h61 行で定義されています。

参照元 Initialize()Prefetch()StreamPrefetcher()UpdateMonitorStream().

u64 Onikiri::StreamPrefetcher::m_effectiveTrainingWindow [protected]

StreamPrefetcher.h63 行で定義されています。

参照元 Initialize()StreamPrefetcher()UpdateTrainingStream().

Onikiri::StreamPrefetcher::m_numAllocatedStream

StreamPrefetcher.h150 行で定義されています。

s64 Onikiri::StreamPrefetcher::m_numAllocatedStream [protected]

StreamPrefetcher.h66 行で定義されています。

参照元 AllocateStream()StreamPrefetcher().

s64 Onikiri::StreamPrefetcher::m_numAlocatingAccess [protected]

StreamPrefetcher.h72 行で定義されています。

参照元 AllocateStream()StreamPrefetcher().

s64 Onikiri::StreamPrefetcher::m_numAscendingMonitioredStream [protected]

StreamPrefetcher.h68 行で定義されています。

参照元 StreamPrefetcher()UpdateTrainingStream().

double Onikiri::StreamPrefetcher::m_numAvgMonitoredStreamLength [protected]

StreamPrefetcher.h70 行で定義されています。

参照元 StreamPrefetcher()~StreamPrefetcher().

s64 Onikiri::StreamPrefetcher::m_numDesscendingMonitioredStream [protected]

StreamPrefetcher.h69 行で定義されています。

参照元 StreamPrefetcher()UpdateTrainingStream().

s64 Onikiri::StreamPrefetcher::m_numMonitioredStream [protected]

StreamPrefetcher.h67 行で定義されています。

参照元 StreamPrefetcher()UpdateTrainingStream()~StreamPrefetcher().

s64 Onikiri::StreamPrefetcher::m_numTrainingAccess [protected]

StreamPrefetcher.h71 行で定義されています。

参照元 StreamPrefetcher()UpdateTrainingStream().

StreamTable Onikiri::StreamPrefetcher::m_streamTable [protected]

StreamPrefetcher.h110 行で定義されています。

参照元 AllocateStream()Initialize()UpdateMonitorStream()UpdateTrainingStream().

int Onikiri::StreamPrefetcher::m_streamTableSize [protected]

StreamPrefetcher.h57 行で定義されています。

参照元 Initialize()StreamPrefetcher().

int Onikiri::StreamPrefetcher::m_trainingThreshold [protected]

StreamPrefetcher.h59 行で定義されています。

参照元 StreamPrefetcher()UpdateTrainingStream().

int Onikiri::StreamPrefetcher::m_trainingWindowSize [protected]

StreamPrefetcher.h58 行で定義されています。

参照元 Initialize()StreamPrefetcher().


このクラスの説明は次のファイルから生成されました:
Onikiri2に対してTue Jun 18 15:21:43 2013に生成されました。  doxygen 1.4.7