コード例 #1
0
ファイル: SamplerPeriodic.cpp プロジェクト: dagoodma/esesc
void SamplerPeriodic::queue(uint32_t insn, uint64_t pc, uint64_t addr, FlowID fid, char op, uint64_t icount, void *env)
  /* main qemu/gpu/tracer/... entry point {{{1 */
{
  I(fid < emul->getNumEmuls());
  if(likely(!execute(fid, icount)))
    return; // QEMU can still send a few additional instructions (emul should stop soon)

  I(insn);

  // process the current sample mode
  if (nextSwitch>totalnInst) {
    if (mode == EmuRabbit || mode == EmuInit)
      return;
    if (mode == EmuDetail || mode == EmuTiming) {
      emul->queueInstruction(insn,pc,addr, (op&0xc0) /* thumb */ ,fid, env, getStatsFlag());
      return;
    }
    I(mode == EmuWarmup);
    doWarmupOpAddr(op, addr);
    return;
  }

  // We did enough
  if (isItDone())
    return;

  // We are not done yet though. Look for the new mode
  I(nextSwitch <= totalnInst);
  coordinateWithOthersAndNextMode(fid);
  I(mode == next_mode); //it was a detailed sync
}
コード例 #2
0
ファイル: SamplerGPUSpacial.cpp プロジェクト: bugamn/esesc
void SamplerGPUSpacial::queue(uint32_t insn, uint64_t pc, uint64_t addr, FlowID fid, char op, uint64_t icount, void *env)
  /* main qemu/gpu/tracer/... entry point  */
{

  if(likely(!execute(fid, icount)))
    return; // QEMU can still send a few additional instructions (emul should stop soon)
  I(mode!=EmuInit);

  I(insn);

  if (mode == EmuRabbit || mode == EmuWarmup){
    if (doPower && noActiveCPU()) {
      if (lastMode == EmuTiming) { 
#if 1 // For now GPU only, CPU side must be all rabbit!
        doPWTH();
#endif
      }
    }
    lastMode = mode;
    return;
  }

  if (mode == EmuDetail || mode == EmuTiming) {
    emul->queueInstruction(insn,pc,addr, (op&0xc0) /* thumb */ ,fid, env, getStatsFlag());
    lastMode = mode;
    return;
  }


  // not happening for GPU, the CPU will decide!

  // We did enough
  //if (totalnInst >= nInstMax/* || endSimSiged*/) {
  if (totalnInst >= nInstMax) {
    markDone();
    return;
  }


}
コード例 #3
0
ファイル: SamplerSMARTS.cpp プロジェクト: rallylee/esesc
void SamplerSMARTS::queue(uint32_t insn, uint64_t pc, uint64_t addr, FlowID fid, char op, uint64_t icount, void *env)
  /* main qemu/gpu/tracer/... entry point {{{1 */
{

  I(fid < emul->getNumEmuls());
  if(likely(!execute(fid, icount)))
    return; // QEMU can still send a few additional instructions (emul should stop soon)
  I(mode!=EmuInit);

  I(insn);

  // process the current sample mode
  if (getNextSwitch()>totalnInst) {

    if (mode == EmuRabbit || mode == EmuInit)
      return;

    if (mode == EmuDetail || mode == EmuTiming) {
      emul->queueInstruction(insn,pc,addr, (op&0xc0) /* thumb */ ,fid, env, getStatsFlag());
      return;
    }

    I(mode == EmuWarmup);
		doWarmupOpAddr(op, addr);
    return;
  }


  // Look for the new mode
  I(getNextSwitch() <= totalnInst);

 // I(mode != next_mode);
  pthread_mutex_lock (&mode_lock);
  //

  if (getNextSwitch() > totalnInst){//another thread just changed the mode
    pthread_mutex_unlock (&mode_lock);
    return;
  }

  lastMode = mode;
  nextMode(ROTATE, fid);
  if (lastMode == EmuTiming) { // timing is going to be over
    if (getTime()>=maxnsTime || totalnInst>=nInstMax) {
      markDone();
      pthread_mutex_unlock (&mode_lock);
      return;
    }
    if (doPower) {
      uint64_t mytime = getTime();
      int64_t ti = mytime - lastTime;
      I(ti > 0);
      ti = (static_cast<int64_t>(freq)*ti)/1e9;

      BootLoader::getPowerModelPtr()->setSamplingRatio(getSamplingRatio()); 
      BootLoader::getPowerModelPtr()->calcStats(ti, !(lastMode == EmuTiming), fid); 
      lastTime = mytime;
      updateCPI(fid); 
      if (doTherm) {
        BootLoader::getPowerModelPtr()->updateSescTherm(ti);  
      }
    }
  }
  pthread_mutex_unlock (&mode_lock);

}
コード例 #4
0
ファイル: SamplerSMARTS.cpp プロジェクト: volyrique/esesc
uint64_t SamplerSMARTS::queue(uint64_t pc, uint64_t addr, FlowID fid, char op, int src1, int src2, int dest, int dest2)
  /* main qemu/gpu/tracer/... entry point {{{1 */
{
  I(fid < emul->getNumEmuls());
  if(likely(!execute(fid, 1)))
    return 0; // QEMU can still send a few additional instructions (emul should stop soon)
  I(mode!=EmuInit);

  // process the current sample mode
  if (getNextSwitch()>totalnInst) {

    if (mode == EmuRabbit || mode == EmuInit) {
      uint64_t rabbitInst = getNextSwitch() - totalnInst;
      execute(fid,rabbitInst);
      // Qemu is not going to return untill it has executed these many instructions
      // Or untill it hits a syscall that causes it to exit
      // Untill then, you are on your own. Sit back and relax!
      return rabbitInst; 
    }

    if (mode == EmuDetail || mode == EmuTiming) {
      emul->queueInstruction(pc,addr, fid, op, src1, src2, dest, dest2, getStatsFlag());
      return 0;
    }

    I(mode == EmuWarmup);
#if 1
    if ( op == iLALU_LD || op == iSALU_ST)
      // cache warmup fake inst, do not need SRC deps (faster)
      emul->queueInstruction(0,addr, fid, op, LREG_R0, LREG_R0, LREG_InvalidOutput, LREG_InvalidOutput, false);
#else
		//doWarmupOpAddr(static_cast<InstOpcode>(op), addr);
#endif
    return 0;
  }

  // Look for the new mode
  I(getNextSwitch() <= totalnInst);

 // I(mode != next_mode);
  pthread_mutex_lock (&mode_lock);
  //

  if (getNextSwitch() > totalnInst){//another thread just changed the mode
    pthread_mutex_unlock (&mode_lock);
    return 0;
  }

  lastMode = mode;
  nextMode(ROTATE, fid);
  if (lastMode == EmuTiming) { // timing is going to be over

#if 0
		static double last_timing         = 0;
		static long long last_globalClock = 0;

		MSG("%f %lld"
				,iusage[EmuTiming]->getDouble()
				,globalClock-last_globalClock);

		last_timing      = iusage[EmuTiming]->getDouble();
		last_globalClock = globalClock;
#endif

    BootLoader::reportSample();
    
    if (getTime()>=maxnsTime || totalnInst>=nInstMax) {
      markDone();
      pthread_mutex_unlock (&mode_lock);
      return 0;
    }
    if (doPower) {
      uint64_t mytime = getTime();
      int64_t ti = mytime - lastTime;
      I(ti > 0);
      ti = (static_cast<int64_t>(freq)*ti)/1e9;

      BootLoader::getPowerModelPtr()->setSamplingRatio(getSamplingRatio()); 
      BootLoader::getPowerModelPtr()->calcStats(ti, !(lastMode == EmuTiming), fid); 
      lastTime = mytime;
      updateCPI(fid); 
      if (doTherm) {
        BootLoader::getPowerModelPtr()->updateSescTherm(ti);  
      }
    }
  }
  pthread_mutex_unlock (&mode_lock);

  return 0;
}