AUB CSR with a capability to add AUB comment

Change-Id: Ia7e85468c3f1e937d34b67b0e279c013e8e3c190
Signed-off-by: Milczarek, Slawomir <slawomir.milczarek@intel.com>
This commit is contained in:
Milczarek, Slawomir
2019-04-01 09:33:19 +02:00
committed by sys_ocldev
parent f3d17008ee
commit 17493426c1
12 changed files with 121 additions and 12 deletions

View File

@@ -8,6 +8,7 @@
#include "runtime/aub_mem_dump/page_table_entry_bits.h"
#include "runtime/command_stream/aub_command_stream_receiver_hw.h"
#include "runtime/helpers/hardware_context_controller.h"
#include "runtime/helpers/neo_driver_version.h"
#include "runtime/os_interface/os_context.h"
#include "test.h"
#include "unit_tests/fixtures/aub_command_stream_receiver_fixture.h"
@@ -201,6 +202,35 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenFlushIsCalledThenI
EXPECT_FALSE(aubCsr->pollForCompletionCalled);
}
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenCallingAddAubCommentThenCallAddCommentOnAubFileStream) {
auto aubFileStream = std::make_unique<MockAubFileStream>();
auto aubExecutionEnvironment = getEnvironment<MockAubCsr<FamilyType>>(true, true, true);
auto aubCsr = aubExecutionEnvironment->template getCsr<MockAubCsr<FamilyType>>();
aubCsr->stream = aubFileStream.get();
const char *comment = "message";
aubCsr->addAubComment(comment);
EXPECT_TRUE(aubCsr->addAubCommentCalled);
EXPECT_TRUE(aubFileStream->addCommentCalled);
EXPECT_STREQ(comment, aubFileStream->receivedComment.c_str());
}
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWithAubManagerWhenCallingAddAubCommentThenCallAddCommentOnAubManager) {
MockAubCsr<FamilyType> aubCsr("", true, *pDevice->executionEnvironment);
MockOsContext osContext(0, 1, aub_stream::ENGINE_RCS, PreemptionMode::Disabled, false);
aubCsr.setupContext(osContext);
auto mockAubManager = static_cast<MockAubManager *>(aubCsr.aubManager);
ASSERT_NE(nullptr, mockAubManager);
const char *comment = "message";
aubCsr.addAubComment(comment);
EXPECT_TRUE(aubCsr.addAubCommentCalled);
EXPECT_TRUE(mockAubManager->addCommentCalled);
EXPECT_STREQ(comment, mockAubManager->receivedComment.c_str());
}
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenCallingInsertAubWaitInstructionThenCallPollForCompletion) {
auto aubExecutionEnvironment = getEnvironment<MockAubCsr<FamilyType>>(true, true, true);
auto aubCsr = aubExecutionEnvironment->template getCsr<MockAubCsr<FamilyType>>();
@@ -613,16 +643,24 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenInitializeEngineIs
}));
aubCsr->initializeEngine();
#define QTR(a) #a
#define TOSTR(b) QTR(b)
const std::string expectedVersion = TOSTR(NEO_DRIVER_VERSION);
#undef QTR
#undef TOSTR
std::string commentWithDriverVersion = "driver version: " + expectedVersion;
std::string commentWithDriverVersion = "driver version: " + std::string(driverVersion);
EXPECT_EQ(commentWithDriverVersion, comments[0]);
}
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWithAubManagerWhenInitFileIsCalledThenMemTraceCommentWithDriverVersionIsPutIntoAubStream) {
auto mockAubManager = std::make_unique<MockAubManager>();
auto aubExecutionEnvironment = getEnvironment<AUBCommandStreamReceiverHw<FamilyType>>(false, true, true);
auto aubCsr = aubExecutionEnvironment->template getCsr<AUBCommandStreamReceiverHw<FamilyType>>();
aubCsr->aubManager = mockAubManager.get();
std::string fileName = "file_name.aub";
aubCsr->initFile(fileName);
std::string commentWithDriverVersion = "driver version: " + std::string(driverVersion);
EXPECT_EQ(mockAubManager->receivedComment, commentWithDriverVersion);
}
HWTEST_F(AubFileStreamTests, givenAddPatchInfoCommentsCalledWhenNoPatchInfoDataObjectsThenCommentsAreEmpty) {
auto mockAubFileStream = std::make_unique<GmockAubFileStream>();
auto aubExecutionEnvironment = getEnvironment<AUBCommandStreamReceiverHw<FamilyType>>(false, true, true);

View File

@@ -325,6 +325,12 @@ HWTEST_F(CommandStreamReceiverTest, givenTimestampPacketAllocatorWhenAskingForTa
EXPECT_NE(node1, node2);
}
HWTEST_F(CommandStreamReceiverTest, givenUltCommandStreamReceiverWhenAddAubCommentIsCalledThenCallAddAubCommentOnCsr) {
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
csr.addAubComment("message");
EXPECT_TRUE(csr.addAubCommentCalled);
}
TEST(CommandStreamReceiverSimpleTest, givenCSRWithTagAllocationSetWhenGetTagAllocationIsCalledThenCorrectAllocationIsReturned) {
ExecutionEnvironment executionEnvironment;
MockCommandStreamReceiver csr(executionEnvironment);

View File

@@ -123,6 +123,10 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily>, publ
CommandStreamReceiverHw<GfxFamily>::activateAubSubCapture(dispatchInfo);
activateAubSubCaptureCalled = true;
}
void addAubComment(const char *message) override {
CommandStreamReceiverHw<GfxFamily>::addAubComment(message);
addAubCommentCalled = true;
}
void flushBatchedSubmissions() override {
CommandStreamReceiverHw<GfxFamily>::flushBatchedSubmissions();
flushBatchedSubmissionsCalled = true;
@@ -140,6 +144,7 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily>, publ
std::atomic<uint32_t> recursiveLockCounter;
bool createPageTableManagerCalled = false;
bool activateAubSubCaptureCalled = false;
bool addAubCommentCalled = false;
bool flushBatchedSubmissionsCalled = false;
bool initProgrammingFlagsCalled = false;
LinearStream *lastFlushedCommandStream = nullptr;

View File

@@ -114,6 +114,10 @@ struct MockAubCsr : public AUBCommandStreamReceiverHw<GfxFamily> {
bool waitForCompletionWithTimeout(bool enableTimeout, int64_t timeoutMicroseconds, uint32_t taskCountToWait) {
return true;
}
void addAubComment(const char *message) {
AUBCommandStreamReceiverHw<GfxFamily>::addAubComment(message);
addAubCommentCalled = true;
}
bool flushBatchedSubmissionsCalled = false;
bool initProgrammingFlagsCalled = false;
bool initializeEngineCalled = false;
@@ -123,6 +127,7 @@ struct MockAubCsr : public AUBCommandStreamReceiverHw<GfxFamily> {
bool pollForCompletionCalled = false;
bool expectMemoryEqualCalled = false;
bool expectMemoryNotEqualCalled = false;
bool addAubCommentCalled = false;
void initFile(const std::string &fileName) override {
fileIsOpen = true;

View File

@@ -57,6 +57,11 @@ struct MockAubFileStream : public AUBCommandStreamReceiver::AubFileStream {
addressSpaceCapturedFromExpectMemory = addressSpace;
compareOperationFromExpectMemory = compareOperation;
}
bool addComment(const char *message) override {
receivedComment.assign(message);
addCommentCalled = true;
return true;
}
void registerPoll(uint32_t registerOffset, uint32_t mask, uint32_t value, bool pollNotEqual, uint32_t timeoutAction) override {
registerPollCalled = true;
AUBCommandStreamReceiver::AubFileStream::registerPoll(registerOffset, mask, value, pollNotEqual, timeoutAction);
@@ -68,6 +73,8 @@ struct MockAubFileStream : public AUBCommandStreamReceiver::AubFileStream {
mutable bool isOpenCalled = false;
mutable bool getFileNameCalled = false;
bool registerPollCalled = false;
bool addCommentCalled = false;
std::string receivedComment = "";
bool flushCalled = false;
bool lockStreamCalled = false;
uint32_t mmioRegisterFromExpectMMIO = 0;

View File

@@ -74,6 +74,11 @@ class MockAubManager : public aub_stream::AubManager {
return fileName;
}
void addComment(const char *message) override {
receivedComment.assign(message);
addCommentCalled = true;
}
void writeMemory(uint64_t gfxAddress, const void *memory, size_t size, uint32_t memoryBanks, int hint, size_t pageSize = 65536) override {
writeMemoryCalled = true;
}
@@ -83,6 +88,8 @@ class MockAubManager : public aub_stream::AubManager {
bool closeCalled = false;
bool isOpenCalled = false;
bool getFileNameCalled = false;
bool addCommentCalled = false;
std::string receivedComment = "";
bool writeMemoryCalled = false;
uint32_t contextFlags = 0;