From 3af20b1bbb13c9503d74ec86d92fb58decd1683e Mon Sep 17 00:00:00 2001 From: Vlad Sytchenko Date: Tue, 16 Jun 2020 11:41:01 -0400 Subject: [PATCH] Fix -Wsign-compare warnings Change-Id: I874dc007ac657c25a72c6752c1a2da74c028a822 [ROCm/hip commit: a6aef2a36aed85a4c85c2f86747c0b8eb746babb] --- projects/hip/rocclr/hip_global.cpp | 8 ++++---- projects/hip/rocclr/hip_hmm.cpp | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/projects/hip/rocclr/hip_global.cpp b/projects/hip/rocclr/hip_global.cpp index 1bbc157d58..2b88002524 100755 --- a/projects/hip/rocclr/hip_global.cpp +++ b/projects/hip/rocclr/hip_global.cpp @@ -98,7 +98,7 @@ 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(deviceId < modules_->size()); + guarantee(static_cast(deviceId) < modules_->size()); hipModule_t module = (*modules_)[deviceId].first; FatBinaryMetaInfo* fb_meta = (*modules_)[deviceId].second; @@ -121,7 +121,7 @@ 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(deviceId < modules_->size()); + guarantee(static_cast(deviceId) < modules_->size()); hipModule_t module = (*modules_)[deviceId].first; FatBinaryMetaInfo* fb_meta = (*modules_)[deviceId].second; @@ -166,7 +166,7 @@ Var::~Var() { hipError_t Var::getDeviceVar(DeviceVar** dvar, int deviceId, hipModule_t hmod) { guarantee(deviceId >= 0); - guarantee(deviceId < g_devices.size()); + guarantee(static_cast(deviceId) < g_devices.size()); guarantee(dVar_.size() == g_devices.size()); if (dVar_[deviceId] == nullptr) { @@ -179,7 +179,7 @@ hipError_t Var::getDeviceVar(DeviceVar** dvar, int deviceId, hipModule_t hmod) { hipError_t Var::getStatDeviceVar(DeviceVar** dvar, int deviceId) { guarantee(deviceId >= 0); - guarantee(deviceId < g_devices.size()); + guarantee(static_cast(deviceId) < g_devices.size()); hipModule_t module = (*modules_)[deviceId].first; FatBinaryMetaInfo* fb_meta = (*modules_)[deviceId].second; diff --git a/projects/hip/rocclr/hip_hmm.cpp b/projects/hip/rocclr/hip_hmm.cpp index 5342c18349..ab787e195e 100644 --- a/projects/hip/rocclr/hip_hmm.cpp +++ b/projects/hip/rocclr/hip_hmm.cpp @@ -112,7 +112,8 @@ hipError_t hipMemPrefetchAsync(const void* dev_ptr, size_t count, int device, hipError_t hipMemAdvise(const void* dev_ptr, size_t count, hipMemoryAdvise advice, int device) { HIP_INIT_API(hipMemAdvise, dev_ptr, count, advice, device); - if ((dev_ptr == nullptr) || (count == 0) || (device >= g_devices.size())) { + if ((dev_ptr == nullptr) || (count == 0) || + (static_cast(device) >= g_devices.size())) { HIP_RETURN(hipErrorInvalidValue); } amd::Device* dev = g_devices[device]->devices()[0];