Add unit test for events
Change-Id: I13d74626a244d234a5bbaff369ed09fb59d6e33f
This commit is contained in:
parent
5fb5f1a46a
commit
76276d4c23
|
@ -145,7 +145,7 @@ class CommandStreamReceiver {
|
||||||
void setExperimentalCmdBuffer(std::unique_ptr<ExperimentalCommandBuffer> &&cmdBuffer);
|
void setExperimentalCmdBuffer(std::unique_ptr<ExperimentalCommandBuffer> &&cmdBuffer);
|
||||||
|
|
||||||
bool initializeTagAllocation();
|
bool initializeTagAllocation();
|
||||||
std::unique_lock<MutexType> obtainUniqueOwnership();
|
MOCKABLE_VIRTUAL std::unique_lock<MutexType> obtainUniqueOwnership();
|
||||||
|
|
||||||
KmdNotifyHelper *peekKmdNotifyHelper() {
|
KmdNotifyHelper *peekKmdNotifyHelper() {
|
||||||
return kmdNotifyHelper.get();
|
return kmdNotifyHelper.get();
|
||||||
|
|
|
@ -864,6 +864,61 @@ TEST(Event, GivenNoContextOnDeletionDeletesSelf) {
|
||||||
ASSERT_TRUE(autoptr.isUnused());
|
ASSERT_TRUE(autoptr.isUnused());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HWTEST_F(EventTest, givenVirtualEventWhenCommandSubmittedThenLockCSROccurs) {
|
||||||
|
using UniqueIH = std::unique_ptr<IndirectHeap>;
|
||||||
|
class MockCommandComputeKernel : public CommandComputeKernel {
|
||||||
|
public:
|
||||||
|
using CommandComputeKernel::eventsWaitlist;
|
||||||
|
MockCommandComputeKernel(CommandQueue &commandQueue, KernelOperation *kernelResources, std::vector<Surface *> &surfaces, Kernel *kernel)
|
||||||
|
: CommandComputeKernel(commandQueue, std::unique_ptr<KernelOperation>(kernelResources), surfaces, false, false, false, nullptr, PreemptionMode::Disabled, kernel, 0) {}
|
||||||
|
};
|
||||||
|
class MockEvent : public Event {
|
||||||
|
public:
|
||||||
|
using Event::submitCommand;
|
||||||
|
MockEvent(CommandQueue *cmdQueue, cl_command_type cmdType,
|
||||||
|
uint32_t taskLevel, uint32_t taskCount) : Event(cmdQueue, cmdType,
|
||||||
|
taskLevel, taskCount) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
MockKernelWithInternals kernel(*pDevice);
|
||||||
|
|
||||||
|
IndirectHeap *ih1 = nullptr, *ih2 = nullptr, *ih3 = nullptr;
|
||||||
|
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);
|
||||||
|
|
||||||
|
std::vector<Surface *> surfaces;
|
||||||
|
auto kernelOperation = new KernelOperation(std::unique_ptr<LinearStream>(cmdStream), UniqueIH(ih1), UniqueIH(ih2), UniqueIH(ih3),
|
||||||
|
*pDevice->getDefaultEngine().commandStreamReceiver->getInternalAllocationStorage());
|
||||||
|
|
||||||
|
std::unique_ptr<MockCommandComputeKernel> command = std::make_unique<MockCommandComputeKernel>(*pCmdQ, kernelOperation, surfaces, kernel);
|
||||||
|
|
||||||
|
auto virtualEvent = make_releaseable<MockEvent>(pCmdQ, CL_COMMAND_NDRANGE_KERNEL, Event::eventNotReady, Event::eventNotReady);
|
||||||
|
|
||||||
|
virtualEvent->setCommand(std::move(command));
|
||||||
|
|
||||||
|
virtualEvent->submitCommand(false);
|
||||||
|
|
||||||
|
EXPECT_EQ(pDevice->getUltCommandStreamReceiver<FamilyType>().recursiveLockCounter, 2u);
|
||||||
|
}
|
||||||
|
|
||||||
|
HWTEST_F(EventTest, givenVirtualEventWhenSubmitCommandEventNotReadyAndEventWithoutCommandThenOneLockCSRNeeded) {
|
||||||
|
class MockEvent : public Event {
|
||||||
|
public:
|
||||||
|
using Event::submitCommand;
|
||||||
|
MockEvent(CommandQueue *cmdQueue, cl_command_type cmdType,
|
||||||
|
uint32_t taskLevel, uint32_t taskCount) : Event(cmdQueue, cmdType,
|
||||||
|
taskLevel, taskCount) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
auto virtualEvent = make_releaseable<MockEvent>(pCmdQ, CL_COMMAND_NDRANGE_KERNEL, Event::eventNotReady, Event::eventNotReady);
|
||||||
|
|
||||||
|
virtualEvent->submitCommand(false);
|
||||||
|
|
||||||
|
EXPECT_EQ(pDevice->getUltCommandStreamReceiver<FamilyType>().recursiveLockCounter, 1u);
|
||||||
|
}
|
||||||
|
|
||||||
HWTEST_F(InternalsEventTest, GivenBufferWithoutZeroCopyOnCommandMapOrUnmapFlushesPreviousTasksBeforeMappingOrUnmapping) {
|
HWTEST_F(InternalsEventTest, GivenBufferWithoutZeroCopyOnCommandMapOrUnmapFlushesPreviousTasksBeforeMappingOrUnmapping) {
|
||||||
struct MockNonZeroCopyBuff : UnalignedBuffer {
|
struct MockNonZeroCopyBuff : UnalignedBuffer {
|
||||||
MockNonZeroCopyBuff(int32_t &executionStamp)
|
MockNonZeroCopyBuff(int32_t &executionStamp)
|
||||||
|
|
|
@ -68,7 +68,7 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily>, publ
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UltCommandStreamReceiver(const HardwareInfo &hwInfoIn, ExecutionEnvironment &executionEnvironment) : BaseClass(hwInfoIn, executionEnvironment) {
|
UltCommandStreamReceiver(const HardwareInfo &hwInfoIn, ExecutionEnvironment &executionEnvironment) : BaseClass(hwInfoIn, executionEnvironment), recursiveLockCounter(0) {
|
||||||
if (hwInfoIn.capabilityTable.defaultPreemptionMode == PreemptionMode::MidThread) {
|
if (hwInfoIn.capabilityTable.defaultPreemptionMode == PreemptionMode::MidThread) {
|
||||||
tempPreemptionLocation = std::make_unique<GraphicsAllocation>(nullptr, 0, 0, 0, false);
|
tempPreemptionLocation = std::make_unique<GraphicsAllocation>(nullptr, 0, 0, 0, false);
|
||||||
this->preemptionCsrAllocation = tempPreemptionLocation.get();
|
this->preemptionCsrAllocation = tempPreemptionLocation.get();
|
||||||
|
@ -129,6 +129,12 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily>, publ
|
||||||
initProgrammingFlagsCalled = true;
|
initProgrammingFlagsCalled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_lock<CommandStreamReceiver::MutexType> obtainUniqueOwnership() override {
|
||||||
|
recursiveLockCounter++;
|
||||||
|
return CommandStreamReceiverHw<GfxFamily>::obtainUniqueOwnership();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::atomic<uint32_t> recursiveLockCounter;
|
||||||
bool createPageTableManagerCalled = false;
|
bool createPageTableManagerCalled = false;
|
||||||
bool activateAubSubCaptureCalled = false;
|
bool activateAubSubCaptureCalled = false;
|
||||||
bool flushBatchedSubmissionsCalled = false;
|
bool flushBatchedSubmissionsCalled = false;
|
||||||
|
|
Loading…
Reference in New Issue