Skip to content

Commit

Permalink
Revert "Remove fallback path for PAT index programming"
Browse files Browse the repository at this point in the history
This reverts commit faf8d51.

Signed-off-by: Compute-Runtime-Validation <[email protected]>
  • Loading branch information
Compute-Runtime-Validation authored and Compute-Runtime-Automation committed Sep 23, 2022
1 parent fbc9188 commit f5575a1
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 9 deletions.
6 changes: 6 additions & 0 deletions opencl/test/unit_test/helpers/hw_helper_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1456,6 +1456,12 @@ HWTEST_F(HwHelperTest, GivenHwInfoWhenGetBatchBufferEndReferenceCalledThenCorrec
EXPECT_EQ(hwHelper.getBatchBufferEndReference(), reinterpret_cast<const void *>(&FamilyType::cmdInitBatchBufferEnd));
}

HWTEST_F(HwHelperTest, givenHwHelperWhenAskingForPatIndexWaThenReturnFalse) {
const auto &hwHelper = HwHelper::get(renderCoreFamily);

EXPECT_FALSE(hwHelper.isPatIndexFallbackWaRequired());
}

HWTEST_F(HwHelperTest, givenHwHelperWhenPassingCopyEngineTypeThenItsCopyOnly) {
EXPECT_TRUE(EngineHelper::isCopyOnlyEngineType(EngineGroupType::Copy));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ HWTEST_EXCLUDE_PRODUCT(CommandStreamReceiverFlushTaskTests, givenOverrideThreadA
HWTEST_EXCLUDE_PRODUCT(XeHPAndLaterAubCommandStreamReceiverWithoutFixtureTests, GivenCopyHostPtrAndHostNoAccessAndReadOnlyFlagsWhenAllocatingBufferThenAllocationIsCopiedToEveryTile, IGFX_XE_HPC_CORE);
HWTEST_EXCLUDE_PRODUCT(GetAllocationDataTestHw, givenRingBufferAllocationWhenGetAllocationDataIsCalledThenItHasProperFieldsSet, IGFX_XE_HPC_CORE);
HWTEST_EXCLUDE_PRODUCT(GetAllocationDataTestHw, givenSemaphoreBufferAllocationWhenGetAllocationDataIsCalledThenItHasProperFieldsSet, IGFX_XE_HPC_CORE);
HWTEST_EXCLUDE_PRODUCT(HwHelperTest, givenHwHelperWhenAskingForPatIndexWaThenReturnFalse, IGFX_XE_HPC_CORE);
Original file line number Diff line number Diff line change
Expand Up @@ -826,3 +826,9 @@ XE_HPC_CORETEST_F(HwHelperTestsXeHpcCore, givenCommandBufferAllocationWhenSetExt
XE_HPC_CORETEST_F(HwHelperTestsXeHpcCore, WhenGettingDeviceIpVersionThenMakeCorrectDeviceIpVersion) {
EXPECT_EQ(ClHwHelperMock::makeDeviceIpVersion(12, 8, 1), ClHwHelper::get(renderCoreFamily).getDeviceIpVersion(*defaultHwInfo));
}

XE_HPC_CORETEST_F(HwHelperTestsXeHpcCore, givenHwHelperWhenAskingForPatIndexWaThenReturnTrue) {
const auto &hwHelper = HwHelper::get(renderCoreFamily);

EXPECT_TRUE(hwHelper.isPatIndexFallbackWaRequired());
}
1 change: 1 addition & 0 deletions shared/source/gmm_helper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
set(NEO_CORE_GMM_HELPER
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}resource_info_${DRIVER_MODEL}.cpp
${CMAKE_CURRENT_SOURCE_DIR}/client_context${BRANCH_DIR_SUFFIX}/gmm_client_context_extra.cpp
${CMAKE_CURRENT_SOURCE_DIR}/client_context/gmm_client_context.cpp
${CMAKE_CURRENT_SOURCE_DIR}/client_context/gmm_client_context.h
${CMAKE_CURRENT_SOURCE_DIR}/cache_settings_helper.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,4 @@ void GmmClientContext::setGmmDeviceInfo(GMM_DEVICE_INFO *deviceInfo) {
clientContext->GmmSetDeviceInfo(deviceInfo);
}

uint32_t GmmClientContext::cachePolicyGetPATIndex(GMM_RESOURCE_INFO *gmmResourceInfo, GMM_RESOURCE_USAGE_TYPE usage) {
return clientContext->CachePolicyGetPATIndex(gmmResourceInfo, usage, nullptr, false);
}

} // namespace NEO
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/

#include "shared/source/gmm_helper/client_context/gmm_client_context.h"

namespace NEO {

uint32_t GmmClientContext::cachePolicyGetPATIndex(GMM_RESOURCE_INFO *gmmResourceInfo, GMM_RESOURCE_USAGE_TYPE usage) {
return 0;
}

} // namespace NEO
2 changes: 2 additions & 0 deletions shared/source/helpers/hw_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ class HwHelper {
virtual size_t getBatchBufferEndSize() const = 0;
virtual const void *getBatchBufferEndReference() const = 0;
virtual bool isPlatformFlushTaskEnabled(const NEO::HardwareInfo &hwInfo) const = 0;
virtual bool isPatIndexFallbackWaRequired() const = 0;
virtual uint32_t getMinimalScratchSpaceSize() const = 0;

protected:
Expand Down Expand Up @@ -396,6 +397,7 @@ class HwHelperHw : public HwHelper {
size_t getBatchBufferEndSize() const override;
const void *getBatchBufferEndReference() const override;
bool isPlatformFlushTaskEnabled(const NEO::HardwareInfo &hwInfo) const override;
bool isPatIndexFallbackWaRequired() const override;
uint32_t getMinimalScratchSpaceSize() const override;

protected:
Expand Down
6 changes: 6 additions & 0 deletions shared/source/helpers/hw_helper_base.inl
Original file line number Diff line number Diff line change
Expand Up @@ -712,4 +712,10 @@ uint64_t HwHelperHw<GfxFamily>::getPatIndex(CacheRegion cacheRegion, CachePolicy

return -1;
}

template <typename GfxFamily>
bool HwHelperHw<GfxFamily>::isPatIndexFallbackWaRequired() const {
return false;
}

} // namespace NEO
4 changes: 1 addition & 3 deletions shared/source/os_interface/linux/drm_neo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1304,13 +1304,11 @@ uint64_t Drm::getPatIndex(Gmm *gmm, AllocationType allocationType, CacheRegion c

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

UNRECOVERABLE_IF(patIndex == static_cast<uint64_t>(GMM_PAT_ERROR));

if (DebugManager.flags.ClosEnabled.get() != -1) {
closEnabled = !!DebugManager.flags.ClosEnabled.get();
}

if (closEnabled) {
if (patIndex == static_cast<uint64_t>(GMM_PAT_ERROR) || closEnabled || hwHelper.isPatIndexFallbackWaRequired()) {
patIndex = hwHelper.getPatIndex(cacheRegion, cachePolicy);
}

Expand Down
5 changes: 5 additions & 0 deletions shared/source/xe_hpc_core/hw_helper_xe_hpc_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,11 @@ uint64_t HwHelperHw<Family>::getPatIndex(CacheRegion cacheRegion, CachePolicy ca
return (static_cast<uint32_t>(cachePolicy) + (static_cast<uint16_t>(cacheRegion) * 2));
}

template <>
bool HwHelperHw<Family>::isPatIndexFallbackWaRequired() const {
return true;
}

} // namespace NEO

#include "shared/source/helpers/hw_helper_pvc_and_later.inl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,9 @@ HWTEST_F(DrmMemoryOperationsHandlerBindTest, givenPatIndexProgrammingEnabledWhen

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

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

Expand All @@ -753,7 +756,51 @@ HWTEST_F(DrmMemoryOperationsHandlerBindTest, givenPatIndexProgrammingEnabledWhen
}
}

HWTEST_F(DrmMemoryOperationsHandlerBindTest, givenPatIndexErrorAndUncachedDebugFlagSetWhenGetPatIndexCalledThenAbort) {
HWTEST_F(DrmMemoryOperationsHandlerBindTest, givenPatIndexErrorWhenVmBindCalledThenSetDefaultPatIndexExtension) {
DebugManager.flags.UseVmBind.set(1);
mock->bindAvailable = true;

auto csr = std::make_unique<UltCommandStreamReceiver<FamilyType>>(*executionEnvironment, 0, DeviceBitfield(1));
auto osContext = memoryManager->createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor());
csr->setupContext(*osContext);

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

bool closSupported = (hwHelper.getNumCacheRegions() > 0);
bool patIndexProgrammingSupported = hwInfoConfig->isVmBindPatIndexProgrammingSupported();

if (!closSupported || !patIndexProgrammingSupported) {
GTEST_SKIP();
}

uint64_t gpuAddress = 0x123000;
size_t size = 1;
BufferObject bo(mock, static_cast<uint64_t>(MockGmmClientContextBase::MockPatIndex::cached), 0, 1, 1);
DrmAllocation allocation(0, 1, AllocationType::BUFFER, &bo, nullptr, gpuAddress, size, MemoryPool::System4KBPages);

auto allocationPtr = static_cast<GraphicsAllocation *>(&allocation);

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

for (int32_t debugFlag : {-1, 0, 1}) {
DebugManager.flags.ClosEnabled.set(debugFlag);

mock->context.receivedVmBindPatIndex.reset();
mock->context.receivedVmUnbindPatIndex.reset();

bo.setPatIndex(mock->getPatIndex(allocation.getDefaultGmm(), allocation.getAllocationType(), CacheRegion::Default, CachePolicy::WriteBack, false));

operationHandler->makeResident(device, ArrayRef<GraphicsAllocation *>(&allocationPtr, 1));

EXPECT_EQ(3u, mock->context.receivedVmBindPatIndex.value());

operationHandler->evict(device, allocation);
EXPECT_EQ(3u, mock->context.receivedVmUnbindPatIndex.value());
}
}

HWTEST_F(DrmMemoryOperationsHandlerBindTest, givenPatIndexErrorAndUncachedDebugFlagSetWhenVmBindCalledThenSetDefaultPatIndexExtension) {
DebugManager.flags.UseVmBind.set(1);
DebugManager.flags.ForceAllResourcesUncached.set(1);
mock->bindAvailable = true;
Expand All @@ -774,12 +821,24 @@ HWTEST_F(DrmMemoryOperationsHandlerBindTest, givenPatIndexErrorAndUncachedDebugF

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

mock->context.receivedVmBindPatIndex.reset();
mock->context.receivedVmUnbindPatIndex.reset();

uint64_t gpuAddress = 0x123000;
size_t size = 1;
BufferObject bo(mock, static_cast<uint64_t>(MockGmmClientContextBase::MockPatIndex::cached), 0, 1, 1);
DrmAllocation allocation(0, 1, AllocationType::BUFFER, &bo, nullptr, gpuAddress, size, MemoryPool::System4KBPages);

EXPECT_ANY_THROW(mock->getPatIndex(allocation.getDefaultGmm(), allocation.getAllocationType(), CacheRegion::Default, CachePolicy::WriteBack, false));
bo.setPatIndex(mock->getPatIndex(allocation.getDefaultGmm(), allocation.getAllocationType(), CacheRegion::Default, CachePolicy::WriteBack, false));

auto allocationPtr = static_cast<GraphicsAllocation *>(&allocation);

operationHandler->makeResident(device, ArrayRef<GraphicsAllocation *>(&allocationPtr, 1));

EXPECT_EQ(0u, mock->context.receivedVmBindPatIndex.value());

operationHandler->evict(device, allocation);
EXPECT_EQ(0u, mock->context.receivedVmUnbindPatIndex.value());
}

HWTEST_F(DrmMemoryOperationsHandlerBindTest, givenUncachedDebugFlagSetWhenVmBindCalledThenSetCorrectPatIndexExtension) {
Expand All @@ -793,6 +852,7 @@ HWTEST_F(DrmMemoryOperationsHandlerBindTest, givenUncachedDebugFlagSetWhenVmBind

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

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

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

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

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

Expand Down

0 comments on commit f5575a1

Please sign in to comment.