[Openmp-commits] [openmp] 1f940b6 - [Libomptarget][NFC] Fix signed comparison warnings

Joseph Huber via Openmp-commits openmp-commits at lists.llvm.org
Fri Jul 15 10:23:07 PDT 2022


Author: Joseph Huber
Date: 2022-07-15T13:22:55-04:00
New Revision: 1f940b69c366beb39493b695327d5c112a7bb57b

URL: https://github.com/llvm/llvm-project/commit/1f940b69c366beb39493b695327d5c112a7bb57b
DIFF: https://github.com/llvm/llvm-project/commit/1f940b69c366beb39493b695327d5c112a7bb57b.diff

LOG: [Libomptarget][NFC] Fix signed comparison warnings

Summary:
Non-functional change, just fixing some sign comparison warnings by
making both match.

Added: 
    

Modified: 
    openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
    openmp/libomptarget/plugins/cuda/src/rtl.cpp
    openmp/libomptarget/src/omptarget.cpp

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
index 5c28c25ff24db..9ecf2b126253f 100644
--- a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
+++ b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
@@ -858,7 +858,7 @@ class RTLDeviceInfoTy : HSALifetime {
   }
 
   hsa_status_t addDeviceMemoryPool(hsa_amd_memory_pool_t MemoryPool,
-                                   int DeviceId) {
+                                   unsigned int DeviceId) {
     assert(DeviceId < DeviceFineGrainedMemoryPools.size() && "Error here.");
     uint32_t GlobalFlags = 0;
     hsa_status_t Err = hsa_amd_memory_pool_get_info(
@@ -878,7 +878,7 @@ class RTLDeviceInfoTy : HSALifetime {
   }
 
   hsa_status_t setupDevicePools(const std::vector<hsa_agent_t> &Agents) {
-    for (int DeviceId = 0; DeviceId < Agents.size(); DeviceId++) {
+    for (unsigned int DeviceId = 0; DeviceId < Agents.size(); DeviceId++) {
       hsa_status_t Err = hsa::amd_agent_iterate_memory_pools(
           Agents[DeviceId], [&](hsa_amd_memory_pool_t MemoryPool) {
             hsa_status_t ValidStatus = core::isValidMemoryPool(MemoryPool);
@@ -942,7 +942,7 @@ class RTLDeviceInfoTy : HSALifetime {
     return HSA_STATUS_ERROR;
   }
 
-  hsa_amd_memory_pool_t getDeviceMemoryPool(int DeviceId) {
+  hsa_amd_memory_pool_t getDeviceMemoryPool(unsigned int DeviceId) {
     assert(DeviceId >= 0 && DeviceId < DeviceCoarseGrainedMemoryPools.size() &&
            "Invalid device Id");
     return DeviceCoarseGrainedMemoryPools[DeviceId];
@@ -1205,7 +1205,7 @@ LaunchVals getLaunchVals(int WarpSize, EnvironmentVariables Env,
   int NumGroups = 0;
 
   int MaxTeams = Env.MaxTeamsDefault > 0 ? Env.MaxTeamsDefault : DeviceNumTeams;
-  if (MaxTeams > RTLDeviceInfoTy::HardTeamLimit)
+  if (MaxTeams > static_cast<int>(RTLDeviceInfoTy::HardTeamLimit))
     MaxTeams = RTLDeviceInfoTy::HardTeamLimit;
 
   if (print_kernel_trace & STARTUP_DETAILS) {

diff  --git a/openmp/libomptarget/plugins/cuda/src/rtl.cpp b/openmp/libomptarget/plugins/cuda/src/rtl.cpp
index 6e503d859e292..2f96869ea3866 100644
--- a/openmp/libomptarget/plugins/cuda/src/rtl.cpp
+++ b/openmp/libomptarget/plugins/cuda/src/rtl.cpp
@@ -155,9 +155,9 @@ struct DeviceDataTy {
 
   CUcontext Context = nullptr;
   // Device properties
-  int ThreadsPerBlock = 0;
-  int BlocksPerGrid = 0;
-  int WarpSize = 0;
+  unsigned int ThreadsPerBlock = 0;
+  unsigned int BlocksPerGrid = 0;
+  unsigned int WarpSize = 0;
   // OpenMP properties
   int NumTeams = 0;
   int NumThreads = 0;

diff  --git a/openmp/libomptarget/src/omptarget.cpp b/openmp/libomptarget/src/omptarget.cpp
index 1174c39bc6269..c33a3edc39891 100644
--- a/openmp/libomptarget/src/omptarget.cpp
+++ b/openmp/libomptarget/src/omptarget.cpp
@@ -1509,7 +1509,7 @@ int target(ident_t *Loc, DeviceTy &Device, void *HostPtr, int32_t ArgNum,
   assert(TargetTable && "Global data has not been mapped\n");
 
   // FIXME: Use legacy tripcount method if it is '-1'.
-  Tripcount = Tripcount == -1 ? getLoopTripCount(DeviceId) : Tripcount;
+  Tripcount = Tripcount == -1UL ? getLoopTripCount(DeviceId) : Tripcount;
   DP("loop trip count is %" PRIu64 ".\n", Tripcount);
 
   // We need to keep bases and offsets separate. Sometimes (e.g. in OpenCL) we


        


More information about the Openmp-commits mailing list