2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2019-02-08 17:27:48 +08:00
|
|
|
* Copyright (C) 2017-2019 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-04-05 21:12:28 +08:00
|
|
|
#include "runtime/command_queue/gpgpu_walker.h"
|
2018-09-27 21:22:36 +08:00
|
|
|
#include "runtime/command_queue/hardware_interface.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "runtime/event/hw_timestamps.h"
|
2019-06-12 15:13:06 +08:00
|
|
|
#include "runtime/helpers/hardware_commands_helper.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "runtime/helpers/task_information.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
#include "runtime/utilities/tag_allocator.h"
|
|
|
|
#include "unit_tests/fixtures/execution_model_fixture.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "unit_tests/mocks/mock_command_queue.h"
|
|
|
|
#include "unit_tests/mocks/mock_device_queue.h"
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
using namespace NEO;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
class SubmitBlockedParentKernelFixture : public ExecutionModelSchedulerTest,
|
|
|
|
public testing::Test {
|
|
|
|
void SetUp() override {
|
|
|
|
ExecutionModelSchedulerTest::SetUp();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TearDown() override {
|
|
|
|
ExecutionModelSchedulerTest::TearDown();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
class MockDeviceQueueHwWithCriticalSectionRelease : public DeviceQueueHw<GfxFamily> {
|
|
|
|
using BaseClass = DeviceQueueHw<GfxFamily>;
|
|
|
|
|
|
|
|
public:
|
|
|
|
MockDeviceQueueHwWithCriticalSectionRelease(Context *context,
|
|
|
|
Device *device,
|
|
|
|
cl_queue_properties &properties) : BaseClass(context, device, properties) {}
|
|
|
|
|
|
|
|
bool isEMCriticalSectionFree() override {
|
|
|
|
auto igilCmdQueue = reinterpret_cast<IGIL_CommandQueue *>(DeviceQueue::queueBuffer->getUnderlyingBuffer());
|
|
|
|
|
|
|
|
criticalSectioncheckCounter++;
|
|
|
|
|
|
|
|
if (criticalSectioncheckCounter == maxCounter) {
|
|
|
|
igilCmdQueue->m_controls.m_CriticalSection = DeviceQueueHw<GfxFamily>::ExecutionModelCriticalSection::Free;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return igilCmdQueue->m_controls.m_CriticalSection == DeviceQueueHw<GfxFamily>::ExecutionModelCriticalSection::Free;
|
|
|
|
}
|
|
|
|
|
2019-11-13 22:37:52 +08:00
|
|
|
void setupIndirectState(IndirectHeap &surfaceStateHeap, IndirectHeap &dynamicStateHeap, Kernel *parentKernel, uint32_t parentIDCount, bool isCcsUsed) override {
|
2017-12-21 07:45:38 +08:00
|
|
|
indirectStateSetup = true;
|
2019-11-13 22:37:52 +08:00
|
|
|
return BaseClass::setupIndirectState(surfaceStateHeap, dynamicStateHeap, parentKernel, parentIDCount, isCcsUsed);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
2019-08-23 19:50:46 +08:00
|
|
|
void addExecutionModelCleanUpSection(Kernel *parentKernel, TagNode<HwTimeStamps> *hwTimeStamp, uint64_t tagAddress, uint32_t taskCount) override {
|
2017-12-21 07:45:38 +08:00
|
|
|
cleanupSectionAdded = true;
|
2019-02-08 17:27:48 +08:00
|
|
|
timestampAddedInCleanupSection = hwTimeStamp ? hwTimeStamp->tagForCpuAccess : nullptr;
|
2019-08-23 19:50:46 +08:00
|
|
|
return BaseClass::addExecutionModelCleanUpSection(parentKernel, hwTimeStamp, tagAddress, taskCount);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
2019-11-13 22:37:52 +08:00
|
|
|
void dispatchScheduler(LinearStream &commandStream, SchedulerKernel &scheduler, PreemptionMode preemptionMode, IndirectHeap *ssh, IndirectHeap *dsh, bool isCcsUsed) override {
|
2017-12-21 07:45:38 +08:00
|
|
|
schedulerDispatched = true;
|
2019-11-13 22:37:52 +08:00
|
|
|
return BaseClass::dispatchScheduler(commandStream, scheduler, preemptionMode, ssh, dsh, isCcsUsed);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t criticalSectioncheckCounter = 0;
|
|
|
|
const uint32_t maxCounter = 10;
|
|
|
|
bool indirectStateSetup = false;
|
|
|
|
bool cleanupSectionAdded = false;
|
|
|
|
bool schedulerDispatched = false;
|
|
|
|
HwTimeStamps *timestampAddedInCleanupSection = nullptr;
|
|
|
|
};
|
|
|
|
|
2019-07-15 21:08:42 +08:00
|
|
|
HWCMDTEST_F(IGFX_GEN8_CORE, ParentKernelCommandQueueFixture, givenLockedEMcritcalSectionWhenParentKernelCommandIsSubmittedThenItWaitsForcriticalSectionReleasement) {
|
2017-12-21 07:45:38 +08:00
|
|
|
if (device->getSupportedClVersion() >= 20) {
|
|
|
|
cl_queue_properties properties[3] = {0};
|
2018-07-30 20:13:37 +08:00
|
|
|
MockParentKernel *parentKernel = MockParentKernel::create(*context);
|
2017-12-21 07:45:38 +08:00
|
|
|
MockDeviceQueueHwWithCriticalSectionRelease<FamilyType> mockDevQueue(context, device, properties[0]);
|
|
|
|
parentKernel->createReflectionSurface();
|
|
|
|
context->setDefaultDeviceQueue(&mockDevQueue);
|
|
|
|
|
|
|
|
mockDevQueue.acquireEMCriticalSection();
|
|
|
|
|
|
|
|
size_t heapSize = 20;
|
2018-04-05 21:12:28 +08:00
|
|
|
size_t dshSize = mockDevQueue.getDshBuffer()->getUnderlyingBufferSize();
|
|
|
|
|
|
|
|
IndirectHeap *dsh = nullptr, *ioh = nullptr, *ssh = nullptr;
|
|
|
|
pCmdQ->allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, dshSize, dsh);
|
|
|
|
pCmdQ->allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, heapSize, ioh);
|
|
|
|
pCmdQ->allocateHeapMemory(IndirectHeap::SURFACE_STATE, heapSize, ssh);
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
dsh->getSpace(mockDevQueue.getDshOffset());
|
|
|
|
|
2019-12-17 17:43:19 +08:00
|
|
|
size_t minSizeSSHForEM = HardwareCommandsHelper<FamilyType>::getSshSizeForExecutionModel(*parentKernel);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-11-07 21:15:04 +08:00
|
|
|
auto cmdStreamAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties({device->getRootDeviceIndex(), 4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
2019-07-23 02:55:09 +08:00
|
|
|
auto blockedCommandData = std::make_unique<KernelOperation>(new LinearStream(cmdStreamAllocation),
|
|
|
|
*pCmdQ->getGpgpuCommandStreamReceiver().getInternalAllocationStorage());
|
2019-07-19 03:15:50 +08:00
|
|
|
blockedCommandData->setHeaps(dsh, ioh, ssh);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
blockedCommandData->surfaceStateHeapSizeEM = minSizeSSHForEM;
|
2018-03-02 05:43:04 +08:00
|
|
|
PreemptionMode preemptionMode = device->getPreemptionMode();
|
2017-12-21 07:45:38 +08:00
|
|
|
std::vector<Surface *> surfaces;
|
2019-07-23 02:55:09 +08:00
|
|
|
auto *cmdComputeKernel = new CommandComputeKernel(*pCmdQ, blockedCommandData, surfaces, false, false, false, nullptr, preemptionMode, parentKernel, 1);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
cmdComputeKernel->submit(0, false);
|
|
|
|
|
|
|
|
EXPECT_EQ(mockDevQueue.maxCounter, mockDevQueue.criticalSectioncheckCounter);
|
|
|
|
delete cmdComputeKernel;
|
|
|
|
delete parentKernel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-15 21:08:42 +08:00
|
|
|
HWCMDTEST_F(IGFX_GEN8_CORE, ParentKernelCommandQueueFixture, givenParentKernelWhenCommandIsSubmittedThenPassedDshIsUsed) {
|
2017-12-21 07:45:38 +08:00
|
|
|
if (device->getSupportedClVersion() >= 20) {
|
|
|
|
cl_queue_properties properties[3] = {0};
|
2018-07-30 20:13:37 +08:00
|
|
|
MockParentKernel *parentKernel = MockParentKernel::create(*context);
|
2017-12-21 07:45:38 +08:00
|
|
|
MockDeviceQueueHwWithCriticalSectionRelease<FamilyType> mockDevQueue(context, device, properties[0]);
|
|
|
|
parentKernel->createReflectionSurface();
|
|
|
|
context->setDefaultDeviceQueue(&mockDevQueue);
|
|
|
|
|
|
|
|
auto *dshOfDevQueue = mockDevQueue.getIndirectHeap(IndirectHeap::DYNAMIC_STATE);
|
|
|
|
|
|
|
|
size_t heapSize = 20;
|
2018-04-05 21:12:28 +08:00
|
|
|
size_t dshSize = mockDevQueue.getDshBuffer()->getUnderlyingBufferSize();
|
|
|
|
|
|
|
|
IndirectHeap *dsh = nullptr, *ioh = nullptr, *ssh = nullptr;
|
|
|
|
pCmdQ->allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, dshSize, dsh);
|
|
|
|
pCmdQ->allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, heapSize, ioh);
|
|
|
|
pCmdQ->allocateHeapMemory(IndirectHeap::SURFACE_STATE, heapSize, ssh);
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
// add initial offset of colorCalState
|
|
|
|
dsh->getSpace(DeviceQueue::colorCalcStateSize);
|
|
|
|
|
|
|
|
uint64_t ValueToFillDsh = 5;
|
|
|
|
uint64_t *dshVal = (uint64_t *)dsh->getSpace(sizeof(uint64_t));
|
2018-04-05 21:12:28 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
// Fill Interface Descriptor Data
|
|
|
|
*dshVal = ValueToFillDsh;
|
|
|
|
|
|
|
|
// Move to parent DSH Offset
|
|
|
|
size_t alignToOffsetDshSize = mockDevQueue.getDshOffset() - DeviceQueue::colorCalcStateSize - sizeof(uint64_t);
|
|
|
|
dsh->getSpace(alignToOffsetDshSize);
|
|
|
|
|
|
|
|
// Fill with pattern
|
|
|
|
dshVal = (uint64_t *)dsh->getSpace(sizeof(uint64_t));
|
|
|
|
*dshVal = ValueToFillDsh;
|
|
|
|
|
|
|
|
size_t usedDSHBeforeSubmit = dshOfDevQueue->getUsed();
|
|
|
|
|
|
|
|
uint32_t colorCalcSizeDevQueue = DeviceQueue::colorCalcStateSize;
|
|
|
|
EXPECT_EQ(colorCalcSizeDevQueue, usedDSHBeforeSubmit);
|
|
|
|
|
2019-11-07 21:15:04 +08:00
|
|
|
auto cmdStreamAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties({device->getRootDeviceIndex(), 4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
2019-07-23 02:55:09 +08:00
|
|
|
auto blockedCommandData = std::make_unique<KernelOperation>(new LinearStream(cmdStreamAllocation),
|
|
|
|
*pCmdQ->getGpgpuCommandStreamReceiver().getInternalAllocationStorage());
|
2019-07-19 03:15:50 +08:00
|
|
|
blockedCommandData->setHeaps(dsh, ioh, ssh);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-12-17 17:43:19 +08:00
|
|
|
size_t minSizeSSHForEM = HardwareCommandsHelper<FamilyType>::getSshSizeForExecutionModel(*parentKernel);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
blockedCommandData->surfaceStateHeapSizeEM = minSizeSSHForEM;
|
2018-03-02 05:43:04 +08:00
|
|
|
PreemptionMode preemptionMode = device->getPreemptionMode();
|
2017-12-21 07:45:38 +08:00
|
|
|
std::vector<Surface *> surfaces;
|
2019-07-23 02:55:09 +08:00
|
|
|
auto *cmdComputeKernel = new CommandComputeKernel(*pCmdQ, blockedCommandData, surfaces, false, false, false, nullptr, preemptionMode, parentKernel, 1);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
cmdComputeKernel->submit(0, false);
|
|
|
|
|
2018-04-05 21:12:28 +08:00
|
|
|
//device queue dsh is not changed
|
2017-12-21 07:45:38 +08:00
|
|
|
size_t usedDSHAfterSubmit = dshOfDevQueue->getUsed();
|
2018-04-05 21:12:28 +08:00
|
|
|
EXPECT_EQ(usedDSHAfterSubmit, usedDSHAfterSubmit);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
delete cmdComputeKernel;
|
|
|
|
delete parentKernel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-15 21:08:42 +08:00
|
|
|
HWCMDTEST_F(IGFX_GEN8_CORE, ParentKernelCommandQueueFixture, givenParentKernelWhenCommandIsSubmittedThenIndirectStateAndEMCleanupSectionIsSetup) {
|
2017-12-21 07:45:38 +08:00
|
|
|
if (device->getSupportedClVersion() >= 20) {
|
|
|
|
cl_queue_properties properties[3] = {0};
|
2018-07-30 20:13:37 +08:00
|
|
|
MockParentKernel *parentKernel = MockParentKernel::create(*context);
|
2017-12-21 07:45:38 +08:00
|
|
|
MockDeviceQueueHwWithCriticalSectionRelease<FamilyType> mockDevQueue(context, device, properties[0]);
|
|
|
|
parentKernel->createReflectionSurface();
|
|
|
|
context->setDefaultDeviceQueue(&mockDevQueue);
|
|
|
|
|
|
|
|
size_t heapSize = 20;
|
2018-04-05 21:12:28 +08:00
|
|
|
size_t dshSize = mockDevQueue.getDshBuffer()->getUnderlyingBufferSize();
|
|
|
|
|
|
|
|
IndirectHeap *dsh = nullptr, *ioh = nullptr, *ssh = nullptr;
|
|
|
|
pCmdQ->allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, dshSize, dsh);
|
|
|
|
pCmdQ->allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, heapSize, ioh);
|
|
|
|
pCmdQ->allocateHeapMemory(IndirectHeap::SURFACE_STATE, heapSize, ssh);
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
dsh->getSpace(mockDevQueue.getDshOffset());
|
|
|
|
|
2019-11-07 21:15:04 +08:00
|
|
|
auto cmdStreamAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties({device->getRootDeviceIndex(), 4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
2019-07-23 02:55:09 +08:00
|
|
|
auto blockedCommandData = std::make_unique<KernelOperation>(new LinearStream(cmdStreamAllocation),
|
|
|
|
*pCmdQ->getGpgpuCommandStreamReceiver().getInternalAllocationStorage());
|
2019-07-19 03:15:50 +08:00
|
|
|
blockedCommandData->setHeaps(dsh, ioh, ssh);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-12-17 17:43:19 +08:00
|
|
|
size_t minSizeSSHForEM = HardwareCommandsHelper<FamilyType>::getSshSizeForExecutionModel(*parentKernel);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
blockedCommandData->surfaceStateHeapSizeEM = minSizeSSHForEM;
|
2018-03-02 05:43:04 +08:00
|
|
|
PreemptionMode preemptionMode = device->getPreemptionMode();
|
2017-12-21 07:45:38 +08:00
|
|
|
std::vector<Surface *> surfaces;
|
2019-07-23 02:55:09 +08:00
|
|
|
auto *cmdComputeKernel = new CommandComputeKernel(*pCmdQ, blockedCommandData, surfaces, false, false, false, nullptr, preemptionMode, parentKernel, 1);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
cmdComputeKernel->submit(0, false);
|
|
|
|
|
|
|
|
EXPECT_TRUE(mockDevQueue.indirectStateSetup);
|
|
|
|
EXPECT_TRUE(mockDevQueue.cleanupSectionAdded);
|
|
|
|
|
|
|
|
delete cmdComputeKernel;
|
|
|
|
delete parentKernel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-15 21:08:42 +08:00
|
|
|
HWCMDTEST_F(IGFX_GEN8_CORE, ParentKernelCommandQueueFixture, givenBlockedParentKernelWithProfilingWhenCommandIsSubmittedThenEMCleanupSectionsSetsCompleteTimestamp) {
|
2017-12-21 07:45:38 +08:00
|
|
|
if (device->getSupportedClVersion() >= 20) {
|
|
|
|
cl_queue_properties properties[3] = {0};
|
2018-07-30 20:13:37 +08:00
|
|
|
MockParentKernel *parentKernel = MockParentKernel::create(*context);
|
2017-12-21 07:45:38 +08:00
|
|
|
MockDeviceQueueHwWithCriticalSectionRelease<FamilyType> mockDevQueue(context, device, properties[0]);
|
|
|
|
parentKernel->createReflectionSurface();
|
|
|
|
context->setDefaultDeviceQueue(&mockDevQueue);
|
|
|
|
|
|
|
|
size_t heapSize = 20;
|
2018-04-05 21:12:28 +08:00
|
|
|
size_t dshSize = mockDevQueue.getDshBuffer()->getUnderlyingBufferSize();
|
|
|
|
IndirectHeap *dsh = nullptr, *ioh = nullptr, *ssh = nullptr;
|
|
|
|
pCmdQ->allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, dshSize, dsh);
|
|
|
|
pCmdQ->allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, heapSize, ioh);
|
|
|
|
pCmdQ->allocateHeapMemory(IndirectHeap::SURFACE_STATE, heapSize, ssh);
|
2017-12-21 07:45:38 +08:00
|
|
|
dsh->getSpace(mockDevQueue.getDshOffset());
|
|
|
|
|
2019-11-07 21:15:04 +08:00
|
|
|
auto cmdStreamAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties({device->getRootDeviceIndex(), 4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
2019-07-23 02:55:09 +08:00
|
|
|
auto blockedCommandData = std::make_unique<KernelOperation>(new LinearStream(cmdStreamAllocation),
|
|
|
|
*pCmdQ->getGpgpuCommandStreamReceiver().getInternalAllocationStorage());
|
2019-07-19 03:15:50 +08:00
|
|
|
blockedCommandData->setHeaps(dsh, ioh, ssh);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-12-17 17:43:19 +08:00
|
|
|
size_t minSizeSSHForEM = HardwareCommandsHelper<FamilyType>::getSshSizeForExecutionModel(*parentKernel);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
blockedCommandData->surfaceStateHeapSizeEM = minSizeSSHForEM;
|
2018-03-02 05:43:04 +08:00
|
|
|
PreemptionMode preemptionMode = device->getPreemptionMode();
|
2017-12-21 07:45:38 +08:00
|
|
|
std::vector<Surface *> surfaces;
|
2019-07-23 02:55:09 +08:00
|
|
|
auto *cmdComputeKernel = new CommandComputeKernel(*pCmdQ, blockedCommandData, surfaces, false, false, false, nullptr, preemptionMode, parentKernel, 1);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-07-15 20:28:09 +08:00
|
|
|
auto timestamp = pCmdQ->getGpgpuCommandStreamReceiver().getEventTsAllocator()->getTag();
|
2018-12-21 20:05:21 +08:00
|
|
|
cmdComputeKernel->timestamp = timestamp;
|
2017-12-21 07:45:38 +08:00
|
|
|
cmdComputeKernel->submit(0, false);
|
|
|
|
|
|
|
|
EXPECT_TRUE(mockDevQueue.cleanupSectionAdded);
|
2019-02-08 17:27:48 +08:00
|
|
|
EXPECT_EQ(mockDevQueue.timestampAddedInCleanupSection, timestamp->tagForCpuAccess);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
delete cmdComputeKernel;
|
|
|
|
delete parentKernel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-15 21:08:42 +08:00
|
|
|
HWCMDTEST_F(IGFX_GEN8_CORE, ParentKernelCommandQueueFixture, givenParentKernelWhenCommandIsSubmittedThenSchedulerIsDispatched) {
|
2017-12-21 07:45:38 +08:00
|
|
|
if (device->getSupportedClVersion() >= 20) {
|
|
|
|
cl_queue_properties properties[3] = {0};
|
2018-07-30 20:13:37 +08:00
|
|
|
MockParentKernel *parentKernel = MockParentKernel::create(*context);
|
2017-12-21 07:45:38 +08:00
|
|
|
MockDeviceQueueHwWithCriticalSectionRelease<FamilyType> mockDevQueue(context, device, properties[0]);
|
|
|
|
parentKernel->createReflectionSurface();
|
|
|
|
context->setDefaultDeviceQueue(&mockDevQueue);
|
|
|
|
|
|
|
|
size_t heapSize = 20;
|
2018-04-05 21:12:28 +08:00
|
|
|
size_t dshSize = mockDevQueue.getDshBuffer()->getUnderlyingBufferSize();
|
|
|
|
|
|
|
|
IndirectHeap *dsh = nullptr, *ioh = nullptr, *ssh = nullptr;
|
|
|
|
pCmdQ->allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, dshSize, dsh);
|
|
|
|
pCmdQ->allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, heapSize, ioh);
|
|
|
|
pCmdQ->allocateHeapMemory(IndirectHeap::SURFACE_STATE, heapSize, ssh);
|
2017-12-21 07:45:38 +08:00
|
|
|
dsh->getSpace(mockDevQueue.getDshOffset());
|
|
|
|
|
2019-11-07 21:15:04 +08:00
|
|
|
auto cmdStreamAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties({device->getRootDeviceIndex(), 4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
2019-07-23 02:55:09 +08:00
|
|
|
auto blockedCommandData = std::make_unique<KernelOperation>(new LinearStream(cmdStreamAllocation),
|
|
|
|
*pCmdQ->getGpgpuCommandStreamReceiver().getInternalAllocationStorage());
|
2019-07-19 03:15:50 +08:00
|
|
|
blockedCommandData->setHeaps(dsh, ioh, ssh);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-12-17 17:43:19 +08:00
|
|
|
size_t minSizeSSHForEM = HardwareCommandsHelper<FamilyType>::getSshSizeForExecutionModel(*parentKernel);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
blockedCommandData->surfaceStateHeapSizeEM = minSizeSSHForEM;
|
2018-03-02 05:43:04 +08:00
|
|
|
PreemptionMode preemptionMode = device->getPreemptionMode();
|
2017-12-21 07:45:38 +08:00
|
|
|
std::vector<Surface *> surfaces;
|
2019-07-23 02:55:09 +08:00
|
|
|
auto *cmdComputeKernel = new CommandComputeKernel(*pCmdQ, blockedCommandData, surfaces, false, false, false, nullptr, preemptionMode, parentKernel, 1);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
cmdComputeKernel->submit(0, false);
|
|
|
|
|
|
|
|
EXPECT_TRUE(mockDevQueue.schedulerDispatched);
|
|
|
|
|
|
|
|
delete cmdComputeKernel;
|
|
|
|
delete parentKernel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-18 17:45:45 +08:00
|
|
|
HWCMDTEST_F(IGFX_GEN8_CORE, ParentKernelCommandQueueFixture, givenUsedCommandQueueHeapshenParentKernelIsSubmittedThenQueueHeapsAreNotUsed) {
|
2017-12-21 07:45:38 +08:00
|
|
|
if (device->getSupportedClVersion() >= 20) {
|
|
|
|
cl_queue_properties properties[3] = {0};
|
2018-07-30 20:13:37 +08:00
|
|
|
MockParentKernel *parentKernel = MockParentKernel::create(*context);
|
2017-12-21 07:45:38 +08:00
|
|
|
MockDeviceQueueHw<FamilyType> mockDevQueue(context, device, properties[0]);
|
|
|
|
parentKernel->createReflectionSurface();
|
|
|
|
context->setDefaultDeviceQueue(&mockDevQueue);
|
|
|
|
|
|
|
|
MockCommandQueue cmdQ(context, device, properties);
|
|
|
|
|
2019-12-17 17:43:19 +08:00
|
|
|
size_t minSizeSSHForEM = HardwareCommandsHelper<FamilyType>::getSshSizeForExecutionModel(*parentKernel);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
size_t heapSize = 20;
|
|
|
|
|
2018-04-05 21:12:28 +08:00
|
|
|
size_t dshSize = mockDevQueue.getDshBuffer()->getUnderlyingBufferSize();
|
|
|
|
IndirectHeap *dsh = nullptr, *ioh = nullptr, *ssh = nullptr;
|
|
|
|
pCmdQ->allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, dshSize, dsh);
|
|
|
|
pCmdQ->allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, heapSize, ioh);
|
|
|
|
pCmdQ->allocateHeapMemory(IndirectHeap::SURFACE_STATE, heapSize, ssh);
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
dsh->getSpace(mockDevQueue.getDshOffset());
|
|
|
|
|
2018-04-05 21:12:28 +08:00
|
|
|
auto &queueSsh = cmdQ.getIndirectHeap(IndirectHeap::SURFACE_STATE, 100);
|
|
|
|
auto &queueDsh = cmdQ.getIndirectHeap(IndirectHeap::DYNAMIC_STATE, 100);
|
|
|
|
auto &queueIoh = cmdQ.getIndirectHeap(IndirectHeap::INDIRECT_OBJECT, 100);
|
|
|
|
|
|
|
|
size_t usedSize = 4u;
|
|
|
|
|
|
|
|
queueSsh.getSpace(usedSize);
|
|
|
|
queueDsh.getSpace(usedSize);
|
|
|
|
queueIoh.getSpace(usedSize);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-11-07 21:15:04 +08:00
|
|
|
auto cmdStreamAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties({device->getRootDeviceIndex(), 4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
2019-07-23 02:55:09 +08:00
|
|
|
auto blockedCommandData = std::make_unique<KernelOperation>(new LinearStream(cmdStreamAllocation),
|
|
|
|
*pCmdQ->getGpgpuCommandStreamReceiver().getInternalAllocationStorage());
|
2019-07-19 03:15:50 +08:00
|
|
|
blockedCommandData->setHeaps(dsh, ioh, ssh);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
blockedCommandData->surfaceStateHeapSizeEM = minSizeSSHForEM;
|
2018-03-02 05:43:04 +08:00
|
|
|
PreemptionMode preemptionMode = device->getPreemptionMode();
|
2017-12-21 07:45:38 +08:00
|
|
|
std::vector<Surface *> surfaces;
|
2019-07-23 02:55:09 +08:00
|
|
|
auto *cmdComputeKernel = new CommandComputeKernel(cmdQ, blockedCommandData, surfaces, false, false, false, nullptr, preemptionMode, parentKernel, 1);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
cmdComputeKernel->submit(0, false);
|
|
|
|
|
2018-04-05 21:12:28 +08:00
|
|
|
EXPECT_FALSE(cmdQ.releaseIndirectHeapCalled);
|
|
|
|
EXPECT_EQ(usedSize, queueDsh.getUsed());
|
|
|
|
EXPECT_EQ(usedSize, queueIoh.getUsed());
|
|
|
|
EXPECT_EQ(usedSize, queueSsh.getUsed());
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
delete cmdComputeKernel;
|
|
|
|
delete parentKernel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-18 17:45:45 +08:00
|
|
|
HWCMDTEST_F(IGFX_GEN8_CORE, ParentKernelCommandQueueFixture, givenNotUsedSSHWhenParentKernelIsSubmittedThenExistingSSHIsUsed) {
|
2017-12-21 07:45:38 +08:00
|
|
|
if (device->getSupportedClVersion() >= 20) {
|
|
|
|
cl_queue_properties properties[3] = {0};
|
2018-07-30 20:13:37 +08:00
|
|
|
MockParentKernel *parentKernel = MockParentKernel::create(*context);
|
2017-12-21 07:45:38 +08:00
|
|
|
MockDeviceQueueHw<FamilyType> mockDevQueue(context, device, properties[0]);
|
|
|
|
parentKernel->createReflectionSurface();
|
|
|
|
context->setDefaultDeviceQueue(&mockDevQueue);
|
|
|
|
|
2019-12-17 17:43:19 +08:00
|
|
|
size_t minSizeSSHForEM = HardwareCommandsHelper<FamilyType>::getSshSizeForExecutionModel(*parentKernel);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
size_t heapSize = 20;
|
|
|
|
|
2018-04-05 21:12:28 +08:00
|
|
|
size_t dshSize = mockDevQueue.getDshBuffer()->getUnderlyingBufferSize();
|
2017-12-21 07:45:38 +08:00
|
|
|
size_t sshSize = 1000;
|
2018-04-05 21:12:28 +08:00
|
|
|
IndirectHeap *dsh = nullptr, *ioh = nullptr, *ssh = nullptr;
|
|
|
|
pCmdQ->allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, dshSize, dsh);
|
|
|
|
pCmdQ->allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, heapSize, ioh);
|
|
|
|
pCmdQ->allocateHeapMemory(IndirectHeap::SURFACE_STATE, sshSize, ssh);
|
|
|
|
dsh->getSpace(mockDevQueue.getDshOffset());
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
EXPECT_EQ(0u, ssh->getUsed());
|
|
|
|
|
|
|
|
pCmdQ->getIndirectHeap(IndirectHeap::SURFACE_STATE, sshSize);
|
|
|
|
|
2018-04-16 22:39:00 +08:00
|
|
|
void *sshBuffer = pCmdQ->getIndirectHeap(IndirectHeap::SURFACE_STATE, 0u).getCpuBase();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-11-07 21:15:04 +08:00
|
|
|
auto cmdStreamAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties({device->getRootDeviceIndex(), 4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
2019-07-23 02:55:09 +08:00
|
|
|
auto blockedCommandData = std::make_unique<KernelOperation>(new LinearStream(cmdStreamAllocation),
|
|
|
|
*pCmdQ->getGpgpuCommandStreamReceiver().getInternalAllocationStorage());
|
2019-07-19 03:15:50 +08:00
|
|
|
blockedCommandData->setHeaps(dsh, ioh, ssh);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
blockedCommandData->surfaceStateHeapSizeEM = minSizeSSHForEM;
|
2018-03-02 05:43:04 +08:00
|
|
|
PreemptionMode preemptionMode = device->getPreemptionMode();
|
2017-12-21 07:45:38 +08:00
|
|
|
std::vector<Surface *> surfaces;
|
2019-07-23 02:55:09 +08:00
|
|
|
auto *cmdComputeKernel = new CommandComputeKernel(*pCmdQ, blockedCommandData, surfaces, false, false, false, nullptr, preemptionMode, parentKernel, 1);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
cmdComputeKernel->submit(0, false);
|
|
|
|
|
2018-04-16 22:39:00 +08:00
|
|
|
void *newSshBuffer = pCmdQ->getIndirectHeap(IndirectHeap::SURFACE_STATE, 0u).getCpuBase();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
EXPECT_EQ(sshBuffer, newSshBuffer);
|
|
|
|
|
|
|
|
delete cmdComputeKernel;
|
|
|
|
delete parentKernel;
|
|
|
|
}
|
|
|
|
}
|
2018-04-05 21:12:28 +08:00
|
|
|
|
2018-05-18 17:45:45 +08:00
|
|
|
HWCMDTEST_F(IGFX_GEN8_CORE, ParentKernelCommandQueueFixture, givenBlockedCommandQueueWhenDispatchWalkerIsCalledThenHeapsHaveProperSizes) {
|
2018-04-05 21:12:28 +08:00
|
|
|
if (device->getSupportedClVersion() >= 20) {
|
|
|
|
cl_queue_properties properties[3] = {0};
|
2018-07-30 20:13:37 +08:00
|
|
|
std::unique_ptr<MockParentKernel> parentKernel(MockParentKernel::create(*context));
|
2018-04-05 21:12:28 +08:00
|
|
|
|
|
|
|
MockDeviceQueueHw<FamilyType> mockDevQueue(context, device, properties[0]);
|
|
|
|
parentKernel->createReflectionSurface();
|
|
|
|
context->setDefaultDeviceQueue(&mockDevQueue);
|
|
|
|
|
2019-07-19 03:15:50 +08:00
|
|
|
auto blockedCommandsData = createBlockedCommandsData(*pCmdQ);
|
2018-04-05 21:12:28 +08:00
|
|
|
const size_t globalOffsets[3] = {0, 0, 0};
|
|
|
|
const size_t workItems[3] = {1, 1, 1};
|
|
|
|
|
2018-08-16 21:47:25 +08:00
|
|
|
DispatchInfo dispatchInfo(parentKernel.get(), 1, workItems, nullptr, globalOffsets);
|
|
|
|
MultiDispatchInfo multiDispatchInfo(parentKernel.get());
|
|
|
|
multiDispatchInfo.push(dispatchInfo);
|
2018-09-27 21:22:36 +08:00
|
|
|
HardwareInterface<FamilyType>::dispatchWalker(
|
2018-08-16 21:47:25 +08:00
|
|
|
*pCmdQ,
|
|
|
|
multiDispatchInfo,
|
2019-01-25 17:20:32 +08:00
|
|
|
CsrDependencies(),
|
2019-07-19 03:15:50 +08:00
|
|
|
blockedCommandsData.get(),
|
2018-08-16 21:47:25 +08:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2018-08-24 14:48:59 +08:00
|
|
|
nullptr,
|
2018-09-11 15:43:06 +08:00
|
|
|
nullptr,
|
2019-07-19 03:15:50 +08:00
|
|
|
CL_COMMAND_NDRANGE_KERNEL);
|
2018-04-05 21:12:28 +08:00
|
|
|
|
|
|
|
EXPECT_NE(nullptr, blockedCommandsData);
|
|
|
|
EXPECT_EQ(blockedCommandsData->dsh->getMaxAvailableSpace(), mockDevQueue.getDshBuffer()->getUnderlyingBufferSize());
|
|
|
|
EXPECT_EQ(blockedCommandsData->dsh, blockedCommandsData->ioh);
|
|
|
|
|
|
|
|
EXPECT_NE(nullptr, blockedCommandsData->dsh->getGraphicsAllocation());
|
|
|
|
EXPECT_NE(nullptr, blockedCommandsData->ioh->getGraphicsAllocation());
|
|
|
|
EXPECT_NE(nullptr, blockedCommandsData->ssh->getGraphicsAllocation());
|
|
|
|
EXPECT_EQ(blockedCommandsData->dsh->getGraphicsAllocation(), blockedCommandsData->ioh->getGraphicsAllocation());
|
|
|
|
}
|
|
|
|
}
|