Skip to content

Commit ed6381a

Browse files
Use HEAP_STANDARD64Kb when cpu access is required
Change-Id: I3a451b618f1b72836cd640ed510e874cf2d60624 Signed-off-by: Jablonski, Mateusz <[email protected]>
1 parent aa587b3 commit ed6381a

File tree

6 files changed

+48
-13
lines changed

6 files changed

+48
-13
lines changed

runtime/memory_manager/graphics_allocation.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,13 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
164164

165165
virtual std::string getAllocationInfoString() const;
166166

167+
static bool isCpuAccessRequired(AllocationType allocationType) {
168+
return allocationType == AllocationType::LINEAR_STREAM ||
169+
allocationType == AllocationType::KERNEL_ISA ||
170+
allocationType == AllocationType::INTERNAL_HEAP ||
171+
allocationType == AllocationType::TIMESTAMP_PACKET_TAG_BUFFER;
172+
}
173+
167174
protected:
168175
constexpr static uint32_t objectNotResident = (uint32_t)-1;
169176
constexpr static uint32_t objectNotUsed = (uint32_t)-1;

runtime/memory_manager/memory_manager.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -274,17 +274,7 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo
274274
break;
275275
}
276276

277-
switch (properties.allocationType) {
278-
case GraphicsAllocation::AllocationType::LINEAR_STREAM:
279-
case GraphicsAllocation::AllocationType::KERNEL_ISA:
280-
case GraphicsAllocation::AllocationType::INTERNAL_HEAP:
281-
case GraphicsAllocation::AllocationType::TIMESTAMP_PACKET_TAG_BUFFER:
282-
allocationData.flags.requiresCpuAccess = true;
283-
break;
284-
default:
285-
break;
286-
}
287-
277+
allocationData.flags.requiresCpuAccess = GraphicsAllocation::isCpuAccessRequired(properties.allocationType);
288278
allocationData.flags.mustBeZeroCopy = mustBeZeroCopy;
289279
allocationData.flags.allocateMemory = properties.flags.allocateMemory;
290280
allocationData.flags.allow32Bit = allow32Bit;

runtime/os_interface/windows/wddm/wddm.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,9 @@ HeapIndex Wddm::selectHeap(const WddmAllocation *allocation, const void *ptr) co
10061006
if (ptr) {
10071007
return HeapIndex::HEAP_SVM;
10081008
}
1009+
if (allocation && GraphicsAllocation::isCpuAccessRequired(allocation->getAllocationType())) {
1010+
return HeapIndex::HEAP_STANDARD64Kb;
1011+
}
10091012
return HeapIndex::HEAP_STANDARD;
10101013
}
10111014
return HeapIndex::HEAP_LIMITED;

unit_tests/memory_manager/graphics_allocation_tests.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,19 @@ TEST(GraphicsAllocationTest, givenResidentGraphicsAllocationWhenCheckIfResidency
112112
EXPECT_TRUE(graphicsAllocation.isResident(0u));
113113
EXPECT_TRUE(graphicsAllocation.isResidencyTaskCountBelow(currentResidencyTaskCount + 1u, 0u));
114114
}
115+
116+
TEST(GraphicsAllocationTest, whenAllocationTypeIsLinearStreamThenCpuAccessIsRequired) {
117+
EXPECT_TRUE(GraphicsAllocation::isCpuAccessRequired(GraphicsAllocation::AllocationType::LINEAR_STREAM));
118+
}
119+
120+
TEST(GraphicsAllocationTest, whenAllocationTypeIsKernelIsaThenCpuAccessIsRequired) {
121+
EXPECT_TRUE(GraphicsAllocation::isCpuAccessRequired(GraphicsAllocation::AllocationType::KERNEL_ISA));
122+
}
123+
124+
TEST(GraphicsAllocationTest, whenAllocationTypeIsInternalHeapThenCpuAccessIsRequired) {
125+
EXPECT_TRUE(GraphicsAllocation::isCpuAccessRequired(GraphicsAllocation::AllocationType::INTERNAL_HEAP));
126+
}
127+
128+
TEST(GraphicsAllocationTest, whenAllocationTypeIsTimestampPacketThenCpuAccessIsRequired) {
129+
EXPECT_TRUE(GraphicsAllocation::isCpuAccessRequired(GraphicsAllocation::AllocationType::TIMESTAMP_PACKET_TAG_BUFFER));
130+
}

unit_tests/mock_gdi/mock_gdi.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2018 Intel Corporation
2+
* Copyright (C) 2017-2019 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -27,6 +27,8 @@ BOOLEAN WINAPI DllMain(IN HINSTANCE hDllHandle,
2727
case DLL_PROCESS_ATTACH:
2828
gAdapterInfo.GfxPartition.Standard.Base = 0x0000800400000000;
2929
gAdapterInfo.GfxPartition.Standard.Limit = 0x0000eeffffffffff;
30+
gAdapterInfo.GfxPartition.Standard64KB.Base = 0x0000b80200000000;
31+
gAdapterInfo.GfxPartition.Standard64KB.Limit = 0x0000efffffffffff;
3032
gAdapterInfo.GfxPartition.SVM.Base = 0;
3133
gAdapterInfo.GfxPartition.SVM.Limit = 0x00007fffffffffff;
3234
gAdapterInfo.GfxPartition.Heap32[0].Base = 0x0000800000000000;
@@ -287,6 +289,8 @@ NTSTATUS __stdcall D3DKMTQueryAdapterInfo(IN CONST D3DKMT_QUERYADAPTERINFO *quer
287289

288290
adapterInfo->GfxPartition.Standard.Base = gAdapterInfo.GfxPartition.Standard.Base;
289291
adapterInfo->GfxPartition.Standard.Limit = gAdapterInfo.GfxPartition.Standard.Limit;
292+
adapterInfo->GfxPartition.Standard64KB.Base = gAdapterInfo.GfxPartition.Standard64KB.Base;
293+
adapterInfo->GfxPartition.Standard64KB.Limit = gAdapterInfo.GfxPartition.Standard64KB.Limit;
290294

291295
adapterInfo->GfxPartition.SVM.Base = gAdapterInfo.GfxPartition.SVM.Base;
292296
adapterInfo->GfxPartition.SVM.Limit = gAdapterInfo.GfxPartition.SVM.Limit;

unit_tests/os_interface/windows/wddm20_tests.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,9 +1030,24 @@ TEST_F(WddmHeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAl
10301030
}
10311031
EXPECT_EQ(HeapIndex::HEAP_SVM, wddm->selectHeap(&allocation, &allocation));
10321032
}
1033-
TEST_F(WddmHeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocationWithoutPtrThenStandardHeapIsUsed) {
1033+
TEST_F(WddmHeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocationWithoutPtrAndCpuAccessIsRequiredThenStandard64kHeapIsUsed) {
10341034
WddmAllocation allocation{nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
10351035
EXPECT_EQ(AllocationOrigin::EXTERNAL_ALLOCATION, allocation.origin);
1036+
auto allocationType = GraphicsAllocation::AllocationType::LINEAR_STREAM;
1037+
allocation.setAllocationType(allocationType);
1038+
EXPECT_TRUE(GraphicsAllocation::isCpuAccessRequired(allocationType));
1039+
if (hardwareInfoTable[wddm->getGfxPlatform()->eProductFamily]->capabilityTable.gpuAddressSpace != MemoryConstants::max48BitAddress) {
1040+
return;
1041+
}
1042+
EXPECT_EQ(HeapIndex::HEAP_STANDARD64Kb, wddm->selectHeap(&allocation, nullptr));
1043+
}
1044+
1045+
TEST_F(WddmHeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocationWithoutPtrAndCpuAccessIsNotRequiredThenStandardHeapIsUsed) {
1046+
WddmAllocation allocation{nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
1047+
EXPECT_EQ(AllocationOrigin::EXTERNAL_ALLOCATION, allocation.origin);
1048+
auto allocationType = GraphicsAllocation::AllocationType::UNDECIDED;
1049+
allocation.setAllocationType(allocationType);
1050+
EXPECT_FALSE(GraphicsAllocation::isCpuAccessRequired(allocationType));
10361051
if (hardwareInfoTable[wddm->getGfxPlatform()->eProductFamily]->capabilityTable.gpuAddressSpace != MemoryConstants::max48BitAddress) {
10371052
return;
10381053
}

0 commit comments

Comments
 (0)