Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[GPU] Add JIT compilation support to SYCL runtime (#37046)

Akihiro-Tabuchicabbc18210a6
diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/build_implementations.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/build_implementations.cpp
index d5025feed84..2f825b5d9ae 100644
--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/build_implementations.cpp
+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/build_implementations.cpp
@@ -15,11 +15,6 @@ void build_implementations::run(program& p) {
return;
}
- // Skip for the SYCL runtime because JIT compilation is not supported
- if (p.get_engine().runtime_type() == runtime_types::sycl) {
- return;
- }
-
auto& cache = p.get_kernels_cache();
for (const auto& n : p.get_processing_order()) {
if (auto* impl = n->get_selected_impl()) {
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/kernels_cache.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/kernels_cache.cpp
index 6e52d7a4c55..a8b4d8df499 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl/kernels_cache.cpp
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/kernels_cache.cpp
@@ -30,6 +30,7 @@
#endif
#include <cassert>
+#include <cstring>
#include <sstream>
#include <fstream>
#include <set>
@@ -523,23 +524,26 @@ void kernels_cache::add_to_cached_kernels(const std::vector<kernel::ptr>& kernel
void kernels_cache::save(BinaryOutputBuffer& ob) const {
ob << _cached_binaries.size();
- auto is_zebin = [](const std::vector<unsigned char>& bin) {
+ // zebin (ELF format) or SPIR-V.
+ auto is_driver_agnostic = [](const std::vector<unsigned char>& bin) {
constexpr uint32_t ELF_MAGIC = 0x464C457F;
+ constexpr uint32_t SPIRV_MAGIC = 0x07230203;
if (bin.size() < sizeof(uint32_t)) {
return false;
}
- auto magic = reinterpret_cast<const uint32_t*>(bin.data())[0];
- return magic == ELF_MAGIC;
+ uint32_t magic;
+ std::memcpy(&magic, bin.data(), sizeof(magic));
+ return magic == ELF_MAGIC || magic == SPIRV_MAGIC;
};
for (const auto& cached_binary : _cached_binaries) {
- auto is_zebin_binary = is_zebin(cached_binary.first);
+ auto is_driver_agnostic_binary = is_driver_agnostic(cached_binary.first);
ob << cached_binary.second;
ob << cached_binary.first;
- ob << is_zebin_binary;
- if (!is_zebin_binary) {
+ ob << is_driver_agnostic_binary;
+ if (!is_driver_agnostic_binary) {
auto driver_version = _device->get_info().driver_version;
ob << driver_version;
}
@@ -552,13 +556,13 @@ void kernels_cache::load(BinaryInputBuffer& ib) {
size_t num_cached_binaries;
ib >> num_cached_binaries;
for (size_t i = 0; i < num_cached_binaries; ++i) {
- bool is_zebin_binary = true;
+ bool is_driver_agnostic_binary = true;
uint32_t id;
ib >> id;
ib >> precompiled_kernels[id];
- ib >> is_zebin_binary;
- if (!is_zebin_binary) {
+ ib >> is_driver_agnostic_binary;
+ if (!is_driver_agnostic_binary) {
// Legacy patchtoken path
std::string driver_version, current_driver_version;
ib >> driver_version;
diff --git a/src/plugins/intel_gpu/src/graph/program.cpp b/src/plugins/intel_gpu/src/graph/program.cpp
index 9c7650872a2..7654ca70243 100644
--- a/src/plugins/intel_gpu/src/graph/program.cpp
+++ b/src/plugins/intel_gpu/src/graph/program.cpp
@@ -243,12 +243,10 @@ void program::init_program() {
if (_task_executor == nullptr)
_task_executor = program::make_task_executor(_config);
- if (_engine.runtime_type() != runtime_types::sycl) {
- _kernels_cache = std::unique_ptr<kernels_cache>(new kernels_cache(_engine, _config, prog_id, _task_executor,
- kernel_selector::KernelBase::get_db().get_batch_headers()));
+ _kernels_cache = std::unique_ptr<kernels_cache>(new kernels_cache(_engine, _config, prog_id, _task_executor,
+ kernel_selector::KernelBase::get_db().get_batch_headers()));
- _kernels_cache->set_kernels_reuse(_config.get_enable_kernels_reuse());
- }
+ _kernels_cache->set_kernels_reuse(_config.get_enable_kernels_reuse());
if (!_compilation_context)
_compilation_context = program::make_compilation_context(_config);
@@ -278,7 +276,6 @@ void program::init_primitives() {
}
kernels_cache& program::get_kernels_cache() const {
- OPENVINO_ASSERT(_engine.runtime_type() != runtime_types::sycl, "[GPU] Kernels cache is not available for SYCL runtime");
return *_kernels_cache;
}
@@ -1867,10 +1864,6 @@ void program::cancel_compilation_context() {
}
void program::save(cldnn::BinaryOutputBuffer& ob) const {
- if (_engine.runtime_type() == runtime_types::sycl) {
- OPENVINO_THROW("[GPU] program::save is not supported for SYCL runtime");
- }
-
std::map<cldnn::memory::ptr, std::vector<const cldnn::program_node*>> mutable_datas_ptrs;
ob << nodes_map.size();
@@ -1999,10 +1992,6 @@ void program::save(cldnn::BinaryOutputBuffer& ob) const {
void program::load(cldnn::BinaryInputBuffer& ib,
std::shared_ptr<const ov::Model> model_ptr,
std::shared_ptr<ov::intel_gpu::GpuWeightlessCacheMap> cache_attr_map) {
- if (_engine.runtime_type() == runtime_types::sycl) {
- OPENVINO_THROW("[GPU] program::load is not supported for SYCL runtime");
- }
-
init_program();
std::shared_ptr<WeightsMemory> weights_memory = nullptr;
diff --git a/src/plugins/intel_gpu/src/graph/registry/registry.hpp b/src/plugins/intel_gpu/src/graph/registry/registry.hpp
index 54873dbc8af..395b11da900 100644
--- a/src/plugins/intel_gpu/src/graph/registry/registry.hpp
+++ b/src/plugins/intel_gpu/src/graph/registry/registry.hpp
@@ -18,11 +18,7 @@
#define OV_GPU_WITH_SYCL 0
#endif
-#ifdef OV_GPU_WITH_SYCL_RT
-#define OV_GPU_WITH_OCL 0
-#else
#define OV_GPU_WITH_OCL 1
-#endif
#define OV_GPU_WITH_COMMON 1
#define OV_GPU_WITH_CPU 1
#ifdef ENABLE_CM_FOR_GPU
diff --git a/src/plugins/intel_gpu/src/plugin/remote_context.cpp b/src/plugins/intel_gpu/src/plugin/remote_context.cpp
index 639dbab0ae6..2a1e91a573d 100644
--- a/src/plugins/intel_gpu/src/plugin/remote_context.cpp
+++ b/src/plugins/intel_gpu/src/plugin/remote_context.cpp
@@ -43,6 +43,10 @@ ContextType get_default_context_type() {
return ContextType::ZE;
#elif defined(OV_GPU_WITH_OCL_RT)
return ContextType::OCL;
+ #elif defined(OV_GPU_WITH_SYCL_RT)
+ // TODO: return OCL or ZE ContextType according to the underlying SYCL backend.
+ // OCL is used as a placeholder for now.
+ return ContextType::OCL;
#else
#error "Expected OpenVINO GPU runtime macros to be defined"
#endif
@@ -68,6 +72,10 @@ RemoteContextImpl::RemoteContextImpl(const std::string& device_name, std::vector
}
RemoteContextImpl::RemoteContextImpl(const std::map<std::string, RemoteContextImpl::Ptr>& known_contexts, const AnyMap& params) {
+#ifdef OV_GPU_WITH_SYCL_RT
+ // TODO: enable shared RemoteContext for SYCL_RT once SYCL interop is wired up.
+ OPENVINO_THROW("[GPU] Shared RemoteContext is not supported with SYCL runtime yet");
+#endif
gpu_handle_param context_id = nullptr;
int ctx_device_id = 0;
int target_tile_id = -1;
@@ -125,6 +133,11 @@ const cldnn::engine& RemoteContextImpl::get_engine() const {
}
void RemoteContextImpl::init_properties() {
+#ifdef OV_GPU_WITH_SYCL_RT
+ // TODO: populate SYCL-backed RemoteContext properties once SYCL interop is wired up.
+ // SYCL engine exposes no OCL/ZE user-context handles; leave properties empty (RemoteTensor is blocked separately).
+ return;
+#endif
switch (m_type) {
case ContextType::OCL:
properties.insert(ov::intel_gpu::context_type(ov::intel_gpu::ContextType::OCL));
diff --git a/src/plugins/intel_gpu/src/plugin/remote_tensor.cpp b/src/plugins/intel_gpu/src/plugin/remote_tensor.cpp
index 99a8d33ea8b..571f7211d4b 100644
--- a/src/plugins/intel_gpu/src/plugin/remote_tensor.cpp
+++ b/src/plugins/intel_gpu/src/plugin/remote_tensor.cpp
@@ -187,6 +187,10 @@ RemoteTensorImpl::RemoteTensorImpl(RemoteContextImpl::Ptr context,
, m_shared_buffer_handle(shared_buffer_handle)
, m_va_mem(va_mem)
, m_mapped_memory(std::move(mapped_memory)) {
+#ifdef OV_GPU_WITH_SYCL_RT
+ // TODO: enable RemoteTensor for SYCL_RT once SYCL interop is wired up.
+ OPENVINO_THROW("[GPU] RemoteTensor is not supported with SYCL runtime yet");
+#endif
update_hash();
allocate();
}
diff --git a/src/plugins/intel_gpu/src/runtime/CMakeLists.txt b/src/plugins/intel_gpu/src/runtime/CMakeLists.txt
index 4803afa9a4d..5458d6d5b64 100644
--- a/src/plugins/intel_gpu/src/runtime/CMakeLists.txt
+++ b/src/plugins/intel_gpu/src/runtime/CMakeLists.txt
@@ -29,6 +29,12 @@ file(GLOB LIBRARY_SOURCES_SYCL
"${CMAKE_CURRENT_SOURCE_DIR}/sycl/*.cpp"
)
+file(GLOB LIBRARY_SOURCES_SYCL_INTEL
+ "${CMAKE_CURRENT_SOURCE_DIR}/sycl/intel/*.hpp"
+ "${CMAKE_CURRENT_SOURCE_DIR}/sycl/intel/*.cpp"
+)
+list(APPEND LIBRARY_SOURCES_SYCL ${LIBRARY_SOURCES_SYCL_INTEL})
+
file(GLOB_RECURSE OCL_SYCL_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/ocl/sycl_*.[ch]pp")
if(NOT OV_GPU_WITH_SYCL)
@@ -78,6 +84,11 @@ if(OV_GPU_WITH_SYCL)
target_compile_definitions(${TARGET_NAME} PUBLIC OV_GPU_WITH_SYCL)
endif()
+if(GPU_RT_TYPE STREQUAL "SYCL")
+ find_path(OCLOC_API_INCLUDE_DIR NAMES ocloc_api.h REQUIRED)
+ target_include_directories(${TARGET_NAME} PRIVATE ${OCLOC_API_INCLUDE_DIR})
+endif()
+
if(ENABLE_ONEDNN_FOR_GPU)
ov_target_link_libraries_as_system(${TARGET_NAME} PUBLIC onednn_gpu_tgt)
endif()
diff --git a/src/plugins/intel_gpu/src/runtime/device_query.cpp b/src/plugins/intel_gpu/src/runtime/device_query.cpp
index edae3c27f20..8f5ee0bc1bb 100644
--- a/src/plugins/intel_gpu/src/runtime/device_query.cpp
+++ b/src/plugins/intel_gpu/src/runtime/device_query.cpp
@@ -36,6 +36,7 @@ device_query::device_query(engine_types engine_type,
int target_tile_id,
bool initialize_devices) {
switch (runtime_type) {
+#if defined(OV_GPU_WITH_OCL_RT) || defined(OV_GPU_WITH_ZE_RT)
case runtime_types::ocl: {
OPENVINO_ASSERT(engine_type == engine_types::ocl || engine_type == engine_types::sycl);
ocl::ocl_device_detector ocl_detector;
@@ -51,6 +52,7 @@ device_query::device_query(engine_types engine_type,
#endif
break;
}
+#endif
#ifdef OV_GPU_WITH_ZE_RT
case runtime_types::ze: {
OPENVINO_ASSERT(engine_type == engine_types::ze);
diff --git a/src/plugins/intel_gpu/src/runtime/sycl/intel/sycl_kernel_builder.cpp b/src/plugins/intel_gpu/src/runtime/sycl/intel/sycl_kernel_builder.cpp
new file mode 100644
index 00000000000..5704fd5b230
--- /dev/null
+++ b/src/plugins/intel_gpu/src/runtime/sycl/intel/sycl_kernel_builder.cpp
@@ -0,0 +1,187 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+// Copyright (C) 2026 FUJITSU LIMITED
+//
+
+#include "sycl_kernel_builder.hpp"
+#include "../sycl_kernel.hpp"
+#include "../sycl_common.hpp"
+#include "openvino/core/except.hpp"
+#include "openvino/util/shared_object.hpp"
+
+#include <ocloc_api.h>
+
+#include <cstring>
+#include <exception>
+#include <memory>
+#include <string>
+#include <vector>
+
+namespace {
+
+#if defined(_WIN32)
+constexpr const char* OCLOC_LIBRARY_NAME = "ocloc64.dll";
+#else
+constexpr const char* OCLOC_LIBRARY_NAME = "libocloc.so";
+#endif
+
+struct OclocApi {
+ std::shared_ptr<void> lib;
+ pOclocInvoke invoke;
+ decltype(&oclocFreeOutput) free_output;
+};
+
+// Load ocloc and resolve its entry points exactly once per process.
+const OclocApi& get_ocloc_api() {
+ static const OclocApi api = [] {
+ OclocApi a;
+ try {
+ a.lib = ov::util::load_shared_object(OCLOC_LIBRARY_NAME);
+ a.invoke = reinterpret_cast<pOclocInvoke>(ov::util::get_symbol(a.lib, "oclocInvoke"));
+ a.free_output = reinterpret_cast<decltype(&oclocFreeOutput)>(
+ ov::util::get_symbol(a.lib, "oclocFreeOutput"));
+ } catch (const std::exception& e) {
+ OPENVINO_THROW("[GPU] failed to load ocloc library '", OCLOC_LIBRARY_NAME, "': ", e.what());
+ }
+ return a;
+ }();
+ return api;
+}
+
+uint32_t query_device_ip_version(::sycl::device device) {
+#if SYCL_EXT_ONEAPI_DEVICE_ARCHITECTURE
+ namespace syclex = ::sycl::ext::oneapi::experimental;
+
+ // The experimental `architecture` info query relies on backend support
+ // (e.g. `cl_intel_device_attribute_query` on the OpenCL backend). It may
+ // throw on drivers that do not implement it. In that case, fall back to 0
+ // so that ocloc is invoked without `-device` and still produces target
+ // independent SPIR-V.
+ try {
+ // arch = 0xAABBBBCCCCCCCCDD
+ // for Intel GPU, AA=0x00, BBBB=reserved, CCCCCCCC=GMDID, DD=reserved
+ const auto arch = device.get_info<syclex::info::device::architecture>();
+
+ // extract GMDID from arch
+ return static_cast<uint32_t>(static_cast<uint64_t>(arch) >> 8);
+ } catch (const ::sycl::exception&) {
+ return 0;
+ }
+#else
+ // If the device architecture extension is not available, fall back to 0.
+ (void)device;
+ return 0;
+#endif
+}
+
+std::vector<std::byte> opencl_c_to_spirv(const std::string& source,
+ const std::string& options,
+ uint32_t device_ip_version,
+ std::string& build_log) {
+ const auto& ocloc = get_ocloc_api();
+ auto* invoke_fn = ocloc.invoke;
+ auto* free_fn = ocloc.free_output;
+
+ // Build the ocloc argument list:
+ // ocloc -spv_only [-device <ip_ver>] [-options <options>] -file kernel.cl
+ std::vector<const char*> args = {"ocloc", "-spv_only"};
+
+ // Pass the device IP version so that ocloc enables the right extension set
+ // (including cl_khr_fp16, sub-groups, etc.).
+ std::string device_str;
+ if (device_ip_version != 0) {
+ device_str = std::to_string(device_ip_version);
+ args.push_back("-device");
+ args.push_back(device_str.c_str());
+ }
+
+ if (!options.empty()) {
+ args.push_back("-options");
+ args.push_back(options.c_str());
+ }
+ args.push_back("-file");
+ args.push_back("kernel.cl");
+
+ const uint8_t* src_data[] = {reinterpret_cast<const uint8_t*>(source.c_str())};
+ const uint64_t src_sizes[] = {static_cast<uint64_t>(source.size() + 1)};
+ const char* src_names[] = {"kernel.cl"};
+
+ uint32_t num_outputs = 0;
+ uint8_t** outputs = nullptr;
+ uint64_t* out_sizes = nullptr;
+ char** out_names = nullptr;
+
+ int ret = invoke_fn(static_cast<uint32_t>(args.size()), args.data(),
+ 1, src_data, src_sizes, src_names,
+ 0, nullptr, nullptr, nullptr,
+ &num_outputs, &outputs, &out_sizes, &out_names);
+
+ // Collect SPIR-V output and any error log
+ std::vector<std::byte> spirv;
+ build_log.clear();
+ for (uint32_t i = 0; i < num_outputs; ++i) {
+ if (out_names[i] && ::strstr(out_names[i], ".spv") != nullptr &&
+ outputs[i] != nullptr) {
+ spirv.assign(reinterpret_cast<std::byte*>(outputs[i]),
+ reinterpret_cast<std::byte*>(outputs[i]) + out_sizes[i]);
+ } else if (out_names[i] &&
+ ::strcmp(out_names[i], "stdout.log") == 0 &&
+ out_sizes[i] > 0) {
+ build_log.assign(reinterpret_cast<const char*>(outputs[i]), out_sizes[i]);
+ }
+ }
+ free_fn(&num_outputs, &outputs, &out_sizes, &out_names);
+
+ if (ret != 0 || spirv.empty()) {
+ GPU_DEBUG_INFO << "-------- Kernel build error" << std::endl;
+ GPU_DEBUG_INFO << build_log;
+ GPU_DEBUG_INFO << "-------- End of Kernel build error" << std::endl;
+
+ OPENVINO_THROW("[GPU] ocloc SPIR-V compilation failed");
+ }
+
+ return spirv;
+}
+
+} // namespace
+
+namespace cldnn {
+namespace sycl {
+namespace intel {
+
+sycl_kernel_builder::sycl_kernel_builder(const sycl_device& device)
+ : _device(device) {}
+
+ void sycl_kernel_builder::build_kernels(
+ const void* src, size_t src_bytes, KernelFormat src_format,
+ const std::string& options,
+ std::vector<kernel::ptr>& out) const {
+ OPENVINO_ASSERT(src && src_bytes > 0,
+ "[GPU] sycl::intel::sycl_kernel_builder: empty kernel source");
+
+ std::vector<std::byte> spirv;
+ std::string build_log;
+
+ if (src_format == KernelFormat::SOURCE) {
+ const std::string source(static_cast<const char*>(src), src_bytes);
+ spirv = opencl_c_to_spirv(source, options, query_device_ip_version(_device.get_device()), build_log);
+ } else if (src_format == KernelFormat::NATIVE_BIN) {
+ // For Intel SYCL, the "native binary" stored in the kernel cache is
+ // the SPIR-V binary returned by sycl_kernel::get_binary().
+ spirv.assign(static_cast<const std::byte*>(src),
+ static_cast<const std::byte*>(src) + src_bytes);
+ } else {
+ OPENVINO_THROW("[GPU] sycl::intel::sycl_kernel_builder: unsupported kernel format");
+ }
+
+ cldnn::sycl::sycl_kernel::create_kernels(
+ _device.get_context(),
+ std::make_shared<const std::vector<std::byte>>(std::move(spirv)),
+ std::make_shared<const std::string>(std::move(build_log)),
+ out);
+}
+
+} // namespace intel
+} // namespace sycl
+} // namespace cldnn
diff --git a/src/plugins/intel_gpu/src/runtime/sycl/intel/sycl_kernel_builder.hpp b/src/plugins/intel_gpu/src/runtime/sycl/intel/sycl_kernel_builder.hpp
new file mode 100644
index 00000000000..7217f97cc99
--- /dev/null
+++ b/src/plugins/intel_gpu/src/runtime/sycl/intel/sycl_kernel_builder.hpp
@@ -0,0 +1,36 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+// Copyright (C) 2026 FUJITSU LIMITED
+//
+
+#pragma once
+
+#include "intel_gpu/runtime/kernel_builder.hpp"
+#include "../sycl_device.hpp"
+
+#include <cstdint>
+#include <string>
+#include <vector>
+
+namespace cldnn {
+namespace sycl {
+namespace intel {
+
+class sycl_kernel_builder : public kernel_builder {
+public:
+ explicit sycl_kernel_builder(const sycl_device& device);
+
+ void build_kernels(const void* src,
+ size_t src_bytes,
+ KernelFormat src_format,
+ const std::string& options,
+ std::vector<kernel::ptr>& out) const override;
+
+private:
+ const sycl_device& _device;
+};
+
+} // namespace intel
+} // namespace sycl
+} // namespace cldnn
diff --git a/src/plugins/intel_gpu/src/runtime/sycl/sycl_base_kernel.cpp b/src/plugins/intel_gpu/src/runtime/sycl/sycl_base_kernel.cpp
new file mode 100644
index 00000000000..1551669a794
--- /dev/null
+++ b/src/plugins/intel_gpu/src/runtime/sycl/sycl_base_kernel.cpp
@@ -0,0 +1,99 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+// Copyright (C) 2026 FUJITSU LIMITED
+//
+
+#include "sycl_base_kernel.hpp"
+
+#include <utility>
+#include <vector>
+
+namespace cldnn {
+namespace sycl {
+
+namespace {
+
+memory::cptr resolve_arg_mem(const argument_desc& arg,
+ const kernel_arguments_data& data) {
+ using T = argument_desc::Types;
+ switch (arg.t) {
+ case T::INPUT:
+ OPENVINO_ASSERT(arg.index < data.inputs.size() && data.inputs[arg.index],
+ "The allocated input memory is necessary to set kernel arguments.");
+ return data.inputs[arg.index];
+ case T::OUTPUT:
+ OPENVINO_ASSERT(arg.index < data.outputs.size() && data.outputs[arg.index],
+ "The allocated output memory is necessary to set kernel arguments.");
+ return data.outputs[arg.index];
+ case T::WEIGHTS:
+ return data.weights;
+ case T::BIAS:
+ return data.bias;
+ case T::SCALE_TABLE:
+ return data.scale_table;
+ case T::SLOPE:
+ return data.slope;
+ case T::INTERNAL_BUFFER:
+ OPENVINO_ASSERT(arg.index < data.intermediates.size() && data.intermediates[arg.index],
+ "The allocated intermediate memory is necessary to set kernel arguments.");
+ return data.intermediates[arg.index];
+ case T::CELL:
+ return data.cell;
+ case T::WEIGHTS_ZERO_POINTS:
+ return data.weights_zero_points;
+ case T::ACTIVATIONS_ZERO_POINTS:
+ return data.activations_zero_points;
+ case T::COMPENSATION:
+ return data.compensation;
+ case T::INPUT_OF_FUSED_PRIMITIVE:
+ OPENVINO_ASSERT(arg.index < data.fused_op_inputs.size() && data.fused_op_inputs[arg.index],
+ "The allocated fused_op_input memory is necessary to set kernel arguments.");
+ return data.fused_op_inputs[arg.index];
+ case T::SHAPE_INFO:
+ return data.shape_info;
+ default:
+ return nullptr;
+ }
+}
+
+} // namespace
+
+void sycl_base_kernel::set_arguments(const kernel_arguments_desc& args_desc,
+ const kernel_arguments_data& data) {
+ const auto& desc = args_desc.arguments;
+ std::vector<arg_t> next;
+ next.reserve(desc.size());
+
+ for (const auto& ad : desc) {
+ arg_t a;
+ using T = argument_desc::Types;
+ if (ad.t == T::SCALAR) {
+ a.kind = arg_t::kind_t::SCALAR;
+ OPENVINO_ASSERT(data.scalars && ad.index < data.scalars->size(),
+ "The allocated scalar is necessary to set kernel arguments.");
+ a.scalar = (*data.scalars)[ad.index];
+ } else if (ad.t == T::LOCAL_MEMORY_SIZE) {
+ a.kind = arg_t::kind_t::LOCAL_MEM;
+ OPENVINO_ASSERT(data.local_memory_args && ad.index < data.local_memory_args->size()
+ && (*data.local_memory_args)[ad.index],
+ "The allocated local memory is necessary to set kernel arguments.");
+ a.local_size = (*data.local_memory_args)[ad.index];
+ } else {
+ a.kind = arg_t::kind_t::BUFFER;
+ a.mem = resolve_arg_mem(ad, data);
+ }
+ next.push_back(std::move(a));
+ }
+
+ std::lock_guard<std::mutex> lock(_args_mutex);
+ _stored_args = std::move(next);
+}
+
+std::vector<sycl_base_kernel::arg_t> sycl_base_kernel::stored_args() const {
+ std::lock_guard<std::mutex> lock(_args_mutex);
+ return _stored_args;
+}
+
+} // namespace sycl
+} // namespace cldnn
diff --git a/src/plugins/intel_gpu/src/runtime/sycl/sycl_base_kernel.hpp b/src/plugins/intel_gpu/src/runtime/sycl/sycl_base_kernel.hpp
new file mode 100644
index 00000000000..d15cf6f76b5
--- /dev/null
+++ b/src/plugins/intel_gpu/src/runtime/sycl/sycl_base_kernel.hpp
@@ -0,0 +1,47 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+// Copyright (C) 2026 FUJITSU LIMITED
+//
+
+#pragma once
+
+#include "sycl_common.hpp"
+#include "intel_gpu/runtime/kernel_args.hpp"
+#include "intel_gpu/runtime/kernel.hpp"
+
+#include <mutex>
+#include <vector>
+
+namespace cldnn {
+namespace sycl {
+
+class sycl_base_kernel : public cldnn::kernel {
+public:
+ // Backend-independent description of one kernel argument slot.
+ struct arg_t {
+ enum class kind_t { BUFFER, SCALAR, LOCAL_MEM };
+ kind_t kind = kind_t::BUFFER;
+ memory::cptr mem; // BUFFER
+ scalar_desc scalar{}; // SCALAR
+ size_t local_size = 0; // LOCAL_MEM (bytes)
+ };
+
+ // Store per-dispatch kernel arguments (called before launch).
+ void set_arguments(const kernel_arguments_desc& args_desc,
+ const kernel_arguments_data& data);
+
+ // Record this kernel into the given SYCL command group (handler).
+ virtual void launch(::sycl::handler& cgh,
+ const kernel_arguments_desc& args_desc) = 0;
+
+protected:
+ // Return a snapshot of the stored arguments taken under _args_mutex.
+ std::vector<arg_t> stored_args() const;
+
+ mutable std::mutex _args_mutex;
+ std::vector<arg_t> _stored_args;
+};
+
+} // namespace sycl
+} // namespace cldnn
diff --git a/src/plugins/intel_gpu/src/runtime/sycl/sycl_engine.cpp b/src/plugins/intel_gpu/src/runtime/sycl/sycl_engine.cpp
index 9fafc6a35c6..8d1b09313d8 100644
--- a/src/plugins/intel_gpu/src/runtime/sycl/sycl_engine.cpp
+++ b/src/plugins/intel_gpu/src/runtime/sycl/sycl_engine.cpp
@@ -11,6 +11,7 @@
#include "sycl_memory.hpp"
#include "sycl_stream.hpp"
#include "sycl_engine_factory.hpp"
+#include "intel/sycl_kernel_builder.hpp"
#include <string>
#include <vector>
#include <memory>
@@ -237,15 +238,23 @@ bool sycl_engine::is_the_same_buffer(const memory& mem1, const memory& mem2) {
downcast<const sycl::gpu_usm>(mem2).get_buffer();
}
-void* sycl_engine::get_user_context() const {
+void* sycl_engine::get_user_context(runtime_types rt_type) const {
+ OPENVINO_ASSERT(rt_type == runtime_types::sycl,
+ "[GPU] SYCL engine can only provide SYCL context but requested context for ", rt_type);
auto& sycl_device = downcast<sycl::sycl_device>(*_device);
return const_cast<void*>(static_cast<const void*>(&sycl_device.get_context()));
}
std::shared_ptr<kernel_builder> sycl_engine::create_kernel_builder() const {
- auto sycl_device = std::dynamic_pointer_cast<sycl::sycl_device>(_device);
- OPENVINO_ASSERT(sycl_device, "[GPU] Invalid device type for sycl_engine");
- OPENVINO_NOT_IMPLEMENTED;
+ auto& sycl_device = downcast<sycl::sycl_device>(*_device);
+ switch (sycl_device.get_device().get_backend()) {
+ case ::sycl::backend::opencl:
+ case ::sycl::backend::ext_oneapi_level_zero:
+ return std::make_shared<sycl::intel::sycl_kernel_builder>(sycl_device);
+ default:
+ OPENVINO_THROW("[GPU] No kernel builder available for backend ",
+ sycl_device.get_device().get_backend());
+ }
}
bool sycl_engine::extension_supported(::sycl::aspect extension) const {
diff --git a/src/plugins/intel_gpu/src/runtime/sycl/sycl_engine.hpp b/src/plugins/intel_gpu/src/runtime/sycl/sycl_engine.hpp
index 89a1489e38a..1603a624454 100644
--- a/src/plugins/intel_gpu/src/runtime/sycl/sycl_engine.hpp
+++ b/src/plugins/intel_gpu/src/runtime/sycl/sycl_engine.hpp
@@ -36,7 +36,7 @@ public:
memory_ptr import_buffer(const layout& layout, ov::intel_gpu::os_handle_param external_handle) override;
bool is_the_same_buffer(const memory& mem1, const memory& mem2) override;
- void* get_user_context() const override;
+ void* get_user_context(runtime_types rt_type) const override;
allocation_type get_default_allocation_type() const override { return allocation_type::sycl_buffer; }
allocation_type detect_usm_allocation_type(const void* memory) const override;
diff --git a/src/plugins/intel_gpu/src/runtime/sycl/sycl_kernel.cpp b/src/plugins/intel_gpu/src/runtime/sycl/sycl_kernel.cpp
new file mode 100644
index 00000000000..cb6feb8a621
--- /dev/null
+++ b/src/plugins/intel_gpu/src/runtime/sycl/sycl_kernel.cpp
@@ -0,0 +1,252 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+// Copyright (C) 2026 FUJITSU LIMITED
+//
+
+#include "sycl_kernel.hpp"
+#include "sycl_memory.hpp"
+#include "openvino/core/except.hpp"
+
+#include <algorithm>
+#include <cstddef>
+#include <cstdint>
+#include <cstring>
+#include <vector>
+
+namespace cldnn {
+namespace sycl {
+
+namespace {
+
+// SPIR-V magic number (little-endian layout in memory)
+constexpr uint32_t SPIRV_MAGIC = 0x07230203u;
+
+// OpEntryPoint opcode
+constexpr uint16_t SPIRV_OP_ENTRY_POINT = 15u;
+
+// Execution model value for OpenCL kernels
+constexpr uint32_t SPIRV_EXEC_MODEL_KERNEL = 6u;
+
+// Read a uint32_t from an unaligned/potentially-aliased byte pointer via
+// memcpy. Compilers (GCC/Clang/MSVC) fold this into a single load
+// instruction when the pointer is in fact aligned, so there is no
+// runtime overhead in the common case.
+inline uint32_t read_u32(const void* p) noexcept {
+ uint32_t v;
+ std::memcpy(&v, p, sizeof(v));
+ return v;
+}
+
+// Validates the SPIR-V module header: non-null pointer, at least the 5-word
+// header (magic, version, generator, bound, schema) present, and correct magic.
+bool is_spirv(const void* data, size_t bytes) {
+ if (!data || bytes < 5 * sizeof(uint32_t) || bytes % sizeof(uint32_t) != 0)
+ return false;
+ return read_u32(data) == SPIRV_MAGIC;
+}
+
+// Extracts entry point names (OpEntryPoint with ExecutionModel=Kernel) from a
+// SPIR-V module. Throws if the input is not a valid SPIR-V binary.
+std::vector<std::string> extract_spirv_kernel_names(const void* data, size_t bytes) {
+ if (!is_spirv(data, bytes)) {
+ OPENVINO_THROW("[GPU] extract_spirv_kernel_names: invalid SPIR-V binary");
+ }
+
+ const size_t word_count = bytes / sizeof(uint32_t);
+ const auto* p = static_cast<const uint8_t*>(data);
+
+ std::vector<std::string> names;
+ size_t i = 5; // skip the five-word header
+ while (i < word_count) {
+ const uint32_t first_word = read_u32(p + i * sizeof(uint32_t));
+ const uint16_t opcode = static_cast<uint16_t>(first_word & 0xFFFFu);
+ const uint16_t instr_words = static_cast<uint16_t>(first_word >> 16u);
+
+ // An instruction must contain at least the opcode word and must not
+ // extend past the end of the module. (word_count - i) is safe from
+ // underflow because the loop guard ensures i < word_count.
+ if (instr_words == 0 || instr_words > word_count - i) {
+ OPENVINO_THROW("[GPU] extract_spirv_kernel_names: malformed SPIR-V instruction at word offset ", i);
+ }
+
+ // OpEntryPoint layout:
+ // word 0: opcode | wordcount (already consumed above)
+ // word 1: execution model
+ // word 2: entry point <id>
+ // word 3..: name (null-terminated UTF-8, packed into 4-byte words)
+ // The minimum valid wordcount is therefore 4 (empty name still needs
+ // one null-terminator word).
+ if (opcode == SPIRV_OP_ENTRY_POINT &&
+ instr_words >= 4 &&
+ read_u32(p + (i + 1) * sizeof(uint32_t)) == SPIRV_EXEC_MODEL_KERNEL) {
+ const char* name_start =
+ reinterpret_cast<const char*>(p + (i + 3) * sizeof(uint32_t));
+ const size_t max_name_bytes =
+ (static_cast<size_t>(instr_words) - 3) * sizeof(uint32_t);
+ const char* name_end = static_cast<const char*>(
+ std::memchr(name_start, '\0', max_name_bytes));
+ const size_t name_len =
+ name_end ? static_cast<size_t>(name_end - name_start) : max_name_bytes;
+ names.emplace_back(name_start, name_len);
+ }
+
+ i += instr_words;
+ }
+ return names;
+}
+
+// Entry point names present in a SPIR-V module but not usable as executable kernels.
+// These are compiler-internal (vendor-specific) synthetic entries and cannot be
+// looked up via ext_oneapi_get_kernel().
+// - "Intel_Symbol_Table_Void_Program": IGC bookkeeping entry for externally-linked
+// / indirectly-called symbols.
+bool is_ignored_kernel_name(const std::string& name) {
+ return name == "Intel_Symbol_Table_Void_Program";
+}
+
+} // namespace
+
+std::vector<uint8_t> sycl_kernel::get_binary() const {
+ OPENVINO_ASSERT(_spirv_binary && !_spirv_binary->empty(),
+ "[GPU] sycl_kernel::get_binary: SPIR-V binary is empty");
+
+ const auto* p = reinterpret_cast<const uint8_t*>(_spirv_binary->data());
+ return std::vector<uint8_t>(p, p + _spirv_binary->size());
+}
+
+std::string sycl_kernel::get_build_log() const {
+ return _build_log ? *_build_log : std::string{};
+}
+
+void sycl_kernel::launch(::sycl::handler& cgh,
+ const kernel_arguments_desc& args_desc) {
+ // Get stored_args by value to avoid data race
+ const auto args = stored_args();
+
+ const auto& gws = args_desc.workGroups.global;
+ const auto& lws = args_desc.workGroups.local;
+
+ // Associate the kernel bundle with this command group so that set_arg and
+ // parallel_for know which kernel to target.
+ cgh.use_kernel_bundle(_compiled_kernel.get_kernel_bundle());
+
+ // Bind each argument.
+ int arg_idx = 0;
+ for (const auto& arg : args) {
+ if (arg.kind == arg_t::kind_t::BUFFER) {
+ if (!arg.mem) {
+ OPENVINO_THROW("[GPU] sycl_kernel::launch: null memory for BUFFER arg at index ", arg_idx);
+ }
+ if (auto* gu = dynamic_cast<const gpu_usm*>(arg.mem.get())) {
+ // USM pointer: pass the device pointer directly.
+ void* ptr = gu->buffer_ptr();
+ cgh.set_arg(arg_idx, ptr);
+ } else if (auto* gb = dynamic_cast<const gpu_buffer*>(arg.mem.get())) {
+ // SYCL buffer: create a read-write accessor on the
+ // (sub-)buffer so the runtime registers the dependency and
+ // passes the cl_mem to the OpenCL kernel argument.
+ auto acc = const_cast<gpu_buffer*>(gb)->get_buffer().template get_access<::sycl::access::mode::read_write>(cgh);
+ cgh.set_arg(arg_idx, acc);
+ } else {
+ OPENVINO_THROW("[GPU] sycl_kernel::launch: unknown memory type at arg index ", arg_idx);
+ }
+ } else if (arg.kind == arg_t::kind_t::LOCAL_MEM) {
+ ::sycl::local_accessor<std::byte, 1> local_acc(arg.local_size, cgh);
+ cgh.set_arg(arg_idx, local_acc);
+ } else if (arg.kind == arg_t::kind_t::SCALAR) {
+ // Pass the scalar value with the correct C++ type so SYCL can
+ // determine the correct kernel argument size.
+ switch (arg.scalar.t) {
+ case scalar_desc::Types::UINT8:
+ cgh.set_arg(arg_idx, arg.scalar.v.u8); break;
+ case scalar_desc::Types::UINT16:
+ cgh.set_arg(arg_idx, arg.scalar.v.u16); break;
+ case scalar_desc::Types::UINT32:
+ cgh.set_arg(arg_idx, arg.scalar.v.u32); break;
+ case scalar_desc::Types::UINT64:
+ cgh.set_arg(arg_idx, arg.scalar.v.u64); break;
+ case scalar_desc::Types::INT8:
+ cgh.set_arg(arg_idx, arg.scalar.v.s8); break;
+ case scalar_desc::Types::INT16:
+ cgh.set_arg(arg_idx, arg.scalar.v.s16); break;
+ case scalar_desc::Types::INT32:
+ cgh.set_arg(arg_idx, arg.scalar.v.s32); break;
+ case scalar_desc::Types::INT64:
+ cgh.set_arg(arg_idx, arg.scalar.v.s64); break;
+ case scalar_desc::Types::FLOAT32:
+ cgh.set_arg(arg_idx, arg.scalar.v.f32); break;
+ case scalar_desc::Types::FLOAT64:
+ cgh.set_arg(arg_idx, arg.scalar.v.f64); break;
+ default:
+ OPENVINO_THROW("[GPU] sycl_kernel::launch: "
+ "unknown scalar type at arg index ", arg_idx);
+ }
+ }
+ ++arg_idx;
+ }
+
+ // Build the nd_range from the work-group sizes stored in args_desc.
+ // OpenVINO follows OpenCL convention: gws[0]=X (fastest), gws[1]=Y, gws[2]=Z (slowest).
+ // SYCL nd_range<3>(r0,r1,r2) uses the opposite convention (dim 0 = slowest) and
+ // passes OpenCL globalWorkSize={r2, r1, r0}. To preserve the OpenCL IDs seen by
+ // the kernel we must reverse the dimensions:
+ // SYCL range<3>(g2, g1, g0) -> OpenCL globalWorkSize = {g0, g1, g2}
+ const size_t g0 = gws.size() > 0 ? gws[0] : 1;
+ const size_t g1 = gws.size() > 1 ? gws[1] : 1;
+ const size_t g2 = gws.size() > 2 ? gws[2] : 1;
+
+ ::sycl::range<3> global_range(g2, g1, g0);
+
+ if (lws.empty()) {
+ // When no local work size is specified, let the SYCL runtime choose
+ // the optimal work-group size, matching OpenCL's LWS=NULL behavior.
+ cgh.parallel_for(global_range, _compiled_kernel);
+ } else {
+ const size_t l0 = lws[0];
+ const size_t l1 = lws.size() > 1 ? lws[1] : 1;
+ const size_t l2 = lws.size() > 2 ? lws[2] : 1;
+
+ ::sycl::nd_range<3> ndr(global_range, ::sycl::range<3>(l2, l1, l0));
+ cgh.parallel_for(ndr, _compiled_kernel);
+ }
+}
+
+void sycl_kernel::create_kernels(const ::sycl::context& ctx,
+ std::shared_ptr<const std::vector<std::byte>> spirv_binary,
+ std::shared_ptr<const std::string> build_log,
+ std::vector<kernel::ptr>& out) {
+ namespace syclex = ::sycl::ext::oneapi::experimental;
+
+ OPENVINO_ASSERT(spirv_binary && !spirv_binary->empty(),
+ "[GPU] sycl_kernel::create_kernels: empty SPIR-V binary");
+
+ // extract_spirv_kernel_names throws if the binary is not a valid SPIR-V module.
+ auto kernel_names = extract_spirv_kernel_names(spirv_binary->data(), spirv_binary->size());
+
+ // Drop kernel names that are not executable
+ kernel_names.erase(std::remove_if(kernel_names.begin(), kernel_names.end(),
+ is_ignored_kernel_name),
+ kernel_names.end());
+
+ if (kernel_names.empty()) {
+ OPENVINO_THROW("[GPU] sycl_kernel::create_kernels: no executable kernel entry points found in SPIR-V binary");
+ }
+
+ try {
+ auto src_bundle = syclex::create_kernel_bundle_from_source(ctx,
+ syclex::source_language::spirv,
+ *spirv_binary);
+ auto exec_bundle = syclex::build(src_bundle);
+
+ for (const auto& kernel_name : kernel_names) {
+ ::sycl::kernel k = exec_bundle.ext_oneapi_get_kernel(kernel_name);
+ out.push_back(std::make_shared<sycl_kernel>(k, kernel_name, spirv_binary, build_log));
+ }
+ } catch (const ::sycl::exception& e) {
+ OPENVINO_THROW(SYCL_ERR_MSG_FMT(e));
+ }
+}
+
+} // namespace sycl
+} // namespace cldnn
diff --git a/src/plugins/intel_gpu/src/runtime/sycl/sycl_kernel.hpp b/src/plugins/intel_gpu/src/runtime/sycl/sycl_kernel.hpp
index 2046d6ac85b..ace4675943f 100644
--- a/src/plugins/intel_gpu/src/runtime/sycl/sycl_kernel.hpp
+++ b/src/plugins/intel_gpu/src/runtime/sycl/sycl_kernel.hpp
@@ -6,50 +6,56 @@
#pragma once
+#include "sycl_base_kernel.hpp"
#include "sycl_common.hpp"
-#include "sycl_memory.hpp"
#include "intel_gpu/runtime/kernel_args.hpp"
#include "intel_gpu/runtime/kernel.hpp"
+#include <cstddef>
#include <memory>
+#include <string>
#include <vector>
namespace cldnn {
namespace sycl {
-class sycl_kernel : public kernel {
- sycl_kernel_type _compiled_kernel;
- std::string _kernel_id;
-
+class sycl_kernel : public sycl_base_kernel {
public:
- sycl_kernel(sycl_kernel_type compiled_kernel, const std::string& kernel_id)
- : _compiled_kernel(compiled_kernel)
- , _kernel_id(kernel_id) { }
+ sycl_kernel(sycl_kernel_type compiled_kernel, const std::string& kernel_id,
+ std::shared_ptr<const std::vector<std::byte>> spirv_binary,
+ std::shared_ptr<const std::string> build_log = {})
+ : _compiled_kernel(std::move(compiled_kernel))
+ , _kernel_id(kernel_id)
+ , _spirv_binary(std::move(spirv_binary))
+ , _build_log(std::move(build_log)) { }
std::string get_id() const override { return _kernel_id; }
- const sycl_kernel_type& get_handle() const { return _compiled_kernel; }
- sycl_kernel_type& get_handle() { return _compiled_kernel; }
- std::shared_ptr<kernel> clone(bool reuse_kernel_handle = false) const override {
- if (reuse_kernel_handle)
- return std::make_shared<sycl_kernel>(get_handle(), _kernel_id);
-
- OPENVINO_THROW("SYCL kernel cloning with reuse_kernel_handle=false is not supported.");
+ std::shared_ptr<kernel> clone(bool /*reuse_kernel_handle*/ = false) const override {
+ return std::make_shared<sycl_kernel>(_compiled_kernel, _kernel_id, _spirv_binary, _build_log);
}
bool is_same(const kernel &other) const override {
auto other_ptr = dynamic_cast<const sycl_kernel*>(&other);
if (other_ptr == nullptr) {
return false;
}
- return get_handle() == other_ptr->get_handle();
+ return _compiled_kernel == other_ptr->_compiled_kernel;
}
- std::vector<uint8_t> get_binary() const override {
- OPENVINO_NOT_IMPLEMENTED;
- }
+ std::vector<uint8_t> get_binary() const override;
+ std::string get_build_log() const override;
- std::string get_build_log() const override {
- OPENVINO_NOT_IMPLEMENTED;
- }
+ void launch(::sycl::handler& cgh, const kernel_arguments_desc& args_desc) override;
+
+ static void create_kernels(const ::sycl::context& ctx,
+ std::shared_ptr<const std::vector<std::byte>> spirv_binary,
+ std::shared_ptr<const std::string> build_log,
+ std::vector<kernel::ptr>& out);
+
+private:
+ sycl_kernel_type _compiled_kernel;
+ std::string _kernel_id;
+ std::shared_ptr<const std::vector<std::byte>> _spirv_binary;
+ std::shared_ptr<const std::string> _build_log;
};
} // namespace sycl
diff --git a/src/plugins/intel_gpu/src/runtime/sycl/sycl_memory.cpp b/src/plugins/intel_gpu/src/runtime/sycl/sycl_memory.cpp
index bd3d6baf323..98024a34f57 100644
--- a/src/plugins/intel_gpu/src/runtime/sycl/sycl_memory.cpp
+++ b/src/plugins/intel_gpu/src/runtime/sycl/sycl_memory.cpp
@@ -158,7 +158,8 @@ event::ptr gpu_buffer::fill(stream& stream, unsigned char pattern, const std::ve
}
}
-shared_mem_params gpu_buffer::get_internal_params() const {
+shared_mem_params gpu_buffer::get_internal_params(runtime_types rt_type) const {
+ OPENVINO_ASSERT(rt_type == runtime_types::sycl, "[GPU] gpu_buffer can not provide internal params for non-SYCL runtime");
auto sycl_engine = downcast<const sycl::sycl_engine>(_engine);
return {shared_mem_type::shared_mem_buffer, const_cast<shared_handle>(static_cast<const void*>(&(sycl_engine->get_sycl_context()))), nullptr,
const_cast<shared_handle>(static_cast<const void*>(&_buffer)),
@@ -584,7 +585,8 @@ dnnl::memory gpu_usm::get_onednn_memory(dnnl::memory::desc desc, int64_t offset)
}
#endif
-shared_mem_params gpu_usm::get_internal_params() const {
+shared_mem_params gpu_usm::get_internal_params(runtime_types rt_type) const {
+ OPENVINO_ASSERT(rt_type == runtime_types::sycl, "[GPU] gpu_usm can not provide internal params for non-SYCL runtime");
auto sycl_engine = downcast<const sycl::sycl_engine>(_engine);
return {
shared_mem_type::shared_mem_usm, // shared_mem_type
diff --git a/src/plugins/intel_gpu/src/runtime/sycl/sycl_memory.hpp b/src/plugins/intel_gpu/src/runtime/sycl/sycl_memory.hpp
index 5ca70d03e1a..7f8a72cfdec 100644
--- a/src/plugins/intel_gpu/src/runtime/sycl/sycl_memory.hpp
+++ b/src/plugins/intel_gpu/src/runtime/sycl/sycl_memory.hpp
@@ -159,7 +159,7 @@ struct gpu_buffer : public lockable_gpu_mem, public memory {
void unlock(const stream& stream) override;
event::ptr fill(stream& stream, unsigned char pattern, const std::vector<event::ptr>& dep_events = {}, bool blocking = true) override;
event::ptr fill(stream& stream, const std::vector<event::ptr>& dep_events = {}, bool blocking = true) override;
- shared_mem_params get_internal_params() const override;
+ shared_mem_params get_internal_params(runtime_types rt_type) const override;
::sycl::buffer<std::byte, 1>& get_buffer() {
assert(0 == _lock_count);
return _buffer;
@@ -211,7 +211,7 @@ struct gpu_usm : public lockable_gpu_mem, public memory {
event::ptr fill(stream& stream, unsigned char pattern, const std::vector<event::ptr>& dep_events = {}, bool blocking = true) override;
event::ptr fill(stream& stream, const std::vector<event::ptr>& dep_events = {}, bool blocking = true) override;
- shared_mem_params get_internal_params() const override;
+ shared_mem_params get_internal_params(runtime_types rt_type) const override;
event::ptr copy_from(stream& stream, const void* data_ptr, size_t src_offset, size_t dst_offset, size_t size, bool blocking) override;
event::ptr copy_from(stream& stream, const memory& src_mem, size_t src_offset, size_t dst_offset, size_t size, bool blocking) override;
diff --git a/src/plugins/intel_gpu/src/runtime/sycl/sycl_stream.cpp b/src/plugins/intel_gpu/src/runtime/sycl/sycl_stream.cpp
index 70ee8a7ed17..cd8589f2b9f 100644
--- a/src/plugins/intel_gpu/src/runtime/sycl/sycl_stream.cpp
+++ b/src/plugins/intel_gpu/src/runtime/sycl/sycl_stream.cpp
@@ -5,12 +5,11 @@
//
#include "sycl_stream.hpp"
-#include "CL/cl.h"
#include "intel_gpu/runtime/stream.hpp"
#include "sycl_event.hpp"
#include "sycl_command_queues_builder.hpp"
#include "intel_gpu/runtime/debug_configuration.hpp"
-#include "sycl_kernel.hpp"
+#include "sycl_base_kernel.hpp"
#include "sycl_common.hpp"
#include <cassert>
@@ -72,15 +71,63 @@ QueueTypes sycl_stream::detect_queue_type(void *queue_handle) {
}
void sycl_stream::set_arguments(kernel& kernel, const kernel_arguments_desc& args_desc, const kernel_arguments_data& args) {
- OPENVINO_THROW("[GPU] sycl_stream::set_arguments is not implemented");
+ auto& sycl_kern = downcast<sycl_base_kernel>(kernel);
+ GPU_DEBUG_TRACE_DETAIL << "Set arguments for primitive: " << args_desc.layerID << " (" << kernel.get_id() << ")\n";
+ sycl_kern.set_arguments(args_desc, args);
}
event::ptr sycl_stream::enqueue_kernel(kernel& kernel,
const kernel_arguments_desc& args_desc,
- const kernel_arguments_data& args,
+ const kernel_arguments_data& /* args */,
std::vector<event::ptr> const& deps,
bool is_output) {
- OPENVINO_THROW("[GPU] sycl_stream::enqueue_kernel is not implemented");
+ auto& sycl_kern = downcast<sycl_base_kernel>(kernel);
+
+ // Skip launching the kernel if any of the global work-group dimensions is zero.
+ // Fall back to enqueue_marker() so downstream dependencies still see a valid
+ // completion event.
+ {
+ const auto& gws = args_desc.workGroups.global;
+ bool has_zero_gws = false;
+ for (size_t i = 0; i < gws.size(); ++i) {
+ if (gws[i] == 0) {
+ has_zero_gws = true;
+ break;
+ }
+ }
+ if (has_zero_gws) {
+ GPU_DEBUG_TRACE_DETAIL << "Skip empty kernel launch: " << args_desc.layerID
+ << " (" << kernel.get_id() << ") gws=["
+ << (gws.size() > 0 ? gws[0] : 0) << ", "
+ << (gws.size() > 1 ? gws[1] : 0) << ", "
+ << (gws.size() > 2 ? gws[2] : 0) << "]" << std::endl;
+ return enqueue_marker(deps, is_output);
+ }
+ }
+
+ // Collect dependency events
+ std::vector<::sycl::event> dep_events;
+ if (m_sync_method == SyncMethods::events) {
+ for (auto& dep : deps) {
+ if (auto* sycl_base_ev = dynamic_cast<sycl_base_event*>(dep.get()))
+ dep_events.push_back(sycl_base_ev->get());
+ }
+ } else if (m_sync_method == SyncMethods::barriers) {
+ sync_events(deps, is_output);
+ }
+
+ ::sycl::event ret_ev;
+ try {
+ ret_ev = _command_queue.submit([&](::sycl::handler& cgh) {
+ if (!dep_events.empty())
+ cgh.depends_on(dep_events);
+ sycl_kern.launch(cgh, args_desc);
+ });
+ } catch (::sycl::exception const& err) {
+ OPENVINO_THROW(SYCL_ERR_MSG_FMT(err));
+ }
+
+ return std::make_shared<sycl_event>(ret_ev, _command_queue, ++_queue_counter);
}
void sycl_stream::enqueue_barrier() {
diff --git a/src/plugins/intel_gpu/tests/unit/module_tests/sycl/sycl_kernel_builder_test.cpp b/src/plugins/intel_gpu/tests/unit/module_tests/sycl/sycl_kernel_builder_test.cpp
new file mode 100644
index 00000000000..c39c30279c2
--- /dev/null
+++ b/src/plugins/intel_gpu/tests/unit/module_tests/sycl/sycl_kernel_builder_test.cpp
@@ -0,0 +1,86 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+// Copyright (C) 2026 FUJITSU LIMITED
+//
+
+#ifdef OV_GPU_WITH_SYCL_RT
+
+#include "sycl_test_context.hpp"
+
+#include "intel_gpu/runtime/kernel_builder.hpp"
+#include "intel_gpu/runtime/kernel.hpp"
+
+#include <cstdint>
+#include <string>
+#include <vector>
+
+using namespace cldnn;
+using namespace sycl_tests;
+
+// Build a trivial OpenCL C kernel from source via the SYCL kernel builder.
+TEST(sycl_kernel_builder, build_from_source) {
+ auto ctx = create_sycl_test_context();
+ auto builder = ctx.sycl_test_engine->create_kernel_builder();
+ ASSERT_NE(builder, nullptr);
+
+ const std::string source = R"__cl(
+ __kernel void test_add(__global const float* a,
+ __global const float* b,
+ __global float* c) {
+ const uint i = get_global_id(0);
+ c[i] = a[i] + b[i];
+ }
+ )__cl";
+
+ std::vector<kernel::ptr> kernels;
+ ASSERT_NO_THROW(builder->build_kernels(source.data(), source.size(),
+ KernelFormat::SOURCE, "",
+ kernels));
+ ASSERT_EQ(kernels.size(), 1);
+ EXPECT_EQ(kernels[0]->get_id(), "test_add");
+}
+
+// Verify the SOURCE -> get_binary() -> NATIVE_BIN roundtrip:
+// a kernel compiled from source should produce a binary (SPIR-V) that can
+// be fed back through build_kernels with NATIVE_BIN to recreate an
+// equivalent kernel.
+TEST(sycl_kernel_builder, build_from_cached_binary) {
+ auto ctx = create_sycl_test_context();
+ auto builder = ctx.sycl_test_engine->create_kernel_builder();
+ ASSERT_NE(builder, nullptr);
+
+ const std::string source = R"__cl(
+ __kernel void test_mul(__global const float* in,
+ __global float* out) {
+ const uint i = get_global_id(0);
+ out[i] = in[i] * 2.0f;
+ }
+ )__cl";
+
+ // Step 1: Build from source
+ std::vector<kernel::ptr> source_kernels;
+ ASSERT_NO_THROW(builder->build_kernels(source.data(), source.size(),
+ KernelFormat::SOURCE, "",
+ source_kernels));
+ ASSERT_EQ(source_kernels.size(), 1);
+ EXPECT_EQ(source_kernels[0]->get_id(), "test_mul");
+
+ // Step 2: Extract binary (SPIR-V)
+ std::vector<uint8_t> binary = source_kernels[0]->get_binary();
+ ASSERT_FALSE(binary.empty());
+
+ // Step 3: Rebuild from NATIVE_BIN
+ std::vector<kernel::ptr> cached_kernels;
+ ASSERT_NO_THROW(builder->build_kernels(binary.data(), binary.size(),
+ KernelFormat::NATIVE_BIN, "",
+ cached_kernels));
+ ASSERT_EQ(cached_kernels.size(), 1);
+ EXPECT_EQ(cached_kernels[0]->get_id(), source_kernels[0]->get_id());
+
+ // Step 4: The rebuilt kernel should also produce a valid binary
+ std::vector<uint8_t> binary2 = cached_kernels[0]->get_binary();
+ EXPECT_EQ(binary, binary2);
+}
+
+#endif // OV_GPU_WITH_SYCL_RT