diff --git a/hipamd/src/hip_event.cpp b/hipamd/src/hip_event.cpp index d708fb235f..78e1605fa2 100644 --- a/hipamd/src/hip_event.cpp +++ b/hipamd/src/hip_event.cpp @@ -439,7 +439,7 @@ hipError_t hipEventSynchronize(hipEvent_t event) { hip::Stream* s = reinterpret_cast(e->GetCaptureStream()); if ((s != nullptr) && (s->GetCaptureStatus() == hipStreamCaptureStatusActive)) { s->SetCaptureStatus(hipStreamCaptureStatusInvalidated); - return HIP_RETURN(hipErrorCapturedEvent); + HIP_RETURN(hipErrorCapturedEvent); } if (hip::Stream::StreamCaptureOngoing(e->GetCaptureStream()) == true) { HIP_RETURN(hipErrorStreamCaptureUnsupported); @@ -460,7 +460,7 @@ hipError_t ihipEventQuery(hipEvent_t event) { hip::Stream* s = reinterpret_cast(e->GetCaptureStream()); if ((s != nullptr) && (s->GetCaptureStatus() == hipStreamCaptureStatusActive)) { s->SetCaptureStatus(hipStreamCaptureStatusInvalidated); - return HIP_RETURN(hipErrorCapturedEvent); + HIP_RETURN(hipErrorCapturedEvent); } return e->query(); } diff --git a/hipamd/src/hip_internal.hpp b/hipamd/src/hip_internal.hpp index d0a6dca57d..faf75f55bf 100644 --- a/hipamd/src/hip_internal.hpp +++ b/hipamd/src/hip_internal.hpp @@ -164,19 +164,34 @@ const char* ihipGetErrorName(hipError_t hip_error); HIP_RETURN(hipErrorNoDevice); \ } -#define HIP_INIT_API_NO_RETURN(cid, ...) \ +#define HIP_INIT_API_NO_RETURN(cid, ...) \ HIP_INIT_API_INTERNAL(1, cid, __VA_ARGS__) #define HIP_RETURN_DURATION(ret, ...) \ - hip::tls.last_error_ = ret; \ + hip::tls.last_command_error_ = ret; \ + if (DEBUG_HIP_7_PREVIEW & amd::CHANGE_HIP_GET_LAST_ERROR) { \ + if (ret != hipSuccess && ret != hipErrorNotReady) { \ + hip::tls.last_error_ = ret; \ + } \ + } else { \ + hip::tls.last_error_ = ret; \ + } \ HIPPrintDuration(amd::LOG_INFO, amd::LOG_API, &startTimeUs, "%s: Returned %s : %s", __func__, \ - hip::ihipGetErrorName(hip::tls.last_error_), ToString(__VA_ARGS__).c_str()); \ - return hip::tls.last_error_; + hip::ihipGetErrorName(hip::tls.last_command_error_), \ + ToString(__VA_ARGS__).c_str()); \ + return hip::tls.last_command_error_; -#define HIP_RETURN(ret, ...) \ - hip::tls.last_error_ = ret; \ - HIP_ERROR_PRINT(hip::tls.last_error_, __VA_ARGS__) \ - return hip::tls.last_error_; +#define HIP_RETURN(ret, ...) \ + hip::tls.last_command_error_ = ret; \ + if (DEBUG_HIP_7_PREVIEW & amd::CHANGE_HIP_GET_LAST_ERROR) { \ + if (ret != hipSuccess && ret != hipErrorNotReady) { \ + hip::tls.last_error_ = ret; \ + } \ + } else { \ + hip::tls.last_error_ = ret; \ + } \ + HIP_ERROR_PRINT(hip::tls.last_command_error_, __VA_ARGS__) \ + return hip::tls.last_command_error_; #define HIP_RETURN_ONFAIL(func) \ do { \ @@ -610,7 +625,7 @@ public: public: Device* device_; std::stack ctxt_stack_; - hipError_t last_error_; + hipError_t last_error_, last_command_error_; std::vector capture_streams_; hipStreamCaptureMode stream_capture_mode_; std::stack exec_stack_; @@ -618,6 +633,7 @@ public: TlsAggregator(): device_(nullptr), last_error_(hipSuccess), + last_command_error_(hipSuccess), stream_capture_mode_(hipStreamCaptureModeGlobal) { } ~TlsAggregator() { diff --git a/hipamd/src/hip_memory.cpp b/hipamd/src/hip_memory.cpp index 58133d981c..b1726d95f3 100644 --- a/hipamd/src/hip_memory.cpp +++ b/hipamd/src/hip_memory.cpp @@ -4621,7 +4621,7 @@ hipError_t hipExternalMemoryGetMappedMipmappedArray( hip::getNumChannels(mipmapDesc->formatDesc), mipmapDesc->flags}; if (!hip::CheckArrayFormat(mipmapDesc->formatDesc)) { - return HIP_RETURN(hipErrorInvalidValue); + HIP_RETURN(hipErrorInvalidValue); } HIP_RETURN(ihipMipmapArrayCreate(mipmap, &allocateArray, mipmapDesc->numLevels, diff --git a/rocclr/utils/debug.hpp b/rocclr/utils/debug.hpp index 85c171f563..78307d20af 100644 --- a/rocclr/utils/debug.hpp +++ b/rocclr/utils/debug.hpp @@ -68,6 +68,11 @@ enum LogMask { LOG_ALWAYS = -1 //!< (0xFFFFFFFF) Log always even mask flag is zero }; +// Flags to support backward incompatible changes before 7.0 +enum BreakingHipChange7 { + CHANGE_HIP_GET_LAST_ERROR = 1, //!< (0x1) HIP_GET_LAST_ERROR +}; + //! \brief log file output extern FILE* outFile; diff --git a/rocclr/utils/flags.hpp b/rocclr/utils/flags.hpp index 9fc958809d..ca176b83ae 100644 --- a/rocclr/utils/flags.hpp +++ b/rocclr/utils/flags.hpp @@ -266,9 +266,12 @@ release(bool, DEBUG_CLR_SYSMEM_POOL, true, \ release(bool, DEBUG_HIP_KERNARG_COPY_OPT, true, \ "Enable/Disable multiple kern arg copies") \ release(bool, DEBUG_CLR_USE_STDMUTEX_IN_AMD_MONITOR, false, \ - "Use std::mutex in amd::monotor") \ + "Use std::mutex in amd::monitor") \ release(bool, DEBUG_CLR_KERNARG_HDP_FLUSH_WA, false, \ "Toggle kernel arg copy workaround") \ +release(uint, DEBUG_HIP_7_PREVIEW, 0, \ + "Enables specific backward incompatible changes support before 7.0," \ + "using the mask. By default the changes are disabled and is set to 0")\ namespace amd {