Skip to content

Commit

Permalink
#2302: Fix PAPI error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrepebay committed Dec 12, 2024
1 parent 73cc34b commit fc3891f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/vt/context/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ struct Context : runtime::component::Component<Context> {
#if vt_check_enabled(papi)
void handle_papi_error (int retval)
{
printf("PAPI error %d: %s\n", retval, PAPI_strerror(retval));
exit(1);
vtAbort(fmt::format("PAPI error {}: {}\n", retval, PAPI_strerror(retval)));
}
#endif

Expand Down
10 changes: 4 additions & 6 deletions src/vt/context/runnable_context/papi_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#define INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_LB_DATA_PAPI_DATA_H

#include <papi.h>
#include INCLUDE_FMT_CORE

namespace vt { namespace ctx {

Expand Down Expand Up @@ -107,21 +108,18 @@ struct PAPIData {
native = 0x0;
retval = PAPI_event_name_to_code(native_events[i].c_str(), &native);
if (retval != PAPI_OK) {
printf("Couldn't event_name_to_code for %s: PAPI error %d: %s\n",native_events[i].c_str(), retval, PAPI_strerror(retval));
exit(1);
vtAbort(fmt::format("Couldn't event_name_to_code for {}: PAPI error {}: {}\n", native_events[i].c_str(), retval, PAPI_strerror(retval)));
}
retval = PAPI_add_event(EventSet, native);
if (retval != PAPI_OK) {
printf("Couldn't add %s to the PAPI Event Set: PAPI error %d: %s\n",native_events[i].c_str(), retval, PAPI_strerror(retval));
exit(1);
vtAbort(fmt::format("Couldn't add {} to the PAPI Event Set: PAPI error {}: {}\n", native_events[i].c_str(), retval, PAPI_strerror(retval)));
}
}
}

void handle_error (std::string info) const
{
printf("%s: PAPI error %d: %s\n", info.c_str(), retval, PAPI_strerror(retval));
exit(1);
vtAbort(fmt::format("{}: PAPI error {}: {}\n", info.c_str(), retval, PAPI_strerror(retval)));
}

void start()
Expand Down

0 comments on commit fc3891f

Please sign in to comment.