Optimize waiting scheme in user events scenarios.

- do not wait on map/unmap if zero copy resource.
- do not wait in marker commands at all.

Change-Id: I74cdd8320d13602bf662eed412ed2fcad1504989
Signed-off-by: Mrozek, Michal <michal.mrozek@intel.com>
This commit is contained in:
Mrozek, Michal
2019-07-08 16:27:36 +02:00
committed by sys_ocldev
parent 64403ef630
commit 7f7f1b8ac9
3 changed files with 25 additions and 5 deletions

View File

@@ -76,9 +76,8 @@ CompletionStamp &CommandMapUnmap::submit(uint32_t taskLevel, bool terminated) {
dispatchFlags,
cmdQ.getDevice());
cmdQ.waitUntilComplete(completionStamp.taskCount, completionStamp.flushStamp, false);
if (!memObj.isMemObjZeroCopy()) {
cmdQ.waitUntilComplete(completionStamp.taskCount, completionStamp.flushStamp, false);
if (op == MAP) {
memObj.transferDataToHostPtr(copySize, copyOffset);
} else if (!readOnly) {
@@ -283,8 +282,6 @@ CompletionStamp &CommandMarker::submit(uint32_t taskLevel, bool terminated) {
dispatchFlags,
cmdQ.getDevice());
cmdQ.waitUntilComplete(completionStamp.taskCount, completionStamp.flushStamp, false);
return completionStamp;
}
} // namespace NEO

View File

@@ -177,7 +177,7 @@ HWTEST_F(CommandQueueHwTest, addMapUnmapToWaitlistEventsDoesntAddDependenciesInt
buffer->decRefInternal();
}
HWTEST_F(CommandQueueHwTest, givenMapCommandWhenZeroStateCommandIsSubmittedThenTaskCountIsBeingWaited) {
HWTEST_F(CommandQueueHwTest, givenMapCommandWhenZeroStateCommandIsSubmittedThenTaskCountIsNotBeingWaited) {
auto buffer = new MockBuffer;
CommandQueueHw<FamilyType> *pHwQ = reinterpret_cast<CommandQueueHw<FamilyType> *>(pCmdQ);
@@ -194,6 +194,28 @@ HWTEST_F(CommandQueueHwTest, givenMapCommandWhenZeroStateCommandIsSubmittedThenT
EXPECT_NE(nullptr, pHwQ->virtualEvent);
pHwQ->virtualEvent->setStatus(CL_COMPLETE);
EXPECT_EQ(std::numeric_limits<uint32_t>::max(), pHwQ->latestTaskCountWaited);
buffer->decRefInternal();
}
HWTEST_F(CommandQueueHwTest, givenMapCommandWhenZeroStateCommandIsSubmittedOnNonZeroCopyBufferThenTaskCountIsBeingWaited) {
auto buffer = new MockBuffer;
buffer->isZeroCopy = false;
CommandQueueHw<FamilyType> *pHwQ = reinterpret_cast<CommandQueueHw<FamilyType> *>(pCmdQ);
MockEventBuilder eventBuilder;
MemObjSizeArray size = {{1, 1, 1}};
MemObjOffsetArray offset = {{0, 0, 0}};
pHwQ->enqueueBlockedMapUnmapOperation(nullptr,
0,
MAP,
buffer,
size, offset, false,
eventBuilder);
EXPECT_NE(nullptr, pHwQ->virtualEvent);
pHwQ->virtualEvent->setStatus(CL_COMPLETE);
EXPECT_EQ(1u, pHwQ->latestTaskCountWaited);
buffer->decRefInternal();
}

View File

@@ -29,6 +29,7 @@ class MockBuffer : public MockBufferStorage, public Buffer {
public:
using Buffer::magic;
using Buffer::offset;
using MemObj::isZeroCopy;
using MockBufferStorage::device;
MockBuffer(GraphicsAllocation &alloc)