[Openmp-commits] [PATCH] D147756: [Libomptarget] Load an image if it is compatible with at least one device

Joseph Huber via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Apr 6 19:14:13 PDT 2023


jhuber6 created this revision.
jhuber6 added reviewers: estewart08, jdoerfert, JonChesterfield, ronlieb, ye-luo, tianshilei1992.
Herald added subscribers: kosarev, kerbowa, jvesely.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added a project: OpenMP.
Herald added a subscriber: openmp-commits.

Currently, we only load an image if its supported architecture matches
all of the devices found. This prevents us from supporting a system with
multiple GPUs from the same vendor but different architectures. This
patch makes a very simple change that returns that the image is
incompatible only once we've searched every device.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147756

Files:
  openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
  openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp


Index: openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
===================================================================
--- openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
+++ openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
@@ -962,10 +962,10 @@
       // A cubin generated for a certain compute capability is supported to run
       // on any GPU with the same major revision and same or higher minor
       // revision.
-      if (Major != ImageMajor || Minor < ImageMinor)
-        return false;
+      if (Major == ImageMajor && Minor >= ImageMinor)
+        return true;
     }
-    return true;
+    return false;
   }
 };
 
Index: openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
===================================================================
--- openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
+++ openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
@@ -1165,7 +1165,7 @@
 
   bool Compatible = *CompatibleOrErr;
   DP("Image is %scompatible with current environment: %s\n",
-     (Compatible) ? "" : "not", Info->Arch);
+     (Compatible) ? "" : "not ", Info->Arch);
 
   return Compatible;
 }
Index: openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
===================================================================
--- openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
+++ openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
@@ -2448,9 +2448,8 @@
         if (Status != HSA_STATUS_SUCCESS)
           return Status;
 
-        // TODO: This is not allowed by the standard.
-        char ISAName[Length];
-        Status = hsa_isa_get_info_alt(ISA, HSA_ISA_INFO_NAME, ISAName);
+        std::string ISAName(Length, '\0');
+        Status = hsa_isa_get_info_alt(ISA, HSA_ISA_INFO_NAME, ISAName.data());
         if (Status != HSA_STATUS_SUCCESS)
           return Status;
 
@@ -2462,10 +2461,10 @@
       if (Err)
         return std::move(Err);
 
-      if (!utils::isImageCompatibleWithEnv(Info, Target))
-        return false;
+      if (utils::isImageCompatibleWithEnv(Info, Target))
+        return true;
     }
-    return true;
+    return false;
   }
 
   /// This plugin does not support exchanging data between two devices.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147756.511590.patch
Type: text/x-patch
Size: 2269 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20230407/bd664196/attachment.bin>


More information about the Openmp-commits mailing list