Revert "fix: device usm alloc reuse"

This reverts commit 7cb1819b22.

Signed-off-by: Compute-Runtime-Validation <compute-runtime-validation@intel.com>
This commit is contained in:
Compute-Runtime-Validation
2024-05-28 17:53:40 +02:00
committed by Compute-Runtime-Automation
parent 1d06f4bf50
commit dd55225041
6 changed files with 11 additions and 16 deletions

View File

@@ -298,7 +298,7 @@ void *SVMAllocsManager::createUnifiedMemoryAllocation(size_t size,
if (memoryProperties.memoryType == InternalMemoryType::deviceUnifiedMemory) {
unifiedMemoryProperties.flags.isUSMDeviceAllocation = true;
if (this->usmDeviceAllocationsCacheEnabled &&
false == memoryProperties.isInternalAllocation) {
false == memoryProperties.needZeroedOutAllocation) {
void *allocationFromCache = this->usmDeviceAllocationsCache.get(size, memoryProperties, this);
if (allocationFromCache) {
return allocationFromCache;
@@ -332,7 +332,6 @@ void *SVMAllocsManager::createUnifiedMemoryAllocation(size_t size,
allocData.allocationFlagsProperty = memoryProperties.allocationFlags;
allocData.device = memoryProperties.device;
allocData.setAllocId(++this->allocationsCounter);
allocData.isInternalAllocation = memoryProperties.isInternalAllocation;
auto retPtr = reinterpret_cast<void *>(unifiedMemoryAllocation->getGpuAddress());
insertSVMAlloc(retPtr, allocData);
@@ -446,9 +445,8 @@ bool SVMAllocsManager::freeSVMAlloc(void *ptr, bool blocking) {
SvmAllocationData *svmData = getSVMAlloc(ptr);
if (svmData) {
if (InternalMemoryType::deviceUnifiedMemory == svmData->memoryType &&
false == svmData->isInternalAllocation &&
this->usmDeviceAllocationsCacheEnabled) {
if (this->usmDeviceAllocationsCache.insert(svmData->gpuAllocations.getDefaultGraphicsAllocation()->getUnderlyingBufferSize(), ptr)) {
if (this->usmDeviceAllocationsCache.insert(svmData->size, ptr)) {
return true;
}
}

View File

@@ -41,7 +41,6 @@ struct SvmAllocationData {
this->allocId = svmAllocData.allocId;
this->pageSizeForAlignment = svmAllocData.pageSizeForAlignment;
this->isImportedAllocation = svmAllocData.isImportedAllocation;
this->isInternalAllocation = svmAllocData.isInternalAllocation;
for (auto allocation : svmAllocData.gpuAllocations.getGraphicsAllocations()) {
if (allocation) {
this->gpuAllocations.addAllocation(allocation);
@@ -64,7 +63,6 @@ struct SvmAllocationData {
allocId = id;
}
bool mappedAllocData = false;
bool isInternalAllocation = false;
uint32_t getAllocId() const {
return allocId;
@@ -140,7 +138,7 @@ class SVMAllocsManager {
const RootDeviceIndicesContainer &rootDeviceIndices;
const std::map<uint32_t, DeviceBitfield> &subdeviceBitfields;
AllocationType requestedAllocationType = AllocationType::unknown;
bool isInternalAllocation = false;
bool needZeroedOutAllocation = false;
};
struct SvmCacheAllocationInfo {

View File

@@ -38,7 +38,7 @@ GraphicsAllocation *allocateGlobalsSurface(NEO::SVMAllocsManager *const svmAlloc
NEO::SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::deviceUnifiedMemory, 1, rootDeviceIndices, subDeviceBitfields);
unifiedMemoryProperties.device = &device;
unifiedMemoryProperties.requestedAllocationType = allocationType;
unifiedMemoryProperties.isInternalAllocation = true;
unifiedMemoryProperties.needZeroedOutAllocation = true;
auto ptr = svmAllocManager->createUnifiedMemoryAllocation(totalSize, unifiedMemoryProperties);
DEBUG_BREAK_IF(ptr == nullptr);
if (ptr == nullptr) {

View File

@@ -34,7 +34,7 @@ struct MockSVMAllocsManager : public SVMAllocsManager {
bool prefetchMemoryCalled = false;
void *createUnifiedMemoryAllocation(size_t size, const UnifiedMemoryProperties &memoryProperties) override {
requestedZeroedOutAllocation = memoryProperties.isInternalAllocation;
requestedZeroedOutAllocation = memoryProperties.needZeroedOutAllocation;
return SVMAllocsManager::createUnifiedMemoryAllocation(size, memoryProperties);
}
bool requestedZeroedOutAllocation = false;

View File

@@ -291,8 +291,11 @@ TEST_F(SvmDeviceAllocationCacheTest, givenAllocationsWithDifferentSizesWhenAlloc
auto testDataset = std::vector<SvmDeviceAllocationCacheSimpleTestDataType>(
{
{(allocationSizeBasis << 0), nullptr},
{(allocationSizeBasis << 0) + 1, nullptr},
{(allocationSizeBasis << 1), nullptr},
{(allocationSizeBasis << 1) + 1, nullptr},
{(allocationSizeBasis << 2), nullptr},
{(allocationSizeBasis << 2) + 1, nullptr},
});
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::deviceUnifiedMemory, 1, rootDeviceIndices, deviceBitfields);
@@ -516,7 +519,7 @@ TEST_F(SvmDeviceAllocationCacheTest, givenDeviceOutOfMemoryWhenAllocatingThenCac
ASSERT_EQ(svmManager->usmDeviceAllocationsCache.allocations.size(), 0u);
}
TEST_F(SvmDeviceAllocationCacheTest, givenAllocationWithIsInternalAllocationSetWhenAllocatingAfterFreeThenDoNotReuseAllocation) {
TEST_F(SvmDeviceAllocationCacheTest, givenAllocationWithNeedZeroedOutAllocationWhenAllocatingAfterFreeThenDoNotReuseAllocation) {
std::unique_ptr<UltDeviceFactory> deviceFactory(new UltDeviceFactory(1, 1));
RootDeviceIndicesContainer rootDeviceIndices = {mockRootDeviceIndex};
std::map<uint32_t, DeviceBitfield> deviceBitfields{{mockRootDeviceIndex, mockDeviceBitfield}};
@@ -535,15 +538,13 @@ TEST_F(SvmDeviceAllocationCacheTest, givenAllocationWithIsInternalAllocationSetW
svmManager->freeSVMAlloc(allocation);
EXPECT_EQ(svmManager->usmDeviceAllocationsCache.allocations.size(), 1u);
unifiedMemoryProperties.isInternalAllocation = true;
unifiedMemoryProperties.needZeroedOutAllocation = true;
auto testedAllocation = svmManager->createUnifiedMemoryAllocation(10u, unifiedMemoryProperties);
EXPECT_EQ(svmManager->usmDeviceAllocationsCache.allocations.size(), 1u);
auto svmData = svmManager->getSVMAlloc(testedAllocation);
EXPECT_NE(nullptr, svmData);
EXPECT_TRUE(svmData->isInternalAllocation);
svmManager->freeSVMAlloc(testedAllocation);
EXPECT_EQ(svmManager->usmDeviceAllocationsCache.allocations.size(), 1u);
svmManager->trimUSMDeviceAllocCache();
}

View File

@@ -90,9 +90,7 @@ TEST(AllocateGlobalSurfaceTest, GivenSvmAllocsManagerWhenGlobalsAreExportedThenM
EXPECT_EQ(0, memcmp(alloc->getUnderlyingBuffer(), initData.data(), initData.size()));
ASSERT_NE(nullptr, svmAllocsManager.getSVMAlloc(reinterpret_cast<void *>(static_cast<uintptr_t>(alloc->getGpuAddress()))));
EXPECT_TRUE(alloc->isMemObjectsAllocationWithWritableFlags());
auto svmData = svmAllocsManager.getSVMAlloc(reinterpret_cast<void *>(alloc->getGpuAddress()));
EXPECT_EQ(InternalMemoryType::deviceUnifiedMemory, svmData->memoryType);
EXPECT_TRUE(svmData->isInternalAllocation);
EXPECT_EQ(InternalMemoryType::deviceUnifiedMemory, svmAllocsManager.getSVMAlloc(reinterpret_cast<void *>(alloc->getGpuAddress()))->memoryType);
EXPECT_EQ(AllocationType::constantSurface, alloc->getAllocationType());
EXPECT_FALSE(alloc->getDefaultGmm()->resourceParams.Flags.Info.NotLockable);
EXPECT_TRUE(svmAllocsManager.requestedZeroedOutAllocation);