From 91cf5064ded359022ce608e974d33f5dc7217dc1 Mon Sep 17 00:00:00 2001 From: Michal Mrozek Date: Wed, 9 Feb 2022 09:13:26 +0000 Subject: [PATCH] Use timestamps reported by KMD. Signed-off-by: Michal Mrozek --- .../unit_test/device/device_timers_tests.cpp | 14 +------------- shared/source/device/device.cpp | 18 ++++++++---------- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/opencl/test/unit_test/device/device_timers_tests.cpp b/opencl/test/unit_test/device/device_timers_tests.cpp index b6890ec5f3..ed8abfb1a4 100644 --- a/opencl/test/unit_test/device/device_timers_tests.cpp +++ b/opencl/test/unit_test/device/device_timers_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2021 Intel Corporation + * Copyright (C) 2018-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -158,18 +158,6 @@ class FailingMockOSTime : public OSTime { } }; -TEST(MockOSTime, givenFailingOSTimeWhenGetDeviceAndHostTimerThenFalseIsReturned) { - auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); - mockDevice->setOSTime(new FailingMockOSTime()); - - uint64_t deviceTS = 0u, hostTS = 0u; - bool retVal = mockDevice->getDeviceAndHostTimer(&deviceTS, &hostTS); - - EXPECT_FALSE(retVal); - EXPECT_EQ(deviceTS, 0u); - EXPECT_EQ(hostTS, 0u); -} - class FailingMockDeviceTime : public DeviceTime { public: bool getCpuGpuTime(TimeStampData *pGpuCpuTime, OSTime *osTime) override { diff --git a/shared/source/device/device.cpp b/shared/source/device/device.cpp index 86b6d9b063..856bb1cdb6 100644 --- a/shared/source/device/device.cpp +++ b/shared/source/device/device.cpp @@ -475,17 +475,15 @@ EngineControl &Device::getEngine(uint32_t index) { } bool Device::getDeviceAndHostTimer(uint64_t *deviceTimestamp, uint64_t *hostTimestamp) const { - bool retVal = getOSTime()->getCpuTime(hostTimestamp); + TimeStampData timeStamp; + auto retVal = getOSTime()->getCpuGpuTime(&timeStamp); if (retVal) { - TimeStampData timeStamp; - retVal = getOSTime()->getCpuGpuTime(&timeStamp); - if (retVal) { - if (DebugManager.flags.EnableDeviceBasedTimestamps.get()) { - auto resolution = getOSTime()->getDynamicDeviceTimerResolution(getHardwareInfo()); - *deviceTimestamp = static_cast(timeStamp.GPUTimeStamp * resolution); - } else - *deviceTimestamp = *hostTimestamp; - } + *hostTimestamp = timeStamp.CPUTimeinNS; + if (DebugManager.flags.EnableDeviceBasedTimestamps.get()) { + auto resolution = getOSTime()->getDynamicDeviceTimerResolution(getHardwareInfo()); + *deviceTimestamp = static_cast(timeStamp.GPUTimeStamp * resolution); + } else + *deviceTimestamp = *hostTimestamp; } return retVal; }