mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-10 12:53:42 +08:00
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:

committed by
Compute-Runtime-Automation

parent
343371faad
commit
bbd75959d5
@ -6,9 +6,6 @@
|
||||
*/
|
||||
|
||||
#include "shared/source/execution_environment/root_device_environment.h"
|
||||
#include "shared/test/common/mocks/mock_execution_environment.h"
|
||||
#include "shared/test/common/mocks/mock_ostime.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"
|
||||
|
||||
@ -18,25 +15,6 @@ using namespace NEO;
|
||||
|
||||
namespace ULT {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
TEST(GetDeviceInfo, givenClDeviceWhenGettingDeviceInfoThenCorrectAdapterLuidIsReturned) {
|
||||
auto clDevice = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
|
||||
clDevice->executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(new NEO::OSInterface);
|
||||
|
@ -162,6 +162,7 @@ class HwHelper {
|
||||
virtual uint32_t getAmountOfAllocationsToFill() const = 0;
|
||||
virtual bool isChipsetUniqueUUIDSupported() const = 0;
|
||||
virtual bool isSurfaceFormatSupportedForMediaBlockOperation(NEO::GFX3DSTATE_SURFACEFORMAT format) const = 0;
|
||||
virtual bool isTimestampShiftRequired() const = 0;
|
||||
|
||||
protected:
|
||||
HwHelper() = default;
|
||||
@ -406,6 +407,7 @@ class HwHelperHw : public HwHelper {
|
||||
uint32_t getAmountOfAllocationsToFill() const override;
|
||||
bool isChipsetUniqueUUIDSupported() const override;
|
||||
bool isSurfaceFormatSupportedForMediaBlockOperation(NEO::GFX3DSTATE_SURFACEFORMAT format) const override;
|
||||
bool isTimestampShiftRequired() const override;
|
||||
|
||||
protected:
|
||||
static const AuxTranslationMode defaultAuxTranslationMode;
|
||||
|
@ -737,4 +737,9 @@ template <typename gfxProduct>
|
||||
bool HwHelperHw<gfxProduct>::isSurfaceFormatSupportedForMediaBlockOperation(NEO::GFX3DSTATE_SURFACEFORMAT format) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename gfxProduct>
|
||||
bool HwHelperHw<gfxProduct>::isTimestampShiftRequired() const {
|
||||
return true;
|
||||
}
|
||||
} // namespace NEO
|
||||
|
@ -60,7 +60,6 @@ class HwInfoConfig {
|
||||
virtual uint64_t getSharedSystemMemCapabilities(const HardwareInfo *hwInfo) = 0;
|
||||
virtual void getKernelExtendedProperties(uint32_t *fp16, uint32_t *fp32, uint32_t *fp64) = 0;
|
||||
virtual std::vector<int32_t> getKernelSupportedThreadArbitrationPolicies() = 0;
|
||||
virtual void convertTimestampsFromOaToCsDomain(uint64_t ×tampData) = 0;
|
||||
virtual uint32_t getDeviceMemoryMaxClkRate(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) = 0;
|
||||
virtual uint64_t getDeviceMemoryPhysicalSizeInBytes(const OSInterface *osIface, uint32_t subDeviceIndex) = 0;
|
||||
virtual uint64_t getDeviceMemoryMaxBandWidthInBytesPerSecond(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) = 0;
|
||||
@ -196,7 +195,6 @@ class HwInfoConfigHw : public HwInfoConfig {
|
||||
uint64_t getSharedSystemMemCapabilities(const HardwareInfo *hwInfo) override;
|
||||
void getKernelExtendedProperties(uint32_t *fp16, uint32_t *fp32, uint32_t *fp64) override;
|
||||
std::vector<int32_t> getKernelSupportedThreadArbitrationPolicies() override;
|
||||
void convertTimestampsFromOaToCsDomain(uint64_t ×tampData) override;
|
||||
uint32_t getDeviceMemoryMaxClkRate(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) override;
|
||||
uint64_t getDeviceMemoryPhysicalSizeInBytes(const OSInterface *osIface, uint32_t subDeviceIndex) override;
|
||||
uint64_t getDeviceMemoryMaxBandWidthInBytesPerSecond(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) override;
|
||||
|
@ -42,9 +42,6 @@ std::vector<int32_t> HwInfoConfigHw<gfxProduct>::getKernelSupportedThreadArbitra
|
||||
return PreambleHelper<GfxFamily>::getSupportedThreadArbitrationPolicies();
|
||||
}
|
||||
|
||||
template <PRODUCT_FAMILY gfxProduct>
|
||||
void HwInfoConfigHw<gfxProduct>::convertTimestampsFromOaToCsDomain(uint64_t ×tampData){};
|
||||
|
||||
template <PRODUCT_FAMILY gfxProduct>
|
||||
void HwInfoConfigHw<gfxProduct>::adjustPlatformForProductFamily(HardwareInfo *hwInfo) {}
|
||||
|
||||
|
@ -21,9 +21,8 @@ bool DeviceTimeWddm::getCpuGpuTime(TimeStampData *pGpuCpuTime, OSTime *osTime) {
|
||||
TimeStampDataHeader escapeInfo = {};
|
||||
|
||||
if (runEscape(wddm, escapeInfo)) {
|
||||
auto productFamily = wddm->getRootDeviceEnvironment().getHardwareInfo()->platform.eProductFamily;
|
||||
auto *hwInfoConfig = HwInfoConfig::get(productFamily);
|
||||
hwInfoConfig->convertTimestampsFromOaToCsDomain(escapeInfo.m_Data.m_Out.gpuPerfTicks);
|
||||
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()));
|
||||
|
||||
osTime->getCpuTime(&pGpuCpuTime->CPUTimeinNS);
|
||||
pGpuCpuTime->GPUTimeStamp = (unsigned long long)escapeInfo.m_Data.m_Out.gpuPerfTicks;
|
||||
|
@ -21,9 +21,8 @@ bool DeviceTimeWddm::getCpuGpuTime(TimeStampData *pGpuCpuTime, OSTime *osTime) {
|
||||
TimeStampDataHeader escapeInfo = {};
|
||||
|
||||
if (runEscape(wddm, escapeInfo)) {
|
||||
auto productFamily = wddm->getRootDeviceEnvironment().getHardwareInfo()->platform.eProductFamily;
|
||||
auto *hwInfoConfig = HwInfoConfig::get(productFamily);
|
||||
hwInfoConfig->convertTimestampsFromOaToCsDomain(escapeInfo.m_Data.m_Out.gpuPerfTicks);
|
||||
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()));
|
||||
double cpuNanoseconds = escapeInfo.m_Data.m_Out.cpuPerfTicks *
|
||||
(1000000000.0 / escapeInfo.m_Data.m_Out.cpuPerfFreq);
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "shared/source/os_interface/windows/device_time_wddm.h"
|
||||
|
||||
#include "shared/source/execution_environment/root_device_environment.h"
|
||||
#include "shared/source/helpers/hw_helper.h"
|
||||
#include "shared/source/os_interface/hw_info_config.h"
|
||||
#include "shared/source/os_interface/os_interface.h"
|
||||
#include "shared/source/os_interface/windows/wddm/wddm.h"
|
||||
@ -70,4 +71,12 @@ 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 &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
|
||||
|
||||
if (hwHelper.isTimestampShiftRequired() && freqCS > 0) {
|
||||
auto freqRatio = freqOA / freqCS;
|
||||
timestampData /= freqRatio;
|
||||
}
|
||||
};
|
||||
} // namespace NEO
|
||||
|
@ -24,6 +24,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);
|
||||
Wddm *wddm = nullptr;
|
||||
};
|
||||
|
||||
|
@ -168,11 +168,6 @@ uint32_t HwInfoConfigHw<gfxProduct>::computeMaxNeededSubSliceSpace(const Hardwar
|
||||
return maxSubSlice;
|
||||
}
|
||||
|
||||
template <>
|
||||
void HwInfoConfigHw<gfxProduct>::convertTimestampsFromOaToCsDomain(uint64_t ×tampData) {
|
||||
timestampData >>= 1;
|
||||
}
|
||||
|
||||
template <>
|
||||
bool HwInfoConfigHw<gfxProduct>::isFlushTaskAllowed() const {
|
||||
return true;
|
||||
|
@ -18,10 +18,6 @@ template <>
|
||||
void HwInfoConfigHw<IGFX_UNKNOWN>::adjustSamplerState(void *sampler, const HardwareInfo &hwInfo) {
|
||||
}
|
||||
|
||||
template <>
|
||||
void HwInfoConfigHw<IGFX_UNKNOWN>::convertTimestampsFromOaToCsDomain(uint64_t ×tampData) {
|
||||
}
|
||||
|
||||
template <>
|
||||
uint32_t HwInfoConfigHw<IGFX_UNKNOWN>::getMaxThreadsForWorkgroupInDSSOrSS(const HardwareInfo &hwInfo, uint32_t maxNumEUsPerSubSlice, uint32_t maxNumEUsPerDualSubSlice) const {
|
||||
return 0;
|
||||
|
@ -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 ×tampData, uint64_t freqOA, uint64_t freqCS) {
|
||||
static_cast<MockDeviceTimeWddm *>(this->deviceTime.get())->convertTimestampsFromOaToCsDomain(hwInfo, timestampData, freqOA, freqCS);
|
||||
}
|
||||
};
|
||||
} // namespace NEO
|
||||
|
@ -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);
|
||||
}
|
@ -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());
|
||||
|
@ -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 >SystemInfo = hwInfo.gtSystemInfo;
|
||||
|
Reference in New Issue
Block a user