Skip to content

Commit

Permalink
make print_help_force_rtm_abort_mode more robust
Browse files Browse the repository at this point in the history
Change-Id: I91e3b0249b98a217d6b985aedff21d17cdda5ad4
  • Loading branch information
rdementi committed Nov 6, 2024
1 parent 49a6186 commit 652c772
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/cpucounters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4636,7 +4636,7 @@ void PCM::disableForceRTMAbortMode(const bool silent)
}
}

bool PCM::isForceRTMAbortModeAvailable() const
bool PCM::isForceRTMAbortModeAvailable()
{
PCM_CPUID_INFO info;
pcm_cpuid(7, 0, info); // leaf 7, subleaf 0
Expand Down
2 changes: 1 addition & 1 deletion src/cpucounters.h
Original file line number Diff line number Diff line change
Expand Up @@ -2405,7 +2405,7 @@ class PCM_API PCM
void disableForceRTMAbortMode(const bool silent = false);

//! \brief queries availability of "force all RTM transaction abort" mode
bool isForceRTMAbortModeAvailable() const;
static bool isForceRTMAbortModeAvailable();

//! \brief Get microcode level (returns -1 if retrieval not supported due to some restrictions)
int64 getCPUMicrocodeLevel() const { return cpu_microcode_level; }
Expand Down
29 changes: 22 additions & 7 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,16 +812,31 @@ int calibratedSleep(const double delay, const char* sysCmd, const MainLoop& main

void print_help_force_rtm_abort_mode(const int alignment, const char * separator)
{
const auto m = PCM::getInstance();
if (m->isForceRTMAbortModeAvailable() && (m->getMaxCustomCoreEvents() < 4))
if (PCM::isForceRTMAbortModeAvailable() == false)
{
return;
}
try
{
std::cout << " -force-rtm-abort-mode";
for (int i = 0; i < (alignment - 23); ++i)
const auto m = PCM::getInstance();
if (m->getMaxCustomCoreEvents() < 4)
{
std::cout << " ";
std::cout << " -force-rtm-abort-mode";
for (int i = 0; i < (alignment - 23); ++i)
{
std::cout << " ";
}
assert(separator);
std::cout << separator << " force RTM transaction abort mode to enable more programmable counters\n";
}
assert(separator);
std::cout << separator << " force RTM transaction abort mode to enable more programmable counters\n";
}
catch (std::exception & e)
{
std::cerr << "ERROR: " << e.what() << "\n";
}
catch (...)
{
std::cerr << "ERROR: Unknown exception caught in print_help_force_rtm_abort_mode\n";
}
}

Expand Down

0 comments on commit 652c772

Please sign in to comment.