7
7
8
8
#include " runtime/aub_mem_dump/page_table_entry_bits.h"
9
9
#include " runtime/helpers/ptr_math.h"
10
- #include " runtime/helpers/selectors.h"
11
10
#include " runtime/memory_manager/memory_banks.h"
12
11
#include " runtime/memory_manager/page_table.h"
13
12
#include " runtime/memory_manager/page_table.inl"
@@ -75,10 +74,10 @@ class MockPDPE : public MockPageTable<MockPDE, 2, 2> {
75
74
}
76
75
};
77
76
78
- class PPGTTPageTable : public TypeSelector <PML4, PDPE, sizeof ( void *) == 8 >::type {
77
+ class PPGTTPageTable : public std ::conditional<is64bit, PML4, PDPE >::type {
79
78
public:
80
- const size_t ppgttEntries = IntSelector< 512u , 4u , sizeof ( void *) == 8 >::value ;
81
- PPGTTPageTable (PhysicalAddressAllocator *allocator) : TypeSelector<PML4, PDPE, sizeof ( void *) == 8 >::type(allocator) {
79
+ const size_t ppgttEntries = is64bit ? 512u : 4u ;
80
+ PPGTTPageTable (PhysicalAddressAllocator *allocator) : std::conditional<is64bit, PML4, PDPE >::type(allocator) {
82
81
EXPECT_EQ (ppgttEntries, entries.size ());
83
82
}
84
83
bool isEmpty () {
@@ -105,7 +104,7 @@ class GGTTPageTable : public PDPE {
105
104
class PageTableFixture {
106
105
protected:
107
106
const size_t pageSize = 1 << 12 ;
108
- const uintptr_t refAddr = ( uintptr_t (1 ) << IntSelector< 46 , 31 , is64Bit>::value );
107
+ const uintptr_t refAddr = uintptr_t (1 ) << (is64Bit ? 46 : 31 );
109
108
MockPhysicalAddressAllocator allocator;
110
109
uint64_t startAddress = 0x1000 ;
111
110
@@ -248,8 +247,8 @@ TEST_F(PageTableTests48, givenBigGpuAddressWhenPageWalkIsCalledThenPageTablesAre
248
247
}
249
248
250
249
TEST_F (PageTableTests48, givenZeroEntryBitsWhenPageWalkIsCalledThenPageTableEntryHasPresentBitSet) {
251
- std::unique_ptr<TypeSelector<MockPML4, MockPDPE, sizeof ( void *) == 8 >::type>
252
- pageTable (std::make_unique<TypeSelector<MockPML4, MockPDPE, sizeof ( void *) == 8 >::type>(&allocator));
250
+ std::unique_ptr<std::conditional<is64bit, MockPML4, MockPDPE >::type>
251
+ pageTable (std::make_unique<std::conditional<is64bit, MockPML4, MockPDPE >::type>(&allocator));
253
252
254
253
uintptr_t gpuVa = 0x1000 ;
255
254
@@ -266,25 +265,25 @@ TEST_F(PageTableTests48, givenZeroEntryBitsWhenPageWalkIsCalledThenPageTableEntr
266
265
EXPECT_EQ (size, walked);
267
266
ASSERT_NE (nullptr , pageTable->entries [0 ]);
268
267
269
- PageTableEntryChecker::testEntry<TypeSelector<MockPML4, MockPDPE, sizeof ( void *) == 8 >::type>(pageTable.get (), 1 , static_cast <uintptr_t >(address | 0x1 ));
268
+ PageTableEntryChecker::testEntry<std::conditional<is64bit, MockPML4, MockPDPE >::type>(pageTable.get (), 1 , static_cast <uintptr_t >(address | 0x1 ));
270
269
}
271
270
272
271
TEST_F (PageTableTests48, givenZeroEntryBitsWhenMapIsCalledThenPageTableEntryHasPresentBitSet) {
273
- std::unique_ptr<TypeSelector<MockPML4, MockPDPE, sizeof ( void *) == 8 >::type>
274
- pageTable (std::make_unique<TypeSelector<MockPML4, MockPDPE, sizeof ( void *) == 8 >::type>(&allocator));
272
+ std::unique_ptr<std::conditional<is64bit, MockPML4, MockPDPE >::type>
273
+ pageTable (std::make_unique<std::conditional<is64bit, MockPML4, MockPDPE >::type>(&allocator));
275
274
uintptr_t gpuVa = 0x1000 ;
276
275
size_t size = pageSize;
277
276
auto address = allocator.mainAllocator .load ();
278
277
279
278
pageTable->map (gpuVa, size, 0 , MemoryBanks::MainBank);
280
279
ASSERT_NE (nullptr , pageTable->entries [0 ]);
281
280
282
- PageTableEntryChecker::testEntry<TypeSelector<MockPML4, MockPDPE, sizeof ( void *) == 8 >::type>(pageTable.get (), 1 , static_cast <uintptr_t >(address | 0x1 ));
281
+ PageTableEntryChecker::testEntry<std::conditional<is64bit, MockPML4, MockPDPE >::type>(pageTable.get (), 1 , static_cast <uintptr_t >(address | 0x1 ));
283
282
}
284
283
285
284
TEST_F (PageTableTests48, givenEntryBitsWhenPageWalkIsCalledThenEntryBitsArePassedToPageWalker) {
286
- std::unique_ptr<TypeSelector<MockPML4, MockPDPE, sizeof ( void *) == 8 >::type>
287
- pageTable (std::make_unique<TypeSelector<MockPML4, MockPDPE, sizeof ( void *) == 8 >::type>(&allocator));
285
+ std::unique_ptr<std::conditional<is64bit, MockPML4, MockPDPE >::type>
286
+ pageTable (std::make_unique<std::conditional<is64bit, MockPML4, MockPDPE >::type>(&allocator));
288
287
289
288
uintptr_t gpuVa = 0x1000 ;
290
289
size_t size = pageSize;
@@ -303,8 +302,8 @@ TEST_F(PageTableTests48, givenEntryBitsWhenPageWalkIsCalledThenEntryBitsArePasse
303
302
}
304
303
305
304
TEST_F (PageTableTests48, givenTwoPageWalksWhenSecondWalkHasDifferentEntryBitsThenEntryIsUpdated) {
306
- std::unique_ptr<TypeSelector<MockPML4, MockPDPE, sizeof ( void *) == 8 >::type>
307
- pageTable (std::make_unique<TypeSelector<MockPML4, MockPDPE, sizeof ( void *) == 8 >::type>(&allocator));
305
+ std::unique_ptr<std::conditional<is64bit, MockPML4, MockPDPE >::type>
306
+ pageTable (std::make_unique<std::conditional<is64bit, MockPML4, MockPDPE >::type>(&allocator));
308
307
309
308
uintptr_t gpuVa = 0x1000 ;
310
309
size_t size = pageSize;
@@ -328,8 +327,8 @@ TEST_F(PageTableTests48, givenTwoPageWalksWhenSecondWalkHasDifferentEntryBitsThe
328
327
}
329
328
330
329
TEST_F (PageTableTests48, givenTwoPageWalksWhenSecondWalkHasNonValidEntryBitsThenEntryIsNotUpdated) {
331
- std::unique_ptr<TypeSelector<MockPML4, MockPDPE, sizeof ( void *) == 8 >::type>
332
- pageTable (std::make_unique<TypeSelector<MockPML4, MockPDPE, sizeof ( void *) == 8 >::type>(&allocator));
330
+ std::unique_ptr<std::conditional<is64bit, MockPML4, MockPDPE >::type>
331
+ pageTable (std::make_unique<std::conditional<is64bit, MockPML4, MockPDPE >::type>(&allocator));
333
332
334
333
uintptr_t gpuVa = 0x1000 ;
335
334
size_t size = pageSize;
@@ -357,25 +356,25 @@ TEST_F(PageTableTests48, givenTwoPageWalksWhenSecondWalkHasNonValidEntryBitsThen
357
356
}
358
357
359
358
TEST_F (PageTableTests48, givenTwoMapsWhenSecondMapHasDifferentEntryBitsThenEntryIsUpdated) {
360
- std::unique_ptr<TypeSelector<MockPML4, MockPDPE, sizeof ( void *) == 8 >::type>
361
- pageTable (std::make_unique<TypeSelector<MockPML4, MockPDPE, sizeof ( void *) == 8 >::type>(&allocator));
359
+ std::unique_ptr<std::conditional<is64bit, MockPML4, MockPDPE >::type>
360
+ pageTable (std::make_unique<std::conditional<is64bit, MockPML4, MockPDPE >::type>(&allocator));
362
361
uintptr_t gpuVa = 0x1000 ;
363
362
size_t size = pageSize;
364
363
uint64_t ppgttBits = 0xabc ;
365
364
auto address = allocator.mainAllocator .load ();
366
365
367
366
pageTable->map (gpuVa, size, ppgttBits, 0 );
368
367
ASSERT_NE (nullptr , pageTable->entries [0 ]);
369
- PageTableEntryChecker::testEntry<TypeSelector<MockPML4, MockPDPE, sizeof ( void *) == 8 >::type>(pageTable.get (), 1 , static_cast <uintptr_t >(address | ppgttBits | 0x1 ));
368
+ PageTableEntryChecker::testEntry<std::conditional<is64bit, MockPML4, MockPDPE >::type>(pageTable.get (), 1 , static_cast <uintptr_t >(address | ppgttBits | 0x1 ));
370
369
371
370
ppgttBits = 0x345 ;
372
371
pageTable->map (gpuVa, size, ppgttBits, 0 );
373
- PageTableEntryChecker::testEntry<TypeSelector<MockPML4, MockPDPE, sizeof ( void *) == 8 >::type>(pageTable.get (), 1 , static_cast <uintptr_t >(address | ppgttBits | 0x1 ));
372
+ PageTableEntryChecker::testEntry<std::conditional<is64bit, MockPML4, MockPDPE >::type>(pageTable.get (), 1 , static_cast <uintptr_t >(address | ppgttBits | 0x1 ));
374
373
}
375
374
376
375
TEST_F (PageTableTests48, givenTwoMapsWhenSecondMapHasNonValidEntryBitsThenEntryIsNotUpdated) {
377
- std::unique_ptr<TypeSelector<MockPML4, MockPDPE, sizeof ( void *) == 8 >::type>
378
- pageTable (std::make_unique<TypeSelector<MockPML4, MockPDPE, sizeof ( void *) == 8 >::type>(&allocator));
376
+ std::unique_ptr<std::conditional<is64bit, MockPML4, MockPDPE >::type>
377
+ pageTable (std::make_unique<std::conditional<is64bit, MockPML4, MockPDPE >::type>(&allocator));
379
378
uintptr_t gpuVa = 0x1000 ;
380
379
size_t size = pageSize;
381
380
uint64_t ppgttBits = 0xabc ;
@@ -384,12 +383,12 @@ TEST_F(PageTableTests48, givenTwoMapsWhenSecondMapHasNonValidEntryBitsThenEntryI
384
383
pageTable->map (gpuVa, size, ppgttBits, 0 );
385
384
ASSERT_NE (nullptr , pageTable->entries [0 ]);
386
385
387
- PageTableEntryChecker::testEntry<TypeSelector<MockPML4, MockPDPE, sizeof ( void *) == 8 >::type>(pageTable.get (), 1 , static_cast <uintptr_t >(address | ppgttBits | 0x1 ));
386
+ PageTableEntryChecker::testEntry<std::conditional<is64bit, MockPML4, MockPDPE >::type>(pageTable.get (), 1 , static_cast <uintptr_t >(address | ppgttBits | 0x1 ));
388
387
389
388
uint64_t nonValidPpgttBits = PageTableEntry::nonValidBits;
390
389
pageTable->map (gpuVa, size, nonValidPpgttBits, 0 );
391
390
392
- PageTableEntryChecker::testEntry<TypeSelector<MockPML4, MockPDPE, sizeof ( void *) == 8 >::type>(pageTable.get (), 1 , static_cast <uintptr_t >(address | ppgttBits | 0x1 ));
391
+ PageTableEntryChecker::testEntry<std::conditional<is64bit, MockPML4, MockPDPE >::type>(pageTable.get (), 1 , static_cast <uintptr_t >(address | ppgttBits | 0x1 ));
393
392
}
394
393
395
394
TEST_F (PageTableTests48, givenPageTableWhenMappingTheSameAddressMultipleTimesThenNumberOfPagesReservedInAllocatorMatchPagesMapped) {
0 commit comments