SWDEV-378006 - Adding a new guarantee macro to support printing args.

Change-Id: I9c838644e31a84d96a44b2bd10525a08d805a047


[ROCm/clr commit: b968394b4e]
Esse commit está contido em:
kjayapra-amd
2023-01-18 13:25:07 -08:00
commit de Karthik Jayaprakash
commit b4ffe0e810
5 arquivos alterados com 15 adições e 35 exclusões
+6 -4
Ver Arquivo
@@ -729,14 +729,16 @@ bool HostBlitManager::FillBufferInfo::PackInfo(const device::Memory& memory, siz
std::vector<FillBufferInfo>& 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);
+2 -4
Ver Arquivo
@@ -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;
}
}
+4 -10
Ver Arquivo
@@ -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<uintptr_t>(k));
if (rval != 1) {
DevLogPrintfError("Memobj map does not have ptr: 0x%x",
reinterpret_cast<uintptr_t>(k));
guarantee(false, "Memobj map does not have ptr");
}
guarantee(rval == 1, "Memobj map does not have ptr: 0x%x",
reinterpret_cast<uintptr_t>(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<uintptr_t>(k));
if (rval != 1) {
DevLogPrintfError("Virtual Memobj map does not have ptr: 0x%x",
reinterpret_cast<uintptr_t>(k));
guarantee(false, "VirtualMemobj map does not have ptr");
}
guarantee(rval == 1, "Virtual Memobj map does not have ptr: 0x%x",
reinterpret_cast<uintptr_t>(k));
}
amd::Memory* MemObjMap::FindVirtualMemObj(const void* k) {
-11
Ver Arquivo
@@ -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); }
+3 -6
Ver Arquivo
@@ -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__)