Skip to content

Commit 91cf506

Browse files
Use timestamps reported by KMD.
Signed-off-by: Michal Mrozek <[email protected]>
1 parent 1390af6 commit 91cf506

File tree

2 files changed

+9
-23
lines changed

2 files changed

+9
-23
lines changed

opencl/test/unit_test/device/device_timers_tests.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2021 Intel Corporation
2+
* Copyright (C) 2018-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -158,18 +158,6 @@ class FailingMockOSTime : public OSTime {
158158
}
159159
};
160160

161-
TEST(MockOSTime, givenFailingOSTimeWhenGetDeviceAndHostTimerThenFalseIsReturned) {
162-
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
163-
mockDevice->setOSTime(new FailingMockOSTime());
164-
165-
uint64_t deviceTS = 0u, hostTS = 0u;
166-
bool retVal = mockDevice->getDeviceAndHostTimer(&deviceTS, &hostTS);
167-
168-
EXPECT_FALSE(retVal);
169-
EXPECT_EQ(deviceTS, 0u);
170-
EXPECT_EQ(hostTS, 0u);
171-
}
172-
173161
class FailingMockDeviceTime : public DeviceTime {
174162
public:
175163
bool getCpuGpuTime(TimeStampData *pGpuCpuTime, OSTime *osTime) override {

shared/source/device/device.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -475,17 +475,15 @@ EngineControl &Device::getEngine(uint32_t index) {
475475
}
476476

477477
bool Device::getDeviceAndHostTimer(uint64_t *deviceTimestamp, uint64_t *hostTimestamp) const {
478-
bool retVal = getOSTime()->getCpuTime(hostTimestamp);
478+
TimeStampData timeStamp;
479+
auto retVal = getOSTime()->getCpuGpuTime(&timeStamp);
479480
if (retVal) {
480-
TimeStampData timeStamp;
481-
retVal = getOSTime()->getCpuGpuTime(&timeStamp);
482-
if (retVal) {
483-
if (DebugManager.flags.EnableDeviceBasedTimestamps.get()) {
484-
auto resolution = getOSTime()->getDynamicDeviceTimerResolution(getHardwareInfo());
485-
*deviceTimestamp = static_cast<uint64_t>(timeStamp.GPUTimeStamp * resolution);
486-
} else
487-
*deviceTimestamp = *hostTimestamp;
488-
}
481+
*hostTimestamp = timeStamp.CPUTimeinNS;
482+
if (DebugManager.flags.EnableDeviceBasedTimestamps.get()) {
483+
auto resolution = getOSTime()->getDynamicDeviceTimerResolution(getHardwareInfo());
484+
*deviceTimestamp = static_cast<uint64_t>(timeStamp.GPUTimeStamp * resolution);
485+
} else
486+
*deviceTimestamp = *hostTimestamp;
489487
}
490488
return retVal;
491489
}

0 commit comments

Comments
 (0)