mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 14:02:58 +08:00
Use HEAP_STANDARD for Limited-range allocations
Change-Id: I8b35cda2b5542e98a83021b4ce1c9f5118e6697d Signed-off-by: Venevtsev, Igor <igor.venevtsev@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
a3369a9679
commit
ddf3aa186d
@@ -23,7 +23,7 @@ void TestEnvironment::SetUp() {
|
||||
fclPushDebugVars(fclDefaultDebugVars);
|
||||
igcPushDebugVars(igcDefaultDebugVars);
|
||||
if (libraryOS == nullptr) {
|
||||
libraryOS = setAdapterInfo(hwInfoDefaultDebugVars.pPlatform, hwInfoDefaultDebugVars.pSysInfo);
|
||||
libraryOS = setAdapterInfo(hwInfoDefaultDebugVars.pPlatform, hwInfoDefaultDebugVars.pSysInfo, hwInfoDefaultDebugVars.capabilityTable.gpuAddressSpace);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
OsLibrary *setAdapterInfo(const PLATFORM *platform, const GT_SYSTEM_INFO *gtSystemInfo);
|
||||
OsLibrary *setAdapterInfo(const PLATFORM *platform, const GT_SYSTEM_INFO *gtSystemInfo, uint64_t gpuAddressSpace);
|
||||
|
||||
class TestEnvironment : public ::testing::Environment {
|
||||
public:
|
||||
|
||||
@@ -71,7 +71,7 @@ void testGfxPartition(uint64_t gpuAddressSpace) {
|
||||
size_t sizeBig = 4 * MemoryConstants::megaByte + MemoryConstants::pageSize;
|
||||
for (auto heap : MockGfxPartition::allHeapNames) {
|
||||
if (!gfxPartition.heapInitialized(heap)) {
|
||||
EXPECT_TRUE(heap == HeapIndex::HEAP_SVM || heap == HeapIndex::HEAP_LIMITED);
|
||||
EXPECT_TRUE(heap == HeapIndex::HEAP_SVM);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1671,12 +1671,12 @@ TEST(HeapSelectorTest, given32bitExternalAllocationWhenSelectingHeapThenExternal
|
||||
EXPECT_EQ(HeapIndex::HEAP_EXTERNAL, MemoryManager::selectHeap(&allocation, nullptr, *platformDevices[0]));
|
||||
}
|
||||
|
||||
TEST(HeapSelectorTest, givenLimitedAddressSpaceWhenSelectingHeapForExternalAllocationThenLimitedHeapIsUsed) {
|
||||
TEST(HeapSelectorTest, givenLimitedAddressSpaceWhenSelectingHeapForExternalAllocationThenStandardHeapIsUsed) {
|
||||
GraphicsAllocation allocation{GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull, false};
|
||||
if (platformDevices[0]->capabilityTable.gpuAddressSpace == MemoryConstants::max48BitAddress) {
|
||||
return;
|
||||
}
|
||||
EXPECT_EQ(HeapIndex::HEAP_LIMITED, MemoryManager::selectHeap(&allocation, nullptr, *platformDevices[0]));
|
||||
EXPECT_EQ(HeapIndex::HEAP_STANDARD, MemoryManager::selectHeap(&allocation, nullptr, *platformDevices[0]));
|
||||
}
|
||||
|
||||
TEST(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocationWithPtrThenSvmHeapIsUsed) {
|
||||
@@ -1718,10 +1718,10 @@ TEST(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForNullAllocationWi
|
||||
EXPECT_EQ(HeapIndex::HEAP_STANDARD, MemoryManager::selectHeap(nullptr, nullptr, *platformDevices[0]));
|
||||
}
|
||||
|
||||
TEST(HeapSelectorTest, givenLimitedAddressSpaceWhenSelectingHeapForNullAllocationWithoutPtrThenLimitedHeapIsUsed) {
|
||||
TEST(HeapSelectorTest, givenLimitedAddressSpaceWhenSelectingHeapForNullAllocationWithoutPtrThenStandardHeapIsUsed) {
|
||||
auto hwInfo = *platformDevices[0];
|
||||
hwInfo.capabilityTable.gpuAddressSpace = MemoryConstants::max32BitAddress;
|
||||
EXPECT_EQ(HeapIndex::HEAP_LIMITED, MemoryManager::selectHeap(nullptr, nullptr, hwInfo));
|
||||
EXPECT_EQ(HeapIndex::HEAP_STANDARD, MemoryManager::selectHeap(nullptr, nullptr, hwInfo));
|
||||
}
|
||||
|
||||
TEST(MemoryAllocationTest, givenAllocationTypeWhenPassedToMemoryAllocationConstructorThenAllocationTypeIsStored) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2017-2018 Intel Corporation
|
||||
# Copyright (C) 2017-2019 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
@@ -14,6 +14,7 @@ if(WIN32)
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_gdi.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_gdi.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/mock_gdi_gfx_partition.cpp
|
||||
${DEF_FILE}
|
||||
)
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ D3DDDI_MAPGPUVIRTUALADDRESS gLastCallMapGpuVaArg = {0};
|
||||
D3DDDI_RESERVEGPUVIRTUALADDRESS gLastCallReserveGpuVaArg = {0};
|
||||
uint32_t gMapGpuVaFailConfigCount = 0;
|
||||
uint32_t gMapGpuVaFailConfigMax = 0;
|
||||
uint64_t gGpuAddressSpace = 0ull;
|
||||
|
||||
#ifdef __cplusplus // If used by C++ code,
|
||||
extern "C" { // we need to export the C interface
|
||||
@@ -22,31 +23,7 @@ extern "C" { // we need to export the C interface
|
||||
BOOLEAN WINAPI DllMain(IN HINSTANCE hDllHandle,
|
||||
IN DWORD nReason,
|
||||
IN LPVOID Reserved) {
|
||||
BOOLEAN bRet = TRUE;
|
||||
|
||||
switch (nReason) {
|
||||
case DLL_PROCESS_ATTACH:
|
||||
gAdapterInfo.GfxPartition.Standard.Base = 0x0000800400000000;
|
||||
gAdapterInfo.GfxPartition.Standard.Limit = 0x0000eeffffffffff;
|
||||
gAdapterInfo.GfxPartition.Standard64KB.Base = 0x0000b80200000000;
|
||||
gAdapterInfo.GfxPartition.Standard64KB.Limit = 0x0000efffffffffff;
|
||||
gAdapterInfo.GfxPartition.SVM.Base = 0;
|
||||
gAdapterInfo.GfxPartition.SVM.Limit = 0x00007fffffffffff;
|
||||
gAdapterInfo.GfxPartition.Heap32[0].Base = 0x0000800000000000;
|
||||
gAdapterInfo.GfxPartition.Heap32[0].Limit = 0x00008000ffffefff;
|
||||
gAdapterInfo.GfxPartition.Heap32[1].Base = 0x0000800100000000;
|
||||
gAdapterInfo.GfxPartition.Heap32[1].Limit = 0x00008001ffffefff;
|
||||
gAdapterInfo.GfxPartition.Heap32[2].Base = 0x0000800200000000;
|
||||
gAdapterInfo.GfxPartition.Heap32[2].Limit = 0x00008002ffffefff;
|
||||
gAdapterInfo.GfxPartition.Heap32[3].Base = 0x0000800300000000;
|
||||
gAdapterInfo.GfxPartition.Heap32[3].Limit = 0x00008003ffffefff;
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return bRet;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
NTSTATUS __stdcall D3DKMTEscape(IN CONST D3DKMT_ESCAPE *pData) {
|
||||
@@ -64,13 +41,15 @@ DECL_FUNCTIONS()
|
||||
|
||||
UINT64 PagingFence = 0;
|
||||
|
||||
void __stdcall MockSetAdapterInfo(const void *pGfxPlatform, const void *pGTSystemInfo) {
|
||||
void __stdcall MockSetAdapterInfo(const void *pGfxPlatform, const void *pGTSystemInfo, uint64_t gpuAddressSpace) {
|
||||
if (pGfxPlatform != NULL) {
|
||||
gAdapterInfo.GfxPlatform = *(PLATFORM *)pGfxPlatform;
|
||||
}
|
||||
if (pGTSystemInfo != NULL) {
|
||||
gAdapterInfo.SystemInfo = *(GT_SYSTEM_INFO *)pGTSystemInfo;
|
||||
}
|
||||
gGpuAddressSpace = gpuAddressSpace;
|
||||
InitGfxPartition();
|
||||
}
|
||||
|
||||
NTSTATUS __stdcall D3DKMTOpenAdapterFromLuid(IN OUT CONST D3DKMT_OPENADAPTERFROMLUID *openAdapter) {
|
||||
|
||||
@@ -77,3 +77,4 @@ D3DKMT_CREATECONTEXTVIRTUAL *getCreateContextData();
|
||||
D3DKMT_CREATEHWQUEUE *getCreateHwQueueData();
|
||||
D3DKMT_DESTROYHWQUEUE *getDestroyHwQueueData();
|
||||
D3DKMT_SUBMITCOMMANDTOHWQUEUE *getSubmitCommandToHwQueueData();
|
||||
void InitGfxPartition();
|
||||
|
||||
27
unit_tests/mock_gdi/mock_gdi_gfx_partition.cpp
Normal file
27
unit_tests/mock_gdi/mock_gdi_gfx_partition.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mock_gdi.h"
|
||||
|
||||
extern ADAPTER_INFO gAdapterInfo;
|
||||
|
||||
void InitGfxPartition() {
|
||||
gAdapterInfo.GfxPartition.Standard.Base = 0x0000800400000000;
|
||||
gAdapterInfo.GfxPartition.Standard.Limit = 0x0000eeffffffffff;
|
||||
gAdapterInfo.GfxPartition.Standard64KB.Base = 0x0000b80200000000;
|
||||
gAdapterInfo.GfxPartition.Standard64KB.Limit = 0x0000efffffffffff;
|
||||
gAdapterInfo.GfxPartition.SVM.Base = 0;
|
||||
gAdapterInfo.GfxPartition.SVM.Limit = 0x00007fffffffffff;
|
||||
gAdapterInfo.GfxPartition.Heap32[0].Base = 0x0000800000000000;
|
||||
gAdapterInfo.GfxPartition.Heap32[0].Limit = 0x00008000ffffefff;
|
||||
gAdapterInfo.GfxPartition.Heap32[1].Base = 0x0000800100000000;
|
||||
gAdapterInfo.GfxPartition.Heap32[1].Limit = 0x00008001ffffefff;
|
||||
gAdapterInfo.GfxPartition.Heap32[2].Base = 0x0000800200000000;
|
||||
gAdapterInfo.GfxPartition.Heap32[2].Limit = 0x00008002ffffefff;
|
||||
gAdapterInfo.GfxPartition.Heap32[3].Base = 0x0000800300000000;
|
||||
gAdapterInfo.GfxPartition.Heap32[3].Limit = 0x00008003ffffefff;
|
||||
}
|
||||
@@ -16,5 +16,4 @@ std::array<HeapIndex, static_cast<uint32_t>(HeapIndex::TOTAL_HEAPS)>
|
||||
HeapIndex::HEAP_EXTERNAL,
|
||||
HeapIndex::HEAP_STANDARD,
|
||||
HeapIndex::HEAP_STANDARD64KB,
|
||||
HeapIndex::HEAP_SVM,
|
||||
HeapIndex::HEAP_LIMITED}};
|
||||
HeapIndex::HEAP_SVM}};
|
||||
|
||||
@@ -16,7 +16,7 @@ class MockGfxPartition : public GfxPartition {
|
||||
}
|
||||
|
||||
bool heapInitialized(HeapIndex heapIndex) {
|
||||
return getHeapBase(heapIndex) && getHeapSize(heapIndex);
|
||||
return getHeapSize(heapIndex) > 0;
|
||||
}
|
||||
|
||||
static std::array<HeapIndex, static_cast<uint32_t>(HeapIndex::TOTAL_HEAPS)> allHeapNames;
|
||||
|
||||
@@ -18,14 +18,14 @@
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
OsLibrary *setAdapterInfo(const PLATFORM *platform, const GT_SYSTEM_INFO *gtSystemInfo);
|
||||
OsLibrary *setAdapterInfo(const PLATFORM *platform, const GT_SYSTEM_INFO *gtSystemInfo, uint64_t gpuAddressSpace);
|
||||
|
||||
struct DeviceFactoryTest : public ::testing::Test {
|
||||
public:
|
||||
void SetUp() override {
|
||||
const HardwareInfo hwInfo = *platformDevices[0];
|
||||
executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||
mockGdiDll = setAdapterInfo(hwInfo.pPlatform, hwInfo.pSysInfo);
|
||||
mockGdiDll = setAdapterInfo(hwInfo.pPlatform, hwInfo.pSysInfo, hwInfo.capabilityTable.gpuAddressSpace);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
|
||||
@@ -26,6 +26,6 @@ const char *gmmEntryName = "openMockGmm";
|
||||
const char *sysFsPciPath = "./test_files";
|
||||
} // namespace Os
|
||||
|
||||
OCLRT::OsLibrary *setAdapterInfo(const PLATFORM *platform, const GT_SYSTEM_INFO *gtSystemInfo) {
|
||||
OCLRT::OsLibrary *setAdapterInfo(const PLATFORM *platform, const GT_SYSTEM_INFO *gtSystemInfo, uint64_t gpuAddressSpace) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -13,12 +13,12 @@
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
OsLibrary *setAdapterInfo(const PLATFORM *platform, const GT_SYSTEM_INFO *gtSystemInfo);
|
||||
OsLibrary *setAdapterInfo(const PLATFORM *platform, const GT_SYSTEM_INFO *gtSystemInfo, uint64_t gpuAddressSpace);
|
||||
|
||||
struct GdiDllFixture {
|
||||
virtual void SetUp() {
|
||||
const HardwareInfo hwInfo = *platformDevices[0];
|
||||
mockGdiDll.reset(setAdapterInfo(hwInfo.pPlatform, hwInfo.pSysInfo));
|
||||
mockGdiDll.reset(setAdapterInfo(hwInfo.pPlatform, hwInfo.pSysInfo, hwInfo.capabilityTable.gpuAddressSpace));
|
||||
|
||||
setSizesFcn = reinterpret_cast<decltype(&MockSetSizes)>(mockGdiDll->getProcAddress("MockSetSizes"));
|
||||
getSizesFcn = reinterpret_cast<decltype(&GetMockSizes)>(mockGdiDll->getProcAddress("GetMockSizes"));
|
||||
|
||||
@@ -23,14 +23,14 @@ const char *gmmEntryName = "openMockGmm";
|
||||
const char *testDllName = "test_dynamic_lib.dll";
|
||||
} // namespace Os
|
||||
|
||||
OCLRT::OsLibrary *setAdapterInfo(const PLATFORM *platform, const GT_SYSTEM_INFO *gtSystemInfo) {
|
||||
OCLRT::OsLibrary *setAdapterInfo(const PLATFORM *platform, const GT_SYSTEM_INFO *gtSystemInfo, uint64_t gpuAddressSpace) {
|
||||
OCLRT::OsLibrary *mockGdiDll;
|
||||
mockGdiDll = OCLRT::OsLibrary::load("gdi32_mock.dll");
|
||||
|
||||
typedef void(__stdcall * pfSetAdapterInfo)(const void *, const void *);
|
||||
typedef void(__stdcall * pfSetAdapterInfo)(const void *, const void *, uint64_t);
|
||||
pfSetAdapterInfo setAdpaterInfo = reinterpret_cast<pfSetAdapterInfo>(mockGdiDll->getProcAddress("MockSetAdapterInfo"));
|
||||
|
||||
setAdpaterInfo(platform, gtSystemInfo);
|
||||
setAdpaterInfo(platform, gtSystemInfo, gpuAddressSpace);
|
||||
|
||||
return mockGdiDll;
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ TEST(Wddm20EnumAdaptersTest, expectTrue) {
|
||||
HardwareInfo outHwInfo;
|
||||
|
||||
const HardwareInfo hwInfo = *platformDevices[0];
|
||||
OsLibrary *mockGdiDll = setAdapterInfo(hwInfo.pPlatform, hwInfo.pSysInfo);
|
||||
OsLibrary *mockGdiDll = setAdapterInfo(hwInfo.pPlatform, hwInfo.pSysInfo, hwInfo.capabilityTable.gpuAddressSpace);
|
||||
|
||||
std::unique_ptr<Wddm> wddm(Wddm::createWddm());
|
||||
bool success = wddm->enumAdapters(outHwInfo);
|
||||
@@ -112,7 +112,7 @@ TEST(Wddm20EnumAdaptersTest, givenEmptyHardwareInfoWhenEnumAdapterIsCalledThenCa
|
||||
HardwareInfo outHwInfo = {};
|
||||
|
||||
auto hwInfo = *platformDevices[0];
|
||||
std::unique_ptr<OsLibrary> mockGdiDll(setAdapterInfo(hwInfo.pPlatform, hwInfo.pSysInfo));
|
||||
std::unique_ptr<OsLibrary> mockGdiDll(setAdapterInfo(hwInfo.pPlatform, hwInfo.pSysInfo, hwInfo.capabilityTable.gpuAddressSpace));
|
||||
|
||||
std::unique_ptr<Wddm> wddm(Wddm::createWddm());
|
||||
bool success = wddm->enumAdapters(outHwInfo);
|
||||
@@ -147,13 +147,13 @@ TEST(Wddm20EnumAdaptersTest, givenUnknownPlatformWhenEnumAdapterIsCalledThenFals
|
||||
platform.eProductFamily = IGFX_UNKNOWN;
|
||||
|
||||
std::unique_ptr<OsLibrary, std::function<void(OsLibrary *)>> mockGdiDll(
|
||||
setAdapterInfo(&platform, hwInfo.pSysInfo),
|
||||
setAdapterInfo(&platform, hwInfo.pSysInfo, hwInfo.capabilityTable.gpuAddressSpace),
|
||||
[&](OsLibrary *ptr) {
|
||||
platform.eProductFamily = bkp;
|
||||
typedef void(__stdcall * pfSetAdapterInfo)(const void *, const void *);
|
||||
typedef void(__stdcall * pfSetAdapterInfo)(const void *, const void *, uint64_t);
|
||||
pfSetAdapterInfo fSetAdpaterInfo = reinterpret_cast<pfSetAdapterInfo>(ptr->getProcAddress("MockSetAdapterInfo"));
|
||||
|
||||
fSetAdpaterInfo(&platform, hwInfo.pSysInfo);
|
||||
fSetAdpaterInfo(&platform, hwInfo.pSysInfo, hwInfo.capabilityTable.gpuAddressSpace);
|
||||
delete ptr;
|
||||
});
|
||||
std::unique_ptr<Wddm> wddm(Wddm::createWddm());
|
||||
@@ -1011,7 +1011,7 @@ TEST_F(WddmGfxPartitionTest, initGfxPartition) {
|
||||
|
||||
for (auto heap : MockGfxPartition::allHeapNames) {
|
||||
if (!gfxPartition.heapInitialized(heap)) {
|
||||
EXPECT_TRUE(heap == HeapIndex::HEAP_SVM || heap == HeapIndex::HEAP_LIMITED);
|
||||
EXPECT_TRUE(heap == HeapIndex::HEAP_SVM);
|
||||
} else {
|
||||
EXPECT_TRUE(gfxPartition.heapInitialized(heap));
|
||||
}
|
||||
|
||||
@@ -1406,14 +1406,7 @@ TEST_F(MockWddmMemoryManagerTest, givenRenderCompressedAllocationWhenMappedGpuVa
|
||||
auto result = wddm.mapGpuVirtualAddressImpl(gmm.get(), ALLOCATION_HANDLE, nullptr, gpuVa, MemoryManager::selectHeap(nullptr, nullptr, *hwInfo));
|
||||
ASSERT_TRUE(result);
|
||||
|
||||
auto gpuAddressRange = hwInfo->capabilityTable.gpuAddressSpace;
|
||||
if (gpuAddressRange == MemoryConstants::max48BitAddress) {
|
||||
EXPECT_EQ(GmmHelper::canonize(wddm.getGfxPartition().Standard.Base), gpuVa);
|
||||
} else {
|
||||
EXPECT_GE(gpuAddressRange, gpuVa);
|
||||
EXPECT_LE(0u, gpuVa);
|
||||
expectedDdiUpdateAuxTable.BaseGpuVA = MemoryConstants::pageSize64k;
|
||||
}
|
||||
EXPECT_EQ(GmmHelper::canonize(wddm.getGfxPartition().Standard.Base), gpuVa);
|
||||
EXPECT_TRUE(memcmp(&expectedDdiUpdateAuxTable, &givenDdiUpdateAuxTable, sizeof(GMM_DDI_UPDATEAUXTABLE)) == 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user