[llvm] [SYCL] Add platform enumeration and info query using liboffload (PR #166927)
Kseniya Tikhomirova via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 5 04:22:53 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;
+ }
+
+ for (const auto &Platform : Platforms) {
+ backend Backend = Platform.get_backend();
+ std::cout << "[" << detail::get_backend_name(Backend) << ":"
+ << "unknown" << "]" << std::endl;
+ }
+
+ if (Verbose) {
+ std::cout << "\nPlatforms: " << Platforms.size() << std::endl;
+ uint32_t PlatformNum = 0;
+ for (const auto &Platform : Platforms) {
+ ++PlatformNum;
+ auto PlatformVersion = Platform.get_info<info::platform::version>();
+ auto PlatformName = Platform.get_info<info::platform::name>();
+ auto PlatformVendor = Platform.get_info<info::platform::vendor>();
+ std::cout << "Platform [#" << PlatformNum << "]:" << std::endl;
+ std::cout << " Version : " << PlatformVersion << std::endl;
+ std::cout << " Name : " << PlatformName << std::endl;
+ std::cout << " Vendor : " << PlatformVendor << std::endl;
+
+ std::cout << " Devices : " << "unknown" << std::endl;
+ }
+ } else {
+ return EXIT_SUCCESS;
+ }
----------------
KseniyaTikhomirova wrote:
done
https://github.com/llvm/llvm-project/pull/166927
More information about the llvm-commits
mailing list