Pass aubfile name to TbxCommandStreamReceiver::create and CSRWithAubDump

Change-Id: Ib10c017ce4ed2a572815053dae3f517e0dfd9eb3
This commit is contained in:
Hoppe, Mateusz
2019-02-05 17:38:57 +01:00
committed by sys_ocldev
parent e1e139fe76
commit 4d9acf3352
15 changed files with 101 additions and 56 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -45,11 +45,13 @@ void AubWriteCopyReadBuffer::runTest() {
retVal));
ASSERT_NE(nullptr, dstBuffer);
aubCsr->writeMemory(*srcBuffer->getGraphicsAllocation());
aubCsr->writeMemory(*dstBuffer->getGraphicsAllocation());
if (aubCsr) {
aubCsr->writeMemory(*srcBuffer->getGraphicsAllocation());
aubCsr->writeMemory(*dstBuffer->getGraphicsAllocation());
getAubCsr<FamilyType>()->expectMemoryEqual(AUBFixture::getGpuPointer(srcBuffer->getGraphicsAllocation()), srcMemoryInitial, bufferSize);
getAubCsr<FamilyType>()->expectMemoryEqual(AUBFixture::getGpuPointer(dstBuffer->getGraphicsAllocation()), dstMemoryInitial, bufferSize);
aubCsr->expectMemoryEqual(AUBFixture::getGpuPointer(srcBuffer->getGraphicsAllocation()), srcMemoryInitial, bufferSize);
aubCsr->expectMemoryEqual(AUBFixture::getGpuPointer(dstBuffer->getGraphicsAllocation()), dstMemoryInitial, bufferSize);
}
cl_uint numEventsInWaitList = 0;
cl_event *eventWaitList = nullptr;
@@ -79,8 +81,10 @@ void AubWriteCopyReadBuffer::runTest() {
EXPECT_EQ(CL_SUCCESS, retVal);
getAubCsr<FamilyType>()->expectMemoryEqual(AUBFixture::getGpuPointer(srcBuffer->getGraphicsAllocation()), srcMemoryToWrite, bufferSize);
getAubCsr<FamilyType>()->expectMemoryEqual(AUBFixture::getGpuPointer(dstBuffer->getGraphicsAllocation()), dstMemoryToWrite, bufferSize);
if (aubCsr) {
aubCsr->expectMemoryEqual(AUBFixture::getGpuPointer(srcBuffer->getGraphicsAllocation()), srcMemoryToWrite, bufferSize);
aubCsr->expectMemoryEqual(AUBFixture::getGpuPointer(dstBuffer->getGraphicsAllocation()), dstMemoryToWrite, bufferSize);
}
retVal = pCmdQ->enqueueCopyBuffer(
srcBuffer.get(),
@@ -96,8 +100,10 @@ void AubWriteCopyReadBuffer::runTest() {
pCmdQ->flush();
// Destination buffer should have src buffer content
getAubCsr<FamilyType>()->expectMemoryEqual(AUBFixture::getGpuPointer(dstBuffer->getGraphicsAllocation()), srcMemoryToWrite, bufferSize);
if (aubCsr) {
// Destination buffer should have src buffer content
aubCsr->expectMemoryEqual(AUBFixture::getGpuPointer(dstBuffer->getGraphicsAllocation()), srcMemoryToWrite, bufferSize);
}
char hostPtrMemory[] = {0, 0, 0, 0, 0, 0, 0, 0};
ASSERT_EQ(bufferSize, sizeof(hostPtrMemory));
@@ -119,7 +125,9 @@ void AubWriteCopyReadBuffer::runTest() {
allocation = allocation->next;
}
getAubCsr<FamilyType>()->expectMemoryEqual(AUBFixture::getGpuPointer(allocation), srcMemoryToWrite, bufferSize);
if (aubCsr) {
aubCsr->expectMemoryEqual(AUBFixture::getGpuPointer(allocation), srcMemoryToWrite, bufferSize);
}
}
HWTEST_F(AubWriteCopyReadBuffer, givenTwoBuffersFilledWithPatternWhenSourceIsCopiedToDestinationThenDestinationDataValidates) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -33,7 +33,7 @@ void AUBCommandStreamFixture::SetUp(CommandQueue *pCmdQ) {
strfilename << testInfo->test_case_name() << "_" << testInfo->name() << "_" << hwHelper.getCsTraits(engineType.type).name;
if (testMode == TestMode::AubTestsWithTbx) {
pCommandStreamReceiver = TbxCommandStreamReceiver::create(hwInfo, true, *device.executionEnvironment);
pCommandStreamReceiver = TbxCommandStreamReceiver::create(hwInfo, strfilename.str(), true, *device.executionEnvironment);
} else {
pCommandStreamReceiver = AUBCommandStreamReceiver::create(hwInfo, strfilename.str(), true, *device.executionEnvironment);
}

View File

@@ -37,7 +37,7 @@ class AUBFixture : public CommandQueueHwFixture {
executionEnvironment = new ExecutionEnvironment;
if (testMode == TestMode::AubTestsWithTbx) {
this->csr = TbxCommandStreamReceiver::create(hwInfo, true, *executionEnvironment);
this->csr = TbxCommandStreamReceiver::create(hwInfo, strfilename.str(), true, *executionEnvironment);
} else {
this->csr = AUBCommandStreamReceiver::create(hwInfo, strfilename.str(), true, *executionEnvironment);
}
@@ -70,13 +70,17 @@ class AUBFixture : public CommandQueueHwFixture {
template <typename FamilyType>
void expectMemory(void *gfxAddress, const void *srcAddress, size_t length) {
auto aubCsr = getAubCsr<FamilyType>();
aubCsr->expectMemoryEqual(gfxAddress, srcAddress, length);
if (aubCsr) {
aubCsr->expectMemoryEqual(gfxAddress, srcAddress, length);
}
}
template <typename FamilyType>
void expectNotEqualMemory(void *gfxAddress, const void *srcAddress, size_t length) {
auto aubCsr = getAubCsr<FamilyType>();
aubCsr->expectMemoryNotEqual(gfxAddress, srcAddress, length);
if (aubCsr) {
aubCsr->expectMemoryNotEqual(gfxAddress, srcAddress, length);
}
}
static void *getGpuPointer(GraphicsAllocation *allocation) {

View File

@@ -9,10 +9,13 @@
#include "runtime/command_stream/command_stream_receiver_with_aub_dump.h"
#include "runtime/command_stream/command_stream_receiver_with_aub_dump.inl"
#include "runtime/command_stream/preemption.h"
#include "runtime/command_stream/tbx_command_stream_receiver_hw.h"
#include "runtime/execution_environment/execution_environment.h"
#include "runtime/helpers/dispatch_info.h"
#include "runtime/os_interface/os_context.h"
#include "unit_tests/mocks/mock_allocation_properties.h"
#include "unit_tests/mocks/mock_aub_center.h"
#include "unit_tests/mocks/mock_aub_manager.h"
#include "test.h"
@@ -87,7 +90,7 @@ struct MyMockCsr : UltCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> {
template <typename BaseCSR>
struct MyMockCsrWithAubDump : CommandStreamReceiverWithAUBDump<BaseCSR> {
MyMockCsrWithAubDump<BaseCSR>(const HardwareInfo &hwInfoIn, bool createAubCSR, ExecutionEnvironment &executionEnvironment) : CommandStreamReceiverWithAUBDump<BaseCSR>(hwInfoIn, executionEnvironment) {
MyMockCsrWithAubDump<BaseCSR>(const HardwareInfo &hwInfoIn, bool createAubCSR, ExecutionEnvironment &executionEnvironment) : CommandStreamReceiverWithAUBDump<BaseCSR>(hwInfoIn, "aubfile", executionEnvironment) {
if (this->aubCSR != nullptr) {
delete this->aubCSR;
this->aubCSR = nullptr;
@@ -134,7 +137,7 @@ using CommandStreamReceiverWithAubDumpSimpleTest = ::testing::Test;
HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenCsrWithAubDumpWhenSettingOsContextThenReplicateItToAubCsr) {
ExecutionEnvironment executionEnvironment;
CommandStreamReceiverWithAUBDump<UltCommandStreamReceiver<FamilyType>> csrWithAubDump(*platformDevices[0], executionEnvironment);
CommandStreamReceiverWithAUBDump<UltCommandStreamReceiver<FamilyType>> csrWithAubDump(*platformDevices[0], "aubfile", executionEnvironment);
OsContext osContext(nullptr, 0, HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
csrWithAubDump.setupContext(osContext);
@@ -142,6 +145,28 @@ HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenCsrWithAubDumpWhenSett
EXPECT_EQ(&osContext, &csrWithAubDump.aubCSR->getOsContext());
}
HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenAubManagerAvailaleWhenTbxCsrWithAubDumpIsCreatedThenAubCsrIsNotCreated) {
HardwareInfo hwInfo = *platformDevices[0];
std::string fileName = "file_name.aub";
MockAubManager *mockManager = new MockAubManager();
MockAubCenter *mockAubCenter = new MockAubCenter(&hwInfo, false, fileName);
mockAubCenter->aubManager = std::unique_ptr<MockAubManager>(mockManager);
ExecutionEnvironment executionEnvironment;
executionEnvironment.aubCenter = std::unique_ptr<MockAubCenter>(mockAubCenter);
CommandStreamReceiverWithAUBDump<TbxCommandStreamReceiverHw<FamilyType>> csrWithAubDump(*platformDevices[0], "aubfile", executionEnvironment);
ASSERT_EQ(nullptr, csrWithAubDump.aubCSR);
}
HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenNullAubManagerAvailaleWhenTbxCsrWithAubDumpIsCreatedThenAubCsrIsCreated) {
MockAubCenter *mockAubCenter = new MockAubCenter();
ExecutionEnvironment executionEnvironment;
executionEnvironment.aubCenter = std::unique_ptr<MockAubCenter>(mockAubCenter);
CommandStreamReceiverWithAUBDump<TbxCommandStreamReceiverHw<FamilyType>> csrWithAubDump(*platformDevices[0], "aubfile", executionEnvironment);
EXPECT_NE(nullptr, csrWithAubDump.aubCSR);
}
HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenCtorIsCalledThenAubCsrIsInitialized) {
if (createAubCSR) {
EXPECT_NE(nullptr, csrWithAubDump->aubCSR);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -18,7 +18,7 @@ namespace OCLRT {
void TbxCommandStreamFixture::SetUp(MockDevice *pDevice) {
// Create our TBX command stream receiver based on HW type
const auto &hwInfo = pDevice->getHardwareInfo();
pCommandStreamReceiver = TbxCommandStreamReceiver::create(hwInfo, false, *pDevice->executionEnvironment);
pCommandStreamReceiver = TbxCommandStreamReceiver::create(hwInfo, "", false, *pDevice->executionEnvironment);
ASSERT_NE(nullptr, pCommandStreamReceiver);
mmTbx = pCommandStreamReceiver->createMemoryManager(false, false);
pDevice->resetCommandStreamReceiver(pCommandStreamReceiver);

View File

@@ -17,6 +17,7 @@
#include "unit_tests/fixtures/device_fixture.h"
#include "unit_tests/gen_common/gen_cmd_parse.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
#include "unit_tests/helpers/variable_backup.h"
#include "unit_tests/mocks/mock_aub_center.h"
#include "unit_tests/mocks/mock_aub_manager.h"
#include "unit_tests/mocks/mock_graphics_allocation.h"
@@ -25,6 +26,11 @@
#include <cstdint>
using namespace OCLRT;
namespace OCLRT {
extern TbxCommandStreamReceiverCreateFunc tbxCommandStreamReceiverFactory[IGFX_MAX_CORE];
} // namespace OCLRT
namespace Os {
extern const char *tbxLibName;
}
@@ -110,25 +116,16 @@ HWTEST_F(TbxCommandStreamTests, DISABLED_getCsTraits) {
tbxCsr->getCsTraits(EngineType::ENGINE_VECS);
}
#if defined(__linux__)
namespace OCLRT {
TEST(TbxCommandStreamReceiverTest, createShouldReturnNullptrForEmptyEntryInFactory) {
extern TbxCommandStreamReceiverCreateFunc tbxCommandStreamReceiverFactory[IGFX_MAX_PRODUCT];
TbxCommandStreamReceiver tbx;
TEST(TbxCommandStreamReceiverTest, givenNullFactoryEntryWhenTbxCsrIsCreatedThenNullptrIsReturned) {
const HardwareInfo *hwInfo = platformDevices[0];
GFXCORE_FAMILY family = hwInfo->pPlatform->eRenderCoreFamily;
auto pCreate = tbxCommandStreamReceiverFactory[family];
VariableBackup<TbxCommandStreamReceiverCreateFunc> tbxCsrFactoryBackup(&tbxCommandStreamReceiverFactory[family]);
tbxCommandStreamReceiverFactory[family] = nullptr;
ExecutionEnvironment executionEnvironment;
CommandStreamReceiver *csr = tbx.create(*hwInfo, false, executionEnvironment);
CommandStreamReceiver *csr = TbxCommandStreamReceiver::create(*hwInfo, "", false, executionEnvironment);
EXPECT_EQ(nullptr, csr);
tbxCommandStreamReceiverFactory[family] = pCreate;
}
} // namespace OCLRT
#endif
TEST(TbxCommandStreamReceiverTest, givenTbxCommandStreamReceiverWhenItIsCreatedWithWrongGfxCoreFamilyThenNullPointerShouldBeReturned) {
HardwareInfo hwInfo = *platformDevices[0];
@@ -136,7 +133,7 @@ TEST(TbxCommandStreamReceiverTest, givenTbxCommandStreamReceiverWhenItIsCreatedW
const_cast<PLATFORM *>(hwInfo.pPlatform)->eRenderCoreFamily = GFXCORE_FAMILY_FORCE_ULONG; // wrong gfx core family
ExecutionEnvironment executionEnvironment;
CommandStreamReceiver *csr = TbxCommandStreamReceiver::create(hwInfo, false, executionEnvironment);
CommandStreamReceiver *csr = TbxCommandStreamReceiver::create(hwInfo, "", false, executionEnvironment);
EXPECT_EQ(nullptr, csr);
const_cast<PLATFORM *>(hwInfo.pPlatform)->eRenderCoreFamily = family;
@@ -145,7 +142,7 @@ TEST(TbxCommandStreamReceiverTest, givenTbxCommandStreamReceiverWhenItIsCreatedW
TEST(TbxCommandStreamReceiverTest, givenTbxCommandStreamReceiverWhenTypeIsCheckedThenTbxCsrIsReturned) {
HardwareInfo hwInfo = *platformDevices[0];
ExecutionEnvironment executionEnvironment;
std::unique_ptr<CommandStreamReceiver> csr(TbxCommandStreamReceiver::create(hwInfo, false, executionEnvironment));
std::unique_ptr<CommandStreamReceiver> csr(TbxCommandStreamReceiver::create(hwInfo, "", false, executionEnvironment));
EXPECT_NE(nullptr, csr);
EXPECT_EQ(CommandStreamReceiverType::CSR_TBX, csr->getType());
}
@@ -290,7 +287,7 @@ HWTEST_F(TbxCommandStreamTests, givenDbgDeviceIdFlagIsSetWhenTbxCsrIsCreatedThen
DebugManager.flags.OverrideAubDeviceId.set(9); //this is Hsw, not used
const HardwareInfo &hwInfoIn = *platformDevices[0];
ExecutionEnvironment executionEnvironment;
std::unique_ptr<TbxCommandStreamReceiverHw<FamilyType>> tbxCsr(reinterpret_cast<TbxCommandStreamReceiverHw<FamilyType> *>(TbxCommandStreamReceiver::create(hwInfoIn, false, executionEnvironment)));
std::unique_ptr<TbxCommandStreamReceiverHw<FamilyType>> tbxCsr(reinterpret_cast<TbxCommandStreamReceiverHw<FamilyType> *>(TbxCommandStreamReceiver::create(hwInfoIn, "", false, executionEnvironment)));
EXPECT_EQ(9u, tbxCsr->aubDeviceId);
}
@@ -448,7 +445,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenHardwareContextIsCreatedThenTbxSt
ExecutionEnvironment executionEnvironment;
executionEnvironment.aubCenter = std::unique_ptr<MockAubCenter>(mockAubCenter);
auto tbxCsr = std::unique_ptr<TbxCommandStreamReceiverHw<FamilyType>>(reinterpret_cast<TbxCommandStreamReceiverHw<FamilyType> *>(
TbxCommandStreamReceiverHw<FamilyType>::create(hwInfo, false, executionEnvironment)));
TbxCommandStreamReceiverHw<FamilyType>::create(hwInfo, "", false, executionEnvironment)));
EXPECT_FALSE(tbxCsr->streamInitialized);
}
@@ -462,7 +459,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenOsContextIsSetThenCreateHardwareC
ExecutionEnvironment executionEnvironment;
executionEnvironment.aubCenter = std::unique_ptr<MockAubCenter>(mockAubCenter);
std::unique_ptr<TbxCommandStreamReceiverHw<FamilyType>> tbxCsr(reinterpret_cast<TbxCommandStreamReceiverHw<FamilyType> *>(TbxCommandStreamReceiver::create(*platformDevices[0], true, executionEnvironment)));
std::unique_ptr<TbxCommandStreamReceiverHw<FamilyType>> tbxCsr(reinterpret_cast<TbxCommandStreamReceiverHw<FamilyType> *>(TbxCommandStreamReceiver::create(*platformDevices[0], fileName, true, executionEnvironment)));
EXPECT_EQ(nullptr, tbxCsr->hardwareContext.get());
tbxCsr->setupContext(osContext);