Skip to content

Commit e36cf0d

Browse files
committed
better error output
1 parent 7e030ad commit e36cf0d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/cpucounters.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2969,6 +2969,8 @@ void PCM::checkError(const PCM::ErrorCode code)
29692969
}
29702970
}
29712971

2972+
std::mutex printErrorMutex;
2973+
29722974
PCM::ErrorCode PCM::programCoreCounters(const int i /* core */,
29732975
const PCM::ProgramMode mode_,
29742976
const ExtendedCustomCoreEventDescription * pExtDesc,
@@ -3011,6 +3013,7 @@ PCM::ErrorCode PCM::programCoreCounters(const int i /* core */,
30113013
if ((perfEventHandle[i][eventPos] = syscall(SYS_perf_event_open, &e, -1,
30123014
i /* core id */, leader_counter /* group leader */, 0)) <= 0)
30133015
{
3016+
std::lock_guard<std::mutex> _(printErrorMutex);
30143017
std::cerr << "Linux Perf: Error when programming " << eventName << ", error: " << strerror(errno) <<
30153018
" with config 0x" << std::hex << e.config <<
30163019
" config1 0x" << e.config1 << std::dec << "\n";
@@ -3239,6 +3242,7 @@ PCM::ErrorCode PCM::programCoreCounters(const int i /* core */,
32393242
}
32403243
else
32413244
{
3245+
std::lock_guard<std::mutex> _(printErrorMutex);
32423246
std::cerr << "ERROR: unknown token " << token << " in event description \"" << eventDesc << "\" from " << event.first << "\n";
32433247
decrementInstanceSemaphore();
32443248
return PCM::UnknownError;
@@ -4742,7 +4746,11 @@ PCM::ErrorCode PCM::program(const RawPMUConfigs& curPMUConfigs_, const bool sile
47424746
auto corePMUConfig = curPMUConfigs["core"];
47434747
if (corePMUConfig.programmable.size() > (size_t)getMaxCustomCoreEvents())
47444748
{
4745-
std::cerr << "ERROR: trying to program " << corePMUConfig.programmable.size() << " core PMU counters, which exceeds the max num possible ("<< getMaxCustomCoreEvents() << ").";
4749+
std::cerr << "ERROR: trying to program " << corePMUConfig.programmable.size() << " core PMU counters, which exceeds the max num possible ("<< getMaxCustomCoreEvents() << ").\n";
4750+
for (const auto & e : corePMUConfig.programmable)
4751+
{
4752+
std::cerr << " Event: " << e.second << "\n";
4753+
}
47464754
return PCM::UnknownError;
47474755
}
47484756
size_t c = 0;

0 commit comments

Comments
 (0)