Add multicontext aub fixture

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski
2022-01-19 11:33:02 +00:00
committed by Compute-Runtime-Automation
parent ad7f2f1f6e
commit f88267161e
4 changed files with 366 additions and 0 deletions

View File

@@ -9,6 +9,9 @@ target_sources(igdrcl_aub_tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/aub_fixture.cpp
${CMAKE_CURRENT_SOURCE_DIR}/aub_fixture.h
${CMAKE_CURRENT_SOURCE_DIR}/hello_world_fixture.h
${CMAKE_CURRENT_SOURCE_DIR}/multicontext_aub_fixture.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}multicontext_aub_fixture_extended.cpp
${CMAKE_CURRENT_SOURCE_DIR}/multicontext_aub_fixture.h
${CMAKE_CURRENT_SOURCE_DIR}/run_kernel_fixture.h
${CMAKE_CURRENT_SOURCE_DIR}/simple_arg_fixture.h
${CMAKE_CURRENT_SOURCE_DIR}/unified_memory_fixture.h

View File

@@ -0,0 +1,236 @@
/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "opencl/test/unit_test/aub_tests/fixtures/multicontext_aub_fixture.h"
#include "shared/source/command_stream/aub_command_stream_receiver.h"
#include "shared/source/helpers/api_specific_config.h"
#include "shared/source/helpers/hw_helper.h"
#include "shared/test/common/helpers/ult_hw_config.h"
#include "shared/test/common/helpers/variable_backup.h"
#include "shared/test/common/mocks/mock_device.h"
#include "shared/test/common/test_macros/test.h"
#include "shared/test/unit_test/tests_configuration.h"
#include "opencl/source/cl_device/cl_device.h"
#include "opencl/source/platform/platform.h"
#include "opencl/test/unit_test/mocks/mock_context.h"
#include "opencl/test/unit_test/mocks/mock_platform.h"
namespace NEO {
void MulticontextAubFixture::SetUp(uint32_t numberOfTiles, EnabledCommandStreamers enabledCommandStreamers, bool enableCompression) {
this->numberOfEnabledTiles = numberOfTiles;
const ::testing::TestInfo *const testInfo = ::testing::UnitTest::GetInstance()->current_test_info();
cl_int retVal = CL_SUCCESS;
DebugManager.flags.CsrDispatchMode.set(static_cast<int32_t>(DispatchMode::BatchedDispatch));
DebugManager.flags.CreateMultipleSubDevices.set(numberOfTiles);
if (testMode == TestMode::AubTestsWithTbx) {
DebugManager.flags.SetCommandStreamReceiver.set(static_cast<int32_t>(CommandStreamReceiverType::CSR_TBX_WITH_AUB));
} else {
DebugManager.flags.SetCommandStreamReceiver.set(static_cast<int32_t>(CommandStreamReceiverType::CSR_AUB));
}
HardwareInfo localHwInfo = *defaultHwInfo;
if ((EnabledCommandStreamers::All == enabledCommandStreamers) && localHwInfo.gtSystemInfo.SliceCount < 8) {
overridePlatformConfigForAllEnginesSupport(localHwInfo);
}
if (numberOfTiles > 1) {
localHwInfo.gtSystemInfo.MultiTileArchInfo.IsValid = (numberOfEnabledTiles > 1) ? 1 : 0;
localHwInfo.gtSystemInfo.MultiTileArchInfo.TileCount = numberOfEnabledTiles;
localHwInfo.gtSystemInfo.MultiTileArchInfo.TileMask = 0;
for (uint32_t i = 0; i < numberOfEnabledTiles; i++) {
localHwInfo.gtSystemInfo.MultiTileArchInfo.TileMask |= (1 << i);
}
}
localHwInfo.capabilityTable.blitterOperationsSupported = true;
if (DebugManager.flags.EnableBlitterOperationsSupport.get() != -1) {
localHwInfo.capabilityTable.blitterOperationsSupported = !!DebugManager.flags.EnableBlitterOperationsSupport.get();
}
auto &hwHelper = HwHelper::get(localHwInfo.platform.eRenderCoreFamily);
auto engineType = getChosenEngineType(localHwInfo);
auto renderEngine = aub_stream::NUM_ENGINES;
for (auto &engine : hwHelper.getGpgpuEngineInstances(localHwInfo)) {
if (!EngineHelpers::isCcs(engine.first)) {
renderEngine = engine.first;
break;
}
}
ASSERT_NE(aub_stream::NUM_ENGINES, renderEngine);
auto renderEngineName = hwHelper.getCsTraits(renderEngine).name;
std::stringstream strfilename;
strfilename << ApiSpecificConfig::getAubPrefixForSpecificApi();
strfilename << testInfo->test_case_name() << "_" << testInfo->name() << "_";
if (EnabledCommandStreamers::Single == enabledCommandStreamers) {
strfilename << renderEngineName;
} else if (EnabledCommandStreamers::Dual == enabledCommandStreamers) {
strfilename << renderEngineName << "_CCS0";
} else if (EnabledCommandStreamers::All == enabledCommandStreamers) {
strfilename << renderEngineName << "_CCS0_3"; // xehp_config_name_RCS_CCS0_3.aub
}
auto filename = AUBCommandStreamReceiver::createFullFilePath(localHwInfo, strfilename.str(), rootDeviceIndex);
DebugManager.flags.AUBDumpCaptureFileName.set(filename);
auto createCommandQueueForEngine = [&](uint32_t tileNumber, size_t engineFamily, size_t engineIndex) {
cl_queue_properties properties[] = {CL_QUEUE_FAMILY_INTEL, engineFamily, CL_QUEUE_INDEX_INTEL, engineIndex, 0};
auto clQueue = clCreateCommandQueueWithProperties(context.get(), tileDevices[tileNumber], properties, &retVal);
EXPECT_EQ(CL_SUCCESS, retVal);
return std::unique_ptr<CommandQueue>(castToObject<CommandQueue>(clQueue));
};
DebugManager.flags.RenderCompressedBuffersEnabled.set(enableCompression);
DebugManager.flags.RenderCompressedImagesEnabled.set(enableCompression);
DebugManager.flags.EnableBlitterForEnqueueOperations.set(false);
platformsImpl->clear();
VariableBackup<UltHwConfig> backup(&ultHwConfig);
ultHwConfig.useHwCsr = true;
constructPlatform()->peekExecutionEnvironment()->prepareRootDeviceEnvironments(1u);
platform()->peekExecutionEnvironment()->rootDeviceEnvironments[rootDeviceIndex]->setHwInfo(&localHwInfo);
initPlatform();
rootDevice = platform()->getClDevice(0);
EXPECT_EQ(rootDeviceIndex, rootDevice->getRootDeviceIndex());
{
cl_device_id deviceId = rootDevice;
ClDeviceVector clDeviceVector{&deviceId, 1};
if (numberOfTiles > 1) {
for (uint32_t i = 0; i < numberOfTiles; i++) {
clDeviceVector.push_back(rootDevice->getNearestGenericSubDevice(i));
}
}
context.reset(MockContext::create<MockContext>(nullptr, clDeviceVector, nullptr, nullptr, retVal));
EXPECT_EQ(CL_SUCCESS, retVal);
}
commandQueues.resize(numberOfTiles);
for (uint32_t tile = 0; tile < numberOfTiles; tile++) {
tileDevices.push_back(rootDevice->getNearestGenericSubDevice(tile));
EXPECT_NE(nullptr, tileDevices[tile]);
if (EnabledCommandStreamers::Single == enabledCommandStreamers) {
if (EngineHelpers::isCcs(engineType)) {
auto familyQueue = tileDevices[tile]->getDevice().getEngineGroupIndexFromEngineGroupType(EngineGroupType::Compute);
commandQueues[tile].push_back(createCommandQueueForEngine(tile, familyQueue, 0));
} else {
auto familyQueue = tileDevices[tile]->getDevice().getEngineGroupIndexFromEngineGroupType(EngineGroupType::RenderCompute);
commandQueues[tile].push_back(createCommandQueueForEngine(tile, familyQueue, 0));
}
} else if (EnabledCommandStreamers::Dual == enabledCommandStreamers) {
auto rcsQueue = tileDevices[tile]->getDevice().getEngineGroupIndexFromEngineGroupType(EngineGroupType::RenderCompute);
auto ccsQueue = tileDevices[tile]->getDevice().getEngineGroupIndexFromEngineGroupType(EngineGroupType::Compute);
commandQueues[tile].push_back(createCommandQueueForEngine(tile, rcsQueue, 0));
commandQueues[tile].push_back(createCommandQueueForEngine(tile, ccsQueue, 0));
} else if (EnabledCommandStreamers::All == enabledCommandStreamers) {
auto rcsQueue = tileDevices[tile]->getDevice().getEngineGroupIndexFromEngineGroupType(EngineGroupType::RenderCompute);
auto ccsQueue = tileDevices[tile]->getDevice().getEngineGroupIndexFromEngineGroupType(EngineGroupType::Compute);
commandQueues[tile].push_back(createCommandQueueForEngine(tile, rcsQueue, 0));
commandQueues[tile].push_back(createCommandQueueForEngine(tile, ccsQueue, 0));
commandQueues[tile].push_back(createCommandQueueForEngine(tile, ccsQueue, 1));
commandQueues[tile].push_back(createCommandQueueForEngine(tile, ccsQueue, 2));
commandQueues[tile].push_back(createCommandQueueForEngine(tile, ccsQueue, 3));
}
}
{
cl_int retVal = CL_SUCCESS;
cl_device_id deviceId = rootDevice;
multiTileDefaultContext.reset(MockContext::create<MockContext>(nullptr, ClDeviceVector(&deviceId, 1), nullptr, nullptr, retVal));
EXPECT_EQ(CL_SUCCESS, retVal);
}
}
void MulticontextAubFixture::TearDown() {
auto filename = DebugManager.flags.AUBDumpCaptureFileName.get();
std::string tileString = std::to_string(numberOfEnabledTiles) + "tx";
if (numberOfEnabledTiles > 1) {
EXPECT_NE(std::string::npos, filename.find(tileString));
} else {
EXPECT_EQ(std::string::npos, filename.find(tileString));
}
}
void MulticontextAubFixture::overridePlatformConfigForAllEnginesSupport(HardwareInfo &localHwInfo) {
const ::testing::TestInfo *const testInfo = ::testing::UnitTest::GetInstance()->current_test_info();
printf("\nWARNING: Platform configuration for %s_%s test forced to %dtx8x4x16\n",
testInfo->test_case_name(), testInfo->name(), numberOfEnabledTiles);
bool setupCalled = false;
if (localHwInfo.platform.eRenderCoreFamily == IGFX_XE_HP_CORE) {
#ifdef SUPPORT_XE_HP_SDV
if (localHwInfo.platform.eProductFamily == IGFX_XE_HP_SDV) {
setupCalled = true;
XE_HP_SDV_CONFIG::setupHardwareInfoMultiTile(&localHwInfo, true, true);
// Mock values
localHwInfo.gtSystemInfo.SliceCount = 8;
localHwInfo.gtSystemInfo.SubSliceCount = 32;
localHwInfo.gtSystemInfo.EUCount = 512;
localHwInfo.gtSystemInfo.CCSInfo.IsValid = true;
localHwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 4;
localHwInfo.gtSystemInfo.CCSInfo.Instances.CCSEnableMask = 0b1111;
}
#endif
}
if (localHwInfo.platform.eRenderCoreFamily == IGFX_XE_HPG_CORE) {
#ifdef SUPPORT_DG2
if (localHwInfo.platform.eProductFamily == IGFX_DG2) {
ASSERT_TRUE(numberOfEnabledTiles == 1);
setupCalled = true;
DG2_CONFIG::setupHardwareInfoMultiTile(&localHwInfo, true, false);
// Mock values
localHwInfo.gtSystemInfo.SliceCount = 8;
localHwInfo.gtSystemInfo.SubSliceCount = 32;
localHwInfo.gtSystemInfo.EUCount = 512;
localHwInfo.gtSystemInfo.CCSInfo.IsValid = true;
localHwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 4;
localHwInfo.gtSystemInfo.CCSInfo.Instances.CCSEnableMask = 0b1111;
}
#endif
}
if (localHwInfo.platform.eRenderCoreFamily == IGFX_XE_HPC_CORE) {
#ifdef SUPPORT_PVC
if (localHwInfo.platform.eProductFamily == IGFX_PVC) {
setupCalled = true;
PVC_CONFIG::setupHardwareInfoMultiTile(&localHwInfo, true, true);
// Mock values
localHwInfo.gtSystemInfo.SliceCount = 8;
localHwInfo.gtSystemInfo.SubSliceCount = 64;
localHwInfo.gtSystemInfo.EUCount = 512;
localHwInfo.gtSystemInfo.CCSInfo.IsValid = true;
localHwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 4;
localHwInfo.gtSystemInfo.CCSInfo.Instances.CCSEnableMask = 0b1111;
}
#endif
}
adjustPlatformOverride(localHwInfo, setupCalled);
ASSERT_TRUE(setupCalled);
}
} // namespace NEO

View File

@@ -0,0 +1,112 @@
/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#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/helpers/hw_info.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/unit_test/tests_configuration.h"
#include "opencl/source/command_queue/command_queue.h"
#include "opencl/test/unit_test/mocks/mock_context.h"
#include "gtest/gtest.h"
#include <memory>
#include <vector>
namespace NEO {
class MockDevice;
struct MulticontextAubFixture {
enum class EnabledCommandStreamers {
Single, // default only
Dual, // RCS + CCS0
All, // RCS + CCS0-3
};
void SetUp(uint32_t numberOfTiles, EnabledCommandStreamers enabledCommandStreamers, bool enableCompression);
void TearDown();
template <typename FamilyType>
CommandStreamReceiverSimulatedCommonHw<FamilyType> *getSimulatedCsr(uint32_t tile, uint32_t engine) {
using CsrWithAubDump = CommandStreamReceiverWithAUBDump<TbxCommandStreamReceiverHw<FamilyType>>;
using SimulatedCsr = CommandStreamReceiverSimulatedCommonHw<FamilyType>;
SimulatedCsr *simulatedCsr = nullptr;
if (testMode == TestMode::AubTestsWithTbx) {
auto csrWithAubDump = static_cast<CsrWithAubDump *>(&commandQueues[tile][engine]->getGpgpuCommandStreamReceiver());
simulatedCsr = static_cast<SimulatedCsr *>(csrWithAubDump);
} else {
simulatedCsr = static_cast<SimulatedCsr *>(&commandQueues[tile][engine]->getGpgpuCommandStreamReceiver());
}
return simulatedCsr;
}
template <typename FamilyType>
void expectMemory(void *gfxAddress, const void *srcAddress, size_t length, uint32_t tile, uint32_t engine) {
CommandStreamReceiverSimulatedCommonHw<FamilyType> *csrSimulated = getSimulatedCsr<FamilyType>(tile, engine);
if (testMode == TestMode::AubTestsWithTbx) {
auto tbxCsr = csrSimulated;
EXPECT_TRUE(tbxCsr->expectMemoryEqual(gfxAddress, srcAddress, length));
csrSimulated = static_cast<CommandStreamReceiverSimulatedCommonHw<FamilyType> *>(
static_cast<CommandStreamReceiverWithAUBDump<TbxCommandStreamReceiverHw<FamilyType>> *>(csrSimulated)->aubCSR.get());
}
if (csrSimulated) {
csrSimulated->expectMemoryEqual(gfxAddress, srcAddress, length);
}
}
template <typename FamilyType>
void expectMemoryNotEqual(void *gfxAddress, const void *srcAddress, size_t length, uint32_t tile, uint32_t engine) {
CommandStreamReceiverSimulatedCommonHw<FamilyType> *csrSimulated = getSimulatedCsr<FamilyType>(tile, engine);
if (testMode == TestMode::AubTestsWithTbx) {
auto tbxCsr = csrSimulated;
EXPECT_TRUE(tbxCsr->expectMemoryNotEqual(gfxAddress, srcAddress, length));
csrSimulated = static_cast<CommandStreamReceiverSimulatedCommonHw<FamilyType> *>(
static_cast<CommandStreamReceiverWithAUBDump<TbxCommandStreamReceiverHw<FamilyType>> *>(csrSimulated)->aubCSR.get());
}
if (csrSimulated) {
csrSimulated->expectMemoryNotEqual(gfxAddress, srcAddress, length);
}
}
template <typename FamilyType>
void expectMemoryCompressed(void *gfxAddress, const void *srcAddress, size_t length, uint32_t tile, uint32_t engine) {
CommandStreamReceiverSimulatedCommonHw<FamilyType> *csrSimulated = getSimulatedCsr<FamilyType>(tile, engine);
if (testMode == TestMode::AubTestsWithTbx) {
auto tbxCsr = csrSimulated;
EXPECT_TRUE(tbxCsr->expectMemoryCompressed(gfxAddress, srcAddress, length));
csrSimulated = static_cast<CommandStreamReceiverSimulatedCommonHw<FamilyType> *>(
static_cast<CommandStreamReceiverWithAUBDump<TbxCommandStreamReceiverHw<FamilyType>> *>(csrSimulated)->aubCSR.get());
}
if (csrSimulated) {
csrSimulated->expectMemoryCompressed(gfxAddress, srcAddress, length);
}
}
void overridePlatformConfigForAllEnginesSupport(HardwareInfo &localHwInfo);
void adjustPlatformOverride(HardwareInfo &localHwInfo, bool &setupCalled);
DebugManagerStateRestore restore;
const uint32_t rootDeviceIndex = 0u;
uint32_t numberOfEnabledTiles = 0;
std::vector<ClDevice *> tileDevices;
ClDevice *rootDevice = nullptr;
std::unique_ptr<MockContext> context;
std::unique_ptr<MockContext> multiTileDefaultContext;
std::vector<std::vector<std::unique_ptr<CommandQueue>>> commandQueues;
};
} // namespace NEO

View File

@@ -0,0 +1,15 @@
/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "opencl/test/unit_test/aub_tests/fixtures/multicontext_aub_fixture.h"
namespace NEO {
void MulticontextAubFixture::adjustPlatformOverride(HardwareInfo &localHwInfo, bool &setupCalled) {
}
} // namespace NEO