From 12883eee8c7db8a5d095fb4d694d7dd4a43fc139 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Thu, 17 Mar 2022 17:42:34 +0000 Subject: [PATCH] Various build fixes warning proposal. Mainly around ignored return statuses. --- src/hip_device_runtime.cpp | 18 +++++++++--------- src/hip_platform.cpp | 25 ++++++++++++++----------- src/hip_prof_api.h | 7 +++++++ src/hip_stream.cpp | 6 +++--- src/hip_surface.cpp | 10 +++------- src/hip_texture.cpp | 2 +- 6 files changed, 37 insertions(+), 31 deletions(-) diff --git a/src/hip_device_runtime.cpp b/src/hip_device_runtime.cpp index 0e9733d9..a6277f6c 100644 --- a/src/hip_device_runtime.cpp +++ b/src/hip_device_runtime.cpp @@ -33,7 +33,7 @@ hipError_t hipChooseDevice(int* device, const hipDeviceProp_t* properties) { *device = 0; cl_uint maxMatchedCount = 0; int count = 0; - ihipDeviceGetCount(&count); + (void)ihipDeviceGetCount(&count); for (cl_int i = 0; i< count; ++i) { hipDeviceProp_t currentProp = {0}; @@ -145,7 +145,7 @@ hipError_t hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device) } int count = 0; - ihipDeviceGetCount(&count); + (void)ihipDeviceGetCount(&count); if (device < 0 || device >= count) { HIP_RETURN(hipErrorInvalidDevice); } @@ -344,12 +344,12 @@ hipError_t hipDeviceGetByPCIBusId(int* device, const char*pciBusIdstr) { reinterpret_cast(&pciBusID), reinterpret_cast(&pciDeviceID)) == 0x3) { int count = 0; - ihipDeviceGetCount(&count); + (void)ihipDeviceGetCount(&count); for (cl_int i = 0; i < count; i++) { hipDevice_t dev; - ihipDeviceGet(&dev, i); hipDeviceProp_t prop; - ihipGetDeviceProperties(&prop, dev); + (void)ihipDeviceGet(&dev, i); + (void)ihipGetDeviceProperties(&prop, dev); if ((pciBusID == prop.pciBusID) && (pciDomainID == prop.pciDomainID) && (pciDeviceID == prop.pciDeviceID)) { @@ -386,8 +386,8 @@ hipError_t hipDeviceGetLimit ( size_t* pValue, hipLimit_t limit ) { HIP_RETURN(hipErrorInvalidValue); } if(limit == hipLimitMallocHeapSize) { - hipDeviceProp_t prop; - ihipGetDeviceProperties(&prop, ihipGetDevice()); + hipDeviceProp_t prop = {0}; + (void)ihipGetDeviceProperties(&prop, ihipGetDevice()); *pValue = prop.totalGlobalMem; HIP_RETURN(hipSuccess); @@ -401,7 +401,7 @@ hipError_t hipDeviceGetPCIBusId ( char* pciBusId, int len, int device ) { HIP_INIT_API(hipDeviceGetPCIBusId, (void*)pciBusId, len, device); int count; - ihipDeviceGetCount(&count); + (void)ihipDeviceGetCount(&count); if (device < 0 || device >= count) { HIP_RETURN(hipErrorInvalidDevice); } @@ -411,7 +411,7 @@ hipError_t hipDeviceGetPCIBusId ( char* pciBusId, int len, int device ) { } hipDeviceProp_t prop; - ihipGetDeviceProperties(&prop, device); + (void)ihipGetDeviceProperties(&prop, device); snprintf (pciBusId, len, "%04x:%02x:%02x.0", prop.pciDomainID, diff --git a/src/hip_platform.cpp b/src/hip_platform.cpp index bcae8560..14139a34 100644 --- a/src/hip_platform.cpp +++ b/src/hip_platform.cpp @@ -101,7 +101,7 @@ extern "C" void __hipRegisterFunction( }() }; hip::Function* func = new hip::Function(std::string(deviceName), modules); - PlatformState::instance().registerStatFunction(hostFunction, func); + (void)PlatformState::instance().registerStatFunction(hostFunction, func); if (!enable_deferred_loading) { HIP_INIT_VOID(); @@ -130,7 +130,7 @@ extern "C" void __hipRegisterVar( int global) // Unknown, always 0 { hip::Var* var_ptr = new hip::Var(std::string(hostVar), hip::Var::DeviceVarKind::DVK_Variable, size, 0, 0, modules); - PlatformState::instance().registerStatGlobalVar(var, var_ptr); + (void)PlatformState::instance().registerStatGlobalVar(var, var_ptr); } extern "C" void __hipRegisterSurface(hip::FatBinaryInfo** modules, // The device modules containing code object @@ -139,7 +139,7 @@ extern "C" void __hipRegisterSurface(hip::FatBinaryInfo** modules, // The d char* deviceVar, // Variable name in device code int type, int ext) { hip::Var* var_ptr = new hip::Var(std::string(hostVar), hip::Var::DeviceVarKind::DVK_Surface, sizeof(surfaceReference), 0, 0, modules); - PlatformState::instance().registerStatGlobalVar(var, var_ptr); + (void)PlatformState::instance().registerStatGlobalVar(var, var_ptr); } extern "C" void __hipRegisterManagedVar(void *hipModule, // Pointer to hip module returned from __hipRegisterFatbinary @@ -154,7 +154,10 @@ extern "C" void __hipRegisterManagedVar(void *hipModule, // Pointer to hip mod if( status == hipSuccess) { amd::HostQueue* queue = hip::getNullStream(); if(queue != nullptr) { - ihipMemcpy(*pointer, init_value, size, hipMemcpyHostToDevice, *queue); + status = ihipMemcpy(*pointer, init_value, size, hipMemcpyHostToDevice, *queue); + if ( status != hipSuccess) { + guarantee(false, "Error during copy on the managed memory!"); + } } else { ClPrint(amd::LOG_ERROR, amd::LOG_API, "Host Queue is NULL"); } @@ -163,7 +166,7 @@ extern "C" void __hipRegisterManagedVar(void *hipModule, // Pointer to hip mod } hip::Var* var_ptr = new hip::Var(std::string(name), hip::Var::DeviceVarKind::DVK_Managed, pointer, size, align, reinterpret_cast(hipModule)); - PlatformState::instance().registerStatManagedVar(var_ptr); + (void)PlatformState::instance().registerStatManagedVar(var_ptr); } extern "C" void __hipRegisterTexture(hip::FatBinaryInfo** modules, // The device modules containing code object @@ -172,12 +175,12 @@ extern "C" void __hipRegisterTexture(hip::FatBinaryInfo** modules, // The d char* deviceVar, // Variable name in device code int type, int norm, int ext) { hip::Var* var_ptr = new hip::Var(std::string(hostVar), hip::Var::DeviceVarKind::DVK_Texture, sizeof(textureReference), 0, 0, modules); - PlatformState::instance().registerStatGlobalVar(var, var_ptr); + (void)PlatformState::instance().registerStatGlobalVar(var, var_ptr); } extern "C" void __hipUnregisterFatBinary(hip::FatBinaryInfo** modules) { - PlatformState::instance().removeFatBinary(modules); + (void)PlatformState::instance().removeFatBinary(modules); } extern "C" hipError_t hipConfigureCall( @@ -608,7 +611,7 @@ void hipLaunchKernelGGLImpl( LogPrintfError("Cannot find the static function: 0x%x", function_address); } - hipModuleLaunchKernel(func, + (void)hipModuleLaunchKernel(func, numBlocks.x, numBlocks.y, numBlocks.z, dimBlocks.x, dimBlocks.y, dimBlocks.z, sharedMemBytes, stream, nullptr, kernarg); @@ -624,7 +627,7 @@ void hipLaunchCooperativeKernelGGLImpl( { HIP_INIT_VOID(); - hipLaunchCooperativeKernel(reinterpret_cast(function_address), + (void)hipLaunchCooperativeKernel(reinterpret_cast(function_address), numBlocks, dimBlocks, kernarg, sharedMemBytes, stream); } @@ -730,7 +733,7 @@ void PlatformState::init() } initialized_ = true; for (auto& it : statCO_.modules_) { - digestFatBinary(it.first, it.second); + (void)digestFatBinary(it.first, it.second); } for (auto &it : statCO_.vars_) { it.second->resize_dVar(g_devices.size()); @@ -819,7 +822,7 @@ hipError_t PlatformState::getDynGlobalVar(const char* hostVar, hipModule_t hmod, return hipErrorNotFound; } *dev_ptr = nullptr; - it->second->getManagedVarPointer(hostVar, dev_ptr, size_ptr); + (void)it->second->getManagedVarPointer(hostVar, dev_ptr, size_ptr); // if dev_ptr is nullptr, hostvar is not in managed variable list if (*dev_ptr == nullptr) { hip::DeviceVar* dvar = nullptr; diff --git a/src/hip_prof_api.h b/src/hip_prof_api.h index 787a62c5..c78b6952 100644 --- a/src/hip_prof_api.h +++ b/src/hip_prof_api.h @@ -26,6 +26,13 @@ #include #if USE_PROF_API +#include +#include + +#include +#include +#include + #include "hip/amd_detail/hip_prof_str.h" #include "platform/prof_protocol.h" diff --git a/src/hip_stream.cpp b/src/hip_stream.cpp index d3720526..fa8a6314 100644 --- a/src/hip_stream.cpp +++ b/src/hip_stream.cpp @@ -58,11 +58,11 @@ Stream::~Stream() { hipError_t Stream::EndCapture() { for (auto event : captureEvents_) { hip::Event* e = reinterpret_cast(event); - e->EndCapture(); + (void)e->EndCapture(); } for (auto stream : parallelCaptureStreams_) { hip::Stream* s = reinterpret_cast(stream); - s->EndCapture(); + (void)s->EndCapture(); } captureStatus_ = hipStreamCaptureStatusNone; pCaptureGraph_ = nullptr; @@ -307,7 +307,7 @@ class stream_per_thread { // There is a scenario where hipResetDevice destroys stream per thread // hence isValid check is required to make sure only valid stream is used if (m_stream == nullptr || !hip::isValid(m_stream)) { - ihipStreamCreate(&m_stream, hipStreamDefault, hip::Stream::Priority::Normal); + (void)ihipStreamCreate(&m_stream, hipStreamDefault, hip::Stream::Priority::Normal); } return m_stream; } diff --git a/src/hip_surface.cpp b/src/hip_surface.cpp index 831df321..1cf999c1 100644 --- a/src/hip_surface.cpp +++ b/src/hip_surface.cpp @@ -64,11 +64,11 @@ hipError_t ihipCreateSurfaceObject(hipSurfaceObject_t* pSurfObject, image = as_amd(memObj)->asImage(); void* surfObjectBuffer = nullptr; - ihipMalloc(&surfObjectBuffer, sizeof(__hip_surface), CL_MEM_SVM_FINE_GRAIN_BUFFER); + (void)ihipMalloc(&surfObjectBuffer, sizeof(__hip_surface), CL_MEM_SVM_FINE_GRAIN_BUFFER); if (surfObjectBuffer == nullptr) { return hipErrorOutOfMemory; } - *pSurfObject = new (surfObjectBuffer) __hip_surface{image, *pResDesc}; + pSurfObject = reinterpret_cast(new (surfObjectBuffer) __hip_surface{image, *pResDesc}); return hipSuccess; } @@ -83,11 +83,7 @@ hipError_t hipCreateSurfaceObject(hipSurfaceObject_t* pSurfObject, hipError_t ihipDestroySurfaceObject(hipSurfaceObject_t surfaceObject) { HIP_INIT_API(hipDestroySurfaceObject, surfaceObject); - if (surfaceObject == nullptr) { - return hipSuccess; - } - - return ihipFree(surfaceObject); + return ihipFree(&surfaceObject); } hipError_t hipDestroySurfaceObject(hipSurfaceObject_t surfaceObject) { diff --git a/src/hip_texture.cpp b/src/hip_texture.cpp index bc73f731..8a2adfc1 100644 --- a/src/hip_texture.cpp +++ b/src/hip_texture.cpp @@ -297,7 +297,7 @@ hipError_t ihipCreateTextureObject(hipTextureObject_t* pTexObject, } void *texObjectBuffer = nullptr; - ihipMalloc(&texObjectBuffer, sizeof(__hip_texture), CL_MEM_SVM_FINE_GRAIN_BUFFER); + (void)ihipMalloc(&texObjectBuffer, sizeof(__hip_texture), CL_MEM_SVM_FINE_GRAIN_BUFFER); if (texObjectBuffer == nullptr) { return hipErrorOutOfMemory; }