[llvm] [SYCL] E2E LIT tests initial configs & test (PR #177407)
Dmitry Rogozhkin via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 23 10:02:41 PST 2026
================
@@ -0,0 +1,116 @@
+// RUN: %clangxx %sycl_options %s -o %t.out
+// RUN: %t.out
+//
+// Tests platform::get_devices for each device type.
+
+#include <sycl.hpp>
+
+#include <algorithm>
+#include <iostream>
+
+std::string BackendToString(sycl::backend Backend) {
+ switch (Backend) {
+ case sycl::backend::opencl:
+ return "opencl";
+ case sycl::backend::level_zero:
+ return "level_zero";
+ case sycl::backend::cuda:
+ return "cuda";
+ case sycl::backend::hip:
+ return "hip";
+ default:
+ return "unknown";
+ }
+}
+
+std::string DeviceTypeToString(sycl::info::device_type DevType) {
+ switch (DevType) {
+ case sycl::info::device_type::all:
+ return "device_type::all";
+ case sycl::info::device_type::cpu:
+ return "device_type::cpu";
+ case sycl::info::device_type::gpu:
+ return "device_type::gpu";
+ case sycl::info::device_type::accelerator:
+ return "device_type::accelerator";
+ case sycl::info::device_type::custom:
+ return "device_type::custom";
+ case sycl::info::device_type::automatic:
+ return "device_type::automatic";
+ case sycl::info::device_type::host:
+ return "device_type::host";
+ default:
+ return "UNKNOWN";
+ }
+}
+
+template <typename T1, typename T2>
+int Check(const T1 &LHS, const T2 &RHS, std::string TestName) {
+ if (LHS != RHS) {
+ std::cout << "Failed check " << LHS << " != " << RHS << ": " << TestName
+ << std::endl;
+ return 1;
+ }
+ return 0;
+}
+
+int CheckDeviceType(const sycl::platform &P, sycl::info::device_type DevType,
+ std::vector<sycl::device> &AllDevices) {
+ assert(DevType != sycl::info::device_type::all);
+ int Failures = 0;
+
+ std::vector<sycl::device> Devices = P.get_devices(DevType);
+
+ if (DevType == sycl::info::device_type::automatic) {
+ if (AllDevices.empty()) {
+ Failures += Check(
+ Devices.size(), 0,
+ "No devices reported for all query, but automatic returns a device.");
----------------
dvrogozh wrote:
I would emphasize `all` and `automatic` in the message with adding `device_type::` or maybe just quoting it if line will be too long. Otherwise reading is somewhat difficult as actual English is mixed with the keywords.
```suggestion
"No devices reported for device_type::all query, but device_type::automatic returns a device.");
```
https://github.com/llvm/llvm-project/pull/177407
More information about the llvm-commits
mailing list