From 56847274fab59d3f3027ad89c8fbcd18b4a687a4 Mon Sep 17 00:00:00 2001 From: Artur Harasimiuk Date: Wed, 24 Apr 2024 12:43:17 +0000 Subject: [PATCH] build: improve L0 driver versioning to allow HotFix number new format is: BBBBB.HHH, where: * BBBBB is build number * HHH is hotfix number Signed-off-by: Artur Harasimiuk --- driver_version.h.in | 1 + level_zero/core/source/driver/driver_handle_imp.cpp | 5 +++-- level_zero/core/source/driver/driver_handle_imp.h | 2 -- .../test/unit_tests/sources/driver/test_driver.cpp | 12 ++++++------ .../l0_gpu_driver/build_l0_gpu_driver_deb.sh | 7 ++++--- .../l0_gpu_driver/build_l0_gpu_driver_rpm.sh | 3 ++- scripts/packaging/l0_gpu_driver/l0_gpu_driver.sh | 1 + .../l0_gpu_driver/rhel_8/SPECS/l0_gpu_driver.spec | 2 ++ .../l0_gpu_driver/sles_15/SPECS/l0_gpu_driver.spec | 2 ++ .../l0_gpu_driver/ubuntu_20.04/debian/rules | 2 ++ version.cmake | 5 +++++ 11 files changed, 28 insertions(+), 14 deletions(-) diff --git a/driver_version.h.in b/driver_version.h.in index d52b248232e28..86d4dab8fac20 100644 --- a/driver_version.h.in +++ b/driver_version.h.in @@ -12,5 +12,6 @@ #cmakedefine NEO_REVISION "${NEO_REVISION}" #define NEO_VERSION_BUILD ${NEO_VERSION_BUILD} +#define NEO_VERSION_HOTFIX ${NEO_VERSION_HOTFIX} #endif /* DRIVER_VERSION_H */ diff --git a/level_zero/core/source/driver/driver_handle_imp.cpp b/level_zero/core/source/driver/driver_handle_imp.cpp index 0eab55491cc6a..78a762dd12cab 100644 --- a/level_zero/core/source/driver/driver_handle_imp.cpp +++ b/level_zero/core/source/driver/driver_handle_imp.cpp @@ -113,9 +113,10 @@ ze_result_t DriverHandleImp::getApiVersion(ze_api_version_t *version) { } ze_result_t DriverHandleImp::getProperties(ze_driver_properties_t *properties) { - uint32_t versionBuild = static_cast(NEO_VERSION_BUILD); + uint32_t versionBuild = static_cast(NEO_VERSION_BUILD) << 12; + uint32_t versionHotfix = static_cast(NEO_VERSION_HOTFIX); - properties->driverVersion = DriverHandleImp::initialDriverVersionValue + versionBuild; + properties->driverVersion = versionBuild + versionHotfix; if (NEO::debugManager.flags.OverrideDriverVersion.get() > -1) { properties->driverVersion = static_cast(NEO::debugManager.flags.OverrideDriverVersion.get()); } diff --git a/level_zero/core/source/driver/driver_handle_imp.h b/level_zero/core/source/driver/driver_handle_imp.h index 6f0069ef03111..e1ec02f5308c1 100644 --- a/level_zero/core/source/driver/driver_handle_imp.h +++ b/level_zero/core/source/driver/driver_handle_imp.h @@ -51,8 +51,6 @@ struct DriverHandleImp : public DriverHandle { ~DriverHandleImp() override; DriverHandleImp(); - static constexpr uint32_t initialDriverVersionValue = 0x01030000; - ze_result_t createContext(const ze_context_desc_t *desc, uint32_t numDevices, ze_device_handle_t *phDevices, diff --git a/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp b/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp index 4e4bd5c887764..498dcdc00b2e6 100644 --- a/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp +++ b/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp @@ -203,8 +203,8 @@ TEST_F(DriverVersionTest, WhenGettingDriverVersionThenExpectedDriverVersionIsRet ze_result_t res = driverHandle->getProperties(&properties); EXPECT_EQ(ZE_RESULT_SUCCESS, res); - auto expectedDriverVersion = static_cast(DriverHandleImp::initialDriverVersionValue); - expectedDriverVersion += static_cast(NEO_VERSION_BUILD); + auto expectedDriverVersion = static_cast(NEO_VERSION_BUILD << 12); + expectedDriverVersion += static_cast(NEO_VERSION_HOTFIX); EXPECT_EQ(expectedDriverVersion, properties.driverVersion); } @@ -227,12 +227,12 @@ TEST_F(DriverVersionTest, GivenDebugOverrideWhenGettingDriverVersionThenExpected expectedDriverVersion = 10; EXPECT_EQ(expectedDriverVersion, properties.driverVersion); - NEO::debugManager.flags.OverrideDriverVersion.set(DriverHandleImp::initialDriverVersionValue + 20); + NEO::debugManager.flags.OverrideDriverVersion.set((29383 << 12) + 71); res = driverHandle->getProperties(&properties); EXPECT_EQ(ZE_RESULT_SUCCESS, res); - expectedDriverVersion = DriverHandleImp::initialDriverVersionValue + 20; + expectedDriverVersion = (0x72c7000 + 0x47); EXPECT_EQ(expectedDriverVersion, properties.driverVersion); } @@ -249,8 +249,8 @@ TEST_F(DriverVersionTest, givenCallToGetDriverPropertiesThenUuidIsSet) { EXPECT_NE(0u, uniqueId); auto driverVersion = static_cast(uuid & 0xFFFFFFFF); - auto expectedDriverVersion = static_cast(DriverHandleImp::initialDriverVersionValue); - expectedDriverVersion += static_cast(NEO_VERSION_BUILD); + auto expectedDriverVersion = static_cast(NEO_VERSION_BUILD << 12); + expectedDriverVersion += static_cast(NEO_VERSION_HOTFIX); EXPECT_EQ(expectedDriverVersion, driverVersion); } diff --git a/scripts/packaging/l0_gpu_driver/build_l0_gpu_driver_deb.sh b/scripts/packaging/l0_gpu_driver/build_l0_gpu_driver_deb.sh index c45533e5bbb78..ab290547cb1ce 100755 --- a/scripts/packaging/l0_gpu_driver/build_l0_gpu_driver_deb.sh +++ b/scripts/packaging/l0_gpu_driver/build_l0_gpu_driver_deb.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # -# Copyright (C) 2021-2023 Intel Corporation +# Copyright (C) 2021-2024 Intel Corporation # # SPDX-License-Identifier: MIT # @@ -32,10 +32,10 @@ source "${REPO_DIR}/scripts/packaging/${BRANCH_SUFFIX}/functions.sh" source "${REPO_DIR}/scripts/packaging/${BRANCH_SUFFIX}/l0_gpu_driver/l0_gpu_driver.sh" get_api_version # API_VERSION-API_VERSION_SRC and API_DEB_MODEL_LINK -get_l0_gpu_driver_version # NEO_L0_VERSION_MAJOR.NEO_L0_VERSION_MINOR.NEO_L0_VERSION_PATCH +get_l0_gpu_driver_version # NEO_L0_VERSION_MAJOR.NEO_L0_VERSION_MINOR.NEO_L0_VERSION_PATCH.NEO_L0_VERSION_HOTFIX if [ -z "${BRANCH_SUFFIX}" ]; then - VERSION="${NEO_L0_VERSION_MAJOR}.${NEO_L0_VERSION_MINOR}.${NEO_L0_VERSION_PATCH}${API_DEB_MODEL_LINK}" + VERSION="${NEO_L0_VERSION_MAJOR}.${NEO_L0_VERSION_MINOR}.${NEO_L0_VERSION_PATCH}-${NEO_L0_VERSION_HOTFIX}${API_DEB_MODEL_LINK}" else VERSION="${NEO_L0_VERSION_MAJOR}.${NEO_L0_VERSION_MINOR}.${NEO_L0_VERSION_PATCH}${API_VERSION}-${NEO_L0_VERSION_HOTFIX}${API_VERSION_SRC}${API_DEB_MODEL_LINK}" fi @@ -85,6 +85,7 @@ fi # Update rules file with new version perl -pi -e "s/^ver = .*/ver = $NEO_L0_VERSION_PATCH/" $BUILD_DIR/debian/rules +perl -pi -e "s/^ver_hf = .*/ver_hf = $NEO_L0_VERSION_HOTFIX/" $BUILD_DIR/debian/rules #needs a top level CMAKE file cat << EOF | tee $BUILD_DIR/CMakeLists.txt diff --git a/scripts/packaging/l0_gpu_driver/build_l0_gpu_driver_rpm.sh b/scripts/packaging/l0_gpu_driver/build_l0_gpu_driver_rpm.sh index bfd68409431cd..759a57b8e0391 100755 --- a/scripts/packaging/l0_gpu_driver/build_l0_gpu_driver_rpm.sh +++ b/scripts/packaging/l0_gpu_driver/build_l0_gpu_driver_rpm.sh @@ -47,7 +47,7 @@ if [ "${BUILD_SRPM}" == "1" ]; then source "${REPO_DIR}/scripts/packaging/${BRANCH_SUFFIX}/l0_gpu_driver/l0_gpu_driver.sh" get_api_version # API_VERSION-API_VERSION_SRC and API_RPM_MODEL_LINK - get_l0_gpu_driver_version # NEO_L0_VERSION_MAJOR.NEO_L0_VERSION_MINOR.NEO_L0_VERSION_PATCH + get_l0_gpu_driver_version # NEO_L0_VERSION_MAJOR.NEO_L0_VERSION_MINOR.NEO_L0_VERSION_PATCH.NEO_L0_VERSION_HOTFIX VERSION="${NEO_L0_VERSION_MAJOR}.${NEO_L0_VERSION_MINOR}.${NEO_L0_VERSION_PATCH}${API_VERSION}" RELEASE="${NEO_L0_VERSION_HOTFIX}${API_VERSION_SRC}${API_RPM_MODEL_LINK}" @@ -77,6 +77,7 @@ if [ "${BUILD_SRPM}" == "1" ]; then perl -pi -e "s/^%global rel .*/%global rel ${RELEASE}/" $SPEC perl -pi -e "s/^%global NEO_RELEASE_WITH_REGKEYS .*/%global NEO_RELEASE_WITH_REGKEYS ${RELEASE_WITH_REGKEYS}/" $SPEC perl -pi -e "s/^%global build_id .*/%global build_id ${NEO_L0_VERSION_PATCH}/" $SPEC + perl -pi -e "s/^%global hotfix_id .*/%global hotfix_id ${NEO_L0_VERSION_HOTFIX}/" $SPEC rpmbuild --define "_topdir $BUILD_DIR" -bs $SPEC --define 'build_type ${CMAKE_BUILD_TYPE}' "${build_args[@]}" mkdir -p ${REPO_DIR}/../output/SRPMS diff --git a/scripts/packaging/l0_gpu_driver/l0_gpu_driver.sh b/scripts/packaging/l0_gpu_driver/l0_gpu_driver.sh index 7ebc7eafbb56e..eecfd5651397a 100755 --- a/scripts/packaging/l0_gpu_driver/l0_gpu_driver.sh +++ b/scripts/packaging/l0_gpu_driver/l0_gpu_driver.sh @@ -24,5 +24,6 @@ get_l0_gpu_driver_version() { unset __NEO_L0_VERSION_PATCH_TMP __NEO_L0_VERSION_HOTFIX_TMP=$(echo $NEO_TAG | awk -F '-' '{ if(NF>1) { print $2; } }') NEO_L0_VERSION_HOTFIX="${NEO_L0_VERSION_HOTFIX:-$__NEO_L0_VERSION_HOTFIX_TMP}" + NEO_L0_VERSION_HOTFIX="${NEO_L0_VERSION_HOTFIX:-0}" unset __NEO_L0_VERSION_HOTFIX_TMP } diff --git a/scripts/packaging/l0_gpu_driver/rhel_8/SPECS/l0_gpu_driver.spec b/scripts/packaging/l0_gpu_driver/rhel_8/SPECS/l0_gpu_driver.spec index 40ad07c5bb008..aef1c8af59c38 100644 --- a/scripts/packaging/l0_gpu_driver/rhel_8/SPECS/l0_gpu_driver.spec +++ b/scripts/packaging/l0_gpu_driver/rhel_8/SPECS/l0_gpu_driver.spec @@ -2,6 +2,7 @@ %global ver xxx %global rel xxx %global build_id xxx +%global hotfix_id xxx %global NEO_RELEASE_WITH_REGKEYS FALSE %global NEO_ENABLE_XE_EU_DEBUG_SUPPORT FALSE %global NEO_I915_PRELIM_HEADERS_DIR %{nil} @@ -62,6 +63,7 @@ cd build %cmake .. \ -GNinja ${NEO_BUILD_EXTRA_OPTS} \ -DNEO_VERSION_BUILD=%{build_id} \ + -DNEO_VERSION_HOTFIX=%{hotfix_id} \ -DCMAKE_BUILD_TYPE=Release \ -DNEO_BUILD_WITH_OCL=FALSE \ -DNEO_SKIP_UNIT_TESTS=TRUE \ diff --git a/scripts/packaging/l0_gpu_driver/sles_15/SPECS/l0_gpu_driver.spec b/scripts/packaging/l0_gpu_driver/sles_15/SPECS/l0_gpu_driver.spec index d754c09cd27b4..042479a20816c 100644 --- a/scripts/packaging/l0_gpu_driver/sles_15/SPECS/l0_gpu_driver.spec +++ b/scripts/packaging/l0_gpu_driver/sles_15/SPECS/l0_gpu_driver.spec @@ -4,6 +4,7 @@ %global ver xxx %global rel xxx %global build_id xxx +%global hotfix_id xxx %global NEO_RELEASE_WITH_REGKEYS FALSE %global NEO_ENABLE_XE_EU_DEBUG_SUPPORT FALSE %global NEO_I915_PRELIM_HEADERS_DIR %{nil} @@ -72,6 +73,7 @@ Intel(R) Graphics Compute Runtime for oneAPI Level Zero - development headers %cmake .. \ -GNinja ${NEO_BUILD_EXTRA_OPTS} \ -DNEO_VERSION_BUILD=%{build_id} \ + -DNEO_VERSION_HOTFIX=%{hotfix_id} \ -DCMAKE_BUILD_TYPE=%{build_type} \ -DNEO_BUILD_WITH_OCL=FALSE \ -DNEO_SKIP_UNIT_TESTS=TRUE \ diff --git a/scripts/packaging/l0_gpu_driver/ubuntu_20.04/debian/rules b/scripts/packaging/l0_gpu_driver/ubuntu_20.04/debian/rules index 50cc0773fb534..9bac5e6b310c6 100755 --- a/scripts/packaging/l0_gpu_driver/ubuntu_20.04/debian/rules +++ b/scripts/packaging/l0_gpu_driver/ubuntu_20.04/debian/rules @@ -1,5 +1,6 @@ #!/usr/bin/make -f ver = xxx +ver_hf = 0 %: dh $@ --builddir build/ --buildsystem=cmake+ninja @@ -16,6 +17,7 @@ override_dh_auto_configure: dh_auto_configure -- ${NEO_BUILD_EXTRA_OPTS} \ -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \ -DNEO_VERSION_BUILD=$(ver) \ + -DNEO_VERSION_HOTFIX=$(ver_hf) \ -DNEO_SKIP_UNIT_TESTS=${NEO_SKIP_UNIT_TESTS} \ -DNEO_ENABLE_i915_PRELIM_DETECTION=${NEO_ENABLE_i915_PRELIM_DETECTION} \ -DNEO_ENABLE_XE_EU_DEBUG_SUPPORT=${NEO_ENABLE_XE_EU_DEBUG_SUPPORT} \ diff --git a/version.cmake b/version.cmake index 9a447f4134f4a..4e2e8fa854182 100644 --- a/version.cmake +++ b/version.cmake @@ -74,6 +74,10 @@ if(NOT DEFINED NEO_REVISION) set(NEO_REVISION 0) endif() +if(NOT DEFINED NEO_VERSION_HOTFIX) + set(NEO_VERSION_HOTFIX 0) +endif() + # OpenCL pacakge version set(NEO_OCL_DRIVER_VERSION "${NEO_OCL_VERSION_MAJOR}.${NEO_OCL_VERSION_MINOR}.${NEO_VERSION_BUILD}") @@ -83,3 +87,4 @@ set(NEO_L0_VERSION_MINOR 3) # Remove leading zeros string(REGEX REPLACE "^0+([0-9]+)" "\\1" NEO_VERSION_BUILD "${NEO_VERSION_BUILD}") +string(REGEX REPLACE "^0+([0-9]+)" "\\1" NEO_VERSION_HOTFIX "${NEO_VERSION_HOTFIX}")