Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions .cproject
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="cdt.managedbuild.toolchain.gnu.base.224831437">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.base.224831437" moduleId="org.eclipse.cdt.core.settings" name="Default">
<cconfiguration id="cdt.managedbuild.toolchain.gnu.base.832941795">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.base.832941795" moduleId="org.eclipse.cdt.core.settings" name="Default">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration buildProperties="" id="cdt.managedbuild.toolchain.gnu.base.224831437" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
<folderInfo id="cdt.managedbuild.toolchain.gnu.base.224831437.52879886" name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.base.1385639197" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.base">
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.target.gnu.platform.base.917860584" name="Debug Platform" osList="linux,hpux,aix,qnx" superClass="cdt.managedbuild.target.gnu.platform.base"/>
<builder id="cdt.managedbuild.target.gnu.builder.base.695063280" managedBuildOn="false" name="Gnu Make Builder.Default" superClass="cdt.managedbuild.target.gnu.builder.base"/>
<tool id="cdt.managedbuild.tool.gnu.archiver.base.612961909" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.728389944" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base"/>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.base.1072898463" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base"/>
<tool id="cdt.managedbuild.tool.gnu.c.linker.base.639258867" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.1587744886" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base"/>
<tool id="cdt.managedbuild.tool.gnu.assembler.base.943680124" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base"/>
<configuration buildProperties="" id="cdt.managedbuild.toolchain.gnu.base.832941795" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
<folderInfo id="cdt.managedbuild.toolchain.gnu.base.832941795.1524821063" name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.base.706089132" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.base">
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.target.gnu.platform.base.2063658798" name="Debug Platform" osList="linux,hpux,aix,qnx" superClass="cdt.managedbuild.target.gnu.platform.base"/>
<builder id="cdt.managedbuild.target.gnu.builder.base.491074999" managedBuildOn="false" name="Gnu Make Builder.Default" superClass="cdt.managedbuild.target.gnu.builder.base"/>
<tool id="cdt.managedbuild.tool.gnu.archiver.base.1395661362" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.2088420433" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base"/>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.base.1944358193" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base"/>
<tool id="cdt.managedbuild.tool.gnu.c.linker.base.485646867" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.1227572479" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base"/>
<tool id="cdt.managedbuild.tool.gnu.assembler.base.542451486" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base"/>
</toolChain>
</folderInfo>
</configuration>
Expand All @@ -42,7 +42,7 @@
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="Simulator.null.1169294365" name="Simulator"/>
<project id="HMMsim-Server2.null.151997428" name="HMMsim-Server2"/>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
</cproject>
2 changes: 1 addition & 1 deletion .settings/language.settings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project>
<configuration id="cdt.managedbuild.toolchain.gnu.base.224831437" name="Default">
<configuration id="cdt.managedbuild.toolchain.gnu.base.832941795" name="Default">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
Expand Down
4 changes: 3 additions & 1 deletion Bank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ MemoryMapping::MemoryMapping(MappingType mappingTypeArg, unsigned numRanksArg, u
numBanks = numRanks * banksPerRank;
totalSize = static_cast<uint64>(numBanks) * static_cast<uint64>(rowsPerBank) * static_cast<uint64>(blocksPerRow) * static_cast<uint64>(blockSize);


// cout << totalSize;
// cout << flush;
// getchar();
//these 5 assignments depend on the address mapping used
if (mappingType == ROW_RANK_BANK_COL){
blockOffset = 0;
Expand Down
2 changes: 2 additions & 0 deletions CPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,8 @@ bool CPU::readNextEntry(){
} else {
if (reader->readEntry(&firstEntry)){
addrint firstByteBlockAddress = firstEntry.address & ~offsetMask;
//cout << firstEntry.address << "\t" << firstByteBlockAddress;
//cout <<endl;
addrint lastByteBlockAddress = (firstEntry.address + firstEntry.size - 1) & ~offsetMask;
if (firstByteBlockAddress == lastByteBlockAddress){
firstEntry.address = firstByteBlockAddress;
Expand Down
4 changes: 3 additions & 1 deletion Cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ CacheModel::Result CacheModel::access(addrint addr, bool read, bool instr, addri
Result ret;
timestamp++;
int block = sets[index].access(tag, timestamp, read);
if (block == -1){
//block = -1;
if (block == -1){
if (read){
if (instr){
instrLoadMisses++;
Expand All @@ -289,6 +290,7 @@ CacheModel::Result CacheModel::access(addrint addr, bool read, bool instr, addri
if (it != remapTable.end()){
it->second.count++;
}
//res = Set::NO_EVICTION;
if (res == Set::NO_EVICTION){
misses_without_eviction++;
ret = MISS_WITHOUT_EVICTION;
Expand Down
43 changes: 38 additions & 5 deletions HybridMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@
* See the file LICENSE.txt for copying permission.
*/

#include "HybridMemory.H"
#include "include/HybridMemory.H"

#include <iomanip>
#include <iostream>
#include <unistd.h>
#include <cmath>
#include <list>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>

HybridMemory::HybridMemory(
const string& nameArg,
Expand Down Expand Up @@ -178,7 +183,10 @@ HybridMemory::HybridMemory(
avgPcmWriteTimePerPid(statCont, nameArg + "_avg_pcm_write_time_per_pid", "Average number of cycles servicing PCM writes as seen by the " + descArg + " from process", &pcmWriteTimePerPid, &pcmWritesPerPid),
avgPcmAccessTimePerPid(statCont, nameArg + "_avg_pcm_access_time_per_pid", "Average number of cycles servicing PCM accesses as seen by the " + descArg + " from process", &pcmAccessTimePerPid, &pcmAccessesPerPid),

avgAccessTimePerPid(statCont, nameArg + "_avg_access_time_per_pid", "Average number of cycles servicing all accesses as seen by the " + descArg + " from process", &totalAccessTimePerPid, &totalAccessesPerPid)
avgAccessTimePerPid(statCont, nameArg + "_avg_access_time_per_pid", "Average number of cycles servicing all accesses as seen by the " + descArg + " from process", &totalAccessTimePerPid, &totalAccessesPerPid),

uniquepages(statCont, nameArg + "_unique_pages", "Number of unique pages found", 0)

{

}
Expand All @@ -200,6 +208,13 @@ bool HybridMemory::access(MemoryRequest *request, IMemoryCallback *caller){
}
bool read = request->read;
int pid = manager->getPidOfAddress(request->addr);
/* string r = request->read?"R":"W";
string ins = request->instr?"I":"D";
cout << request->addr << "\t";
cout << 64 << "\t";
cout << r << "\t";
cout << ins << "\t";
cout << endl;*/

auto mit = migrations.find(page);
if (mit != migrations.end()){
Expand Down Expand Up @@ -381,7 +396,25 @@ bool HybridMemory::access(MemoryRequest *request, IMemoryCallback *caller){
}
}
}
static std::map<addrint, int> pages_map;
if (caller != manager){
std::map<addrint, int>::iterator i = pages_map.find(request->addr);
if(i == pages_map.end()){
pages_map[request->addr] = 1;
}
else
{
pages_map[request->addr] = i->second + 1;
}
uniquepages=pages_map.size();

/*string r = request->read?"R":"W";
string ins = request->instr?"I":"D";
cout << request->addr << "\t";
cout << 64 << "\t";
cout << r << "\t";
cout << ins << "\t";
cout << endl;*/
//ignore accesses that come from hybrid memory manager (these are due to flushes, which are not monitored)
auto monit = monitors.find(page);
if (monit == monitors.end()){
Expand Down Expand Up @@ -1229,7 +1262,7 @@ void OldHybridMemory::process(const Event *event){

bool OldHybridMemory::access(MemoryRequest *request, IMemoryCallback *caller){
uint64 timestamp = engine->getTimestamp();
debug("(%p, %lu, %u, %s, %s, %d, %s)", request, request->addr, request->size, request->read?"read":"write", request->instr?"instr":"data", request->priority, caller->getName());
//printf("\n(%p, %lu, %u, %s, %s, %d, %s)", request, request->addr, request->size, request->read?"read":"write", request->instr?"instr":"data", request->priority, caller->getName());
/* static int u=0;
if(u%100==0)
cout<<"ACCCCCCCSES"<<u<<endl;
Expand Down
4 changes: 3 additions & 1 deletion Memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ Memory::Memory(
uint64 accessLatencyArg,
bool longCloseLatencyArg,
uint64 busLatencyArg,
addrint offsetArg) :
addrint offsetArg,
string pcmFractionArg) :
name(nameArg),
pcmFraction(pcmFractionArg),
desc(descArg),
engine(engineArg),
debugStart(debugStartArg),
Expand Down
35 changes: 30 additions & 5 deletions MemoryManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ HybridMemoryManager::HybridMemoryManager(
numDramPages = memory->getDramSize() / pageSize;
dramSize = numDramPages * pageSize;
numPcmPages = memory->getPcmSize() / pageSize;
// cout << "pcm pages: "<< numPcmPages << flush<< endl;
// cout << "dram pages: "<<numDramPages << flush;

pcmSize = numPcmPages * pageSize;

offsetWidth = logPageSize;
Expand All @@ -180,14 +183,16 @@ HybridMemoryManager::HybridMemoryManager(
onePastLastDramPage = getIndex(onePastLastDramAddress);
firstPcmPage = getIndex(firstPcmAddress);
onePastLastPcmPage = getIndex(onePastLastPcmAddress);

for(addrint page = firstDramPage; page < onePastLastDramPage; page++){
for(addrint page=firstDramPage; page < onePastLastDramPage; page++){
dramFreePageList.emplace_back(page);
}

for(addrint page = firstPcmPage; page < onePastLastPcmPage; page++){
pcmFreePageList.emplace_back(page);
}
cout <<endl<< "pcm pages num: "<< pcmFreePageList.size() << flush<< endl;
cout << "dram pages num: "<<dramFreePageList.size() << flush<<endl;
// getchar();

pages = new PageMap[numProcesses];

Expand Down Expand Up @@ -269,6 +274,7 @@ bool HybridMemoryManager::access(int pid, addrint virtualAddr, bool read, bool i
}

bool HybridMemoryManager::migrateOnDemand(addrint physicalPage, addrint *destPhysicalPage){
updateMonitors();
uint64 timestamp = engine->getTimestamp();
debug("(%lu)", physicalPage);
// cout << dramFreePageList.size();
Expand Down Expand Up @@ -427,6 +433,7 @@ void HybridMemoryManager::process(const Event * event){
uint64 timestamp = engine->getTimestamp();
EventType type = static_cast<EventType>(event->getData());
debug("(%d)", type);

if (type == DEMOTE){
updateMonitors();
selectPolicyAndDemote();
Expand Down Expand Up @@ -590,10 +597,10 @@ void HybridMemoryManager::updateMonitors(){
warn("%lu: Why is this page (%lu) not in the physical map?", engine->getTimestamp(), mit->page);
for (unsigned i = 0; i < pageSize/blockSize; i++){
if (mit->readBlocks[i] != 0){
cout << "read: " << getAddressFromBlock(mit->page, i) << endl;
//cout << "read: " << getAddressFromBlock(mit->page, i) << endl;
}
if (mit->writtenBlocks[i] != 0){
cout << "written: " << getAddressFromBlock(mit->page, i) << endl;
//cout << "written: " << getAddressFromBlock(mit->page, i) << endl;
}
}
myassert(false);
Expand Down Expand Up @@ -1274,6 +1281,7 @@ OldHybridMemoryManager::OldHybridMemoryManager(
*/
bool OldHybridMemoryManager::access(int pid, addrint virtualAddr, bool read, bool instr, addrint *physicalAddr, CPU *cpu){

cout << "access: " << engine->getTimestamp() << ", " << virtualAddr<<endl;
uint64 timestamp = engine->getTimestamp();
//debug("(%d, %lu, %s, %s)", pid, virtualAddr, read ? "read" : "write", instr ? "instr" : "data");
addrint virtualPage = getIndex(virtualAddr);
Expand Down Expand Up @@ -1318,10 +1326,14 @@ bool OldHybridMemoryManager::access(int pid, addrint virtualAddr, bool read, boo
myassert(false);
}
}

if (state == NOT_MIGRATING || state == WAITING){
//cout << "BBBB" << endl;
selectPolicyAndMigrate();
}
else {
//cout << "CCCC: " << virtualAddr << ", " << state << endl;
}
/* if(state == COPY){
cout<<"COPY\n";
}*/
Expand Down Expand Up @@ -1531,6 +1543,13 @@ void OldHybridMemoryManager::monitorPhysicalAccess(addrint addr, bool read, bool

//monitoring
if (monitoringLocation == AFTER_CACHES){
string r = read?"R":"W";
string ins = instr?"I":"D";
// cout << addr << "\t";
// cout << 64 << "\t";
// cout << r << "\t";
// cout << ins << "\t";
// cout << endl;
if ((state == FLUSH_BEFORE || state == COPY || state == FLUSH_AFTER) && page == currentMigration.destPhysicalPage){
static int q=0;
cout<<"FLUSH__MEMANAGER "<<q;
Expand All @@ -1555,6 +1574,7 @@ void OldHybridMemoryManager::monitorPhysicalAccess(addrint addr, bool read, bool
}

bool OldHybridMemoryManager::startMigration(int pid){

myassert(state == NOT_MIGRATING || state == WAITING);
myassert(flushQueue.empty());
uint64 timestamp = engine->getTimestamp();
Expand Down Expand Up @@ -1703,9 +1723,11 @@ bool OldHybridMemoryManager::startMigration(int pid){
}

void OldHybridMemoryManager::selectPolicyAndMigrate(){
cout << engine->getTimestamp() << endl;
uint64 timestamp = engine->getTimestamp();
//debug("(): state: %d", state);
if (state == NOT_MIGRATING){

int previousPolicy = currentPolicy;
bool found = false;
do {
Expand Down Expand Up @@ -1743,6 +1765,7 @@ void OldHybridMemoryManager::selectPolicyAndMigrate(){
if (minValue != numeric_limits<uint64>::max()){
state = WAITING;
wakeupTime = minValue + timestamp;
cout << "WWWW: " << minValue << endl;
addEvent(minValue, START_MIGRATION);
lastStartWaitingTime = timestamp;
}
Expand All @@ -1768,13 +1791,15 @@ void OldHybridMemoryManager::selectPolicyAndMigrate(){
}
}
} else {

//another event already scheduled a migration, so don't do anything
}
}

void OldHybridMemoryManager::process(const Event * event){
uint64 timestamp = engine->getTimestamp();
EventType type = static_cast<EventType>(event->getData());
cout << "process: " << type << endl;
if (type == START_MIGRATION){
selectPolicyAndMigrate();
} else if (type == COPY_PAGE){
Expand Down
Loading