void SamplerBase::getGPUCycles(FlowID fid, float ratio) { char str[255]; sprintf(str,"P(%u):clockTicks", getsFid()); GStats *gref = 0; gref = GStats::getRef(str); I(gref); uint64_t cticks = gref->getSamples(); // clockTicks if (doPower) gpuEstimatedCycles = cticks*(ratio); else gpuEstimatedCycles = cticks; gpuSampledRatio = ratio; }
void PowerModel::updateActivity(uint64_t timeinterval, FlowID fid) /* updateActivity {{{1 */ { // Update stats that are passed to McPat timeInterval = timeinterval; PowerStats *pwrstat = 0; uint32_t zcnt = 0; for(size_t i = 0; i < stats->size(); i++) { pwrstat = (*stats)[i]; (*activity)[i] = pwrstat->getActivity(); if (!(*activity)[i]) zcnt++; } dumpActivity(); #ifdef DEBUG static int pcnt = 0; if ((2*zcnt > stats->size())) { if (pcnt++ < 20) printf("WARNING: Too many blocks have zero activity. Check the eSESC to McPAT mapping.\n"); } #endif // Update internal performance counters GStats *gref = 0; char str[128]; for (size_t i=0; i<ncores; i++) { sprintf(str,"S(%lu):globalClock_Timing", i); gref = GStats::getRef(str); I(gref); uint64_t cticks = gref->getSamples(); // clockTicks if (cticks - clockPrev[i] == 0) { I(0); clockInterval[i] = 0; } else { clockInterval[i] = cticks - clockPrev[i]; // + 1000; } clockPrev[i] = cticks; } // Just use the total stats, not average avgTimingIPC = static_cast<float>(1.0)/static_cast<float>(getEmul(fid)->getSampler()->getMeaCPI()); ipc = avgTimingIPC; }
void EmuSampler::calcCPI() /* calculates cpi for the last EmuTiming mode */ { if (mode != EmuTiming) return; if (terminated) return; I(calcCPIJustCalled == false); I(!stopJustCalled); calcCPIJustCalled = true; //get instruction count uint64_t timingInst = iusage[EmuTiming]->getSamples(); uint64_t instCount = timingInst - instPrev[sFid]; char str[255]; sprintf(str, "P(%d):clockTicks", sFid); //FIXME: needs mapping GStats *gref = 0; gref = GStats::getRef(str); I(gref); //fprintf(stderr, "\n\nCalcCPI: %s->getSamples returns %lld (previously : %lld)\n\n",str,gref->getSamples(),clockPrev[sFid]); uint64_t cticks = gref->getSamples(); uint64_t clockInterval = cticks - clockPrev[sFid] + 1; if(instCount<100 || clockInterval <100) // To avoid too frequent sampling errors return; instPrev[sFid] = timingInst; clockPrev[sFid] = cticks; //Get freezed cycles due to thermal throttling sprintf(str, "P(%d):nFreeze", sFid); //FIXME: needs mapping gref = 0; gref = GStats::getRef(str); I(gref); uint64_t fticks = gref->getSamples(); //fprintf(stderr,"\n\nCalcCPI: %s->getSamples returns %lld\n\n",str,gref->getSamples()); uint64_t fticksInterval = fticks - fticksPrev[sFid] + 1; fticksPrev[sFid] = fticks; uint64_t uInstCount = nCommitted->getSamples() - prevnCommitted; prevnCommitted = nCommitted->getSamples(); uint64_t adjustedClock = clockInterval - fticksInterval; float newCPI = static_cast<float>(adjustedClock)/static_cast<float>(instCount); // newuCPI should be used, but as the sampler, we can only scale Inst, not uInst. //float newCPI = static_cast<float>(clockInterval)/static_cast<float>(uInstCount); I(newCPI>0); /* //printf("InstCnt:%ld, prevInst:%ld, clock:%ld, ipc:%f\n", instCount, instPrev, clockInterval, static_cast<float>(instCount)/static_cast<float>(clockInterval)); if (newCPI <= 0){ fprintf(stderr,"newCPI = %f, clockInterval = %lld, adjustedClock = %lld, uInstCount = %lld",newCPI,clockInterval,adjustedClock, uInstCount); } */ float newipc = static_cast<float>(instCount)/static_cast<float>(adjustedClock); float newuipc = static_cast<float>(uInstCount)/static_cast<float>(adjustedClock); uipc->sample(100*newuipc,true); ipc->sample(100*newipc,true); //I(newCPI<=4); if (newCPI > 5) { //newCPI = 5.0; //return; } //meaCPI = newCPI; meaCPI = newCPI; meauCPI = 1.0/newuipc; }