diff --git a/projects/clr/rocclr/device/blit.cpp b/projects/clr/rocclr/device/blit.cpp index 3c6b5dbf35..a2c25376b4 100644 --- a/projects/clr/rocclr/device/blit.cpp +++ b/projects/clr/rocclr/device/blit.cpp @@ -729,14 +729,16 @@ bool HostBlitManager::FillBufferInfo::PackInfo(const device::Memory& memory, siz std::vector& packed_info) { // 1. Validate input arguments - guarantee(fill_size >= pattern_size, "Pattern Size cannot be greater than fill size"); - guarantee(fill_size <= memory.size(), "Cannot fill more than the mem object size"); + guarantee(fill_size >= pattern_size, "Pattern Size: %u cannot be greater than fill size: %u \n", + pattern_size, fill_size); + guarantee(fill_size <= memory.size(), "Cannot fill: %u more than the mem object size:%u \n", + fill_size, memory.size()); // 2. Calculate the next closest dword aligned address for faster processing size_t dst_addr = memory.virtualAddress() + fill_origin; size_t aligned_dst_addr = amd::alignUp(dst_addr, sizeof(size_t)); - guarantee(aligned_dst_addr >= dst_addr, "Aligned address cannot be greater than destination" - "address"); + guarantee(aligned_dst_addr >= dst_addr, "Aligned address: %u cannot be greater than destination" + "address :%u \n", aligned_dst_addr, dst_addr); // 3. If given address is not aligned calculate head and tail size. size_t head_size = std::min(aligned_dst_addr - dst_addr, fill_size); diff --git a/projects/clr/rocclr/device/devhostcall.cpp b/projects/clr/rocclr/device/devhostcall.cpp index 8226e3daee..12e5fe905f 100644 --- a/projects/clr/rocclr/device/devhostcall.cpp +++ b/projects/clr/rocclr/device/devhostcall.cpp @@ -84,7 +84,7 @@ static void handlePayload(MessageHandler& messages, uint32_t service, uint64_t* if (!messages.handlePayload(service, payload)) { ClPrint(amd::LOG_ERROR, amd::LOG_ALWAYS, "Hostcall: invalid request for service \"%d\".", service); - amd::report_fatal(__FILE__, __LINE__, "Hostcall: invalid service request."); + guarantee(false, "Hostcall: invalid service request %d \n", service); } return; case SERVICE_DEVMEM: { @@ -114,9 +114,7 @@ static void handlePayload(MessageHandler& messages, uint32_t service, uint64_t* return; } default: - ClPrint(amd::LOG_ERROR, amd::LOG_ALWAYS, "Hostcall: no handler found for service ID \"%d\".", - service); - amd::report_fatal(__FILE__, __LINE__, "Hostcall service not supported."); + guarantee(false, "Hostcall: no handler found for service ID %d \n", service); return; } } diff --git a/projects/clr/rocclr/device/device.cpp b/projects/clr/rocclr/device/device.cpp index 2709febd8b..f87452dbd5 100644 --- a/projects/clr/rocclr/device/device.cpp +++ b/projects/clr/rocclr/device/device.cpp @@ -289,11 +289,8 @@ void MemObjMap::AddMemObj(const void* k, amd::Memory* v) { void MemObjMap::RemoveMemObj(const void* k) { amd::ScopedLock lock(AllocatedLock_); auto rval = MemObjMap_.erase(reinterpret_cast(k)); - if (rval != 1) { - DevLogPrintfError("Memobj map does not have ptr: 0x%x", - reinterpret_cast(k)); - guarantee(false, "Memobj map does not have ptr"); - } + guarantee(rval == 1, "Memobj map does not have ptr: 0x%x", + reinterpret_cast(k)); } amd::Memory* MemObjMap::FindMemObj(const void* k, size_t* offset) { @@ -328,11 +325,8 @@ void MemObjMap::AddVirtualMemObj(const void* k, amd::Memory* v) { void MemObjMap::RemoveVirtualMemObj(const void* k) { amd::ScopedLock lock(AllocatedLock_); auto rval = VirtualMemObjMap_.erase(reinterpret_cast(k)); - if (rval != 1) { - DevLogPrintfError("Virtual Memobj map does not have ptr: 0x%x", - reinterpret_cast(k)); - guarantee(false, "VirtualMemobj map does not have ptr"); - } + guarantee(rval == 1, "Virtual Memobj map does not have ptr: 0x%x", + reinterpret_cast(k)); } amd::Memory* MemObjMap::FindVirtualMemObj(const void* k) { diff --git a/projects/clr/rocclr/utils/debug.cpp b/projects/clr/rocclr/utils/debug.cpp index fc60756455..cdda2516b8 100644 --- a/projects/clr/rocclr/utils/debug.cpp +++ b/projects/clr/rocclr/utils/debug.cpp @@ -49,17 +49,6 @@ extern "C" void breakpoint(void) { } //! \endcond -// ================================================================================================ -void report_fatal(const char* file, int line, const char* message) { - // FIXME_lmoriche: Obfuscate the message string - #if (defined(DEBUG)) - fprintf(outFile, "%s:%d: %s\n", file, line, message); - #else - fprintf(outFile, "%s\n", message); - #endif - ::abort(); -} - // ================================================================================================ void report_warning(const char* message) { fprintf(outFile, "Warning: %s\n", message); } diff --git a/projects/clr/rocclr/utils/debug.hpp b/projects/clr/rocclr/utils/debug.hpp index dd3ffd6eb2..07cb3b61e8 100644 --- a/projects/clr/rocclr/utils/debug.hpp +++ b/projects/clr/rocclr/utils/debug.hpp @@ -66,9 +66,6 @@ extern FILE* outFile; extern "C" void breakpoint(); //! \endcond -//! \brief Report a Fatal exception message and abort. -extern void report_fatal(const char* file, int line, const char* message); - //! \brief Display a warning message. extern void report_warning(const char* message); @@ -94,10 +91,10 @@ extern void log_printf(LogLevel level, const char* file, int line, uint64_t *sta #endif // __INTEL_COMPILER //! \brief Abort the program if the invariant \a cond is false. -#define guarantee(cond, message) \ +#define guarantee(cond, format, ...) \ if (!(cond)) { \ - amd::report_fatal(__FILE__, __LINE__, XSTR(message) ); \ - amd::breakpoint(); \ + amd::log_printf(amd::LOG_NONE, __FILE__, __LINE__, format, ##__VA_ARGS__); \ + ::abort(); \ } #define fixme_guarantee(cond, ...) guarantee(cond, __VA_ARGS__)