Refactor: pass gfxCoreHelper to convertTimestampsFromOaToCsDomain
Related-To: NEO-6853 Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
This commit is contained in:
parent
fd2f79df08
commit
1dc4afe8ab
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -21,8 +21,8 @@ bool DeviceTimeWddm::getCpuGpuTime(TimeStampData *pGpuCpuTime, OSTime *osTime) {
|
|||
TimeStampDataHeader escapeInfo = {};
|
||||
|
||||
if (runEscape(wddm, escapeInfo)) {
|
||||
auto hwInfo = wddm->getRootDeviceEnvironment().getHardwareInfo();
|
||||
convertTimestampsFromOaToCsDomain(*hwInfo, escapeInfo.m_Data.m_Out.gpuPerfTicks, escapeInfo.m_Data.m_Out.gpuPerfFreq, static_cast<uint64_t>(wddm->getTimestampFrequency()));
|
||||
auto &gfxCoreHelper = wddm->getRootDeviceEnvironment().getHelper<GfxCoreHelper>();
|
||||
convertTimestampsFromOaToCsDomain(gfxCoreHelper, escapeInfo.m_Data.m_Out.gpuPerfTicks, escapeInfo.m_Data.m_Out.gpuPerfFreq, static_cast<uint64_t>(wddm->getTimestampFrequency()));
|
||||
|
||||
osTime->getCpuTime(&pGpuCpuTime->CPUTimeinNS);
|
||||
pGpuCpuTime->GPUTimeStamp = (unsigned long long)escapeInfo.m_Data.m_Out.gpuPerfTicks;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -21,8 +21,8 @@ bool DeviceTimeWddm::getCpuGpuTime(TimeStampData *pGpuCpuTime, OSTime *osTime) {
|
|||
TimeStampDataHeader escapeInfo = {};
|
||||
|
||||
if (runEscape(wddm, escapeInfo)) {
|
||||
auto hwInfo = wddm->getRootDeviceEnvironment().getHardwareInfo();
|
||||
convertTimestampsFromOaToCsDomain(*hwInfo, escapeInfo.m_Data.m_Out.gpuPerfTicks, escapeInfo.m_Data.m_Out.gpuPerfFreq, static_cast<uint64_t>(wddm->getTimestampFrequency()));
|
||||
auto &gfxCoreHelper = wddm->getRootDeviceEnvironment().getHelper<GfxCoreHelper>();
|
||||
convertTimestampsFromOaToCsDomain(gfxCoreHelper, escapeInfo.m_Data.m_Out.gpuPerfTicks, escapeInfo.m_Data.m_Out.gpuPerfFreq, static_cast<uint64_t>(wddm->getTimestampFrequency()));
|
||||
double cpuNanoseconds = escapeInfo.m_Data.m_Out.cpuPerfTicks *
|
||||
(1000000000.0 / escapeInfo.m_Data.m_Out.cpuPerfFreq);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -71,8 +71,8 @@ uint64_t DeviceTimeWddm::getDynamicDeviceTimerClock(HardwareInfo const &hwInfo)
|
|||
return retVal;
|
||||
}
|
||||
|
||||
void DeviceTimeWddm::convertTimestampsFromOaToCsDomain(HardwareInfo const &hwInfo, uint64_t ×tampData, uint64_t freqOA, uint64_t freqCS) {
|
||||
auto &gfxCoreHelper = GfxCoreHelper::get(hwInfo.platform.eRenderCoreFamily);
|
||||
void DeviceTimeWddm::convertTimestampsFromOaToCsDomain(const GfxCoreHelper &gfxCoreHelper, uint64_t ×tampData, uint64_t freqOA, uint64_t freqCS) {
|
||||
|
||||
if (gfxCoreHelper.isTimestampShiftRequired() && freqCS > 0 && freqOA > 0) {
|
||||
auto freqRatio = static_cast<double>(freqOA) / static_cast<double>(freqCS);
|
||||
timestampData = static_cast<uint64_t>(timestampData / freqRatio);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -13,6 +13,7 @@
|
|||
|
||||
namespace NEO {
|
||||
class Wddm;
|
||||
class GfxCoreHelper;
|
||||
struct TimeStampDataHeader;
|
||||
|
||||
class DeviceTimeWddm : public DeviceTime {
|
||||
|
@ -24,7 +25,7 @@ class DeviceTimeWddm : public DeviceTime {
|
|||
|
||||
protected:
|
||||
MOCKABLE_VIRTUAL bool runEscape(Wddm *wddm, TimeStampDataHeader &escapeInfo);
|
||||
void convertTimestampsFromOaToCsDomain(HardwareInfo const &hwInfo, uint64_t ×tampData, uint64_t freqOA, uint64_t freqCS);
|
||||
void convertTimestampsFromOaToCsDomain(const GfxCoreHelper &gfxCoreHelper, uint64_t ×tampData, uint64_t freqOA, uint64_t freqCS);
|
||||
Wddm *wddm = nullptr;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -18,8 +18,8 @@ class MockOSTimeWin : public OSTimeWin {
|
|||
MockOSTimeWin(Wddm *wddm) {
|
||||
this->deviceTime = std::make_unique<DeviceTimeWddm>(wddm);
|
||||
}
|
||||
void convertTimestampsFromOaToCsDomain(HardwareInfo const &hwInfo, uint64_t ×tampData, uint64_t freqOA, uint64_t freqCS) {
|
||||
static_cast<MockDeviceTimeWddm *>(this->deviceTime.get())->convertTimestampsFromOaToCsDomain(hwInfo, timestampData, freqOA, freqCS);
|
||||
void convertTimestampsFromOaToCsDomain(const GfxCoreHelper &gfxCoreHelper, uint64_t ×tampData, uint64_t freqOA, uint64_t freqCS) {
|
||||
static_cast<MockDeviceTimeWddm *>(this->deviceTime.get())->convertTimestampsFromOaToCsDomain(gfxCoreHelper, timestampData, freqOA, freqCS);
|
||||
}
|
||||
};
|
||||
} // namespace NEO
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
* Copyright (C) 2022-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -95,47 +95,48 @@ HWTEST_F(MockOSTimeWinTest, whenConvertingTimestampsToCsDomainThenTimestampDataA
|
|||
wddmMock->init();
|
||||
auto hwInfo = wddmMock->getRootDeviceEnvironment().getHardwareInfo();
|
||||
RAIIGfxCoreHelperFactory<TestMockGfxCoreHelper<FamilyType>> gfxCoreHelperBackup{hwInfo->platform.eRenderCoreFamily};
|
||||
auto &gfxCoreHelper = gfxCoreHelperBackup.mockGfxCoreHelper;
|
||||
std::unique_ptr<MockOSTimeWin> timeWin(new MockOSTimeWin(wddmMock));
|
||||
uint64_t timestampData = 0x1234;
|
||||
uint64_t freqOA = 5;
|
||||
uint64_t freqCS = 2;
|
||||
double ratio = static_cast<double>(freqOA) / static_cast<double>(freqCS);
|
||||
auto expectedGpuTicksWhenOAfreqBiggerThanCSfreq = static_cast<uint64_t>(timestampData / ratio);
|
||||
timeWin->convertTimestampsFromOaToCsDomain(*hwInfo, timestampData, freqOA, freqCS);
|
||||
timeWin->convertTimestampsFromOaToCsDomain(gfxCoreHelper, timestampData, freqOA, freqCS);
|
||||
EXPECT_EQ(expectedGpuTicksWhenOAfreqBiggerThanCSfreq, timestampData);
|
||||
freqOA = 2;
|
||||
freqCS = 5;
|
||||
ratio = static_cast<double>(freqCS) / static_cast<double>(freqOA);
|
||||
auto expectedGpuTicksWhenCSfreqBiggerThanOAfreq = static_cast<uint64_t>(timestampData * ratio);
|
||||
timeWin->convertTimestampsFromOaToCsDomain(*hwInfo, timestampData, freqOA, freqCS);
|
||||
timeWin->convertTimestampsFromOaToCsDomain(gfxCoreHelper, timestampData, freqOA, freqCS);
|
||||
EXPECT_EQ(expectedGpuTicksWhenCSfreqBiggerThanOAfreq, timestampData);
|
||||
|
||||
freqOA = 1;
|
||||
freqCS = 0;
|
||||
auto expectedGpuTicksWhenNotChange = timestampData;
|
||||
timeWin->convertTimestampsFromOaToCsDomain(*hwInfo, timestampData, freqOA, freqCS);
|
||||
timeWin->convertTimestampsFromOaToCsDomain(gfxCoreHelper, timestampData, freqOA, freqCS);
|
||||
EXPECT_EQ(expectedGpuTicksWhenNotChange, timestampData);
|
||||
freqOA = 1;
|
||||
freqCS = 1;
|
||||
timeWin->convertTimestampsFromOaToCsDomain(*hwInfo, timestampData, freqOA, freqCS);
|
||||
timeWin->convertTimestampsFromOaToCsDomain(gfxCoreHelper, timestampData, freqOA, freqCS);
|
||||
EXPECT_EQ(expectedGpuTicksWhenNotChange, timestampData);
|
||||
freqOA = 0;
|
||||
freqCS = 1;
|
||||
timeWin->convertTimestampsFromOaToCsDomain(*hwInfo, timestampData, freqOA, freqCS);
|
||||
timeWin->convertTimestampsFromOaToCsDomain(gfxCoreHelper, timestampData, freqOA, freqCS);
|
||||
EXPECT_EQ(expectedGpuTicksWhenNotChange, timestampData);
|
||||
|
||||
gfxCoreHelperBackup.mockGfxCoreHelper.shiftRequired = false;
|
||||
freqOA = 1;
|
||||
freqCS = 0;
|
||||
expectedGpuTicksWhenNotChange = timestampData;
|
||||
timeWin->convertTimestampsFromOaToCsDomain(*hwInfo, timestampData, freqOA, freqCS);
|
||||
timeWin->convertTimestampsFromOaToCsDomain(gfxCoreHelper, timestampData, freqOA, freqCS);
|
||||
EXPECT_EQ(expectedGpuTicksWhenNotChange, timestampData);
|
||||
freqOA = 0;
|
||||
freqCS = 1;
|
||||
timeWin->convertTimestampsFromOaToCsDomain(*hwInfo, timestampData, freqOA, freqCS);
|
||||
timeWin->convertTimestampsFromOaToCsDomain(gfxCoreHelper, timestampData, freqOA, freqCS);
|
||||
EXPECT_EQ(expectedGpuTicksWhenNotChange, timestampData);
|
||||
freqOA = 2;
|
||||
freqCS = 1;
|
||||
timeWin->convertTimestampsFromOaToCsDomain(*hwInfo, timestampData, freqOA, freqCS);
|
||||
timeWin->convertTimestampsFromOaToCsDomain(gfxCoreHelper, timestampData, freqOA, freqCS);
|
||||
EXPECT_EQ(expectedGpuTicksWhenNotChange, timestampData);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue