Skip to content

Commit b9aee10

Browse files
Initialize internal heaps with at least minAddress from Wddm
Signed-off-by: Mateusz Hoppe <[email protected]>
1 parent d7ea713 commit b9aee10

File tree

7 files changed

+21
-18
lines changed

7 files changed

+21
-18
lines changed

opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2020 Intel Corporation
2+
* Copyright (C) 2017-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -1499,6 +1499,7 @@ TEST(WddmMemoryManagerDefaults, givenDefaultWddmMemoryManagerWhenItIsQueriedForI
14991499
wddm->init();
15001500
MockWddmMemoryManager memoryManager(*executionEnvironment);
15011501
auto heapBase = wddm->getGfxPartition().Heap32[static_cast<uint32_t>(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)].Base;
1502+
heapBase = std::max(heapBase, static_cast<uint64_t>(wddm->getWddmMinAddress()));
15021503
EXPECT_EQ(heapBase, memoryManager.getInternalHeapBaseAddress(0, true));
15031504
}
15041505

shared/source/helpers/heap_assigner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020 Intel Corporation
2+
* Copyright (C) 2020-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -37,7 +37,7 @@ bool HeapAssigner::useExternal32BitHeap(GraphicsAllocation::AllocationType alloc
3737
return false;
3838
}
3939

40-
bool HeapAssigner::heapTypeWithFrontWindowPool(HeapIndex heap) {
40+
bool HeapAssigner::heapTypeExternalWithFrontWindowPool(HeapIndex heap) {
4141
return heap == HeapIndex::HEAP_EXTERNAL_DEVICE_MEMORY || heap == HeapIndex::HEAP_EXTERNAL;
4242
}
4343

shared/source/helpers/heap_assigner.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020 Intel Corporation
2+
* Copyright (C) 2020-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -17,7 +17,7 @@ struct HeapAssigner {
1717
bool useInternal32BitHeap(GraphicsAllocation::AllocationType allocType);
1818
bool use32BitHeap(GraphicsAllocation::AllocationType allocType);
1919
HeapIndex get32BitHeapIndex(GraphicsAllocation::AllocationType allocType, bool useLocalMem, const HardwareInfo &hwInfo, bool useFrontWindow);
20-
static bool heapTypeWithFrontWindowPool(HeapIndex heap);
20+
static bool heapTypeExternalWithFrontWindowPool(HeapIndex heap);
2121
static bool isInternalHeap(HeapIndex heap);
2222

2323
static HeapIndex mapExternalWindowIndex(HeapIndex index);

shared/source/memory_manager/gfx_partition.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 Intel Corporation
2+
* Copyright (C) 2019-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -82,7 +82,7 @@ void GfxPartition::freeGpuAddressRange(uint64_t ptr, size_t size) {
8282
}
8383
}
8484

85-
bool GfxPartition::init(uint64_t gpuAddressSpace, size_t cpuAddressRangeSizeToReserve, uint32_t rootDeviceIndex, size_t numRootDevices, bool useFrontWindowPool) {
85+
bool GfxPartition::init(uint64_t gpuAddressSpace, size_t cpuAddressRangeSizeToReserve, uint32_t rootDeviceIndex, size_t numRootDevices, bool useExternalFrontWindowPool) {
8686

8787
/*
8888
* I. 64-bit builds:
@@ -168,7 +168,7 @@ bool GfxPartition::init(uint64_t gpuAddressSpace, size_t cpuAddressRangeSizeToRe
168168
}
169169

170170
for (auto heap : GfxPartition::heap32Names) {
171-
if (useFrontWindowPool && HeapAssigner::heapTypeWithFrontWindowPool(heap)) {
171+
if (useExternalFrontWindowPool && HeapAssigner::heapTypeExternalWithFrontWindowPool(heap)) {
172172
heapInitExternalWithFrontWindow(heap, gfxBase, gfxHeap32Size);
173173
size_t externalFrontWindowSize = GfxPartition::externalFrontWindowPoolSize;
174174
heapInitExternalWithFrontWindow(HeapAssigner::mapExternalWindowIndex(heap), heapAllocate(heap, externalFrontWindowSize),

shared/source/memory_manager/gfx_partition.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 Intel Corporation
2+
* Copyright (C) 2019-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -42,7 +42,7 @@ class GfxPartition {
4242
bool init(uint64_t gpuAddressSpace, size_t cpuAddressRangeSizeToReserve, uint32_t rootDeviceIndex, size_t numRootDevices) {
4343
return init(gpuAddressSpace, cpuAddressRangeSizeToReserve, rootDeviceIndex, numRootDevices, false);
4444
}
45-
MOCKABLE_VIRTUAL bool init(uint64_t gpuAddressSpace, size_t cpuAddressRangeSizeToReserve, uint32_t rootDeviceIndex, size_t numRootDevices, bool useFrontWindowPool);
45+
MOCKABLE_VIRTUAL bool init(uint64_t gpuAddressSpace, size_t cpuAddressRangeSizeToReserve, uint32_t rootDeviceIndex, size_t numRootDevices, bool useExternalFrontWindowPool);
4646

4747
void heapInit(HeapIndex heapIndex, uint64_t base, uint64_t size) {
4848
getHeap(heapIndex).init(base, size);

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2020 Intel Corporation
2+
* Copyright (C) 2018-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -878,7 +878,7 @@ bool Wddm::waitFromCpu(uint64_t lastFenceValue, const MonitoredFence &monitoredF
878878
return status == STATUS_SUCCESS;
879879
}
880880

881-
void Wddm::initGfxPartition(GfxPartition &outGfxPartition, uint32_t rootDeviceIndex, size_t numRootDevices, bool useFrontWindowPool) const {
881+
void Wddm::initGfxPartition(GfxPartition &outGfxPartition, uint32_t rootDeviceIndex, size_t numRootDevices, bool useExternalFrontWindowPool) const {
882882
if (gfxPartition.SVM.Limit != 0) {
883883
outGfxPartition.heapInit(HeapIndex::HEAP_SVM, gfxPartition.SVM.Base, gfxPartition.SVM.Limit - gfxPartition.SVM.Base + 1);
884884
} else if (is32bit) {
@@ -892,17 +892,19 @@ void Wddm::initGfxPartition(GfxPartition &outGfxPartition, uint32_t rootDeviceIn
892892
outGfxPartition.heapInit(HeapIndex::HEAP_STANDARD64KB, gfxPartition.Standard64KB.Base + rootDeviceIndex * gfxStandard64KBSize, gfxStandard64KBSize);
893893

894894
for (auto heap : GfxPartition::heap32Names) {
895-
if (useFrontWindowPool && HeapAssigner::heapTypeWithFrontWindowPool(heap)) {
895+
if (useExternalFrontWindowPool && HeapAssigner::heapTypeExternalWithFrontWindowPool(heap)) {
896896
outGfxPartition.heapInitExternalWithFrontWindow(heap, gfxPartition.Heap32[static_cast<uint32_t>(heap)].Base,
897897
gfxPartition.Heap32[static_cast<uint32_t>(heap)].Limit - gfxPartition.Heap32[static_cast<uint32_t>(heap)].Base + 1);
898898
size_t externalFrontWindowSize = GfxPartition::externalFrontWindowPoolSize;
899899
outGfxPartition.heapInitExternalWithFrontWindow(HeapAssigner::mapExternalWindowIndex(heap), outGfxPartition.heapAllocate(heap, externalFrontWindowSize),
900900
externalFrontWindowSize);
901901
} else if (HeapAssigner::isInternalHeap(heap)) {
902-
outGfxPartition.heapInitWithFrontWindow(heap, gfxPartition.Heap32[static_cast<uint32_t>(heap)].Base,
903-
gfxPartition.Heap32[static_cast<uint32_t>(heap)].Limit - gfxPartition.Heap32[static_cast<uint32_t>(heap)].Base + 1,
902+
auto baseAddress = gfxPartition.Heap32[static_cast<uint32_t>(heap)].Base >= minAddress ? gfxPartition.Heap32[static_cast<uint32_t>(heap)].Base : minAddress;
903+
904+
outGfxPartition.heapInitWithFrontWindow(heap, baseAddress,
905+
gfxPartition.Heap32[static_cast<uint32_t>(heap)].Limit - baseAddress + 1,
904906
GfxPartition::internalFrontWindowPoolSize);
905-
outGfxPartition.heapInitFrontWindow(HeapAssigner::mapInternalWindowIndex(heap), gfxPartition.Heap32[static_cast<uint32_t>(heap)].Base, GfxPartition::internalFrontWindowPoolSize);
907+
outGfxPartition.heapInitFrontWindow(HeapAssigner::mapInternalWindowIndex(heap), baseAddress, GfxPartition::internalFrontWindowPoolSize);
906908
} else {
907909
outGfxPartition.heapInit(heap, gfxPartition.Heap32[static_cast<uint32_t>(heap)].Base,
908910
gfxPartition.Heap32[static_cast<uint32_t>(heap)].Limit - gfxPartition.Heap32[static_cast<uint32_t>(heap)].Base + 1);

shared/source/os_interface/windows/wddm_memory_manager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2020 Intel Corporation
2+
* Copyright (C) 2017-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -45,8 +45,8 @@ WddmMemoryManager::WddmMemoryManager(ExecutionEnvironment &executionEnvironment)
4545
mallocRestrictions.minAddress = 0u;
4646

4747
for (uint32_t rootDeviceIndex = 0; rootDeviceIndex < gfxPartitions.size(); ++rootDeviceIndex) {
48-
getWddm(rootDeviceIndex).initGfxPartition(*getGfxPartition(rootDeviceIndex), rootDeviceIndex, gfxPartitions.size(), heapAssigner.apiAllowExternalHeapForSshAndDsh);
4948
mallocRestrictions.minAddress = std::max(mallocRestrictions.minAddress, getWddm(rootDeviceIndex).getWddmMinAddress());
49+
getWddm(rootDeviceIndex).initGfxPartition(*getGfxPartition(rootDeviceIndex), rootDeviceIndex, gfxPartitions.size(), heapAssigner.apiAllowExternalHeapForSshAndDsh);
5050
}
5151

5252
initialized = true;

0 commit comments

Comments
 (0)