mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 01:04:57 +08:00
Pass maxOsContextCount to ResidencyData
Change-Id: If9cf4c9a153ee7afff3f6b66e061db4630d0c8f5 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
ddacea4383
commit
fe163311b1
@@ -179,7 +179,7 @@ void OsAgnosticMemoryManager::addAllocationToHostPtrManager(GraphicsAllocation *
|
||||
fragment.fragmentCpuPointer = gfxAllocation->getUnderlyingBuffer();
|
||||
fragment.fragmentSize = alignUp(gfxAllocation->getUnderlyingBufferSize(), MemoryConstants::pageSize);
|
||||
fragment.osInternalStorage = new OsHandle();
|
||||
fragment.residency = new ResidencyData();
|
||||
fragment.residency = new ResidencyData(maxOsContextCount);
|
||||
hostPtrManager->storeFragment(gfxAllocation->getRootDeviceIndex(), fragment);
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ MemoryManager::AllocationStatus OsAgnosticMemoryManager::populateOsHandles(OsHan
|
||||
for (unsigned int i = 0; i < maxFragmentsCount; i++) {
|
||||
if (!handleStorage.fragmentStorageData[i].osHandleStorage && handleStorage.fragmentStorageData[i].cpuPtr) {
|
||||
handleStorage.fragmentStorageData[i].osHandleStorage = new OsHandle();
|
||||
handleStorage.fragmentStorageData[i].residency = new ResidencyData();
|
||||
handleStorage.fragmentStorageData[i].residency = new ResidencyData(maxOsContextCount);
|
||||
|
||||
FragmentStorage newFragment = {};
|
||||
newFragment.fragmentCpuPointer = const_cast<void *>(handleStorage.fragmentStorageData[i].cpuPtr);
|
||||
|
||||
@@ -1793,9 +1793,10 @@ TEST(ResidencyDataTest, givenGpgpuEnginesWhenAskedForMaxOsContextCountThenValueI
|
||||
TEST(ResidencyDataTest, givenResidencyDataWhenUpdateCompletionDataIsCalledThenItIsProperlyUpdated) {
|
||||
struct MockResidencyData : public ResidencyData {
|
||||
using ResidencyData::lastFenceValues;
|
||||
using ResidencyData::ResidencyData;
|
||||
};
|
||||
|
||||
MockResidencyData residency;
|
||||
MockResidencyData residency(MemoryManager::maxOsContextCount);
|
||||
|
||||
MockOsContext osContext(0u, 1,
|
||||
HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*defaultHwInfo)[0],
|
||||
|
||||
@@ -3428,15 +3428,16 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledValidateHostMem
|
||||
TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDrmMemoryManagerWhenCleanOsHandlesDeletesHandleDataThenOsHandleStorageAndResidencyIsSetToNullptr) {
|
||||
std::unique_ptr<TestedDrmMemoryManager> memoryManager(new TestedDrmMemoryManager(false, false, true, *executionEnvironment));
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[device->getRootDeviceIndex()]);
|
||||
auto maxOsContextCount = 1u;
|
||||
|
||||
OsHandleStorage handleStorage;
|
||||
handleStorage.fragmentStorageData[0].osHandleStorage = new OsHandle();
|
||||
handleStorage.fragmentStorageData[0].residency = new ResidencyData();
|
||||
handleStorage.fragmentStorageData[0].residency = new ResidencyData(maxOsContextCount);
|
||||
handleStorage.fragmentStorageData[0].cpuPtr = reinterpret_cast<void *>(0x1000);
|
||||
handleStorage.fragmentStorageData[0].fragmentSize = 4096;
|
||||
|
||||
handleStorage.fragmentStorageData[1].osHandleStorage = new OsHandle();
|
||||
handleStorage.fragmentStorageData[1].residency = new ResidencyData();
|
||||
handleStorage.fragmentStorageData[1].residency = new ResidencyData(maxOsContextCount);
|
||||
handleStorage.fragmentStorageData[1].cpuPtr = reinterpret_cast<void *>(0x1000);
|
||||
handleStorage.fragmentStorageData[1].fragmentSize = 4096;
|
||||
|
||||
|
||||
@@ -822,7 +822,8 @@ TEST_F(Wddm20Tests, givenReadOnlyMemoryWhenCreateAllocationFailsWithNoVideoMemor
|
||||
|
||||
OsHandleStorage handleStorage;
|
||||
OsHandle handle = {0};
|
||||
ResidencyData residency;
|
||||
auto maxOsContextCount = 1u;
|
||||
ResidencyData residency(maxOsContextCount);
|
||||
|
||||
handleStorage.fragmentCount = 1;
|
||||
handleStorage.fragmentStorageData[0].cpuPtr = (void *)0x1000;
|
||||
|
||||
@@ -58,8 +58,9 @@ void WddmMemoryManagerFixture::SetUp() {
|
||||
}
|
||||
|
||||
TEST(ResidencyData, givenNewlyConstructedResidencyDataThenItIsNotResidentOnAnyOsContext) {
|
||||
ResidencyData residencyData;
|
||||
for (auto contextId = 0u; contextId < MemoryManager::maxOsContextCount; contextId++) {
|
||||
auto maxOsContextCount = 3u;
|
||||
ResidencyData residencyData(maxOsContextCount);
|
||||
for (auto contextId = 0u; contextId < maxOsContextCount; contextId++) {
|
||||
EXPECT_EQ(false, residencyData.resident[contextId]);
|
||||
}
|
||||
}
|
||||
@@ -998,9 +999,10 @@ TEST_F(WddmMemoryManagerTest, WhenAllocating32BitMemoryThenGpuBaseAddressIsCanno
|
||||
TEST_F(WddmMemoryManagerTest, GivenThreeOsHandlesWhenAskedForDestroyAllocationsThenAllMarkedAllocationsAreDestroyed) {
|
||||
OsHandleStorage storage;
|
||||
void *pSysMem = reinterpret_cast<void *>(0x1000);
|
||||
uint32_t maxOsContextCount = 1u;
|
||||
|
||||
storage.fragmentStorageData[0].osHandleStorage = new OsHandle;
|
||||
storage.fragmentStorageData[0].residency = new ResidencyData;
|
||||
storage.fragmentStorageData[0].residency = new ResidencyData(maxOsContextCount);
|
||||
|
||||
storage.fragmentStorageData[0].osHandleStorage->handle = ALLOCATION_HANDLE;
|
||||
storage.fragmentStorageData[0].freeTheFragment = true;
|
||||
@@ -1008,7 +1010,7 @@ TEST_F(WddmMemoryManagerTest, GivenThreeOsHandlesWhenAskedForDestroyAllocationsT
|
||||
|
||||
storage.fragmentStorageData[1].osHandleStorage = new OsHandle;
|
||||
storage.fragmentStorageData[1].osHandleStorage->handle = ALLOCATION_HANDLE;
|
||||
storage.fragmentStorageData[1].residency = new ResidencyData;
|
||||
storage.fragmentStorageData[1].residency = new ResidencyData(maxOsContextCount);
|
||||
|
||||
storage.fragmentStorageData[1].freeTheFragment = false;
|
||||
|
||||
@@ -1016,7 +1018,7 @@ TEST_F(WddmMemoryManagerTest, GivenThreeOsHandlesWhenAskedForDestroyAllocationsT
|
||||
storage.fragmentStorageData[2].osHandleStorage->handle = ALLOCATION_HANDLE;
|
||||
storage.fragmentStorageData[2].freeTheFragment = true;
|
||||
storage.fragmentStorageData[2].osHandleStorage->gmm = new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096u, false);
|
||||
storage.fragmentStorageData[2].residency = new ResidencyData;
|
||||
storage.fragmentStorageData[2].residency = new ResidencyData(maxOsContextCount);
|
||||
|
||||
memoryManager->cleanOsHandles(storage, 0);
|
||||
|
||||
@@ -1246,11 +1248,12 @@ TEST_F(BufferWithWddmMemory, givenFragmentsThatAreNotInOrderWhenGraphicsAllocati
|
||||
D3DGPU_VIRTUAL_ADDRESS gpuAdress = MemoryConstants::pageSize * 1;
|
||||
auto ptr = reinterpret_cast<void *>(wddm->virtualAllocAddress + MemoryConstants::pageSize);
|
||||
auto size = MemoryConstants::pageSize * 2;
|
||||
auto maxOsContextCount = 1u;
|
||||
|
||||
handleStorage.fragmentStorageData[0].cpuPtr = ptr;
|
||||
handleStorage.fragmentStorageData[0].fragmentSize = size;
|
||||
handleStorage.fragmentStorageData[0].osHandleStorage = new OsHandle();
|
||||
handleStorage.fragmentStorageData[0].residency = new ResidencyData();
|
||||
handleStorage.fragmentStorageData[0].residency = new ResidencyData(maxOsContextCount);
|
||||
handleStorage.fragmentStorageData[0].freeTheFragment = true;
|
||||
auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get();
|
||||
handleStorage.fragmentStorageData[0].osHandleStorage->gmm = new Gmm(rootDeviceEnvironment->getGmmClientContext(), ptr, size, false);
|
||||
@@ -1281,11 +1284,12 @@ TEST_F(BufferWithWddmMemory, givenFragmentsThatAreNotInOrderWhenGraphicsAllocati
|
||||
D3DGPU_VIRTUAL_ADDRESS gpuAdress = MemoryConstants::pageSize * 1;
|
||||
auto ptr = reinterpret_cast<void *>(wddm->virtualAllocAddress + MemoryConstants::pageSize);
|
||||
auto size = MemoryConstants::pageSize * 2;
|
||||
auto maxOsContextCount = 1u;
|
||||
|
||||
handleStorage.fragmentStorageData[0].cpuPtr = ptr;
|
||||
handleStorage.fragmentStorageData[0].fragmentSize = size;
|
||||
handleStorage.fragmentStorageData[0].osHandleStorage = new OsHandle();
|
||||
handleStorage.fragmentStorageData[0].residency = new ResidencyData();
|
||||
handleStorage.fragmentStorageData[0].residency = new ResidencyData(maxOsContextCount);
|
||||
handleStorage.fragmentStorageData[0].freeTheFragment = true;
|
||||
auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get();
|
||||
handleStorage.fragmentStorageData[0].osHandleStorage->gmm = new Gmm(rootDeviceEnvironment->getGmmClientContext(), ptr, size, false);
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/memory_manager/memory_manager.h"
|
||||
#include "shared/source/utilities/stackvec.h"
|
||||
|
||||
#include <vector>
|
||||
@@ -14,8 +13,8 @@
|
||||
namespace NEO {
|
||||
|
||||
struct ResidencyData {
|
||||
ResidencyData() : lastFenceValues(static_cast<size_t>(MemoryManager::maxOsContextCount)) {}
|
||||
std::vector<bool> resident = std::vector<bool>(MemoryManager::maxOsContextCount, 0);
|
||||
ResidencyData(size_t maxOsContextCount) : resident(maxOsContextCount, 0), lastFenceValues(static_cast<size_t>(maxOsContextCount)) {}
|
||||
std::vector<bool> resident;
|
||||
|
||||
void updateCompletionData(uint64_t newFenceValue, uint32_t contextId);
|
||||
uint64_t getFenceValueForContextId(uint32_t contextId);
|
||||
|
||||
@@ -578,12 +578,13 @@ GraphicsAllocation *DrmMemoryManager::createPaddedAllocation(GraphicsAllocation
|
||||
|
||||
void DrmMemoryManager::addAllocationToHostPtrManager(GraphicsAllocation *gfxAllocation) {
|
||||
DrmAllocation *drmMemory = static_cast<DrmAllocation *>(gfxAllocation);
|
||||
auto maxOsContextCount = 1u;
|
||||
FragmentStorage fragment = {};
|
||||
fragment.driverAllocation = true;
|
||||
fragment.fragmentCpuPointer = gfxAllocation->getUnderlyingBuffer();
|
||||
fragment.fragmentSize = alignUp(gfxAllocation->getUnderlyingBufferSize(), MemoryConstants::pageSize);
|
||||
fragment.osInternalStorage = new OsHandle();
|
||||
fragment.residency = new ResidencyData();
|
||||
fragment.residency = new ResidencyData(maxOsContextCount);
|
||||
fragment.osInternalStorage->bo = drmMemory->getBO();
|
||||
hostPtrManager->storeFragment(gfxAllocation->getRootDeviceIndex(), fragment);
|
||||
}
|
||||
@@ -650,12 +651,13 @@ MemoryManager::AllocationStatus DrmMemoryManager::populateOsHandles(OsHandleStor
|
||||
BufferObject *allocatedBos[maxFragmentsCount];
|
||||
uint32_t numberOfBosAllocated = 0;
|
||||
uint32_t indexesOfAllocatedBos[maxFragmentsCount];
|
||||
auto maxOsContextCount = 1u;
|
||||
|
||||
for (unsigned int i = 0; i < maxFragmentsCount; i++) {
|
||||
// If there is no fragment it means it already exists.
|
||||
if (!handleStorage.fragmentStorageData[i].osHandleStorage && handleStorage.fragmentStorageData[i].fragmentSize) {
|
||||
handleStorage.fragmentStorageData[i].osHandleStorage = new OsHandle();
|
||||
handleStorage.fragmentStorageData[i].residency = new ResidencyData();
|
||||
handleStorage.fragmentStorageData[i].residency = new ResidencyData(maxOsContextCount);
|
||||
|
||||
handleStorage.fragmentStorageData[i].osHandleStorage->bo = allocUserptr((uintptr_t)handleStorage.fragmentStorageData[i].cpuPtr,
|
||||
handleStorage.fragmentStorageData[i].fragmentSize,
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#define UMDF_USING_NTSTATUS
|
||||
#include "shared/source/helpers/aligned_memory.h"
|
||||
#include "shared/source/memory_manager/graphics_allocation.h"
|
||||
#include "shared/source/memory_manager/memory_manager.h"
|
||||
#include "shared/source/memory_manager/residency.h"
|
||||
#include "shared/source/os_interface/windows/windows_wrapper.h"
|
||||
|
||||
@@ -31,7 +32,7 @@ class WddmAllocation : public GraphicsAllocation {
|
||||
|
||||
WddmAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn,
|
||||
void *reservedAddr, MemoryPool::Type pool, uint32_t shareable)
|
||||
: GraphicsAllocation(rootDeviceIndex, numGmms, allocationType, cpuPtrIn, castToUint64(cpuPtrIn), 0llu, sizeIn, pool), shareable(shareable), trimCandidateListPositions(MemoryManager::maxOsContextCount, trimListUnusedPosition) {
|
||||
: GraphicsAllocation(rootDeviceIndex, numGmms, allocationType, cpuPtrIn, castToUint64(cpuPtrIn), 0llu, sizeIn, pool), shareable(shareable), residency(MemoryManager::maxOsContextCount), trimCandidateListPositions(MemoryManager::maxOsContextCount, trimListUnusedPosition) {
|
||||
reservedAddressRangeInfo.addressPtr = reservedAddr;
|
||||
reservedAddressRangeInfo.rangeSize = sizeIn;
|
||||
handles.resize(gmms.size());
|
||||
@@ -42,7 +43,7 @@ class WddmAllocation : public GraphicsAllocation {
|
||||
|
||||
WddmAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn,
|
||||
osHandle sharedHandle, MemoryPool::Type pool)
|
||||
: GraphicsAllocation(rootDeviceIndex, numGmms, allocationType, cpuPtrIn, sizeIn, sharedHandle, pool), trimCandidateListPositions(MemoryManager::maxOsContextCount, trimListUnusedPosition) {
|
||||
: GraphicsAllocation(rootDeviceIndex, numGmms, allocationType, cpuPtrIn, sizeIn, sharedHandle, pool), residency(MemoryManager::maxOsContextCount), trimCandidateListPositions(MemoryManager::maxOsContextCount, trimListUnusedPosition) {
|
||||
handles.resize(gmms.size());
|
||||
}
|
||||
|
||||
|
||||
@@ -520,7 +520,7 @@ MemoryManager::AllocationStatus WddmMemoryManager::populateOsHandles(OsHandleSto
|
||||
// If no fragment is present it means it already exists.
|
||||
if (!handleStorage.fragmentStorageData[i].osHandleStorage && handleStorage.fragmentStorageData[i].cpuPtr) {
|
||||
handleStorage.fragmentStorageData[i].osHandleStorage = new OsHandle();
|
||||
handleStorage.fragmentStorageData[i].residency = new ResidencyData();
|
||||
handleStorage.fragmentStorageData[i].residency = new ResidencyData(maxOsContextCount);
|
||||
|
||||
handleStorage.fragmentStorageData[i].osHandleStorage->gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getGmmClientContext(), handleStorage.fragmentStorageData[i].cpuPtr,
|
||||
handleStorage.fragmentStorageData[i].fragmentSize, false);
|
||||
|
||||
Reference in New Issue
Block a user