Skip to content

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

[GPU] Add NVIDIA GPU build support to SYCL runtime (#39034)

Akihiro-Tabuchi831e7175afe3
diff --git a/cmake/features.cmake b/cmake/features.cmake
index 01938af26ef..0e9458141cd 100644
--- a/cmake/features.cmake
+++ b/cmake/features.cmake
@@ -42,6 +42,8 @@ else()
set(ENABLE_ONEDNN_FOR_GPU_DEFAULT ON)
endif()
+ov_dependent_option (ENABLE_ONEDNN_FOR_GPU "Enable oneDNN with GPU support" ${ENABLE_ONEDNN_FOR_GPU_DEFAULT} "ENABLE_INTEL_GPU" OFF)
+
# Set default GPU runtime to OCL. COMBINED (build ZE and OCL plugins side by side) is
# opt-in only; the default is never flipped.
set(OV_GPU_DEFAULT_RT "OCL")
@@ -55,9 +57,22 @@ if (ENABLE_INTEL_GPU)
message(FATAL_ERROR "GPU_RT_TYPE=COMBINED requires BUILD_SHARED_LIBS=ON. "
"Static/monolithic builds support a single GPU runtime only.")
endif()
+ ov_option_enum (GPU_VENDOR "Target GPU vendor. Supported values: INTEL (default) and NVIDIA (SYCL runtime only)" INTEL
+ ALLOWED_VALUES INTEL NVIDIA)
+ # NVIDIA builds rely on the SYCL runtime and oneDNN, and do not support static builds yet.
+ if(GPU_VENDOR STREQUAL "NVIDIA")
+ if(NOT GPU_RT_TYPE STREQUAL "SYCL")
+ message(FATAL_ERROR "GPU_VENDOR=NVIDIA requires GPU_RT_TYPE=SYCL")
+ endif()
+ if(NOT ENABLE_ONEDNN_FOR_GPU)
+ message(FATAL_ERROR "GPU_VENDOR=NVIDIA requires ENABLE_ONEDNN_FOR_GPU=ON")
+ endif()
+ if(NOT BUILD_SHARED_LIBS)
+ message(FATAL_ERROR "GPU_VENDOR=NVIDIA does not support static builds (BUILD_SHARED_LIBS=OFF) yet")
+ endif()
+ endif()
endif()
-ov_dependent_option (ENABLE_ONEDNN_FOR_GPU "Enable oneDNN with GPU support" ${ENABLE_ONEDNN_FOR_GPU_DEFAULT} "ENABLE_INTEL_GPU" OFF)
if(APPLE)
set(ENABLE_CM_FOR_GPU_DEFAULT OFF)
else()
diff --git a/src/plugins/intel_gpu/CMakeLists.txt b/src/plugins/intel_gpu/CMakeLists.txt
index 376a5ecd6e3..0f787edb816 100644
--- a/src/plugins/intel_gpu/CMakeLists.txt
+++ b/src/plugins/intel_gpu/CMakeLists.txt
@@ -13,6 +13,11 @@ include(${CMAKE_CURRENT_LIST_DIR}/cmake/utils.cmake)
# convert white-space separated string to list
string(REPLACE " " ";" SYCL_EXTRA_FLAGS "${SYCL_EXTRA_FLAGS}")
+# Add the SYCL target flags for the GPU vendor.
+if(GPU_VENDOR STREQUAL "NVIDIA")
+ list(APPEND SYCL_EXTRA_FLAGS -fsycl-targets=nvptx64-nvidia-cuda)
+endif()
+
if(OV_COMPILER_IS_INTEL_LLVM)
# For windows we need to disable warning as error option to make FindSYCL.cmake work
if (WIN32)
@@ -127,6 +132,9 @@ if(APPLE)
add_definitions(-DCL_HPP_TARGET_OPENCL_VERSION=${INTEL_GPU_TARGET_OCL_VERSION})
endif()
+# GPU vendor the plugin is built for (not the vendor of the device found at runtime)
+add_compile_definitions(OV_GPU_VENDOR_${GPU_VENDOR})
+
set(MAIN_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
diff --git a/src/plugins/intel_gpu/src/graph/common_utils/kernel_generator_base.cpp b/src/plugins/intel_gpu/src/graph/common_utils/kernel_generator_base.cpp
index 80ee0e5385d..145251d4063 100644
--- a/src/plugins/intel_gpu/src/graph/common_utils/kernel_generator_base.cpp
+++ b/src/plugins/intel_gpu/src/graph/common_utils/kernel_generator_base.cpp
@@ -4,7 +4,7 @@
#include "kernel_generator_base.hpp"
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
# include "micro_utils.hpp"
#endif
@@ -23,7 +23,7 @@ void KernelData::save(cldnn::BinaryOutputBuffer& ob) const {
ob << make_data(&scalar.t, sizeof(cldnn::scalar_desc::Types)) << make_data(&scalar.v, sizeof(cldnn::scalar_desc::ValueT));
}
ob << params.layerID;
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
ob << micro_kernels.size();
for (const auto& microkernel : micro_kernels) {
microkernel->save(ob);
@@ -51,7 +51,7 @@ void KernelData::load(cldnn::BinaryInputBuffer& ib) {
ib >> params.layerID;
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
size_t n_microkernels = 0;
ib >> n_microkernels;
micro_kernels.clear();
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 76886afe77a..92c8259b766 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
@@ -44,7 +44,7 @@
#include <malloc.h>
#endif
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
#ifndef NOMINMAX
# define NOMINMAX
#endif
@@ -355,7 +355,7 @@ void kernels_cache::build_batch(const batch_program& batch, compiled_kernels& co
dump_file << "\n*/\n";
}
if (batch.has_microkernels) {
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
OPENVINO_ASSERT(batch.kernels_counter == 1 && kernels.size() == 1);
std::vector<uint8_t> binary = kernels[0]->get_binary();
kernels.clear();
@@ -367,9 +367,9 @@ void kernels_cache::build_batch(const batch_program& batch, compiled_kernels& co
GPU_DEBUG_LOG << "[GPU] Microkernels were fused, but their registers could not be checked against the host kernel payload" << std::endl;
}
_builder->build_kernels(binary.data(), binary.size(), KernelFormat::NATIVE_BIN, "", kernels);
-#else // ENABLE_ONEDNN_FOR_GPU
+#else // OV_GPU_WITH_ONEDNN_MICROKERNELS
OPENVINO_THROW("[GPU] Can't compile kernel w/ microkernels as onednn is not available");
-#endif // ENABLE_ONEDNN_FOR_GPU
+#endif // OV_GPU_WITH_ONEDNN_MICROKERNELS
}
if (is_cache_enabled()) {
// If kernels caching is enabled, then we save compiled bucket to binary file with name ${code_hash_value}.cl_cache
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gather_matmul.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gather_matmul.cpp
index 9eb74a7b099..126860dfd54 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gather_matmul.cpp
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gather_matmul.cpp
@@ -19,7 +19,7 @@
#include "gather_matmul_inst.h"
#include "ocl_v2/utils/fused_ops_jitter.hpp"
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
# include <algorithm>
# include <cstdlib>
# include <memory>
@@ -32,7 +32,7 @@
namespace ov::intel_gpu::ocl {
namespace {
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
inline bool is_prefill_stage(const RuntimeParams& params) {
const auto& input_shape = params.input_layouts[0].get_partial_shape();
const auto n_tokens = input_shape[1];
@@ -104,7 +104,7 @@ enum GatherMatmulInternalBufferIdx {
class GatherMatmulOCLImpl : public PrimitiveImplOCL {
public:
DECLARE_OBJECT_TYPE_SERIALIZATION(ov::intel_gpu::ocl::GatherMatmulOCLImpl)
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
static constexpr bool prefill = true;
// Per-token stages
@@ -122,7 +122,7 @@ public:
#endif
explicit GatherMatmulOCLImpl() : PrimitiveImplOCL(GatherMatmulImpl::get_type_info_static()) {
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
// GATHER_MATMUL_USE_ONEDNN_PREFILL gates the dnnl-grouped large-prefill path (default off).
_use_onednn_grouped = std::getenv("GATHER_MATMUL_USE_ONEDNN_PREFILL") != nullptr;
#endif
@@ -131,7 +131,7 @@ public:
auto params = impl_param;
GPU_DEBUG_TRACE_DETAIL << "GatherMatmul create stages for dynamic = " << params.is_dynamic() << "\n";
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
// Non-u4/i4 weights have no functional OCL path; force onednn-grouped.
const bool need_onednn_for_weights = weights_need_onednn_grouped(params);
if (need_onednn_for_weights) {
@@ -191,7 +191,7 @@ public:
// 7: expert_offsets — cumulative exclusive ends per expert.
descs.emplace_back(n_all_experts, ov::element::i32);
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
// OR: env-var doesn't survive clone(), but execute() dispatches on dtype directly.
if (_use_onednn_grouped || weights_need_onednn_grouped(params)) {
// 8: packed dnnl::matmul output [total_tokens, N], unfused N.
@@ -225,7 +225,7 @@ public:
}
[[nodiscard]] event::ptr execute(const std::vector<event::ptr>& events, primitive_inst& instance) override {
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
const auto& params = *instance.get_impl_params();
bool is_prefill = is_prefill_stage(params);
update_rt_params(instance);
@@ -268,7 +268,7 @@ public:
}
private:
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
// One entry per total_tokens; carries the wrappers we need at execute() time.
struct OnednnGroupedKernel {
dnnl::matmul::primitive_desc pd;
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gather_matmul_gen_micro.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gather_matmul_gen_micro.cpp
index 33827e90439..b47ca926d7c 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gather_matmul_gen_micro.cpp
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gather_matmul_gen_micro.cpp
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
//
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
// clang-format off
#include "gather_matmul_gen_micro.hpp"
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gather_matmul_gen_micro.hpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gather_matmul_gen_micro.hpp
index 97942823829..1e483baf17f 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gather_matmul_gen_micro.hpp
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gather_matmul_gen_micro.hpp
@@ -23,7 +23,7 @@ struct GatherMatmulRuntimeParams : public ImplRuntimeParams {
int32_t n_tokens = 0;
};
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
# include "micro_utils.hpp"
struct gathermatmul_config {
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gathermatmul_batched_gemm_gen.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gathermatmul_batched_gemm_gen.cpp
index f44edb3d4dd..fa9fc3ef505 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gathermatmul_batched_gemm_gen.cpp
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gathermatmul_batched_gemm_gen.cpp
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
//
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
// clang-format off
#include "gathermatmul_batched_gemm_gen.hpp"
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gathermatmul_batched_gemm_gen.hpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gathermatmul_batched_gemm_gen.hpp
index cd8667e4c5f..928d4f2e4c0 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gathermatmul_batched_gemm_gen.hpp
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gathermatmul_batched_gemm_gen.hpp
@@ -13,7 +13,7 @@
namespace ov::intel_gpu::ocl {
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
// Prefill batched GEMM: same gemmstone micro-kernel as GatherMatmulMicroGenerator with grouped dispatch.
class GatherMatmulBatchedGemmGenerator : public KernelGenerator {
public:
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/moe_3gemm_gen_micro.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/moe_3gemm_gen_micro.cpp
index 5ef4d18f4a9..606f483591d 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/moe_3gemm_gen_micro.cpp
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/moe_3gemm_gen_micro.cpp
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
//
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
// clang-format off
// Put this file at first to avoid incorrect header files includes order.
// For example, intel_gpu/runtime/utils.hpp will causes compiling error in hash<dnnl::impl::primitive_hashing::key_t>
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/moe_3gemm_gen_micro.hpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/moe_3gemm_gen_micro.hpp
index d5e2915562a..a6c951a3519 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/moe_3gemm_gen_micro.hpp
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/moe_3gemm_gen_micro.hpp
@@ -17,7 +17,7 @@
#include "ocl_v2/utils/jitter.hpp"
using namespace cldnn; // TODO: Remove once namespaces are aligned
namespace ov::intel_gpu::ocl {
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
# include "micro_utils.hpp"
class MoE3GemmMicroGenerator : public MoEGemmOptGeneratorBase {
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/moe_3gemm_swiglu_opt.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/moe_3gemm_swiglu_opt.cpp
index f0b3bcff3e3..5c9523357e0 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/moe_3gemm_swiglu_opt.cpp
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/moe_3gemm_swiglu_opt.cpp
@@ -18,7 +18,7 @@ using ov::intel_gpu::ocl::moe::ResidentExpertWeightProvider;
#define DEBUG_MOE_LOG 0
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
# include <algorithm>
# include <array>
# include <chrono>
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/paged_attention_opt.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/paged_attention_opt.cpp
index 04bc1cbe34b..66c4db52b8f 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/paged_attention_opt.cpp
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/paged_attention_opt.cpp
@@ -1595,7 +1595,7 @@ public:
Stage::Ptr kv_cache_rotate = make_stage<KVCacheRotateGenerator>();
Stage::Ptr pa_scores_calc = make_stage<PagedAttentionGeneratorScoresCalculation>();
Stage::Ptr pa_diversity_calc = make_stage<AdaptiveRKVDiversityGenerator>();
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
Stage::Ptr pa_sdpa_micro = make_stage<SDPAMicroGenerator>(true);
Stage::Ptr pa_sdpa_micro_mixed = make_stage<SDPAMicroGenerator>(false);
Stage::Ptr pa_tt_bounds = make_stage<PagedAttentionGeneratorTTBounds>();
@@ -1608,7 +1608,7 @@ public:
const bool has_rotated_blocks = desc->has_rotated_blocks;
const bool has_adaptive_rkv = desc->has_adaptive_rkv;
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
const bool use_micro_sdpa = supports_micro_sdpa(params);
if (use_micro_sdpa) {
add_stage(pa_sdpa_micro, params);
@@ -1646,7 +1646,7 @@ public:
}
}
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
bool valid_micro_stage(const PagedAttentionStage& stage) const {
if (stage == PagedAttentionStage::PREFILL)
return !pa_sdpa_micro->kd.micro_kernels.empty();
@@ -1787,7 +1787,7 @@ public:
rt_params->paged_attention_snap_kv_tokens = 0;
}
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
rt_params->use_micro_sdpa = can_use_micro_sdpa_for(params, rt_params->stage);
#else
rt_params->use_micro_sdpa = false;
@@ -1851,7 +1851,7 @@ public:
}
if (rt_params->stage == PagedAttentionStage::PREFILL) {
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
if (rt_params->use_micro_sdpa) {
if (pa_micro_uses_tt_bounds(*desc)) {
res_event = {execute_stage(res_event, instance, pa_tt_bounds)};
@@ -1870,7 +1870,7 @@ public:
instance,
multi_tokens_mode ? get_gqa_multi_token_stage(rt_params->gqa_multi_tokens_kernel) : pa_gqa_single_token)};
} else {
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
if (multi_tokens_mode && rt_params->use_micro_sdpa) {
if (pa_micro_uses_tt_bounds(*desc)) {
res_event = {execute_stage(res_event, instance, pa_tt_bounds)};
@@ -1988,7 +1988,7 @@ public:
num_of_partitions = ceil_div(max_context_len, partition_size);
}
bool can_use_micro_sdpa = false;
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
// Keep internal buffer layout decision aligned with execute() path.
// If runtime params are already prepared, they are the source of truth.
if (rt_params != nullptr && rt_params->num_of_partitions != 0) {
@@ -2080,7 +2080,7 @@ public:
internal_buffers.emplace_back(total_tokens, softmax_accumulator_type, lockable, not_shareable); // 9
}
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
if (can_use_micro_sdpa) {
const auto wg_tile_q = 8; // This is set as the minimum size of query block for sharing between sdpa_micro_prefill and mixed.
const auto target_seq_len = std::max(paged_attention_aligned_seq_len, static_cast<int64_t>(1));
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_gen_micro.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_gen_micro.cpp
index eb773295011..c60d39d3c53 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_gen_micro.cpp
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_gen_micro.cpp
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
//
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
// clang-format off
// Put this file at first to avoid incorrect header files includes order.
// For example, intel_gpu/runtime/utils.hpp will causes compiling error in hash<dnnl::impl::primitive_hashing::key_t>
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_gen_micro.hpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_gen_micro.hpp
index 16b449f96e4..0bd4272f97d 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_gen_micro.hpp
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_gen_micro.hpp
@@ -19,7 +19,7 @@
using namespace cldnn; // TODO: Remove once namespaces are aligned
namespace ov::intel_gpu::ocl {
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
class SDPAMicroGenerator : public SDPABase {
public:
explicit SDPAMicroGenerator(bool prefill, bool gqa_single_token = false)
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_opt.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_opt.cpp
index d82b9499cf6..ad3234a1559 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_opt.cpp
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_opt.cpp
@@ -62,7 +62,7 @@ public:
Stage::Ptr indirect_finalization = make_stage<SDPAOptGeneratorFinalization>(indirect);
Stage::Ptr regular_finalization = make_stage<SDPAOptGeneratorFinalization>(!indirect);
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
Stage::Ptr regular_micro_single_token = make_stage<SDPAMicroGenerator>(!prefill);
Stage::Ptr regular_micro_multi_tokens = make_stage<SDPAMicroGenerator>(prefill);
#endif
@@ -79,7 +79,7 @@ public:
add_stage(indirect_multi_tokens, params);
add_stage(regular_finalization, params);
add_stage(indirect_finalization, params);
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
if (SDPAOpt::supports_micro_sdpa(params)) {
GPU_DEBUG_TRACE_DETAIL << "add stage for micro_sdpa dynamic ...\n";
add_stage(regular_micro_multi_tokens, params);
@@ -94,7 +94,7 @@ public:
if (is_indirect) {
GPU_DEBUG_TRACE_DETAIL << "add stage for indirect non-dynamic with prefill_stage \n";
add_stage(indirect_multi_tokens, params);
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
} else if (SDPAOpt::supports_micro_sdpa(params)) {
GPU_DEBUG_TRACE_DETAIL << "add stage for micro_sdpa non-dynamic with prefill_stage \n";
add_stage(regular_micro_multi_tokens, params);
@@ -112,7 +112,7 @@ public:
}
} else {
GPU_DEBUG_TRACE_DETAIL << "add stage single_tokens \n";
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
const auto& gfx_ver = params.get_program().get_engine().get_device_info().gfx_ver;
bool is_ARL_H = (gfx_ver.major == 12 && gfx_ver.minor == 74);
bool can_use_micro_sdpa = SDPAOpt::supports_micro_sdpa(params) && !is_ARL_H && !is_indirect;
@@ -139,7 +139,7 @@ public:
kernel_dump_info.clear_entries();
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
const auto k_dt = new_params.input_layouts[1].data_type;
const bool is_kv_compressed = data_type_traits::is_i8_u8(k_dt) || data_type_traits::is_i4_u4(k_dt);
const auto kv_cache_dt = new_params.get_program().get_config().get_kv_cache_precision();
@@ -159,7 +159,7 @@ public:
GPU_DEBUG_TRACE_DETAIL << "execute multi_tokens with indirect = " << is_indirect << "\n";
return execute_stage(events, instance, is_indirect ? indirect_multi_tokens : regular_multi_tokens);
}
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
if (has_stage(regular_micro_single_token) && !is_indirect) {
return execute_stage(events, instance, regular_micro_single_token);
}
@@ -199,7 +199,7 @@ public:
};
bool SDPAOpt::has_bf16_compressed_kv_zero_point(const kernel_impl_params& params) {
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
const auto desc = params.typed_desc<scaled_dot_product_attention>();
if (!desc->is_kv_compressed || desc->quantization_attributes.quantization_type != ov::op::internal::DynamicQuantize::QuantizationType::Asymmetric ||
desc->quantization_attributes.output_storage_type != ov::op::internal::DynamicQuantize::OutputStorageType::Planar) {
@@ -226,7 +226,7 @@ bool SDPAOpt::has_bf16_compressed_kv_zero_point(const kernel_impl_params& params
}
bool SDPAOpt::supports_micro_sdpa(const RuntimeParams& params) {
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
// Knob (OV_GPU_ENABLE_SDPA_MICRO=0): force the SDPA backend onto the OCL sdpa_opt kernel
// instead of the oneDNN-derived micro kernel, for accuracy A/B without rebuilding.
if (!params.get_program().get_config().get_enable_sdpa_micro()) {
diff --git a/src/plugins/intel_gpu/src/graph/program.cpp b/src/plugins/intel_gpu/src/graph/program.cpp
index 4c63d7ab3ae..876d83de84e 100644
--- a/src/plugins/intel_gpu/src/graph/program.cpp
+++ b/src/plugins/intel_gpu/src/graph/program.cpp
@@ -1759,6 +1759,12 @@ void program::set_layout_optimizer_attributes(layout_optimizer& lo) {
lo.set_optimization_attribute(layout_optimizer::optimization_attributes_type::bs_fs_yx_bsv16_fsv16_network, 1);
#ifdef ENABLE_ONEDNN_FOR_GPU
+#if defined(OV_GPU_VENDOR_NVIDIA)
+ // oneDNN is the main backend on NVIDIA GPUs, so don't check enable_onednn_for_tests
+ if (get_config().get_queue_type() == QueueTypes::in_order) {
+ lo.add_all_onednn_impls_optimization_attribute();
+ }
+#else
bool enable_onednn_for_tests = get_config().get_optimize_data() || is_internal_program();
auto& engine = get_engine();
if (engine.get_device_info().vendor_id == INTEL_VENDOR_ID &&
@@ -1773,6 +1779,7 @@ void program::set_layout_optimizer_attributes(layout_optimizer& lo) {
}
}
}
+#endif // OV_GPU_VENDOR_NVIDIA
if (_onednn_impls.has_value()) {
lo.clear_onednn_impls_optimization_attribute();
diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernel_selector_common.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernel_selector_common.cpp
index e4c143e2fd9..bab5cb010ac 100644
--- a/src/plugins/intel_gpu/src/kernel_selector/kernel_selector_common.cpp
+++ b/src/plugins/intel_gpu/src/kernel_selector/kernel_selector_common.cpp
@@ -7,7 +7,7 @@
#include <sstream>
#include <string>
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
#include "micro_utils.hpp"
#endif
@@ -617,7 +617,7 @@ void clKernelData::save(cldnn::BinaryOutputBuffer& ob) const {
}
ob << params.layerID;
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
ob << micro_kernels.size();
for (const auto& microkernel : micro_kernels) {
microkernel->save(ob);
@@ -651,7 +651,7 @@ void clKernelData::load(cldnn::BinaryInputBuffer& ib) {
ib >> params.layerID;
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
size_t n_microkernels;
ib >> n_microkernels;
micro_kernels.clear();
diff --git a/src/plugins/intel_gpu/src/kernel_selector/micro_utils.hpp b/src/plugins/intel_gpu/src/kernel_selector/micro_utils.hpp
index 813c5b05cb8..e7300642119 100644
--- a/src/plugins/intel_gpu/src/kernel_selector/micro_utils.hpp
+++ b/src/plugins/intel_gpu/src/kernel_selector/micro_utils.hpp
@@ -4,7 +4,7 @@
#pragma once
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_WITH_ONEDNN_MICROKERNELS
#include "intel_gpu/graph/serialization/binary_buffer.hpp"
#include "intel_gpu/graph/serialization/string_serializer.hpp"
@@ -123,4 +123,4 @@ typedef uchar f4_e2m1;
#undef UNUSED
-#endif // ENABLE_ONEDNN_FOR_GPU
+#endif // OV_GPU_WITH_ONEDNN_MICROKERNELS
diff --git a/src/plugins/intel_gpu/src/runtime/CMakeLists.txt b/src/plugins/intel_gpu/src/runtime/CMakeLists.txt
index 238f2bdcb06..4fb33cbe5fb 100644
--- a/src/plugins/intel_gpu/src/runtime/CMakeLists.txt
+++ b/src/plugins/intel_gpu/src/runtime/CMakeLists.txt
@@ -20,6 +20,9 @@ set(LIBRARY_SOURCES_MAIN ${GPU_RUNTIME_MAIN_SOURCES})
set(LIBRARY_SOURCES_OCL ${GPU_RUNTIME_OCL_SOURCES})
set(LIBRARY_SOURCES_ZE ${GPU_RUNTIME_ZE_SOURCES} ${GPU_RUNTIME_ZE_COMPUTE_RUNTIME_HEADERS})
set(LIBRARY_SOURCES_SYCL ${GPU_RUNTIME_SYCL_SOURCES})
+if(GPU_VENDOR STREQUAL "INTEL")
+ list(APPEND LIBRARY_SOURCES_SYCL ${GPU_RUNTIME_SYCL_INTEL_SOURCES})
+endif()
set(OCL_SYCL_SOURCES ${GPU_RUNTIME_OCL_SYCL_SOURCES})
# ocl/sycl_*.{h,hpp,cpp} require the SYCL compiler, so they are only part of the
@@ -71,7 +74,7 @@ if(OV_GPU_WITH_SYCL)
target_compile_definitions(${TARGET_NAME} PUBLIC OV_GPU_WITH_SYCL)
endif()
-if(GPU_RT_TYPE STREQUAL "SYCL")
+if(GPU_RT_TYPE STREQUAL "SYCL" AND GPU_VENDOR STREQUAL "INTEL")
find_path(OCLOC_API_INCLUDE_DIR NAMES ocloc_api.h REQUIRED)
target_include_directories(${TARGET_NAME} PRIVATE ${OCLOC_API_INCLUDE_DIR})
endif()
diff --git a/src/plugins/intel_gpu/src/runtime/execution_config.cpp b/src/plugins/intel_gpu/src/runtime/execution_config.cpp
index 387ca2e23ec..09e6a629358 100644
--- a/src/plugins/intel_gpu/src/runtime/execution_config.cpp
+++ b/src/plugins/intel_gpu/src/runtime/execution_config.cpp
@@ -371,8 +371,15 @@ void ExecutionConfig::finalize_impl(const IRemoteContext* context) {
m_enable_lp_transformations = info.supports_imad || info.supports_immad;
}
#ifdef ENABLE_ONEDNN_FOR_GPU
- if (!is_set_by_user(ov::intel_gpu::use_onednn) && info.supports_immad) {
+ if (!is_set_by_user(ov::intel_gpu::use_onednn)) {
+#if defined(OV_GPU_VENDOR_NVIDIA)
+ // oneDNN is the main backend on NVIDIA GPUs
m_use_onednn = true;
+#else
+ if (info.supports_immad) {
+ m_use_onednn = true;
+ }
+#endif
}
if (m_use_onednn) {
m_queue_type = QueueTypes::in_order;
diff --git a/src/plugins/intel_gpu/src/runtime/sources.cmake b/src/plugins/intel_gpu/src/runtime/sources.cmake
index 08d541e350c..79b672f771f 100644
--- a/src/plugins/intel_gpu/src/runtime/sources.cmake
+++ b/src/plugins/intel_gpu/src/runtime/sources.cmake
@@ -135,6 +135,9 @@ set(GPU_RUNTIME_SYCL_SOURCES
${CMAKE_CURRENT_LIST_DIR}/sycl/sycl_user_event.cpp
${CMAKE_CURRENT_LIST_DIR}/sycl/sycl_user_event.hpp
${CMAKE_CURRENT_LIST_DIR}/sycl/sycl_wrapper.hpp
+)
+
+set(GPU_RUNTIME_SYCL_INTEL_SOURCES
${CMAKE_CURRENT_LIST_DIR}/sycl/intel/sycl_kernel_builder.cpp
${CMAKE_CURRENT_LIST_DIR}/sycl/intel/sycl_kernel_builder.hpp
)
diff --git a/src/plugins/intel_gpu/src/runtime/sycl/sycl_device.cpp b/src/plugins/intel_gpu/src/runtime/sycl/sycl_device.cpp
index 8b29c5ce1a0..a23a0b80b2d 100644
--- a/src/plugins/intel_gpu/src/runtime/sycl/sycl_device.cpp
+++ b/src/plugins/intel_gpu/src/runtime/sycl/sycl_device.cpp
@@ -4,7 +4,7 @@
// Copyright (C) 2026 FUJITSU LIMITED
//
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#if defined(ENABLE_ONEDNN_FOR_GPU) && defined(OV_GPU_VENDOR_INTEL)
#ifndef NOMINMAX
# define NOMINMAX
#endif
@@ -56,7 +56,7 @@ namespace sycl {
namespace {
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#if defined(ENABLE_ONEDNN_FOR_GPU) && defined(OV_GPU_VENDOR_INTEL)
gpu_arch convert_ngen_arch(ngen::HW gpu_arch) {
switch (gpu_arch) {
case ngen::HW::Gen9: return gpu_arch::gen9;
@@ -294,7 +294,7 @@ device_info init_device_info(const ::sycl::device& device, const ::sycl::context
info.num_ccs = 1;
-#ifdef ENABLE_ONEDNN_FOR_GPU
+#if defined(ENABLE_ONEDNN_FOR_GPU) && defined(OV_GPU_VENDOR_INTEL)
using namespace dnnl::impl::gpu::intel::jit;
ngen::Product product = generator_t<ngen::HW::Unknown>::detectHWInfo(context, device);
info.arch = convert_ngen_arch(ngen::getCore(product.family));
diff --git a/src/plugins/intel_gpu/src/runtime/sycl/sycl_device_detector.cpp b/src/plugins/intel_gpu/src/runtime/sycl/sycl_device_detector.cpp
index 528e0116f66..4ba4740425f 100644
--- a/src/plugins/intel_gpu/src/runtime/sycl/sycl_device_detector.cpp
+++ b/src/plugins/intel_gpu/src/runtime/sycl/sycl_device_detector.cpp
@@ -27,6 +27,17 @@ bool does_device_match_config(const ::sycl::device& device) {
return false;
}
+#if defined(OV_GPU_VENDOR_NVIDIA)
+ // The plugin is built for NVIDIA GPUs through the CUDA backend only, so skip GPUs of other vendors
+ // (e.g. an Intel iGPU next to an NVIDIA dGPU) and NVIDIA GPUs exposed through other backends
+ // (e.g. OpenCL), which cannot run the CUDA device images of this build: otherwise they would be
+ // listed and could even become the default "GPU" device
+ if (device.get_info<::sycl::info::device::vendor_id>() != cldnn::NVIDIA_VENDOR_ID ||
+ device.get_backend() != ::sycl::backend::ext_oneapi_cuda) {
+ return false;
+ }
+#endif
+
return true;
}
} // namespace
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 33dd2a8d135..8573d8e2bc2 100644
--- a/src/plugins/intel_gpu/src/runtime/sycl/sycl_engine.cpp
+++ b/src/plugins/intel_gpu/src/runtime/sycl/sycl_engine.cpp
@@ -11,7 +11,9 @@
#include "sycl_memory.hpp"
#include "sycl_stream.hpp"
#include "sycl_engine_factory.hpp"
+#ifdef OV_GPU_VENDOR_INTEL
#include "intel/sycl_kernel_builder.hpp"
+#endif
#include <string>
#include <vector>
#include <memory>
@@ -57,7 +59,11 @@ backend_types sycl_engine::backend_type() const {
#ifdef ENABLE_ONEDNN_FOR_GPU
void sycl_engine::create_onednn_engine(const ExecutionConfig& config) {
const std::lock_guard<std::mutex> lock(onednn_mutex);
+#if defined(OV_GPU_VENDOR_INTEL)
OPENVINO_ASSERT(_device->get_info().vendor_id == INTEL_VENDOR_ID, "[GPU] OneDNN engine can be used for Intel GPUs only");
+#elif defined(OV_GPU_VENDOR_NVIDIA)
+ OPENVINO_ASSERT(_device->get_info().vendor_id == NVIDIA_VENDOR_ID, "[GPU] OneDNN engine can be used for NVIDIA GPUs only");
+#endif
if (!_onednn_engine) {
auto casted = std::dynamic_pointer_cast<sycl_device>(_device);
OPENVINO_ASSERT(casted, "[GPU] Invalid device type stored in sycl_engine");
@@ -248,9 +254,12 @@ void* sycl_engine::get_user_context(runtime_types rt_type) const {
std::shared_ptr<kernel_builder> sycl_engine::create_kernel_builder() const {
auto& sycl_device = downcast<sycl::sycl_device>(*_device);
switch (sycl_device.get_device().get_backend()) {
+#ifdef OV_GPU_VENDOR_INTEL
case ::sycl::backend::opencl:
case ::sycl::backend::ext_oneapi_level_zero:
return std::make_shared<sycl::intel::sycl_kernel_builder>(sycl_device);
+#endif
+ // OpenCL kernels are not supported on NVIDIA GPUs yet.
default:
OPENVINO_THROW("[GPU] No kernel builder available for backend ",
sycl_device.get_device().get_backend());
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 72b90930136..2c708fbd9f0 100644
--- a/src/plugins/intel_gpu/src/runtime/sycl/sycl_stream.cpp
+++ b/src/plugins/intel_gpu/src/runtime/sycl/sycl_stream.cpp
@@ -57,7 +57,11 @@ sycl_stream::sycl_stream(const sycl_engine &engine, const ExecutionConfig& confi
#ifdef ENABLE_ONEDNN_FOR_GPU
dnnl::stream& sycl_stream::get_onednn_stream() {
OPENVINO_ASSERT(m_queue_type == QueueTypes::in_order, "[GPU] Can't create onednn stream handle as onednn doesn't support out-of-order queue");
+#if defined(OV_GPU_VENDOR_INTEL)
OPENVINO_ASSERT(_engine.get_device_info().vendor_id == INTEL_VENDOR_ID, "[GPU] Can't create onednn stream handle as for non-Intel devices");
+#elif defined(OV_GPU_VENDOR_NVIDIA)
+ OPENVINO_ASSERT(_engine.get_device_info().vendor_id == NVIDIA_VENDOR_ID, "[GPU] Can't create onednn stream handle as for non-NVIDIA devices");
+#endif
if (!_onednn_stream) {
_onednn_stream = std::make_shared<dnnl::stream>(dnnl::sycl_interop::make_stream(_engine.get_onednn_engine(), _command_queue));
}
diff --git a/src/plugins/intel_gpu/tests/unit/test_utils/test_utils.cpp b/src/plugins/intel_gpu/tests/unit/test_utils/test_utils.cpp
index 3f76422d0c1..1f90971cbf1 100644
--- a/src/plugins/intel_gpu/tests/unit/test_utils/test_utils.cpp
+++ b/src/plugins/intel_gpu/tests/unit/test_utils/test_utils.cpp
@@ -294,9 +294,14 @@ cldnn::ExecutionConfig get_test_default_config(const cldnn::engine& engine,
ExecutionConfig config(values);
// Onednn engine currently does NOT support out_of_order
+#ifdef OV_GPU_VENDOR_NVIDIA
+ // oneDNN is the main backend on NVIDIA GPUs
+ config.set_property(ov::intel_gpu::queue_type(QueueTypes::in_order));
+#else
if (engine.get_device_info().supports_immad) {
config.set_property(ov::intel_gpu::queue_type(QueueTypes::in_order));
}
+#endif
if (engine.get_enable_large_allocations()) {
config.set_property(ov::intel_gpu::hint::enable_large_allocations(true));
@@ -309,8 +314,13 @@ std::shared_ptr<cldnn::engine> create_test_engine() {
auto ret = cldnn::engine::create(
cldnn::get_default_engine_type(), cldnn::get_default_runtime_type());
#ifdef ENABLE_ONEDNN_FOR_GPU
+#ifdef OV_GPU_VENDOR_NVIDIA
+ // oneDNN is the main backend on NVIDIA GPUs
+ ret->create_onednn_engine({});
+#else
if (ret->get_device_info().supports_immad)
ret->create_onednn_engine({});
+#endif
#endif
return ret;
}
diff --git a/src/plugins/intel_gpu/thirdparty/CMakeLists.txt b/src/plugins/intel_gpu/thirdparty/CMakeLists.txt
index fb0df5b5bf5..e0efddb7b47 100644
--- a/src/plugins/intel_gpu/thirdparty/CMakeLists.txt
+++ b/src/plugins/intel_gpu/thirdparty/CMakeLists.txt
@@ -69,12 +69,18 @@ if(ENABLE_ONEDNN_FOR_GPU)
endif()
# pass common variables
- foreach(cmake_var IN ITEMS CMAKE_SYSTEM_NAME CMAKE_SYSTEM_VERSION
- CMAKE_SYSTEM_PROCESSOR CMAKE_TOOLCHAIN_FILE
- CMAKE_SYSROOT
- CMAKE_VERBOSE_MAKEFILE CMAKE_GENERATOR
- CMAKE_CXX_COMPILER CMAKE_C_COMPILER
- CMAKE_CXX_COMPILER_LAUNCHER CMAKE_C_COMPILER_LAUNCHER)
+ # CMAKE_TOOLCHAIN_FILE is always passed: a toolchain such as conan_toolchain.cmake carries
+ # Conan's prefix paths and CMakeDeps lookups (e.g. OpenCL) that the oneDNN build needs
+ set(cmake_vars_to_pass CMAKE_TOOLCHAIN_FILE CMAKE_SYSROOT
+ CMAKE_VERBOSE_MAKEFILE CMAKE_GENERATOR
+ CMAKE_CXX_COMPILER CMAKE_C_COMPILER
+ CMAKE_CXX_COMPILER_LAUNCHER CMAKE_C_COMPILER_LAUNCHER)
+ # pass the target system variables only when cross-compiling:
+ # passing CMAKE_SYSTEM_NAME forces CMAKE_CROSSCOMPILING=TRUE in the oneDNN build
+ if(CMAKE_CROSSCOMPILING)
+ list(APPEND cmake_vars_to_pass CMAKE_SYSTEM_NAME CMAKE_SYSTEM_VERSION CMAKE_SYSTEM_PROCESSOR)
+ endif()
+ foreach(cmake_var IN LISTS cmake_vars_to_pass)
if(${cmake_var})
list(APPEND cmake_extra_args "-D${cmake_var}=${${cmake_var}}")
endif()
@@ -139,6 +145,20 @@ if(ENABLE_ONEDNN_FOR_GPU)
endif()
endif()
+ # set target GPU
+ set(GPU_DEP_LIBS "")
+ if(GPU_VENDOR STREQUAL "NVIDIA")
+ # Link dependencies of the static oneDNN library: resolve them with oneDNN's own Find
+ # modules, so that they match what the oneDNN build itself links against
+ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/onednn_gpu/cmake)
+ find_package(cuBLAS REQUIRED)
+ find_package(cublasLt REQUIRED)
+ find_package(cuDNN REQUIRED)
+ set(GPU_DEP_LIBS cuBLAS::cuBLAS cublasLt::cublasLt cuDNN::cuDNN)
+ # onednn_gpu_tgt is consumed from sibling directories, so the imported targets must be global
+ set_target_properties(${GPU_DEP_LIBS} PROPERTIES IMPORTED_GLOBAL TRUE)
+ endif()
+
set(onednn_gpu_lib "${CMAKE_STATIC_LIBRARY_PREFIX}${onednn_lib_name}${CMAKE_STATIC_LIBRARY_SUFFIX}")
# This twin's own library: everything below builds, links and installs THIS path, so it
# must stay local - sharing it across twins would link one runtime against the other's.
@@ -178,8 +198,10 @@ if(ENABLE_ONEDNN_FOR_GPU)
"-DDNNL_TARGET_ARCH=${ONEDNN_TARGET_ARCH}"
"-DDNNL_CPU_RUNTIME=NONE"
"-DDNNL_GPU_RUNTIME=${ONEDNN_GPU_RT}"
+ "-DDNNL_GPU_VENDOR=${GPU_VENDOR}"
"-DDNNL_LIBRARY_NAME=${onednn_lib_name}"
"-DCMAKE_INSTALL_PREFIX=${ONEDNN_INSTALL_DIR}"
+ "-DCMAKE_INSTALL_LIBDIR=lib"
"-DDNNL_ENABLE_CONCURRENT_EXEC=ON"
"-DDNNL_ENABLE_PRIMITIVE_CACHE=ON"
"-DDNNL_ENABLE_WORKLOAD=INFERENCE"
@@ -236,9 +258,14 @@ if(ENABLE_ONEDNN_FOR_GPU)
list(APPEND LIB_DEFINITIONS NGEN_LINK_OPENCL)
endif()
+ # gemmstone microkernels are built into oneDNN for Intel GPUs only
+ if(GPU_VENDOR STREQUAL "INTEL")
+ list(APPEND LIB_DEFINITIONS OV_GPU_WITH_ONEDNN_MICROKERNELS)
+ endif()
+
add_library(onednn_gpu_tgt${SUFFIX} INTERFACE)
set_target_properties(onednn_gpu_tgt${SUFFIX} PROPERTIES
- INTERFACE_LINK_LIBRARIES $<BUILD_INTERFACE:${onednn_lib_path}>
+ INTERFACE_LINK_LIBRARIES "$<BUILD_INTERFACE:${onednn_lib_path};$<LINK_ONLY:${GPU_DEP_LIBS}>>"
INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${LIB_INCLUDE_DIRS}>"
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${LIB_INCLUDE_DIRS}>"
INTERFACE_COMPILE_DEFINITIONS "${LIB_DEFINITIONS}"