Investigating Cycle Accuracy in the Cycle-Accurate Simulator Sniper

Looking at the trace of the div instruction, it appears that the time is not spent after issue, but rather that it is waiting on Dispatch the whole time.

The div latency calculation is where it first looks wrong: getInstructionLatency(68) = 1.

disassembly : div         a4, a5, a0
instruction_decoder_wlib.cc::InstructionDecoder::decode() called
totalMicroOps = numLoads + numExecs + numStores = 1 = 0 + 1 + 0
CoreModelBoomV1::getInstructionLatency(68) = 1

I wonder if things return to normal if I remove the div?

The pipeline became clean after removing div

It seems the div latency information is being propagated correctly.

Looking more carefully, it is apparently set somewhere else.

  • common/performance_model/performance_models/core_model/core_model_boom_v1.cc
unsigned int CoreModelBoomV1::getAluLatency(const MicroOp *uop) const
{
   switch(uop->getInstructionOpcode()) {
      case rv_op_div:
      case rv_op_divu:
      case rv_op_rem:
      case rv_op_remu:
      case rv_op_divw:
      case rv_op_divuw:
      case rv_op_remw:
      case rv_op_remuw:
      case rv_op_divd:
      case rv_op_divud:
      case rv_op_remd:
      case rv_op_remud:
      case rv_op_fdiv_s:
      case rv_op_fdiv_d:
      case rv_op_fdiv_q:
         return 32;     // TODO: Latency of div operations need to be more accurately determined
      default:
         return getInstructionLatency(uop);
         //LOG_PRINT_ERROR("Don't know the ALU latency for this MicroOp.");
   }

In the end, the pipeline looks like this, and you can see 32-cycle div instructions propagating one after another.


This is an English translation of the original Japanese post: サイクル精度シミュレータSniperにおけるサイクル精度の調査