Narrowing the usDeviceID range for WA

This patch narrows down the scope covered by WA
to G10 machines only

Related-To: NEO-7475
Signed-off-by: Andrzej Koska andrzej.koska@intel.com
This commit is contained in:
Andrzej Koska 2023-01-03 18:44:33 +00:00 committed by Compute-Runtime-Automation
parent bc5bce6847
commit be9775891c
5 changed files with 220 additions and 2 deletions

View File

@ -123,7 +123,7 @@ bool ProductHelperHw<gfxProduct>::allowCompression(const HardwareInfo &hwInfo) c
template <>
LocalMemoryAccessMode ProductHelperHw<gfxProduct>::getDefaultLocalMemoryAccessMode(const HardwareInfo &hwInfo) const {
if (GfxCoreHelper::isWorkaroundRequired(REVISION_A0, REVISION_B, hwInfo, *this)) {
if (DG2::isG10(hwInfo) && GfxCoreHelper::isWorkaroundRequired(REVISION_A0, REVISION_B, hwInfo, *this)) {
return LocalMemoryAccessMode::CpuAccessDisallowed;
}
return LocalMemoryAccessMode::Default;

View File

@ -6,6 +6,8 @@
*/
#include "shared/source/helpers/hw_helper.h"
#include "shared/source/memory_manager/allocation_properties.h"
#include "shared/source/memory_manager/allocation_type.h"
#include "shared/source/xe_hpg_core/hw_cmds_dg2.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/default_hw_info.h"
@ -84,3 +86,21 @@ DG2TEST_F(GfxCoreHelperTestDg2, givenRcsDisabledButDebugVariableSetWhenGetGpgpuE
EXPECT_EQ(aub_stream::ENGINE_BCS, engines[7].first);
EXPECT_EQ(aub_stream::ENGINE_BCS, engines[8].first);
}
using GfxCoreHelperTests = Test<DeviceFixture>;
DG2TEST_F(GfxCoreHelperTests, givenAllocationTypeInternalHeapWhenSetExtraAllocationDataThenUseSystemMemory) {
HardwareInfo hwInfo = *defaultHwInfo;
hwInfo.platform.usDeviceID = dg2G10DeviceIds[0];
auto &gfxCoreHelper = getHelper<GfxCoreHelper>();
constexpr DeviceBitfield singleTileBitfield = 0b0100;
const AllocationProperties singleTileAllocProperties(0, 1, AllocationType::INTERNAL_HEAP, singleTileBitfield);
AllocationData allocData;
allocData.flags.useSystemMemory = false;
gfxCoreHelper.setExtraAllocationData(allocData, singleTileAllocProperties, hwInfo);
EXPECT_TRUE(allocData.flags.useSystemMemory);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2022 Intel Corporation
* Copyright (C) 2021-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -45,6 +45,7 @@ DG2TEST_F(Dg2ProductHelper, givenDG2WithBSteppingThenMaxThreadsForWorkgroupWAIsN
}
DG2TEST_F(Dg2ProductHelper, givenSteppingWhenAskingForLocalMemoryAccessModeThenDisallowOnA0) {
pInHwInfo.platform.usDeviceID = dg2G10DeviceIds[0];
pInHwInfo.platform.usRevId = productHelper->getHwRevIdFromStepping(REVISION_A0, pInHwInfo);
EXPECT_EQ(LocalMemoryAccessMode::CpuAccessDisallowed, productHelper->getLocalMemoryAccessMode(pInHwInfo));
@ -85,3 +86,16 @@ DG2TEST_F(Dg2ProductHelper, givenProductHelperWhenGetCommandsStreamPropertiesSup
EXPECT_FALSE(productHelper->getPipelineSelectPropertyMediaSamplerDopClockGateSupport());
EXPECT_TRUE(productHelper->getPipelineSelectPropertySystolicModeSupport());
}
DG2TEST_F(Dg2ProductHelper, givenDG2WhenGettingLocalMemoryAccessModeThenCorrectValueIsReturned) {
pInHwInfo.platform.usRevId = REVISION_A0;
pInHwInfo.platform.usDeviceID = dg2G10DeviceIds[0];
EXPECT_EQ(LocalMemoryAccessMode::CpuAccessDisallowed, productHelper->getLocalMemoryAccessMode(pInHwInfo));
pInHwInfo.platform.usDeviceID = dg2G11DeviceIds[0];
EXPECT_EQ(LocalMemoryAccessMode::Default, productHelper->getLocalMemoryAccessMode(pInHwInfo));
pInHwInfo.platform.usDeviceID = dg2G12DeviceIds[0];
EXPECT_EQ(LocalMemoryAccessMode::Default, productHelper->getLocalMemoryAccessMode(pInHwInfo));
}

View File

@ -0,0 +1,12 @@
#
# Copyright (C) 2023 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(WIN32)
target_sources(neo_shared_tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_manager_tests_dg2.cpp
)
endif()

View File

@ -0,0 +1,172 @@
/*
* Copyright (C) 2020-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/gmm_helper/gmm_helper.h"
#include "shared/source/os_interface/hw_info_config.h"
#include "shared/source/os_interface/windows/wddm_memory_operations_handler.h"
#include "shared/test/common/mocks/mock_wddm.h"
#include "shared/test/common/mocks/windows/mock_gmm_memory_base.h"
#include "shared/test/common/os_interface/windows/gdi_dll_fixture.h"
#include "shared/test/common/os_interface/windows/mock_wddm_memory_manager.h"
#include "shared/test/common/test_macros/hw_test.h"
using namespace NEO;
using Dg2WddmTest = ::testing::Test;
DG2TEST_F(Dg2WddmTest, givenG10A0WhenGettingLocalMemoryAccessModeThenCorrectValueIsReturned) {
MockExecutionEnvironment executionEnvironment;
RootDeviceEnvironment *rootDeviceEnvironment = executionEnvironment.rootDeviceEnvironments[0].get();
rootDeviceEnvironment->initGmm();
WddmMock *wddm = static_cast<WddmMock *>(Wddm::createWddm(nullptr, *rootDeviceEnvironment));
MockGmmMemoryBase *gmmMemory = new MockGmmMemoryBase(rootDeviceEnvironment->getGmmClientContext());
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
rootDeviceEnvironment->osInterface->setDriverModel(std::unique_ptr<DriverModel>(wddm));
wddm->init();
wddm->gmmMemory.reset(gmmMemory);
constexpr uint16_t REV_ID_A0 = 0;
rootDeviceEnvironment->getMutableHardwareInfo()->platform.usRevId = REV_ID_A0;
rootDeviceEnvironment->getMutableHardwareInfo()->platform.usDeviceID = dg2G10DeviceIds[0];
MockWddmMemoryManager memoryManager = MockWddmMemoryManager(false, true, executionEnvironment);
auto graphicsAllocation = memoryManager.allocateGraphicsMemoryWithProperties({mockRootDeviceIndex, 4096u, AllocationType::LINEAR_STREAM, mockDeviceBitfield});
ASSERT_NE(nullptr, graphicsAllocation);
EXPECT_NE(nullptr, graphicsAllocation->getUnderlyingBuffer());
EXPECT_EQ(graphicsAllocation->getAllocationType(), AllocationType::LINEAR_STREAM);
auto gpuAddress = graphicsAllocation->getGpuAddress();
auto gpuAddressEnd = gpuAddress + 4096u;
auto gmmHelper = memoryManager.getGmmHelper(graphicsAllocation->getRootDeviceIndex());
EXPECT_NE(MemoryPool::LocalMemory, graphicsAllocation->getMemoryPool());
EXPECT_FALSE(graphicsAllocation->isLocked());
auto &partition = wddm->getGfxPartition();
EXPECT_GE(gpuAddress, gmmHelper->canonize(partition.SVM.Base));
EXPECT_LE(gpuAddressEnd, gmmHelper->canonize(partition.SVM.Limit));
memoryManager.freeGraphicsMemory(graphicsAllocation);
}
DG2TEST_F(Dg2WddmTest, givenG10B0WhenGettingLocalMemoryAccessModeThenCorrectValueIsReturned) {
MockExecutionEnvironment executionEnvironment;
RootDeviceEnvironment *rootDeviceEnvironment = executionEnvironment.rootDeviceEnvironments[0].get();
rootDeviceEnvironment->initGmm();
WddmMock *wddm = static_cast<WddmMock *>(Wddm::createWddm(nullptr, *rootDeviceEnvironment));
MockGmmMemoryBase *gmmMemory = new MockGmmMemoryBase(rootDeviceEnvironment->getGmmClientContext());
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
rootDeviceEnvironment->osInterface->setDriverModel(std::unique_ptr<DriverModel>(wddm));
wddm->init();
wddm->gmmMemory.reset(gmmMemory);
constexpr uint16_t REV_ID_B0 = 4;
rootDeviceEnvironment->getMutableHardwareInfo()->platform.usRevId = REV_ID_B0;
rootDeviceEnvironment->getMutableHardwareInfo()->platform.usDeviceID = dg2G10DeviceIds[0];
MockWddmMemoryManager memoryManager = MockWddmMemoryManager(false, true, executionEnvironment);
auto graphicsAllocation = memoryManager.allocateGraphicsMemoryWithProperties({mockRootDeviceIndex, 4096u, AllocationType::LINEAR_STREAM, mockDeviceBitfield});
ASSERT_NE(nullptr, graphicsAllocation);
EXPECT_NE(nullptr, graphicsAllocation->getUnderlyingBuffer());
EXPECT_EQ(graphicsAllocation->getAllocationType(), AllocationType::LINEAR_STREAM);
auto gpuAddress = graphicsAllocation->getGpuAddress();
auto gpuAddressEnd = gpuAddress + 4096u;
auto gmmHelper = memoryManager.getGmmHelper(graphicsAllocation->getRootDeviceIndex());
EXPECT_EQ(MemoryPool::LocalMemory, graphicsAllocation->getMemoryPool());
EXPECT_TRUE(graphicsAllocation->isLocked());
auto &partition = wddm->getGfxPartition();
if (is64bit) {
EXPECT_GE(gpuAddress, gmmHelper->canonize(partition.Standard64KB.Base));
EXPECT_LE(gpuAddressEnd, gmmHelper->canonize(partition.Standard64KB.Limit));
} else {
EXPECT_GE(gpuAddress, gmmHelper->canonize(partition.SVM.Base));
EXPECT_LE(gpuAddressEnd, gmmHelper->canonize(partition.SVM.Limit));
}
memoryManager.freeGraphicsMemory(graphicsAllocation);
}
DG2TEST_F(Dg2WddmTest, givenG11WhenGettingLocalMemoryAccessModeThenCorrectValueIsReturned) {
MockExecutionEnvironment executionEnvironment;
RootDeviceEnvironment *rootDeviceEnvironment = executionEnvironment.rootDeviceEnvironments[0].get();
rootDeviceEnvironment->initGmm();
WddmMock *wddm = static_cast<WddmMock *>(Wddm::createWddm(nullptr, *rootDeviceEnvironment));
MockGmmMemoryBase *gmmMemory = new MockGmmMemoryBase(rootDeviceEnvironment->getGmmClientContext());
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
rootDeviceEnvironment->osInterface->setDriverModel(std::unique_ptr<DriverModel>(wddm));
wddm->init();
wddm->gmmMemory.reset(gmmMemory);
rootDeviceEnvironment->getMutableHardwareInfo()->platform.usDeviceID = dg2G11DeviceIds[0];
MockWddmMemoryManager memoryManager = MockWddmMemoryManager(false, true, executionEnvironment);
auto graphicsAllocation = memoryManager.allocateGraphicsMemoryWithProperties({mockRootDeviceIndex, 4096u, AllocationType::LINEAR_STREAM, mockDeviceBitfield});
ASSERT_NE(nullptr, graphicsAllocation);
EXPECT_NE(nullptr, graphicsAllocation->getUnderlyingBuffer());
EXPECT_EQ(graphicsAllocation->getAllocationType(), AllocationType::LINEAR_STREAM);
auto gpuAddress = graphicsAllocation->getGpuAddress();
auto gpuAddressEnd = gpuAddress + 4096u;
auto gmmHelper = memoryManager.getGmmHelper(graphicsAllocation->getRootDeviceIndex());
EXPECT_EQ(MemoryPool::LocalMemory, graphicsAllocation->getMemoryPool());
EXPECT_TRUE(graphicsAllocation->isLocked());
auto &partition = wddm->getGfxPartition();
if (is64bit) {
EXPECT_GE(gpuAddress, gmmHelper->canonize(partition.Standard64KB.Base));
EXPECT_LE(gpuAddressEnd, gmmHelper->canonize(partition.Standard64KB.Limit));
} else {
EXPECT_GE(gpuAddress, gmmHelper->canonize(partition.SVM.Base));
EXPECT_LE(gpuAddressEnd, gmmHelper->canonize(partition.SVM.Limit));
}
memoryManager.freeGraphicsMemory(graphicsAllocation);
}
DG2TEST_F(Dg2WddmTest, givenG12WhenGettingLocalMemoryAccessModeThenCorrectValueIsReturned) {
MockExecutionEnvironment executionEnvironment;
RootDeviceEnvironment *rootDeviceEnvironment = executionEnvironment.rootDeviceEnvironments[0].get();
rootDeviceEnvironment->initGmm();
WddmMock *wddm = static_cast<WddmMock *>(Wddm::createWddm(nullptr, *rootDeviceEnvironment));
MockGmmMemoryBase *gmmMemory = new MockGmmMemoryBase(rootDeviceEnvironment->getGmmClientContext());
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
rootDeviceEnvironment->osInterface->setDriverModel(std::unique_ptr<DriverModel>(wddm));
wddm->init();
wddm->gmmMemory.reset(gmmMemory);
rootDeviceEnvironment->getMutableHardwareInfo()->platform.usDeviceID = dg2G12DeviceIds[0];
MockWddmMemoryManager memoryManager = MockWddmMemoryManager(false, true, executionEnvironment);
auto graphicsAllocation = memoryManager.allocateGraphicsMemoryWithProperties({mockRootDeviceIndex, 4096u, AllocationType::LINEAR_STREAM, mockDeviceBitfield});
ASSERT_NE(nullptr, graphicsAllocation);
EXPECT_NE(nullptr, graphicsAllocation->getUnderlyingBuffer());
EXPECT_EQ(graphicsAllocation->getAllocationType(), AllocationType::LINEAR_STREAM);
auto gpuAddress = graphicsAllocation->getGpuAddress();
auto gpuAddressEnd = gpuAddress + 4096u;
auto gmmHelper = memoryManager.getGmmHelper(graphicsAllocation->getRootDeviceIndex());
EXPECT_EQ(MemoryPool::LocalMemory, graphicsAllocation->getMemoryPool());
EXPECT_TRUE(graphicsAllocation->isLocked());
auto &partition = wddm->getGfxPartition();
if (is64bit) {
EXPECT_GE(gpuAddress, gmmHelper->canonize(partition.Standard64KB.Base));
EXPECT_LE(gpuAddressEnd, gmmHelper->canonize(partition.Standard64KB.Limit));
} else {
EXPECT_GE(gpuAddress, gmmHelper->canonize(partition.SVM.Base));
EXPECT_LE(gpuAddressEnd, gmmHelper->canonize(partition.SVM.Limit));
}
memoryManager.freeGraphicsMemory(graphicsAllocation);
}