From fbf1f367f40b33c90f2492048bb29b239163f114 Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Thu, 4 Nov 2021 16:38:47 +0000 Subject: [PATCH] Dont create blitter engine when blitter support is disabled Related-To: NEO-6325 Signed-off-by: Mateusz Jablonski --- .../sources/cmdlist/test_cmdlist_3.cpp | 19 +++-- .../sources/debugger/test_l0_debugger.cpp | 8 +- .../command_queue/command_queue_tests.cpp | 12 ++- .../command_queue/enqueue_kernel_2_tests.cpp | 78 +++++++++++-------- .../enqueue_read_image_tests.cpp | 10 ++- ...and_stream_receiver_flush_task_4_tests.cpp | 4 +- .../test/unit_test/context/context_tests.cpp | 3 + opencl/test/unit_test/device/device_tests.cpp | 18 ++--- .../device/get_device_info_tests.cpp | 6 ++ .../unit_test/device/sub_device_tests.cpp | 3 + .../gen12lp/hw_helper_tests_gen12lp.inl | 1 + .../hw_helper_tests_xehp_and_later.cpp | 3 + .../unit_test/mem_obj/buffer_bcs_tests.cpp | 19 ++--- .../program/printf_handler_tests.cpp | 4 +- .../copy_engine_tests_xe_hp_core.cpp | 1 + .../xe_hp_core/xehp/hw_helper_tests_xehp.inl | 2 + shared/source/device/device.cpp | 4 + .../command_stream_receiver_tests.cpp | 4 +- .../unit_test/device/neo_device_tests.cpp | 14 ++-- 19 files changed, 136 insertions(+), 77 deletions(-) diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_3.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_3.cpp index d3322c1402..e223e5502c 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_3.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_3.cpp @@ -873,12 +873,17 @@ HWTEST2_F(CommandListCreate, givenImmediateCommandListWhenMemoryCopyRegionWithSi using ImageSupported = IsAtLeastProduct; -HWTEST2_F(CommandListCreate, givenImmediateCommandListWhenCopyRegionFromImageToImageUsingRenderThenSuccessIsReturned, IsAtLeastXeHpCore) { +struct CommandListCreateWithBcs : public CommandListCreate { + void SetUp() override { + VariableBackup backupHwInfo(defaultHwInfo.get()); + defaultHwInfo->capabilityTable.blitterOperationsSupported = true; + CommandListCreate::SetUp(); + } +}; +HWTEST2_F(CommandListCreateWithBcs, givenImmediateCommandListWhenCopyRegionFromImageToImageUsingRenderThenSuccessIsReturned, IsAtLeastXeHpCore) { const ze_command_queue_desc_t queueDesc = {}; bool internalEngine = true; - neoDevice->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.blitterOperationsSupported = true; - ze_result_t returnValue; std::unique_ptr commandList0(CommandList::createImmediate(productFamily, device, @@ -919,7 +924,7 @@ HWTEST2_F(CommandListCreate, givenImmediateCommandListWhenCopyRegionFromImageToI EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue); } -HWTEST2_F(CommandListCreate, givenImmediateCommandListWhenCopyRegionFromImageToImageUsingCopyWintInvalidRegionArguementsThenErrorIsReturned, IsAtLeastXeHpCore) { +HWTEST2_F(CommandListCreateWithBcs, givenImmediateCommandListWhenCopyRegionFromImageToImageUsingCopyWintInvalidRegionArguementsThenErrorIsReturned, IsAtLeastXeHpCore) { const ze_command_queue_desc_t queueDesc = {}; bool internalEngine = true; @@ -965,7 +970,7 @@ HWTEST2_F(CommandListCreate, givenImmediateCommandListWhenCopyRegionFromImageToI EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, returnValue); } -HWTEST2_F(CommandListCreate, givenImmediateCommandListWhenCopyFromImageToImageUsingRenderThenSuccessIsReturned, IsAtLeastXeHpCore) { +HWTEST2_F(CommandListCreateWithBcs, givenImmediateCommandListWhenCopyFromImageToImageUsingRenderThenSuccessIsReturned, IsAtLeastXeHpCore) { const ze_command_queue_desc_t queueDesc = {}; bool internalEngine = true; @@ -1009,7 +1014,7 @@ HWTEST2_F(CommandListCreate, givenImmediateCommandListWhenCopyFromImageToImageUs EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue); } -HWTEST2_F(CommandListCreate, givenImmediateCommandListWhenMemoryCopyRegionWithSignalAndInvalidWaitHandleUsingCopyEngineThenErrorIsReturned, Platforms) { +HWTEST2_F(CommandListCreateWithBcs, givenImmediateCommandListWhenMemoryCopyRegionWithSignalAndInvalidWaitHandleUsingCopyEngineThenErrorIsReturned, Platforms) { const ze_command_queue_desc_t desc = {}; bool internalEngine = true; @@ -1176,7 +1181,7 @@ TEST_F(CommandListCreate, whenCreatingImmCmdListWithASyncModeAndAppendEventReset EXPECT_EQ(event_object->queryStatus(), ZE_RESULT_SUCCESS); } -TEST_F(CommandListCreate, givenQueueDescriptionwhenCreatingImmediateCommandListForCopyEnigneThenItHasImmediateCommandQueueCreated) { +TEST_F(CommandListCreateWithBcs, givenQueueDescriptionwhenCreatingImmediateCommandListForCopyEnigneThenItHasImmediateCommandQueueCreated) { auto &engines = neoDevice->getEngineGroups(); uint32_t numaAvailableEngineGroups = 0; for (uint32_t ordinal = 0; ordinal < CommonConstants::engineGroupCount; ordinal++) { diff --git a/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger.cpp b/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger.cpp index b857f9678a..87242a9914 100644 --- a/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger.cpp +++ b/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger.cpp @@ -517,7 +517,13 @@ HWTEST2_F(L0DebuggerTest, givenDebuggingEnabledWhenCommandListIsExecutedThenSbaB commandList->destroy(); } -using L0DebuggerInternalUsageTest = L0DebuggerTest; +struct L0DebuggerInternalUsageTest : public L0DebuggerTest { + void SetUp() override { + VariableBackup backupHwInfo(defaultHwInfo.get()); + defaultHwInfo->capabilityTable.blitterOperationsSupported = true; + L0DebuggerTest::SetUp(); + } +}; HWTEST_F(L0DebuggerInternalUsageTest, givenFlushTaskSubmissionEnabledWhenCommandListIsInititalizedOrResetThenCaptureSbaIsNotCalled) { using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; diff --git a/opencl/test/unit_test/command_queue/command_queue_tests.cpp b/opencl/test/unit_test/command_queue/command_queue_tests.cpp index d3dc97608e..51cf43fd3c 100644 --- a/opencl/test/unit_test/command_queue/command_queue_tests.cpp +++ b/opencl/test/unit_test/command_queue/command_queue_tests.cpp @@ -1691,7 +1691,11 @@ struct CommandQueueOnSpecificEngineTests : ::testing::Test { HWTEST_F(CommandQueueOnSpecificEngineTests, givenMultipleFamiliesWhenCreatingQueueOnSpecificEngineThenUseCorrectEngine) { auto raiiHwHelper = overrideHwHelper>(); - MockContext context{}; + HardwareInfo hwInfo = *defaultHwInfo; + hwInfo.capabilityTable.blitterOperationsSupported = true; + MockDevice *device = MockDevice::createWithNewExecutionEnvironment(&hwInfo, 0); + MockClDevice clDevice{device}; + MockContext context{&clDevice}; cl_command_queue_properties properties[5] = {}; fillProperties(properties, 0, 0); @@ -1732,6 +1736,9 @@ HWTEST_F(CommandQueueOnSpecificEngineTests, givenRootDeviceAndMultipleFamiliesWh HWTEST_F(CommandQueueOnSpecificEngineTests, givenSubDeviceAndMultipleFamiliesWhenCreatingQueueOnSpecificEngineThenUseDefaultEngine) { auto raiiHwHelper = overrideHwHelper>(); + + VariableBackup backupHwInfo(defaultHwInfo.get()); + defaultHwInfo->capabilityTable.blitterOperationsSupported = true; UltClDeviceFactory deviceFactory{1, 2}; MockContext context{deviceFactory.subDevices[0]}; cl_command_queue_properties properties[5] = {}; @@ -1758,6 +1765,9 @@ HWTEST_F(CommandQueueOnSpecificEngineTests, givenSubDeviceAndMultipleFamiliesWhe HWTEST_F(CommandQueueOnSpecificEngineTests, givenBcsFamilySelectedWhenCreatingQueueOnSpecificEngineThenInitializeBcsProperly) { auto raiiHwHelper = overrideHwHelper>(); + + VariableBackup backupHwInfo(defaultHwInfo.get()); + defaultHwInfo->capabilityTable.blitterOperationsSupported = true; MockContext context{}; cl_command_queue_properties properties[5] = {}; diff --git a/opencl/test/unit_test/command_queue/enqueue_kernel_2_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_kernel_2_tests.cpp index 2108b0ee22..31455642c8 100644 --- a/opencl/test/unit_test/command_queue/enqueue_kernel_2_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_kernel_2_tests.cpp @@ -11,6 +11,7 @@ #include "shared/test/common/cmd_parse/gen_cmd_parse.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/mocks/mock_csr.h" +#include "shared/test/common/mocks/ult_device_factory.h" #include "shared/test/unit_test/utilities/base_object_utils.h" #include "opencl/test/unit_test/command_queue/enqueue_fixture.h" @@ -781,37 +782,37 @@ HWTEST_F(EnqueueKernelTests, whenEnqueueingKernelThenCsrCorrectlySetsRequiredThr typedef HelloWorldFixture EnqueueKernelFixture; typedef Test EnqueueKernelTest; +template +class MyCmdQ : public MockCommandQueueHw { + public: + using CommandQueueHw::commandStream; + using CommandQueueHw::gpgpuEngine; + using CommandQueueHw::bcsEngines; + MyCmdQ(Context *context, ClDevice *device) : MockCommandQueueHw(context, device, nullptr) {} + void dispatchAuxTranslationBuiltin(MultiDispatchInfo &multiDispatchInfo, AuxTranslationDirection auxTranslationDirection) override { + CommandQueueHw::dispatchAuxTranslationBuiltin(multiDispatchInfo, auxTranslationDirection); + auxTranslationDirections.push_back(auxTranslationDirection); + Kernel *lastKernel = nullptr; + for (const auto &dispatchInfo : multiDispatchInfo) { + lastKernel = dispatchInfo.getKernel(); + dispatchInfos.emplace_back(dispatchInfo); + } + dispatchAuxTranslationInputs.emplace_back(lastKernel, multiDispatchInfo.size(), *multiDispatchInfo.getKernelObjsForAuxTranslation(), + auxTranslationDirection); + } + + void waitUntilComplete(uint32_t gpgpuTaskCountToWait, Range copyEnginesToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool cleanTemporaryAllocationList) override { + waitCalled++; + MockCommandQueueHw::waitUntilComplete(gpgpuTaskCountToWait, copyEnginesToWait, flushStampToWait, useQuickKmdSleep, cleanTemporaryAllocationList); + } + + std::vector auxTranslationDirections; + std::vector dispatchInfos; + std::vector> dispatchAuxTranslationInputs; + uint32_t waitCalled = 0; +}; + struct EnqueueAuxKernelTests : public EnqueueKernelTest { - template - class MyCmdQ : public MockCommandQueueHw { - public: - using CommandQueueHw::commandStream; - using CommandQueueHw::gpgpuEngine; - using CommandQueueHw::bcsEngines; - MyCmdQ(Context *context, ClDevice *device) : MockCommandQueueHw(context, device, nullptr) {} - void dispatchAuxTranslationBuiltin(MultiDispatchInfo &multiDispatchInfo, AuxTranslationDirection auxTranslationDirection) override { - CommandQueueHw::dispatchAuxTranslationBuiltin(multiDispatchInfo, auxTranslationDirection); - auxTranslationDirections.push_back(auxTranslationDirection); - Kernel *lastKernel = nullptr; - for (const auto &dispatchInfo : multiDispatchInfo) { - lastKernel = dispatchInfo.getKernel(); - dispatchInfos.emplace_back(dispatchInfo); - } - dispatchAuxTranslationInputs.emplace_back(lastKernel, multiDispatchInfo.size(), *multiDispatchInfo.getKernelObjsForAuxTranslation(), - auxTranslationDirection); - } - - void waitUntilComplete(uint32_t gpgpuTaskCountToWait, Range copyEnginesToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool cleanTemporaryAllocationList) override { - waitCalled++; - MockCommandQueueHw::waitUntilComplete(gpgpuTaskCountToWait, copyEnginesToWait, flushStampToWait, useQuickKmdSleep, cleanTemporaryAllocationList); - } - - std::vector auxTranslationDirections; - std::vector dispatchInfos; - std::vector> dispatchAuxTranslationInputs; - uint32_t waitCalled = 0; - }; - void SetUp() override { DebugManager.flags.ForceAuxTranslationMode.set(static_cast(AuxTranslationMode::Builtin)); EnqueueKernelTest::SetUp(); @@ -927,16 +928,27 @@ HWTEST_F(EnqueueAuxKernelTests, givenKernelWithRequiredAuxTranslationWhenEnqueue EXPECT_TRUE(kernelAfter->isBuiltIn); } -HWTEST_F(EnqueueAuxKernelTests, givenDebugVariableDisablingBuiltinTranslationWhenDispatchingKernelWithRequiredAuxTranslationThenDontDispatch) { +using BlitAuxKernelTests = ::testing::Test; +HWTEST_F(BlitAuxKernelTests, givenDebugVariableDisablingBuiltinTranslationWhenDispatchingKernelWithRequiredAuxTranslationThenDontDispatch) { + DebugManagerStateRestore dbgRestore; DebugManager.flags.ForceAuxTranslationMode.set(static_cast(AuxTranslationMode::Blit)); + + VariableBackup backupHwInfo(defaultHwInfo.get()); + defaultHwInfo->capabilityTable.blitterOperationsSupported = true; + + UltClDeviceFactory factory{1, 0}; + auto rootDeviceIndex = 0u; + auto pClDevice = factory.rootDevices[rootDeviceIndex]; + auto pDevice = factory.pUltDeviceFactory->rootDevices[rootDeviceIndex]; pDevice->getUltCommandStreamReceiver().timestampPacketWriteEnabled = true; auto hwInfo = pDevice->getExecutionEnvironment()->rootDeviceEnvironments[rootDeviceIndex]->getMutableHardwareInfo(); hwInfo->capabilityTable.blitterOperationsSupported = true; REQUIRE_FULL_BLITTER_OR_SKIP(hwInfo); - MockKernelWithInternals mockKernel(*pClDevice, context); - MyCmdQ cmdQ(context, pClDevice); + MockContext context(pClDevice); + MockKernelWithInternals mockKernel(context.getDevices(), &context); + MyCmdQ cmdQ(&context, pClDevice); size_t gws[3] = {1, 0, 0}; MockBuffer buffer; diff --git a/opencl/test/unit_test/command_queue/enqueue_read_image_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_read_image_tests.cpp index b8335ec409..cd1a77a9ab 100644 --- a/opencl/test/unit_test/command_queue/enqueue_read_image_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_read_image_tests.cpp @@ -857,7 +857,15 @@ HWTEST_F(EnqueueReadImageTest, GivenImage1DThatIsZeroCopyWhenReadImageWithTheSam pEvent->release(); } -HWTEST_F(EnqueueReadImageTest, givenDeviceWithBlitterSupportWhenEnqueueReadImageThenBlitEnqueueImageAllowedReturnsCorrectResult) { +struct EnqueueReadImageTestWithBcs : EnqueueReadImageTest { + void SetUp() override { + VariableBackup backupHwInfo(defaultHwInfo.get()); + defaultHwInfo->capabilityTable.blitterOperationsSupported = true; + EnqueueReadImageTest::SetUp(); + } +}; + +HWTEST_F(EnqueueReadImageTestWithBcs, givenDeviceWithBlitterSupportWhenEnqueueReadImageThenBlitEnqueueImageAllowedReturnsCorrectResult) { DebugManagerStateRestore restorer; DebugManager.flags.EnableBlitterForEnqueueOperations.set(1); DebugManager.flags.EnableBlitterForEnqueueImageOperations.set(1); diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_4_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_4_tests.cpp index b07554aeba..60806083b6 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_4_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_4_tests.cpp @@ -253,7 +253,8 @@ HWTEST_F(MultiRootDeviceCommandStreamReceiverTests, givenMultipleEventInMultiRoo struct CrossDeviceDependenciesTests : public ::testing::Test { void SetUp() override { - + VariableBackup backupHwInfo(defaultHwInfo.get()); + defaultHwInfo->capabilityTable.blitterOperationsSupported = true; deviceFactory = std::make_unique(3, 0); auto device1 = deviceFactory->rootDevices[1]; auto device2 = deviceFactory->rootDevices[2]; @@ -502,7 +503,6 @@ HWTEST_F(CrossDeviceDependenciesTests, givenWaitListWithEventBlockedByUserEventW DebugManager.flags.EnableBlitterForEnqueueOperations.set(true); for (auto &rootDeviceEnvironment : deviceFactory->rootDevices[0]->getExecutionEnvironment()->rootDeviceEnvironments) { - rootDeviceEnvironment->getMutableHardwareInfo()->capabilityTable.blitterOperationsSupported = true; REQUIRE_FULL_BLITTER_OR_SKIP(rootDeviceEnvironment->getHardwareInfo()); } diff --git a/opencl/test/unit_test/context/context_tests.cpp b/opencl/test/unit_test/context/context_tests.cpp index d46c3b6bd1..56d74cafbc 100644 --- a/opencl/test/unit_test/context/context_tests.cpp +++ b/opencl/test/unit_test/context/context_tests.cpp @@ -549,6 +549,9 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, ContextCreateTests, givenLocalMemoryAllocationWhenB DebugManagerStateRestore restore; DebugManager.flags.EnableLocalMemory.set(true); DebugManager.flags.ForceLocalMemoryAccessMode.set(static_cast(LocalMemoryAccessMode::Default)); + + VariableBackup backupHwInfo(defaultHwInfo.get()); + defaultHwInfo->capabilityTable.blitterOperationsSupported = true; UltClDeviceFactory deviceFactory{1, 2}; ClDevice *devicesToTest[] = {deviceFactory.rootDevices[0], deviceFactory.subDevices[0], deviceFactory.subDevices[1]}; diff --git a/opencl/test/unit_test/device/device_tests.cpp b/opencl/test/unit_test/device/device_tests.cpp index d12b2b48ce..9ba782a55d 100644 --- a/opencl/test/unit_test/device/device_tests.cpp +++ b/opencl/test/unit_test/device/device_tests.cpp @@ -86,6 +86,7 @@ TEST_F(DeviceTest, givenDeviceWhenEngineIsCreatedThenSetInitialValueForTag) { TEST_F(DeviceTest, givenDeviceWhenAskedForSpecificEngineThenReturnIt) { auto hwInfo = *defaultHwInfo; hwInfo.featureTable.ftrCCSNode = true; + hwInfo.capabilityTable.blitterOperationsSupported = true; MockClDevice mockClDevice{MockDevice::createWithNewExecutionEnvironment(&hwInfo, 0)}; @@ -103,14 +104,6 @@ TEST_F(DeviceTest, givenDeviceWhenAskedForSpecificEngineThenReturnIt) { EXPECT_THROW(mockClDevice.getEngine(aub_stream::ENGINE_VCS, EngineUsage::Regular), std::exception); } -TEST_F(DeviceTest, givenDeviceWhenAskedForEngineWithValidIndexThenReturnIt) { - auto &engines = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*defaultHwInfo); - for (uint32_t i = 0; i < engines.size(); i++) { - auto &deviceEngine = pDevice->getEngine(i); - EXPECT_EQ(deviceEngine.osContext->getEngineType(), engines[i].first); - } -} - TEST_F(DeviceTest, givenDebugVariableToAlwaysChooseEngineZeroWhenNotExistingEngineSelectedThenIndexZeroEngineIsReturned) { DebugManagerStateRestore restore; DebugManager.flags.OverrideInvalidEngineWithDefault.set(true); @@ -323,9 +316,10 @@ TEST(DeviceCreation, givenDefaultHwCsrInDebugVarsWhenDeviceIsCreatedThenIsSimula } TEST(DeviceCreation, givenDeviceWhenItIsCreatedThenOsContextIsRegistredInMemoryManager) { - auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); + auto hwInfo = *defaultHwInfo; + hwInfo.capabilityTable.blitterOperationsSupported = true; + auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(&hwInfo)); auto memoryManager = device->getMemoryManager(); - auto &hwInfo = device->getHardwareInfo(); auto numEnginesForDevice = HwHelper::get(hwInfo.platform.eRenderCoreFamily).getGpgpuEngineInstances(hwInfo).size(); if (device->getNumGenericSubDevices() > 1) { numEnginesForDevice *= device->getNumGenericSubDevices(); @@ -346,6 +340,7 @@ TEST(DeviceCreation, givenMultiRootDeviceWhenTheyAreCreatedThenEachOsContextHasU executionEnvironment->prepareRootDeviceEnvironments(numDevices); for (auto i = 0u; i < numDevices; i++) { executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(defaultHwInfo.get()); + executionEnvironment->rootDeviceEnvironments[i]->getMutableHardwareInfo()->capabilityTable.blitterOperationsSupported = true; } auto device1 = std::unique_ptr(Device::create(executionEnvironment, 0u)); @@ -421,8 +416,9 @@ TEST(DeviceCreation, givenMultiRootDeviceWhenTheyAreCreatedThenEachDeviceHasSepe executionEnvironment->prepareRootDeviceEnvironments(numDevices); for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(defaultHwInfo.get()); + executionEnvironment->rootDeviceEnvironments[i]->getMutableHardwareInfo()->capabilityTable.blitterOperationsSupported = true; } - auto hwInfo = *defaultHwInfo; + auto hwInfo = *executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo(); const auto &numGpgpuEngines = HwHelper::get(hwInfo.platform.eRenderCoreFamily).getGpgpuEngineInstances(hwInfo).size(); auto device1 = std::unique_ptr(Device::create(executionEnvironment, 0u)); auto device2 = std::unique_ptr(Device::create(executionEnvironment, 1u)); diff --git a/opencl/test/unit_test/device/get_device_info_tests.cpp b/opencl/test/unit_test/device/get_device_info_tests.cpp index 5c09954b9b..b056bcee6c 100644 --- a/opencl/test/unit_test/device/get_device_info_tests.cpp +++ b/opencl/test/unit_test/device/get_device_info_tests.cpp @@ -725,6 +725,8 @@ using GetDeviceInfoQueueFamilyTest = ::testing::Test; HWTEST_F(GetDeviceInfoQueueFamilyTest, givenSingleDeviceWhenInitializingCapsThenReturnCorrectFamilies) { auto raiiHwHelper = MockHwHelper::overrideHwHelper(); + VariableBackup backupHwInfo(defaultHwInfo.get()); + defaultHwInfo->capabilityTable.blitterOperationsSupported = true; UltClDeviceFactory deviceFactory{1, 0}; ClDevice &clDevice = *deviceFactory.rootDevices[0]; size_t paramRetSize{}; @@ -746,6 +748,8 @@ HWTEST_F(GetDeviceInfoQueueFamilyTest, givenSingleDeviceWhenInitializingCapsThen HWTEST_F(GetDeviceInfoQueueFamilyTest, givenSubDeviceWhenInitializingCapsThenReturnCorrectFamilies) { auto raiiHwHelper = MockHwHelper::overrideHwHelper(); + VariableBackup backupHwInfo(defaultHwInfo.get()); + defaultHwInfo->capabilityTable.blitterOperationsSupported = true; UltClDeviceFactory deviceFactory{1, 2}; ClDevice &clDevice = *deviceFactory.subDevices[1]; size_t paramRetSize{}; @@ -776,6 +780,8 @@ HWTEST_F(GetDeviceInfoQueueFamilyTest, givenSubDeviceWithoutSupportedEngineWhenI mockHwHelper.disableEngineSupportOnSubDevice = 0b10; // subdevice 1 mockHwHelper.disabledSubDeviceEngineType = aub_stream::EngineType::ENGINE_BCS; + VariableBackup backupHwInfo(defaultHwInfo.get()); + defaultHwInfo->capabilityTable.blitterOperationsSupported = true; UltClDeviceFactory deviceFactory{1, 2}; ClDevice &clDevice0 = *deviceFactory.subDevices[0]; ClDevice &clDevice1 = *deviceFactory.subDevices[1]; diff --git a/opencl/test/unit_test/device/sub_device_tests.cpp b/opencl/test/unit_test/device/sub_device_tests.cpp index 79cf90af30..617455ba73 100644 --- a/opencl/test/unit_test/device/sub_device_tests.cpp +++ b/opencl/test/unit_test/device/sub_device_tests.cpp @@ -234,9 +234,11 @@ TEST(SubDevicesTest, givenSubDevicesWhenGettingDeviceByIdZeroThenGetThisSubDevic TEST(RootDevicesTest, givenRootDeviceWithoutSubdevicesWhenCreateEnginesThenDeviceCreatesCorrectNumberOfEngines) { auto hwInfo = *defaultHwInfo; + hwInfo.capabilityTable.blitterOperationsSupported = true; auto &gpgpuEngines = HwHelper::get(hwInfo.platform.eRenderCoreFamily).getGpgpuEngineInstances(hwInfo); auto executionEnvironment = new MockExecutionEnvironment; + executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(&hwInfo); MockDevice device(executionEnvironment, 0); EXPECT_EQ(0u, device.engines.size()); device.createEngines(); @@ -305,6 +307,7 @@ struct EngineInstancedDeviceTests : public ::testing::Test { auto hwInfo = executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo(); hwInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled = numCcs; hwInfo->featureTable.ftrCCSNode = (numCcs > 0); + hwInfo->capabilityTable.blitterOperationsSupported = true; HwHelper::get(hwInfo->platform.eRenderCoreFamily).adjustDefaultEngineType(hwInfo); if (!multiCcsDevice(*hwInfo, numCcs)) { diff --git a/opencl/test/unit_test/gen12lp/hw_helper_tests_gen12lp.inl b/opencl/test/unit_test/gen12lp/hw_helper_tests_gen12lp.inl index f93134948c..efc53b6ca1 100644 --- a/opencl/test/unit_test/gen12lp/hw_helper_tests_gen12lp.inl +++ b/opencl/test/unit_test/gen12lp/hw_helper_tests_gen12lp.inl @@ -71,6 +71,7 @@ GEN12LPTEST_F(HwHelperTestGen12Lp, givenFtrCcsNodeNotSetAndBcsInfoSetWhenGetGpgp HardwareInfo hwInfo = *defaultHwInfo; hwInfo.featureTable.ftrCCSNode = false; hwInfo.featureTable.ftrBcsInfo = 1; + hwInfo.capabilityTable.blitterOperationsSupported = true; hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_RCS; auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(&hwInfo, 0)); diff --git a/opencl/test/unit_test/helpers/hw_helper_tests_xehp_and_later.cpp b/opencl/test/unit_test/helpers/hw_helper_tests_xehp_and_later.cpp index 1689ade059..7e7e9cabb6 100644 --- a/opencl/test/unit_test/helpers/hw_helper_tests_xehp_and_later.cpp +++ b/opencl/test/unit_test/helpers/hw_helper_tests_xehp_and_later.cpp @@ -94,6 +94,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPAndLater, givenAllFlagsSetWhenGetGp hwInfo.featureTable.ftrCCSNode = true; hwInfo.featureTable.ftrBcsInfo = 1; hwInfo.featureTable.ftrRcsNode = true; + hwInfo.capabilityTable.blitterOperationsSupported = true; hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_CCS; hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 4; @@ -142,6 +143,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPAndLater, givenCcsDisabledWhenGetGp HardwareInfo hwInfo = *defaultHwInfo; hwInfo.featureTable.ftrCCSNode = false; hwInfo.featureTable.ftrBcsInfo = 1; + hwInfo.capabilityTable.blitterOperationsSupported = true; hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_RCS; hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 0; @@ -163,6 +165,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPAndLater, givenCcsDisabledAndNumber hwInfo.featureTable.ftrCCSNode = false; hwInfo.featureTable.ftrBcsInfo = 1; hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_RCS; + hwInfo.capabilityTable.blitterOperationsSupported = true; hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 4; auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(&hwInfo, 0)); diff --git a/opencl/test/unit_test/mem_obj/buffer_bcs_tests.cpp b/opencl/test/unit_test/mem_obj/buffer_bcs_tests.cpp index bf69f94697..38721b1417 100644 --- a/opencl/test/unit_test/mem_obj/buffer_bcs_tests.cpp +++ b/opencl/test/unit_test/mem_obj/buffer_bcs_tests.cpp @@ -66,20 +66,13 @@ struct BcsBufferTests : public ::testing::Test { DebugManager.flags.EnableBlitterForEnqueueOperations.set(1); DebugManager.flags.ForceGpgpuSubmissionForBcsEnqueue.set(1); DebugManager.flags.PreferCopyEngineForCopyBufferToBuffer.set(1); - device = std::make_unique(MockClDevice::createWithNewExecutionEnvironment(nullptr)); - auto &capabilityTable = device->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable; - bool createBcsEngine = !capabilityTable.blitterOperationsSupported; - capabilityTable.blitterOperationsSupported = true; + auto hwInfo = *defaultHwInfo; + hwInfo.capabilityTable.blitterOperationsSupported = true; + device = std::make_unique(MockClDevice::createWithNewExecutionEnvironment(&hwInfo)); if (!HwInfoConfig::get(defaultHwInfo->platform.eProductFamily)->isBlitterFullySupported(device->getHardwareInfo())) { GTEST_SKIP(); } - if (createBcsEngine) { - auto &engine = device->getEngine(getChosenEngineType(device->getHardwareInfo()), EngineUsage::LowPriority); - bcsOsContext.reset(OsContext::create(nullptr, 1, EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_BCS, EngineUsage::Regular}, device->getDeviceBitfield()))); - engine.osContext = bcsOsContext.get(); - engine.commandStreamReceiver->setupContext(*bcsOsContext); - } bcsMockContext = std::make_unique(device.get()); commandQueue.reset(new MockCommandQueueHw(bcsMockContext.get(), device.get(), nullptr)); @@ -105,9 +98,9 @@ struct BcsBufferTests : public ::testing::Test { HWTEST_TEMPLATED_F(BcsBufferTests, givenBufferWithInitializationDataAndBcsCsrWhenCreatingThenUseBlitOperation) { auto bcsCsr = static_cast *>(bcsMockContext->bcsCsr.get()); - auto newMemoryManager = new MockMemoryManager(true, true, *device->getExecutionEnvironment()); - device->getExecutionEnvironment()->memoryManager.reset(newMemoryManager); - bcsMockContext->memoryManager = newMemoryManager; + + static_cast(device->getExecutionEnvironment()->memoryManager.get())->enable64kbpages[0] = true; + static_cast(device->getExecutionEnvironment()->memoryManager.get())->localMemorySupported[0] = true; EXPECT_EQ(0u, bcsCsr->blitBufferCalled); auto bufferForBlt = clUniquePtr(Buffer::create(bcsMockContext.get(), CL_MEM_COPY_HOST_PTR, 2000, &hostPtr, retVal)); diff --git a/opencl/test/unit_test/program/printf_handler_tests.cpp b/opencl/test/unit_test/program/printf_handler_tests.cpp index 94975e0929..2d75b7c36c 100644 --- a/opencl/test/unit_test/program/printf_handler_tests.cpp +++ b/opencl/test/unit_test/program/printf_handler_tests.cpp @@ -129,8 +129,8 @@ HWTEST_F(PrintfHandlerTests, givenEnabledStatelessCompressionWhenPrintEnqueueOut for (auto enable : {-1, 0, 1}) { DebugManager.flags.EnableStatelessCompression.set(enable); - auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr)); - MockContext context; + auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(&hwInfo)); + MockContext context(device.get()); auto kernelInfo = std::make_unique(); kernelInfo->setPrintfSurface(sizeof(uintptr_t), 0); diff --git a/opencl/test/unit_test/xe_hp_core/copy_engine_tests_xe_hp_core.cpp b/opencl/test/unit_test/xe_hp_core/copy_engine_tests_xe_hp_core.cpp index a22460948d..b6e6454d80 100644 --- a/opencl/test/unit_test/xe_hp_core/copy_engine_tests_xe_hp_core.cpp +++ b/opencl/test/unit_test/xe_hp_core/copy_engine_tests_xe_hp_core.cpp @@ -35,6 +35,7 @@ struct BlitXE_HP_CORETests : public ::testing::Test { HardwareInfo hwInfo = *defaultHwInfo; hwInfo.featureTable.ftrBcsInfo = 1; + hwInfo.capabilityTable.blitterOperationsSupported = true; clDevice = std::make_unique(MockDevice::createWithNewExecutionEnvironment(&hwInfo)); } diff --git a/opencl/test/unit_test/xe_hp_core/xehp/hw_helper_tests_xehp.inl b/opencl/test/unit_test/xe_hp_core/xehp/hw_helper_tests_xehp.inl index 5e9732564d..f2033c4c43 100644 --- a/opencl/test/unit_test/xe_hp_core/xehp/hw_helper_tests_xehp.inl +++ b/opencl/test/unit_test/xe_hp_core/xehp/hw_helper_tests_xehp.inl @@ -52,6 +52,7 @@ XEHPTEST_F(HwHelperTestsXeHP, givenRcsDisabledWhenGetGpgpuEnginesCalledThenDontS hwInfo.featureTable.ftrCCSNode = true; hwInfo.featureTable.ftrBcsInfo = 1; hwInfo.featureTable.ftrRcsNode = false; + hwInfo.capabilityTable.blitterOperationsSupported = true; hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_CCS; hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 4; @@ -76,6 +77,7 @@ XEHPTEST_F(HwHelperTestsXeHP, givenRcsDisabledButDebugVariableSetWhenGetGpgpuEng hwInfo.featureTable.ftrCCSNode = true; hwInfo.featureTable.ftrBcsInfo = 1; hwInfo.featureTable.ftrRcsNode = false; + hwInfo.capabilityTable.blitterOperationsSupported = true; hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_CCS; hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 4; diff --git a/shared/source/device/device.cpp b/shared/source/device/device.cpp index 7d927ec011..486aadb007 100644 --- a/shared/source/device/device.cpp +++ b/shared/source/device/device.cpp @@ -307,6 +307,10 @@ bool Device::createEngine(uint32_t deviceCsrIndex, EngineTypeUsage engineTypeUsa const bool isDefaultEngine = defaultEngineType == engineType && engineUsage == EngineUsage::Regular; const bool createAsEngineInstanced = engineInstanced && EngineHelpers::isCcs(engineType); + if (EngineHelpers::isBcs(engineType) && !hwInfo.capabilityTable.blitterOperationsSupported) { + return true; + } + std::unique_ptr commandStreamReceiver = createCommandStreamReceiver(); if (!commandStreamReceiver) { return false; diff --git a/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp b/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp index 38dac71986..7d2f743626 100644 --- a/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp +++ b/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp @@ -1533,13 +1533,15 @@ TEST(CreateWorkPartitionAllocationTest, givenDisabledBlitterWhenInitializingWork TEST(CreateWorkPartitionAllocationTest, givenEnabledBlitterWhenInitializingWorkPartitionAllocationThenDontCopyOnCpu) { DebugManagerStateRestore restore{}; VariableBackup backup(&ImplicitScaling::apiSupport, true); + VariableBackup backupHwInfo(defaultHwInfo.get()); + + defaultHwInfo->capabilityTable.blitterOperationsSupported = true; UltDeviceFactory deviceFactory{1, 2}; MockDevice &device = *deviceFactory.rootDevices[0]; auto memoryManager = static_cast(device.getMemoryManager()); auto commandStreamReceiver = device.getDefaultEngine().commandStreamReceiver; - device.getRootDeviceEnvironmentRef().getMutableHardwareInfo()->capabilityTable.blitterOperationsSupported = true; REQUIRE_BLITTER_OR_SKIP(&device.getHardwareInfo()); memoryManager->freeGraphicsMemory(commandStreamReceiver->getWorkPartitionAllocation()); diff --git a/shared/test/unit_test/device/neo_device_tests.cpp b/shared/test/unit_test/device/neo_device_tests.cpp index 509af21563..50a3afd29f 100644 --- a/shared/test/unit_test/device/neo_device_tests.cpp +++ b/shared/test/unit_test/device/neo_device_tests.cpp @@ -5,15 +5,19 @@ * */ -#include "shared/test/common/fixtures/device_fixture.h" +#include "shared/test/common/helpers/default_hw_info.h" +#include "shared/test/common/helpers/variable_backup.h" +#include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/mocks/ult_device_factory.h" #include "test.h" using namespace NEO; -typedef Test DeviceTest; +TEST(DeviceTest, whenBlitterOperationsSupportIsDisabledThenNoInternalCopyEngineIsReturned) { + VariableBackup backupHwInfo(defaultHwInfo.get()); + defaultHwInfo->capabilityTable.blitterOperationsSupported = false; -TEST_F(DeviceTest, whenBlitterOperationsSupportIsDisabledThenNoInternalCopyEngineIsReturned) { - pDevice->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.blitterOperationsSupported = false; - EXPECT_EQ(nullptr, pDevice->getInternalCopyEngine()); + UltDeviceFactory factory{1, 0}; + EXPECT_EQ(nullptr, factory.rootDevices[0]->getInternalCopyEngine()); }