Skip to content

Commit f5575a1

Browse files
Revert "Remove fallback path for PAT index programming"
This reverts commit faf8d51. Signed-off-by: Compute-Runtime-Validation <[email protected]>
1 parent fbc9188 commit f5575a1

File tree

11 files changed

+109
-9
lines changed

11 files changed

+109
-9
lines changed

opencl/test/unit_test/helpers/hw_helper_tests.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -1456,6 +1456,12 @@ HWTEST_F(HwHelperTest, GivenHwInfoWhenGetBatchBufferEndReferenceCalledThenCorrec
14561456
EXPECT_EQ(hwHelper.getBatchBufferEndReference(), reinterpret_cast<const void *>(&FamilyType::cmdInitBatchBufferEnd));
14571457
}
14581458

1459+
HWTEST_F(HwHelperTest, givenHwHelperWhenAskingForPatIndexWaThenReturnFalse) {
1460+
const auto &hwHelper = HwHelper::get(renderCoreFamily);
1461+
1462+
EXPECT_FALSE(hwHelper.isPatIndexFallbackWaRequired());
1463+
}
1464+
14591465
HWTEST_F(HwHelperTest, givenHwHelperWhenPassingCopyEngineTypeThenItsCopyOnly) {
14601466
EXPECT_TRUE(EngineHelper::isCopyOnlyEngineType(EngineGroupType::Copy));
14611467
}

opencl/test/unit_test/xe_hpc_core/excludes_ocl_xe_hpc_core.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ HWTEST_EXCLUDE_PRODUCT(CommandStreamReceiverFlushTaskTests, givenOverrideThreadA
5252
HWTEST_EXCLUDE_PRODUCT(XeHPAndLaterAubCommandStreamReceiverWithoutFixtureTests, GivenCopyHostPtrAndHostNoAccessAndReadOnlyFlagsWhenAllocatingBufferThenAllocationIsCopiedToEveryTile, IGFX_XE_HPC_CORE);
5353
HWTEST_EXCLUDE_PRODUCT(GetAllocationDataTestHw, givenRingBufferAllocationWhenGetAllocationDataIsCalledThenItHasProperFieldsSet, IGFX_XE_HPC_CORE);
5454
HWTEST_EXCLUDE_PRODUCT(GetAllocationDataTestHw, givenSemaphoreBufferAllocationWhenGetAllocationDataIsCalledThenItHasProperFieldsSet, IGFX_XE_HPC_CORE);
55+
HWTEST_EXCLUDE_PRODUCT(HwHelperTest, givenHwHelperWhenAskingForPatIndexWaThenReturnFalse, IGFX_XE_HPC_CORE);

opencl/test/unit_test/xe_hpc_core/hw_helper_tests_xe_hpc_core.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -826,3 +826,9 @@ XE_HPC_CORETEST_F(HwHelperTestsXeHpcCore, givenCommandBufferAllocationWhenSetExt
826826
XE_HPC_CORETEST_F(HwHelperTestsXeHpcCore, WhenGettingDeviceIpVersionThenMakeCorrectDeviceIpVersion) {
827827
EXPECT_EQ(ClHwHelperMock::makeDeviceIpVersion(12, 8, 1), ClHwHelper::get(renderCoreFamily).getDeviceIpVersion(*defaultHwInfo));
828828
}
829+
830+
XE_HPC_CORETEST_F(HwHelperTestsXeHpcCore, givenHwHelperWhenAskingForPatIndexWaThenReturnTrue) {
831+
const auto &hwHelper = HwHelper::get(renderCoreFamily);
832+
833+
EXPECT_TRUE(hwHelper.isPatIndexFallbackWaRequired());
834+
}

shared/source/gmm_helper/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
set(NEO_CORE_GMM_HELPER
88
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
99
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}resource_info_${DRIVER_MODEL}.cpp
10+
${CMAKE_CURRENT_SOURCE_DIR}/client_context${BRANCH_DIR_SUFFIX}/gmm_client_context_extra.cpp
1011
${CMAKE_CURRENT_SOURCE_DIR}/client_context/gmm_client_context.cpp
1112
${CMAKE_CURRENT_SOURCE_DIR}/client_context/gmm_client_context.h
1213
${CMAKE_CURRENT_SOURCE_DIR}/cache_settings_helper.cpp

shared/source/gmm_helper/client_context/gmm_client_context.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,4 @@ void GmmClientContext::setGmmDeviceInfo(GMM_DEVICE_INFO *deviceInfo) {
7979
clientContext->GmmSetDeviceInfo(deviceInfo);
8080
}
8181

82-
uint32_t GmmClientContext::cachePolicyGetPATIndex(GMM_RESOURCE_INFO *gmmResourceInfo, GMM_RESOURCE_USAGE_TYPE usage) {
83-
return clientContext->CachePolicyGetPATIndex(gmmResourceInfo, usage, nullptr, false);
84-
}
85-
8682
} // namespace NEO
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (C) 2022 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "shared/source/gmm_helper/client_context/gmm_client_context.h"
9+
10+
namespace NEO {
11+
12+
uint32_t GmmClientContext::cachePolicyGetPATIndex(GMM_RESOURCE_INFO *gmmResourceInfo, GMM_RESOURCE_USAGE_TYPE usage) {
13+
return 0;
14+
}
15+
16+
} // namespace NEO

shared/source/helpers/hw_helper.h

+2
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ class HwHelper {
156156
virtual size_t getBatchBufferEndSize() const = 0;
157157
virtual const void *getBatchBufferEndReference() const = 0;
158158
virtual bool isPlatformFlushTaskEnabled(const NEO::HardwareInfo &hwInfo) const = 0;
159+
virtual bool isPatIndexFallbackWaRequired() const = 0;
159160
virtual uint32_t getMinimalScratchSpaceSize() const = 0;
160161

161162
protected:
@@ -396,6 +397,7 @@ class HwHelperHw : public HwHelper {
396397
size_t getBatchBufferEndSize() const override;
397398
const void *getBatchBufferEndReference() const override;
398399
bool isPlatformFlushTaskEnabled(const NEO::HardwareInfo &hwInfo) const override;
400+
bool isPatIndexFallbackWaRequired() const override;
399401
uint32_t getMinimalScratchSpaceSize() const override;
400402

401403
protected:

shared/source/helpers/hw_helper_base.inl

+6
Original file line numberDiff line numberDiff line change
@@ -712,4 +712,10 @@ uint64_t HwHelperHw<GfxFamily>::getPatIndex(CacheRegion cacheRegion, CachePolicy
712712

713713
return -1;
714714
}
715+
716+
template <typename GfxFamily>
717+
bool HwHelperHw<GfxFamily>::isPatIndexFallbackWaRequired() const {
718+
return false;
719+
}
720+
715721
} // namespace NEO

shared/source/os_interface/linux/drm_neo.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -1304,13 +1304,11 @@ uint64_t Drm::getPatIndex(Gmm *gmm, AllocationType allocationType, CacheRegion c
13041304

13051305
uint64_t patIndex = rootDeviceEnvironment.getGmmClientContext()->cachePolicyGetPATIndex(resourceInfo, usageType);
13061306

1307-
UNRECOVERABLE_IF(patIndex == static_cast<uint64_t>(GMM_PAT_ERROR));
1308-
13091307
if (DebugManager.flags.ClosEnabled.get() != -1) {
13101308
closEnabled = !!DebugManager.flags.ClosEnabled.get();
13111309
}
13121310

1313-
if (closEnabled) {
1311+
if (patIndex == static_cast<uint64_t>(GMM_PAT_ERROR) || closEnabled || hwHelper.isPatIndexFallbackWaRequired()) {
13141312
patIndex = hwHelper.getPatIndex(cacheRegion, cachePolicy);
13151313
}
13161314

shared/source/xe_hpc_core/hw_helper_xe_hpc_core.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,11 @@ uint64_t HwHelperHw<Family>::getPatIndex(CacheRegion cacheRegion, CachePolicy ca
437437
return (static_cast<uint32_t>(cachePolicy) + (static_cast<uint16_t>(cacheRegion) * 2));
438438
}
439439

440+
template <>
441+
bool HwHelperHw<Family>::isPatIndexFallbackWaRequired() const {
442+
return true;
443+
}
444+
440445
} // namespace NEO
441446

442447
#include "shared/source/helpers/hw_helper_pvc_and_later.inl"

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

+65-2
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,9 @@ HWTEST_F(DrmMemoryOperationsHandlerBindTest, givenPatIndexProgrammingEnabledWhen
739739

740740
if (debugFlag == 0 || !closSupported || debugFlag == -1) {
741741
auto expectedIndex = static_cast<uint64_t>(MockGmmClientContextBase::MockPatIndex::cached);
742+
if (hwHelper.isPatIndexFallbackWaRequired()) {
743+
expectedIndex = hwHelper.getPatIndex(CacheRegion::Default, CachePolicy::WriteBack);
744+
}
742745

743746
EXPECT_EQ(expectedIndex, mock->context.receivedVmBindPatIndex.value());
744747

@@ -753,7 +756,51 @@ HWTEST_F(DrmMemoryOperationsHandlerBindTest, givenPatIndexProgrammingEnabledWhen
753756
}
754757
}
755758

756-
HWTEST_F(DrmMemoryOperationsHandlerBindTest, givenPatIndexErrorAndUncachedDebugFlagSetWhenGetPatIndexCalledThenAbort) {
759+
HWTEST_F(DrmMemoryOperationsHandlerBindTest, givenPatIndexErrorWhenVmBindCalledThenSetDefaultPatIndexExtension) {
760+
DebugManager.flags.UseVmBind.set(1);
761+
mock->bindAvailable = true;
762+
763+
auto csr = std::make_unique<UltCommandStreamReceiver<FamilyType>>(*executionEnvironment, 0, DeviceBitfield(1));
764+
auto osContext = memoryManager->createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor());
765+
csr->setupContext(*osContext);
766+
767+
auto &hwHelper = HwHelper::get(executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo()->platform.eRenderCoreFamily);
768+
auto hwInfoConfig = HwInfoConfig::get(executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo()->platform.eProductFamily);
769+
770+
bool closSupported = (hwHelper.getNumCacheRegions() > 0);
771+
bool patIndexProgrammingSupported = hwInfoConfig->isVmBindPatIndexProgrammingSupported();
772+
773+
if (!closSupported || !patIndexProgrammingSupported) {
774+
GTEST_SKIP();
775+
}
776+
777+
uint64_t gpuAddress = 0x123000;
778+
size_t size = 1;
779+
BufferObject bo(mock, static_cast<uint64_t>(MockGmmClientContextBase::MockPatIndex::cached), 0, 1, 1);
780+
DrmAllocation allocation(0, 1, AllocationType::BUFFER, &bo, nullptr, gpuAddress, size, MemoryPool::System4KBPages);
781+
782+
auto allocationPtr = static_cast<GraphicsAllocation *>(&allocation);
783+
784+
static_cast<MockGmmClientContextBase *>(executionEnvironment->rootDeviceEnvironments[0]->getGmmClientContext())->returnErrorOnPatIndexQuery = true;
785+
786+
for (int32_t debugFlag : {-1, 0, 1}) {
787+
DebugManager.flags.ClosEnabled.set(debugFlag);
788+
789+
mock->context.receivedVmBindPatIndex.reset();
790+
mock->context.receivedVmUnbindPatIndex.reset();
791+
792+
bo.setPatIndex(mock->getPatIndex(allocation.getDefaultGmm(), allocation.getAllocationType(), CacheRegion::Default, CachePolicy::WriteBack, false));
793+
794+
operationHandler->makeResident(device, ArrayRef<GraphicsAllocation *>(&allocationPtr, 1));
795+
796+
EXPECT_EQ(3u, mock->context.receivedVmBindPatIndex.value());
797+
798+
operationHandler->evict(device, allocation);
799+
EXPECT_EQ(3u, mock->context.receivedVmUnbindPatIndex.value());
800+
}
801+
}
802+
803+
HWTEST_F(DrmMemoryOperationsHandlerBindTest, givenPatIndexErrorAndUncachedDebugFlagSetWhenVmBindCalledThenSetDefaultPatIndexExtension) {
757804
DebugManager.flags.UseVmBind.set(1);
758805
DebugManager.flags.ForceAllResourcesUncached.set(1);
759806
mock->bindAvailable = true;
@@ -774,12 +821,24 @@ HWTEST_F(DrmMemoryOperationsHandlerBindTest, givenPatIndexErrorAndUncachedDebugF
774821

775822
static_cast<MockGmmClientContextBase *>(executionEnvironment->rootDeviceEnvironments[0]->getGmmClientContext())->returnErrorOnPatIndexQuery = true;
776823

824+
mock->context.receivedVmBindPatIndex.reset();
825+
mock->context.receivedVmUnbindPatIndex.reset();
826+
777827
uint64_t gpuAddress = 0x123000;
778828
size_t size = 1;
779829
BufferObject bo(mock, static_cast<uint64_t>(MockGmmClientContextBase::MockPatIndex::cached), 0, 1, 1);
780830
DrmAllocation allocation(0, 1, AllocationType::BUFFER, &bo, nullptr, gpuAddress, size, MemoryPool::System4KBPages);
781831

782-
EXPECT_ANY_THROW(mock->getPatIndex(allocation.getDefaultGmm(), allocation.getAllocationType(), CacheRegion::Default, CachePolicy::WriteBack, false));
832+
bo.setPatIndex(mock->getPatIndex(allocation.getDefaultGmm(), allocation.getAllocationType(), CacheRegion::Default, CachePolicy::WriteBack, false));
833+
834+
auto allocationPtr = static_cast<GraphicsAllocation *>(&allocation);
835+
836+
operationHandler->makeResident(device, ArrayRef<GraphicsAllocation *>(&allocationPtr, 1));
837+
838+
EXPECT_EQ(0u, mock->context.receivedVmBindPatIndex.value());
839+
840+
operationHandler->evict(device, allocation);
841+
EXPECT_EQ(0u, mock->context.receivedVmUnbindPatIndex.value());
783842
}
784843

785844
HWTEST_F(DrmMemoryOperationsHandlerBindTest, givenUncachedDebugFlagSetWhenVmBindCalledThenSetCorrectPatIndexExtension) {
@@ -793,6 +852,7 @@ HWTEST_F(DrmMemoryOperationsHandlerBindTest, givenUncachedDebugFlagSetWhenVmBind
793852

794853
auto timestampStorageAlloc = csr->getTimestampPacketAllocator()->getTag()->getBaseGraphicsAllocation()->getDefaultGraphicsAllocation();
795854

855+
auto &hwHelper = HwHelper::get(executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo()->platform.eRenderCoreFamily);
796856
auto hwInfoConfig = HwInfoConfig::get(executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo()->platform.eProductFamily);
797857

798858
if (!hwInfoConfig->isVmBindPatIndexProgrammingSupported()) {
@@ -805,6 +865,9 @@ HWTEST_F(DrmMemoryOperationsHandlerBindTest, givenUncachedDebugFlagSetWhenVmBind
805865
operationHandler->makeResident(device, ArrayRef<GraphicsAllocation *>(&timestampStorageAlloc, 1));
806866

807867
auto expectedIndex = static_cast<uint64_t>(MockGmmClientContextBase::MockPatIndex::uncached);
868+
if (hwHelper.isPatIndexFallbackWaRequired()) {
869+
expectedIndex = hwHelper.getPatIndex(CacheRegion::Default, CachePolicy::Uncached);
870+
}
808871

809872
EXPECT_EQ(expectedIndex, mock->context.receivedVmBindPatIndex.value());
810873

0 commit comments

Comments
 (0)