diff --git a/level_zero/core/source/device/device_imp.cpp b/level_zero/core/source/device/device_imp.cpp index f62ab28d23..22cbd252b6 100644 --- a/level_zero/core/source/device/device_imp.cpp +++ b/level_zero/core/source/device/device_imp.cpp @@ -719,17 +719,4 @@ NEO::GraphicsAllocation *DeviceImp::allocateMemoryFromHostPtr(const void *buffer return allocation; } -template -ze_result_t DeviceImp::isCreatedCommandListCopyOnly(const DescriptionType *desc, bool *useBliter, ExpectedFlagType flag) { - if (desc->flags & flag) { - auto hwInfo = neoDevice->getHardwareInfo(); - if (hwInfo.capabilityTable.blitterOperationsSupported) { - *useBliter = true; - return ZE_RESULT_SUCCESS; - } - return ZE_RESULT_ERROR_INVALID_ENUMERATION; - } - return ZE_RESULT_SUCCESS; -} - } // namespace L0 diff --git a/level_zero/core/source/device/device_imp.h b/level_zero/core/source/device/device_imp.h index cc4e93a9d8..dd1d840c19 100644 --- a/level_zero/core/source/device/device_imp.h +++ b/level_zero/core/source/device/device_imp.h @@ -94,7 +94,17 @@ struct DeviceImp : public Device { protected: template - ze_result_t isCreatedCommandListCopyOnly(const DescriptionType *desc, bool *useBliter, ExpectedFlagType flag); + ze_result_t isCreatedCommandListCopyOnly(const DescriptionType *desc, bool *useBliter, ExpectedFlagType flag) { + if (desc->flags & flag) { + auto hwInfo = neoDevice->getHardwareInfo(); + if (hwInfo.capabilityTable.blitterOperationsSupported) { + *useBliter = NEO::DebugManager.flags.EnableCopyOnlyCommandListsAndCommandQueues.get(); + return ZE_RESULT_SUCCESS; + } + return ZE_RESULT_ERROR_INVALID_ENUMERATION; + } + return ZE_RESULT_SUCCESS; + } NEO::GraphicsAllocation *debugSurface = nullptr; }; diff --git a/level_zero/core/test/unit_tests/mocks/mock_device.h b/level_zero/core/test/unit_tests/mocks/mock_device.h index fed5eab748..74b7bdfc7c 100644 --- a/level_zero/core/test/unit_tests/mocks/mock_device.h +++ b/level_zero/core/test/unit_tests/mocks/mock_device.h @@ -114,6 +114,7 @@ struct Mock : public Device { template <> struct Mock : public L0::DeviceImp { using Base = L0::DeviceImp; + using Base::isCreatedCommandListCopyOnly; explicit Mock(NEO::Device *device, NEO::ExecutionEnvironment *execEnv) { device->incRefInternal(); diff --git a/level_zero/core/test/unit_tests/sources/device/test_device.cpp b/level_zero/core/test/unit_tests/sources/device/test_device.cpp index 40d9b429fe..a9ce17f8c5 100644 --- a/level_zero/core/test/unit_tests/sources/device/test_device.cpp +++ b/level_zero/core/test/unit_tests/sources/device/test_device.cpp @@ -240,5 +240,51 @@ TEST_F(MultipleDevicesDifferentFamilyAndLocalMemorySupportTest, givenTwoDevicesF EXPECT_FALSE(canAccess); } +TEST_F(DeviceTest, givenHwInfoAndCopyOnlyFlagWhenCopyOnlyDebugFlagIsDefaultThenUseBliterIsFalse) { + NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get(); + hwInfo.capabilityTable.blitterOperationsSupported = true; + auto *neoMockDevice = NEO::MockDevice::createWithNewExecutionEnvironment(&hwInfo, rootDeviceIndex); + Mock l0Device(neoMockDevice, neoDevice->getExecutionEnvironment()); + ze_command_list_desc_t desc = {}; + desc.flags = ZE_COMMAND_LIST_FLAG_COPY_ONLY; + auto flag = ZE_COMMAND_LIST_FLAG_COPY_ONLY; + bool useBliter = true; + ze_result_t res = l0Device.isCreatedCommandListCopyOnly(&desc, &useBliter, flag); + EXPECT_FALSE(useBliter); + EXPECT_EQ(ZE_RESULT_SUCCESS, res); +} + +TEST_F(DeviceTest, givenHwInfoAndCopyOnlyFlagWhenCopyOnlyDebugFlagIsEnabledThenUseBliterIsTrue) { + DebugManagerStateRestore dbgRestore; + DebugManager.flags.EnableCopyOnlyCommandListsAndCommandQueues.set(true); + NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get(); + hwInfo.capabilityTable.blitterOperationsSupported = true; + auto *neoMockDevice = NEO::MockDevice::createWithNewExecutionEnvironment(&hwInfo, rootDeviceIndex); + Mock l0Device(neoMockDevice, neoDevice->getExecutionEnvironment()); + ze_command_list_desc_t desc = {}; + desc.flags = ZE_COMMAND_LIST_FLAG_COPY_ONLY; + auto flag = ZE_COMMAND_LIST_FLAG_COPY_ONLY; + bool useBliter = false; + ze_result_t res = l0Device.isCreatedCommandListCopyOnly(&desc, &useBliter, flag); + EXPECT_TRUE(useBliter); + EXPECT_EQ(ZE_RESULT_SUCCESS, res); +} + +TEST_F(DeviceTest, givenHwInfoAndCopyOnlyFlagWhenCopyOnlyDebugFlagIsDisabledThenUseBliterIsFalse) { + DebugManagerStateRestore dbgRestore; + DebugManager.flags.EnableCopyOnlyCommandListsAndCommandQueues.set(false); + NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get(); + hwInfo.capabilityTable.blitterOperationsSupported = true; + auto *neoMockDevice = NEO::MockDevice::createWithNewExecutionEnvironment(&hwInfo, rootDeviceIndex); + Mock l0Device(neoMockDevice, neoDevice->getExecutionEnvironment()); + ze_command_list_desc_t desc = {}; + desc.flags = ZE_COMMAND_LIST_FLAG_COPY_ONLY; + auto flag = ZE_COMMAND_LIST_FLAG_COPY_ONLY; + bool useBliter = false; + ze_result_t res = l0Device.isCreatedCommandListCopyOnly(&desc, &useBliter, flag); + EXPECT_FALSE(useBliter); + EXPECT_EQ(ZE_RESULT_SUCCESS, res); +} + } // namespace ult } // namespace L0 \ No newline at end of file diff --git a/opencl/test/unit_test/test_files/igdrcl.config b/opencl/test/unit_test/test_files/igdrcl.config index b4a72fcb86..5b4bc9ccf2 100644 --- a/opencl/test/unit_test/test_files/igdrcl.config +++ b/opencl/test/unit_test/test_files/igdrcl.config @@ -143,4 +143,5 @@ DirectSubmissionBufferAddressing = -1 DirectSubmissionSemaphoreAddressing = -1 ForceSystemMemoryPlacement = 0 DirectSubmissionDiagnosticExecutionCount = 30 -DisableAtomicForPostSyncs = 0 \ No newline at end of file +DisableAtomicForPostSyncs = 0 +EnableCopyOnlyCommandListsAndCommandQueues = 0 \ No newline at end of file diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index a21f0d15e0..39656dfb67 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -125,6 +125,7 @@ DECLARE_DEBUG_VARIABLE(bool, ForceSamplerLowFilteringPrecision, false, "Force Lo DECLARE_DEBUG_VARIABLE(bool, UseBindlessBuffers, false, "Force compiler to use bindless buffer addressing instead of stateful one") DECLARE_DEBUG_VARIABLE(bool, UseBindlessImages, false, "Force compiler to use bindless image addressing instead of stateful one") DECLARE_DEBUG_VARIABLE(bool, MakeAllBuffersResident, false, "Make all buffers resident after creation") +DECLARE_DEBUG_VARIABLE(bool, EnableCopyOnlyCommandListsAndCommandQueues, false, "Enable copy only commandlists and commandQueues") DECLARE_DEBUG_VARIABLE(int32_t, EnableIntelVme, -1, "-1: default, 0: disabled, 1: Enables cl_intel_motion_estimation extension") DECLARE_DEBUG_VARIABLE(int32_t, EnableIntelAdvancedVme, -1, "-1: default, 0: disabled, 1: Enables cl_intel_advanced_motion_estimation extension") DECLARE_DEBUG_VARIABLE(int32_t, EnableBlitterOperationsSupport, -1, "-1: default, 0: disable, 1: enable")