[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:33 PST 2025


================
@@ -8,10 +8,38 @@
 
 #include <sycl/__impl/platform.hpp>
 
+#include <detail/platform_impl.hpp>
+
 #include <stdexcept>
 
 _LIBSYCL_BEGIN_NAMESPACE_SYCL
 
-platform::platform() { throw std::runtime_error("Unimplemented"); }
+backend platform::get_backend() const noexcept {
+  return getImpl().getBackend();
+}
+
+std::vector<platform> platform::get_platforms() {
+  auto PlatformsView = detail::platform_impl::getPlatforms();
+  std::vector<platform> Platforms;
+  Platforms.reserve(PlatformsView.size());
+  for (size_t i = 0; i < PlatformsView.size(); i++) {
----------------
bader wrote:

https://llvm.org/docs/CodingStandards.html#use-range-based-for-loops-wherever-possible
I suppose we can use range-based for loop here.

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


More information about the llvm-commits mailing list