Skip to content

Commit

Permalink
Revert "performance: Limit tlb flush WA scope on DG2 Linux"
Browse files Browse the repository at this point in the history
This reverts commit 0b85a9f.

Signed-off-by: Compute-Runtime-Validation <[email protected]>
  • Loading branch information
Compute-Runtime-Validation authored and Compute-Runtime-Automation committed Dec 21, 2023
1 parent 2d62c4e commit 590418a
Show file tree
Hide file tree
Showing 16 changed files with 15 additions and 67 deletions.
10 changes: 0 additions & 10 deletions shared/source/os_interface/linux/drm_buffer_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "shared/source/command_stream/task_count_helper.h"
#include "shared/source/helpers/common_types.h"
#include "shared/source/helpers/constants.h"
#include "shared/source/memory_manager/allocation_type.h"
#include "shared/source/memory_manager/definitions/engine_limits.h"
#include "shared/source/memory_manager/memory_operations_status.h"
#include "shared/source/os_interface/linux/cache_info.h"
Expand Down Expand Up @@ -214,14 +213,6 @@ class BufferObject {

bool isChunked = false;

void setIsImage(AllocationType type) {
this->isImageAllocation = type == AllocationType::image;
}

bool isImage() const {
return this->isImageAllocation;
}

protected:
MOCKABLE_VIRTUAL MemoryOperationsStatus evictUnusedAllocations(bool waitForCompletion, bool isLockNeeded);

Expand All @@ -239,7 +230,6 @@ class BufferObject {
bool allowCapture = false;
bool requiresImmediateBinding = false;
bool requiresExplicitResidency = false;
bool isImageAllocation = false;

MOCKABLE_VIRTUAL void fillExecObject(ExecObject &execObject, OsContext *osContext, uint32_t vmHandleId, uint32_t drmContextId);
void printBOBindingResult(OsContext *osContext, uint32_t vmHandleId, bool bind, int retVal);
Expand Down
3 changes: 0 additions & 3 deletions shared/source/os_interface/linux/drm_memory_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,6 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryForImageImpl(const A
return nullptr;
}
bo->setAddress(gpuRange);
bo->setIsImage(allocationData.type);

[[maybe_unused]] auto ret2 = bo->setTiling(ioctlHelper->getDrmParamValue(DrmParam::tilingY), static_cast<uint32_t>(allocationData.imgInfo->rowPitch));
DEBUG_BREAK_IF(ret2 != true);
Expand Down Expand Up @@ -1068,7 +1067,6 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o
drmAllocation->setDefaultGmm(gmm);

bo->setPatIndex(drm.getPatIndex(gmm, properties.allocationType, CacheRegion::defaultRegion, CachePolicy::writeBack, false, MemoryPoolHelper::isSystemMemoryPool(memoryPool)));
bo->setIsImage(properties.allocationType);
}

if (!reuseSharedAllocation) {
Expand Down Expand Up @@ -1899,7 +1897,6 @@ BufferObject *DrmMemoryManager::createBufferObjectInMemoryRegion(uint32_t rootDe
}

bo->setAddress(gpuAddress);
bo->setIsImage(allocationType);

return bo;
}
Expand Down
2 changes: 1 addition & 1 deletion shared/source/os_interface/linux/drm_neo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ uint32_t Drm::getVirtualMemoryAddressSpace(uint32_t vmId) const {
}

void Drm::setNewResourceBoundToVM(BufferObject *bo, uint32_t vmHandleId) {
if (!this->rootDeviceEnvironment.getProductHelper().isTlbFlushRequired(*this->getHardwareInfo(), bo->isImage())) {
if (!this->rootDeviceEnvironment.getProductHelper().isTlbFlushRequired()) {
return;
}
const auto &engines = this->rootDeviceEnvironment.executionEnvironment.memoryManager->getRegisteredEngines(bo->getRootDeviceIndex());
Expand Down
2 changes: 1 addition & 1 deletion shared/source/os_interface/product_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class ProductHelper {
virtual bool isResolveDependenciesByPipeControlsSupported(const HardwareInfo &hwInfo, bool isOOQ, TaskCountType queueTaskCount, const CommandStreamReceiver &queueCsr) const = 0;
virtual bool isMidThreadPreemptionDisallowedForRayTracingKernels() const = 0;
virtual bool isBufferPoolAllocatorSupported() const = 0;
virtual bool isTlbFlushRequired(const HardwareInfo &hwInfo, bool precondition) const = 0;
virtual bool isTlbFlushRequired() const = 0;
virtual bool isDummyBlitWaRequired() const = 0;
virtual bool isDetectIndirectAccessInKernelSupported(const KernelDescriptor &kernelDescriptor, const bool isPrecompiled) const = 0;
virtual bool isLinearStoragePreferred(bool isImage1d, bool forceLinearStorage) const = 0;
Expand Down
2 changes: 1 addition & 1 deletion shared/source/os_interface/product_helper.inl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void ProductHelperHw<gfxProduct>::adjustSamplerState(void *sampler, const Hardwa
}

template <PRODUCT_FAMILY gfxProduct>
bool ProductHelperHw<gfxProduct>::isTlbFlushRequired(const HardwareInfo &hwInfo, bool precondition) const {
bool ProductHelperHw<gfxProduct>::isTlbFlushRequired() const {
bool tlbFlushRequired = true;
if (debugManager.flags.ForceTlbFlush.get() != -1) {
tlbFlushRequired = !!debugManager.flags.ForceTlbFlush.get();
Expand Down
2 changes: 1 addition & 1 deletion shared/source/os_interface/product_helper_hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class ProductHelperHw : public ProductHelper {
bool isResolveDependenciesByPipeControlsSupported(const HardwareInfo &hwInfo, bool isOOQ, TaskCountType queueTaskCount, const CommandStreamReceiver &queueCsr) const override;
bool isMidThreadPreemptionDisallowedForRayTracingKernels() const override;
bool isBufferPoolAllocatorSupported() const override;
bool isTlbFlushRequired(const HardwareInfo &hwInfo, bool precondition) const override;
bool isTlbFlushRequired() const override;
bool isDummyBlitWaRequired() const override;
bool isDetectIndirectAccessInKernelSupported(const KernelDescriptor &kernelDescriptor, const bool isPrecompiled) const override;
bool isLinearStoragePreferred(bool isImage1d, bool forceLinearStorage) const override;
Expand Down
2 changes: 1 addition & 1 deletion shared/source/os_interface/windows/wddm/wddm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,7 @@ void Wddm::populateIpVersion(HardwareInfo &hwInfo) {
}

void Wddm::setNewResourceBoundToPageTable() {
if (!this->rootDeviceEnvironment.getProductHelper().isTlbFlushRequired(*this->getHardwareInfo(), true)) {
if (!this->rootDeviceEnvironment.getProductHelper().isTlbFlushRequired()) {
return;
}
this->forEachContextWithinWddm([](const EngineControl &engine) { engine.osContext->setNewResourceBound(); });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ bool ProductHelperHw<gfxProduct>::isBlitCopyRequiredForLocalMemory(const RootDev
}

template <>
bool ProductHelperHw<gfxProduct>::isTlbFlushRequired(const HardwareInfo &hwInfo, bool precondition) const {
bool ProductHelperHw<gfxProduct>::isTlbFlushRequired() const {
bool tlbFlushRequired = false;
if (debugManager.flags.ForceTlbFlush.get() != -1) {
tlbFlushRequired = !!debugManager.flags.ForceTlbFlush.get();
Expand Down
9 changes: 0 additions & 9 deletions shared/source/xe_hpg_core/linux/product_helper_dg2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,6 @@ int ProductHelperHw<gfxProduct>::configureHardwareCustom(HardwareInfo *hwInfo, O
return 0;
}

template <>
bool ProductHelperHw<gfxProduct>::isTlbFlushRequired(const HardwareInfo &hwInfo, bool precondition) const {
bool tlbFlushRequired = !DG2::isG10(hwInfo) && precondition;
if (debugManager.flags.ForceTlbFlush.get() != -1) {
tlbFlushRequired = !!debugManager.flags.ForceTlbFlush.get();
}
return tlbFlushRequired;
}

template <>
bool ProductHelperHw<gfxProduct>::getUuid(NEO::DriverModel *driverModel, const uint32_t subDeviceCount, const uint32_t deviceIndex, std::array<uint8_t, ProductHelper::uuidSize> &uuid) const {
if (driverModel->getDriverModelType() != DriverModelType::drm) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,6 @@ TEST_F(DrmBufferObjectTest, whenExecFailsThenValidateHostPtrFails) {
EXPECT_EQ(EINVAL, ret);
}

TEST_F(DrmBufferObjectTest, whenSetImageAllocTypeForBOThenReturnProperValue) {
TestedBufferObject bo(0u, this->mock.get());
EXPECT_FALSE(bo.isImage());
bo.setIsImage(AllocationType::kernelIsa);
EXPECT_FALSE(bo.isImage());
bo.setIsImage(AllocationType::image);
EXPECT_TRUE(bo.isImage());
}

TEST_F(DrmBufferObjectTest, givenResidentBOWhenPrintExecutionBufferIsSetToTrueThenDebugInformationAboutBOIsPrinted) {
mock->ioctlExpected.total = 1;
DebugManagerStateRestore restore;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ TEST_F(DrmMemoryOperationsHandlerBindMultiRootDeviceTest, whenSetNewResourceBoun

for (const auto &engine : device->getAllEngines()) {
auto osContexLinux = static_cast<MockOsContextLinux *>(engine.osContext);
if (osContexLinux->getDeviceBitfield().test(1u) && executionEnvironment->rootDeviceEnvironments[device->getRootDeviceIndex()]->getProductHelper().isTlbFlushRequired(*executionEnvironment->rootDeviceEnvironments[device->getRootDeviceIndex()]->getHardwareInfo(), true)) {
if (osContexLinux->getDeviceBitfield().test(1u) && executionEnvironment->rootDeviceEnvironments[device->getRootDeviceIndex()]->getProductHelper().isTlbFlushRequired()) {
EXPECT_TRUE(osContexLinux->isTlbFlushRequired());
} else {
EXPECT_FALSE(osContexLinux->isTlbFlushRequired());
Expand All @@ -150,7 +150,7 @@ TEST_F(DrmMemoryOperationsHandlerBindMultiRootDeviceTest, whenSetNewResourceBoun

for (const auto &engine : devices[1]->getAllEngines()) {
auto osContexLinux = static_cast<MockOsContextLinux *>(engine.osContext);
if (osContexLinux->getDeviceBitfield().test(0u) && executionEnvironment->rootDeviceEnvironments[1]->getProductHelper().isTlbFlushRequired(*executionEnvironment->rootDeviceEnvironments[device->getRootDeviceIndex()]->getHardwareInfo(), true)) {
if (osContexLinux->getDeviceBitfield().test(0u) && executionEnvironment->rootDeviceEnvironments[1]->getProductHelper().isTlbFlushRequired()) {
EXPECT_TRUE(osContexLinux->isTlbFlushRequired());
} else {
EXPECT_FALSE(osContexLinux->isTlbFlushRequired());
Expand All @@ -168,7 +168,7 @@ TEST_F(DrmMemoryOperationsHandlerBindMultiRootDeviceTest, whenSetNewResourceBoun

for (const auto &engine : device->getAllEngines()) {
auto osContexLinux = static_cast<MockOsContextLinux *>(engine.osContext);
if (osContexLinux->getDeviceBitfield().test(1u) && executionEnvironment->rootDeviceEnvironments[1]->getProductHelper().isTlbFlushRequired(*executionEnvironment->rootDeviceEnvironments[device->getRootDeviceIndex()]->getHardwareInfo(), true)) {
if (osContexLinux->getDeviceBitfield().test(1u) && executionEnvironment->rootDeviceEnvironments[1]->getProductHelper().isTlbFlushRequired()) {
EXPECT_TRUE(osContexLinux->isTlbFlushRequired());
} else {
EXPECT_FALSE(osContexLinux->isTlbFlushRequired());
Expand Down
6 changes: 2 additions & 4 deletions shared/test/unit_test/os_interface/product_helper_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,15 +455,13 @@ HWTEST2_F(ProductHelperTest, givenProductHelperWhenAskedIfIsTimestampWaitSupport
}

HWTEST2_F(ProductHelperTest, givenProductHelperWhenAskedIfIsTlbFlushRequiredThenTrueIsReturned, IsNotXeHpgOrXeHpcCore) {
EXPECT_TRUE(productHelper->isTlbFlushRequired(pInHwInfo, false));
EXPECT_TRUE(productHelper->isTlbFlushRequired(pInHwInfo, true));
EXPECT_TRUE(productHelper->isTlbFlushRequired());
}

HWTEST2_F(ProductHelperTest, givenProductHelperAndForceTlbFlushNotSetWhenAskedIfIsTlbFlushRequiredThenFalseIsReturned, IsNotPVC) {
DebugManagerStateRestore restore{};
debugManager.flags.ForceTlbFlush.set(0);
EXPECT_FALSE(productHelper->isTlbFlushRequired(pInHwInfo, true));
EXPECT_FALSE(productHelper->isTlbFlushRequired(pInHwInfo, false));
EXPECT_FALSE(productHelper->isTlbFlushRequired());
}

HWTEST_F(ProductHelperTest, givenLockableAllocationWhenGettingIsBlitCopyRequiredForLocalMemoryThenCorrectValuesAreReturned) {
Expand Down
2 changes: 1 addition & 1 deletion shared/test/unit_test/os_interface/windows/wddm_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ TEST(WddmNewRsourceTest, whenSetNewResourcesBoundToPageTableThenSetInContextFrom
}
engines = executionEnvironment.memoryManager->getRegisteredEngines(1);
for (const auto &engine : engines) {
EXPECT_EQ(engine.osContext->peekTlbFlushCounter(), executionEnvironment.rootDeviceEnvironments[1]->getProductHelper().isTlbFlushRequired(*defaultHwInfo, true));
EXPECT_EQ(engine.osContext->peekTlbFlushCounter(), executionEnvironment.rootDeviceEnvironments[1]->getProductHelper().isTlbFlushRequired());
}

executionEnvironment.memoryManager->unregisterEngineForCsr(csr1.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@ PVCTEST_F(PvcProductHelper, whenGettingAubstreamProductFamilyThenProperEnumValue
}

PVCTEST_F(PvcProductHelper, whenCheckIsTlbFlushRequiredThenReturnProperValue) {
EXPECT_FALSE(productHelper->isTlbFlushRequired(*defaultHwInfo, true));
EXPECT_FALSE(productHelper->isTlbFlushRequired(*defaultHwInfo, false));
EXPECT_FALSE(productHelper->isTlbFlushRequired());
}

PVCTEST_F(PvcProductHelper, whenForceTlbFlushSetAndCheckIsTlbFlushRequiredThenReturnProperValue) {
DebugManagerStateRestore restore;
debugManager.flags.ForceTlbFlush.set(1);
EXPECT_TRUE(productHelper->isTlbFlushRequired(*defaultHwInfo, false));
EXPECT_TRUE(productHelper->isTlbFlushRequired(*defaultHwInfo, true));
EXPECT_TRUE(productHelper->isTlbFlushRequired());
}

PVCTEST_F(PvcProductHelper, givenPVCRevId3AndAboveWhenGettingThreadEuRatioForScratchThen16IsReturned) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
*/

#include "shared/source/os_interface/os_interface.h"
#include "shared/source/xe_hpg_core/hw_cmds_dg2.h"
#include "shared/source/xe_hpg_core/hw_info_xe_hpg_core.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/gtest_helpers.h"
#include "shared/test/common/libult/linux/drm_mock.h"
Expand Down Expand Up @@ -45,18 +43,3 @@ DG2TEST_F(Dg2ProductHelperLinux, GivenDg2WhenConfigureHardwareCustomThenKmdNotif
EXPECT_TRUE(pInHwInfo.capabilityTable.kmdNotifyProperties.enableQuickKmdSleepForDirectSubmission);
EXPECT_EQ(20ll, pInHwInfo.capabilityTable.kmdNotifyProperties.delayQuickKmdSleepForDirectSubmissionMicroseconds);
}

DG2TEST_F(Dg2ProductHelperLinux, whenCheckIsTlbFlushRequiredThenReturnProperValue) {
EXPECT_EQ(productHelper->isTlbFlushRequired(pInHwInfo, true), !DG2::isG10(pInHwInfo));
EXPECT_FALSE(productHelper->isTlbFlushRequired(pInHwInfo, false));
}

DG2TEST_F(Dg2ProductHelperLinux, whenForceTlbFlushSetAndCheckIsTlbFlushRequiredThenReturnProperValue) {
DebugManagerStateRestore restore;
debugManager.flags.ForceTlbFlush.set(1);
EXPECT_TRUE(productHelper->isTlbFlushRequired(pInHwInfo, false));
EXPECT_TRUE(productHelper->isTlbFlushRequired(pInHwInfo, true));
debugManager.flags.ForceTlbFlush.set(0);
EXPECT_FALSE(productHelper->isTlbFlushRequired(pInHwInfo, false));
EXPECT_FALSE(productHelper->isTlbFlushRequired(pInHwInfo, true));
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ using namespace NEO;
using MtlProductHelperWindows = ProductHelperTestWindows;

MTLTEST_F(MtlProductHelperWindows, whenCheckIsTlbFlushRequiredThenReturnProperValue) {
EXPECT_TRUE(productHelper->isTlbFlushRequired(pInHwInfo, false));
EXPECT_TRUE(productHelper->isTlbFlushRequired());
}

MTLTEST_F(MtlProductHelperWindows, whenCheckingIsTimestampWaitSupportedForEventsThenReturnTrue) {
Expand Down

0 comments on commit 590418a

Please sign in to comment.