mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
WSL - fixing allocation alignment
Signed-off-by: Jaroslaw Chodor <jaroslaw.chodor@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
2fab8ccf05
commit
766d56e300
@ -20,6 +20,7 @@ class MockWddmMemoryManager : public MemoryManagerCreate<WddmMemoryManager> {
|
||||
public:
|
||||
using BaseClass::alignmentSelector;
|
||||
using BaseClass::allocateGraphicsMemoryForNonSvmHostPtr;
|
||||
using BaseClass::allocateGraphicsMemoryWithAlignment;
|
||||
using BaseClass::allocateGraphicsMemoryWithGpuVa;
|
||||
using BaseClass::allocateGraphicsMemoryWithProperties;
|
||||
using BaseClass::allocateShareableMemory;
|
||||
|
@ -2290,3 +2290,46 @@ TEST_F(WddmMemoryManagerSimpleTest, givenWddmMemoryManagerWhenGettingGlobalMemor
|
||||
uint32_t rootDeviceIndex = 0u;
|
||||
EXPECT_EQ(memoryManager.getPercentOfGlobalMemoryAvailable(rootDeviceIndex), 0.8);
|
||||
}
|
||||
|
||||
TEST_F(WddmMemoryManagerSimpleTest, whenAlignmentRequirementExceedsPageSizeThenAllocateGraphicsMemoryFromSystemPtr) {
|
||||
struct MockWddmMemoryManagerAllocateWithAlignment : MockWddmMemoryManager {
|
||||
using MockWddmMemoryManager::MockWddmMemoryManager;
|
||||
|
||||
GraphicsAllocation *allocateSystemMemoryAndCreateGraphicsAllocationFromIt(const AllocationData &allocationData) override {
|
||||
++callCount.allocateSystemMemoryAndCreateGraphicsAllocationFromIt;
|
||||
return nullptr;
|
||||
}
|
||||
GraphicsAllocation *allocateGraphicsMemoryUsingKmdAndMapItToCpuVA(const AllocationData &allocationData, bool allowLargePages) override {
|
||||
++callCount.allocateGraphicsMemoryUsingKmdAndMapItToCpuVA;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
struct {
|
||||
int allocateSystemMemoryAndCreateGraphicsAllocationFromIt = 0;
|
||||
int allocateGraphicsMemoryUsingKmdAndMapItToCpuVA = 0;
|
||||
} callCount;
|
||||
};
|
||||
|
||||
MockWddmMemoryManagerAllocateWithAlignment memoryManager(true, true, *executionEnvironment);
|
||||
|
||||
AllocationData allocData = {};
|
||||
allocData.size = 1024;
|
||||
allocData.alignment = MemoryConstants::pageSize64k * 4;
|
||||
memoryManager.allocateGraphicsMemoryWithAlignment(allocData);
|
||||
EXPECT_EQ(1U, memoryManager.callCount.allocateSystemMemoryAndCreateGraphicsAllocationFromIt);
|
||||
EXPECT_EQ(0U, memoryManager.callCount.allocateGraphicsMemoryUsingKmdAndMapItToCpuVA);
|
||||
|
||||
memoryManager.callCount.allocateSystemMemoryAndCreateGraphicsAllocationFromIt = 0;
|
||||
memoryManager.callCount.allocateGraphicsMemoryUsingKmdAndMapItToCpuVA = 0;
|
||||
|
||||
allocData.size = 1024;
|
||||
allocData.alignment = MemoryConstants::pageSize;
|
||||
memoryManager.allocateGraphicsMemoryWithAlignment(allocData);
|
||||
if (preferredAllocationMethod == GfxMemoryAllocationMethod::AllocateByKmd) {
|
||||
EXPECT_EQ(0U, memoryManager.callCount.allocateSystemMemoryAndCreateGraphicsAllocationFromIt);
|
||||
EXPECT_EQ(1U, memoryManager.callCount.allocateGraphicsMemoryUsingKmdAndMapItToCpuVA);
|
||||
} else {
|
||||
EXPECT_EQ(1U, memoryManager.callCount.allocateSystemMemoryAndCreateGraphicsAllocationFromIt);
|
||||
EXPECT_EQ(0U, memoryManager.callCount.allocateGraphicsMemoryUsingKmdAndMapItToCpuVA);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user