You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now this function has side effects (program exiting, console reading and writing):
voidPCM::checkError(const PCM::ErrorCode code)
{
switch (code)
{
case PCM::Success:
break;
case PCM::MSRAccessDenied:
std::cerr << "Access to Intel(r) Performance Counter Monitor has denied (no MSR or PCI CFG space access).\n";
exit(EXIT_FAILURE);
case PCM::PMUBusy:
std::cerr << "Access to Intel(r) Performance Counter Monitor has denied (Performance Monitoring Unit is occupied by other application)\n";
std::cerr << "Try to stop the application that uses PMU, or reset PMU configuration from PCM application itself\n";
std::cerr << "You can try to reset PMU configuration now. Try to reset? (y/n)\n";
charyn;
std::cin >> yn;
if ('y' == yn)
{
resetPMU();
std::cerr << "PMU configuration has been reset. Try to rerun the program again.\n";
}
exit(EXIT_FAILURE);
default:
std::cerr << "Access to Intel(r) Performance Counter Monitor has denied (Unknown error).\n";
exit(EXIT_FAILURE);
}
}
But it's not very convenient when PCM is used as a library in the applications, other than built-in utilities.
Probably creating another function, which will be generate exceptions and use it in the checkError() will be convenient?
I.e.:
voidcheck_pcm_status(const pcm::PCM::ErrorCode& status)
{
switch (status)
{
case pcm::PCM::Success:
{
// Some logging?// SPDLOG_TRACE("PCM instance programming is ok");break;
}
case pcm::PCM::MSRAccessDenied:
throwsystem_error(pcm::PCM::MSRAccessDenied, std::generic_category(),
"Access to Intel(r) Performance Counter Monitor has denied (no MSR or PCI CFG space access).");
case pcm::PCM::PMUBusy:
throwsystem_error(pcm::PCM::PMUBusy, std::generic_category(),
"Access to Intel(r) Performance Counter Monitor has denied (Performance Monitoring Unit"" is occupied by other application). Try to stop the application that uses PMU,"" or reset PMU configuration from PCM application itself");
default:
throwsystem_error(pcm::PCM::UnknownError, std::generic_category(),
"Access to Intel(r) Performance Counter Monitor has denied (Unknown error).");
}
}
...
voidPCM::checkError(const PCM::ErrorCode code)
{
try
{
check_pcm_status(code);
}
catch (const std::system_error &e)
{
switch (e.code())
{
case PCM::PMUBusy:
std::cerr << e.what() << "\n"
<< "You can try to reset PMU configuration now. Try to reset? (y/n)" << std::endl;
charyn;
std::cin >> yn;
if ('y' == yn)
{
resetPMU();
std::cerr << "PMU configuration has been reset. Try to rerun the program again." << std::endl;
}
exit(EXIT_FAILURE);
case PCM::MSRAccessDenied:
default:
std::cerr << e.what() << std::endl;
exit(EXIT_FAILURE);
}
}
}
The text was updated successfully, but these errors were encountered:
Now this function has side effects (program exiting, console reading and writing):
But it's not very convenient when PCM is used as a library in the applications, other than built-in utilities.
Probably creating another function, which will be generate exceptions and use it in the
checkError()
will be convenient?I.e.:
The text was updated successfully, but these errors were encountered: