Skip to content

Commit 432ecbc

Browse files
fix: disable compression for exported allocations
Related-To: NEO-12021 Signed-off-by: Szymon Morek <[email protected]>
1 parent 80afda1 commit 432ecbc

File tree

7 files changed

+25
-1
lines changed

7 files changed

+25
-1
lines changed

level_zero/core/test/unit_tests/sources/memory/test_memory.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3154,7 +3154,10 @@ TEST_F(MemoryExportImportTest,
31543154
size, alignment, &ptr);
31553155
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
31563156
EXPECT_NE(nullptr, ptr);
3157-
3157+
auto allocData = context->getDriverHandle()->getSvmAllocsManager()->getSVMAlloc(ptr);
3158+
EXPECT_NE(nullptr, allocData);
3159+
auto allocation = allocData->gpuAllocations.getDefaultGraphicsAllocation();
3160+
EXPECT_FALSE(allocation->isCompressionEnabled());
31583161
result = context->freeMem(ptr);
31593162
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
31603163

shared/source/memory_manager/memory_manager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,8 @@ class MemoryManager {
306306
virtual bool createMediaContext(uint32_t rootDeviceIndex, void *controlSharedMemoryBuffer, uint32_t controlSharedMemoryBufferSize, void *controlBatchBuffer, uint32_t controlBatchBufferSize, uint64_t &outDoorbell) { return false; }
307307
virtual bool releaseMediaContext(uint32_t rootDeviceIndex, uint64_t doorbellHandle) { return false; }
308308

309+
virtual bool isCompressionSupportedForShareable(bool isShareable) { return true; }
310+
309311
protected:
310312
bool getAllocationData(AllocationData &allocationData, const AllocationProperties &properties, const void *hostPtr, const StorageInfo &storageInfo);
311313
static void overrideAllocationData(AllocationData &allocationData, const AllocationProperties &properties);

shared/source/memory_manager/unified_memory_manager.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ void *SVMAllocsManager::createUnifiedMemoryAllocation(size_t size,
294294
unifiedMemoryProperties.cacheRegion = MemoryPropertiesHelper::getCacheRegion(memoryProperties.allocationFlags);
295295
unifiedMemoryProperties.flags.uncacheable = memoryProperties.allocationFlags.flags.locallyUncachedResource;
296296
unifiedMemoryProperties.flags.preferCompressed = compressionEnabled || memoryProperties.allocationFlags.flags.compressedHint;
297+
unifiedMemoryProperties.flags.preferCompressed &= memoryManager->isCompressionSupportedForShareable(memoryProperties.allocationFlags.flags.shareable);
297298
unifiedMemoryProperties.flags.resource48Bit = memoryProperties.allocationFlags.flags.resource48Bit;
298299

299300
if (memoryProperties.memoryType == InternalMemoryType::deviceUnifiedMemory) {

shared/source/os_interface/linux/drm_memory_manager.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2740,4 +2740,9 @@ bool DrmMemoryManager::releaseMediaContext(uint32_t rootDeviceIndex, uint64_t do
27402740
return getDrm(rootDeviceIndex).getIoctlHelper()->releaseMediaContext(doorbellHandle);
27412741
}
27422742

2743+
bool DrmMemoryManager::isCompressionSupportedForShareable(bool isShareable) {
2744+
// Currently KMD does not support compression with allocation sharing
2745+
return !isShareable;
2746+
}
2747+
27432748
} // namespace NEO

shared/source/os_interface/linux/drm_memory_manager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ class DrmMemoryManager : public MemoryManager {
104104
bool createMediaContext(uint32_t rootDeviceIndex, void *controlSharedMemoryBuffer, uint32_t controlSharedMemoryBufferSize, void *controlBatchBuffer, uint32_t controlBatchBufferSize, uint64_t &outDoorbell) override;
105105
bool releaseMediaContext(uint32_t rootDeviceIndex, uint64_t doorbellHandle) override;
106106

107+
bool isCompressionSupportedForShareable(bool isShareable) override;
108+
107109
protected:
108110
void registerSharedBoHandleAllocation(DrmAllocation *drmAllocation);
109111
BufferObjectHandleWrapper tryToGetBoHandleWrapperWithSharedOwnership(int boHandle);

shared/test/unit_test/memory_manager/memory_manager_tests.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3204,4 +3204,10 @@ TEST(AllocationListTest, givenAllocationInListWhenFreeAllGraphicsAllocationsCall
32043204
EXPECT_EQ(nullptr, allocList.peekHead());
32053205
EXPECT_EQ(nullptr, allocList.peekTail());
32063206
EXPECT_TRUE(allocList.peekIsEmpty());
3207+
}
3208+
3209+
TEST(MemoryManagerTest, givenIsCompressionSupportedForShareableThenReturnTrue) {
3210+
MockMemoryManager memoryManager;
3211+
EXPECT_TRUE(memoryManager.isCompressionSupportedForShareable(true));
3212+
EXPECT_TRUE(memoryManager.isCompressionSupportedForShareable(false));
32073213
}

shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7929,3 +7929,8 @@ TEST_F(DrmMemoryManagerTest, givenDebugVariableToToggleGpuVaBitsWhenAllocatingRe
79297929
memoryManager->freeGraphicsMemory(allocation);
79307930
}
79317931
}
7932+
7933+
TEST_F(DrmMemoryManagerTest, givenIsCompressionSupportedForShareableThenReturnCorrectValue) {
7934+
EXPECT_FALSE(memoryManager->isCompressionSupportedForShareable(true));
7935+
EXPECT_TRUE(memoryManager->isCompressionSupportedForShareable(false));
7936+
}

0 commit comments

Comments
 (0)