Skip to content

Commit 10cff46

Browse files
Fix make resident event alloc for marker dispatch
Signed-off-by: Maciej Plewka <[email protected]>
1 parent f34db6a commit 10cff46

File tree

3 files changed

+38
-15
lines changed

3 files changed

+38
-15
lines changed

opencl/source/command_queue/enqueue_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ void CommandQueueHw<GfxFamily>::processDispatchForMarker(CommandQueue &commandQu
589589

590590
HardwareInterface<GfxFamily>::dispatchProfilingPerfStartCommands(hwTimeStamps, hwPerfCounter, commandStream, commandQueue);
591591
HardwareInterface<GfxFamily>::dispatchProfilingPerfEndCommands(hwTimeStamps, hwPerfCounter, commandStream, commandQueue);
592+
getGpgpuCommandStreamReceiver().makeResident(*hwTimeStamps->getBaseGraphicsAllocation());
592593
}
593594

594595
template <typename GfxFamily>

opencl/test/unit_test/command_queue/command_queue_hw_tests.cpp

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,42 @@ HWTEST_F(CommandQueueHwTest, WhenEnqueuingBlockedMapUnmapOperationThenVirtualEve
176176
pHwQ->virtualEvent = nullptr;
177177
}
178178

179+
class MockCommandStreamReceiverWithFailingFlushBatchedSubmission : public MockCommandStreamReceiver {
180+
public:
181+
using MockCommandStreamReceiver::MockCommandStreamReceiver;
182+
bool flushBatchedSubmissions() override {
183+
return false;
184+
}
185+
};
186+
187+
template <typename GfxFamily>
188+
struct MockCommandQueueHwWithOverwrittenCsr : public CommandQueueHw<GfxFamily> {
189+
using CommandQueueHw<GfxFamily>::CommandQueueHw;
190+
MockCommandStreamReceiverWithFailingFlushBatchedSubmission *csr;
191+
CommandStreamReceiver &getGpgpuCommandStreamReceiver() const override { return *csr; }
192+
};
193+
194+
HWTEST_F(CommandQueueHwTest, GivenCommandQueueWhenProcessDispatchForMarkerCalledThenEventAllocationIsMadeResident) {
195+
196+
pDevice->getUltCommandStreamReceiver<FamilyType>().timestampPacketWriteEnabled = false;
197+
MockCommandStreamReceiverWithFailingFlushBatchedSubmission csr(*pDevice->getExecutionEnvironment(), 0, pDevice->getDeviceBitfield());
198+
auto myCmdQ = std::make_unique<MockCommandQueueHwWithOverwrittenCsr<FamilyType>>(pCmdQ->getContextPtr(), pClDevice, nullptr, false);
199+
myCmdQ->csr = &csr;
200+
csr.osContext = &pCmdQ->getCommandStreamReceiver(false).getOsContext();
201+
std::unique_ptr<Event> event(new Event(myCmdQ.get(), CL_COMMAND_COPY_BUFFER, 0, 0));
202+
ASSERT_NE(nullptr, event);
203+
204+
GraphicsAllocation *allocation = event->getHwTimeStampNode()->getBaseGraphicsAllocation()->getDefaultGraphicsAllocation();
205+
ASSERT_NE(nullptr, allocation);
206+
cl_event a = event.get();
207+
EventsRequest eventsRequest(0, nullptr, &a);
208+
uint32_t streamBuffer[100] = {};
209+
NEO::LinearStream linearStream(streamBuffer, sizeof(streamBuffer));
210+
CsrDependencies deps = {};
211+
myCmdQ->processDispatchForMarker(*myCmdQ.get(), &linearStream, eventsRequest, deps);
212+
EXPECT_GT(csr.makeResidentCalledTimes, 0u);
213+
}
214+
179215
HWTEST_F(CommandQueueHwTest, givenCommandQueueWhenAskingForCacheFlushOnBcsThenReturnTrue) {
180216
auto pHwQ = static_cast<CommandQueueHw<FamilyType> *>(pCmdQ);
181217

@@ -1366,21 +1402,6 @@ HWTEST_F(CommandQueueHwTest, givenSizeWhenForceStatelessIsCalledThenCorrectValue
13661402
EXPECT_FALSE(pCmdQHw->forceStateless(static_cast<size_t>(smallSize)));
13671403
}
13681404

1369-
class MockCommandStreamReceiverWithFailingFlushBatchedSubmission : public MockCommandStreamReceiver {
1370-
public:
1371-
using MockCommandStreamReceiver::MockCommandStreamReceiver;
1372-
bool flushBatchedSubmissions() override {
1373-
return false;
1374-
}
1375-
};
1376-
1377-
template <typename GfxFamily>
1378-
struct MockCommandQueueHwWithOverwrittenCsr : public CommandQueueHw<GfxFamily> {
1379-
using CommandQueueHw<GfxFamily>::CommandQueueHw;
1380-
MockCommandStreamReceiverWithFailingFlushBatchedSubmission *csr;
1381-
CommandStreamReceiver &getGpgpuCommandStreamReceiver() const override { return *csr; }
1382-
};
1383-
13841405
HWTEST_F(CommandQueueHwTest, givenFlushWhenFlushBatchedSubmissionsFailsThenErrorIsRetured) {
13851406
MockCommandQueueHwWithOverwrittenCsr<FamilyType> cmdQueue(context, pClDevice, nullptr, false);
13861407
MockCommandStreamReceiverWithFailingFlushBatchedSubmission csr(*pDevice->executionEnvironment, 0, pDevice->getDeviceBitfield());

shared/test/common/mocks/mock_command_stream_receiver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class MockCommandStreamReceiver : public CommandStreamReceiver {
3333
using CommandStreamReceiver::latestFlushedTaskCount;
3434
using CommandStreamReceiver::latestSentTaskCount;
3535
using CommandStreamReceiver::newResources;
36+
using CommandStreamReceiver::osContext;
3637
using CommandStreamReceiver::preemptionAllocation;
3738
using CommandStreamReceiver::requiredThreadArbitrationPolicy;
3839
using CommandStreamReceiver::tagAddress;

0 commit comments

Comments
 (0)