Skip to content

Commit 5e36b1f

Browse files
Revert "Calculate CS timestamp based on OA timestamp and frequencies ratio"
This reverts commit 03c5283. Signed-off-by: Compute-Runtime-Validation <[email protected]>
1 parent b2c80be commit 5e36b1f

File tree

13 files changed

+60
-59
lines changed

13 files changed

+60
-59
lines changed

opencl/test/unit_test/device/windows/device_windows_tests.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
*/
77

88
#include "shared/source/execution_environment/root_device_environment.h"
9+
#include "shared/test/common/mocks/mock_execution_environment.h"
10+
#include "shared/test/common/mocks/mock_ostime.h"
11+
#include "shared/test/common/mocks/mock_ostime_win.h"
912
#include "shared/test/common/mocks/mock_wddm.h"
1013
#include "shared/test/common/test_macros/test.h"
1114

@@ -15,6 +18,25 @@ using namespace NEO;
1518

1619
namespace ULT {
1720

21+
typedef ::testing::Test MockOSTimeWinTest;
22+
23+
TEST_F(MockOSTimeWinTest, whenCreatingTimerThenResolutionIsSetCorrectly) {
24+
MockExecutionEnvironment executionEnvironment;
25+
RootDeviceEnvironment rootDeviceEnvironment(executionEnvironment);
26+
auto wddmMock = new WddmMock(rootDeviceEnvironment);
27+
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
28+
29+
wddmMock->init();
30+
31+
wddmMock->timestampFrequency = 1000;
32+
33+
std::unique_ptr<MockOSTimeWin> timeWin(new MockOSTimeWin(wddmMock));
34+
35+
double res = 0.0;
36+
res = timeWin->getDynamicDeviceTimerResolution(device->getHardwareInfo());
37+
EXPECT_EQ(res, 1e+06);
38+
}
39+
1840
TEST(GetDeviceInfo, givenClDeviceWhenGettingDeviceInfoThenCorrectAdapterLuidIsReturned) {
1941
auto clDevice = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
2042
clDevice->executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(new NEO::OSInterface);

shared/source/os_interface/hw_info_config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class HwInfoConfig {
6060
virtual uint64_t getSharedSystemMemCapabilities(const HardwareInfo *hwInfo) = 0;
6161
virtual void getKernelExtendedProperties(uint32_t *fp16, uint32_t *fp32, uint32_t *fp64) = 0;
6262
virtual std::vector<int32_t> getKernelSupportedThreadArbitrationPolicies() = 0;
63+
virtual void convertTimestampsFromOaToCsDomain(uint64_t &timestampData) = 0;
6364
virtual uint32_t getDeviceMemoryMaxClkRate(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) = 0;
6465
virtual uint64_t getDeviceMemoryPhysicalSizeInBytes(const OSInterface *osIface, uint32_t subDeviceIndex) = 0;
6566
virtual uint64_t getDeviceMemoryMaxBandWidthInBytesPerSecond(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) = 0;
@@ -195,6 +196,7 @@ class HwInfoConfigHw : public HwInfoConfig {
195196
uint64_t getSharedSystemMemCapabilities(const HardwareInfo *hwInfo) override;
196197
void getKernelExtendedProperties(uint32_t *fp16, uint32_t *fp32, uint32_t *fp64) override;
197198
std::vector<int32_t> getKernelSupportedThreadArbitrationPolicies() override;
199+
void convertTimestampsFromOaToCsDomain(uint64_t &timestampData) override;
198200
uint32_t getDeviceMemoryMaxClkRate(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) override;
199201
uint64_t getDeviceMemoryPhysicalSizeInBytes(const OSInterface *osIface, uint32_t subDeviceIndex) override;
200202
uint64_t getDeviceMemoryMaxBandWidthInBytesPerSecond(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) override;

shared/source/os_interface/hw_info_config.inl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ std::vector<int32_t> HwInfoConfigHw<gfxProduct>::getKernelSupportedThreadArbitra
4242
return PreambleHelper<GfxFamily>::getSupportedThreadArbitrationPolicies();
4343
}
4444

45+
template <PRODUCT_FAMILY gfxProduct>
46+
void HwInfoConfigHw<gfxProduct>::convertTimestampsFromOaToCsDomain(uint64_t &timestampData){};
47+
4548
template <PRODUCT_FAMILY gfxProduct>
4649
void HwInfoConfigHw<gfxProduct>::adjustPlatformForProductFamily(HardwareInfo *hwInfo) {}
4750

shared/source/os_interface/windows/device_time_gpu_cpu_drm_or_wddm.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ bool DeviceTimeWddm::getCpuGpuTime(TimeStampData *pGpuCpuTime, OSTime *osTime) {
2121
TimeStampDataHeader escapeInfo = {};
2222

2323
if (runEscape(wddm, escapeInfo)) {
24-
convertTimestampsFromOaToCsDomain(escapeInfo.m_Data.m_Out.gpuPerfTicks, escapeInfo.m_Data.m_Out.gpuPerfFreq, static_cast<uint64_t>(wddm->getTimestampFrequency()));
24+
auto productFamily = wddm->getRootDeviceEnvironment().getHardwareInfo()->platform.eProductFamily;
25+
auto *hwInfoConfig = HwInfoConfig::get(productFamily);
26+
hwInfoConfig->convertTimestampsFromOaToCsDomain(escapeInfo.m_Data.m_Out.gpuPerfTicks);
2527

2628
osTime->getCpuTime(&pGpuCpuTime->CPUTimeinNS);
2729
pGpuCpuTime->GPUTimeStamp = (unsigned long long)escapeInfo.m_Data.m_Out.gpuPerfTicks;

shared/source/os_interface/windows/device_time_gpu_cpu_wddm.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ bool DeviceTimeWddm::getCpuGpuTime(TimeStampData *pGpuCpuTime, OSTime *osTime) {
2121
TimeStampDataHeader escapeInfo = {};
2222

2323
if (runEscape(wddm, escapeInfo)) {
24-
convertTimestampsFromOaToCsDomain(escapeInfo.m_Data.m_Out.gpuPerfTicks, escapeInfo.m_Data.m_Out.gpuPerfFreq, static_cast<uint64_t>(wddm->getTimestampFrequency()));
24+
auto productFamily = wddm->getRootDeviceEnvironment().getHardwareInfo()->platform.eProductFamily;
25+
auto *hwInfoConfig = HwInfoConfig::get(productFamily);
26+
hwInfoConfig->convertTimestampsFromOaToCsDomain(escapeInfo.m_Data.m_Out.gpuPerfTicks);
2527
double cpuNanoseconds = escapeInfo.m_Data.m_Out.cpuPerfTicks *
2628
(1000000000.0 / escapeInfo.m_Data.m_Out.cpuPerfFreq);
2729

shared/source/os_interface/windows/device_time_wddm.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,4 @@ uint64_t DeviceTimeWddm::getDynamicDeviceTimerClock(HardwareInfo const &hwInfo)
7070
return retVal;
7171
}
7272

73-
void DeviceTimeWddm::convertTimestampsFromOaToCsDomain(uint64_t &timestampData, uint64_t freqOA, uint64_t freqCS) {
74-
if (freqCS > 0) {
75-
auto freqRatio = freqOA / freqCS;
76-
timestampData /= freqRatio;
77-
}
78-
};
7973
} // namespace NEO

shared/source/os_interface/windows/device_time_wddm.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class DeviceTimeWddm : public DeviceTime {
2424

2525
protected:
2626
MOCKABLE_VIRTUAL bool runEscape(Wddm *wddm, TimeStampDataHeader &escapeInfo);
27-
void convertTimestampsFromOaToCsDomain(uint64_t &timestampData, uint64_t freqOA, uint64_t freqCS);
2827
Wddm *wddm = nullptr;
2928
};
3029

shared/source/xe_hpg_core/dg2/os_agnostic_hw_info_config_dg2.inl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ uint32_t HwInfoConfigHw<gfxProduct>::computeMaxNeededSubSliceSpace(const Hardwar
169169
return maxSubSlice;
170170
}
171171

172+
template <>
173+
void HwInfoConfigHw<gfxProduct>::convertTimestampsFromOaToCsDomain(uint64_t &timestampData) {
174+
timestampData >>= 1;
175+
}
176+
172177
template <>
173178
bool HwInfoConfigHw<gfxProduct>::isFlushTaskAllowed() const {
174179
return true;

shared/test/common/mocks/mock_hw_info_config.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ template <>
1818
void HwInfoConfigHw<IGFX_UNKNOWN>::adjustSamplerState(void *sampler, const HardwareInfo &hwInfo) {
1919
}
2020

21+
template <>
22+
void HwInfoConfigHw<IGFX_UNKNOWN>::convertTimestampsFromOaToCsDomain(uint64_t &timestampData) {
23+
}
24+
2125
template <>
2226
uint32_t HwInfoConfigHw<IGFX_UNKNOWN>::getMaxThreadsForWorkgroupInDSSOrSS(const HardwareInfo &hwInfo, uint32_t maxNumEUsPerSubSlice, uint32_t maxNumEUsPerDualSubSlice) const {
2327
return 0;

shared/test/common/mocks/mock_ostime_win.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,10 @@
1010
#include "shared/source/os_interface/windows/os_time_win.h"
1111

1212
namespace NEO {
13-
struct MockDeviceTimeWddm : DeviceTimeWddm {
14-
using DeviceTimeWddm::convertTimestampsFromOaToCsDomain;
15-
};
1613
class MockOSTimeWin : public OSTimeWin {
1714
public:
1815
MockOSTimeWin(Wddm *wddm) {
1916
this->deviceTime = std::make_unique<DeviceTimeWddm>(wddm);
2017
}
21-
void convertTimestampsFromOaToCsDomain(uint64_t &timestampData, uint64_t freqOA, uint64_t freqCS) {
22-
static_cast<MockDeviceTimeWddm *>(this->deviceTime.get())->convertTimestampsFromOaToCsDomain(timestampData, freqOA, freqCS);
23-
}
2418
};
2519
} // namespace NEO

0 commit comments

Comments
 (0)