Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 13th, 2013  |  syntax: C++  |  size: 2.24 KB  |  views: 23  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. void UncoreCounterState::readAndAggregate(MsrHandle * msr)
  2. {
  3.     TemporalThreadAffinity tempThreadAffinity(msr->getCoreId()); // speedup trick for Linux
  4.  
  5.     PCM * m = PCM::getInstance();
  6.     uint32 cpu_model = m->getCPUModel();
  7.     switch (cpu_model)
  8.     {
  9.     case PCM::WESTMERE_EP:
  10.     case PCM::NEHALEM_EP:
  11.     {
  12.         uint64 cUncMCFullWrites = 0;
  13.         uint64 cUncMCNormalReads = 0;
  14.         msr->read(MSR_UNCORE_PMC0, &cUncMCFullWrites);
  15.         msr->read(MSR_UNCORE_PMC1, &cUncMCNormalReads);
  16.         UncMCFullWrites += m->extractUncoreGenCounterValue(cUncMCFullWrites);
  17.         UncMCNormalReads += m->extractUncoreGenCounterValue(cUncMCNormalReads);
  18.     }
  19.     break;
  20.     case PCM::NEHALEM_EX:
  21.     case PCM::WESTMERE_EX:
  22.     {
  23.         uint64 cUncMCNormalReads = 0;
  24.         msr->read(MB0_MSR_PMU_CNT_0, &cUncMCNormalReads);
  25.         UncMCNormalReads += m->extractUncoreGenCounterValue(cUncMCNormalReads);
  26.         msr->read(MB1_MSR_PMU_CNT_0, &cUncMCNormalReads);
  27.         UncMCNormalReads += m->extractUncoreGenCounterValue(cUncMCNormalReads);
  28.  
  29.         uint64 cUncMCFullWrites = 0;                         // really good approximation of
  30.         msr->read(BB0_MSR_PERF_CNT_1, &cUncMCFullWrites);
  31.         UncMCFullWrites += m->extractUncoreGenCounterValue(cUncMCFullWrites);
  32.         msr->read(BB1_MSR_PERF_CNT_1, &cUncMCFullWrites);
  33.         UncMCFullWrites += m->extractUncoreGenCounterValue(cUncMCFullWrites);
  34.     }
  35.     break;
  36.     case PCM::JAKETOWN:
  37.     case PCM::SANDY_BRIDGE:
  38.     case PCM::IVY_BRIDGE:
  39.     {
  40.     }
  41.     break;
  42.     default:;
  43.     }
  44.  
  45.                 uint64 cC2Residency = 0;
  46.     uint64 cC3Residency = 0;
  47.     uint64 cC6Residency = 0;
  48.     uint64 cC7Residency = 0;
  49.  
  50.     msr->read(MSR_PKG_C3_RESIDENCY, &cC3Residency);
  51.     msr->read(MSR_PKG_C6_RESIDENCY, &cC6Residency);
  52.  
  53.     if(m->extendedCStateMetricsAvailable())
  54.     {
  55.         msr->read(MSR_PKG_C2_RESIDENCY, &cC2Residency);
  56.         msr->read(MSR_PKG_C7_RESIDENCY, &cC7Residency);
  57.     }
  58.  
  59.     C2Residency += cC2Residency;
  60.     C3Residency += cC3Residency;
  61.     C6Residency += cC6Residency;
  62.     C7Residency += cC7Residency;
  63. }
clone this paste RAW Paste Data