mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-06 19:32:25 +08:00
[13/n] Internal 4GB allocator.
- Add common function for all memory managers to obtain internal heap base. Change-Id: Iacdaaf598e8786dad046b3f4550f9c80ce3f15d9
This commit is contained in:
committed by
sys_ocldev
parent
bc08ecdcea
commit
2119d5db08
@@ -144,6 +144,8 @@ class MemoryManager {
|
|||||||
|
|
||||||
virtual uint64_t getMaxApplicationAddress() = 0;
|
virtual uint64_t getMaxApplicationAddress() = 0;
|
||||||
|
|
||||||
|
virtual uint64_t getInternalHeapBaseAddress() = 0;
|
||||||
|
|
||||||
virtual bool cleanAllocationList(uint32_t waitTaskCount, uint32_t allocationType);
|
virtual bool cleanAllocationList(uint32_t waitTaskCount, uint32_t allocationType);
|
||||||
|
|
||||||
void freeAllocationsList(uint32_t waitTaskCount, AllocationsList &allocationsList);
|
void freeAllocationsList(uint32_t waitTaskCount, AllocationsList &allocationsList);
|
||||||
|
|||||||
@@ -167,6 +167,10 @@ uint64_t OsAgnosticMemoryManager::getMaxApplicationAddress() {
|
|||||||
return MemoryConstants::max32BitAppAddress + static_cast<uint64_t>(is64bit) * (MemoryConstants::max64BitAppAddress - MemoryConstants::max32BitAppAddress);
|
return MemoryConstants::max32BitAppAddress + static_cast<uint64_t>(is64bit) * (MemoryConstants::max64BitAppAddress - MemoryConstants::max32BitAppAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t OsAgnosticMemoryManager::getInternalHeapBaseAddress() {
|
||||||
|
return this->allocator32Bit->getBase();
|
||||||
|
}
|
||||||
|
|
||||||
GraphicsAllocation *OsAgnosticMemoryManager::createGraphicsAllocation(OsHandleStorage &handleStorage, size_t hostPtrSize, const void *hostPtr) {
|
GraphicsAllocation *OsAgnosticMemoryManager::createGraphicsAllocation(OsHandleStorage &handleStorage, size_t hostPtrSize, const void *hostPtr) {
|
||||||
auto allocation = new MemoryAllocation(false, 0, const_cast<void *>(hostPtr), reinterpret_cast<uint64_t>(hostPtr), hostPtrSize, counter++);
|
auto allocation = new MemoryAllocation(false, 0, const_cast<void *>(hostPtr), reinterpret_cast<uint64_t>(hostPtr), hostPtrSize, counter++);
|
||||||
allocation->fragmentsStorage = handleStorage;
|
allocation->fragmentsStorage = handleStorage;
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ class OsAgnosticMemoryManager : public MemoryManager {
|
|||||||
|
|
||||||
uint64_t getSystemSharedMemory() override;
|
uint64_t getSystemSharedMemory() override;
|
||||||
uint64_t getMaxApplicationAddress() override;
|
uint64_t getMaxApplicationAddress() override;
|
||||||
|
uint64_t getInternalHeapBaseAddress() override;
|
||||||
|
|
||||||
GraphicsAllocation *createGraphicsAllocation(OsHandleStorage &handleStorage, size_t hostPtrSize, const void *hostPtr) override;
|
GraphicsAllocation *createGraphicsAllocation(OsHandleStorage &handleStorage, size_t hostPtrSize, const void *hostPtr) override;
|
||||||
|
|
||||||
|
|||||||
@@ -462,6 +462,10 @@ uint64_t DrmMemoryManager::getMaxApplicationAddress() {
|
|||||||
return MemoryConstants::max32BitAppAddress + (uint64_t)is64bit * (MemoryConstants::max64BitAppAddress - MemoryConstants::max32BitAppAddress);
|
return MemoryConstants::max32BitAppAddress + (uint64_t)is64bit * (MemoryConstants::max64BitAppAddress - MemoryConstants::max32BitAppAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t DrmMemoryManager::getInternalHeapBaseAddress() {
|
||||||
|
return this->internal32bitAllocator->getBase();
|
||||||
|
}
|
||||||
|
|
||||||
bool DrmMemoryManager::populateOsHandles(OsHandleStorage &handleStorage) {
|
bool DrmMemoryManager::populateOsHandles(OsHandleStorage &handleStorage) {
|
||||||
for (unsigned int i = 0; i < max_fragments_count; i++) {
|
for (unsigned int i = 0; i < max_fragments_count; i++) {
|
||||||
// If there is no fragment it means it already exists.
|
// If there is no fragment it means it already exists.
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ class DrmMemoryManager : public MemoryManager {
|
|||||||
|
|
||||||
uint64_t getSystemSharedMemory() override;
|
uint64_t getSystemSharedMemory() override;
|
||||||
uint64_t getMaxApplicationAddress() override;
|
uint64_t getMaxApplicationAddress() override;
|
||||||
|
uint64_t getInternalHeapBaseAddress() override;
|
||||||
|
|
||||||
bool populateOsHandles(OsHandleStorage &handleStorage) override;
|
bool populateOsHandles(OsHandleStorage &handleStorage) override;
|
||||||
void cleanOsHandles(OsHandleStorage &handleStorage) override;
|
void cleanOsHandles(OsHandleStorage &handleStorage) override;
|
||||||
|
|||||||
@@ -395,6 +395,10 @@ uint64_t WddmMemoryManager::getMaxApplicationAddress() {
|
|||||||
return wddm->getMaxApplicationAddress();
|
return wddm->getMaxApplicationAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t WddmMemoryManager::getInternalHeapBaseAddress() {
|
||||||
|
return this->wddm->getGfxPartition().Heap32[1].Base;
|
||||||
|
}
|
||||||
|
|
||||||
bool WddmMemoryManager::makeResidentResidencyAllocations(ResidencyContainer *allocationsForResidency) {
|
bool WddmMemoryManager::makeResidentResidencyAllocations(ResidencyContainer *allocationsForResidency) {
|
||||||
|
|
||||||
auto &residencyAllocations = allocationsForResidency ? *allocationsForResidency : this->residencyAllocations;
|
auto &residencyAllocations = allocationsForResidency ? *allocationsForResidency : this->residencyAllocations;
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ class WddmMemoryManager : public MemoryManager {
|
|||||||
|
|
||||||
uint64_t getSystemSharedMemory() override;
|
uint64_t getSystemSharedMemory() override;
|
||||||
uint64_t getMaxApplicationAddress() override;
|
uint64_t getMaxApplicationAddress() override;
|
||||||
|
uint64_t getInternalHeapBaseAddress() override;
|
||||||
|
|
||||||
static void APIENTRY trimCallback(_Inout_ D3DKMT_TRIMNOTIFICATION *trimNotification);
|
static void APIENTRY trimCallback(_Inout_ D3DKMT_TRIMNOTIFICATION *trimNotification);
|
||||||
|
|
||||||
|
|||||||
@@ -1133,6 +1133,11 @@ TEST(OsAgnosticMemoryManager, givenPointerAndSizeWhenCreateInternalAllocationIsC
|
|||||||
EXPECT_EQ(allocationSize, graphicsAllocation->getUnderlyingBufferSize());
|
EXPECT_EQ(allocationSize, graphicsAllocation->getUnderlyingBufferSize());
|
||||||
memoryManager.freeGraphicsMemory(graphicsAllocation);
|
memoryManager.freeGraphicsMemory(graphicsAllocation);
|
||||||
}
|
}
|
||||||
|
TEST(OsAgnosticMemoryManager, givenDefaultOsAgnosticMemoryManagerWhenItIsQueriedForInternalHeapBaseThen32BitAllocatorBaseIsReturned) {
|
||||||
|
OsAgnosticMemoryManager memoryManager;
|
||||||
|
auto heapBase = memoryManager.allocator32Bit->getBase();
|
||||||
|
EXPECT_EQ(heapBase, memoryManager.getInternalHeapBaseAddress());
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(MemoryAllocatorTest, GivenSizeWhenGmmIsCreatedThenSuccess) {
|
TEST_F(MemoryAllocatorTest, GivenSizeWhenGmmIsCreatedThenSuccess) {
|
||||||
Gmm *gmm = Gmm::create(nullptr, 65536, false);
|
Gmm *gmm = Gmm::create(nullptr, 65536, false);
|
||||||
|
|||||||
@@ -2115,3 +2115,10 @@ TEST(DrmMemoryManager, givenDisabledAsyncDeleterFlagWhenMemoryManagerIsCreatedTh
|
|||||||
EXPECT_FALSE(memoryManager.isAsyncDeleterEnabled());
|
EXPECT_FALSE(memoryManager.isAsyncDeleterEnabled());
|
||||||
EXPECT_EQ(nullptr, memoryManager.getDeferredDeleter());
|
EXPECT_EQ(nullptr, memoryManager.getDeferredDeleter());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(DrmMemoryManager, givenDefaultDrmMemoryManagerWhenItIsQueriedForInternalHeapBaseThenInternalHeapBaseIsReturned) {
|
||||||
|
std::unique_ptr<TestedDrmMemoryManager> memoryManager(new (std::nothrow) TestedDrmMemoryManager(Drm::get(0), true));
|
||||||
|
auto internalAllocator = memoryManager->getDrmInternal32BitAllocator();
|
||||||
|
auto heapBase = internalAllocator->getBase();
|
||||||
|
EXPECT_EQ(heapBase, memoryManager->getInternalHeapBaseAddress());
|
||||||
|
}
|
||||||
|
|||||||
@@ -1787,6 +1787,14 @@ TEST(WddmMemoryManagerWithAsyncDeleterTest, givenMemoryManagerWithoutAsyncDelete
|
|||||||
EXPECT_EQ(1u, wddm->createAllocationResult.called);
|
EXPECT_EQ(1u, wddm->createAllocationResult.called);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(WddmMemoryManagerDefaults, givenDefaultWddmMemoryManagerWhenItIsQueriedForInternalHeapBaseThenHeap1BaseIsReturned) {
|
||||||
|
WddmMock *wddm = new WddmMock;
|
||||||
|
wddm->callBaseDestroyAllocations = false;
|
||||||
|
MockWddmMemoryManager memoryManager(wddm);
|
||||||
|
auto heapBase = wddm->getGfxPartition().Heap32[1].Base;
|
||||||
|
EXPECT_EQ(heapBase, memoryManager.getInternalHeapBaseAddress());
|
||||||
|
}
|
||||||
|
|
||||||
HWTEST_F(MockWddmMemoryManagerTest, givenValidateAllocationFunctionWhenItIsCalledWithTripleAllocationThenSuccessIsReturned) {
|
HWTEST_F(MockWddmMemoryManagerTest, givenValidateAllocationFunctionWhenItIsCalledWithTripleAllocationThenSuccessIsReturned) {
|
||||||
WddmMock *wddm = new WddmMock;
|
WddmMock *wddm = new WddmMock;
|
||||||
EXPECT_TRUE(wddm->init<FamilyType>());
|
EXPECT_TRUE(wddm->init<FamilyType>());
|
||||||
|
|||||||
Reference in New Issue
Block a user