From fc3891f159e32149e7ef2823527326825ec4cafc Mon Sep 17 00:00:00 2001 From: Pierre Pebay Date: Wed, 13 Nov 2024 17:43:51 +0100 Subject: [PATCH] #2302: Fix PAPI error handling --- src/vt/context/context.h | 3 +-- src/vt/context/runnable_context/papi_data.h | 10 ++++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/vt/context/context.h b/src/vt/context/context.h index 3b5ecfd20e..ba6602d8a4 100644 --- a/src/vt/context/context.h +++ b/src/vt/context/context.h @@ -130,8 +130,7 @@ struct Context : runtime::component::Component { #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 diff --git a/src/vt/context/runnable_context/papi_data.h b/src/vt/context/runnable_context/papi_data.h index 8e273959d6..d2fc63a0f4 100644 --- a/src/vt/context/runnable_context/papi_data.h +++ b/src/vt/context/runnable_context/papi_data.h @@ -45,6 +45,7 @@ #define INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_LB_DATA_PAPI_DATA_H #include +#include INCLUDE_FMT_CORE namespace vt { namespace ctx { @@ -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()