From 8812f6250b9536a14129577bdc8252c2f73f27b8 Mon Sep 17 00:00:00 2001 From: Bartosz Dunajski Date: Wed, 25 May 2022 16:10:46 +0000 Subject: [PATCH] Fix timestamp conversion by using correct timestamp size mask Signed-off-by: Bartosz Dunajski --- .../test/unit_test/helpers/hw_helper_tests_xehp_and_later.cpp | 3 ++- shared/source/helpers/hw_helper_xehp_and_later.inl | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/opencl/test/unit_test/helpers/hw_helper_tests_xehp_and_later.cpp b/opencl/test/unit_test/helpers/hw_helper_tests_xehp_and_later.cpp index f163a47083..4139fe8ae5 100644 --- a/opencl/test/unit_test/helpers/hw_helper_tests_xehp_and_later.cpp +++ b/opencl/test/unit_test/helpers/hw_helper_tests_xehp_and_later.cpp @@ -32,11 +32,12 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPAndLater, WhenGettingMaxBarriersPer } HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPAndLater, givenHwHelperWhenGetGpuTimeStampInNSIsCalledThenOnlyLow32BitsFromTimeStampAreUsedAndCorrectValueIsReturned) { + constexpr uint64_t mask = static_cast(std::numeric_limits::max()); auto &helper = HwHelper::get(renderCoreFamily); auto timeStamp = 0x00ff'ffff'ffff; auto frequency = 123456.0; - auto result = static_cast((timeStamp & 0xffff'ffff) * frequency); + auto result = static_cast((timeStamp & mask) * frequency); EXPECT_EQ(result, helper.getGpuTimeStampInNS(timeStamp, frequency)); } diff --git a/shared/source/helpers/hw_helper_xehp_and_later.inl b/shared/source/helpers/hw_helper_xehp_and_later.inl index 3cb3671d3e..fca7d12fab 100644 --- a/shared/source/helpers/hw_helper_xehp_and_later.inl +++ b/shared/source/helpers/hw_helper_xehp_and_later.inl @@ -139,7 +139,9 @@ uint32_t HwHelperHw::calculateAvailableThreadCount(PRODUCT_FAMILY fam template uint64_t HwHelperHw::getGpuTimeStampInNS(uint64_t timeStamp, double frequency) const { - return static_cast((timeStamp & 0xffff'ffff) * frequency); + constexpr uint64_t mask = static_cast(std::numeric_limits::max()); + + return static_cast((timeStamp & mask) * frequency); } constexpr uint32_t planarYuvMaxHeight = 16128;