[Openmp-commits] [openmp] b280e12 - [Libomptarget][NFC] Address a few warnings in libomptarget

Joseph Huber via Openmp-commits openmp-commits at lists.llvm.org
Mon Jan 23 06:56:25 PST 2023


Author: Joseph Huber
Date: 2023-01-23T08:56:03-06:00
New Revision: b280e12a3d9ffe76fdfdaae828fc43b2455e6808

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

LOG: [Libomptarget][NFC] Address a few warnings in libomptarget

Summary:
Fix a few minor warnings that show up in `libomptarget`.

Added: 
    

Modified: 
    openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
    openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp
    openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
    openmp/libomptarget/plugins/generic-elf-64bit/src/rtl.cpp
    openmp/libomptarget/src/interface.cpp
    openmp/libomptarget/tools/kernelreplay/llvm-omp-kernel-replay.cpp

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp b/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
index 2bbe3f7cbbf08..4374e110628d2 100644
--- a/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
+++ b/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
@@ -48,7 +48,9 @@
 #include "hsa.h"
 #include "hsa_ext_amd.h"
 #endif
+#else
 #include "hsa/hsa.h"
+#include "hsa_ext_amd.h"
 #endif
 
 namespace llvm {

diff  --git a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp
index b7551279277e3..ca52059606cd1 100644
--- a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp
+++ b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp
@@ -363,8 +363,8 @@ JITEngine::compile(const __tgt_device_image &Image,
 
   auto &ImageMB = CUI.JITImages.back();
 
-  JITedImage->ImageStart = (void *)ImageMB->getBufferStart();
-  JITedImage->ImageEnd = (void *)ImageMB->getBufferEnd();
+  JITedImage->ImageStart = const_cast<char *>(ImageMB->getBufferStart());
+  JITedImage->ImageEnd = const_cast<char *>(ImageMB->getBufferEnd());
 
   return JITedImage;
 }

diff  --git a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
index ceece60e27ed0..66d7049f37d2f 100644
--- a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
+++ b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
@@ -182,9 +182,9 @@ struct RecordReplayTy {
   void *alloc(uint64_t Size) {
     assert(MemoryStart && "Expected memory has been pre-allocated");
     void *Alloc = nullptr;
-    constexpr int ALIGN = 16;
+    constexpr int Alignment = 16;
     // Assumes alignment is a power of 2.
-    int64_t AlignedSize = Size + (ALIGN - 1) & (~(ALIGN - 1));
+    int64_t AlignedSize = (Size + (Alignment - 1)) & (~(Alignment - 1));
     std::lock_guard<std::mutex> LG(AllocationLock);
     Alloc = MemoryPtr;
     MemoryPtr = (char *)MemoryPtr + AlignedSize;

diff  --git a/openmp/libomptarget/plugins/generic-elf-64bit/src/rtl.cpp b/openmp/libomptarget/plugins/generic-elf-64bit/src/rtl.cpp
index 080aad354d524..3fba82c3ae12c 100644
--- a/openmp/libomptarget/plugins/generic-elf-64bit/src/rtl.cpp
+++ b/openmp/libomptarget/plugins/generic-elf-64bit/src/rtl.cpp
@@ -254,7 +254,7 @@ int32_t __tgt_rtl_launch_kernel(int32_t DeviceId, void *TgtEntryPtr,
   std::vector<void *> Args(KernelArgs->NumArgs);
   std::vector<void *> Ptrs(KernelArgs->NumArgs);
 
-  for (int32_t I = 0; I < KernelArgs->NumArgs; ++I) {
+  for (uint32_t I = 0; I < KernelArgs->NumArgs; ++I) {
     Ptrs[I] = (void *)((intptr_t)TgtArgs[I] + TgtOffsets[I]);
     Args[I] = &Ptrs[I];
   }

diff  --git a/openmp/libomptarget/src/interface.cpp b/openmp/libomptarget/src/interface.cpp
index 4d4651bdb8111..91dda62b0c2d5 100644
--- a/openmp/libomptarget/src/interface.cpp
+++ b/openmp/libomptarget/src/interface.cpp
@@ -245,10 +245,10 @@ static inline int targetKernel(ident_t *Loc, int64_t DeviceId, int32_t NumTeams,
   KernelArgs =
       upgradeKernelArgs(KernelArgs, LocalKernelArgs, NumTeams, ThreadLimit);
 
-  assert(KernelArgs->NumTeams[0] == NumTeams && !KernelArgs->NumTeams[1] &&
-         !KernelArgs->NumTeams[2] &&
+  assert(KernelArgs->NumTeams[0] == static_cast<uint32_t>(NumTeams) &&
+         !KernelArgs->NumTeams[1] && !KernelArgs->NumTeams[2] &&
          "OpenMP interface should not use multiple dimensions");
-  assert(KernelArgs->ThreadLimit[0] == ThreadLimit &&
+  assert(KernelArgs->ThreadLimit[0] == static_cast<uint32_t>(ThreadLimit) &&
          !KernelArgs->ThreadLimit[1] && !KernelArgs->ThreadLimit[2] &&
          "OpenMP interface should not use multiple dimensions");
 
@@ -257,7 +257,7 @@ static inline int targetKernel(ident_t *Loc, int64_t DeviceId, int32_t NumTeams,
                          KernelArgs->ArgSizes, KernelArgs->ArgTypes,
                          KernelArgs->ArgNames, "Entering OpenMP kernel");
 #ifdef OMPTARGET_DEBUG
-  for (int I = 0; I < KernelArgs->NumArgs; ++I) {
+  for (uint32_t I = 0; I < KernelArgs->NumArgs; ++I) {
     DP("Entry %2d: Base=" DPxMOD ", Begin=" DPxMOD ", Size=%" PRId64
        ", Type=0x%" PRIx64 ", Name=%s\n",
        I, DPxPTR(KernelArgs->ArgBasePtrs[I]), DPxPTR(KernelArgs->ArgPtrs[I]),

diff  --git a/openmp/libomptarget/tools/kernelreplay/llvm-omp-kernel-replay.cpp b/openmp/libomptarget/tools/kernelreplay/llvm-omp-kernel-replay.cpp
index 1348e0fa2b1a8..4b4b168acdcc7 100644
--- a/openmp/libomptarget/tools/kernelreplay/llvm-omp-kernel-replay.cpp
+++ b/openmp/libomptarget/tools/kernelreplay/llvm-omp-kernel-replay.cpp
@@ -100,8 +100,8 @@ int main(int argc, char **argv) {
     report_fatal_error("Error reading the kernel image.");
 
   __tgt_device_image DeviceImage;
-  DeviceImage.ImageStart = (void *)ImageMB.get()->getBufferStart();
-  DeviceImage.ImageEnd = (void *)ImageMB.get()->getBufferEnd();
+  DeviceImage.ImageStart = const_cast<char *>(ImageMB.get()->getBufferStart());
+  DeviceImage.ImageEnd = const_cast<char *>(ImageMB.get()->getBufferEnd());
   DeviceImage.EntriesBegin = &KernelEntry;
   DeviceImage.EntriesEnd = &KernelEntry + 1;
 
@@ -143,7 +143,7 @@ int main(int argc, char **argv) {
 
   __tgt_target_kernel_replay(
       /* Loc */ nullptr, DeviceId, KernelEntry.addr,
-      (void *)DeviceMemoryMB.get()->getBuffer().data(),
+      const_cast<char *>(DeviceMemoryMB.get()->getBuffer().data()),
       DeviceMemoryMB.get()->getBufferSize(), TgtArgs.data(),
       TgtArgOffsets.data(), NumArgs.value(), NumTeams, NumThreads,
       LoopTripCount.value());


        


More information about the Openmp-commits mailing list