Move physical address allocator to CommandStreamReceiverSimulatedHw

Change-Id: Ic3c397fe1a93eccae9235f1315a26ae31a3f5b60
Signed-off-by: Pawel Wilma <pawel.wilma@intel.com>
This commit is contained in:
Pawel Wilma
2018-12-17 15:05:26 +01:00
committed by sys_ocldev
parent 62814237e7
commit 068582445d
7 changed files with 25 additions and 9 deletions

View File

@ -49,7 +49,7 @@ AUBCommandStreamReceiverHw<GfxFamily>::AUBCommandStreamReceiverHw(const Hardware
}
if (!aubCenter->getPhysicalAddressAllocator()) {
aubCenter->initPhysicalAddressAllocator(this->createPhysicalAddressAllocator());
aubCenter->initPhysicalAddressAllocator(this->createPhysicalAddressAllocator(&hwInfoIn));
}
auto physicalAddressAllocator = aubCenter->getPhysicalAddressAllocator();
UNRECOVERABLE_IF(nullptr == physicalAddressAllocator);

View File

@ -9,7 +9,6 @@
#include "runtime/command_stream/command_stream_receiver_hw.h"
#include "runtime/gen_common/aub_mapper.h"
#include "runtime/memory_manager/memory_banks.h"
#include "runtime/memory_manager/physical_address_allocator.h"
namespace AubMemDump {
struct AubStream;
@ -39,6 +38,5 @@ class CommandStreamReceiverSimulatedCommonHw : public CommandStreamReceiverHw<Gf
protected:
MMIOList splitMMIORegisters(const std::string &registers, char delimiter);
PhysicalAddressAllocator *createPhysicalAddressAllocator();
};
} // namespace OCLRT

View File

@ -66,11 +66,6 @@ void CommandStreamReceiverSimulatedCommonHw<GfxFamily>::initAdditionalMMIO() {
}
}
template <typename GfxFamily>
PhysicalAddressAllocator *CommandStreamReceiverSimulatedCommonHw<GfxFamily>::createPhysicalAddressAllocator() {
return new PhysicalAddressAllocator();
}
template <typename GfxFamily>
uint64_t CommandStreamReceiverSimulatedCommonHw<GfxFamily>::getPPGTTAdditionalBits(GraphicsAllocation *gfxAllocation) {
return BIT(PageTableEntry::presentBit) | BIT(PageTableEntry::writableBit) | BIT(PageTableEntry::userSupervisorBit);

View File

@ -8,6 +8,7 @@
#pragma once
#include "runtime/command_stream/command_stream_receiver_simulated_common_hw.h"
#include "runtime/memory_manager/memory_banks.h"
#include "runtime/memory_manager/physical_address_allocator.h"
namespace OCLRT {
class GraphicsAllocation;
@ -24,5 +25,8 @@ class CommandStreamReceiverSimulatedHw : public CommandStreamReceiverSimulatedCo
int getAddressSpace(int hint) {
return AubMemDump::AddressSpaceValues::TraceNonlocal;
}
PhysicalAddressAllocator *createPhysicalAddressAllocator(const HardwareInfo *hwInfo) {
return new PhysicalAddressAllocator();
}
};
} // namespace OCLRT

View File

@ -27,7 +27,7 @@ TbxCommandStreamReceiverHw<GfxFamily>::TbxCommandStreamReceiverHw(const Hardware
ExecutionEnvironment &executionEnvironment)
: BaseClass(hwInfoIn, executionEnvironment) {
physicalAddressAllocator.reset(this->createPhysicalAddressAllocator());
physicalAddressAllocator.reset(this->createPhysicalAddressAllocator(&hwInfoIn));
ppgtt = std::make_unique<std::conditional<is64bit, PML4, PDPE>::type>(physicalAddressAllocator.get());
ggtt = std::make_unique<PDPE>(physicalAddressAllocator.get());

View File

@ -851,3 +851,12 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenSshSize
auto aubCsr = std::make_unique<MockAubCsr<FamilyType>>(**platformDevices, "", true, *pDevice->executionEnvironment);
EXPECT_EQ(64 * KB, aubCsr->defaultSshSize);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenPhysicalAddressAllocatorIsCreatedThenItIsNotNull) {
MockAubCsr<FamilyType> aubCsr(**platformDevices, "", true, *pDevice->executionEnvironment);
auto oldSkuTable = hwInfoHelper.pSkuTable;
std::unique_ptr<FeatureTable, std::function<void(FeatureTable *)>> skuTable(new FeatureTable, [&](FeatureTable *ptr) { delete ptr; hwInfoHelper.pSkuTable = oldSkuTable; });
hwInfoHelper.pSkuTable = skuTable.get();
std::unique_ptr<PhysicalAddressAllocator> allocator(aubCsr.createPhysicalAddressAllocator(&hwInfoHelper));
ASSERT_NE(nullptr, allocator);
}

View File

@ -333,3 +333,13 @@ HWTEST_F(TbxCommandSteamSimpleTest, whenTbxCommandStreamReceiverIsCreatedThenPPG
physicalAddress = tbxCsr.ggtt->map(address, MemoryConstants::pageSize, 0, MemoryBanks::MainBank);
EXPECT_NE(0u, physicalAddress);
}
HWTEST_F(TbxCommandSteamSimpleTest, givenTbxCommandStreamReceiverWhenPhysicalAddressAllocatorIsCreatedThenItIsNotNull) {
MockTbxCsr<FamilyType> tbxCsr(*platformDevices[0], *pDevice->executionEnvironment);
auto oldSkuTable = hwInfoHelper.pSkuTable;
std::unique_ptr<FeatureTable, std::function<void(FeatureTable *)>> skuTable(new FeatureTable, [&](FeatureTable *ptr) { delete ptr; hwInfoHelper.pSkuTable = oldSkuTable; });
hwInfoHelper.pSkuTable = skuTable.get();
std::unique_ptr<PhysicalAddressAllocator> allocator(tbxCsr.createPhysicalAddressAllocator(&hwInfoHelper));
ASSERT_NE(nullptr, allocator);
hwInfoHelper.pSkuTable = nullptr;
}