message: pcm-raw: overhead reduction for single group collection
diff: @@ -1346,12 +1346,21 @@ int main(int argc, char* argv[])
  {
  if (!group.empty()) ++nGroups;
  }
  + for (size_t i = 0; i < PMUConfigs.size(); ++i)
  + {
  + if (PMUConfigs[i].empty())
  + { // erase empty groups
  + PMUConfigs.erase(PMUConfigs.begin() + i);
  + --i;
  + }
  + }
  + assert(PMUConfigs.size() == nGroups);
  if (nGroups == 0)
  {
  cout << "No events specified. Exiting.\n";
  exit(EXIT_FAILURE);
  }
  - cout << "Collecting " << nGroups << " event groups\n";
  + cout << "Collecting " << nGroups << " event group(s)\n";
  if (nGroups > 1)
  {
  @@ -1393,11 +1402,8 @@ int main(int argc, char* argv[])
  MySystem(sysCmd, sysArgv);
  }
  - mainLoop([&]()
  + auto programAndReadGroup = [&](const PCM::RawPMUConfigs & group)
  {
  - for (const auto group : PMUConfigs)
  - {
  - if (group.empty()) continue;
  if (forceRTMAbortMode)
  {
  m->enableForceRTMAbortMode(true);
  @@ -1408,6 +1414,23 @@ int main(int argc, char* argv[])
  {
  BeforeUncoreState[s] = m->getServerUncoreCounterState(s);
  }
  + };
  +
  + if (nGroups == 1)
  + {
  + programAndReadGroup(PMUConfigs[0]);
  + }
  +
  + mainLoop([&]()
  + {
  + for (const auto & group : PMUConfigs)
  + {
  + if (group.empty()) continue;
  +
  + if (nGroups > 1)
  + {
  + programAndReadGroup(group);
  + }
  calibratedSleep(delay, sysCmd, mainLoop, m);
  @@ -1421,8 +1444,16 @@ int main(int argc, char* argv[])
  //cout << "Called sleep function for " << dec << fixed << delay_ms << " ms\n";
  printAll(group, m, BeforeState, AfterState, BeforeUncoreState, AfterUncoreState);
  + if (nGroups > 1)
  + {
  m->cleanup(true);
  }
  + else
  + {
  + std::swap(BeforeState, AfterState);
  + std::swap(BeforeUncoreState, AfterUncoreState);
  + }
  + }
  if (m->isBlocked()) {
  // in case PCM was blocked after spawning child application: break monitoring loop here
  return false;
  