Skip to content

Commit

Permalink
pcm-pcie: Fix issues with delay
Browse files Browse the repository at this point in the history
There were two issues with delay in pcm-pcie:
1. delay (in second) provided by user is a double value and it was casted to integer w/o any
converting. Convert it to ms to avoid this issue.

2. Double delay in getEventGroup(): for collecting events in 'before'
and 'after' cases. Use delay only once
  • Loading branch information
Alexander Antonov authored and rdementi committed Feb 16, 2023
1 parent a2ac6af commit c689a9f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
10 changes: 7 additions & 3 deletions src/pcm-pcie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,18 +222,22 @@ int mainThrows(int argc, char * argv[])
// for non-CSV mode delay < 1.0 does not make a lot of practical sense:
// hard to read from the screen, or
// in case delay is not provided in command line => set default
if ( ((delay<1.0) && (delay>0.0)) || (delay<=0.0) ) delay = PCM_DELAY_DEFAULT;
if ( ((delay < 1.0) && (delay > 0.0)) || (delay <= 0.0) ) {
cerr << "For non-CSV mode delay < 1.0s does not make a lot of practical sense. Default delay 1s is used. Consider to use CSV mode for lower delay values\n";
delay = PCM_DELAY_DEFAULT;
}
}

cerr << "Update every " << delay << " seconds\n";

// Delay in miliseconds
unique_ptr<IPlatform> platform(IPlatform::getPlatform(m, csv, print_bandwidth,
print_additional_info, (uint)delay)); // FIXME: do we support only integer delay? ; lgtm [cpp/fixme-comment]
print_additional_info, (uint)(delay * 1000)));

if (!platform)
{
print_cpu_details();
cerr << "Jaketown, Ivytown, Haswell, Broadwell-DE Server CPU is required for this tool! Program aborted\n";
cerr << "Jaketown, Ivytown, Haswell, Broadwell-DE, Skylake, Icelake, Snowridge and Sapphirerapids Server CPU is required for this tool! Program aborted\n";
exit(EXIT_FAILURE);
}

Expand Down
13 changes: 7 additions & 6 deletions src/pcm-pcie.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ class LegacyPlatform: public IPlatform
int eventsCount = 0;
for (auto &group : eventGroups) eventsCount += (int)group.size();

m_delay = uint32(delay * 1000 / (eventGroups.size()) / NUM_SAMPLES);
if (m_delay * eventsCount * NUM_SAMPLES < delay * 1000) ++m_delay;
// Delay for each multiplexing group. Counters will be scaled.
m_delay = uint32(delay / eventGroups.size() / NUM_SAMPLES);

eventSample.resize(m_socketCount);
for (auto &e: eventSample)
Expand Down Expand Up @@ -182,11 +182,12 @@ void LegacyPlatform::getEventGroup(eventGroup_t &eventGroup)
m_pcm->programPCIeEventGroup(eventGroup);
uint offset = eventGroupOffset(eventGroup);

for (auto &run : eventCount) {
for(uint skt =0; skt < m_socketCount; ++skt)
for (int run = before; run < total; run++) {
for (uint skt = 0; skt < m_socketCount; ++skt)
for (uint ctr = 0; ctr < eventGroup.size(); ++ctr)
run[skt][ctr + offset] = m_pcm->getPCIeCounterData(skt, ctr);
MySleepMs(m_delay);
eventCount[run][skt][ctr + offset] = m_pcm->getPCIeCounterData(skt, ctr);
if (run == before)
MySleepMs(m_delay);
}

for(uint skt = 0; skt < m_socketCount; ++skt)
Expand Down

0 comments on commit c689a9f

Please sign in to comment.