mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-20 08:53:55 +08:00
Create GraphicsAllocation during dispatch when queue is blocked
Change-Id: I8a6f9e14ff57e7ed2920260af291317805f4df13 Signed-off-by: Maciej Dziuban <maciej.dziuban@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
3e2a2ec191
commit
90e970cee6
@@ -7,6 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "runtime/command_queue/hardware_interface.h"
|
||||
#include "runtime/memory_manager/internal_allocation_storage.h"
|
||||
#include "runtime/helpers/kernel_commands.h"
|
||||
#include "runtime/helpers/task_information.h"
|
||||
|
||||
@@ -50,8 +51,23 @@ void HardwareInterface<GfxFamily>::dispatchWalker(
|
||||
// Allocate command stream and indirect heaps
|
||||
if (blockQueue) {
|
||||
using KCH = KernelCommandsHelper<GfxFamily>;
|
||||
commandStream = new LinearStream(alignedMalloc(MemoryConstants::pageSize, MemoryConstants::pageSize),
|
||||
MemoryConstants::pageSize);
|
||||
|
||||
constexpr static auto allocationSize = MemoryConstants::pageSize64k;
|
||||
constexpr static auto allocationType = GraphicsAllocation::AllocationType::COMMAND_BUFFER;
|
||||
auto commandStreamAllocation = commandQueue
|
||||
.getCommandStreamReceiver()
|
||||
.getInternalAllocationStorage()
|
||||
->obtainReusableAllocation(allocationSize, allocationType)
|
||||
.release();
|
||||
if (commandStreamAllocation == nullptr) {
|
||||
const AllocationProperties commandStreamAllocationProperties{allocationSize, allocationType};
|
||||
auto memoryManager = commandQueue.getCommandStreamReceiver().getMemoryManager();
|
||||
commandStreamAllocation = memoryManager->allocateGraphicsMemoryWithProperties(commandStreamAllocationProperties);
|
||||
}
|
||||
UNRECOVERABLE_IF(commandStreamAllocation == nullptr);
|
||||
commandStream = new LinearStream(commandStreamAllocation);
|
||||
commandStream->overrideMaxSize(allocationSize - CSRequirements::csOverfetchSize);
|
||||
|
||||
if (parentKernel) {
|
||||
uint32_t colorCalcSize = commandQueue.getContext().getDefaultDeviceQueue()->colorCalcStateSize;
|
||||
|
||||
|
||||
@@ -31,7 +31,8 @@ KernelOperation::~KernelOperation() {
|
||||
storageForAllocations.storeAllocation(std::unique_ptr<GraphicsAllocation>(ioh->getGraphicsAllocation()), REUSABLE_ALLOCATION);
|
||||
}
|
||||
storageForAllocations.storeAllocation(std::unique_ptr<GraphicsAllocation>(ssh->getGraphicsAllocation()), REUSABLE_ALLOCATION);
|
||||
alignedFree(commandStream->getCpuBase());
|
||||
|
||||
storageForAllocations.storeAllocation(std::unique_ptr<GraphicsAllocation>(commandStream->getGraphicsAllocation()), REUSABLE_ALLOCATION);
|
||||
}
|
||||
|
||||
CommandMapUnmap::CommandMapUnmap(MapOperationType op, MemObj &memObj, MemObjSizeArray ©Size, MemObjOffsetArray ©Offset, bool readOnly,
|
||||
@@ -141,14 +142,6 @@ CompletionStamp &CommandComputeKernel::submit(uint32_t taskLevel, bool terminate
|
||||
devQueue->acquireEMCriticalSection();
|
||||
}
|
||||
|
||||
auto &commandStream = *kernelOperation->commandStream;
|
||||
size_t commandsSize = commandStream.getUsed();
|
||||
auto &queueCommandStream = commandQueue.getCS(commandStream.getUsed());
|
||||
size_t offset = queueCommandStream.getUsed();
|
||||
void *pDst = queueCommandStream.getSpace(commandsSize);
|
||||
//transfer the memory to commandStream of the queue.
|
||||
memcpy_s(pDst, commandsSize, commandStream.getCpuBase(), commandsSize);
|
||||
|
||||
IndirectHeap *dsh = kernelOperation->dsh.get();
|
||||
IndirectHeap *ioh = kernelOperation->ioh.get();
|
||||
IndirectHeap *ssh = kernelOperation->ssh.get();
|
||||
@@ -224,8 +217,8 @@ CompletionStamp &CommandComputeKernel::submit(uint32_t taskLevel, bool terminate
|
||||
|
||||
gtpinNotifyPreFlushTask(&commandQueue);
|
||||
|
||||
completionStamp = commandStreamReceiver.flushTask(queueCommandStream,
|
||||
offset,
|
||||
completionStamp = commandStreamReceiver.flushTask(*kernelOperation->commandStream,
|
||||
0,
|
||||
*dsh,
|
||||
*ioh,
|
||||
*ssh,
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "runtime/helpers/aligned_memory.h"
|
||||
#include "runtime/helpers/kernel_commands.h"
|
||||
#include "runtime/helpers/task_information.h"
|
||||
#include "runtime/memory_manager/internal_allocation_storage.h"
|
||||
#include "runtime/utilities/tag_allocator.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "unit_tests/command_queue/command_queue_fixture.h"
|
||||
@@ -715,11 +716,13 @@ HWTEST_F(DispatchWalkerTest, dispatchWalkerShouldGetRequiredHeapSizesFromKernelW
|
||||
|
||||
Vec3<size_t> localWorkgroupSize(workGroupSize);
|
||||
|
||||
auto expectedSizeCS = MemoryConstants::pageSize; //can get estimated more precisely
|
||||
auto expectedSizeCSAllocation = MemoryConstants::pageSize64k;
|
||||
auto expectedSizeCS = MemoryConstants::pageSize64k - CSRequirements::csOverfetchSize;
|
||||
auto expectedSizeDSH = KernelCommandsHelper<FamilyType>::getSizeRequiredDSH(kernel);
|
||||
auto expectedSizeIOH = KernelCommandsHelper<FamilyType>::getSizeRequiredIOH(kernel, Math::computeTotalElementsCount(localWorkgroupSize));
|
||||
auto expectedSizeSSH = KernelCommandsHelper<FamilyType>::getSizeRequiredSSH(kernel);
|
||||
|
||||
EXPECT_EQ(expectedSizeCSAllocation, blockedCommandsData->commandStream->getGraphicsAllocation()->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(expectedSizeCS, blockedCommandsData->commandStream->getMaxAvailableSpace());
|
||||
EXPECT_LE(expectedSizeDSH, blockedCommandsData->dsh->getMaxAvailableSpace());
|
||||
EXPECT_LE(expectedSizeIOH, blockedCommandsData->ioh->getMaxAvailableSpace());
|
||||
@@ -751,11 +754,13 @@ HWTEST_F(DispatchWalkerTest, dispatchWalkerShouldGetRequiredHeapSizesFromMdiWhen
|
||||
pDevice->getPreemptionMode(),
|
||||
blockQueue);
|
||||
|
||||
auto expectedSizeCS = MemoryConstants::pageSize; //can get estimated more precisely
|
||||
auto expectedSizeCSAllocation = MemoryConstants::pageSize64k;
|
||||
auto expectedSizeCS = MemoryConstants::pageSize64k - CSRequirements::csOverfetchSize;
|
||||
auto expectedSizeDSH = KernelCommandsHelper<FamilyType>::getTotalSizeRequiredDSH(multiDispatchInfo);
|
||||
auto expectedSizeIOH = KernelCommandsHelper<FamilyType>::getTotalSizeRequiredIOH(multiDispatchInfo);
|
||||
auto expectedSizeSSH = KernelCommandsHelper<FamilyType>::getTotalSizeRequiredSSH(multiDispatchInfo);
|
||||
|
||||
EXPECT_EQ(expectedSizeCSAllocation, blockedCommandsData->commandStream->getGraphicsAllocation()->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(expectedSizeCS, blockedCommandsData->commandStream->getMaxAvailableSpace());
|
||||
EXPECT_LE(expectedSizeDSH, blockedCommandsData->dsh->getMaxAvailableSpace());
|
||||
EXPECT_LE(expectedSizeIOH, blockedCommandsData->ioh->getMaxAvailableSpace());
|
||||
@@ -764,6 +769,62 @@ HWTEST_F(DispatchWalkerTest, dispatchWalkerShouldGetRequiredHeapSizesFromMdiWhen
|
||||
delete blockedCommandsData;
|
||||
}
|
||||
|
||||
HWTEST_F(DispatchWalkerTest, givenBlockedQueueWhenDispatchWalkerIsCalledThenCommandStreamHasGpuAddress) {
|
||||
MockKernel kernel(program.get(), kernelInfo, *pDevice);
|
||||
ASSERT_EQ(CL_SUCCESS, kernel.initialize());
|
||||
MockMultiDispatchInfo multiDispatchInfo(&kernel);
|
||||
|
||||
const auto blockQueue = true;
|
||||
KernelOperation *blockedCommandsData = nullptr;
|
||||
HardwareInterface<FamilyType>::dispatchWalker(
|
||||
*pCmdQ,
|
||||
multiDispatchInfo,
|
||||
CsrDependencies(),
|
||||
&blockedCommandsData,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
pDevice->getPreemptionMode(),
|
||||
blockQueue);
|
||||
|
||||
EXPECT_NE(nullptr, blockedCommandsData->commandStream->getGraphicsAllocation());
|
||||
EXPECT_NE(0ull, blockedCommandsData->commandStream->getGraphicsAllocation()->getGpuAddress());
|
||||
|
||||
delete blockedCommandsData;
|
||||
}
|
||||
|
||||
HWTEST_F(DispatchWalkerTest, givenThereAreAllocationsForReuseWhenDispatchWalkerIsCalledThenCommandStreamObtainsReusableAllocation) {
|
||||
MockKernel kernel(program.get(), kernelInfo, *pDevice);
|
||||
ASSERT_EQ(CL_SUCCESS, kernel.initialize());
|
||||
MockMultiDispatchInfo multiDispatchInfo(&kernel);
|
||||
|
||||
auto &csr = pCmdQ->getCommandStreamReceiver();
|
||||
auto allocation = csr.getMemoryManager()->allocateGraphicsMemoryWithProperties({MemoryConstants::pageSize64k + CSRequirements::csOverfetchSize,
|
||||
GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
||||
csr.getInternalAllocationStorage()->storeAllocation(std::unique_ptr<GraphicsAllocation>{allocation}, REUSABLE_ALLOCATION);
|
||||
ASSERT_FALSE(csr.getInternalAllocationStorage()->getAllocationsForReuse().peekIsEmpty());
|
||||
|
||||
const auto blockQueue = true;
|
||||
KernelOperation *blockedCommandsData = nullptr;
|
||||
HardwareInterface<FamilyType>::dispatchWalker(
|
||||
*pCmdQ,
|
||||
multiDispatchInfo,
|
||||
CsrDependencies(),
|
||||
&blockedCommandsData,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
pDevice->getPreemptionMode(),
|
||||
blockQueue);
|
||||
|
||||
EXPECT_TRUE(csr.getInternalAllocationStorage()->getAllocationsForReuse().peekIsEmpty());
|
||||
EXPECT_EQ(allocation, blockedCommandsData->commandStream->getGraphicsAllocation());
|
||||
|
||||
delete blockedCommandsData;
|
||||
}
|
||||
|
||||
HWTEST_F(DispatchWalkerTest, dispatchWalkerWithMultipleDispatchInfo) {
|
||||
MockKernel kernel1(program.get(), kernelInfo, *pDevice);
|
||||
ASSERT_EQ(CL_SUCCESS, kernel1.initialize());
|
||||
|
||||
@@ -957,7 +957,6 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, GivenBlockedKernelRequiringDCFlush
|
||||
auto buffer = Buffer::create(&ctx, CL_MEM_USE_HOST_PTR, sizeof(tempBuffer), tempBuffer, retVal);
|
||||
|
||||
auto &commandStreamCSR = commandStreamReceiver.getCS();
|
||||
auto &commandStreamTask = commandQueue.getCS(1024);
|
||||
|
||||
commandQueue.enqueueReadBuffer(buffer, CL_FALSE, 0, sizeof(tempBuffer), dstBuffer, 1, &blockingEvent, 0);
|
||||
|
||||
@@ -966,6 +965,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, GivenBlockedKernelRequiringDCFlush
|
||||
|
||||
// Unblock Event
|
||||
mockEvent.setStatus(CL_COMPLETE);
|
||||
auto &commandStreamTask = *commandStreamReceiver.lastFlushedCommandStream;
|
||||
|
||||
cmdList.clear();
|
||||
// Parse command list
|
||||
|
||||
@@ -42,7 +42,6 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, GivenBlockedKernelNotRequiringDCFl
|
||||
auto buffer = Buffer::create(&ctx, CL_MEM_USE_HOST_PTR, sizeof(tempBuffer), tempBuffer, retVal);
|
||||
|
||||
auto &commandStreamCSR = commandStreamReceiver.getCS();
|
||||
auto &commandStreamTask = commandQueue.getCS(1024);
|
||||
|
||||
commandQueue.enqueueWriteBuffer(buffer, CL_FALSE, 0, sizeof(tempBuffer), dstBuffer, 1, &blockingEvent, 0);
|
||||
|
||||
@@ -51,6 +50,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, GivenBlockedKernelNotRequiringDCFl
|
||||
|
||||
// Unblock Event
|
||||
mockEvent.setStatus(CL_COMPLETE);
|
||||
auto &commandStreamTask = *commandStreamReceiver.lastFlushedCommandStream;
|
||||
|
||||
cmdList.clear();
|
||||
// Parse command list
|
||||
|
||||
@@ -1437,7 +1437,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, GivenBlockedKernelWhenItIsUnblocke
|
||||
|
||||
std::unique_ptr<MockKernel> pKernel(MockKernel::create(*pDevice, mockProgram.get(), numGrfRequired));
|
||||
auto event = std::make_unique<MockEvent<Event>>(pCmdQ.get(), CL_COMMAND_MARKER, 0, 0);
|
||||
auto cmdStream = new LinearStream(alignedMalloc(4096, 4096), 4096);
|
||||
auto cmdStream = new LinearStream(pDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties({4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER}));
|
||||
|
||||
IndirectHeap *dsh = nullptr, *ioh = nullptr, *ssh = nullptr;
|
||||
pCmdQ->allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, 4096u, dsh);
|
||||
|
||||
@@ -85,7 +85,7 @@ TEST(EventBuilder, givenVirtualEventWithCommandThenFinalizeAddChild) {
|
||||
cmdQ.allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, 1, ih1);
|
||||
cmdQ.allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, 1, ih2);
|
||||
cmdQ.allocateHeapMemory(IndirectHeap::SURFACE_STATE, 1, ih3);
|
||||
auto cmdStream = new LinearStream(alignedMalloc(1, 1), 1);
|
||||
auto cmdStream = new LinearStream(device->getMemoryManager()->allocateGraphicsMemoryWithProperties({1, GraphicsAllocation::AllocationType::COMMAND_BUFFER}));
|
||||
|
||||
std::vector<Surface *> surfaces;
|
||||
auto kernelOperation = new KernelOperation(std::unique_ptr<LinearStream>(cmdStream), UniqueIH(ih1), UniqueIH(ih2), UniqueIH(ih3),
|
||||
@@ -135,7 +135,7 @@ TEST(EventBuilder, givenVirtualEventWithSubmittedCommandAsParentThenFinalizeNotA
|
||||
cmdQ.allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, 1, ih1);
|
||||
cmdQ.allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, 1, ih2);
|
||||
cmdQ.allocateHeapMemory(IndirectHeap::SURFACE_STATE, 1, ih3);
|
||||
auto cmdStream = new LinearStream(alignedMalloc(1, 1), 1);
|
||||
auto cmdStream = new LinearStream(device->getMemoryManager()->allocateGraphicsMemoryWithProperties({4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER}));
|
||||
|
||||
std::vector<Surface *> surfaces;
|
||||
auto kernelOperation = new KernelOperation(std::unique_ptr<LinearStream>(cmdStream), UniqueIH(ih1), UniqueIH(ih2), UniqueIH(ih3),
|
||||
|
||||
@@ -442,7 +442,7 @@ TEST_F(InternalsEventTest, processBlockedCommandsKernelOperation) {
|
||||
CommandQueue cmdQ(mockContext, pDevice, nullptr);
|
||||
MockEvent<Event> event(&cmdQ, CL_COMMAND_NDRANGE_KERNEL, 0, 0);
|
||||
|
||||
auto cmdStream = new LinearStream(alignedMalloc(4096, 4096), 4096);
|
||||
auto cmdStream = new LinearStream(pDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties({4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER}));
|
||||
IndirectHeap *dsh = nullptr, *ioh = nullptr, *ssh = nullptr;
|
||||
cmdQ.allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, 4096u, dsh);
|
||||
cmdQ.allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, 4096u, ioh);
|
||||
@@ -481,7 +481,7 @@ TEST_F(InternalsEventTest, processBlockedCommandsAbortKernelOperation) {
|
||||
CommandQueue cmdQ(mockContext, pDevice, nullptr);
|
||||
MockEvent<Event> event(&cmdQ, CL_COMMAND_NDRANGE_KERNEL, 0, 0);
|
||||
|
||||
auto cmdStream = new LinearStream(alignedMalloc(4096, 4096), 4096);
|
||||
auto cmdStream = new LinearStream(pDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties({4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER}));
|
||||
IndirectHeap *dsh = nullptr, *ioh = nullptr, *ssh = nullptr;
|
||||
cmdQ.allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, 4096u, dsh);
|
||||
cmdQ.allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, 4096u, ioh);
|
||||
@@ -516,7 +516,7 @@ TEST_F(InternalsEventTest, givenBlockedKernelWithPrintfWhenSubmittedThenPrintOut
|
||||
CommandQueue cmdQ(mockContext, pDevice, nullptr);
|
||||
MockEvent<Event> event(&cmdQ, CL_COMMAND_NDRANGE_KERNEL, 0, 0);
|
||||
|
||||
auto cmdStream = new LinearStream(alignedMalloc(4096, 4096), 4096);
|
||||
auto cmdStream = new LinearStream(pDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties({4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER}));
|
||||
IndirectHeap *dsh = nullptr, *ioh = nullptr, *ssh = nullptr;
|
||||
cmdQ.allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, 4096u, dsh);
|
||||
cmdQ.allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, 4096u, ioh);
|
||||
@@ -886,7 +886,7 @@ HWTEST_F(EventTest, givenVirtualEventWhenCommandSubmittedThenLockCSROccurs) {
|
||||
pCmdQ->allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, 1, ih1);
|
||||
pCmdQ->allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, 1, ih2);
|
||||
pCmdQ->allocateHeapMemory(IndirectHeap::SURFACE_STATE, 1, ih3);
|
||||
auto cmdStream = new LinearStream(alignedMalloc(1, 1), 1);
|
||||
auto cmdStream = new LinearStream(pDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties({4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER}));
|
||||
|
||||
std::vector<Surface *> surfaces;
|
||||
auto kernelOperation = new KernelOperation(std::unique_ptr<LinearStream>(cmdStream), UniqueIH(ih1), UniqueIH(ih2), UniqueIH(ih3),
|
||||
@@ -1511,7 +1511,7 @@ HWTEST_F(InternalsEventTest, givenAbortedCommandWhenSubmitCalledThenDontUpdateFl
|
||||
MockKernelWithInternals mockKernelWithInternals(*pDevice);
|
||||
auto pKernel = mockKernelWithInternals.mockKernel;
|
||||
|
||||
auto cmdStream = new LinearStream(alignedMalloc(4096, 4096), 4096);
|
||||
auto cmdStream = new LinearStream(pDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties({4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER}));
|
||||
IndirectHeap *dsh = nullptr, *ioh = nullptr, *ssh = nullptr;
|
||||
pCmdQ->allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, 4096u, dsh);
|
||||
pCmdQ->allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, 4096u, ioh);
|
||||
|
||||
@@ -736,7 +736,7 @@ TEST_F(MockEventTests, virtualEventObtainedFromReturnedEventCannotBeReleasedByIs
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
|
||||
TEST_F(MockEventTests, userEventsDoesntChangeCommandStreamWhileEnqueueButDoesAfterSignaling) {
|
||||
TEST_F(MockEventTests, givenBlockedQueueThenCommandStreamDoesNotChangeWhileEnqueueAndAfterSignaling) {
|
||||
uEvent = make_releaseable<UserEvent>(context);
|
||||
cl_event eventWaitList[] = {uEvent.get()};
|
||||
int sizeOfWaitList = sizeof(eventWaitList) / sizeof(cl_event);
|
||||
@@ -761,7 +761,7 @@ TEST_F(MockEventTests, userEventsDoesntChangeCommandStreamWhileEnqueueButDoesAft
|
||||
retVal |= clFinish(pCmdQ);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_NE(used3, used);
|
||||
EXPECT_EQ(used3, used);
|
||||
|
||||
retVal = clReleaseEvent(retEvent);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
@@ -97,7 +97,8 @@ HWTEST_F(ParentKernelCommandQueueFixture, givenLockedEMcritcalSectionWhenParentK
|
||||
|
||||
size_t minSizeSSHForEM = KernelCommandsHelper<FamilyType>::template getSizeRequiredForExecutionModel<IndirectHeap::SURFACE_STATE>(*parentKernel);
|
||||
|
||||
KernelOperation *blockedCommandData = new KernelOperation(std::unique_ptr<LinearStream>(new LinearStream()),
|
||||
auto cmdStreamAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties({4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
||||
KernelOperation *blockedCommandData = new KernelOperation(std::unique_ptr<LinearStream>(new LinearStream(cmdStreamAllocation)),
|
||||
std::unique_ptr<IndirectHeap>(dsh),
|
||||
std::unique_ptr<IndirectHeap>(ioh),
|
||||
std::unique_ptr<IndirectHeap>(ssh),
|
||||
@@ -156,7 +157,8 @@ HWTEST_F(ParentKernelCommandQueueFixture, givenParentKernelWhenCommandIsSubmitte
|
||||
uint32_t colorCalcSizeDevQueue = DeviceQueue::colorCalcStateSize;
|
||||
EXPECT_EQ(colorCalcSizeDevQueue, usedDSHBeforeSubmit);
|
||||
|
||||
KernelOperation *blockedCommandData = new KernelOperation(std::unique_ptr<LinearStream>(new LinearStream()),
|
||||
auto cmdStreamAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties({4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
||||
KernelOperation *blockedCommandData = new KernelOperation(std::unique_ptr<LinearStream>(new LinearStream(cmdStreamAllocation)),
|
||||
std::unique_ptr<IndirectHeap>(dsh),
|
||||
std::unique_ptr<IndirectHeap>(ioh),
|
||||
std::unique_ptr<IndirectHeap>(ssh),
|
||||
@@ -198,7 +200,8 @@ HWTEST_F(ParentKernelCommandQueueFixture, givenParentKernelWhenCommandIsSubmitte
|
||||
|
||||
dsh->getSpace(mockDevQueue.getDshOffset());
|
||||
|
||||
KernelOperation *blockedCommandData = new KernelOperation(std::unique_ptr<LinearStream>(new LinearStream()),
|
||||
auto cmdStreamAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties({4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
||||
KernelOperation *blockedCommandData = new KernelOperation(std::unique_ptr<LinearStream>(new LinearStream(cmdStreamAllocation)),
|
||||
std::unique_ptr<IndirectHeap>(dsh),
|
||||
std::unique_ptr<IndirectHeap>(ioh),
|
||||
std::unique_ptr<IndirectHeap>(ssh),
|
||||
@@ -237,7 +240,8 @@ HWTEST_F(ParentKernelCommandQueueFixture, givenBlockedParentKernelWithProfilingW
|
||||
pCmdQ->allocateHeapMemory(IndirectHeap::SURFACE_STATE, heapSize, ssh);
|
||||
dsh->getSpace(mockDevQueue.getDshOffset());
|
||||
|
||||
KernelOperation *blockedCommandData = new KernelOperation(std::unique_ptr<LinearStream>(new LinearStream()),
|
||||
auto cmdStreamAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties({4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
||||
KernelOperation *blockedCommandData = new KernelOperation(std::unique_ptr<LinearStream>(new LinearStream(cmdStreamAllocation)),
|
||||
std::unique_ptr<IndirectHeap>(dsh),
|
||||
std::unique_ptr<IndirectHeap>(ioh),
|
||||
std::unique_ptr<IndirectHeap>(ssh),
|
||||
@@ -279,7 +283,8 @@ HWTEST_F(ParentKernelCommandQueueFixture, givenParentKernelWhenCommandIsSubmitte
|
||||
pCmdQ->allocateHeapMemory(IndirectHeap::SURFACE_STATE, heapSize, ssh);
|
||||
dsh->getSpace(mockDevQueue.getDshOffset());
|
||||
|
||||
KernelOperation *blockedCommandData = new KernelOperation(std::unique_ptr<LinearStream>(new LinearStream()),
|
||||
auto cmdStreamAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties({4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
||||
KernelOperation *blockedCommandData = new KernelOperation(std::unique_ptr<LinearStream>(new LinearStream(cmdStreamAllocation)),
|
||||
std::unique_ptr<IndirectHeap>(dsh),
|
||||
std::unique_ptr<IndirectHeap>(ioh),
|
||||
std::unique_ptr<IndirectHeap>(ssh),
|
||||
@@ -333,7 +338,8 @@ HWCMDTEST_F(IGFX_GEN8_CORE, ParentKernelCommandQueueFixture, givenUsedCommandQue
|
||||
queueDsh.getSpace(usedSize);
|
||||
queueIoh.getSpace(usedSize);
|
||||
|
||||
KernelOperation *blockedCommandData = new KernelOperation(std::unique_ptr<LinearStream>(new LinearStream()),
|
||||
auto cmdStreamAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties({4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
||||
KernelOperation *blockedCommandData = new KernelOperation(std::unique_ptr<LinearStream>(new LinearStream(cmdStreamAllocation)),
|
||||
std::unique_ptr<IndirectHeap>(dsh),
|
||||
std::unique_ptr<IndirectHeap>(ioh),
|
||||
std::unique_ptr<IndirectHeap>(ssh),
|
||||
@@ -382,7 +388,8 @@ HWCMDTEST_F(IGFX_GEN8_CORE, ParentKernelCommandQueueFixture, givenNotUsedSSHWhen
|
||||
|
||||
void *sshBuffer = pCmdQ->getIndirectHeap(IndirectHeap::SURFACE_STATE, 0u).getCpuBase();
|
||||
|
||||
KernelOperation *blockedCommandData = new KernelOperation(std::unique_ptr<LinearStream>(new LinearStream()),
|
||||
auto cmdStreamAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties({4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
||||
KernelOperation *blockedCommandData = new KernelOperation(std::unique_ptr<LinearStream>(new LinearStream(cmdStreamAllocation)),
|
||||
std::unique_ptr<IndirectHeap>(dsh),
|
||||
std::unique_ptr<IndirectHeap>(ioh),
|
||||
std::unique_ptr<IndirectHeap>(ssh),
|
||||
|
||||
@@ -105,7 +105,7 @@ TEST(CommandTest, givenWaitlistRequestWhenCommandComputeKernelIsCreatedThenMakeL
|
||||
cmdQ.allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, 1, ih1);
|
||||
cmdQ.allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, 1, ih2);
|
||||
cmdQ.allocateHeapMemory(IndirectHeap::SURFACE_STATE, 1, ih3);
|
||||
auto cmdStream = new LinearStream(alignedMalloc(1, 1), 1);
|
||||
auto cmdStream = new LinearStream(device->getMemoryManager()->allocateGraphicsMemoryWithProperties({1, GraphicsAllocation::AllocationType::COMMAND_BUFFER}));
|
||||
|
||||
std::vector<Surface *> surfaces;
|
||||
auto kernelOperation = new KernelOperation(std::unique_ptr<LinearStream>(cmdStream), UniqueIH(ih1), UniqueIH(ih2), UniqueIH(ih3),
|
||||
@@ -127,3 +127,31 @@ TEST(CommandTest, givenWaitlistRequestWhenCommandComputeKernelIsCreatedThenMakeL
|
||||
EXPECT_EQ(static_cast<cl_event>(&event1), command.eventsWaitlist[0]);
|
||||
EXPECT_EQ(static_cast<cl_event>(&event2), command.eventsWaitlist[1]);
|
||||
}
|
||||
|
||||
TEST(KernelOperationDestruction, givenKernelOperationWhenItIsDestructedThenAllAllocationsAreStoredInInternalStorageForReuse) {
|
||||
using UniqueIH = std::unique_ptr<IndirectHeap>;
|
||||
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
|
||||
CommandQueue cmdQ(nullptr, device.get(), nullptr);
|
||||
InternalAllocationStorage &allocationStorage = *device->getDefaultEngine().commandStreamReceiver->getInternalAllocationStorage();
|
||||
auto &allocationsForReuse = allocationStorage.getAllocationsForReuse();
|
||||
|
||||
IndirectHeap *ih1 = nullptr, *ih2 = nullptr, *ih3 = nullptr;
|
||||
cmdQ.allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, 1, ih1);
|
||||
cmdQ.allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, 1, ih2);
|
||||
cmdQ.allocateHeapMemory(IndirectHeap::SURFACE_STATE, 1, ih3);
|
||||
auto cmdStream = std::make_unique<LinearStream>(device->getMemoryManager()->allocateGraphicsMemoryWithProperties({1, GraphicsAllocation::AllocationType::COMMAND_BUFFER}));
|
||||
|
||||
auto &heapAllocation1 = *ih1->getGraphicsAllocation();
|
||||
auto &heapAllocation2 = *ih2->getGraphicsAllocation();
|
||||
auto &heapAllocation3 = *ih3->getGraphicsAllocation();
|
||||
auto &cmdStreamAllocation = *cmdStream->getGraphicsAllocation();
|
||||
|
||||
auto kernelOperation = std::make_unique<KernelOperation>(std::move(cmdStream), UniqueIH(ih1), UniqueIH(ih2), UniqueIH(ih3), allocationStorage);
|
||||
EXPECT_TRUE(allocationsForReuse.peekIsEmpty());
|
||||
|
||||
kernelOperation.reset();
|
||||
EXPECT_TRUE(allocationsForReuse.peekContains(cmdStreamAllocation));
|
||||
EXPECT_TRUE(allocationsForReuse.peekContains(heapAllocation1));
|
||||
EXPECT_TRUE(allocationsForReuse.peekContains(heapAllocation2));
|
||||
EXPECT_TRUE(allocationsForReuse.peekContains(heapAllocation3));
|
||||
}
|
||||
|
||||
@@ -88,6 +88,13 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily>, publ
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CompletionStamp flushTask(LinearStream &commandStream, size_t commandStreamStart,
|
||||
const IndirectHeap &dsh, const IndirectHeap &ioh, const IndirectHeap &ssh,
|
||||
uint32_t taskLevel, DispatchFlags &dispatchFlags, Device &device) override {
|
||||
this->lastFlushedCommandStream = &commandStream;
|
||||
return BaseClass::flushTask(commandStream, commandStreamStart, dsh, ioh, ssh, taskLevel, dispatchFlags, device);
|
||||
}
|
||||
|
||||
size_t getPreferredTagPoolSize() const override {
|
||||
return BaseClass::getPreferredTagPoolSize() + 1;
|
||||
}
|
||||
@@ -139,6 +146,7 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily>, publ
|
||||
bool activateAubSubCaptureCalled = false;
|
||||
bool flushBatchedSubmissionsCalled = false;
|
||||
bool initProgrammingFlagsCalled = false;
|
||||
LinearStream *lastFlushedCommandStream = nullptr;
|
||||
|
||||
protected:
|
||||
std::unique_ptr<GraphicsAllocation> tempPreemptionLocation;
|
||||
|
||||
Reference in New Issue
Block a user