Re: [Gems-users] How to count "Privileged" instructions in Opal??


Date: Wed, 03 Jun 2009 13:40:33 -0500
From: Philip Garcia <pcgarcia@xxxxxxxx>
Subject: Re: [Gems-users] How to count "Privileged" instructions in Opal??
This is likely related to a bug I mentioned yesterday (but couldn't remember offhand) in the way contextSwitch is called in pseq.C.   Modify the pseq_mmu_reg_handler function to this.  Before it wasn't checking that a context switch was actually meant for a cpu on that psequencer properly.  I imagine the flag that checks if an instruction is privileged just checks to see if the context ==0, but I could be wrong.  Either way, it can't hurt to make this change to see if it fixes the problem.

Phil

static void pseq_mmu_reg_handler( void *pseq_obj, void *ptr,
                                  uint64 regindex, uint64 newcontext )
{

  #ifdef DEBUG_PSEQ
  DEBUG_OUT("pseq_t:mmu_reg_handler BEGIN\n");
  #endif
  int PSEQ_ID;
  pseq_t *pseq = (pseq_t *) pseq_obj;
  uint32  context_as_int = (uint32) newcontext;

  //We need to get the logical processor number, to pass in to contextSwitch:
  uint32 logical_proc_num = SIM_get_current_proc_no() % CONFIG_LOGICAL_PER_PHY_PROC;
  PSEQ_ID=SIM_get_current_proc_no()/CONFIG_LOGICAL_PER_PHY_PROC;
  ASSERT(logical_proc_num < CONFIG_LOGICAL_PER_PHY_PROC);

  // CTXT_SWITCH
  
  if (PSEQ_ID == pseq->getID())
    pseq->contextSwitch( context_as_int, logical_proc_num );      

  #ifdef DEBUG_PSEQ
  DEBUG_OUT("pseq_t:mmu_reg_handler END proc[%d] \n", logical_proc_num);
  #endif
}


On Jun 3, 2009, at 10:34 AM, David Bonavila wrote:


Hello again.

I have changed the code, and now it is like this:

/*---------------------------------------------------*/
/* Variable declarations                             */
/*---------------------------------------------------*/
bool last_mode[2] = { false, false }; // transformes it into global
int iPriv[2] = { 0, 0 }; // we have 2 cores
int iUser[2] = { 0, 0 };

[...]

if (d_instr) last_mode[proc] = d_instr->getPrivilegeMode();

[...]

m_stat_committed[proc]++; // this line was already there
if (last_mode[proc]) iPriv[proc]++; // I have added these 2 lines
else iUser[proc]++;


[...]

out_info("  %-50.50s %10llu\n", "PRIVILEGED INSTRUCTIONS:", iPriv[k]);
out_info("  %-50.50s %10llu\n", "USER_MODE  INSTRUCTIONS:", iUser[k]);

and the Opal stats file shows:

[0]   PRIVILEGED INSTRUCTIONS:                               767827
[0]   USER_MODE  INSTRUCTIONS:                               232177


[1]   PRIVILEGED INSTRUCTIONS:                               767827
[1]   USER_MODE  INSTRUCTIONS:                               232177



Now the sum of privileged + user instructions is correct, 1 million, but the number of privileged instructions is the same for the 2 cores, and the number of user instructions is the same for both cores also.

What am I doing wrong now??

Thank you!!


2009/6/2 David Bonavila <david.bonavila@xxxxxxxxxxxxxxxxxx>

Hi.

I have added the following lines to the pseq.C file:

/*------------------------------------------------------------------------*/
/* Variable declarations                                                  */
/*------------------------------------------------------------------------*/
int iPriv[2] = { 0, 0 };
// I am simulating a 2-core processor
int iUser[2] = { 0, 0 };

if (d_instr) {
  last_mode = d_instr->getPrivilegeMode(); // this line already existed
  if (last_mode) iPriv[proc]++; // I have added these two lines
  else iUser[proc]++;
}

out_info("  %-50.50s %10llu\n", "PRIVILEGED INSTRUCTIONS:", iPriv[k]);
out_info("  %-50.50s %10llu\n", "USER_MODE  INSTRUCTIONS:", iUser[k]);


I have simulated 1 Million instructions with Opal, and the Opal output file has this:

[0]   PRIVILEGED INSTRUCTIONS:                                 219278
[0]   USER_MODE  INSTRUCTIONS:                                 175210

[1]   PRIVILEGED INSTRUCTIONS:                                 219278
[1]   USER_MODE  INSTRUCTIONS:                                 175210

The two processors have executed the same number of privileged instructions??
And the total instructions (Privileged + User) is different from 1M (I have changed Opal so the number of instructions passed to the opal0.sim-step command is the TOTAL number of instructions executed between all processors, not just CPU0).
I am simulating a workload which runs only 1 thread.

Is all this right??
Am I doing something wrong??

Thanks!!


_______________________________________________
Gems-users mailing list
Gems-users@xxxxxxxxxxx
https://lists.cs.wisc.edu/mailman/listinfo/gems-users
Use Google to search the GEMS Users mailing list by adding "site:https://lists.cs.wisc.edu/archive/gems-users/" to your search.


[← Prev in Thread] Current Thread [Next in Thread→]