diff --git a/src/cpucounters.cpp b/src/cpucounters.cpp index 67b68e52..9d2443b0 100644 --- a/src/cpucounters.cpp +++ b/src/cpucounters.cpp @@ -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 diff --git a/src/cpucounters.h b/src/cpucounters.h index a5d39422..2e65b908 100644 --- a/src/cpucounters.h +++ b/src/cpucounters.h @@ -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; } diff --git a/src/utils.cpp b/src/utils.cpp index a131ecf7..d442a3b8 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -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"; } }