src/Sim/Predictor/DepPred/MemDepPred/ConservativeMemDepPred.cpp

説明を見る。
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 #include <pch.h>
00033 
00034 #include "Sim/Predictor/DepPred/MemDepPred/ConservativeMemDepPred.h"
00035 #include "Sim/Op/Op.h"
00036 #include "Sim/Core/Core.h"
00037 
00038 
00039 using namespace std;
00040 using namespace boost;
00041 using namespace Onikiri;
00042 
00043 ConservativeMemDepPred::ConservativeMemDepPred() :
00044     m_core(0),
00045     m_checkpointMaster(0),
00046     m_latestStoreDst(),
00047     m_latestMemDst()
00048 {
00049 }
00050 
00051 ConservativeMemDepPred::~ConservativeMemDepPred()
00052 {
00053     ReleaseParam();
00054 }
00055 
00056 void ConservativeMemDepPred::Initialize(InitPhase phase)
00057 {
00058     if(phase == INIT_POST_CONNECTION){
00059         // checkpointMaster Zbg`FbN
00060         CheckNodeInitialized( "checkpointMaster", m_checkpointMaster );
00061 
00062         m_latestStoreDst.Initialize(
00063             m_checkpointMaster,
00064             CheckpointMaster::SLOT_RENAME
00065         );
00066         m_latestMemDst.Initialize(
00067             m_checkpointMaster,
00068             CheckpointMaster::SLOT_RENAME
00069         );
00070         
00071         MemDependencyPtr
00072             tmpStoreDst( 
00073                 m_memDepPool.construct( m_core->GetNumScheduler() )
00074             );
00075         tmpStoreDst->Set();
00076         m_latestStoreDst.GetCurrent() = tmpStoreDst;
00077 
00078         MemDependencyPtr
00079             tmpMemDst(
00080                 m_memDepPool.construct( m_core->GetNumScheduler() )
00081             );
00082         tmpMemDst->Set();
00083         m_latestMemDst.GetCurrent() = tmpMemDst;
00084     }
00085 }
00086 
00087 // AhXv/sv\
00088 // load  Vstore\
00089 // store  V load/store \
00090 void ConservativeMemDepPred::Resolve(OpIterator op)
00091 {
00092     // memoryI
00093     if( !op->GetOpClass().IsMem() ) {
00094         return;
00095     }
00096 
00097     if( op->GetOpClass().IsLoad() ) {
00098         if( m_latestStoreDst.GetCurrent() == NULL ) {
00099             return;
00100         }
00101 
00102         op->SetSrcMem(0, m_latestStoreDst.GetCurrent());
00103     
00104     }else if( op->GetOpClass().IsStore() ) {
00105         if( m_latestMemDst.GetCurrent() == NULL ) {
00106             return;
00107         }
00108 
00109         op->SetSrcMem(0, m_latestMemDst.GetCurrent());
00110 
00111     }else {
00112         THROW_RUNTIME_ERROR("Unknown Memory Instruction");
00113     }
00114 }
00115 
00116 // ゥfetchload/storeo^
00117 void ConservativeMemDepPred::Allocate(OpIterator op)
00118 {
00119     // memoryI
00120     if( !op->GetOpClass().IsMem() ) {
00121         return;
00122     }
00123 
00124     // op  dstMemMemDependency
00125     if( op->GetDstMem(0) == NULL ) {
00126         MemDependencyPtr tmpMem(
00127             m_memDepPool.construct(m_core->GetNumScheduler()) );
00128         tmpMem->Clear();
00129         op->SetDstMem(0, tmpMem);
00130     }
00131 
00132     *m_latestMemDst = op->GetDstMem(0);
00133     if (op->GetOpClass().IsStore()) {
00134         *m_latestStoreDst = op->GetDstMem(0);
00135     }
00136 }
00137 
00138 // o^ゥゥg
00139 void ConservativeMemDepPred::Deallocate(OpIterator op)
00140 {
00141     MemDependencyPtr dstMem = op->GetDstMem(0);
00142     if(*m_latestStoreDst == dstMem) {
00143         m_latestStoreDst->reset();
00144     }
00145 
00146     if(*m_latestMemDst == dstMem) {
00147         m_latestMemDst->reset();
00148     }
00149 }
00150 
00151 void ConservativeMemDepPred::Commit(OpIterator op)
00152 {
00153     if( op->GetOpClass().IsMem() ) {
00154         Deallocate(op);
00155     }
00156 }
00157 
00158 void ConservativeMemDepPred::Flush(OpIterator op)
00159 {
00160     if( op->GetStatus() == OpStatus::OS_FETCH ){
00161         return;
00162     }
00163     if( op->GetOpClass().IsMem() ) {
00164         Deallocate(op);
00165     }
00166 }
00167 
00168 // MemOrderManagerAMemOrderconflictNopg(producer, consumer)
00169 // ConservativeMemDepPred
00170 void ConservativeMemDepPred::OrderConflicted(OpIterator producer, OpIterator consumer)
00171 {
00172     THROW_RUNTIME_ERROR("Access order violation must not occur with Conservative MemDepPred");
00173 }
00174 
00175 // タPhyRegAWX^s
00176 // AKtrue
00177 bool ConservativeMemDepPred::CanAllocate(OpIterator* infoArray, int numOp)
00178 {
00179     return true;
00180 }

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