Skip to content

Commit f882671

Browse files
Add multicontext aub fixture
Signed-off-by: Bartosz Dunajski <[email protected]>
1 parent ad7f2f1 commit f882671

File tree

4 files changed

+366
-0
lines changed

4 files changed

+366
-0
lines changed

opencl/test/unit_test/aub_tests/fixtures/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ target_sources(igdrcl_aub_tests PRIVATE
99
${CMAKE_CURRENT_SOURCE_DIR}/aub_fixture.cpp
1010
${CMAKE_CURRENT_SOURCE_DIR}/aub_fixture.h
1111
${CMAKE_CURRENT_SOURCE_DIR}/hello_world_fixture.h
12+
${CMAKE_CURRENT_SOURCE_DIR}/multicontext_aub_fixture.cpp
13+
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}multicontext_aub_fixture_extended.cpp
14+
${CMAKE_CURRENT_SOURCE_DIR}/multicontext_aub_fixture.h
1215
${CMAKE_CURRENT_SOURCE_DIR}/run_kernel_fixture.h
1316
${CMAKE_CURRENT_SOURCE_DIR}/simple_arg_fixture.h
1417
${CMAKE_CURRENT_SOURCE_DIR}/unified_memory_fixture.h
Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
/*
2+
* Copyright (C) 2022 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "opencl/test/unit_test/aub_tests/fixtures/multicontext_aub_fixture.h"
9+
10+
#include "shared/source/command_stream/aub_command_stream_receiver.h"
11+
#include "shared/source/helpers/api_specific_config.h"
12+
#include "shared/source/helpers/hw_helper.h"
13+
#include "shared/test/common/helpers/ult_hw_config.h"
14+
#include "shared/test/common/helpers/variable_backup.h"
15+
#include "shared/test/common/mocks/mock_device.h"
16+
#include "shared/test/common/test_macros/test.h"
17+
#include "shared/test/unit_test/tests_configuration.h"
18+
19+
#include "opencl/source/cl_device/cl_device.h"
20+
#include "opencl/source/platform/platform.h"
21+
#include "opencl/test/unit_test/mocks/mock_context.h"
22+
#include "opencl/test/unit_test/mocks/mock_platform.h"
23+
24+
namespace NEO {
25+
26+
void MulticontextAubFixture::SetUp(uint32_t numberOfTiles, EnabledCommandStreamers enabledCommandStreamers, bool enableCompression) {
27+
this->numberOfEnabledTiles = numberOfTiles;
28+
const ::testing::TestInfo *const testInfo = ::testing::UnitTest::GetInstance()->current_test_info();
29+
30+
cl_int retVal = CL_SUCCESS;
31+
DebugManager.flags.CsrDispatchMode.set(static_cast<int32_t>(DispatchMode::BatchedDispatch));
32+
DebugManager.flags.CreateMultipleSubDevices.set(numberOfTiles);
33+
if (testMode == TestMode::AubTestsWithTbx) {
34+
DebugManager.flags.SetCommandStreamReceiver.set(static_cast<int32_t>(CommandStreamReceiverType::CSR_TBX_WITH_AUB));
35+
} else {
36+
DebugManager.flags.SetCommandStreamReceiver.set(static_cast<int32_t>(CommandStreamReceiverType::CSR_AUB));
37+
}
38+
39+
HardwareInfo localHwInfo = *defaultHwInfo;
40+
if ((EnabledCommandStreamers::All == enabledCommandStreamers) && localHwInfo.gtSystemInfo.SliceCount < 8) {
41+
overridePlatformConfigForAllEnginesSupport(localHwInfo);
42+
}
43+
44+
if (numberOfTiles > 1) {
45+
localHwInfo.gtSystemInfo.MultiTileArchInfo.IsValid = (numberOfEnabledTiles > 1) ? 1 : 0;
46+
localHwInfo.gtSystemInfo.MultiTileArchInfo.TileCount = numberOfEnabledTiles;
47+
localHwInfo.gtSystemInfo.MultiTileArchInfo.TileMask = 0;
48+
for (uint32_t i = 0; i < numberOfEnabledTiles; i++) {
49+
localHwInfo.gtSystemInfo.MultiTileArchInfo.TileMask |= (1 << i);
50+
}
51+
}
52+
53+
localHwInfo.capabilityTable.blitterOperationsSupported = true;
54+
if (DebugManager.flags.EnableBlitterOperationsSupport.get() != -1) {
55+
localHwInfo.capabilityTable.blitterOperationsSupported = !!DebugManager.flags.EnableBlitterOperationsSupport.get();
56+
}
57+
58+
auto &hwHelper = HwHelper::get(localHwInfo.platform.eRenderCoreFamily);
59+
auto engineType = getChosenEngineType(localHwInfo);
60+
auto renderEngine = aub_stream::NUM_ENGINES;
61+
for (auto &engine : hwHelper.getGpgpuEngineInstances(localHwInfo)) {
62+
if (!EngineHelpers::isCcs(engine.first)) {
63+
renderEngine = engine.first;
64+
break;
65+
}
66+
}
67+
ASSERT_NE(aub_stream::NUM_ENGINES, renderEngine);
68+
69+
auto renderEngineName = hwHelper.getCsTraits(renderEngine).name;
70+
71+
std::stringstream strfilename;
72+
strfilename << ApiSpecificConfig::getAubPrefixForSpecificApi();
73+
strfilename << testInfo->test_case_name() << "_" << testInfo->name() << "_";
74+
if (EnabledCommandStreamers::Single == enabledCommandStreamers) {
75+
strfilename << renderEngineName;
76+
} else if (EnabledCommandStreamers::Dual == enabledCommandStreamers) {
77+
strfilename << renderEngineName << "_CCS0";
78+
} else if (EnabledCommandStreamers::All == enabledCommandStreamers) {
79+
strfilename << renderEngineName << "_CCS0_3"; // xehp_config_name_RCS_CCS0_3.aub
80+
}
81+
82+
auto filename = AUBCommandStreamReceiver::createFullFilePath(localHwInfo, strfilename.str(), rootDeviceIndex);
83+
84+
DebugManager.flags.AUBDumpCaptureFileName.set(filename);
85+
86+
auto createCommandQueueForEngine = [&](uint32_t tileNumber, size_t engineFamily, size_t engineIndex) {
87+
cl_queue_properties properties[] = {CL_QUEUE_FAMILY_INTEL, engineFamily, CL_QUEUE_INDEX_INTEL, engineIndex, 0};
88+
auto clQueue = clCreateCommandQueueWithProperties(context.get(), tileDevices[tileNumber], properties, &retVal);
89+
EXPECT_EQ(CL_SUCCESS, retVal);
90+
return std::unique_ptr<CommandQueue>(castToObject<CommandQueue>(clQueue));
91+
};
92+
93+
DebugManager.flags.RenderCompressedBuffersEnabled.set(enableCompression);
94+
DebugManager.flags.RenderCompressedImagesEnabled.set(enableCompression);
95+
DebugManager.flags.EnableBlitterForEnqueueOperations.set(false);
96+
97+
platformsImpl->clear();
98+
VariableBackup<UltHwConfig> backup(&ultHwConfig);
99+
100+
ultHwConfig.useHwCsr = true;
101+
constructPlatform()->peekExecutionEnvironment()->prepareRootDeviceEnvironments(1u);
102+
platform()->peekExecutionEnvironment()->rootDeviceEnvironments[rootDeviceIndex]->setHwInfo(&localHwInfo);
103+
initPlatform();
104+
105+
rootDevice = platform()->getClDevice(0);
106+
EXPECT_EQ(rootDeviceIndex, rootDevice->getRootDeviceIndex());
107+
{
108+
cl_device_id deviceId = rootDevice;
109+
ClDeviceVector clDeviceVector{&deviceId, 1};
110+
if (numberOfTiles > 1) {
111+
for (uint32_t i = 0; i < numberOfTiles; i++) {
112+
clDeviceVector.push_back(rootDevice->getNearestGenericSubDevice(i));
113+
}
114+
}
115+
context.reset(MockContext::create<MockContext>(nullptr, clDeviceVector, nullptr, nullptr, retVal));
116+
EXPECT_EQ(CL_SUCCESS, retVal);
117+
}
118+
119+
commandQueues.resize(numberOfTiles);
120+
for (uint32_t tile = 0; tile < numberOfTiles; tile++) {
121+
tileDevices.push_back(rootDevice->getNearestGenericSubDevice(tile));
122+
EXPECT_NE(nullptr, tileDevices[tile]);
123+
if (EnabledCommandStreamers::Single == enabledCommandStreamers) {
124+
if (EngineHelpers::isCcs(engineType)) {
125+
auto familyQueue = tileDevices[tile]->getDevice().getEngineGroupIndexFromEngineGroupType(EngineGroupType::Compute);
126+
commandQueues[tile].push_back(createCommandQueueForEngine(tile, familyQueue, 0));
127+
} else {
128+
auto familyQueue = tileDevices[tile]->getDevice().getEngineGroupIndexFromEngineGroupType(EngineGroupType::RenderCompute);
129+
commandQueues[tile].push_back(createCommandQueueForEngine(tile, familyQueue, 0));
130+
}
131+
} else if (EnabledCommandStreamers::Dual == enabledCommandStreamers) {
132+
auto rcsQueue = tileDevices[tile]->getDevice().getEngineGroupIndexFromEngineGroupType(EngineGroupType::RenderCompute);
133+
auto ccsQueue = tileDevices[tile]->getDevice().getEngineGroupIndexFromEngineGroupType(EngineGroupType::Compute);
134+
commandQueues[tile].push_back(createCommandQueueForEngine(tile, rcsQueue, 0));
135+
commandQueues[tile].push_back(createCommandQueueForEngine(tile, ccsQueue, 0));
136+
} else if (EnabledCommandStreamers::All == enabledCommandStreamers) {
137+
auto rcsQueue = tileDevices[tile]->getDevice().getEngineGroupIndexFromEngineGroupType(EngineGroupType::RenderCompute);
138+
auto ccsQueue = tileDevices[tile]->getDevice().getEngineGroupIndexFromEngineGroupType(EngineGroupType::Compute);
139+
commandQueues[tile].push_back(createCommandQueueForEngine(tile, rcsQueue, 0));
140+
commandQueues[tile].push_back(createCommandQueueForEngine(tile, ccsQueue, 0));
141+
commandQueues[tile].push_back(createCommandQueueForEngine(tile, ccsQueue, 1));
142+
commandQueues[tile].push_back(createCommandQueueForEngine(tile, ccsQueue, 2));
143+
commandQueues[tile].push_back(createCommandQueueForEngine(tile, ccsQueue, 3));
144+
}
145+
}
146+
147+
{
148+
cl_int retVal = CL_SUCCESS;
149+
cl_device_id deviceId = rootDevice;
150+
multiTileDefaultContext.reset(MockContext::create<MockContext>(nullptr, ClDeviceVector(&deviceId, 1), nullptr, nullptr, retVal));
151+
EXPECT_EQ(CL_SUCCESS, retVal);
152+
}
153+
}
154+
155+
void MulticontextAubFixture::TearDown() {
156+
auto filename = DebugManager.flags.AUBDumpCaptureFileName.get();
157+
158+
std::string tileString = std::to_string(numberOfEnabledTiles) + "tx";
159+
160+
if (numberOfEnabledTiles > 1) {
161+
EXPECT_NE(std::string::npos, filename.find(tileString));
162+
} else {
163+
EXPECT_EQ(std::string::npos, filename.find(tileString));
164+
}
165+
}
166+
167+
void MulticontextAubFixture::overridePlatformConfigForAllEnginesSupport(HardwareInfo &localHwInfo) {
168+
const ::testing::TestInfo *const testInfo = ::testing::UnitTest::GetInstance()->current_test_info();
169+
printf("\nWARNING: Platform configuration for %s_%s test forced to %dtx8x4x16\n",
170+
testInfo->test_case_name(), testInfo->name(), numberOfEnabledTiles);
171+
172+
bool setupCalled = false;
173+
174+
if (localHwInfo.platform.eRenderCoreFamily == IGFX_XE_HP_CORE) {
175+
#ifdef SUPPORT_XE_HP_SDV
176+
if (localHwInfo.platform.eProductFamily == IGFX_XE_HP_SDV) {
177+
setupCalled = true;
178+
XE_HP_SDV_CONFIG::setupHardwareInfoMultiTile(&localHwInfo, true, true);
179+
180+
// Mock values
181+
localHwInfo.gtSystemInfo.SliceCount = 8;
182+
localHwInfo.gtSystemInfo.SubSliceCount = 32;
183+
localHwInfo.gtSystemInfo.EUCount = 512;
184+
185+
localHwInfo.gtSystemInfo.CCSInfo.IsValid = true;
186+
localHwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 4;
187+
localHwInfo.gtSystemInfo.CCSInfo.Instances.CCSEnableMask = 0b1111;
188+
}
189+
#endif
190+
}
191+
192+
if (localHwInfo.platform.eRenderCoreFamily == IGFX_XE_HPG_CORE) {
193+
#ifdef SUPPORT_DG2
194+
if (localHwInfo.platform.eProductFamily == IGFX_DG2) {
195+
ASSERT_TRUE(numberOfEnabledTiles == 1);
196+
setupCalled = true;
197+
198+
DG2_CONFIG::setupHardwareInfoMultiTile(&localHwInfo, true, false);
199+
200+
// Mock values
201+
localHwInfo.gtSystemInfo.SliceCount = 8;
202+
localHwInfo.gtSystemInfo.SubSliceCount = 32;
203+
localHwInfo.gtSystemInfo.EUCount = 512;
204+
205+
localHwInfo.gtSystemInfo.CCSInfo.IsValid = true;
206+
localHwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 4;
207+
localHwInfo.gtSystemInfo.CCSInfo.Instances.CCSEnableMask = 0b1111;
208+
}
209+
#endif
210+
}
211+
212+
if (localHwInfo.platform.eRenderCoreFamily == IGFX_XE_HPC_CORE) {
213+
#ifdef SUPPORT_PVC
214+
if (localHwInfo.platform.eProductFamily == IGFX_PVC) {
215+
setupCalled = true;
216+
217+
PVC_CONFIG::setupHardwareInfoMultiTile(&localHwInfo, true, true);
218+
219+
// Mock values
220+
localHwInfo.gtSystemInfo.SliceCount = 8;
221+
localHwInfo.gtSystemInfo.SubSliceCount = 64;
222+
localHwInfo.gtSystemInfo.EUCount = 512;
223+
224+
localHwInfo.gtSystemInfo.CCSInfo.IsValid = true;
225+
localHwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 4;
226+
localHwInfo.gtSystemInfo.CCSInfo.Instances.CCSEnableMask = 0b1111;
227+
}
228+
#endif
229+
}
230+
231+
adjustPlatformOverride(localHwInfo, setupCalled);
232+
233+
ASSERT_TRUE(setupCalled);
234+
}
235+
236+
} // namespace NEO
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/*
2+
* Copyright (C) 2022 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#pragma once
9+
#include "shared/source/command_stream/command_stream_receiver_with_aub_dump.h"
10+
#include "shared/source/command_stream/tbx_command_stream_receiver_hw.h"
11+
#include "shared/source/helpers/hw_info.h"
12+
#include "shared/test/common/helpers/debug_manager_state_restore.h"
13+
#include "shared/test/unit_test/tests_configuration.h"
14+
15+
#include "opencl/source/command_queue/command_queue.h"
16+
#include "opencl/test/unit_test/mocks/mock_context.h"
17+
18+
#include "gtest/gtest.h"
19+
20+
#include <memory>
21+
#include <vector>
22+
23+
namespace NEO {
24+
class MockDevice;
25+
26+
struct MulticontextAubFixture {
27+
enum class EnabledCommandStreamers {
28+
Single, // default only
29+
Dual, // RCS + CCS0
30+
All, // RCS + CCS0-3
31+
};
32+
33+
void SetUp(uint32_t numberOfTiles, EnabledCommandStreamers enabledCommandStreamers, bool enableCompression);
34+
void TearDown();
35+
36+
template <typename FamilyType>
37+
CommandStreamReceiverSimulatedCommonHw<FamilyType> *getSimulatedCsr(uint32_t tile, uint32_t engine) {
38+
using CsrWithAubDump = CommandStreamReceiverWithAUBDump<TbxCommandStreamReceiverHw<FamilyType>>;
39+
using SimulatedCsr = CommandStreamReceiverSimulatedCommonHw<FamilyType>;
40+
SimulatedCsr *simulatedCsr = nullptr;
41+
42+
if (testMode == TestMode::AubTestsWithTbx) {
43+
auto csrWithAubDump = static_cast<CsrWithAubDump *>(&commandQueues[tile][engine]->getGpgpuCommandStreamReceiver());
44+
simulatedCsr = static_cast<SimulatedCsr *>(csrWithAubDump);
45+
} else {
46+
simulatedCsr = static_cast<SimulatedCsr *>(&commandQueues[tile][engine]->getGpgpuCommandStreamReceiver());
47+
}
48+
49+
return simulatedCsr;
50+
}
51+
52+
template <typename FamilyType>
53+
void expectMemory(void *gfxAddress, const void *srcAddress, size_t length, uint32_t tile, uint32_t engine) {
54+
CommandStreamReceiverSimulatedCommonHw<FamilyType> *csrSimulated = getSimulatedCsr<FamilyType>(tile, engine);
55+
56+
if (testMode == TestMode::AubTestsWithTbx) {
57+
auto tbxCsr = csrSimulated;
58+
EXPECT_TRUE(tbxCsr->expectMemoryEqual(gfxAddress, srcAddress, length));
59+
csrSimulated = static_cast<CommandStreamReceiverSimulatedCommonHw<FamilyType> *>(
60+
static_cast<CommandStreamReceiverWithAUBDump<TbxCommandStreamReceiverHw<FamilyType>> *>(csrSimulated)->aubCSR.get());
61+
}
62+
63+
if (csrSimulated) {
64+
csrSimulated->expectMemoryEqual(gfxAddress, srcAddress, length);
65+
}
66+
}
67+
68+
template <typename FamilyType>
69+
void expectMemoryNotEqual(void *gfxAddress, const void *srcAddress, size_t length, uint32_t tile, uint32_t engine) {
70+
CommandStreamReceiverSimulatedCommonHw<FamilyType> *csrSimulated = getSimulatedCsr<FamilyType>(tile, engine);
71+
72+
if (testMode == TestMode::AubTestsWithTbx) {
73+
auto tbxCsr = csrSimulated;
74+
EXPECT_TRUE(tbxCsr->expectMemoryNotEqual(gfxAddress, srcAddress, length));
75+
csrSimulated = static_cast<CommandStreamReceiverSimulatedCommonHw<FamilyType> *>(
76+
static_cast<CommandStreamReceiverWithAUBDump<TbxCommandStreamReceiverHw<FamilyType>> *>(csrSimulated)->aubCSR.get());
77+
}
78+
79+
if (csrSimulated) {
80+
csrSimulated->expectMemoryNotEqual(gfxAddress, srcAddress, length);
81+
}
82+
}
83+
84+
template <typename FamilyType>
85+
void expectMemoryCompressed(void *gfxAddress, const void *srcAddress, size_t length, uint32_t tile, uint32_t engine) {
86+
CommandStreamReceiverSimulatedCommonHw<FamilyType> *csrSimulated = getSimulatedCsr<FamilyType>(tile, engine);
87+
88+
if (testMode == TestMode::AubTestsWithTbx) {
89+
auto tbxCsr = csrSimulated;
90+
EXPECT_TRUE(tbxCsr->expectMemoryCompressed(gfxAddress, srcAddress, length));
91+
csrSimulated = static_cast<CommandStreamReceiverSimulatedCommonHw<FamilyType> *>(
92+
static_cast<CommandStreamReceiverWithAUBDump<TbxCommandStreamReceiverHw<FamilyType>> *>(csrSimulated)->aubCSR.get());
93+
}
94+
95+
if (csrSimulated) {
96+
csrSimulated->expectMemoryCompressed(gfxAddress, srcAddress, length);
97+
}
98+
}
99+
100+
void overridePlatformConfigForAllEnginesSupport(HardwareInfo &localHwInfo);
101+
void adjustPlatformOverride(HardwareInfo &localHwInfo, bool &setupCalled);
102+
DebugManagerStateRestore restore;
103+
104+
const uint32_t rootDeviceIndex = 0u;
105+
uint32_t numberOfEnabledTiles = 0;
106+
std::vector<ClDevice *> tileDevices;
107+
ClDevice *rootDevice = nullptr;
108+
std::unique_ptr<MockContext> context;
109+
std::unique_ptr<MockContext> multiTileDefaultContext;
110+
std::vector<std::vector<std::unique_ptr<CommandQueue>>> commandQueues;
111+
};
112+
} // namespace NEO
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright (C) 2022 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "opencl/test/unit_test/aub_tests/fixtures/multicontext_aub_fixture.h"
9+
10+
namespace NEO {
11+
12+
void MulticontextAubFixture::adjustPlatformOverride(HardwareInfo &localHwInfo, bool &setupCalled) {
13+
}
14+
15+
} // namespace NEO

0 commit comments

Comments
 (0)