linux-npu-driver: add recipe

This recipe enables User Mode Driver for Intel® NPU device.
Intel® NPU device is an AI inference accelerator integrated
with Intel client CPUs, starting from Intel® Core™ Ultra generation
of CPUs (formerly known as Meteor Lake).
It enables energy-efficient execution of artificial neural network tasks.

https://github.com/intel/linux-npu-driver

Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
This commit is contained in:
Naveen Saini 2024-05-29 11:09:46 +08:00 committed by Anuj Mittal
parent 28b193723b
commit b47467609d
4 changed files with 243 additions and 0 deletions

View File

@ -31,6 +31,7 @@ RECIPE_MAINTAINER:pn-libxcam = "Naveen Saini <naveen.kumar.saini@intel.com>"
RECIPE_MAINTAINER:pn-linux-intel = "Anuj Mittal <anuj.mittal@intel.com>"
RECIPE_MAINTAINER:pn-linux-intel-rt = "Anuj Mittal <anuj.mittal@intel.com>"
RECIPE_MAINTAINER:pn-linux-intel-dev = "Naveen Saini <naveen.kumar.saini@intel.com>"
RECIPE_MAINTAINER:pn-linux-npu-driver = "Naveen Saini <naveen.kumar.saini@intel.com>"
RECIPE_MAINTAINER:pn-lms = "Anuj Mittal <anuj.mittal@intel.com>"
RECIPE_MAINTAINER:pn-metee = "Naveen Saini <naveen.kumar.saini@intel.com>"
RECIPE_MAINTAINER:pn-metrics-discovery = "Naveen Saini <naveen.kumar.saini@intel.com>"

View File

@ -0,0 +1,99 @@
From b57297c14d94dac9bdef7570b7b33d70b10171f3 Mon Sep 17 00:00:00 2001
From: Jozef Wludzik <jozef.wludzik@intel.com>
Date: Tue, 26 Mar 2024 14:43:29 +0100
Subject: [PATCH 1/2] Fix the compilation warning when using gcc-13 (#25)
Added missing headers. Fixed compilation error about casting from
unsigned to signed int.
Upstream-Status: Backport [https://github.com/intel/linux-npu-driver/commit/4bcbf2abe94eb4d9c083bd616b58e309a82d008a]
Signed-off-by: Jozef Wludzik <jozef.wludzik@intel.com>
Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
---
umd/level_zero_driver/ext/source/graph/vcl_symbols.hpp | 7 ++++---
umd/vpu_driver/include/umd_common.hpp | 1 +
validation/umd-test/umd_prime_buffers.h | 9 +++++++--
validation/umd-test/utilities/data_handle.h | 1 +
4 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/umd/level_zero_driver/ext/source/graph/vcl_symbols.hpp b/umd/level_zero_driver/ext/source/graph/vcl_symbols.hpp
index f206ebe..682e5b4 100644
--- a/umd/level_zero_driver/ext/source/graph/vcl_symbols.hpp
+++ b/umd/level_zero_driver/ext/source/graph/vcl_symbols.hpp
@@ -5,12 +5,13 @@
*
*/
-#include <dlfcn.h>
-#include <memory>
-
#include "vpux_driver_compiler.h"
#include "vpu_driver/source/utilities/log.hpp"
+#include <array>
+#include <dlfcn.h>
+#include <memory>
+
class Vcl {
public:
static Vcl &sym() {
diff --git a/umd/vpu_driver/include/umd_common.hpp b/umd/vpu_driver/include/umd_common.hpp
index 0c874a3..5ad9be2 100644
--- a/umd/vpu_driver/include/umd_common.hpp
+++ b/umd/vpu_driver/include/umd_common.hpp
@@ -7,6 +7,7 @@
#pragma once
+#include <cstdint>
#include <limits>
#include <linux/kernel.h>
#include <stdexcept>
diff --git a/validation/umd-test/umd_prime_buffers.h b/validation/umd-test/umd_prime_buffers.h
index 6f7c7de..ab4814c 100644
--- a/validation/umd-test/umd_prime_buffers.h
+++ b/validation/umd-test/umd_prime_buffers.h
@@ -6,12 +6,17 @@
*/
#pragma once
+
+#include "umd_test.h"
+
#include <fcntl.h>
-#include <linux/kernel.h>
#include <linux/dma-buf.h>
#include <linux/dma-heap.h>
+#include <linux/kernel.h>
+#include <stdint.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
+#include <unistd.h>
#define ALLIGN_TO_PAGE(x) __ALIGN_KERNEL((x), (UmdTest::PAGE_SIZE))
@@ -60,7 +65,7 @@ class PrimeBufferHelper {
return false;
bufferFd = heapAlloc.fd;
- buffers.insert({heapAlloc.fd, {size, nullptr}});
+ buffers.insert({static_cast<int>(heapAlloc.fd), {size, nullptr}});
return true;
}
diff --git a/validation/umd-test/utilities/data_handle.h b/validation/umd-test/utilities/data_handle.h
index d6e0ec0..5d937b2 100644
--- a/validation/umd-test/utilities/data_handle.h
+++ b/validation/umd-test/utilities/data_handle.h
@@ -6,6 +6,7 @@
*/
#include <linux/kernel.h>
+#include <stdint.h>
#include <string>
#include <vector>
--
2.43.0

View File

@ -0,0 +1,110 @@
From a9f51fd88effb7d324609e692ca7da576d6dad2e Mon Sep 17 00:00:00 2001
From: Naveen Saini <naveen.kumar.saini@intel.com>
Date: Tue, 28 May 2024 10:23:42 +0800
Subject: [PATCH 2/2] Fix compilation failure with GCC-14
umd/level_zero_driver/core/source/event/event.cpp:65:31: error: 'remove_if' is not a member of 'std'; did you mean 'remove_cv'?
| 65 | associatedJobs.erase(std::remove_if(associatedJobs.begin(),
| | ^~~~~~~~~
| | remove_cv
| umd/vpu_driver/source/command/vpu_command.cpp: In member function 'void VPU::VPUCommand::appendAssociateBufferObject(VPU::VPUBufferObject*)':
| umd/vpu_driver/source/command/vpu_command.cpp:126:20: error: 'find' is not a member of 'std'; did you mean 'bind'?
| 126 | auto it = std::find(bufferObjects.begin(), bufferObjects.end(), bo);
| | ^~~~
| | bind
| umd/vpu_driver/source/command/vpu_command_buffer.cpp: In member function 'bool VPU::VPUCommandBuffer::addCommand(VPU::VPUCommand*, uint64_t&, uint64_t&)':
| umd/vpu_driver/source/command/vpu_command_buffer.cpp:185:24: error: 'find' is not a member of 'std'; did you mean 'bind'?
| 185 | auto it = std::find(bufferHandles.begin(), bufferHandles.end(), bo->getHandle());
| | ^~~~
| | bind
| umd/level_zero_driver/ext/source/graph/elf_parser.cpp:301:32: error: 'max_element' is not a member of 'std'; did you mean 'tuple_element'?
| 301 | std::max_element(stride_begin + TENSOR_5D_STRIDE_C, stride_end));
| | ^~~~~~~~~~~
| | tuple_element
| umd/level_zero_driver/ext/source/graph/elf_parser.cpp:315:37: error: 'max_element' is not a member of 'std'; did you mean 'tuple_element'?
| 315 | auto max_stride_val = *std::max_element(stride_begin + TENSOR_4D_STRIDE_C, stride_end);
| | ^~~~~~~~~~~
| umd/level_zero_driver/tools/source/metrics/metric.cpp: In member function 'void L0::MetricContext::deactivateMetricGroups(int)':
| umd/level_zero_driver/tools/source/metrics/metric.cpp:275:38: error: 'remove_if' is not a member of 'std'; did you mean 'remove_cv'?
| 275 | activatedMetricGroups.erase(std::remove_if(activatedMetricGroups.begin(),
| | ^~~~~~~~~
| | remove_cv
Upstream-Status: Submitted [https://github.com/intel/linux-npu-driver/pull/30]
Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
---
umd/level_zero_driver/core/source/event/event.cpp | 1 +
umd/level_zero_driver/ext/source/graph/elf_parser.cpp | 1 +
umd/level_zero_driver/tools/source/metrics/metric.cpp | 1 +
umd/vpu_driver/source/command/vpu_command.cpp | 1 +
umd/vpu_driver/source/command/vpu_command_buffer.cpp | 1 +
5 files changed, 5 insertions(+)
diff --git a/umd/level_zero_driver/core/source/event/event.cpp b/umd/level_zero_driver/core/source/event/event.cpp
index a92248f..196d176 100644
--- a/umd/level_zero_driver/core/source/event/event.cpp
+++ b/umd/level_zero_driver/core/source/event/event.cpp
@@ -14,6 +14,7 @@
#include <level_zero/ze_api.h>
#include <thread>
+#include <algorithm>
namespace L0 {
diff --git a/umd/level_zero_driver/ext/source/graph/elf_parser.cpp b/umd/level_zero_driver/ext/source/graph/elf_parser.cpp
index a1c8e14..dfbd61d 100644
--- a/umd/level_zero_driver/ext/source/graph/elf_parser.cpp
+++ b/umd/level_zero_driver/ext/source/graph/elf_parser.cpp
@@ -21,6 +21,7 @@
#include <vpux_headers/metadata.hpp>
#include <vpux_elf/types/vpu_extensions.hpp>
#include <vpux_elf/utils/error.hpp>
+#include <algorithm>
namespace L0 {
diff --git a/umd/level_zero_driver/tools/source/metrics/metric.cpp b/umd/level_zero_driver/tools/source/metrics/metric.cpp
index b67750f..9497311 100644
--- a/umd/level_zero_driver/tools/source/metrics/metric.cpp
+++ b/umd/level_zero_driver/tools/source/metrics/metric.cpp
@@ -7,6 +7,7 @@
#include "level_zero_driver/tools/source/metrics/metric.hpp"
#include "vpu_driver/source/utilities/log.hpp"
+#include <algorithm>
namespace L0 {
diff --git a/umd/vpu_driver/source/command/vpu_command.cpp b/umd/vpu_driver/source/command/vpu_command.cpp
index f4ca23f..75331d9 100644
--- a/umd/vpu_driver/source/command/vpu_command.cpp
+++ b/umd/vpu_driver/source/command/vpu_command.cpp
@@ -14,6 +14,7 @@
#include <cstdint>
#include <vector>
#include <map>
+#include <algorithm>
namespace VPU {
diff --git a/umd/vpu_driver/source/command/vpu_command_buffer.cpp b/umd/vpu_driver/source/command/vpu_command_buffer.cpp
index c4ad052..bbb80ec 100644
--- a/umd/vpu_driver/source/command/vpu_command_buffer.cpp
+++ b/umd/vpu_driver/source/command/vpu_command_buffer.cpp
@@ -11,6 +11,7 @@
#include "vpu_driver/source/command/vpu_command_buffer.hpp"
#include "vpu_driver/source/command/vpu_copy_command.hpp"
#include "vpu_driver/source/utilities/log.hpp"
+#include <algorithm>
namespace VPU {
--
2.43.0

View File

@ -0,0 +1,33 @@
SUMMARY = "User Mode Driver for Intel® NPU device"
HOMEPAGE = "https://github.com/intel/linux-npu-driver"
LICENSE = "MIT & Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE.md;md5=37acda99f3f9c108e62d970fe0e08027 \
file://third-party-programs.txt;md5=dbf0d7a91947cccc5410e9760d9acae5 \
file://third_party/vpux_elf/LICENSE;md5=86d3f3a95c324c9479bd8986968f4327"
SRC_URI = "git://github.com/intel/linux-npu-driver.git;protocol=https;name=linux-npu-driver;branch=main;lfs=1 \
git://github.com/openvinotoolkit/npu_plugin_elf.git;protocol=https;destsuffix=git/third_party/vpux_elf;name=vpux-elf;nobranch=1 \
git://github.com/jbeder/yaml-cpp.git;protocol=https;destsuffix=git/third_party/yaml-cpp;name=yaml-cpp;nobranch=1 \
git://github.com/intel/level-zero-npu-extensions.git;protocol=https;destsuffix=git/third_party/level-zero-vpu-extensions;name=lzvext;nobranch=1 \
git://github.com/google/googletest.git;protocol=https;destsuffix=git/third_party/googletest;name=googletest;nobranch=1 \
file://0001-Fix-the-compilation-warning-when-using-gcc-13-25.patch \
file://0002-Fix-compilation-failure-with-GCC-14.patch \
"
SRCREV_linux-npu-driver = "9d1dd3daa01ebd97a4ac2e8279ddd6e2cb109244"
SRCREV_vpux-elf = "03878c115d13aa1ce6af5329c5759fc1cc94a3fb"
SRCREV_yaml-cpp = "0579ae3d976091d7d664aa9d2527e0d0cff25763"
SRCREV_lzvext = "0e1c471356a724ef6d176ba027a68e210d90939e"
SRCREV_googletest = "b796f7d44681514f58a683a3a71ff17c94edb0c1"
SRCREV_FORMAT = "linux-npu-driver_vpux-elf_yaml-cpp_lzvext_googletest"
S = "${WORKDIR}/git"
inherit cmake
DEPENDS = "level-zero"
PACKAGES =+ "${PN}-firmware ${PN}-tests"
FILES:${PN}-firmware = "${libdir}/firmware/updates/intel/vpu/*"
FILES:${PN}-tests = "${bindir}"