fix: Override timestamp width from KMD
Signed-off-by: Szymon Morek <szymon.morek@intel.com>
This commit is contained in:
parent
8527779778
commit
7f2b806413
|
@ -292,6 +292,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, StandaloneInOrderTimestampAllocationEnabled, -1,
|
|||
DECLARE_DEBUG_VARIABLE(int32_t, ForceComputeWalkerPostSyncFlushWithWrite, -1, "-1: ignore. >=0: Force PostSync cache flush and override postSync immediate write address to given value")
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, DeferStateInitSubmissionToFirstRegularUsage, -1, "-1: ignore, 0: disabled, 1: enabled. If set, instead of initializing at Device creation, submit initial state during first usage (eg. kernel submission)")
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, ForceNonWalkerSplitMemoryCopy, -1, "-1: default, 0: disabled, 1: enabled. If set, memory copy will be executed as single byte copy Walker without performance optimizations")
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, OverrideTimestampWidth, -1, "-1: default from KMD, > 0: Override timestamp width used for profiling. Requires XeKMD kernel.")
|
||||
|
||||
/*LOGGING FLAGS*/
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, PrintDriverDiagnostics, -1, "prints driver diagnostics messages to standard output, value corresponds to hint level")
|
||||
|
|
|
@ -128,6 +128,7 @@ void RootDeviceEnvironment::initOsTime() {
|
|||
if (!osTime) {
|
||||
osTime = OSTime::create(osInterface.get());
|
||||
osTime->setDeviceTimerResolution(*hwInfo);
|
||||
osTime->setDeviceTimestampWidth(gfxCoreHelper->getDeviceTimestampWidth());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -199,6 +199,8 @@ class GfxCoreHelper {
|
|||
|
||||
virtual bool usmCompressionSupported(const NEO::HardwareInfo &hwInfo) const = 0;
|
||||
|
||||
virtual uint32_t getDeviceTimestampWidth() const = 0;
|
||||
|
||||
virtual ~GfxCoreHelper() = default;
|
||||
|
||||
protected:
|
||||
|
@ -433,6 +435,8 @@ class GfxCoreHelperHw : public GfxCoreHelper {
|
|||
|
||||
bool usmCompressionSupported(const NEO::HardwareInfo &hwInfo) const override;
|
||||
|
||||
uint32_t getDeviceTimestampWidth() const override;
|
||||
|
||||
~GfxCoreHelperHw() override = default;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -805,6 +805,14 @@ uint32_t GfxCoreHelperHw<GfxFamily>::calculateAvailableThreadCount(const Hardwar
|
|||
return std::min(hwInfo.gtSystemInfo.ThreadCount, maxThreadsPerEuCount * hwInfo.gtSystemInfo.EUCount);
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
uint32_t GfxCoreHelperHw<GfxFamily>::getDeviceTimestampWidth() const {
|
||||
if (debugManager.flags.OverrideTimestampWidth.get() != -1) {
|
||||
return debugManager.flags.OverrideTimestampWidth.get();
|
||||
}
|
||||
return 0u;
|
||||
}
|
||||
|
||||
template <typename Family>
|
||||
uint32_t GfxCoreHelperHw<Family>::getInternalCopyEngineIndex(const HardwareInfo &hwInfo) const {
|
||||
if (debugManager.flags.ForceBCSForInternalCopyEngine.get() != -1) {
|
||||
|
|
|
@ -429,6 +429,9 @@ bool IoctlHelperXe::setGpuCpuTimes(TimeStampData *pGpuCpuTime, OSTime *osTime) {
|
|||
ret = IoctlHelper::ioctl(DrmIoctl::query, &deviceQuery);
|
||||
|
||||
auto nValidBits = queryEngineCycles->width;
|
||||
if (osTime->getDeviceTimestampWidth() != 0) {
|
||||
nValidBits = osTime->getDeviceTimestampWidth();
|
||||
}
|
||||
auto gpuTimestampValidBits = maxNBitValue(nValidBits);
|
||||
auto gpuCycles = queryEngineCycles->engine_cycles & gpuTimestampValidBits;
|
||||
|
||||
|
|
|
@ -86,6 +86,14 @@ class OSTime {
|
|||
deviceTime->setDeviceTimerResolution(hwInfo);
|
||||
}
|
||||
|
||||
void setDeviceTimestampWidth(uint32_t timestampWidth) {
|
||||
this->timestampWidth = timestampWidth;
|
||||
}
|
||||
|
||||
uint32_t getDeviceTimestampWidth() const {
|
||||
return this->timestampWidth;
|
||||
}
|
||||
|
||||
void setRefreshTimestampsFlag() const {
|
||||
deviceTime->setRefreshTimestampsFlag();
|
||||
}
|
||||
|
@ -99,5 +107,6 @@ class OSTime {
|
|||
OSInterface *osInterface = nullptr;
|
||||
std::unique_ptr<DeviceTime> deviceTime;
|
||||
uint64_t maxGpuTimeStamp = 0;
|
||||
uint32_t timestampWidth = 0;
|
||||
};
|
||||
} // namespace NEO
|
||||
|
|
|
@ -333,6 +333,14 @@ uint32_t GfxCoreHelperHw<Family>::getMetricsLibraryGenId() const {
|
|||
return static_cast<uint32_t>(MetricsLibraryApi::ClientGen::Xe2HPG);
|
||||
}
|
||||
|
||||
template <>
|
||||
uint32_t GfxCoreHelperHw<Family>::getDeviceTimestampWidth() const {
|
||||
if (debugManager.flags.OverrideTimestampWidth.get() != -1) {
|
||||
return debugManager.flags.OverrideTimestampWidth.get();
|
||||
}
|
||||
return 64u;
|
||||
};
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
namespace NEO {
|
||||
|
|
|
@ -625,4 +625,5 @@ ForceNonCoherentModeForTimestamps = 0
|
|||
ExperimentalUSMAllocationReuseVersion = -1
|
||||
ForceNonWalkerSplitMemoryCopy = -1
|
||||
DirectSubmissionSwitchSemaphoreMode = -1
|
||||
OverrideTimestampWidth = -1
|
||||
# Please don't edit below this line
|
||||
|
|
|
@ -1863,3 +1863,13 @@ HWTEST2_F(GfxCoreHelperTest, GivenModifiedGtSystemInfoWhenCallingCalculateAvaila
|
|||
EXPECT_EQ(expectedThreadCount, result);
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST_F(GfxCoreHelperTest, givenGetDeviceTimestampWidthCalledThenReturnCorrectValue) {
|
||||
DebugManagerStateRestore restore;
|
||||
|
||||
auto &helper = getHelper<GfxCoreHelper>();
|
||||
EXPECT_EQ(0u, helper.getDeviceTimestampWidth());
|
||||
|
||||
debugManager.flags.OverrideTimestampWidth.set(64);
|
||||
EXPECT_EQ(64u, helper.getDeviceTimestampWidth());
|
||||
}
|
|
@ -1794,6 +1794,35 @@ TEST(IoctlHelperXeTest, givenIoctlFailureWhenSetGpuCpuTimesIsCalledThenProperVal
|
|||
EXPECT_EQ(pGpuCpuTime.cpuTimeinNS, expectedTimestamp);
|
||||
}
|
||||
|
||||
TEST(IoctlHelperXeTest, whenDeviceTimestampWidthSetThenProperValuesAreSet) {
|
||||
DebugManagerStateRestore restorer;
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto &rootDeviceEnvironment = *executionEnvironment->rootDeviceEnvironments[0];
|
||||
rootDeviceEnvironment.osInterface = std::make_unique<OSInterface>();
|
||||
rootDeviceEnvironment.osInterface->setDriverModel(std::make_unique<DrmMockTime>(mockFd, rootDeviceEnvironment));
|
||||
auto drm = DrmMockXe::create(rootDeviceEnvironment);
|
||||
auto xeIoctlHelper = static_cast<MockIoctlHelperXe *>(drm->getIoctlHelper());
|
||||
auto engineInfo = xeIoctlHelper->createEngineInfo(false);
|
||||
ASSERT_NE(nullptr, engineInfo);
|
||||
|
||||
uint64_t expectedCycles = maxNBitValue(64);
|
||||
auto xeQueryEngineCycles = reinterpret_cast<drm_xe_query_engine_cycles *>(drm->queryEngineCycles);
|
||||
xeQueryEngineCycles->width = 32;
|
||||
xeQueryEngineCycles->engine_cycles = expectedCycles;
|
||||
xeQueryEngineCycles->cpu_timestamp = 100;
|
||||
|
||||
TimeStampData pGpuCpuTime{};
|
||||
std::unique_ptr<MockOSTimeLinux> osTime = MockOSTimeLinux::create(*rootDeviceEnvironment.osInterface);
|
||||
auto ret = xeIoctlHelper->setGpuCpuTimes(&pGpuCpuTime, osTime.get());
|
||||
EXPECT_EQ(true, ret);
|
||||
|
||||
EXPECT_EQ(pGpuCpuTime.gpuTimeStamp, expectedCycles & maxNBitValue(32));
|
||||
osTime->setDeviceTimestampWidth(64);
|
||||
ret = xeIoctlHelper->setGpuCpuTimes(&pGpuCpuTime, osTime.get());
|
||||
EXPECT_EQ(true, ret);
|
||||
EXPECT_EQ(pGpuCpuTime.gpuTimeStamp, expectedCycles);
|
||||
}
|
||||
|
||||
TEST(IoctlHelperXeTest, whenSetDefaultEngineIsCalledThenProperEngineIsSet) {
|
||||
NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get();
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>(&hwInfo);
|
||||
|
|
|
@ -44,3 +44,14 @@ BMGTEST_F(GfxCoreHelperTestsBmg, WhenAskingForDcFlushThenReturnFalse) {
|
|||
setUpImpl();
|
||||
EXPECT_FALSE(MemorySynchronizationCommands<FamilyType>::getDcFlushEnable(true, pDevice->getRootDeviceEnvironment()));
|
||||
}
|
||||
|
||||
BMGTEST_F(GfxCoreHelperTestsBmg, givenGetDeviceTimestampWidthCalledThenReturnCorrectValue) {
|
||||
setUpImpl();
|
||||
DebugManagerStateRestore restore;
|
||||
|
||||
auto &helper = this->pDevice->getGfxCoreHelper();
|
||||
EXPECT_EQ(64u, helper.getDeviceTimestampWidth());
|
||||
|
||||
debugManager.flags.OverrideTimestampWidth.set(36);
|
||||
EXPECT_EQ(36u, helper.getDeviceTimestampWidth());
|
||||
}
|
|
@ -37,3 +37,4 @@ HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenBooleanUncachedWhenCallOverridePa
|
|||
HWTEST_EXCLUDE_PRODUCT(GfxCoreHelperTest, whenEncodeAdditionalTimestampOffsetsThenNothingEncoded, IGFX_XE2_HPG_CORE);
|
||||
HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenProductHelperWhenGetThreadEuRatioForScratchThen8IsReturned, IGFX_XE2_HPG_CORE);
|
||||
HWTEST_EXCLUDE_PRODUCT(CompilerProductHelperFixture, WhenIsMidThreadPreemptionIsSupportedIsCalledThenCorrectResultIsReturned, IGFX_XE2_HPG_CORE);
|
||||
HWTEST_EXCLUDE_PRODUCT(GfxCoreHelperTest, givenGetDeviceTimestampWidthCalledThenReturnCorrectValue, IGFX_XE2_HPG_CORE);
|
|
@ -9,6 +9,7 @@
|
|||
#include "shared/source/os_interface/product_helper.h"
|
||||
#include "shared/source/xe2_hpg_core/hw_cmds_lnl.h"
|
||||
#include "shared/source/xe2_hpg_core/hw_info_lnl.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/default_hw_info.h"
|
||||
#include "shared/test/common/helpers/gfx_core_helper_tests.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
|
@ -31,3 +32,13 @@ LNLTEST_F(GfxCoreHelperTestsLnl, givenCommandBufferAllocationTypeWhenGetAllocati
|
|||
LNLTEST_F(GfxCoreHelperTestsLnl, WhenAskingForDcFlushThenReturnTrue) {
|
||||
EXPECT_NE(MemorySynchronizationCommands<FamilyType>::getDcFlushEnable(true, this->pDevice->getRootDeviceEnvironment()), this->pDevice->getRootDeviceEnvironment().getProductHelper().isDcFlushMitigated());
|
||||
}
|
||||
|
||||
LNLTEST_F(GfxCoreHelperTestsLnl, givenGetDeviceTimestampWidthCalledThenReturnCorrectValue) {
|
||||
DebugManagerStateRestore restore;
|
||||
|
||||
auto &helper = this->pDevice->getGfxCoreHelper();
|
||||
EXPECT_EQ(64u, helper.getDeviceTimestampWidth());
|
||||
|
||||
debugManager.flags.OverrideTimestampWidth.set(36);
|
||||
EXPECT_EQ(36u, helper.getDeviceTimestampWidth());
|
||||
}
|
Loading…
Reference in New Issue