[llvm] [SYCL] Add platform enumeration and info query using liboffload (PR #166927)

Alexey Bader via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 1 18:22:32 PST 2025


================
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// The "sycl-ls" utility lists all platforms discovered by SYCL.
+//
+// There are two types of output:
+//   concise (default) and
+//   verbose (enabled with --verbose).
+//
+#include <sycl/sycl.hpp>
+
+#include "llvm/Support/CommandLine.h"
+
+#include <iostream>
+
+using namespace sycl;
+using namespace std::literals;
+
+int main(int argc, char **argv) {
+  llvm::cl::opt<bool> Verbose(
+      "verbose",
+      llvm::cl::desc("Verbosely prints all the discovered platforms"));
+  llvm::cl::alias VerboseShort("v", llvm::cl::desc("Alias for -verbose"),
+                               llvm::cl::aliasopt(Verbose));
+  llvm::cl::ParseCommandLineOptions(
+      argc, argv, "This program lists all backends discovered by SYCL");
+
+  try {
+    const auto &Platforms = platform::get_platforms();
+
+    if (Platforms.size() == 0) {
+      std::cout << "No platforms found." << std::endl;
+    }
----------------
bader wrote:

```suggestion
      std::cout << "No platforms found." << std::endl;
      return EXIT_SUCCESS;
    }
```

https://github.com/llvm/llvm-project/pull/166927


More information about the llvm-commits mailing list