Skip to content

Commit 8812f62

Browse files
Fix timestamp conversion by using correct timestamp size mask
Signed-off-by: Bartosz Dunajski <[email protected]>
1 parent 6e30f39 commit 8812f62

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

opencl/test/unit_test/helpers/hw_helper_tests_xehp_and_later.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPAndLater, WhenGettingMaxBarriersPer
3232
}
3333

3434
HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPAndLater, givenHwHelperWhenGetGpuTimeStampInNSIsCalledThenOnlyLow32BitsFromTimeStampAreUsedAndCorrectValueIsReturned) {
35+
constexpr uint64_t mask = static_cast<uint64_t>(std::numeric_limits<typename FamilyType::TimestampPacketType>::max());
3536

3637
auto &helper = HwHelper::get(renderCoreFamily);
3738
auto timeStamp = 0x00ff'ffff'ffff;
3839
auto frequency = 123456.0;
39-
auto result = static_cast<uint64_t>((timeStamp & 0xffff'ffff) * frequency);
40+
auto result = static_cast<uint64_t>((timeStamp & mask) * frequency);
4041

4142
EXPECT_EQ(result, helper.getGpuTimeStampInNS(timeStamp, frequency));
4243
}

shared/source/helpers/hw_helper_xehp_and_later.inl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,9 @@ uint32_t HwHelperHw<GfxFamily>::calculateAvailableThreadCount(PRODUCT_FAMILY fam
139139

140140
template <typename GfxFamily>
141141
uint64_t HwHelperHw<GfxFamily>::getGpuTimeStampInNS(uint64_t timeStamp, double frequency) const {
142-
return static_cast<uint64_t>((timeStamp & 0xffff'ffff) * frequency);
142+
constexpr uint64_t mask = static_cast<uint64_t>(std::numeric_limits<typename GfxFamily::TimestampPacketType>::max());
143+
144+
return static_cast<uint64_t>((timeStamp & mask) * frequency);
143145
}
144146

145147
constexpr uint32_t planarYuvMaxHeight = 16128;

0 commit comments

Comments
 (0)