mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
Extend PhysicalAddressAllocator with page size and alignement
- this allows for reserving 64k pages or bigger with specified alignement if required Change-Id: I256d6c0d9e7fee0e2bac5f4ab5e4fd49ea9d8d50
This commit is contained in:
committed by
sys_ocldev
parent
ec48ccecdb
commit
ce29770d61
@@ -14,17 +14,65 @@ using namespace OCLRT;
|
||||
|
||||
TEST(PhysicalAddressAllocator, givenPhysicalAddressesAllocatorWhenReservingFirstPageThenNonZeroAddressIsReturned) {
|
||||
MockPhysicalAddressAllocator allocator;
|
||||
auto physAddress = allocator.reservePage(MemoryBanks::MainBank);
|
||||
auto physAddress = allocator.reserve4kPage(MemoryBanks::MainBank);
|
||||
EXPECT_NE(0u, physAddress);
|
||||
}
|
||||
|
||||
TEST(PhysicalAddressAllocator, givenPhysicalAddressesAllocatorWhenReservingConsecutivePagesThenReturnedAddressesAreDifferent) {
|
||||
TEST(PhysicalAddressAllocator, givenPhysicalAddressesAllocatorWhenReservingConsecutive4kPagesThenReturnedAddressesAreDifferentAndAligned) {
|
||||
MockPhysicalAddressAllocator allocator;
|
||||
|
||||
auto physAddress = allocator.reservePage(MemoryBanks::MainBank);
|
||||
auto physAddress = allocator.reserve4kPage(MemoryBanks::MainBank);
|
||||
EXPECT_NE(0u, physAddress);
|
||||
auto physAddress1 = allocator.reservePage(MemoryBanks::MainBank);
|
||||
EXPECT_EQ(0u, physAddress & MemoryConstants::pageMask);
|
||||
|
||||
auto physAddress1 = allocator.reserve4kPage(MemoryBanks::MainBank);
|
||||
EXPECT_NE(physAddress, physAddress1);
|
||||
auto physAddress2 = allocator.reservePage(MemoryBanks::MainBank);
|
||||
EXPECT_EQ(0u, physAddress1 & MemoryConstants::pageMask);
|
||||
|
||||
auto physAddress2 = allocator.reserve4kPage(MemoryBanks::MainBank);
|
||||
EXPECT_NE(physAddress1, physAddress2);
|
||||
EXPECT_EQ(0u, physAddress2 & MemoryConstants::pageMask);
|
||||
}
|
||||
|
||||
TEST(PhysicalAddressAllocator, givenPhysicalAddressesAllocatorWhenReservingFirst64kPageThen64kAlignedIsReturned) {
|
||||
MockPhysicalAddressAllocator allocator;
|
||||
auto physAddress = allocator.reserve64kPage(MemoryBanks::MainBank);
|
||||
EXPECT_NE(0u, physAddress);
|
||||
EXPECT_EQ(0u, physAddress & MemoryConstants::page64kMask);
|
||||
}
|
||||
|
||||
TEST(PhysicalAddressAllocator, givenPhysicalAddressesAllocatorWhenReservingConsecutive64kPagesThenReturnedAddressesAreDifferentAndAligned) {
|
||||
MockPhysicalAddressAllocator allocator;
|
||||
|
||||
auto physAddress = allocator.reserve64kPage(MemoryBanks::MainBank);
|
||||
EXPECT_NE(0u, physAddress);
|
||||
EXPECT_EQ(0u, physAddress & MemoryConstants::page64kMask);
|
||||
|
||||
auto physAddress1 = allocator.reserve64kPage(MemoryBanks::MainBank);
|
||||
EXPECT_NE(physAddress, physAddress1);
|
||||
EXPECT_EQ(0u, physAddress & MemoryConstants::page64kMask);
|
||||
|
||||
auto physAddress2 = allocator.reserve64kPage(MemoryBanks::MainBank);
|
||||
EXPECT_NE(physAddress1, physAddress2);
|
||||
EXPECT_EQ(0u, physAddress & MemoryConstants::page64kMask);
|
||||
}
|
||||
|
||||
TEST(PhysicalAddressAllocator, givenPhysicalAddressesAllocatorWhenReservingInterleaving4kPagesAnd64kPagesThenReturnedAddressesAreCorrectlyAligned) {
|
||||
MockPhysicalAddressAllocator allocator;
|
||||
|
||||
auto physAddress = allocator.reserve4kPage(MemoryBanks::MainBank);
|
||||
EXPECT_NE(0u, physAddress);
|
||||
EXPECT_EQ(0u, physAddress & MemoryConstants::pageMask);
|
||||
|
||||
auto physAddress1 = allocator.reserve64kPage(MemoryBanks::MainBank);
|
||||
EXPECT_NE(physAddress, physAddress1);
|
||||
EXPECT_EQ(0u, physAddress1 & MemoryConstants::page64kMask);
|
||||
|
||||
auto physAddress2 = allocator.reserve4kPage(MemoryBanks::MainBank);
|
||||
EXPECT_NE(physAddress1, physAddress2);
|
||||
EXPECT_EQ(0u, physAddress2 & MemoryConstants::pageMask);
|
||||
|
||||
auto physAddress3 = allocator.reserve64kPage(MemoryBanks::MainBank);
|
||||
EXPECT_NE(physAddress, physAddress1);
|
||||
EXPECT_EQ(0u, physAddress3 & MemoryConstants::page64kMask);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user