void PowerModel::dumpDeviceTypes() /* dumpDeviceTypes {{{1 */ { // elnaz, dump device types as specified in .xml file of mcpat if (dumppwth) { char *fname_devTypes = static_cast<char *>(malloc(1023)); sprintf(fname_devTypes, "deviceTypes_%s", Report::getNameID()); logDeviceTypes = fopen(fname_devTypes, "w"); GMSG(logDeviceTypes == 0, "ERROR: could not open logDeviceTypes file \"%s\" (ignoring it)", fname_devTypes); free(fname_devTypes); for (size_t ii = 0; ii < energyBundle->cntrs.size(); ii++) { fprintf(logDeviceTypes, "%s\t", energyBundle->cntrs[ii].getName()); } fprintf(logDeviceTypes, "\n"); for (size_t i = 0; i < energyBundle->cntrs.size(); i++) { fprintf(logDeviceTypes, "%i\t", energyBundle->cntrs[i].getDevType()); } fprintf(logDeviceTypes, "\n"); if (logDeviceTypes) { fclose(logDeviceTypes); logDeviceTypes = NULL; } } }
GFlow::GFlow(int32_t i, int32_t cId, GMemorySystem *gmem) : fid(i), cpuId(cId), gms(gmem), gmos(gmem->getMemoryOS()) { //gproc = osSim->id2GProcessor(cpuId); if (trainCache == 0) { if (SescConf->checkCharPtr("cpucore","trainCache", cId)) { const char *cpuSection = SescConf->getCharPtr("", "cpucore", cId); std::vector<char *> vPars = SescConf->getSplitCharPtr(cpuSection, "trainCache"); if (vPars.size() != 2) { MSG("Required format: trainCache = \"descriptionSection name\"\n"); return; } const char *cacheSection = vPars[0]; const char *cacheName = vPars[1]; trainCache = gms->searchMemoryObj(true, cacheSection, cacheName); if(trainCache == 0) { // Maybe it got privatized char *ret=(char*)malloc(strlen(cacheName) + 20); sprintf(ret,"P(%i)_%s", cId, cacheName); trainCache = gms->searchMemoryObj(false, cacheSection, ret); } GMSG(trainCache==0,"Unknown cache to train [%s:%s]",cacheName, cacheSection); } } }
void SMPSystemBus::access(MemRequest *mreq) { GMSG(mreq->getPAddr() < 1024, "mreq dinst=0x%p paddr=0x%x vaddr=0x%x memOp=%d", mreq->getDInst(), (unsigned int) mreq->getPAddr(), (unsigned int) mreq->getVaddr(), mreq->getMemOperation()); I(mreq->getPAddr() > 1024); #ifdef SESC_ENERGY busEnergy->inc(); #endif switch(mreq->getMemOperation()){ case MemRead: read(mreq); break; case MemReadW: case MemWrite: write(mreq); break; case MemPush: push(mreq); break; default: specialOp(mreq); break; } // for reqs coming from upper level: // MemRead means I need to read the data, but I don't have it // MemReadW means I need to write the data, but I don't have it // MemWrite means I need to write the data, but I don't have permission // MemPush means I don't have space to keep the data, send it to memory }
void SMPCache::access(MemRequest *mreq) { PAddr addr; IS(addr = mreq->getPAddr()); GMSG(mreq->getPAddr() < 1024, "mreq dinst=0x%p paddr=0x%x vaddr=0x%x memOp=%d ignored", mreq->getDInst(), (unsigned int) mreq->getPAddr(), (unsigned int) mreq->getVaddr(), mreq->getMemOperation()); I(addr > 1024); switch(mreq->getMemOperation()){ case MemRead: read(mreq); break; case MemWrite: /*I(cache->findLine(mreq->getPAddr())); will be transformed to MemReadW later */ case MemReadW: write(mreq); break; case MemPush: I(0); break; // assumed write-through upperlevel default: specialOp(mreq); break; } // for reqs coming from upper level: // MemRead means "I want to read" // MemReadW means "I want to write, and I missed" // MemWrite means "I want to write, and I hit" // MemPush means "I am writing data back" // (this will never happen if upper level is write-through cache, // which is what we are assuming) }
void PowerModel::dumpLeakage() /* dumpLeakage {{{1 */ { // eka, For each interval, cal this function if you want // have the power dumped into a different file // elnaz, separated dump leakage from dynamic power if (dumppwth) { char *fname_pwr_lkg = static_cast<char *>(malloc(1023)); sprintf(fname_pwr_lkg, "power_lkg_%s", Report::getNameID()); logpwrlkg = fopen(fname_pwr_lkg, "w"); GMSG(logpwrlkg == 0, "ERROR: could not open logpwrlkg file \"%s\" (ignoring it)", fname_pwr_lkg); free(fname_pwr_lkg); if (totalPowerSamples <= 2) { // also write the header for (size_t ii = 0; ii < energyBundle->cntrs.size(); ii++) { fprintf(logpwrlkg, "%s\t", energyBundle->cntrs[ii].getName()); } fprintf(logpwrlkg, "\n"); } for (size_t i = 0; i < energyBundle->cntrs.size(); i++) { fprintf(logpwrlkg, "%e\t", energyBundle->cntrs[i].getLkg()); } fprintf(logpwrlkg, "\n"); if (logpwrlkg) { fclose(logpwrlkg); logpwrlkg = NULL; } } }
Resource::~Resource() { GMSG(!EventScheduler::empty(), "Resources destroyed with %Zu pending instructions" ,EventScheduler::size()); if(gen) gen->unsubscribe(); }
void PowerModel::plug(const char* section) /* plug {{{1 */ { I(sescThermWrapper); I(pwrCntrRepo); I(ipcRepo); I(temperatures); I(mcpatWrapper); I(energyBundle); #ifdef ENABLE_PEQ PeqParser peq_parser; // peq_parser.getGeneralParams(); // peq_parser.getCoreParams(); // peq_parser.getMemParams(); // peq_parser.testParser(); SRAM my_sram; my_sram.testSRAM(); #endif avgTimingIPC = 1; powerGlue.plug(section, energyBundle); logfile = 0; if (SescConf->checkCharPtr(section, "logfile")) { filename = SescConf->getCharPtr(section, "logfile"); logfile = fopen(filename, "w"); GMSG(logfile == 0, "ERROR: could not open logfile \"%s\" (ignoring it)", filename); } powerGlue.createStatCounters(); //checkStatCounters(section); //Parse conf file to get stats information //Format in conf file is: stats[i] = pwrstat +gstat1 -gstat2 ... readStatsFromConfFile(section); genIndeces(); readPowerConfig(section); initPowerModel(section); readTempConfig(section); initTempModel(section); //plugStackingValidator(); //Initialize logfile if (logfile == NULL) return; avgPowerValid = false; fprintf(logfile, "#IPC\t"); for (size_t i = 0; i < stats->size(); i++) { fprintf(logfile, "%s\t", stats->at(i)->getName()); } fprintf(logfile, "Total access all\n"); }
exportTemplate template < class Data, class Time > TQueue < Data, Time > ::~TQueue() { GMSG(nNodes, "Destroying TQueue %d with pending nodes", nNodes); free(accessTail); free(access); }
void ThermTrace::initLoglkg(const char* tfilename){ FILE *tmploglkg; char *lkgfname = (char *) alloca(256); sprintf (lkgfname, "scaled_lkg_%s", tfilename); tmploglkg = fopen(lkgfname,"w"); GMSG(tmploglkg==0,"ERROR: could not open loglkg file \"%s\" (ignoring it)",lkgfname); }
void PowerModel::getPowerDumpFile() /* getPowerDumpFile {{{1 */ { dumppwthSplit = true; totalPowerSamples = 0; nPowerCall++; if (dumppwth && dumppwthSplit) { char *fname_prf = static_cast<char *>(malloc(1023)); char *fname_pwr_dyn = static_cast<char *>(malloc(1023)); sprintf(fname_prf, "perf_%d_%s", nPowerCall, Report::getNameID()); sprintf(fname_pwr_dyn, "power_dyn_%d_%s", nPowerCall, Report::getNameID()); logprf = fopen(fname_prf, "w"); logpwrdyn = fopen(fname_pwr_dyn, "w"); GMSG(logprf == 0, "ERROR: could not open logprf file \"%s\" (ignoring it)", fname_prf); GMSG(logpwrdyn == 0, "ERROR: could not open logpwrdyn file \"%s\" (ignoring it)", fname_pwr_dyn); free(fname_pwr_dyn); free(fname_prf); } }
FILE *SamplerBase::genReportFileNameAndOpen(const char *str) { FILE *fp; char *fname = (char *) alloca(1023); strcpy(fname, str); strcat(fname, Report::getNameID()); fp = fopen(fname,"w"); if(fp==0) { GMSG(fp==0,"ERROR: could not open file \"%s\"",fname); exit(-1); } return fp; }
void EmuSampler::beginTiming(EmuMode mod) /* Start sampling a new mode */ { //I(stopJustCalled); stopJustCalled = false; phasenInst = 0; mode = mod; clock_gettime(CLOCK_REALTIME,&startTime); const char *mode2name[] = { "Init","Rabbit","Warmup","Detail","Timing","InvalidValue"}; GMSG(mode!=mod,"Sampler %s: starting %s mode", name, mode2name[mod]); }
void ThermTrace::initDumpLeakage(){ if (dumppwth){ char *fname_lkg = (char *) malloc(1023); sprintf(fname_lkg, "sesctherm_scaled_lkg_%s",Report::getNameID()); loglkg = fopen(fname_lkg,"w"); GMSG(loglkg==0,"ERROR: could not open loglkg file \"%s\" (ignoring it)",fname_lkg); if (loglkg) { for (size_t ii = 0; ii < energyBundle->cntrs.size(); ii++) { fprintf(loglkg, "%s\t", energyBundle->cntrs[ii].getName()); } fprintf(loglkg, "\n"); } } return; }
void PowerModel::plugStackingValidator() { // read the solution if (SescConf->checkCharPtr("", "stackingSol")) { const char * solution = SescConf->getCharPtr("", "stackingSol"); uint32_t ii = 0; // mark each solution in the Bundle while (solution[ii] != '\0') { energyBundle->cntrs[ii].setSPart(solution[ii]); ii++; } I(ii == energyBundle->cntrs.size()); } char *fname_dpower = static_cast<char *>(malloc(1023)); sprintf(fname_dpower, "dpower_%s", Report::getNameID()); dpowerf = fopen(fname_dpower, "w"); GMSG(dpowerf == 0, "ERROR: could not open dpower file \"%s\".", fname_dpower); free(fname_dpower); }
MemObj *GMemorySystem::finishDeclareMemoryObj(std::vector<char *> vPars, char* name_suffix) { bool shared = false; // Private by default bool privatized = false; const char *device_descr_section = vPars[0]; char *device_name = (vPars.size() > 1) ? vPars[1] : 0; if (vPars.size() > 2) { if (strcasecmp(vPars[2], "shared") == 0) { I(vPars.size() == 3); shared = true; } else if (strcasecmp(vPars[2], "sharedBy") == 0) { I(vPars.size() == 4); int32_t sharedBy = atoi(vPars[3]); //delete[] vPars[3]; GMSG(sharedBy <= 0, "ERROR: SharedBy should be bigger than zero (field %s)", device_name); int32_t nId = coreId / sharedBy; device_name = privatizeDeviceName(device_name, nId); shared = true; privatized = true; } } else if (device_name) { if (strcasecmp(device_name, "shared") == 0) { //delete[] device_name; //device_name = 0; shared = true; } } SescConf->isCharPtr(device_descr_section, "deviceType"); const char *device_type = SescConf->getCharPtr(device_descr_section, "deviceType"); /* If the device has been given a name, we may be refering to an * already existing device in the system, so let's search * it. Anonymous devices (no name given) are always unique, and only * one reference to them may exist in the system. */ if (device_name) { if (!privatized) { if (shared) device_name = privatizeDeviceName(device_name, 0); else { device_name = privatizeDeviceName(device_name, coreId); } } //device_name = privatizeDeviceName(device_name, priv_counter++); char *final_dev_name = device_name; if (name_suffix != NULL){ final_dev_name =new char[strlen(device_name) + strlen(name_suffix)+8]; sprintf(final_dev_name,"%s%s",device_name,name_suffix); } device_name = final_dev_name; MemObj *memdev = searchMemoryObj(shared, device_descr_section, device_name); if (memdev) { //delete[] device_name; //delete[] device_descr_section; return memdev; } } else device_name = buildUniqueName(device_type); MemObj *newMem = buildMemoryObj(device_type, device_descr_section, device_name); if (newMem) // Would be 0 in known-error mode getMemoryObjContainer(shared)->addMemoryObj(device_name, newMem); return newMem; }
PortGeneric::~PortGeneric() { GMSG(nUsers != 0, "Not enough destroys for FUGenUnit"); }
DInst::DInst() :doAtSimTimeCB(this) ,doAtSelectCB(this) ,doAtExecutedCB(this) { pend[0].init(this); pend[1].init(this); I(MAX_PENDING_SOURCES==2); nDeps = 0; #ifdef DINST_TRACK_PHYS static ushort max_preg = 1; preg = max_preg++; GMSG(max_preg>10240,"WARNING: Too many physical register created [%d]",max_preg); #endif #ifdef SESC_BAAD if (avgFetch1QTime == 0) { int32_t maxType = static_cast<int>(MaxInstType); avgFetch1QTime = (GStatsHist **)malloc(sizeof(GStatsHist *)*maxType); avgFetch2QTime = (GStatsHist **)malloc(sizeof(GStatsHist *)*maxType); avgIssueQTime = (GStatsHist **)malloc(sizeof(GStatsHist *)*maxType); avgSchedQTime = (GStatsHist **)malloc(sizeof(GStatsHist *)*maxType); avgExeQTime = (GStatsHist **)malloc(sizeof(GStatsHist *)*maxType); avgRetireQTime = (GStatsHist **)malloc(sizeof(GStatsHist *)*maxType); for(int32_t i = 1; i < maxType ; i++) { avgFetch1QTime[i] = new GStatsHist("BAAD_%sFetch1QTime",Instruction::opcode2Name(static_cast<InstType>(i))); avgFetch2QTime[i] = new GStatsHist("BAAD_%sFetch2QTime",Instruction::opcode2Name(static_cast<InstType>(i))); avgIssueQTime[i] = new GStatsHist("BAAD_%sDepQTime" ,Instruction::opcode2Name(static_cast<InstType>(i))); avgSchedQTime[i] = new GStatsHist("BAAD_%sSchQTime" ,Instruction::opcode2Name(static_cast<InstType>(i))); avgExeQTime[i] = new GStatsHist("BAAD_%sExeQTime" ,Instruction::opcode2Name(static_cast<InstType>(i))); avgRetireQTime[i] = new GStatsHist("BAAD_%sComRetQTime",Instruction::opcode2Name(static_cast<InstType>(i))); } fetch1QHist1 = new GStatsTimingHist("BAAD_Fetch1QHist1"); fetch2QHist1 = new GStatsTimingHist("BAAD_Fetch2QHist1"); issueQHist1 = new GStatsTimingHist("BAAD_DepQHist1"); schedQHist1 = new GStatsTimingHist("BAAD_SchQHist1"); exeQHist1 = new GStatsTimingHist("BAAD_ExeQHist1"); retireQHist1 = new GStatsTimingHist("BAAD_ComRetQHist1"); fetch1QHist2 = new GStatsHist("BAAD_Fetch1QHist2"); fetch2QHist2 = new GStatsHist("BAAD_Fetch2QHist2"); issueQHist2 = new GStatsHist("BAAD_DepQHist2"); schedQHist2 = new GStatsHist("BAAD_SchQHist2"); exeQHist2 = new GStatsHist("BAAD_ExeQHist2"); retireQHist2 = new GStatsHist("BAAD_ComRetQHist2"); fetch1QHistUp = new GStatsHist("BAAD_Fetch1QHistUp"); fetch2QHistUp = new GStatsHist("BAAD_Fetch2QHistUp"); issueQHistUp = new GStatsHist("BAAD_DepQHistUp"); schedQHistUp = new GStatsHist("BAAD_SchQHistUp"); exeQHistUp = new GStatsHist("BAAD_ExeQHistUp"); retireQHistUp = new GStatsHist("BAAD_ComRetQHistUp"); fetch1QHistDown = new GStatsHist("BAAD_Fetch1QHistDown"); fetch2QHistDown = new GStatsHist("BAAD_Fetch2QHistDown"); issueQHistDown = new GStatsHist("BAAD_DepQHistDown"); schedQHistDown = new GStatsHist("BAAD_SchQHistDown"); exeQHistDown = new GStatsHist("BAAD_ExeQHistDown"); retireQHistDown = new GStatsHist("BAAD_ComRetQHistDown"); brdistHist1 = new GStatsHist("BAAD_BrDistHist1"); } #endif }
MarkovPrefetcher::MarkovPrefetcher(MemorySystem* current ,const char *section ,const char *name) : MemObj(section, name) ,gms(current) ,halfMiss("%s:halfMiss", name) ,miss("%s:miss", name) ,hit("%s:hits", name) ,predictions("%s:predictions", name) ,accesses("%s:accesses", name) { MemObj *lower_level = NULL; SescConf->isInt(section, "depth"); depth = SescConf->getInt(section, "depth"); SescConf->isInt(section, "width"); width = SescConf->getInt(section, "width"); const char *Section = SescConf->getCharPtr(section, "nextLevel"); if (Section) { lineSize = SescConf->getInt(Section, "bsize"); } const char *buffSection = SescConf->getCharPtr(section, "buffCache"); if (buffSection) { buff = BuffType::create(buffSection, "", name); SescConf->isInt(buffSection, "numPorts"); numBuffPorts = SescConf->getInt(buffSection, "numPorts"); SescConf->isInt(buffSection, "portOccp"); buffPortOccp = SescConf->getInt(buffSection, "portOccp"); } const char *streamSection = SescConf->getCharPtr(section, "streamCache"); if (streamSection) { char tableName[128]; sprintf(tableName, "%sPrefTable", name); table = MarkovTable::create(streamSection, "", tableName); GMSG(tEntrySize != SescConf->getInt(streamSection, "BSize"), "The prefetch buffer streamBSize field in the configuration file should be %d.", tEntrySize); SescConf->isInt(streamSection, "numPorts"); numTablePorts = SescConf->getInt(streamSection, "numPorts"); SescConf->isInt(streamSection, "portOccp"); tablePortOccp = SescConf->getInt(streamSection, "portOccp"); } defaultMask = ~(buff->getLineSize()-1); char portName[128]; sprintf(portName, "%s_buff", name); buffPort = PortGeneric::create(portName, numBuffPorts, buffPortOccp); sprintf(portName, "%s_table", name); tablePort = PortGeneric::create(portName, numTablePorts, tablePortOccp); ptr = 0; lastAddr = 0; I(current); lower_level = current->declareMemoryObj(section, k_lowerLevel); if (lower_level != NULL) addLowerLevel(lower_level); }
StridePrefetcher::StridePrefetcher(MemorySystem* current ,const char *section ,const char *name) /* constructor {{{1 */ :MemObj(section, name) ,halfMiss("%s:halfMiss", name) ,miss("%s:miss", name) ,hit("%s:hits", name) ,predictions("%s:predictions", name) ,accesses("%s:accesses", name) ,unitStrideStreams("%s:unitStrideStreams", name) ,nonUnitStrideStreams("%s:nonUnitStrideStreams", name) ,ignoredStreams("%s:ignoredStreams", name) { MemObj *lower_level = NULL; // If MemLatency is 200 and busOcc is 10, then there can be at most 20 // requests without saturating the bus. (VERIFY???) something like half sound // conservative (10 pending requests) MaxPendingRequests = 8; // FIXME: SescConf SescConf->isInt(section, "depth"); depth = SescConf->getInt(section, "depth"); SescConf->isInt(section, "missWindow"); missWindow = SescConf->getInt(section, "missWindow"); SescConf->isInt(section, "maxStride"); maxStride = SescConf->getInt(section, "maxStride"); SescConf->isInt(section, "hitDelay"); hitDelay = SescConf->getInt(section, "hitDelay"); SescConf->isInt(section, "missDelay"); missDelay = SescConf->getInt(section, "missDelay"); SescConf->isInt(section, "learnHitDelay"); learnHitDelay = SescConf->getInt(section, "learnHitDelay"); SescConf->isInt(section, "learnMissDelay"); learnMissDelay = SescConf->getInt(section, "learnMissDelay"); I(depth > 0); const char *buffSection = SescConf->getCharPtr(section, "buffCache"); if (buffSection) { buff = BuffType::create(buffSection, "", name); SescConf->isInt(buffSection, "bknumPorts"); numBuffPorts = SescConf->getInt(buffSection, "bknumPorts"); SescConf->isInt(buffSection, "bkportOccp"); buffPortOccp = SescConf->getInt(buffSection, "bkportOccp"); } const char *streamSection = SescConf->getCharPtr(section, "streamCache"); if (streamSection) { char tableName[128]; sprintf(tableName, "%sPrefTable", name); table = PfTable::create(streamSection, "", tableName); GMSG(pEntrySize != SescConf->getInt(streamSection, "BSize"), "The prefetch buffer streamBSize field in the configuration file should be %d.", pEntrySize); SescConf->isInt(streamSection, "bknumPorts"); numTablePorts = SescConf->getInt(streamSection, "bknumPorts"); SescConf->isInt(streamSection, "bkportOccp"); tablePortOccp = SescConf->getInt(streamSection, "bkportOccp"); } char portName[128]; sprintf(portName, "%s_buff", name); buffPort = PortGeneric::create(portName, numBuffPorts, buffPortOccp); sprintf(portName, "%s_table", name); tablePort = PortGeneric::create(portName, numTablePorts, tablePortOccp); defaultMask = ~(buff->getLineSize()-1); I(current); lower_level = current->declareMemoryObj(section, "lowerLevel"); if (lower_level != NULL) addLowerLevel(lower_level); //Is this the memory isMemoryBus = false; }
StridePrefetcher::StridePrefetcher(MemorySystem* current ,const char *section ,const char *name) : MemObj(section, name) ,halfMiss("%s:halfMiss", name) ,miss("%s:miss", name) ,hit("%s:hits", name) ,predictions("%s:predictions", name) ,accesses("%s:accesses", name) ,unitStrideStreams("%s:unitStrideStreams", name) ,nonUnitStrideStreams("%s:nonUnitStrideStreams", name) ,ignoredStreams("%s:ignoredStreams", name) { MemObj *lower_level = NULL; SescConf->isInt(section, "depth"); depth = SescConf->getInt(section, "depth"); SescConf->isInt(section, "missWindow"); missWindow = SescConf->getInt(section, "missWindow"); SescConf->isInt(section, "maxStride"); maxStride = SescConf->getInt(section, "maxStride"); SescConf->isInt(section, "hitDelay"); hitDelay = SescConf->getInt(section, "hitDelay"); SescConf->isInt(section, "missDelay"); missDelay = SescConf->getInt(section, "missDelay"); SescConf->isInt(section, "learnHitDelay"); learnHitDelay = SescConf->getInt(section, "learnHitDelay"); SescConf->isInt(section, "learnMissDelay"); learnMissDelay = SescConf->getInt(section, "learnMissDelay"); I(depth > 0); const char *buffSection = SescConf->getCharPtr(section, "buffCache"); if (buffSection) { buff = BuffType::create(buffSection, "", name); SescConf->isInt(buffSection, "numPorts"); numBuffPorts = SescConf->getInt(buffSection, "numPorts"); SescConf->isInt(buffSection, "portOccp"); buffPortOccp = SescConf->getInt(buffSection, "portOccp"); } const char *streamSection = SescConf->getCharPtr(section, "streamCache"); if (streamSection) { char tableName[128]; sprintf(tableName, "%sPrefTable", name); table = PfTable::create(streamSection, "", tableName); GMSG(pEntrySize != SescConf->getInt(streamSection, "BSize"), "The prefetch buffer streamBSize field in the configuration file should be %d.", pEntrySize); SescConf->isInt(streamSection, "numPorts"); numTablePorts = SescConf->getInt(streamSection, "numPorts"); SescConf->isInt(streamSection, "portOccp"); tablePortOccp = SescConf->getInt(streamSection, "portOccp"); } char portName[128]; sprintf(portName, "%s_buff", name); buffPort = PortGeneric::create(portName, numBuffPorts, buffPortOccp); sprintf(portName, "%s_table", name); tablePort = PortGeneric::create(portName, numTablePorts, tablePortOccp); defaultMask = ~(buff->getLineSize()-1); I(current); lower_level = current->declareMemoryObj(section, k_lowerLevel); if (lower_level != NULL) addLowerLevel(lower_level); }