[llvm-branch-commits] [llvm] [libsycl] Add parallel_for feature (PR #189068)

Kseniya Tikhomirova via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Apr 22 03:07:37 PDT 2026


================
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 SPIRV builtins needed for kernel invocations
+/// (parallel_for).
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBSYCL___SPIRV_SPIRV_VARS
+#define _LIBSYCL___SPIRV_SPIRV_VARS
+
+#ifdef __SYCL_DEVICE_ONLY__
+
+#  include <cstddef>
+#  include <cstdint>
+
+// SPIR-V built-in variables mapped to function call.
+#  define _LIBSYCL_SYCL_DEVICE_ATTR __attribute__((sycl_external))
+
+_LIBSYCL_SYCL_DEVICE_ATTR __attribute__((const)) size_t
+__spirv_BuiltInGlobalInvocationId(int);
+_LIBSYCL_SYCL_DEVICE_ATTR __attribute__((const)) size_t
+__spirv_BuiltInGlobalSize(int);
+_LIBSYCL_SYCL_DEVICE_ATTR __attribute__((const)) size_t
+__spirv_BuiltInGlobalOffset(int);
+
+namespace __spirv {
+
+// Helper function templates to initialize and get vector component from SPIR-V
+// built-in variables
+#  define __SPIRV_DEFINE_INIT_AND_GET_HELPERS(POSTFIX)                         \
+    template <int ID> size_t get##POSTFIX();                                   \
+    template <> size_t get##POSTFIX<0>() { return __spirv_##POSTFIX(0); }      \
----------------
KseniyaTikhomirova wrote:

you are right, thanks

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


More information about the llvm-branch-commits mailing list