Create dedicated allocation for global fence purposes

Related-To: NEO-3216

Change-Id: I0483a99ea1095c7a10b1318f51569e479386cac4
Signed-off-by: Milczarek, Slawomir <slawomir.milczarek@intel.com>
This commit is contained in:
Milczarek, Slawomir
2020-02-05 20:00:08 +01:00
committed by sys_ocldev
parent 004ea3946d
commit 8560b2b262
16 changed files with 99 additions and 1 deletions

View File

@@ -444,6 +444,25 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, handleTagAndScratchAllocationsResi
EXPECT_TRUE(commandStreamReceiver->isMadeNonResident(scratchAllocation));
}
HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCommandStreamReceiverWhenLocalMemoryIsEnabledAndFlushTaskIsCalledThenGlobalFenceAlocationIsMadeResident) {
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.EnableLocalMemory.set(true);
auto commandStreamReceiver = new MockCsrHw<FamilyType>(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex());
pDevice->resetCommandStreamReceiver(commandStreamReceiver);
auto globalFenceAllocation = commandStreamReceiver->globalFenceAllocation;
ASSERT_NE(globalFenceAllocation, nullptr);
EXPECT_FALSE(commandStreamReceiver->isMadeResident(globalFenceAllocation));
EXPECT_FALSE(commandStreamReceiver->isMadeNonResident(globalFenceAllocation));
flushTask(*commandStreamReceiver);
EXPECT_TRUE(commandStreamReceiver->isMadeResident(globalFenceAllocation));
EXPECT_TRUE(commandStreamReceiver->isMadeNonResident(globalFenceAllocation));
}
struct MockScratchController : public ScratchSpaceController {
using ScratchSpaceController::privateScratchAllocation;
using ScratchSpaceController::scratchAllocation;

View File

@@ -363,6 +363,19 @@ TEST(CommandStreamReceiverSimpleTest, givenCommandStreamReceiverWhenInitializeTa
EXPECT_EQ(*csr->getTagAddress(), initialHardwareTag);
}
HWTEST_F(CommandStreamReceiverTest, givenCommandStreamReceiverWhenLocalMemoryIsEnabledAndCreateGlobalFenceAllocationIsCalledThenGlobalFenceAllocationIsAllocated) {
DebugManagerStateRestore dbgRestore;
DebugManager.flags.EnableLocalMemory.set(true);
MockCsrHw<FamilyType> csr(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex());
EXPECT_EQ(nullptr, csr.globalFenceAllocation);
EXPECT_TRUE(csr.createGlobalFenceAllocation());
ASSERT_NE(nullptr, csr.globalFenceAllocation);
EXPECT_EQ(GraphicsAllocation::AllocationType::GLOBAL_FENCE, csr.globalFenceAllocation->getAllocationType());
}
TEST(CommandStreamReceiverSimpleTest, givenNullHardwareDebugModeWhenInitializeTagAllocationIsCalledThenTagAllocationIsBeingAllocatedAndinitialValueIsMinusOne) {
DebugManagerStateRestore dbgRestore;
DebugManager.flags.EnableNullHardware.set(true);

View File

@@ -304,6 +304,29 @@ HWTEST_F(DeviceHwTest, givenHwHelperInputWhenInitializingCsrThenCreatePageTableM
EXPECT_EQ(csr2.needsPageTableManager(defaultEngineType), csr2.createPageTableManagerCalled);
}
HWTEST_F(DeviceHwTest, givenDeviceCreationWhenCsrFailsToCreateGlobalSyncAllocationThenReturnNull) {
class MockUltCsrThatFailsToCreateGlobalFenceAllocation : public UltCommandStreamReceiver<FamilyType> {
public:
MockUltCsrThatFailsToCreateGlobalFenceAllocation(ExecutionEnvironment &executionEnvironment)
: UltCommandStreamReceiver<FamilyType>(executionEnvironment, 0) {}
bool createGlobalFenceAllocation() override {
return false;
}
};
class MockDeviceThatFailsToCreateGlobalFenceAllocation : public MockDevice {
public:
MockDeviceThatFailsToCreateGlobalFenceAllocation(ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex)
: MockDevice(executionEnvironment, deviceIndex) {}
std::unique_ptr<CommandStreamReceiver> createCommandStreamReceiver() const override {
return std::make_unique<MockUltCsrThatFailsToCreateGlobalFenceAllocation>(*executionEnvironment);
}
};
auto executionEnvironment = platform()->peekExecutionEnvironment();
auto mockDevice(MockDevice::create<MockDeviceThatFailsToCreateGlobalFenceAllocation>(executionEnvironment, 0));
EXPECT_EQ(nullptr, mockDevice);
}
TEST(DeviceGenEngineTest, givenHwCsrModeWhenGetEngineThenDedicatedForInternalUsageEngineIsReturned) {
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));

View File

@@ -46,6 +46,7 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily>, publ
using BaseClass::CommandStreamReceiver::executionEnvironment;
using BaseClass::CommandStreamReceiver::experimentalCmdBuffer;
using BaseClass::CommandStreamReceiver::flushStamp;
using BaseClass::CommandStreamReceiver::globalFenceAllocation;
using BaseClass::CommandStreamReceiver::GSBAFor32BitProgrammed;
using BaseClass::CommandStreamReceiver::internalAllocationStorage;
using BaseClass::CommandStreamReceiver::isEnginePrologueSent;

View File

@@ -428,6 +428,14 @@ TEST(MemoryManagerTest, givenTagBufferTypeWhenGetAllocationDataIsCalledThenSyste
EXPECT_TRUE(allocData.flags.useSystemMemory);
}
TEST(MemoryManagerTest, givenGlobalFenceTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsRequested) {
AllocationData allocData;
MockMemoryManager mockMemoryManager;
AllocationProperties properties{0, 1, GraphicsAllocation::AllocationType::GLOBAL_FENCE};
MockMemoryManager::getAllocationData(allocData, properties, nullptr, mockMemoryManager.createStorageInfoFromProperties(properties));
EXPECT_TRUE(allocData.flags.useSystemMemory);
}
TEST(MemoryManagerTest, givenPreemptionTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsRequested) {
AllocationData allocData;
MockMemoryManager mockMemoryManager;

View File

@@ -243,6 +243,7 @@ class MockFlatBatchBufferHelper : public FlatBatchBufferHelperHw<GfxFamily> {
class MockCommandStreamReceiver : public CommandStreamReceiver {
public:
using CommandStreamReceiver::CommandStreamReceiver;
using CommandStreamReceiver::globalFenceAllocation;
using CommandStreamReceiver::internalAllocationStorage;
using CommandStreamReceiver::latestFlushedTaskCount;
using CommandStreamReceiver::latestSentTaskCount;

View File

@@ -101,6 +101,7 @@ void MockDevice::resetCommandStreamReceiver(CommandStreamReceiver *newCsr, uint3
newCsr->setupContext(*osContext);
commandStreamReceivers[engineIndex].reset(newCsr);
commandStreamReceivers[engineIndex]->initializeTagAllocation();
commandStreamReceivers[engineIndex]->createGlobalFenceAllocation();
if (preemptionMode == PreemptionMode::MidThread || isSourceLevelDebuggerActive()) {
commandStreamReceivers[engineIndex]->createPreemptionAllocation();

View File

@@ -941,6 +941,7 @@ AllocationTypeTestCase allocationTypeValues[] = {
{GraphicsAllocation::AllocationType::SVM_GPU, "SVM_GPU"},
{GraphicsAllocation::AllocationType::SVM_ZERO_COPY, "SVM_ZERO_COPY"},
{GraphicsAllocation::AllocationType::TAG_BUFFER, "TAG_BUFFER"},
{GraphicsAllocation::AllocationType::GLOBAL_FENCE, "GLOBAL_FENCE"},
{GraphicsAllocation::AllocationType::TIMESTAMP_PACKET_TAG_BUFFER, "TIMESTAMP_PACKET_TAG_BUFFER"},
{GraphicsAllocation::AllocationType::UNKNOWN, "UNKNOWN"},
{GraphicsAllocation::AllocationType::WRITE_COMBINED, "WRITE_COMBINED"}};