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

@@ -17,7 +17,7 @@ class CommandStreamReceiverWithAUBDump : public BaseCSR {
public: public:
using BaseCSR::createMemoryManager; using BaseCSR::createMemoryManager;
CommandStreamReceiverWithAUBDump(const HardwareInfo &hwInfoIn, ExecutionEnvironment &executionEnvironment); CommandStreamReceiverWithAUBDump(const HardwareInfo &hwInfoIn, const std::string &baseName, ExecutionEnvironment &executionEnvironment);
~CommandStreamReceiverWithAUBDump() override; ~CommandStreamReceiverWithAUBDump() override;
CommandStreamReceiverWithAUBDump(const CommandStreamReceiverWithAUBDump &) = delete; CommandStreamReceiverWithAUBDump(const CommandStreamReceiverWithAUBDump &) = delete;

View File

@@ -5,6 +5,7 @@
* *
*/ */
#include "runtime/aub/aub_center.h"
#include "runtime/command_stream/command_stream_receiver_with_aub_dump.h" #include "runtime/command_stream/command_stream_receiver_with_aub_dump.h"
#include "runtime/command_stream/aub_command_stream_receiver.h" #include "runtime/command_stream/aub_command_stream_receiver.h"
@@ -13,14 +14,20 @@ namespace OCLRT {
extern CommandStreamReceiverCreateFunc commandStreamReceiverFactory[2 * IGFX_MAX_CORE]; extern CommandStreamReceiverCreateFunc commandStreamReceiverFactory[2 * IGFX_MAX_CORE];
template <typename BaseCSR> template <typename BaseCSR>
CommandStreamReceiverWithAUBDump<BaseCSR>::CommandStreamReceiverWithAUBDump(const HardwareInfo &hwInfoIn, ExecutionEnvironment &executionEnvironment) CommandStreamReceiverWithAUBDump<BaseCSR>::CommandStreamReceiverWithAUBDump(const HardwareInfo &hwInfoIn, const std::string &baseName, ExecutionEnvironment &executionEnvironment)
: BaseCSR(hwInfoIn, executionEnvironment) { : BaseCSR(hwInfoIn, executionEnvironment) {
aubCSR = AUBCommandStreamReceiver::create(hwInfoIn, "aubfile", false, executionEnvironment); bool createAubCsr = !executionEnvironment.aubCenter || executionEnvironment.aubCenter->getAubManager() == nullptr;
if (createAubCsr) {
aubCSR = AUBCommandStreamReceiver::create(hwInfoIn, baseName, false, executionEnvironment);
}
} }
template <typename BaseCSR> template <typename BaseCSR>
CommandStreamReceiverWithAUBDump<BaseCSR>::~CommandStreamReceiverWithAUBDump() { CommandStreamReceiverWithAUBDump<BaseCSR>::~CommandStreamReceiverWithAUBDump() {
delete aubCSR; if (aubCSR) {
delete aubCSR;
}
} }
template <typename BaseCSR> template <typename BaseCSR>

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018 Intel Corporation * Copyright (C) 2018-2019 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@@ -29,13 +29,13 @@ CommandStreamReceiver *createCommandStreamImpl(const HardwareInfo *pHwInfo, Exec
commandStreamReceiver = AUBCommandStreamReceiver::create(*pHwInfo, "aubfile", true, executionEnvironment); commandStreamReceiver = AUBCommandStreamReceiver::create(*pHwInfo, "aubfile", true, executionEnvironment);
break; break;
case CSR_TBX: case CSR_TBX:
commandStreamReceiver = TbxCommandStreamReceiver::create(*pHwInfo, false, executionEnvironment); commandStreamReceiver = TbxCommandStreamReceiver::create(*pHwInfo, "", false, executionEnvironment);
break; break;
case CSR_HW_WITH_AUB: case CSR_HW_WITH_AUB:
commandStreamReceiver = funcCreate(*pHwInfo, true, executionEnvironment); commandStreamReceiver = funcCreate(*pHwInfo, true, executionEnvironment);
break; break;
case CSR_TBX_WITH_AUB: case CSR_TBX_WITH_AUB:
commandStreamReceiver = TbxCommandStreamReceiver::create(*pHwInfo, true, executionEnvironment); commandStreamReceiver = TbxCommandStreamReceiver::create(*pHwInfo, "aubfile", true, executionEnvironment);
break; break;
default: default:
break; break;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2017-2018 Intel Corporation * Copyright (C) 2017-2019 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@@ -14,7 +14,7 @@ namespace OCLRT {
TbxCommandStreamReceiverCreateFunc tbxCommandStreamReceiverFactory[IGFX_MAX_CORE] = {}; TbxCommandStreamReceiverCreateFunc tbxCommandStreamReceiverFactory[IGFX_MAX_CORE] = {};
CommandStreamReceiver *TbxCommandStreamReceiver::create(const HardwareInfo &hwInfo, bool withAubDump, ExecutionEnvironment &executionEnvironment) { CommandStreamReceiver *TbxCommandStreamReceiver::create(const HardwareInfo &hwInfo, const std::string &baseName, bool withAubDump, ExecutionEnvironment &executionEnvironment) {
if (hwInfo.pPlatform->eRenderCoreFamily >= IGFX_MAX_CORE) { if (hwInfo.pPlatform->eRenderCoreFamily >= IGFX_MAX_CORE) {
DEBUG_BREAK_IF(!false); DEBUG_BREAK_IF(!false);
@@ -23,6 +23,6 @@ CommandStreamReceiver *TbxCommandStreamReceiver::create(const HardwareInfo &hwIn
auto pCreate = tbxCommandStreamReceiverFactory[hwInfo.pPlatform->eRenderCoreFamily]; auto pCreate = tbxCommandStreamReceiverFactory[hwInfo.pPlatform->eRenderCoreFamily];
return pCreate ? pCreate(hwInfo, withAubDump, executionEnvironment) : nullptr; return pCreate ? pCreate(hwInfo, baseName, withAubDump, executionEnvironment) : nullptr;
} }
} // namespace OCLRT } // namespace OCLRT

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2017-2018 Intel Corporation * Copyright (C) 2017-2019 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@@ -45,10 +45,10 @@ class TbxStream : public AubMemDump::AubStream {
}; };
struct TbxCommandStreamReceiver { struct TbxCommandStreamReceiver {
static CommandStreamReceiver *create(const HardwareInfo &hwInfo, bool withAubDump, ExecutionEnvironment &executionEnvironment); static CommandStreamReceiver *create(const HardwareInfo &hwInfo, const std::string &baseName, bool withAubDump, ExecutionEnvironment &executionEnvironment);
using TbxStream = OCLRT::TbxStream; using TbxStream = OCLRT::TbxStream;
}; };
typedef CommandStreamReceiver *(*TbxCommandStreamReceiverCreateFunc)(const HardwareInfo &hwInfoIn, bool withAubDump, ExecutionEnvironment &executionEnvironment); typedef CommandStreamReceiver *(*TbxCommandStreamReceiverCreateFunc)(const HardwareInfo &hwInfoIn, const std::string &baseName, bool withAubDump, ExecutionEnvironment &executionEnvironment);
} // namespace OCLRT } // namespace OCLRT

View File

@@ -55,7 +55,7 @@ class TbxCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
MOCKABLE_VIRTUAL void submitBatchBuffer(uint64_t batchBufferGpuAddress, const void *batchBuffer, size_t batchBufferSize, uint32_t memoryBank, uint64_t entryBits); MOCKABLE_VIRTUAL void submitBatchBuffer(uint64_t batchBufferGpuAddress, const void *batchBuffer, size_t batchBufferSize, uint32_t memoryBank, uint64_t entryBits);
MOCKABLE_VIRTUAL void pollForCompletion(); MOCKABLE_VIRTUAL void pollForCompletion();
static CommandStreamReceiver *create(const HardwareInfo &hwInfoIn, bool withAubDump, ExecutionEnvironment &executionEnvironment); static CommandStreamReceiver *create(const HardwareInfo &hwInfoIn, const std::string &baseName, bool withAubDump, ExecutionEnvironment &executionEnvironment);
TbxCommandStreamReceiverHw(const HardwareInfo &hwInfoIn, ExecutionEnvironment &executionEnvironment); TbxCommandStreamReceiverHw(const HardwareInfo &hwInfoIn, ExecutionEnvironment &executionEnvironment);
~TbxCommandStreamReceiverHw() override; ~TbxCommandStreamReceiverHw() override;

View File

@@ -166,10 +166,14 @@ void TbxCommandStreamReceiverHw<GfxFamily>::initializeEngine() {
} }
template <typename GfxFamily> template <typename GfxFamily>
CommandStreamReceiver *TbxCommandStreamReceiverHw<GfxFamily>::create(const HardwareInfo &hwInfoIn, bool withAubDump, ExecutionEnvironment &executionEnvironment) { CommandStreamReceiver *TbxCommandStreamReceiverHw<GfxFamily>::create(const HardwareInfo &hwInfoIn, const std::string &baseName, bool withAubDump, ExecutionEnvironment &executionEnvironment) {
TbxCommandStreamReceiverHw<GfxFamily> *csr; TbxCommandStreamReceiverHw<GfxFamily> *csr;
if (withAubDump) { if (withAubDump) {
csr = new CommandStreamReceiverWithAUBDump<TbxCommandStreamReceiverHw<GfxFamily>>(hwInfoIn, executionEnvironment); auto &hwHelper = HwHelper::get(hwInfoIn.pPlatform->eRenderCoreFamily);
auto localMemoryEnabled = hwHelper.isLocalMemoryEnabled(hwInfoIn);
executionEnvironment.initAubCenter(&hwInfoIn, localMemoryEnabled, baseName);
csr = new CommandStreamReceiverWithAUBDump<TbxCommandStreamReceiverHw<GfxFamily>>(hwInfoIn, baseName, executionEnvironment);
} else { } else {
csr = new TbxCommandStreamReceiverHw<GfxFamily>(hwInfoIn, executionEnvironment); csr = new TbxCommandStreamReceiverHw<GfxFamily>(hwInfoIn, executionEnvironment);
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2017-2018 Intel Corporation * Copyright (C) 2017-2019 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@@ -16,7 +16,7 @@ namespace OCLRT {
template <typename GfxFamily> template <typename GfxFamily>
CommandStreamReceiver *DeviceCommandStreamReceiver<GfxFamily>::create(const HardwareInfo &hwInfo, bool withAubDump, ExecutionEnvironment &executionEnvironment) { CommandStreamReceiver *DeviceCommandStreamReceiver<GfxFamily>::create(const HardwareInfo &hwInfo, bool withAubDump, ExecutionEnvironment &executionEnvironment) {
if (withAubDump) { if (withAubDump) {
return new CommandStreamReceiverWithAUBDump<DrmCommandStreamReceiver<GfxFamily>>(hwInfo, executionEnvironment); return new CommandStreamReceiverWithAUBDump<DrmCommandStreamReceiver<GfxFamily>>(hwInfo, "aubfile", executionEnvironment);
} else { } else {
return new DrmCommandStreamReceiver<GfxFamily>(hwInfo, executionEnvironment); return new DrmCommandStreamReceiver<GfxFamily>(hwInfo, executionEnvironment);
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2017-2018 Intel Corporation * Copyright (C) 2017-2019 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@@ -20,7 +20,7 @@ namespace OCLRT {
template <typename GfxFamily> template <typename GfxFamily>
CommandStreamReceiver *DeviceCommandStreamReceiver<GfxFamily>::create(const HardwareInfo &hwInfo, bool withAubDump, ExecutionEnvironment &executionEnvironment) { CommandStreamReceiver *DeviceCommandStreamReceiver<GfxFamily>::create(const HardwareInfo &hwInfo, bool withAubDump, ExecutionEnvironment &executionEnvironment) {
if (withAubDump) { if (withAubDump) {
return new CommandStreamReceiverWithAUBDump<WddmCommandStreamReceiver<GfxFamily>>(hwInfo, executionEnvironment); return new CommandStreamReceiverWithAUBDump<WddmCommandStreamReceiver<GfxFamily>>(hwInfo, "aubfile", executionEnvironment);
} else { } else {
return new WddmCommandStreamReceiver<GfxFamily>(hwInfo, executionEnvironment); return new WddmCommandStreamReceiver<GfxFamily>(hwInfo, executionEnvironment);
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2017-2018 Intel Corporation * Copyright (C) 2017-2019 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@@ -45,11 +45,13 @@ void AubWriteCopyReadBuffer::runTest() {
retVal)); retVal));
ASSERT_NE(nullptr, dstBuffer); ASSERT_NE(nullptr, dstBuffer);
aubCsr->writeMemory(*srcBuffer->getGraphicsAllocation()); if (aubCsr) {
aubCsr->writeMemory(*dstBuffer->getGraphicsAllocation()); aubCsr->writeMemory(*srcBuffer->getGraphicsAllocation());
aubCsr->writeMemory(*dstBuffer->getGraphicsAllocation());
getAubCsr<FamilyType>()->expectMemoryEqual(AUBFixture::getGpuPointer(srcBuffer->getGraphicsAllocation()), srcMemoryInitial, bufferSize); aubCsr->expectMemoryEqual(AUBFixture::getGpuPointer(srcBuffer->getGraphicsAllocation()), srcMemoryInitial, bufferSize);
getAubCsr<FamilyType>()->expectMemoryEqual(AUBFixture::getGpuPointer(dstBuffer->getGraphicsAllocation()), dstMemoryInitial, bufferSize); aubCsr->expectMemoryEqual(AUBFixture::getGpuPointer(dstBuffer->getGraphicsAllocation()), dstMemoryInitial, bufferSize);
}
cl_uint numEventsInWaitList = 0; cl_uint numEventsInWaitList = 0;
cl_event *eventWaitList = nullptr; cl_event *eventWaitList = nullptr;
@@ -79,8 +81,10 @@ void AubWriteCopyReadBuffer::runTest() {
EXPECT_EQ(CL_SUCCESS, retVal); EXPECT_EQ(CL_SUCCESS, retVal);
getAubCsr<FamilyType>()->expectMemoryEqual(AUBFixture::getGpuPointer(srcBuffer->getGraphicsAllocation()), srcMemoryToWrite, bufferSize); if (aubCsr) {
getAubCsr<FamilyType>()->expectMemoryEqual(AUBFixture::getGpuPointer(dstBuffer->getGraphicsAllocation()), dstMemoryToWrite, bufferSize); aubCsr->expectMemoryEqual(AUBFixture::getGpuPointer(srcBuffer->getGraphicsAllocation()), srcMemoryToWrite, bufferSize);
aubCsr->expectMemoryEqual(AUBFixture::getGpuPointer(dstBuffer->getGraphicsAllocation()), dstMemoryToWrite, bufferSize);
}
retVal = pCmdQ->enqueueCopyBuffer( retVal = pCmdQ->enqueueCopyBuffer(
srcBuffer.get(), srcBuffer.get(),
@@ -96,8 +100,10 @@ void AubWriteCopyReadBuffer::runTest() {
pCmdQ->flush(); pCmdQ->flush();
// Destination buffer should have src buffer content if (aubCsr) {
getAubCsr<FamilyType>()->expectMemoryEqual(AUBFixture::getGpuPointer(dstBuffer->getGraphicsAllocation()), srcMemoryToWrite, bufferSize); // 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}; char hostPtrMemory[] = {0, 0, 0, 0, 0, 0, 0, 0};
ASSERT_EQ(bufferSize, sizeof(hostPtrMemory)); ASSERT_EQ(bufferSize, sizeof(hostPtrMemory));
@@ -119,7 +125,9 @@ void AubWriteCopyReadBuffer::runTest() {
allocation = allocation->next; allocation = allocation->next;
} }
getAubCsr<FamilyType>()->expectMemoryEqual(AUBFixture::getGpuPointer(allocation), srcMemoryToWrite, bufferSize); if (aubCsr) {
aubCsr->expectMemoryEqual(AUBFixture::getGpuPointer(allocation), srcMemoryToWrite, bufferSize);
}
} }
HWTEST_F(AubWriteCopyReadBuffer, givenTwoBuffersFilledWithPatternWhenSourceIsCopiedToDestinationThenDestinationDataValidates) { 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 * 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; strfilename << testInfo->test_case_name() << "_" << testInfo->name() << "_" << hwHelper.getCsTraits(engineType.type).name;
if (testMode == TestMode::AubTestsWithTbx) { if (testMode == TestMode::AubTestsWithTbx) {
pCommandStreamReceiver = TbxCommandStreamReceiver::create(hwInfo, true, *device.executionEnvironment); pCommandStreamReceiver = TbxCommandStreamReceiver::create(hwInfo, strfilename.str(), true, *device.executionEnvironment);
} else { } else {
pCommandStreamReceiver = AUBCommandStreamReceiver::create(hwInfo, strfilename.str(), true, *device.executionEnvironment); pCommandStreamReceiver = AUBCommandStreamReceiver::create(hwInfo, strfilename.str(), true, *device.executionEnvironment);
} }

View File

@@ -37,7 +37,7 @@ class AUBFixture : public CommandQueueHwFixture {
executionEnvironment = new ExecutionEnvironment; executionEnvironment = new ExecutionEnvironment;
if (testMode == TestMode::AubTestsWithTbx) { if (testMode == TestMode::AubTestsWithTbx) {
this->csr = TbxCommandStreamReceiver::create(hwInfo, true, *executionEnvironment); this->csr = TbxCommandStreamReceiver::create(hwInfo, strfilename.str(), true, *executionEnvironment);
} else { } else {
this->csr = AUBCommandStreamReceiver::create(hwInfo, strfilename.str(), true, *executionEnvironment); this->csr = AUBCommandStreamReceiver::create(hwInfo, strfilename.str(), true, *executionEnvironment);
} }
@@ -70,13 +70,17 @@ class AUBFixture : public CommandQueueHwFixture {
template <typename FamilyType> template <typename FamilyType>
void expectMemory(void *gfxAddress, const void *srcAddress, size_t length) { void expectMemory(void *gfxAddress, const void *srcAddress, size_t length) {
auto aubCsr = getAubCsr<FamilyType>(); auto aubCsr = getAubCsr<FamilyType>();
aubCsr->expectMemoryEqual(gfxAddress, srcAddress, length); if (aubCsr) {
aubCsr->expectMemoryEqual(gfxAddress, srcAddress, length);
}
} }
template <typename FamilyType> template <typename FamilyType>
void expectNotEqualMemory(void *gfxAddress, const void *srcAddress, size_t length) { void expectNotEqualMemory(void *gfxAddress, const void *srcAddress, size_t length) {
auto aubCsr = getAubCsr<FamilyType>(); auto aubCsr = getAubCsr<FamilyType>();
aubCsr->expectMemoryNotEqual(gfxAddress, srcAddress, length); if (aubCsr) {
aubCsr->expectMemoryNotEqual(gfxAddress, srcAddress, length);
}
} }
static void *getGpuPointer(GraphicsAllocation *allocation) { 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.h"
#include "runtime/command_stream/command_stream_receiver_with_aub_dump.inl" #include "runtime/command_stream/command_stream_receiver_with_aub_dump.inl"
#include "runtime/command_stream/preemption.h" #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/execution_environment/execution_environment.h"
#include "runtime/helpers/dispatch_info.h" #include "runtime/helpers/dispatch_info.h"
#include "runtime/os_interface/os_context.h" #include "runtime/os_interface/os_context.h"
#include "unit_tests/mocks/mock_allocation_properties.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" #include "test.h"
@@ -87,7 +90,7 @@ struct MyMockCsr : UltCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> {
template <typename BaseCSR> template <typename BaseCSR>
struct MyMockCsrWithAubDump : CommandStreamReceiverWithAUBDump<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) { if (this->aubCSR != nullptr) {
delete this->aubCSR; delete this->aubCSR;
this->aubCSR = nullptr; this->aubCSR = nullptr;
@@ -134,7 +137,7 @@ using CommandStreamReceiverWithAubDumpSimpleTest = ::testing::Test;
HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenCsrWithAubDumpWhenSettingOsContextThenReplicateItToAubCsr) { HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenCsrWithAubDumpWhenSettingOsContextThenReplicateItToAubCsr) {
ExecutionEnvironment executionEnvironment; 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])); OsContext osContext(nullptr, 0, HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
csrWithAubDump.setupContext(osContext); csrWithAubDump.setupContext(osContext);
@@ -142,6 +145,28 @@ HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenCsrWithAubDumpWhenSett
EXPECT_EQ(&osContext, &csrWithAubDump.aubCSR->getOsContext()); 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) { HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenCtorIsCalledThenAubCsrIsInitialized) {
if (createAubCSR) { if (createAubCSR) {
EXPECT_NE(nullptr, csrWithAubDump->aubCSR); 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 * SPDX-License-Identifier: MIT
* *
@@ -18,7 +18,7 @@ namespace OCLRT {
void TbxCommandStreamFixture::SetUp(MockDevice *pDevice) { void TbxCommandStreamFixture::SetUp(MockDevice *pDevice) {
// Create our TBX command stream receiver based on HW type // Create our TBX command stream receiver based on HW type
const auto &hwInfo = pDevice->getHardwareInfo(); const auto &hwInfo = pDevice->getHardwareInfo();
pCommandStreamReceiver = TbxCommandStreamReceiver::create(hwInfo, false, *pDevice->executionEnvironment); pCommandStreamReceiver = TbxCommandStreamReceiver::create(hwInfo, "", false, *pDevice->executionEnvironment);
ASSERT_NE(nullptr, pCommandStreamReceiver); ASSERT_NE(nullptr, pCommandStreamReceiver);
mmTbx = pCommandStreamReceiver->createMemoryManager(false, false); mmTbx = pCommandStreamReceiver->createMemoryManager(false, false);
pDevice->resetCommandStreamReceiver(pCommandStreamReceiver); pDevice->resetCommandStreamReceiver(pCommandStreamReceiver);

View File

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