Skip to content

Commit c624787

Browse files
Add comments with kernel names to AUB files
Related-To: NEO-2783 Change-Id: Ib00e969b106301d712dc4c14af8208456bcabdb3 Signed-off-by: Milczarek, Slawomir <slawomir.milczarek@intel.com>
1 parent 1d42fe1 commit c624787

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

runtime/command_queue/enqueue_common.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,13 @@ void CommandQueueHw<GfxFamily>::enqueueHandler(Surface **surfacesForResidency,
184184

185185
enqueueHandlerHook(commandType, multiDispatchInfo);
186186

187+
if (getCommandStreamReceiver().getType() > CommandStreamReceiverType::CSR_HW) {
188+
if (!multiDispatchInfo.empty()) {
189+
auto kernelName = multiDispatchInfo.peekMainKernel()->getKernelInfo().name;
190+
getCommandStreamReceiver().addAubComment(kernelName.c_str());
191+
}
192+
}
193+
187194
if (DebugManager.flags.AUBDumpSubCaptureMode.get()) {
188195
getCommandStreamReceiver().activateAubSubCapture(multiDispatchInfo);
189196
}

unit_tests/command_queue/enqueue_handler_tests.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,37 @@ HWTEST_F(EnqueueHandlerTest, enqueueHandlerWithKernelCallsProcessEvictionOnCSR)
3434
EXPECT_TRUE(csr->processEvictionCalled);
3535
}
3636

37+
HWTEST_F(EnqueueHandlerTest, givenEnqueueHandlerWithKernelWhenAubCsrIsActiveThenAddCommentWithKernelName) {
38+
int32_t tag;
39+
auto aubCsr = new MockCsrAub<FamilyType>(tag, *pDevice->executionEnvironment);
40+
pDevice->resetCommandStreamReceiver(aubCsr);
41+
42+
MockKernelWithInternals mockKernel(*pDevice);
43+
auto mockCmdQ = std::unique_ptr<MockCommandQueueHw<FamilyType>>(new MockCommandQueueHw<FamilyType>(context, pDevice, 0));
44+
45+
size_t gws[] = {1, 1, 1};
46+
mockKernel.kernelInfo.name = "kernel_name";
47+
mockCmdQ->enqueueKernel(mockKernel.mockKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr);
48+
49+
EXPECT_TRUE(aubCsr->addAubCommentCalled);
50+
EXPECT_STREQ("kernel_name", aubCsr->aubCommentMessage.c_str());
51+
}
52+
53+
HWTEST_F(EnqueueHandlerTest, givenEnqueueHandlerWithEmptyDispatchInfoWhenAubCsrIsActiveThenDontAddCommentWithKernelName) {
54+
int32_t tag;
55+
auto aubCsr = new MockCsrAub<FamilyType>(tag, *pDevice->executionEnvironment);
56+
pDevice->resetCommandStreamReceiver(aubCsr);
57+
58+
MockKernelWithInternals mockKernel(*pDevice);
59+
auto mockCmdQ = std::unique_ptr<MockCommandQueueHw<FamilyType>>(new MockCommandQueueHw<FamilyType>(context, pDevice, 0));
60+
61+
size_t gws[] = {0, 0, 0};
62+
mockKernel.kernelInfo.name = "kernel_name";
63+
mockCmdQ->enqueueKernel(mockKernel.mockKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr);
64+
65+
EXPECT_FALSE(aubCsr->addAubCommentCalled);
66+
}
67+
3768
template <typename GfxFamily>
3869
class MyCommandQueueHw : public CommandQueueHw<GfxFamily> {
3970
typedef CommandQueueHw<GfxFamily> BaseClass;

unit_tests/libult/ult_command_stream_receiver.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily>, publ
144144
}
145145
void addAubComment(const char *message) override {
146146
CommandStreamReceiverHw<GfxFamily>::addAubComment(message);
147+
aubCommentMessage.assign(message);
147148
addAubCommentCalled = true;
148149
}
149150
void flushBatchedSubmissions() override {
@@ -165,6 +166,7 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily>, publ
165166
bool recordFlusheBatchBuffer = false;
166167
bool activateAubSubCaptureCalled = false;
167168
bool addAubCommentCalled = false;
169+
std::string aubCommentMessage = "";
168170
bool flushBatchedSubmissionsCalled = false;
169171
uint32_t makeSurfacePackNonResidentCalled = false;
170172
bool initProgrammingFlagsCalled = false;

unit_tests/mocks/mock_csr.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ class MockCsrBase : public UltCommandStreamReceiver<GfxFamily> {
9494
template <typename GfxFamily>
9595
using MockCsrHw = MockCsrBase<GfxFamily>;
9696

97+
template <typename GfxFamily>
98+
class MockCsrAub : public MockCsrBase<GfxFamily> {
99+
public:
100+
MockCsrAub(int32_t &execStamp, ExecutionEnvironment &executionEnvironment) : MockCsrBase<GfxFamily>(execStamp, executionEnvironment) {}
101+
CommandStreamReceiverType getType() override {
102+
return CommandStreamReceiverType::CSR_AUB;
103+
}
104+
};
105+
97106
template <typename GfxFamily>
98107
class MockCsr : public MockCsrBase<GfxFamily> {
99108
public:

0 commit comments

Comments
 (0)