mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
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:
committed by
sys_ocldev
parent
004ea3946d
commit
8560b2b262
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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"}};
|
||||
|
||||
Reference in New Issue
Block a user