Skip to content

Commit 0b85a9f

Browse files
performance: Limit tlb flush WA scope on DG2 Linux
Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
1 parent e3fb97c commit 0b85a9f

File tree

16 files changed

+67
-15
lines changed

16 files changed

+67
-15
lines changed

shared/source/os_interface/linux/drm_buffer_object.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "shared/source/command_stream/task_count_helper.h"
1111
#include "shared/source/helpers/common_types.h"
1212
#include "shared/source/helpers/constants.h"
13+
#include "shared/source/memory_manager/allocation_type.h"
1314
#include "shared/source/memory_manager/definitions/engine_limits.h"
1415
#include "shared/source/memory_manager/memory_operations_status.h"
1516
#include "shared/source/os_interface/linux/cache_info.h"
@@ -213,6 +214,14 @@ class BufferObject {
213214

214215
bool isChunked = false;
215216

217+
void setIsImage(AllocationType type) {
218+
this->isImageAllocation = type == AllocationType::image;
219+
}
220+
221+
bool isImage() const {
222+
return this->isImageAllocation;
223+
}
224+
216225
protected:
217226
MOCKABLE_VIRTUAL MemoryOperationsStatus evictUnusedAllocations(bool waitForCompletion, bool isLockNeeded);
218227

@@ -230,6 +239,7 @@ class BufferObject {
230239
bool allowCapture = false;
231240
bool requiresImmediateBinding = false;
232241
bool requiresExplicitResidency = false;
242+
bool isImageAllocation = false;
233243

234244
MOCKABLE_VIRTUAL void fillExecObject(ExecObject &execObject, OsContext *osContext, uint32_t vmHandleId, uint32_t drmContextId);
235245
void printBOBindingResult(OsContext *osContext, uint32_t vmHandleId, bool bind, int retVal);

shared/source/os_interface/linux/drm_memory_manager.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,7 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryForImageImpl(const A
678678
return nullptr;
679679
}
680680
bo->setAddress(gpuRange);
681+
bo->setIsImage(allocationData.type);
681682

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

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

10721074
if (!reuseSharedAllocation) {
@@ -1897,6 +1899,7 @@ BufferObject *DrmMemoryManager::createBufferObjectInMemoryRegion(uint32_t rootDe
18971899
}
18981900

18991901
bo->setAddress(gpuAddress);
1902+
bo->setIsImage(allocationType);
19001903

19011904
return bo;
19021905
}

shared/source/os_interface/linux/drm_neo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ uint32_t Drm::getVirtualMemoryAddressSpace(uint32_t vmId) const {
688688
}
689689

690690
void Drm::setNewResourceBoundToVM(BufferObject *bo, uint32_t vmHandleId) {
691-
if (!this->rootDeviceEnvironment.getProductHelper().isTlbFlushRequired()) {
691+
if (!this->rootDeviceEnvironment.getProductHelper().isTlbFlushRequired(*this->getHardwareInfo(), bo->isImage())) {
692692
return;
693693
}
694694
const auto &engines = this->rootDeviceEnvironment.executionEnvironment.memoryManager->getRegisteredEngines(bo->getRootDeviceIndex());

shared/source/os_interface/product_helper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class ProductHelper {
159159
virtual bool isResolveDependenciesByPipeControlsSupported(const HardwareInfo &hwInfo, bool isOOQ, TaskCountType queueTaskCount, const CommandStreamReceiver &queueCsr) const = 0;
160160
virtual bool isMidThreadPreemptionDisallowedForRayTracingKernels() const = 0;
161161
virtual bool isBufferPoolAllocatorSupported() const = 0;
162-
virtual bool isTlbFlushRequired() const = 0;
162+
virtual bool isTlbFlushRequired(const HardwareInfo &hwInfo, bool precondition) const = 0;
163163
virtual bool isDummyBlitWaRequired() const = 0;
164164
virtual bool isDetectIndirectAccessInKernelSupported(const KernelDescriptor &kernelDescriptor, const bool isPrecompiled) const = 0;
165165
virtual bool isLinearStoragePreferred(bool isImage1d, bool forceLinearStorage) const = 0;

shared/source/os_interface/product_helper.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void ProductHelperHw<gfxProduct>::adjustSamplerState(void *sampler, const Hardwa
6161
}
6262

6363
template <PRODUCT_FAMILY gfxProduct>
64-
bool ProductHelperHw<gfxProduct>::isTlbFlushRequired() const {
64+
bool ProductHelperHw<gfxProduct>::isTlbFlushRequired(const HardwareInfo &hwInfo, bool precondition) const {
6565
bool tlbFlushRequired = true;
6666
if (debugManager.flags.ForceTlbFlush.get() != -1) {
6767
tlbFlushRequired = !!debugManager.flags.ForceTlbFlush.get();

shared/source/os_interface/product_helper_hw.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class ProductHelperHw : public ProductHelper {
112112
bool isResolveDependenciesByPipeControlsSupported(const HardwareInfo &hwInfo, bool isOOQ, TaskCountType queueTaskCount, const CommandStreamReceiver &queueCsr) const override;
113113
bool isMidThreadPreemptionDisallowedForRayTracingKernels() const override;
114114
bool isBufferPoolAllocatorSupported() const override;
115-
bool isTlbFlushRequired() const override;
115+
bool isTlbFlushRequired(const HardwareInfo &hwInfo, bool precondition) const override;
116116
bool isDummyBlitWaRequired() const override;
117117
bool isDetectIndirectAccessInKernelSupported(const KernelDescriptor &kernelDescriptor, const bool isPrecompiled) const override;
118118
bool isLinearStoragePreferred(bool isImage1d, bool forceLinearStorage) const override;

shared/source/os_interface/windows/wddm/wddm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1349,7 +1349,7 @@ void Wddm::populateIpVersion(HardwareInfo &hwInfo) {
13491349
}
13501350

13511351
void Wddm::setNewResourceBoundToPageTable() {
1352-
if (!this->rootDeviceEnvironment.getProductHelper().isTlbFlushRequired()) {
1352+
if (!this->rootDeviceEnvironment.getProductHelper().isTlbFlushRequired(*this->getHardwareInfo(), true)) {
13531353
return;
13541354
}
13551355
this->forEachContextWithinWddm([](const EngineControl &engine) { engine.osContext->setNewResourceBound(); });

shared/source/xe_hpc_core/pvc/os_agnostic_product_helper_pvc.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ bool ProductHelperHw<gfxProduct>::isBlitCopyRequiredForLocalMemory(const RootDev
138138
}
139139

140140
template <>
141-
bool ProductHelperHw<gfxProduct>::isTlbFlushRequired() const {
141+
bool ProductHelperHw<gfxProduct>::isTlbFlushRequired(const HardwareInfo &hwInfo, bool precondition) const {
142142
bool tlbFlushRequired = false;
143143
if (debugManager.flags.ForceTlbFlush.get() != -1) {
144144
tlbFlushRequired = !!debugManager.flags.ForceTlbFlush.get();

shared/source/xe_hpg_core/linux/product_helper_dg2.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ int ProductHelperHw<gfxProduct>::configureHardwareCustom(HardwareInfo *hwInfo, O
4646
return 0;
4747
}
4848

49+
template <>
50+
bool ProductHelperHw<gfxProduct>::isTlbFlushRequired(const HardwareInfo &hwInfo, bool precondition) const {
51+
bool tlbFlushRequired = !DG2::isG10(hwInfo) && precondition;
52+
if (debugManager.flags.ForceTlbFlush.get() != -1) {
53+
tlbFlushRequired = !!debugManager.flags.ForceTlbFlush.get();
54+
}
55+
return tlbFlushRequired;
56+
}
57+
4958
template <>
5059
bool ProductHelperHw<gfxProduct>::getUuid(NEO::DriverModel *driverModel, const uint32_t subDeviceCount, const uint32_t deviceIndex, std::array<uint8_t, ProductHelper::uuidSize> &uuid) const {
5160
if (driverModel->getDriverModelType() != DriverModelType::drm) {

shared/test/unit_test/os_interface/linux/drm_buffer_object_tests.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,15 @@ TEST_F(DrmBufferObjectTest, whenExecFailsThenValidateHostPtrFails) {
140140
EXPECT_EQ(EINVAL, ret);
141141
}
142142

143+
TEST_F(DrmBufferObjectTest, whenSetImageAllocTypeForBOThenReturnProperValue) {
144+
TestedBufferObject bo(0u, this->mock.get());
145+
EXPECT_FALSE(bo.isImage());
146+
bo.setIsImage(AllocationType::kernelIsa);
147+
EXPECT_FALSE(bo.isImage());
148+
bo.setIsImage(AllocationType::image);
149+
EXPECT_TRUE(bo.isImage());
150+
}
151+
143152
TEST_F(DrmBufferObjectTest, givenResidentBOWhenPrintExecutionBufferIsSetToTrueThenDebugInformationAboutBOIsPrinted) {
144153
mock->ioctlExpected.total = 1;
145154
DebugManagerStateRestore restore;

0 commit comments

Comments
 (0)