diff --git a/level_zero/core/source/cmdqueue/cmdqueue.cpp b/level_zero/core/source/cmdqueue/cmdqueue.cpp index 5aa94d5c32..82790b447b 100644 --- a/level_zero/core/source/cmdqueue/cmdqueue.cpp +++ b/level_zero/core/source/cmdqueue/cmdqueue.cpp @@ -368,6 +368,10 @@ QueueProperties CommandQueue::extractQueueProperties(const ze_command_queue_desc auto baseProperties = static_cast(desc.pNext); + if ((desc.flags & ZE_COMMAND_QUEUE_FLAG_COPY_OFFLOAD_HINT) == ZE_COMMAND_QUEUE_FLAG_COPY_OFFLOAD_HINT) { + queueProperties.copyOffloadHint = true; + } + while (baseProperties) { if (static_cast(baseProperties->stype) == ZEX_INTEL_STRUCTURE_TYPE_QUEUE_ALLOCATE_MSIX_HINT_EXP_PROPERTIES) { queueProperties.interruptHint = static_cast(desc.pNext)->uniqueMsix; diff --git a/level_zero/core/source/helpers/default_descriptors.cpp b/level_zero/core/source/helpers/default_descriptors.cpp index f878c74d5a..9da72327b4 100644 --- a/level_zero/core/source/helpers/default_descriptors.cpp +++ b/level_zero/core/source/helpers/default_descriptors.cpp @@ -18,17 +18,12 @@ const ze_context_desc_t contextDesc{ .flags = static_cast(0), }; -static const zex_intel_queue_copy_operations_offload_hint_exp_desc_t copyOffloadHint = { - .stype = ZEX_INTEL_STRUCTURE_TYPE_QUEUE_COPY_OPERATIONS_OFFLOAD_HINT_EXP_PROPERTIES, - .pNext = nullptr, - .copyOffloadEnabled = true}; - const ze_command_queue_desc_t commandQueueDesc = { .stype = ze_structure_type_t::ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC, - .pNext = ©OffloadHint, + .pNext = nullptr, .ordinal = 0, .index = 0, - .flags = static_cast(ZE_COMMAND_QUEUE_FLAG_IN_ORDER), + .flags = static_cast(ZE_COMMAND_QUEUE_FLAG_IN_ORDER | ZE_COMMAND_QUEUE_FLAG_COPY_OFFLOAD_HINT), .mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS, .priority = ZE_COMMAND_QUEUE_PRIORITY_NORMAL, }; diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_in_order_cmdlist_2.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_in_order_cmdlist_2.cpp index 696d4a2021..d074be319e 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_in_order_cmdlist_2.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_in_order_cmdlist_2.cpp @@ -357,6 +357,45 @@ HWTEST2_F(CopyOffloadInOrderTests, givenQueueDescriptorWhenCreatingCmdListThenEn } } +HWTEST2_F(CopyOffloadInOrderTests, givenQueueDescriptorWithCopyOffloadFlagWhenCreatingCmdListThenEnableCopyOffload, IsAtLeastXeCore) { + NEO::debugManager.flags.ForceCopyOperationOffloadForComputeCmdList.set(-1); + + ze_command_list_handle_t cmdListHandle; + + ze_command_queue_desc_t cmdQueueDesc = {ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC}; + cmdQueueDesc.priority = ZE_COMMAND_QUEUE_PRIORITY_NORMAL; + cmdQueueDesc.flags = ZE_COMMAND_QUEUE_FLAG_IN_ORDER | ZE_COMMAND_QUEUE_FLAG_COPY_OFFLOAD_HINT; + cmdQueueDesc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS; + + auto dcFlushRequired = device->getProductHelper().isDcFlushAllowed(); + + { + EXPECT_EQ(ZE_RESULT_SUCCESS, zeCommandListCreateImmediate(context, device, &cmdQueueDesc, &cmdListHandle)); + auto cmdList = static_cast> *>(CommandList::fromHandle(cmdListHandle)); + + if (dcFlushRequired) { + EXPECT_EQ(CopyOffloadModes::disabled, cmdList->copyOffloadMode); + EXPECT_EQ(nullptr, cmdList->cmdQImmediateCopyOffload); + } else { + EXPECT_NE(CopyOffloadModes::disabled, cmdList->copyOffloadMode); + EXPECT_NE(nullptr, cmdList->cmdQImmediateCopyOffload); + } + + zeCommandListDestroy(cmdListHandle); + } + + { + cmdQueueDesc.flags = ZE_COMMAND_QUEUE_FLAG_IN_ORDER; + + EXPECT_EQ(ZE_RESULT_SUCCESS, zeCommandListCreateImmediate(context, device, &cmdQueueDesc, &cmdListHandle)); + auto cmdList = static_cast> *>(CommandList::fromHandle(cmdListHandle)); + EXPECT_EQ(CopyOffloadModes::disabled, cmdList->copyOffloadMode); + EXPECT_EQ(nullptr, cmdList->cmdQImmediateCopyOffload); + + zeCommandListDestroy(cmdListHandle); + } +} + HWTEST_F(CopyOffloadInOrderTests, givenNonDualStreamOffloadWhenCreatingCmdListThenAcceptOffloadHint) { zex_intel_queue_copy_operations_offload_hint_exp_desc_t copyOffloadDesc = {ZEX_INTEL_STRUCTURE_TYPE_QUEUE_COPY_OPERATIONS_OFFLOAD_HINT_EXP_PROPERTIES}; copyOffloadDesc.copyOffloadEnabled = true; diff --git a/level_zero/include/level_zero/ze_intel_gpu.h b/level_zero/include/level_zero/ze_intel_gpu.h index 13b52e00d7..0f0b07bbac 100644 --- a/level_zero/include/level_zero/ze_intel_gpu.h +++ b/level_zero/include/level_zero/ze_intel_gpu.h @@ -175,6 +175,13 @@ typedef enum _zex_intel_queue_copy_operations_offload_hint_exp_version_t { ZEX_INTEL_QUEUE_COPY_OPERATIONS_OFFLOAD_HINT_EXP_VERSION_FORCE_UINT32 = 0x7fffffff } zex_intel_queue_copy_operations_offload_hint_exp_version_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Command queue flag for enabling copy operations offload +/// +/// If set, try to offload copy operations to different engines. Applicable only for compute queues. +/// This is only a hint. Driver may ignore it per append call, based on platform capabilities or internal heuristics. +#define ZE_COMMAND_QUEUE_FLAG_COPY_OFFLOAD_HINT ZE_BIT(2) + #ifndef ZE_INTEL_GET_DRIVER_VERSION_STRING_EXP_NAME /// @brief Extension name for query to read the Intel Level Zero Driver Version String #define ZE_INTEL_GET_DRIVER_VERSION_STRING_EXP_NAME "ZE_intel_get_driver_version_string"