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:
parent
004ea3946d
commit
8560b2b262
|
@ -79,6 +79,7 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
|
|||
SVM_GPU,
|
||||
SVM_ZERO_COPY,
|
||||
TAG_BUFFER,
|
||||
GLOBAL_FENCE,
|
||||
TIMESTAMP_PACKET_TAG_BUFFER,
|
||||
WRITE_COMBINED
|
||||
};
|
||||
|
|
|
@ -178,6 +178,11 @@ void CommandStreamReceiver::cleanupResources() {
|
|||
tagAddress = nullptr;
|
||||
}
|
||||
|
||||
if (globalFenceAllocation) {
|
||||
getMemoryManager()->freeGraphicsMemory(globalFenceAllocation);
|
||||
globalFenceAllocation = nullptr;
|
||||
}
|
||||
|
||||
if (preemptionAllocation) {
|
||||
getMemoryManager()->freeGraphicsMemory(preemptionAllocation);
|
||||
preemptionAllocation = nullptr;
|
||||
|
@ -379,6 +384,15 @@ bool CommandStreamReceiver::initializeTagAllocation() {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CommandStreamReceiver::createGlobalFenceAllocation() {
|
||||
if (!localMemoryEnabled) {
|
||||
return true;
|
||||
}
|
||||
DEBUG_BREAK_IF(this->globalFenceAllocation != nullptr);
|
||||
this->globalFenceAllocation = getMemoryManager()->allocateGraphicsMemoryWithProperties({rootDeviceIndex, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::GLOBAL_FENCE});
|
||||
return this->globalFenceAllocation != nullptr;
|
||||
}
|
||||
|
||||
bool CommandStreamReceiver::createPreemptionAllocation() {
|
||||
auto hwInfo = executionEnvironment.getHardwareInfo();
|
||||
AllocationProperties properties{rootDeviceIndex, true, hwInfo->capabilityTable.requiredPreemptionSurfaceSize, GraphicsAllocation::AllocationType::PREEMPTION, false};
|
||||
|
|
|
@ -149,6 +149,7 @@ class CommandStreamReceiver {
|
|||
void setExperimentalCmdBuffer(std::unique_ptr<ExperimentalCommandBuffer> &&cmdBuffer);
|
||||
|
||||
bool initializeTagAllocation();
|
||||
MOCKABLE_VIRTUAL bool createGlobalFenceAllocation();
|
||||
MOCKABLE_VIRTUAL bool createPreemptionAllocation();
|
||||
MOCKABLE_VIRTUAL bool createPerDssBackedBuffer(Device &device);
|
||||
MOCKABLE_VIRTUAL std::unique_lock<MutexType> obtainUniqueOwnership();
|
||||
|
@ -216,6 +217,7 @@ class CommandStreamReceiver {
|
|||
volatile uint32_t *tagAddress = nullptr;
|
||||
|
||||
GraphicsAllocation *tagAllocation = nullptr;
|
||||
GraphicsAllocation *globalFenceAllocation = nullptr;
|
||||
GraphicsAllocation *preemptionAllocation = nullptr;
|
||||
GraphicsAllocation *debugSurface = nullptr;
|
||||
GraphicsAllocation *perDssBackedBuffer = nullptr;
|
||||
|
|
|
@ -385,8 +385,13 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
|
|||
|
||||
this->makeResident(*tagAllocation);
|
||||
|
||||
if (preemptionAllocation)
|
||||
if (globalFenceAllocation) {
|
||||
makeResident(*globalFenceAllocation);
|
||||
}
|
||||
|
||||
if (preemptionAllocation) {
|
||||
makeResident(*preemptionAllocation);
|
||||
}
|
||||
|
||||
if (dispatchFlags.preemptionMode == PreemptionMode::MidThread || device.isSourceLevelDebuggerActive()) {
|
||||
makeResident(*SipKernel::getSipKernelAllocation(device));
|
||||
|
|
|
@ -140,6 +140,11 @@ bool Device::createEngine(uint32_t deviceCsrIndex, aub_stream::EngineType engine
|
|||
if (!commandStreamReceiver->initializeTagAllocation()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!commandStreamReceiver->createGlobalFenceAllocation()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (engineType == defaultEngineType && !lowPriority && !internalUsage) {
|
||||
defaultEngineIndex = deviceCsrIndex;
|
||||
}
|
||||
|
|
|
@ -105,6 +105,7 @@ void RootDevice::initializeRootCommandStreamReceiver() {
|
|||
|
||||
rootCommandStreamReceiver->setupContext(*osContext);
|
||||
rootCommandStreamReceiver->initializeTagAllocation();
|
||||
rootCommandStreamReceiver->createGlobalFenceAllocation();
|
||||
commandStreamReceivers.push_back(std::move(rootCommandStreamReceiver));
|
||||
engines.emplace_back(commandStreamReceivers.back().get(), osContext);
|
||||
}
|
||||
|
|
|
@ -280,6 +280,7 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo
|
|||
case GraphicsAllocation::AllocationType::SVM_CPU:
|
||||
case GraphicsAllocation::AllocationType::SVM_ZERO_COPY:
|
||||
case GraphicsAllocation::AllocationType::TAG_BUFFER:
|
||||
case GraphicsAllocation::AllocationType::GLOBAL_FENCE:
|
||||
case GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY:
|
||||
allocationData.flags.useSystemMemory = true;
|
||||
default:
|
||||
|
|
|
@ -315,6 +315,8 @@ const char *FileLogger<DebugLevel>::getAllocationTypeString(GraphicsAllocation c
|
|||
return "SVM_ZERO_COPY";
|
||||
case GraphicsAllocation::AllocationType::TAG_BUFFER:
|
||||
return "TAG_BUFFER";
|
||||
case GraphicsAllocation::AllocationType::GLOBAL_FENCE:
|
||||
return "GLOBAL_FENCE";
|
||||
case GraphicsAllocation::AllocationType::TIMESTAMP_PACKET_TAG_BUFFER:
|
||||
return "TIMESTAMP_PACKET_TAG_BUFFER";
|
||||
case GraphicsAllocation::AllocationType::UNKNOWN:
|
||||
|
|
|
@ -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"}};
|
||||
|
|
Loading…
Reference in New Issue