From c66675d1924a6011f8ec424bd4b90c024ec07474 Mon Sep 17 00:00:00 2001 From: Sean Keely Date: Fri, 15 Feb 2019 18:30:32 -0600 Subject: [PATCH] Suppress exception reporting for well defined invalid signal handles. hsa_exceptions with empty what() strings will not report in debug builds. Change-Id: I0d424d3b1d3044808ece1720a460a57d68bf878e [ROCm/ROCR-Runtime commit: 344d964f9f3f2475539a65d84aa898700554fd14] --- projects/rocr-runtime/runtime/hsa-runtime/core/inc/signal.h | 3 +-- .../runtime/hsa-runtime/core/runtime/hsa_ext_amd.cpp | 4 +++- projects/rocr-runtime/runtime/hsa-runtime/core/util/utils.h | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/inc/signal.h b/projects/rocr-runtime/runtime/hsa-runtime/core/inc/signal.h index 5209fb7430..82ca6d193d 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/inc/signal.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/inc/signal.h @@ -198,8 +198,7 @@ class Signal { /// @brief Converts from public hsa_signal_t type (an opaque handle) to /// this interface class object. static __forceinline Signal* Convert(hsa_signal_t signal) { - if (signal.handle == 0) - throw AMD::hsa_exception(HSA_STATUS_ERROR_INVALID_ARGUMENT, "Signal handle is invalid."); + if (signal.handle == 0) throw AMD::hsa_exception(HSA_STATUS_ERROR_INVALID_ARGUMENT, ""); SharedSignal* shared = SharedSignal::Convert(signal); if (!shared->IsValid()) throw AMD::hsa_exception(HSA_STATUS_ERROR_INVALID_SIGNAL, "Signal handle is invalid."); diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa_ext_amd.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa_ext_amd.cpp index b4b5d49006..3e690ff35a 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa_ext_amd.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa_ext_amd.cpp @@ -133,7 +133,9 @@ hsa_status_t handleException() { debug_print("HSA exception: BadAlloc\n"); return HSA_STATUS_ERROR_OUT_OF_RESOURCES; } catch (const hsa_exception& e) { - debug_print("HSA exception: %s\n", e.what()); + ifdebug { + if (!strIsEmpty(e.what())) debug_print("HSA exception: %s\n", e.what()); + } return e.error_code(); } catch (const std::exception& e) { debug_print("Unhandled exception: %s\n", e.what()); diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/util/utils.h b/projects/rocr-runtime/runtime/hsa-runtime/core/util/utils.h index a512c54f24..f7f09e9d7c 100755 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/util/utils.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/util/utils.h @@ -305,6 +305,8 @@ static __forceinline uint64_t NextPow2(uint64_t value) { return v + 1; } +static __forceinline bool strIsEmpty(const char* str) noexcept { return str[0] == '\0'; } + #include "atomic_helpers.h" #endif // HSA_RUNTIME_CORE_UTIL_UTIIS_H_