Fix scratch in bindless mode

Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
This commit is contained in:
Maciej Plewka
2021-01-11 11:30:28 +00:00
committed by Compute-Runtime-Automation
parent 024012c66c
commit 24a88d22aa
8 changed files with 49 additions and 18 deletions

View File

@@ -142,7 +142,9 @@ ze_result_t CommandQueueHw<gfxCoreFamily>::executeCommandLists(
interlockedMax(commandQueuePerThreadScratchSize, commandList->getCommandListPerThreadScratchSize());
if (commandList->getCommandListPerThreadScratchSize() != 0) {
heapContainer.push_back(commandList->commandContainer.getIndirectHeap(NEO::HeapType::SURFACE_STATE)->getGraphicsAllocation());
if (commandList->commandContainer.getIndirectHeap(NEO::HeapType::SURFACE_STATE) != nullptr) {
heapContainer.push_back(commandList->commandContainer.getIndirectHeap(NEO::HeapType::SURFACE_STATE)->getGraphicsAllocation());
}
for (auto element : commandList->commandContainer.sshAllocations) {
heapContainer.push_back(element);
}

View File

@@ -773,6 +773,27 @@ HWTEST2_F(CommandQueueDestroy, givenCommandQueueAndCommandListWithSshAndScratchW
alignedFree(alloc);
}
HWTEST2_F(CommandQueueDestroy, givenCommandQueueAndCommandListWithWhenBindlessEnabledThenHeapContainerIsEmpty, CommandQueueExecuteTestSupport) {
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.UseBindlessMode.set(1);
neoDevice->bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(neoDevice->getMemoryManager(), neoDevice->getNumAvailableDevices() > 1, neoDevice->getRootDeviceIndex());
ze_command_queue_desc_t desc = {};
NEO::CommandStreamReceiver *csr;
device->getCsrForOrdinalAndIndex(&csr, 0u, 0u);
auto commandQueue = new MockCommandQueue<gfxCoreFamily>(device, csr, &desc);
commandQueue->initialize(false, false);
auto commandList = new CommandListCoreFamily<gfxCoreFamily>();
commandList->initialize(device, NEO::EngineGroupType::Compute);
commandList->commandListPerThreadScratchSize = 100u;
auto commandListHandle = commandList->toHandle();
commandQueue->executeCommandLists(1, &commandListHandle, nullptr, false);
EXPECT_EQ(commandQueue->mockHeapContainer.size(), 0u);
commandQueue->destroy();
commandList->destroy();
}
using ExecuteCommandListTests = Test<ContextFixture>;
HWTEST2_F(ExecuteCommandListTests, givenExecuteCommandListWhenItReturnsThenContainersAreEmpty, CommandQueueExecuteTestSupport) {
ze_command_queue_desc_t desc = {};

View File

@@ -503,7 +503,8 @@ struct MockScratchController : public ScratchSpaceController {
uint32_t currentTaskCount,
OsContext &osContext,
bool &stateBaseAddressDirty,
bool &vfeStateDirty) override {
bool &vfeStateDirty,
NEO::ResidencyContainer &residency) override {
}
void reserveHeap(IndirectHeap::Type heapType, IndirectHeap *&indirectHeap) override{};
};

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 Intel Corporation
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -25,6 +25,8 @@ namespace ScratchSpaceConstants {
constexpr size_t scratchSpaceOffsetFor64Bit = 4096u;
}
using ResidencyContainer = std::vector<GraphicsAllocation *>;
class ScratchSpaceController {
public:
ScratchSpaceController(uint32_t rootDeviceIndex, ExecutionEnvironment &environment, InternalAllocationStorage &allocationStorage);
@@ -63,7 +65,8 @@ class ScratchSpaceController {
uint32_t currentTaskCount,
OsContext &osContext,
bool &stateBaseAddressDirty,
bool &vfeStateDirty) = 0;
bool &vfeStateDirty,
ResidencyContainer &residency) = 0;
protected:
MemoryManager *getMemoryManager() const;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 Intel Corporation
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -97,6 +97,7 @@ void ScratchSpaceControllerBase::programBindlessSurfaceStateForScratch(BindlessH
uint32_t currentTaskCount,
OsContext &osContext,
bool &stateBaseAddressDirty,
bool &vfeStateDirty) {
bool &vfeStateDirty,
ResidencyContainer &residency) {
}
} // namespace NEO

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 Intel Corporation
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -41,7 +41,8 @@ class ScratchSpaceControllerBase : public ScratchSpaceController {
uint32_t currentTaskCount,
OsContext &osContext,
bool &stateBaseAddressDirty,
bool &vfeStateDirty) override;
bool &vfeStateDirty,
ResidencyContainer &residency) override;
protected:
void createScratchSpaceAllocation();

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -140,8 +140,8 @@ void populatePointerKernelArg(ArgDescPointer &dst,
case KernelDescriptor::BindlessAndStateless:
dst.bindful = undefined<SurfaceStateHeapOffset>;
dst.stateless = stateless;
dst.bindless = bindless;
dst.stateless = undefined<CrossThreadDataOffset>;
dst.bindless = stateless;
dst.pointerSize = pointerSize;
break;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -36,10 +36,12 @@ class MockScratchSpaceControllerBase : public ScratchSpaceControllerBase {
uint32_t currentTaskCount,
OsContext &osContext,
bool &stateBaseAddressDirty,
bool &vfeStateDirty) override {
ScratchSpaceControllerBase::programBindlessSurfaceStateForScratch(heapsHelper, requiredPerThreadScratchSize, requiredPerThreadPrivateScratchSize, currentTaskCount, osContext, stateBaseAddressDirty, vfeStateDirty);
bool &vfeStateDirty,
NEO::ResidencyContainer &residency) override {
ScratchSpaceControllerBase::programBindlessSurfaceStateForScratch(heapsHelper, requiredPerThreadScratchSize, requiredPerThreadPrivateScratchSize, currentTaskCount, osContext, stateBaseAddressDirty, vfeStateDirty, residencyContainer);
programBindlessSurfaceStateForScratchCalled = true;
}
ResidencyContainer residencyContainer;
bool programHeapsCalled = false;
bool programBindlessSurfaceStateForScratchCalled = false;
};
@@ -70,14 +72,14 @@ HWTEST_F(ScratchComtrolerTests, givenCommandQueueWhenProgramHeapBindlessCalledTh
csr.setupContext(*pDevice->getDefaultEngine().osContext);
ExecutionEnvironment *execEnv = static_cast<ExecutionEnvironment *>(pDevice->getExecutionEnvironment());
std::unique_ptr<ScratchSpaceController> scratchController = std::make_unique<MockScratchSpaceControllerBase>(pDevice->getRootDeviceIndex(),
*execEnv,
*csr.getInternalAllocationStorage());
std::unique_ptr<MockScratchSpaceControllerBase> scratchController = std::make_unique<MockScratchSpaceControllerBase>(pDevice->getRootDeviceIndex(),
*execEnv,
*csr.getInternalAllocationStorage());
bool gsbaStateDirty = false;
bool frontEndStateDirty = false;
HeapContainer heapContainer;
scratchController->programBindlessSurfaceStateForScratch(nullptr, 0, 0, 0, *pDevice->getDefaultEngine().osContext, gsbaStateDirty, frontEndStateDirty);
scratchController->programBindlessSurfaceStateForScratch(nullptr, 0, 0, 0, *pDevice->getDefaultEngine().osContext, gsbaStateDirty, frontEndStateDirty, scratchController->residencyContainer);
EXPECT_TRUE(static_cast<MockScratchSpaceControllerBase *>(scratchController.get())->programBindlessSurfaceStateForScratchCalled);
}