|
| 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 |
0 commit comments