Calculate CS timestamp based on OA timestamp and frequencies ratio

Changes affect cores up to xe_hpg

Resolves: NEO-7346
Signed-off-by: Katarzyna Cencelewska <katarzyna.cencelewska@intel.com>
This commit is contained in:
Katarzyna Cencelewska
2022-10-28 13:27:05 +00:00
committed by Compute-Runtime-Automation
parent 343371faad
commit bbd75959d5
15 changed files with 97 additions and 61 deletions

View File

@@ -18,10 +18,6 @@ template <>
void HwInfoConfigHw<IGFX_UNKNOWN>::adjustSamplerState(void *sampler, const HardwareInfo &hwInfo) {
}
template <>
void HwInfoConfigHw<IGFX_UNKNOWN>::convertTimestampsFromOaToCsDomain(uint64_t &timestampData) {
}
template <>
uint32_t HwInfoConfigHw<IGFX_UNKNOWN>::getMaxThreadsForWorkgroupInDSSOrSS(const HardwareInfo &hwInfo, uint32_t maxNumEUsPerSubSlice, uint32_t maxNumEUsPerDualSubSlice) const {
return 0;

View File

@@ -10,10 +10,16 @@
#include "shared/source/os_interface/windows/os_time_win.h"
namespace NEO {
struct MockDeviceTimeWddm : DeviceTimeWddm {
using DeviceTimeWddm::convertTimestampsFromOaToCsDomain;
};
class MockOSTimeWin : public OSTimeWin {
public:
MockOSTimeWin(Wddm *wddm) {
this->deviceTime = std::make_unique<DeviceTimeWddm>(wddm);
}
void convertTimestampsFromOaToCsDomain(HardwareInfo const &hwInfo, uint64_t &timestampData, uint64_t freqOA, uint64_t freqCS) {
static_cast<MockDeviceTimeWddm *>(this->deviceTime.get())->convertTimestampsFromOaToCsDomain(hwInfo, timestampData, freqOA, freqCS);
}
};
} // namespace NEO

View File

@@ -9,8 +9,11 @@
#include "shared/source/os_interface/windows/wddm/wddm.h"
#include "shared/test/common/fixtures/device_fixture.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/raii_hw_helper.h"
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "shared/test/common/mocks/mock_ostime_win.h"
#include "shared/test/common/mocks/mock_wddm.h"
#include "shared/test/common/test_macros/test.h"
#include "shared/test/common/test_macros/hw_test.h"
using DeviceTest = Test<DeviceFixture>;
@@ -55,3 +58,69 @@ TEST_F(DeviceTest, GivenDeviceWhenGetAdapterMaskThenMaskIsSet) {
EXPECT_EQ(nodeMask, 1u);
}
typedef ::testing::Test MockOSTimeWinTest;
TEST_F(MockOSTimeWinTest, whenCreatingTimerThenResolutionIsSetCorrectly) {
MockExecutionEnvironment executionEnvironment;
RootDeviceEnvironment rootDeviceEnvironment(executionEnvironment);
auto wddmMock = new WddmMock(rootDeviceEnvironment);
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
wddmMock->init();
wddmMock->timestampFrequency = 1000;
std::unique_ptr<MockOSTimeWin> timeWin(new MockOSTimeWin(wddmMock));
double res = 0.0;
res = timeWin->getDynamicDeviceTimerResolution(device->getHardwareInfo());
EXPECT_EQ(res, 1e+06);
}
template <typename GfxFamily>
class TestMockHwHelper : public HwHelperHw<GfxFamily> {
public:
bool isTimestampShiftRequired() const override {
return shiftRequired;
}
uint32_t shiftRequired = true;
};
HWTEST_F(MockOSTimeWinTest, whenConvertingTimestampsToCsDomainThenTimestampDataAreSetCorrectly) {
MockExecutionEnvironment executionEnvironment;
RootDeviceEnvironment rootDeviceEnvironment(executionEnvironment);
auto wddmMock = new WddmMock(rootDeviceEnvironment);
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
wddmMock->init();
auto hwInfo = wddmMock->getRootDeviceEnvironment().getHardwareInfo();
RAIIHwHelperFactory<TestMockHwHelper<FamilyType>> hwHelperBackup{hwInfo->platform.eRenderCoreFamily};
std::unique_ptr<MockOSTimeWin> timeWin(new MockOSTimeWin(wddmMock));
uint64_t timestampData = 0x1234;
uint64_t freqOA = 1;
uint64_t freqCS = 0;
auto expectedGpuTicksWhenNotChange = timestampData;
timeWin->convertTimestampsFromOaToCsDomain(*hwInfo, timestampData, freqOA, freqCS);
EXPECT_EQ(expectedGpuTicksWhenNotChange, timestampData);
freqCS = 1;
timeWin->convertTimestampsFromOaToCsDomain(*hwInfo, timestampData, freqOA, freqCS);
EXPECT_EQ(expectedGpuTicksWhenNotChange, timestampData);
freqOA = 2;
uint64_t ratio = freqOA / freqCS;
auto expectedGpuTicksWhenRatioBiggerThanOne = timestampData / ratio;
timeWin->convertTimestampsFromOaToCsDomain(*hwInfo, timestampData, freqOA, freqCS);
EXPECT_EQ(expectedGpuTicksWhenRatioBiggerThanOne, timestampData);
hwHelperBackup.mockHwHelper.shiftRequired = false;
freqOA = 1;
freqCS = 0;
expectedGpuTicksWhenNotChange = timestampData;
timeWin->convertTimestampsFromOaToCsDomain(*hwInfo, timestampData, freqOA, freqCS);
EXPECT_EQ(expectedGpuTicksWhenNotChange, timestampData);
freqCS = 1;
timeWin->convertTimestampsFromOaToCsDomain(*hwInfo, timestampData, freqOA, freqCS);
EXPECT_EQ(expectedGpuTicksWhenNotChange, timestampData);
freqOA = 2;
timeWin->convertTimestampsFromOaToCsDomain(*hwInfo, timestampData, freqOA, freqCS);
EXPECT_EQ(expectedGpuTicksWhenNotChange, timestampData);
}

View File

@@ -196,14 +196,6 @@ TEST_F(HwInfoConfigTest, givenInvalidHwInfoWhenParsingHwInfoConfigThenErrorIsRet
EXPECT_FALSE(success);
}
HWTEST_F(HwInfoConfigTest, whenConvertingTimestampsToCsDomainThenNothingIsChanged) {
auto hwInfoConfig = HwInfoConfig::get(pInHwInfo.platform.eProductFamily);
uint64_t timestampData = 0x1234;
uint64_t initialData = timestampData;
hwInfoConfig->convertTimestampsFromOaToCsDomain(timestampData);
EXPECT_EQ(initialData, timestampData);
}
HWTEST_F(HwInfoConfigTest, whenOverrideGfxPartitionLayoutForWslThenReturnFalse) {
auto hwInfoConfig = HwInfoConfig::get(pInHwInfo.platform.eProductFamily);
EXPECT_FALSE(hwInfoConfig->overrideGfxPartitionLayoutForWsl());

View File

@@ -19,16 +19,6 @@ using namespace NEO;
using HwInfoConfigTestDg2 = ::testing::Test;
DG2TEST_F(HwInfoConfigTestDg2, whenConvertingTimestampsToCsDomainThenGpuTicksAreShifted) {
auto hwInfoConfig = HwInfoConfig::get(defaultHwInfo->platform.eProductFamily);
uint64_t gpuTicks = 0x12345u;
auto expectedGpuTicks = gpuTicks >> 1;
hwInfoConfig->convertTimestampsFromOaToCsDomain(gpuTicks);
EXPECT_EQ(expectedGpuTicks, gpuTicks);
}
DG2TEST_F(HwInfoConfigTestDg2, givenDg2ConfigWhenSetupHardwareInfoBaseThenGtSystemInfoIsCorrect) {
HardwareInfo hwInfo = *defaultHwInfo;
GT_SYSTEM_INFO &gtSystemInfo = hwInfo.gtSystemInfo;