diff --git a/rocclr/hip_code_object.cpp b/rocclr/hip_code_object.cpp index dff006d335..8b89647e89 100755 --- a/rocclr/hip_code_object.cpp +++ b/rocclr/hip_code_object.cpp @@ -124,7 +124,7 @@ hipError_t DynCO::loadCodeObject(const char* fname, const void* image) { const void *mmap_ptr = nullptr; size_t mmap_size = 0; - guarantee(fname || image); + guarantee((fname || image) && "Both filename or image are nullptr"); if (fname != nullptr) { /* We are given file name */ diff --git a/rocclr/hip_global.cpp b/rocclr/hip_global.cpp index 680d16b03f..1211d99556 100755 --- a/rocclr/hip_global.cpp +++ b/rocclr/hip_global.cpp @@ -14,20 +14,20 @@ DeviceVar::DeviceVar(std::string name, hipModule_t hmod) : shadowVptr(nullptr), amd::Program* program = as_amd(reinterpret_cast(hmod)); device::Program* dev_program = program->getDeviceProgram(*hip::getCurrentDevice()->devices()[0]); if (dev_program == nullptr) { - DevLogPrintfError("Cannot get Device Function for module: 0x%x \n", hmod); - guarantee(false); + DevLogPrintfError("Cannot get Device Program for module: 0x%x \n", hmod); + guarantee(false && "Cannot get Device Program"); } if(!dev_program->createGlobalVarObj(&amd_mem_obj_, &device_ptr_, &size_, name.c_str())) { DevLogPrintfError("Cannot create Global Var obj for symbol: %s \n", name.c_str()); - guarantee(false); + guarantee(false && "Cannot create GlobalVar Obj"); } // Handle size 0 symbols if (size_ != 0) { if (amd_mem_obj_ == nullptr || device_ptr_ == nullptr) { DevLogPrintfError("Cannot get memory for creating device Var: %s", name.c_str()); - guarantee(false); + guarantee(false && "Cannot get memory for creating device var"); } amd::MemObjMap::AddMemObj(device_ptr_, amd_mem_obj_); } @@ -57,13 +57,13 @@ DeviceFunc::DeviceFunc(std::string name, hipModule_t hmod) : dflock_("function l const amd::Symbol *symbol = program->findSymbol(name.c_str()); if (symbol == nullptr) { DevLogPrintfError("Cannot find Symbol with name: %s \n", name.c_str()); - guarantee(false); + guarantee(false && "Cannot find Symbol"); } kernel_ = new amd::Kernel(*program, *symbol, name); if (kernel_ == nullptr) { DevLogPrintfError("Cannot create kernel with name: %s \n", name.c_str()); - guarantee(false); + guarantee(false && "Cannot Create kernel"); } } @@ -88,7 +88,7 @@ Function::~Function() { } hipError_t Function::getDynFunc(hipFunction_t* hfunc, hipModule_t hmod) { - guarantee(dFunc_.size() == g_devices.size()); + guarantee((dFunc_.size() == g_devices.size()) && "dFunc Size mismatch"); if (dFunc_[ihipGetDevice()] == nullptr) { dFunc_[ihipGetDevice()] = new DeviceFunc(name_, hmod); } @@ -98,9 +98,10 @@ hipError_t Function::getDynFunc(hipFunction_t* hfunc, hipModule_t hmod) { } hipError_t Function::getStatFunc(hipFunction_t* hfunc, int deviceId) { - guarantee(modules_ != nullptr); - guarantee(deviceId >= 0); - guarantee(static_cast(deviceId) < modules_->size()); + guarantee(modules_ != nullptr && "Module not initialized"); + guarantee((deviceId >= 0) && "Invalid DeviceId, less than zero"); + guarantee((static_cast(deviceId) < modules_->size()) + && "Invalid DeviceId, greater than no of code objects"); hipModule_t module = (*modules_)[deviceId].first; FatBinaryMetaInfo* fb_meta = (*modules_)[deviceId].second; @@ -121,9 +122,10 @@ hipError_t Function::getStatFunc(hipFunction_t* hfunc, int deviceId) { } hipError_t Function::getStatFuncAttr(hipFuncAttributes* func_attr, int deviceId) { - guarantee(modules_ != nullptr); - guarantee(deviceId >= 0); - guarantee(static_cast(deviceId) < modules_->size()); + guarantee((modules_ != nullptr) && "Module not initialized"); + guarantee((deviceId >= 0) && "Invalid DeviceId, less than zero"); + guarantee((static_cast(deviceId) < modules_->size()) + && "Invalid DeviceId, greater than no of code objects"); hipModule_t module = (*modules_)[deviceId].first; FatBinaryMetaInfo* fb_meta = (*modules_)[deviceId].second; @@ -175,9 +177,11 @@ Var::~Var() { } hipError_t Var::getDeviceVar(DeviceVar** dvar, int deviceId, hipModule_t hmod) { - guarantee(deviceId >= 0); - guarantee(static_cast(deviceId) < g_devices.size()); - guarantee(dVar_.size() == g_devices.size()); + guarantee((deviceId >= 0) && "Invalid DeviceId, less than zero"); + guarantee((static_cast(deviceId) < g_devices.size()) + && "Invalid DeviceId, greater than no of code objects"); + guarantee((dVar_.size() == g_devices.size()) + && "Device Var not initialized to size"); if (dVar_[deviceId] == nullptr) { dVar_[deviceId] = new DeviceVar(name_, hmod); @@ -188,8 +192,9 @@ hipError_t Var::getDeviceVar(DeviceVar** dvar, int deviceId, hipModule_t hmod) { } hipError_t Var::getStatDeviceVar(DeviceVar** dvar, int deviceId) { - guarantee(deviceId >= 0); - guarantee(static_cast(deviceId) < g_devices.size()); + guarantee((deviceId >= 0) && "Invalid DeviceId, less than zero"); + guarantee((static_cast(deviceId) < g_devices.size()) + && "Invalid DeviceId, greater than no of code objects"); hipModule_t module = (*modules_)[deviceId].first; FatBinaryMetaInfo* fb_meta = (*modules_)[deviceId].second; diff --git a/rocclr/hip_platform.cpp b/rocclr/hip_platform.cpp index 3935e4d5f8..2d74d8f440 100755 --- a/rocclr/hip_platform.cpp +++ b/rocclr/hip_platform.cpp @@ -127,7 +127,7 @@ extern "C" void __hipRegisterFunction( hipError_t hip_error = hipSuccess; for (size_t dev_idx = 0; dev_idx < g_devices.size(); ++dev_idx) { hip_error = PlatformState::instance().getStatFunc(&hfunc, hostFunction, dev_idx); - guarantee(hip_error == hipSuccess); + guarantee((hip_error == hipSuccess) && "Cannot Retrieve Static function"); } } }