Cleanup tbx command stream receiver tests

Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2021-12-20 21:13:39 +00:00
committed by Compute-Runtime-Automation
parent 17f82bbe12
commit 2efcf1f62b
6 changed files with 72 additions and 76 deletions

View File

@@ -12,6 +12,7 @@ set(IGDRCL_SRCS_tests_command_stream
${CMAKE_CURRENT_SOURCE_DIR}/aub_file_stream_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/aub_subcapture_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cl_command_stream_receiver_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cl_tbx_command_stream_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/command_stream_fixture.h
${CMAKE_CURRENT_SOURCE_DIR}/command_stream_receiver_hw_1_tests.cpp

View File

@@ -0,0 +1,53 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/engine_control.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/engine_descriptor_helper.h"
#include "shared/test/common/mocks/mock_tbx_csr.h"
#include "shared/test/common/test_macros/test.h"
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
#include "opencl/test/unit_test/mocks/mock_command_queue.h"
#include "opencl/test/unit_test/mocks/mock_context.h"
#include "opencl/test/unit_test/mocks/mock_os_context.h"
using namespace NEO;
using ClTbxCommandStreamTests = Test<ClDeviceFixture>;
HWTEST_F(ClTbxCommandStreamTests, givenTbxCsrWhenDispatchBlitEnqueueThenProcessCorrectly) {
DebugManagerStateRestore dbgRestore;
DebugManager.flags.EnableBlitterOperationsSupport.set(1);
DebugManager.flags.EnableBlitterForEnqueueOperations.set(1);
MockContext context(pClDevice);
MockTbxCsr<FamilyType> tbxCsr0{*pDevice->executionEnvironment, pDevice->getDeviceBitfield()};
tbxCsr0.initializeTagAllocation();
MockTbxCsr<FamilyType> tbxCsr1{*pDevice->executionEnvironment, pDevice->getDeviceBitfield()};
tbxCsr1.initializeTagAllocation();
MockOsContext osContext0(0, EngineDescriptorHelper::getDefaultDescriptor(pDevice->getDeviceBitfield()));
tbxCsr0.setupContext(osContext0);
EngineControl engineControl0{&tbxCsr0, &osContext0};
MockOsContext osContext1(1, EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_BCS, EngineUsage::Regular}, pDevice->getDeviceBitfield()));
tbxCsr1.setupContext(osContext0);
EngineControl engineControl1{&tbxCsr1, &osContext1};
MockCommandQueueHw<FamilyType> cmdQ(&context, pClDevice, nullptr);
cmdQ.gpgpuEngine = &engineControl0;
cmdQ.clearBcsEngines();
cmdQ.bcsEngines[0] = &engineControl1;
cl_int error = CL_SUCCESS;
std::unique_ptr<Buffer> buffer(Buffer::create(&context, 0, 1, nullptr, error));
uint32_t hostPtr = 0;
error = cmdQ.enqueueWriteBuffer(buffer.get(), CL_TRUE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, error);
}

View File

@@ -8,12 +8,9 @@
#include "opencl/test/unit_test/command_stream/tbx_command_stream_fixture.h"
#include "shared/source/command_stream/command_stream_receiver.h"
#include "shared/source/device/device.h"
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
#include "shared/source/command_stream/tbx_command_stream_receiver_hw.h"
#include "shared/test/common/mocks/mock_device.h"
#include "opencl/source/command_queue/command_queue.h"
#include "gtest/gtest.h"
namespace NEO {
@@ -28,6 +25,5 @@ void TbxCommandStreamFixture::SetUp(MockDevice *pDevice) {
void TbxCommandStreamFixture::TearDown() {
delete memoryManager;
CommandStreamFixture::TearDown();
}
} // namespace NEO

View File

@@ -6,21 +6,17 @@
*/
#pragma once
#include "shared/source/command_stream/tbx_command_stream_receiver_hw.h"
#include "opencl/test/unit_test/command_stream/command_stream_fixture.h"
#include <cstdint>
namespace NEO {
class CommandStreamReceiver;
class MockDevice;
class MemoryManager;
class TbxCommandStreamFixture : public CommandStreamFixture {
class TbxCommandStreamFixture {
public:
virtual void SetUp(MockDevice *pDevice);
void TearDown(void) override;
void SetUp(MockDevice *pDevice);
void TearDown();
CommandStreamReceiver *pCommandStreamReceiver = nullptr;

View File

@@ -9,29 +9,28 @@
#include "shared/source/memory_manager/memory_banks.h"
#include "shared/source/memory_manager/memory_pool.h"
#include "shared/source/memory_manager/physical_address_allocator.h"
#include "shared/test/common/fixtures/device_fixture.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/hw_helper_tests.h"
#include "shared/test/common/mocks/mock_graphics_allocation.h"
#include "shared/test/common/test_macros/test.h"
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
using namespace NEO;
struct XeHPAndLaterTbxCommandStreamReceiverTests : ClDeviceFixture, ::testing::Test {
struct XeHPAndLaterTbxCommandStreamReceiverTests : DeviceFixture, ::testing::Test {
template <typename FamilyType>
void setUpImpl() {
hardwareInfo = *defaultHwInfo;
hardwareInfoSetup[hardwareInfo.platform.eProductFamily](&hardwareInfo, true, 0);
hardwareInfo.gtSystemInfo.MultiTileArchInfo.IsValid = true;
ClDeviceFixture::SetUpImpl(&hardwareInfo);
DeviceFixture::SetUpImpl(&hardwareInfo);
}
void SetUp() override {
}
void TearDown() override {
ClDeviceFixture::TearDown();
DeviceFixture::TearDown();
}
};

View File

@@ -6,8 +6,6 @@
*/
#include "shared/source/aub_mem_dump/aub_alloc_dump.h"
#include "shared/source/command_stream/aub_command_stream_receiver.h"
#include "shared/source/command_stream/command_stream_receiver_hw.h"
#include "shared/source/command_stream/command_stream_receiver_with_aub_dump.h"
#include "shared/source/command_stream/tbx_command_stream_receiver_hw.h"
#include "shared/source/debug_settings/debug_settings_manager.h"
@@ -16,33 +14,20 @@
#include "shared/source/helpers/hw_helper.h"
#include "shared/source/helpers/ptr_math.h"
#include "shared/source/memory_manager/memory_banks.h"
#include "shared/source/os_interface/os_context.h"
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
#include "shared/test/common/fixtures/device_fixture.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/engine_descriptor_helper.h"
#include "shared/test/common/helpers/variable_backup.h"
#include "shared/test/common/mocks/mock_allocation_properties.h"
#include "shared/test/common/mocks/mock_aub_center.h"
#include "shared/test/common/mocks/mock_aub_manager.h"
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "shared/test/common/mocks/mock_graphics_allocation.h"
#include "shared/test/common/mocks/mock_tbx_csr.h"
#include "shared/test/common/test_macros/test.h"
#include "shared/test/unit_test/fixtures/mock_aub_center_fixture.h"
#include "opencl/source/mem_obj/buffer.h"
#include "opencl/source/mem_obj/mem_obj.h"
#include "opencl/source/platform/platform.h"
#include "opencl/test/unit_test/command_queue/command_queue_fixture.h"
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
#include "opencl/test/unit_test/command_stream/tbx_command_stream_fixture.h"
#include "opencl/test/unit_test/mocks/mock_aub_subcapture_manager.h"
#include "opencl/test/unit_test/mocks/mock_command_queue.h"
#include "opencl/test/unit_test/mocks/mock_kernel.h"
#include "opencl/test/unit_test/mocks/mock_mdi.h"
#include "opencl/test/unit_test/mocks/mock_os_context.h"
#include "opencl/test/unit_test/mocks/mock_platform.h"
#include "tbx_command_stream_fixture.h"
#include <cstdint>
@@ -53,7 +38,7 @@ extern TbxCommandStreamReceiverCreateFunc tbxCommandStreamReceiverFactory[IGFX_M
} // namespace NEO
struct TbxFixture : public TbxCommandStreamFixture,
public ClDeviceFixture,
public DeviceFixture,
public MockAubCenterFixture {
using TbxCommandStreamFixture::SetUp;
@@ -61,16 +46,16 @@ struct TbxFixture : public TbxCommandStreamFixture,
TbxFixture() : MockAubCenterFixture(CommandStreamReceiverType::CSR_TBX) {}
void SetUp() {
ClDeviceFixture::SetUp();
DeviceFixture::SetUp();
setMockAubCenter(*pDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]);
TbxCommandStreamFixture::SetUp(pDevice);
MockAubCenterFixture::SetUp();
}
void TearDown() override {
void TearDown() {
MockAubCenterFixture::TearDown();
TbxCommandStreamFixture::TearDown();
ClDeviceFixture::TearDown();
DeviceFixture::TearDown();
}
};
@@ -88,7 +73,7 @@ struct MockTbxCsrToTestDumpTbxNonWritable : public TbxCommandStreamReceiverHw<Gf
};
TEST(TbxCommandStreamReceiverTest, givenNullFactoryEntryWhenTbxCsrIsCreatedThenNullptrIsReturned) {
ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment();
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
GFXCORE_FAMILY family = executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo()->platform.eRenderCoreFamily;
VariableBackup<TbxCommandStreamReceiverCreateFunc> tbxCsrFactoryBackup(&tbxCommandStreamReceiverFactory[family]);
@@ -99,8 +84,7 @@ TEST(TbxCommandStreamReceiverTest, givenNullFactoryEntryWhenTbxCsrIsCreatedThenN
}
TEST(TbxCommandStreamReceiverTest, givenTbxCommandStreamReceiverWhenItIsCreatedWithWrongGfxCoreFamilyThenNullPointerShouldBeReturned) {
ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment();
executionEnvironment->prepareRootDeviceEnvironments(1u);
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto hwInfo = executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo();
hwInfo->platform.eRenderCoreFamily = GFXCORE_FAMILY_FORCE_ULONG; // wrong gfx core family
@@ -110,7 +94,7 @@ TEST(TbxCommandStreamReceiverTest, givenTbxCommandStreamReceiverWhenItIsCreatedW
}
TEST(TbxCommandStreamReceiverTest, givenTbxCommandStreamReceiverWhenTypeIsCheckedThenTbxCsrIsReturned) {
ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment();
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
executionEnvironment->initializeMemoryManager();
std::unique_ptr<CommandStreamReceiver> csr(TbxCommandStreamReceiver::create("", false, *executionEnvironment, 0, 1));
EXPECT_NE(nullptr, csr);
@@ -899,39 +883,6 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCsrInNonSubCaptureModeWhenCheckAndActiva
EXPECT_FALSE(status.wasActiveInPreviousEnqueue);
}
HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenDispatchBlitEnqueueThenProcessCorrectly) {
DebugManagerStateRestore dbgRestore;
DebugManager.flags.EnableBlitterOperationsSupport.set(1);
DebugManager.flags.EnableBlitterForEnqueueOperations.set(1);
MockContext context(pClDevice);
MockTbxCsr<FamilyType> tbxCsr0{*pDevice->executionEnvironment, pDevice->getDeviceBitfield()};
tbxCsr0.initializeTagAllocation();
MockTbxCsr<FamilyType> tbxCsr1{*pDevice->executionEnvironment, pDevice->getDeviceBitfield()};
tbxCsr1.initializeTagAllocation();
MockOsContext osContext0(0, EngineDescriptorHelper::getDefaultDescriptor(pDevice->getDeviceBitfield()));
tbxCsr0.setupContext(osContext0);
EngineControl engineControl0{&tbxCsr0, &osContext0};
MockOsContext osContext1(1, EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_BCS, EngineUsage::Regular}, pDevice->getDeviceBitfield()));
tbxCsr1.setupContext(osContext0);
EngineControl engineControl1{&tbxCsr1, &osContext1};
MockCommandQueueHw<FamilyType> cmdQ(&context, pClDevice, nullptr);
cmdQ.gpgpuEngine = &engineControl0;
cmdQ.clearBcsEngines();
cmdQ.bcsEngines[0] = &engineControl1;
cl_int error = CL_SUCCESS;
std::unique_ptr<Buffer> buffer(Buffer::create(&context, 0, 1, nullptr, error));
uint32_t hostPtr = 0;
error = cmdQ.enqueueWriteBuffer(buffer.get(), CL_TRUE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, error);
}
HWTEST_F(TbxCommandStreamTests, givenGraphicsAllocationWhenDumpAllocationIsCalledButBcsIsUsedThenGraphicsAllocationShouldNotBeDumped) {
MockTbxCsr<FamilyType> tbxCsr(*pDevice->executionEnvironment, pDevice->getDeviceBitfield());
MockOsContext osContext(0, EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_BCS, EngineUsage::Regular}, pDevice->getDeviceBitfield()));