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

Kseniya Tikhomirova via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 19 04:19:40 PST 2025


================
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <detail/offload/offload_utils.hpp>
+
+_LIBSYCL_BEGIN_NAMESPACE_SYCL
+namespace detail {
+
+const char *stringifyErrorCode(int32_t error) {
+  switch (error) {
+#define _OFFLOAD_ERRC(NAME)                                                    \
+  case NAME:                                                                   \
+    return #NAME;
+    _OFFLOAD_ERRC(OL_ERRC_UNKNOWN)
+    _OFFLOAD_ERRC(OL_ERRC_HOST_IO)
+    _OFFLOAD_ERRC(OL_ERRC_INVALID_BINARY)
+    _OFFLOAD_ERRC(OL_ERRC_INVALID_NULL_POINTER)
+    _OFFLOAD_ERRC(OL_ERRC_INVALID_ARGUMENT)
+    _OFFLOAD_ERRC(OL_ERRC_NOT_FOUND)
+    _OFFLOAD_ERRC(OL_ERRC_OUT_OF_RESOURCES)
+    _OFFLOAD_ERRC(OL_ERRC_INVALID_SIZE)
+    _OFFLOAD_ERRC(OL_ERRC_INVALID_ENUMERATION)
+    _OFFLOAD_ERRC(OL_ERRC_HOST_TOOL_NOT_FOUND)
+    _OFFLOAD_ERRC(OL_ERRC_INVALID_VALUE)
+    _OFFLOAD_ERRC(OL_ERRC_UNIMPLEMENTED)
+    _OFFLOAD_ERRC(OL_ERRC_UNSUPPORTED)
+    _OFFLOAD_ERRC(OL_ERRC_ASSEMBLE_FAILURE)
+    _OFFLOAD_ERRC(OL_ERRC_COMPILE_FAILURE)
+    _OFFLOAD_ERRC(OL_ERRC_LINK_FAILURE)
+    _OFFLOAD_ERRC(OL_ERRC_BACKEND_FAILURE)
+    _OFFLOAD_ERRC(OL_ERRC_UNINITIALIZED)
+    _OFFLOAD_ERRC(OL_ERRC_INVALID_NULL_HANDLE)
+    _OFFLOAD_ERRC(OL_ERRC_INVALID_PLATFORM)
+    _OFFLOAD_ERRC(OL_ERRC_INVALID_DEVICE)
+    _OFFLOAD_ERRC(OL_ERRC_INVALID_QUEUE)
+    _OFFLOAD_ERRC(OL_ERRC_INVALID_EVENT)
+    _OFFLOAD_ERRC(OL_ERRC_SYMBOL_KIND)
+#undef _OFFLOAD_ERRC
+
+  default:
+    return "Unknown error code";
----------------
KseniyaTikhomirova wrote:

This is done by another function:

```
const char *stringifyErrorCode(int32_t error);

inline std::string formatCodeString(int32_t code) {
  return std::to_string(code) + " (" + std::string(stringifyErrorCode(code)) +
         ")";
}
```

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


More information about the llvm-commits mailing list