Refactor: pass gfxCoreHelper to convertTimestampsFromOaToCsDomain

Related-To: NEO-6853
Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
This commit is contained in:
Kamil Kopryk 2023-01-01 18:02:40 +00:00 committed by Compute-Runtime-Automation
parent fd2f79df08
commit 1dc4afe8ab
6 changed files with 25 additions and 23 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018-2022 Intel Corporation * Copyright (C) 2018-2023 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@ -21,8 +21,8 @@ bool DeviceTimeWddm::getCpuGpuTime(TimeStampData *pGpuCpuTime, OSTime *osTime) {
TimeStampDataHeader escapeInfo = {}; TimeStampDataHeader escapeInfo = {};
if (runEscape(wddm, escapeInfo)) { if (runEscape(wddm, escapeInfo)) {
auto hwInfo = wddm->getRootDeviceEnvironment().getHardwareInfo(); auto &gfxCoreHelper = wddm->getRootDeviceEnvironment().getHelper<GfxCoreHelper>();
convertTimestampsFromOaToCsDomain(*hwInfo, escapeInfo.m_Data.m_Out.gpuPerfTicks, escapeInfo.m_Data.m_Out.gpuPerfFreq, static_cast<uint64_t>(wddm->getTimestampFrequency())); convertTimestampsFromOaToCsDomain(gfxCoreHelper, escapeInfo.m_Data.m_Out.gpuPerfTicks, escapeInfo.m_Data.m_Out.gpuPerfFreq, static_cast<uint64_t>(wddm->getTimestampFrequency()));
osTime->getCpuTime(&pGpuCpuTime->CPUTimeinNS); osTime->getCpuTime(&pGpuCpuTime->CPUTimeinNS);
pGpuCpuTime->GPUTimeStamp = (unsigned long long)escapeInfo.m_Data.m_Out.gpuPerfTicks; pGpuCpuTime->GPUTimeStamp = (unsigned long long)escapeInfo.m_Data.m_Out.gpuPerfTicks;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018-2022 Intel Corporation * Copyright (C) 2018-2023 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@ -21,8 +21,8 @@ bool DeviceTimeWddm::getCpuGpuTime(TimeStampData *pGpuCpuTime, OSTime *osTime) {
TimeStampDataHeader escapeInfo = {}; TimeStampDataHeader escapeInfo = {};
if (runEscape(wddm, escapeInfo)) { if (runEscape(wddm, escapeInfo)) {
auto hwInfo = wddm->getRootDeviceEnvironment().getHardwareInfo(); auto &gfxCoreHelper = wddm->getRootDeviceEnvironment().getHelper<GfxCoreHelper>();
convertTimestampsFromOaToCsDomain(*hwInfo, escapeInfo.m_Data.m_Out.gpuPerfTicks, escapeInfo.m_Data.m_Out.gpuPerfFreq, static_cast<uint64_t>(wddm->getTimestampFrequency())); 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 * double cpuNanoseconds = escapeInfo.m_Data.m_Out.cpuPerfTicks *
(1000000000.0 / escapeInfo.m_Data.m_Out.cpuPerfFreq); (1000000000.0 / escapeInfo.m_Data.m_Out.cpuPerfFreq);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018-2022 Intel Corporation * Copyright (C) 2018-2023 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@ -71,8 +71,8 @@ uint64_t DeviceTimeWddm::getDynamicDeviceTimerClock(HardwareInfo const &hwInfo)
return retVal; return retVal;
} }
void DeviceTimeWddm::convertTimestampsFromOaToCsDomain(HardwareInfo const &hwInfo, uint64_t &timestampData, uint64_t freqOA, uint64_t freqCS) { void DeviceTimeWddm::convertTimestampsFromOaToCsDomain(const GfxCoreHelper &gfxCoreHelper, uint64_t &timestampData, uint64_t freqOA, uint64_t freqCS) {
auto &gfxCoreHelper = GfxCoreHelper::get(hwInfo.platform.eRenderCoreFamily);
if (gfxCoreHelper.isTimestampShiftRequired() && freqCS > 0 && freqOA > 0) { if (gfxCoreHelper.isTimestampShiftRequired() && freqCS > 0 && freqOA > 0) {
auto freqRatio = static_cast<double>(freqOA) / static_cast<double>(freqCS); auto freqRatio = static_cast<double>(freqOA) / static_cast<double>(freqCS);
timestampData = static_cast<uint64_t>(timestampData / freqRatio); timestampData = static_cast<uint64_t>(timestampData / freqRatio);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018-2022 Intel Corporation * Copyright (C) 2018-2023 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@ -13,6 +13,7 @@
namespace NEO { namespace NEO {
class Wddm; class Wddm;
class GfxCoreHelper;
struct TimeStampDataHeader; struct TimeStampDataHeader;
class DeviceTimeWddm : public DeviceTime { class DeviceTimeWddm : public DeviceTime {
@ -24,7 +25,7 @@ class DeviceTimeWddm : public DeviceTime {
protected: protected:
MOCKABLE_VIRTUAL bool runEscape(Wddm *wddm, TimeStampDataHeader &escapeInfo); MOCKABLE_VIRTUAL bool runEscape(Wddm *wddm, TimeStampDataHeader &escapeInfo);
void convertTimestampsFromOaToCsDomain(HardwareInfo const &hwInfo, uint64_t &timestampData, uint64_t freqOA, uint64_t freqCS); void convertTimestampsFromOaToCsDomain(const GfxCoreHelper &gfxCoreHelper, uint64_t &timestampData, uint64_t freqOA, uint64_t freqCS);
Wddm *wddm = nullptr; Wddm *wddm = nullptr;
}; };

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018-2022 Intel Corporation * Copyright (C) 2018-2023 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@ -18,8 +18,8 @@ class MockOSTimeWin : public OSTimeWin {
MockOSTimeWin(Wddm *wddm) { MockOSTimeWin(Wddm *wddm) {
this->deviceTime = std::make_unique<DeviceTimeWddm>(wddm); this->deviceTime = std::make_unique<DeviceTimeWddm>(wddm);
} }
void convertTimestampsFromOaToCsDomain(HardwareInfo const &hwInfo, uint64_t &timestampData, uint64_t freqOA, uint64_t freqCS) { void convertTimestampsFromOaToCsDomain(const GfxCoreHelper &gfxCoreHelper, uint64_t &timestampData, uint64_t freqOA, uint64_t freqCS) {
static_cast<MockDeviceTimeWddm *>(this->deviceTime.get())->convertTimestampsFromOaToCsDomain(hwInfo, timestampData, freqOA, freqCS); static_cast<MockDeviceTimeWddm *>(this->deviceTime.get())->convertTimestampsFromOaToCsDomain(gfxCoreHelper, timestampData, freqOA, freqCS);
} }
}; };
} // namespace NEO } // namespace NEO

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2022 Intel Corporation * Copyright (C) 2022-2023 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@ -95,47 +95,48 @@ HWTEST_F(MockOSTimeWinTest, whenConvertingTimestampsToCsDomainThenTimestampDataA
wddmMock->init(); wddmMock->init();
auto hwInfo = wddmMock->getRootDeviceEnvironment().getHardwareInfo(); auto hwInfo = wddmMock->getRootDeviceEnvironment().getHardwareInfo();
RAIIGfxCoreHelperFactory<TestMockGfxCoreHelper<FamilyType>> gfxCoreHelperBackup{hwInfo->platform.eRenderCoreFamily}; RAIIGfxCoreHelperFactory<TestMockGfxCoreHelper<FamilyType>> gfxCoreHelperBackup{hwInfo->platform.eRenderCoreFamily};
auto &gfxCoreHelper = gfxCoreHelperBackup.mockGfxCoreHelper;
std::unique_ptr<MockOSTimeWin> timeWin(new MockOSTimeWin(wddmMock)); std::unique_ptr<MockOSTimeWin> timeWin(new MockOSTimeWin(wddmMock));
uint64_t timestampData = 0x1234; uint64_t timestampData = 0x1234;
uint64_t freqOA = 5; uint64_t freqOA = 5;
uint64_t freqCS = 2; uint64_t freqCS = 2;
double ratio = static_cast<double>(freqOA) / static_cast<double>(freqCS); double ratio = static_cast<double>(freqOA) / static_cast<double>(freqCS);
auto expectedGpuTicksWhenOAfreqBiggerThanCSfreq = static_cast<uint64_t>(timestampData / ratio); auto expectedGpuTicksWhenOAfreqBiggerThanCSfreq = static_cast<uint64_t>(timestampData / ratio);
timeWin->convertTimestampsFromOaToCsDomain(*hwInfo, timestampData, freqOA, freqCS); timeWin->convertTimestampsFromOaToCsDomain(gfxCoreHelper, timestampData, freqOA, freqCS);
EXPECT_EQ(expectedGpuTicksWhenOAfreqBiggerThanCSfreq, timestampData); EXPECT_EQ(expectedGpuTicksWhenOAfreqBiggerThanCSfreq, timestampData);
freqOA = 2; freqOA = 2;
freqCS = 5; freqCS = 5;
ratio = static_cast<double>(freqCS) / static_cast<double>(freqOA); ratio = static_cast<double>(freqCS) / static_cast<double>(freqOA);
auto expectedGpuTicksWhenCSfreqBiggerThanOAfreq = static_cast<uint64_t>(timestampData * ratio); auto expectedGpuTicksWhenCSfreqBiggerThanOAfreq = static_cast<uint64_t>(timestampData * ratio);
timeWin->convertTimestampsFromOaToCsDomain(*hwInfo, timestampData, freqOA, freqCS); timeWin->convertTimestampsFromOaToCsDomain(gfxCoreHelper, timestampData, freqOA, freqCS);
EXPECT_EQ(expectedGpuTicksWhenCSfreqBiggerThanOAfreq, timestampData); EXPECT_EQ(expectedGpuTicksWhenCSfreqBiggerThanOAfreq, timestampData);
freqOA = 1; freqOA = 1;
freqCS = 0; freqCS = 0;
auto expectedGpuTicksWhenNotChange = timestampData; auto expectedGpuTicksWhenNotChange = timestampData;
timeWin->convertTimestampsFromOaToCsDomain(*hwInfo, timestampData, freqOA, freqCS); timeWin->convertTimestampsFromOaToCsDomain(gfxCoreHelper, timestampData, freqOA, freqCS);
EXPECT_EQ(expectedGpuTicksWhenNotChange, timestampData); EXPECT_EQ(expectedGpuTicksWhenNotChange, timestampData);
freqOA = 1; freqOA = 1;
freqCS = 1; freqCS = 1;
timeWin->convertTimestampsFromOaToCsDomain(*hwInfo, timestampData, freqOA, freqCS); timeWin->convertTimestampsFromOaToCsDomain(gfxCoreHelper, timestampData, freqOA, freqCS);
EXPECT_EQ(expectedGpuTicksWhenNotChange, timestampData); EXPECT_EQ(expectedGpuTicksWhenNotChange, timestampData);
freqOA = 0; freqOA = 0;
freqCS = 1; freqCS = 1;
timeWin->convertTimestampsFromOaToCsDomain(*hwInfo, timestampData, freqOA, freqCS); timeWin->convertTimestampsFromOaToCsDomain(gfxCoreHelper, timestampData, freqOA, freqCS);
EXPECT_EQ(expectedGpuTicksWhenNotChange, timestampData); EXPECT_EQ(expectedGpuTicksWhenNotChange, timestampData);
gfxCoreHelperBackup.mockGfxCoreHelper.shiftRequired = false; gfxCoreHelperBackup.mockGfxCoreHelper.shiftRequired = false;
freqOA = 1; freqOA = 1;
freqCS = 0; freqCS = 0;
expectedGpuTicksWhenNotChange = timestampData; expectedGpuTicksWhenNotChange = timestampData;
timeWin->convertTimestampsFromOaToCsDomain(*hwInfo, timestampData, freqOA, freqCS); timeWin->convertTimestampsFromOaToCsDomain(gfxCoreHelper, timestampData, freqOA, freqCS);
EXPECT_EQ(expectedGpuTicksWhenNotChange, timestampData); EXPECT_EQ(expectedGpuTicksWhenNotChange, timestampData);
freqOA = 0; freqOA = 0;
freqCS = 1; freqCS = 1;
timeWin->convertTimestampsFromOaToCsDomain(*hwInfo, timestampData, freqOA, freqCS); timeWin->convertTimestampsFromOaToCsDomain(gfxCoreHelper, timestampData, freqOA, freqCS);
EXPECT_EQ(expectedGpuTicksWhenNotChange, timestampData); EXPECT_EQ(expectedGpuTicksWhenNotChange, timestampData);
freqOA = 2; freqOA = 2;
freqCS = 1; freqCS = 1;
timeWin->convertTimestampsFromOaToCsDomain(*hwInfo, timestampData, freqOA, freqCS); timeWin->convertTimestampsFromOaToCsDomain(gfxCoreHelper, timestampData, freqOA, freqCS);
EXPECT_EQ(expectedGpuTicksWhenNotChange, timestampData); EXPECT_EQ(expectedGpuTicksWhenNotChange, timestampData);
} }