[llvm] [libsycl] Add constructors for context (PR #214538)

Kseniya Tikhomirova via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 27 07:00:23 PDT 2026


================
@@ -0,0 +1,62 @@
+// REQUIRES: any-device
+// RUN: %clangxx -fsycl %s -o %t.out
+// RUN: %t.out
+
+#include <iostream>
+
+#include <sycl/sycl.hpp>
+
+using namespace sycl;
+
+void return_fail() {
+  std::cout << "Failed" << std::endl;
+  exit(1);
+}
+
+void dummyAsyncHandler(sycl::exception_list) {}
+
+void check(const context &ctx) {
+  auto devices = ctx.get_devices();
+  if (devices.empty()) {
+    std::cout << "Context has no devices" << std::endl;
+    return_fail();
+  }
+
+  auto plt = ctx.get_platform();
+  for (const auto &dev : devices) {
+    if (dev.get_platform() != plt) {
+      std::cout << "Device platform does not match context platform"
+                << std::endl;
+      return_fail();
+    }
+  }
+  auto backend = ctx.get_backend();
+  for (const auto &dev : devices) {
+    if (dev.get_backend() != backend) {
+      std::cout << "Device backend does not match context backend" << std::endl;
+      return_fail();
+    }
----------------
KseniyaTikhomirova wrote:

this test looks like test that can be converted to UT. in general UTs are preferable if there is no specific integration with liboffload to be tested.


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


More information about the llvm-commits mailing list