Pass eventWaitList to blocked command for semaphore programming

Change-Id: I8b56be03a7b89283f5368cf42d6788d70ebecdc7
Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
Dunajski, Bartosz
2018-09-19 10:34:33 -07:00
committed by sys_ocldev
parent 26006a8482
commit e06b370697
7 changed files with 91 additions and 82 deletions

View File

@ -427,17 +427,17 @@ class SurfaceMock : public Surface {
};
TEST_F(InternalsEventTest, processBlockedCommandsKernelOperation) {
MockEvent<Event> event(nullptr, CL_COMMAND_NDRANGE_KERNEL, 0, 0);
CommandQueue *pCmdQ = new CommandQueue(mockContext, pDevice, 0);
CommandQueue cmdQ(mockContext, pDevice, nullptr);
MockEvent<Event> event(&cmdQ, CL_COMMAND_NDRANGE_KERNEL, 0, 0);
auto cmdStream = new LinearStream(alignedMalloc(4096, 4096), 4096);
IndirectHeap *dsh = nullptr, *ioh = nullptr, *ssh = nullptr;
pCmdQ->allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, 4096u, dsh);
pCmdQ->allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, 4096u, ioh);
pCmdQ->allocateHeapMemory(IndirectHeap::SURFACE_STATE, 4096u, ssh);
cmdQ.allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, 4096u, dsh);
cmdQ.allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, 4096u, ioh);
cmdQ.allocateHeapMemory(IndirectHeap::SURFACE_STATE, 4096u, ssh);
using UniqueIH = std::unique_ptr<IndirectHeap>;
auto blockedCommandsData = new KernelOperation(std::unique_ptr<LinearStream>(cmdStream), UniqueIH(dsh),
UniqueIH(ioh), UniqueIH(ssh), *pCmdQ->getDevice().getMemoryManager());
UniqueIH(ioh), UniqueIH(ssh), *cmdQ.getDevice().getMemoryManager());
MockKernelWithInternals mockKernelWithInternals(*pDevice);
auto pKernel = mockKernelWithInternals.mockKernel;
@ -448,7 +448,7 @@ TEST_F(InternalsEventTest, processBlockedCommandsKernelOperation) {
surface->graphicsAllocation = new GraphicsAllocation((void *)0x1234, 100u);
PreemptionMode preemptionMode = pDevice->getPreemptionMode();
v.push_back(surface);
auto cmd = new CommandComputeKernel(*pCmdQ, csr, std::unique_ptr<KernelOperation>(blockedCommandsData), v, false, false, false, nullptr, preemptionMode, pKernel, 1);
auto cmd = new CommandComputeKernel(cmdQ, std::unique_ptr<KernelOperation>(blockedCommandsData), v, false, false, false, nullptr, preemptionMode, pKernel, 1);
event.setCommand(std::unique_ptr<Command>(cmd));
auto taskLevelBefore = csr.peekTaskLevel();
@ -458,7 +458,6 @@ TEST_F(InternalsEventTest, processBlockedCommandsKernelOperation) {
auto taskLevelAfter = csr.peekTaskLevel();
EXPECT_EQ(taskLevelBefore + 1, taskLevelAfter);
delete pCmdQ;
EXPECT_EQ(surface->resident, 1u);
EXPECT_FALSE(surface->graphicsAllocation->isResident(0u));
@ -466,17 +465,17 @@ TEST_F(InternalsEventTest, processBlockedCommandsKernelOperation) {
}
TEST_F(InternalsEventTest, processBlockedCommandsAbortKernelOperation) {
MockEvent<Event> event(nullptr, CL_COMMAND_NDRANGE_KERNEL, 0, 0);
CommandQueue *pCmdQ = new CommandQueue(mockContext, pDevice, 0);
CommandQueue cmdQ(mockContext, pDevice, nullptr);
MockEvent<Event> event(&cmdQ, CL_COMMAND_NDRANGE_KERNEL, 0, 0);
auto cmdStream = new LinearStream(alignedMalloc(4096, 4096), 4096);
IndirectHeap *dsh = nullptr, *ioh = nullptr, *ssh = nullptr;
pCmdQ->allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, 4096u, dsh);
pCmdQ->allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, 4096u, ioh);
pCmdQ->allocateHeapMemory(IndirectHeap::SURFACE_STATE, 4096u, ssh);
cmdQ.allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, 4096u, dsh);
cmdQ.allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, 4096u, ioh);
cmdQ.allocateHeapMemory(IndirectHeap::SURFACE_STATE, 4096u, ssh);
using UniqueIH = std::unique_ptr<IndirectHeap>;
auto blockedCommandsData = new KernelOperation(std::unique_ptr<LinearStream>(cmdStream), UniqueIH(dsh),
UniqueIH(ioh), UniqueIH(ssh), *pCmdQ->getDevice().getMemoryManager());
UniqueIH(ioh), UniqueIH(ssh), *cmdQ.getDevice().getMemoryManager());
MockKernelWithInternals mockKernelWithInternals(*pDevice);
auto pKernel = mockKernelWithInternals.mockKernel;
@ -486,7 +485,7 @@ TEST_F(InternalsEventTest, processBlockedCommandsAbortKernelOperation) {
NullSurface *surface = new NullSurface;
v.push_back(surface);
PreemptionMode preemptionMode = pDevice->getPreemptionMode();
auto cmd = new CommandComputeKernel(*pCmdQ, csr, std::unique_ptr<KernelOperation>(blockedCommandsData), v, false, false, false, nullptr, preemptionMode, pKernel, 1);
auto cmd = new CommandComputeKernel(cmdQ, std::unique_ptr<KernelOperation>(blockedCommandsData), v, false, false, false, nullptr, preemptionMode, pKernel, 1);
event.setCommand(std::unique_ptr<Command>(cmd));
auto taskLevelBefore = csr.peekTaskLevel();
@ -496,22 +495,21 @@ TEST_F(InternalsEventTest, processBlockedCommandsAbortKernelOperation) {
auto taskLevelAfter = csr.peekTaskLevel();
EXPECT_EQ(taskLevelBefore, taskLevelAfter);
delete pCmdQ;
}
TEST_F(InternalsEventTest, givenBlockedKernelWithPrintfWhenSubmittedThenPrintOutput) {
testing::internal::CaptureStdout();
MockEvent<Event> event(nullptr, CL_COMMAND_NDRANGE_KERNEL, 0, 0);
CommandQueue *pCmdQ = new CommandQueue(mockContext, pDevice, 0);
CommandQueue cmdQ(mockContext, pDevice, nullptr);
MockEvent<Event> event(&cmdQ, CL_COMMAND_NDRANGE_KERNEL, 0, 0);
auto cmdStream = new LinearStream(alignedMalloc(4096, 4096), 4096);
IndirectHeap *dsh = nullptr, *ioh = nullptr, *ssh = nullptr;
pCmdQ->allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, 4096u, dsh);
pCmdQ->allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, 4096u, ioh);
pCmdQ->allocateHeapMemory(IndirectHeap::SURFACE_STATE, 4096u, ssh);
cmdQ.allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, 4096u, dsh);
cmdQ.allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, 4096u, ioh);
cmdQ.allocateHeapMemory(IndirectHeap::SURFACE_STATE, 4096u, ssh);
using UniqueIH = std::unique_ptr<IndirectHeap>;
auto blockedCommandsData = new KernelOperation(std::unique_ptr<LinearStream>(cmdStream), UniqueIH(dsh),
UniqueIH(ioh), UniqueIH(ssh), *pCmdQ->getDevice().getMemoryManager());
UniqueIH(ioh), UniqueIH(ssh), *cmdQ.getDevice().getMemoryManager());
SPatchAllocateStatelessPrintfSurface *pPrintfSurface = new SPatchAllocateStatelessPrintfSurface();
pPrintfSurface->DataParamOffset = 0;
@ -542,10 +540,9 @@ TEST_F(InternalsEventTest, givenBlockedKernelWithPrintfWhenSubmittedThenPrintOut
printfSurface[0] = 8;
printfSurface[1] = 0;
auto &csr = pDevice->getCommandStreamReceiver();
std::vector<Surface *> v;
PreemptionMode preemptionMode = pDevice->getPreemptionMode();
auto cmd = new CommandComputeKernel(*pCmdQ, csr, std::unique_ptr<KernelOperation>(blockedCommandsData), v, false, false, false, std::move(printfHandler), preemptionMode, pKernel, 1);
auto cmd = new CommandComputeKernel(cmdQ, std::unique_ptr<KernelOperation>(blockedCommandsData), v, false, false, false, std::move(printfHandler), preemptionMode, pKernel, 1);
event.setCommand(std::unique_ptr<Command>(cmd));
event.submitCommand(false);
@ -555,7 +552,6 @@ TEST_F(InternalsEventTest, givenBlockedKernelWithPrintfWhenSubmittedThenPrintOut
EXPECT_FALSE(surface->isResident(0u));
delete pPrintfSurface;
delete pCmdQ;
}
TEST_F(InternalsEventTest, processBlockedCommandsMapOperation) {
@ -1431,7 +1427,7 @@ HWTEST_F(InternalsEventTest, givenAbortedCommandWhenSubmitCalledThenDontUpdateFl
UniqueIH(ioh), UniqueIH(ssh), *pCmdQ->getDevice().getMemoryManager());
PreemptionMode preemptionMode = pDevice->getPreemptionMode();
std::vector<Surface *> v;
auto cmd = new CommandComputeKernel(*pCmdQ, csr, std::unique_ptr<KernelOperation>(blockedCommandsData), v, false, false, false, nullptr, preemptionMode, pKernel, 1);
auto cmd = new CommandComputeKernel(*pCmdQ, std::unique_ptr<KernelOperation>(blockedCommandsData), v, false, false, false, nullptr, preemptionMode, pKernel, 1);
event->setCommand(std::unique_ptr<Command>(cmd));
FlushStamp expectedFlushStamp = 0;