Skip to content

Commit

Permalink
[Build] Move level zero submodule from npu to common (openvinotoolkit…
Browse files Browse the repository at this point in the history
…#26626)

### Details:
- L0 submodule can be reused between GPU and NPU plugins, so moved to
common thirdparty dependencies
  • Loading branch information
vladimir-paramuzov authored Sep 23, 2024
1 parent c805873 commit e934d83
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@
[submodule "src/plugins/intel_cpu/thirdparty/mlas"]
path = src/plugins/intel_cpu/thirdparty/mlas
url = https://github.com/openvinotoolkit/mlas.git
[submodule "src/plugins/intel_npu/thirdparty/level-zero"]
path = src/plugins/intel_npu/thirdparty/level-zero
[submodule "thirdparty/level_zero/level-zero"]
path = thirdparty/level_zero/level-zero
url = https://github.com/oneapi-src/level-zero.git
[submodule "src/plugins/intel_npu/thirdparty/level-zero-ext"]
path = src/plugins/intel_npu/thirdparty/level-zero-ext
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/intel_npu/src/plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ target_include_directories(${TARGET_NAME}
)
target_include_directories(${TARGET_NAME}
SYSTEM PRIVATE
${NPU_PLUGIN_SOURCE_DIR}/thirdparty/level-zero/include
${NPU_PLUGIN_SOURCE_DIR}/thirdparty/level-zero-ext
$<TARGET_PROPERTY:LevelZero::LevelZero,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:LevelZero::NPUExt,INTERFACE_INCLUDE_DIRECTORIES>
)

if(ENABLE_AVX2)
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/intel_npu/src/utils/src/zero/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ ov_add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME})
target_include_directories(
${TARGET_NAME}
PUBLIC
$<BUILD_INTERFACE:${NPU_PLUGIN_SOURCE_DIR}/thirdparty/level-zero/include>
$<BUILD_INTERFACE:${NPU_PLUGIN_SOURCE_DIR}/thirdparty/level-zero-ext>
$<TARGET_PROPERTY:LevelZero::LevelZero,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:LevelZero::NPUExt,INTERFACE_INCLUDE_DIRECTORIES>
$<BUILD_INTERFACE:${NPU_UTILS_SOURCE_DIR}/include>)

target_link_libraries(
Expand Down
31 changes: 4 additions & 27 deletions src/plugins/intel_npu/thirdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,13 @@
# SPDX-License-Identifier: Apache-2.0
#

set(BUILD_SHARED_LIBS OFF)

#
# zeroApi
#

if(ENABLE_ZEROAPI_BACKEND)
# We have to avoid linking against loader with debug postfix due it's a part of driver
# and the name will be the same for release and debug configurations
set(CMAKE_DEBUG_POSTFIX "")

# Skip warnings as errors for thirdparty
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
ov_add_compiler_flags(/WX-)
# solve pdb access issue
set(USE_Z7 ON)
# Close spectre for ze loader
add_compile_options("/Qspectre-")
elseif(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG)
ov_add_compiler_flags(-Wno-error)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-Wno-undef \
-Wno-missing-declarations")
if(UNUSED_BUT_SET_VARIABLE_SUPPORTED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-but-set-variable")
endif()
endif()
set(CMAKE_COMPILE_WARNING_AS_ERROR OFF)
add_subdirectory(level-zero EXCLUDE_FROM_ALL)

# This VERSION file created by L0 may cause compilation issue of oneTBB headers, so remove it
file(REMOVE "${CMAKE_BINARY_DIR}/VERSION")
add_library(level-zero-ext INTERFACE)
set_property(TARGET level-zero-ext APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/level-zero-ext/>)
add_library(LevelZero::NPUExt ALIAS level-zero-ext)
install(TARGETS level-zero-ext EXPORT "${PROJECT_NAME}Targets")
endif()
10 changes: 10 additions & 0 deletions thirdparty/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ if(X86_64 OR X86 OR UNIVERSAL2)
endif()
endif()

#
# LevelZero
#

if(ENABLE_INTEL_NPU)
add_subdirectory(thirdparty/level_zero EXCLUDE_FROM_ALL)

add_library(LevelZero::LevelZero ALIAS ze_loader)
endif()

#
# OpenCL
#
Expand Down
34 changes: 34 additions & 0 deletions thirdparty/level_zero/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright (C) 2018-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#

set(BUILD_SHARED_LIBS OFF)


# We have to avoid linking against loader with debug postfix due it's a part of driver
# and the name will be the same for release and debug configurations
set(CMAKE_DEBUG_POSTFIX "")

# Skip warnings as errors for thirdparty
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
ov_add_compiler_flags(/WX-)
# solve pdb access issue
set(USE_Z7 ON)
# Close spectre for ze loader
add_compile_options("/Qspectre-")
elseif(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG)
ov_add_compiler_flags(-Wno-error)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-Wno-undef \
-Wno-missing-declarations")
if(UNUSED_BUT_SET_VARIABLE_SUPPORTED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-but-set-variable")
endif()
endif()
set(CMAKE_COMPILE_WARNING_AS_ERROR OFF)
add_subdirectory(level-zero EXCLUDE_FROM_ALL)

set_property(TARGET ze_loader APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/level-zero/include>)

# This VERSION file created by L0 may cause compilation issue of oneTBB headers, so remove it
file(REMOVE "${CMAKE_BINARY_DIR}/VERSION")

0 comments on commit e934d83

Please sign in to comment.