[Libomptarget] Emit a special warning when no images are found
authorJoseph Huber <jhuber6@vols.utk.edu>
Fri, 17 Mar 2023 15:37:29 +0000 (10:37 -0500)
committerJoseph Huber <jhuber6@vols.utk.edu>
Fri, 17 Mar 2023 16:37:43 +0000 (11:37 -0500)
When offloading is mandatory we can emit a more helpful message if we
did not find any compatible images with the user's system.

Fixes #60221

Reviewed By: ye-luo

Differential Revision: https://reviews.llvm.org/D142369

openmp/libomptarget/src/omptarget.cpp

index 9d800d7..392a9f7 100644 (file)
@@ -274,6 +274,17 @@ void handleTargetOutcome(bool Success, ident_t *Loc) {
         FAILURE_MESSAGE("Consult https://openmp.llvm.org/design/Runtimes.html "
                         "for debugging options.\n");
 
+      if (PM->RTLs.UsedRTLs.empty()) {
+        llvm::SmallVector<llvm::StringRef> Archs;
+        llvm::transform(PM->Images, std::back_inserter(Archs),
+                        [](const auto &x) {
+                          return !x.second.Arch ? "empty" : x.second.Arch;
+                        });
+        FAILURE_MESSAGE(
+            "No images found compatible with the installed hardware. ");
+        fprintf(stderr, "Found (%s)\n", llvm::join(Archs, ",").c_str());
+      }
+
       SourceInfo Info(Loc);
       if (Info.isAvailible())
         fprintf(stderr, "%s:%d:%d: ", Info.getFilename(), Info.getLine(),