[llvm] [libsycl] Add single_task (PR #192499)

Tom Honermann via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 28 09:18:34 PDT 2026


================
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains helper function to query kernel info that is uniform
+/// between different submissions of the same kernel.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBSYCL___IMPL_DETAIL_GET_DEVICE_KERNEL_INFO_HPP
+#define _LIBSYCL___IMPL_DETAIL_GET_DEVICE_KERNEL_INFO_HPP
+
+#include <sycl/__impl/detail/config.hpp>
+
+#include <string_view>
+
+_LIBSYCL_BEGIN_NAMESPACE_SYCL
+
+namespace detail {
+
+class DeviceKernelInfo;
+// Lifetime of the underlying `DeviceKernelInfo` is tied to the availability of
+// the `sycl_device_binaries` corresponding to this kernel. In other words, once
+// user library is unloaded (see __sycl_unregister_lib), program manager
+// destroys this `DeviceKernelInfo` object and the reference returned from here
+// becomes stale.
+_LIBSYCL_EXPORT DeviceKernelInfo &getDeviceKernelInfo(std::string_view);
+
+template <class KernelName>
+DeviceKernelInfo &getDeviceKernelInfo(std::string_view KernelNameStr) {
+  static DeviceKernelInfo &Info = getDeviceKernelInfo(KernelNameStr);
+  return Info;
+}
----------------
tahonermann wrote:

I was thinking more about subsequent calls. Each call needs to pass the kernel entry point name (even though it won't be used in subsequent calls) which means needing to maintain the pointer to that name unnecessarily. We can eliminate that need by making it directly available (and at compile-time) via the kernel name type. I'm not concerned about an optimization; I agree eliminating the `char*` parameter is unlikely to have a measurable impact. The idea is more to reduce code complexity and improve clarity. And also to provide an extension point for future needs; we might have other traits to expose to the SYCL RT in the future and changes to the `sycl_kernel_launch()` signature would be disruptive.

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


More information about the llvm-commits mailing list