Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add intel-npu-level-zero driver #135

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions staging/intel-npu-driver-rpm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Ignore linux-npu-driver tarballs
/v*.tar.gz
# Ignore vpux_elf aka npu_elf tarballs
/npu_ud_*.tar.gz
# Ignore level-zero-npu-extensions aka level-zero-vpu-extensions tarballs
# Is there really no better way to glob a commit hash of exactly 40 hex chars?
/[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9].tar.gz
# Ignore the MTL/VPU37xx firmware bin
# This is no longer needed, since the firmware was moved from LFS into the main tree as of >= v1.10.1
/vpu_37xx_v0.0.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
From 0ccc7c7733477188b2b90ce9845768c03d4333db Mon Sep 17 00:00:00 2001
From: "Alexander F. Lent" <[email protected]>
Date: Sun, 30 Jun 2024 12:48:55 -0400
Subject: [PATCH 1/4] Disable third-party googletest and yaml-cpp

Signed-off-by: Alexander F. Lent <[email protected]>
---
third_party/CMakeLists.txt | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt
index c732967..11237f3 100644
--- a/third_party/CMakeLists.txt
+++ b/third_party/CMakeLists.txt
@@ -11,9 +11,9 @@ include(cmake/vpux_elf.cmake)
include(cmake/level-zero.cmake)
include(cmake/level-zero-npu-extensions.cmake)

-set(INSTALL_GTEST OFF)
-add_subdirectory(googletest EXCLUDE_FROM_ALL)
+#set(INSTALL_GTEST OFF)
+#add_subdirectory(googletest EXCLUDE_FROM_ALL)

-set(YAML_CPP_INSTALL OFF)
-set(BUILD_SHARED_LIBS OFF)
-add_subdirectory(yaml-cpp EXCLUDE_FROM_ALL)
+#set(YAML_CPP_INSTALL OFF)
+#set(BUILD_SHARED_LIBS OFF)
+#add_subdirectory(yaml-cpp EXCLUDE_FROM_ALL)
--
2.45.2

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
From 110f48ee8eda22d8b40daeeecdbbed0fc3b08f8b Mon Sep 17 00:00:00 2001
From: "Song, Callum" <[email protected]>
Date: Fri, 8 Nov 2024 10:53:07 -0800
Subject: [PATCH] Remove structure and enum that are introduced in ze version
1.18.5

---
ze_graph_ext.h | 29 ++++++++---------------------
1 file changed, 8 insertions(+), 21 deletions(-)

diff --git a/ze_graph_ext.h b/ze_graph_ext.h
index 9a0a123..8a80572 100644
--- a/ze_graph_ext.h
+++ b/ze_graph_ext.h
@@ -67,14 +67,14 @@ typedef struct _ze_graph_compiler_version_info_t
/// @brief Defines structure types
typedef enum _ze_structure_type_graph_ext_t
{
- ZE_STRUCTURE_TYPE_DEVICE_GRAPH_PROPERTIES = 0x1, ///< ::ze_device_graph_properties_t
- ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES = 0x2, ///< ::ze_graph_desc_t
- ZE_STRUCTURE_TYPE_GRAPH_PROPERTIES = 0x3, ///< ::ze_graph_properties_t
- ZE_STRUCTURE_TYPE_GRAPH_ARGUMENT_PROPERTIES = 0x4, ///< ::ze_graph_argument_properties_t
- ZE_STRUCTURE_TYPE_GRAPH_ACTIVATION_KERNEL = 0x5, ///< ::ze_graph_activation_kernel_t
- ZE_STRUCTURE_TYPE_GRAPH_ARGUMENT_METADATA = 0x6, ///< ::ze_graph_argument_metadata_t
- ZE_STRUCTURE_TYPE_MUTABLE_GRAPH_ARGUMENT_EXP_DESC = 0x7, ///< ::ze_mutable_graph_argument_exp_desc_t
- ZE_STRUCTURE_TYPE_MUTABLE_GRAPH_PROFILING_QUERY_EXP_DESC = 0x8 ///< ::ze_mutable_graph_profiling_query_exp_desc_t
+ ZE_STRUCTURE_TYPE_DEVICE_GRAPH_PROPERTIES = 0x1, ///< ::ze_device_graph_properties_t
+ ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES = 0x2, ///< ::ze_graph_desc_t
+ ZE_STRUCTURE_TYPE_GRAPH_PROPERTIES = 0x3, ///< ::ze_graph_properties_t
+ ZE_STRUCTURE_TYPE_GRAPH_ARGUMENT_PROPERTIES = 0x4, ///< ::ze_graph_argument_properties_t
+ ZE_STRUCTURE_TYPE_GRAPH_ACTIVATION_KERNEL = 0x5, ///< ::ze_graph_activation_kernel_t
+ ZE_STRUCTURE_TYPE_GRAPH_ARGUMENT_METADATA = 0x6, ///< ::ze_graph_argument_metadata_t
+ ZE_STRUCTURE_TYPE_MUTABLE_GRAPH_ARGUMENT_EXP_DESC_DEPRECATED = 0x7, ///< ::ze_mutable_graph_argument_exp_desc_t
+ ZE_STRUCTURE_TYPE_MUTABLE_GRAPH_PROFILING_QUERY_EXP_DESC = 0x8 ///< ::ze_mutable_graph_profiling_query_exp_desc_t

} ze_structure_type_graph_ext_t;

@@ -672,19 +672,6 @@ typedef enum _ze_mutable_command_npu_exp_flag_t

} ze_mutable_command_npu_exp_flag_t;

-///////////////////////////////////////////////////////////////////////////////
-/// @brief Mutable graph argument descriptor
-typedef struct _ze_mutable_graph_argument_exp_desc_t
-{
- ze_structure_type_graph_ext_t stype; ///< [in] type of this structure
- const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific
- ///< structure (i.e. contains stype and pNext).
- uint64_t commandId; ///< [in] command identifier
- uint32_t argIndex; ///< [in] index of the argument
- const void* pArgValue; ///< [in] value to bind to the index
-
-} ze_mutable_graph_argument_exp_desc_t;
-
///////////////////////////////////////////////////////////////////////////////
/// @brief Mutable graph profiling query descriptor
typedef struct _ze_mutable_graph_profiling_query_exp_desc_t
--
2.47.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
From 23bda45da7dab8128f301a7c7d77bab5b21a0faa Mon Sep 17 00:00:00 2001
From: "Alexander F. Lent" <[email protected]>
Date: Wed, 14 Aug 2024 14:49:42 -0400
Subject: [PATCH 2/4] Make firmware install respect CMAKE_INSTALL_PATH

(Upstream tried to fix this by using an absolute path, but then the
CMake install step will always try to install to /lib rather than
wherever we are pointing the install.)

Signed-off-by: Alexander F. Lent <[email protected]>
---
firmware/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/firmware/CMakeLists.txt b/firmware/CMakeLists.txt
index 09bf0aa..b201813 100644
--- a/firmware/CMakeLists.txt
+++ b/firmware/CMakeLists.txt
@@ -12,7 +12,7 @@ target_include_directories(${PROJECT_NAME} INTERFACE include)
file(GLOB FIRMWARE_BINARIES ${CMAKE_CURRENT_SOURCE_DIR}/bin/*.bin)
if (FIRMWARE_BINARIES)
install(FILES ${FIRMWARE_BINARIES}
- DESTINATION /lib/firmware/updates/intel/vpu/
+ DESTINATION lib/firmware/updates/intel/vpu/
PERMISSIONS OWNER_READ
COMPONENT fw-npu)
endif()
--
2.45.2

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From 24de6373c51138f082ae8b5d27a301f53567fb9a Mon Sep 17 00:00:00 2001
From: "Alexander F. Lent" <[email protected]>
Date: Fri, 8 Nov 2024 23:33:40 -0500
Subject: [PATCH 3/4] Uprev level-zero-npu-extensions to build against headers
> 1.18

Note that this patch is not packaged, instead the submodule code is directly
patched with the extra commit on Fedora >= 41 only, since 40 is still
shipping OneAPI Level Zero headers 1.17.n.

Signed-off-by: Alexander F. Lent <[email protected]>
---
third_party/level-zero-npu-extensions | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/third_party/level-zero-npu-extensions b/third_party/level-zero-npu-extensions
index a63155a..110f48e 160000
--- a/third_party/level-zero-npu-extensions
+++ b/third_party/level-zero-npu-extensions
@@ -1 +1 @@
-Subproject commit a63155ae4e64feaaa6931f4696c2e2e699063875
+Subproject commit 110f48ee8eda22d8b40daeeecdbbed0fc3b08f8b
--
2.45.2

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
From ff63b69c1abb014653aed9d1791e9f012ff12bc3 Mon Sep 17 00:00:00 2001
From: "Alexander F. Lent" <[email protected]>
Date: Fri, 8 Nov 2024 23:34:28 -0500
Subject: [PATCH 4/4] Fix usage of upstreamed extension

Signed-off-by: Alexander F. Lent <[email protected]>
---
umd/level_zero_driver/core/source/cmdlist/cmdlist.cpp | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/umd/level_zero_driver/core/source/cmdlist/cmdlist.cpp b/umd/level_zero_driver/core/source/cmdlist/cmdlist.cpp
index 4e82b37..25c7978 100644
--- a/umd/level_zero_driver/core/source/cmdlist/cmdlist.cpp
+++ b/umd/level_zero_driver/core/source/cmdlist/cmdlist.cpp
@@ -669,9 +669,11 @@ getCommandUpdates(const void *pNext,
CommandUpdatesMap &updatesMap) {
const ze_structure_type_graph_ext_t stype =
*reinterpret_cast<const ze_structure_type_graph_ext_t *>(pNext);
+ const ze_structure_type_t stype_proper =
+ *reinterpret_cast<const ze_structure_type_t *>(pNext);

- switch (stype) {
- case ZE_STRUCTURE_TYPE_MUTABLE_GRAPH_ARGUMENT_EXP_DESC: {
+ if (stype == ZE_STRUCTURE_TYPE_MUTABLE_GRAPH_ARGUMENT_EXP_DESC_DEPRECATED ||
+ stype_proper == ZE_STRUCTURE_TYPE_MUTABLE_GRAPH_ARGUMENT_EXP_DESC) {
const ze_mutable_graph_argument_exp_desc_t *desc =
reinterpret_cast<const ze_mutable_graph_argument_exp_desc_t *>(pNext);
uint64_t commandId = desc->commandId;
@@ -692,14 +694,12 @@ getCommandUpdates(const void *pNext,
LOG(CMDLIST, "Mutate GraphArgument[%u] = %p", argIndex, desc->pArgValue);

return desc->pNext;
- }
- default: {
+ } else {
LOG_E("Unsupported descriptor type (%#x) to mutate commands. Only "
"ZE_STRUCTURE_TYPE_MUTABLE_GRAPH_ARGUMENT_EXP_DESC is supported",
stype);
return {};
}
- }
}

static bool gatherCommandUpdates(const void *pNext,
--
2.45.2

Loading
Loading