Skip to content

Commit 2b0b223

Browse files
Windows: Use timestamp frequency from adapter info
Related-To: NEO-5435 Signed-off-by: Mateusz Jablonski <[email protected]>
1 parent 0ca1cdc commit 2b0b223

File tree

7 files changed

+21
-9
lines changed

7 files changed

+21
-9
lines changed

opencl/test/unit_test/device/device_win_timers_tests.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2020 Intel Corporation
2+
* Copyright (C) 2017-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -30,11 +30,13 @@ TEST_F(MockOSTimeWinTest, WhenCreatingTimerThenResolutionIsSetCorrectly) {
3030

3131
wddmMock->init();
3232

33+
wddmMock->timestampFrequency = 1000;
34+
3335
std::unique_ptr<MockOSTimeWin> timeWin(new MockOSTimeWin(wddmMock));
3436

3537
double res = 0.0;
3638
res = timeWin->getDynamicDeviceTimerResolution(device->getHardwareInfo());
37-
EXPECT_EQ(res, 1e+09);
39+
EXPECT_EQ(res, 1e+06);
3840
}
3941

4042
} // namespace ULT

opencl/test/unit_test/mocks/mock_wddm.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2020 Intel Corporation
2+
* Copyright (C) 2018-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -44,6 +44,7 @@ class WddmMock : public Wddm {
4444
using Wddm::residencyLogger;
4545
using Wddm::rootDeviceEnvironment;
4646
using Wddm::temporaryResources;
47+
using Wddm::timestampFrequency;
4748
using Wddm::wddmInterface;
4849

4950
WddmMock(std::unique_ptr<HwDeviceId> hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) : Wddm(std::move(hwDeviceId), rootDeviceEnvironment) {}

shared/source/os_interface/windows/os_time_win.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,9 @@ double OSTimeWin::getHostTimerResolution() const {
9999
}
100100

101101
double OSTimeWin::getDynamicDeviceTimerResolution(HardwareInfo const &hwInfo) const {
102-
double retVal = 0;
103-
TimeStampDataHeader escapeInfo = {0};
104-
105-
if (runEscape(wddm, escapeInfo)) {
106-
retVal = 1000000000.0 / (double)escapeInfo.m_Data.m_Out.gpuPerfFreq;
102+
double retVal = 0u;
103+
if (wddm) {
104+
retVal = 1000000000.0 / static_cast<double>(wddm->getTimestampFrequency());
107105
}
108106

109107
return retVal;

shared/source/os_interface/windows/wddm/wddm.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ bool Wddm::queryAdapterInfo() {
150150
systemSharedMemory = adapterInfo.SystemSharedMemory;
151151
dedicatedVideoMemory = adapterInfo.DedicatedVideoMemory;
152152
maxRenderFrequency = adapterInfo.MaxRenderFreq;
153+
timestampFrequency = adapterInfo.GfxTimeStampFreq;
153154
instrumentationEnabled = adapterInfo.Caps.InstrumentationIsEnabled != 0;
154155
}
155156

shared/source/os_interface/windows/wddm/wddm.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ class Wddm {
161161

162162
const RootDeviceEnvironment &getRootDeviceEnvironment() const { return rootDeviceEnvironment; }
163163

164+
const uint32_t getTimestampFrequency() const { return timestampFrequency; }
165+
164166
protected:
165167
std::unique_ptr<HwDeviceId> hwDeviceId;
166168
D3DKMT_HANDLE device = 0;
@@ -180,6 +182,7 @@ class Wddm {
180182
uint64_t systemSharedMemory = 0;
181183
uint64_t dedicatedVideoMemory = 0;
182184
uint32_t maxRenderFrequency = 0;
185+
uint32_t timestampFrequency = 0u;
183186
bool instrumentationEnabled = false;
184187
std::string deviceRegistryPath;
185188
RootDeviceEnvironment &rootDeviceEnvironment;

shared/test/unit_test/mock_gdi/mock_gdi.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ NTSTATUS __stdcall D3DKMTQueryAdapterInfo(IN CONST D3DKMT_QUERYADAPTERINFO *quer
291291
adapterInfo->GfxMemorySize = 2181038080;
292292
adapterInfo->SystemSharedMemory = 4249540608;
293293
adapterInfo->SystemVideoMemory = 0;
294+
adapterInfo->GfxTimeStampFreq = 1;
294295

295296
adapterInfo->GfxPartition.Standard.Base = gAdapterInfo.GfxPartition.Standard.Base;
296297
adapterInfo->GfxPartition.Standard.Limit = gAdapterInfo.GfxPartition.Standard.Limit;

shared/test/unit_test/os_interface/windows/wddm_tests.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2020 Intel Corporation
2+
* Copyright (C) 2018-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -39,6 +39,12 @@ TEST_F(WddmTests, whenInitializingWddmThenSetMinAddressToCorrectValue) {
3939
ASSERT_EQ(expectedMinAddress, wddm->getWddmMinAddress());
4040
}
4141

42+
TEST_F(WddmTests, whenInitializingWddmThenSetTimestampFrequencyToCorrectValue) {
43+
EXPECT_EQ(0u, wddm->timestampFrequency);
44+
init();
45+
EXPECT_EQ(1u, wddm->timestampFrequency);
46+
}
47+
4248
TEST_F(WddmTests, givenWddmWhenPassesCorrectHandleToVerifySharedHandleThenReturnTrue) {
4349
init();
4450
D3DKMT_HANDLE handle = 1u;

0 commit comments

Comments
 (0)