diff --git a/level_zero/core/source/cmdlist/cmdlist.h b/level_zero/core/source/cmdlist/cmdlist.h index ed7f65413e..59fde6560d 100644 --- a/level_zero/core/source/cmdlist/cmdlist.h +++ b/level_zero/core/source/cmdlist/cmdlist.h @@ -431,6 +431,7 @@ struct CommandList : _ze_command_list_handle_t { CommandListType cmdListType = CommandListType::typeRegular; uint32_t partitionCount = 1; uint32_t defaultMocsIndex = 0; + int32_t defaultThreadArbitrationPolicy = 0; bool isFlushTaskSubmissionEnabled = false; bool isSyncModeQueue = false; diff --git a/level_zero/core/source/cmdlist/cmdlist_hw.inl b/level_zero/core/source/cmdlist/cmdlist_hw.inl index be69d3e4b8..fc0373b743 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw.inl @@ -248,6 +248,10 @@ ze_result_t CommandListCoreFamily::initialize(Device *device, NEO this->inOrderAtomicSignalingEnabled = gfxCoreHelper.inOrderAtomicSignallingEnabled(rootDeviceEnvironment); this->scratchAddressPatchingEnabled = (this->heaplessModeEnabled && !isImmediateType()); this->copyOperationFenceSupported = isCopyOnly() && productHelper.isDeviceToHostCopySignalingFenceRequired(); + this->defaultThreadArbitrationPolicy = gfxCoreHelper.getDefaultThreadArbitrationPolicy(); + if (NEO::debugManager.flags.OverrideThreadArbitrationPolicy.get() != -1) { + this->defaultThreadArbitrationPolicy = NEO::debugManager.flags.OverrideThreadArbitrationPolicy.get(); + } this->commandContainer.doubleSbaWaRef() = this->doubleSbaWa; this->commandContainer.l1CachePolicyDataRef() = &this->l1CachePolicyData; diff --git a/level_zero/core/source/cmdlist/cmdlist_hw_skl_to_tgllp.inl b/level_zero/core/source/cmdlist/cmdlist_hw_skl_to_tgllp.inl index b275178113..bbe480aa2f 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw_skl_to_tgllp.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw_skl_to_tgllp.inl @@ -208,6 +208,7 @@ ze_result_t CommandListCoreFamily::appendLaunchKernelWithParams(K launchParams.additionalSizeParam, // additionalSizeParam 0, // partitionCount launchParams.reserveExtraPayloadSpace, // reserveExtraPayloadSpace + 0, // defaultThreadArbitrationPolicy launchParams.isIndirect, // isIndirect launchParams.isPredicate, // isPredicate false, // isTimestampEvent diff --git a/level_zero/core/source/cmdlist/cmdlist_hw_xehp_and_later.inl b/level_zero/core/source/cmdlist/cmdlist_hw_xehp_and_later.inl index 9eef65d624..3efd816762 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw_xehp_and_later.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw_xehp_and_later.inl @@ -335,6 +335,7 @@ ze_result_t CommandListCoreFamily::appendLaunchKernelWithParams(K launchParams.additionalSizeParam, // additionalSizeParam this->partitionCount, // partitionCount launchParams.reserveExtraPayloadSpace, // reserveExtraPayloadSpace + this->defaultThreadArbitrationPolicy, // defaultThreadArbitrationPolicy launchParams.isIndirect, // isIndirect launchParams.isPredicate, // isPredicate isTimestampEvent, // isTimestampEvent diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_1.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_1.cpp index 53500c6653..00229acde4 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_1.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_1.cpp @@ -203,6 +203,7 @@ HWTEST2_F(CommandListAppendLaunchKernel, givenNotEnoughSpaceInCommandStreamWhenA NEO::additionalKernelLaunchSizeParamNotSet, // additionalSizeParam 0, // partitionCount 0, // reserveExtraPayloadSpace + 0, // defaultThreadArbitrationPolicy false, // isIndirect false, // isPredicate false, // isTimestampEvent diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_3.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_3.cpp index fc34531a5f..b6cd95935f 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_3.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_3.cpp @@ -700,6 +700,7 @@ HWTEST2_F(CommandListAppendLaunchKernel, givenNotEnoughSpaceInCommandStreamWhenA NEO::additionalKernelLaunchSizeParamNotSet, // additionalSizeParam 0, // partitionCount 0, // reserveExtraPayloadSpace + 0, // defaultThreadArbitrationPolicy false, // isIndirect false, // isPredicate false, // isTimestampEvent diff --git a/shared/source/command_container/command_encoder.h b/shared/source/command_container/command_encoder.h index 42462c2a72..fefd5afeea 100644 --- a/shared/source/command_container/command_encoder.h +++ b/shared/source/command_container/command_encoder.h @@ -62,6 +62,7 @@ struct EncodeDispatchKernelArgs { uint32_t additionalSizeParam = NEO::additionalKernelLaunchSizeParamNotSet; uint32_t partitionCount = 0u; uint32_t reserveExtraPayloadSpace = 0; + int32_t defaultThreadArbitrationPolicy = 0; bool isIndirect = false; bool isPredicate = false; bool isTimestampEvent = false; @@ -125,6 +126,9 @@ struct EncodeDispatchKernel { static void appendAdditionalIDDFields(InterfaceDescriptorType *pInterfaceDescriptor, const RootDeviceEnvironment &rootDeviceEnvironment, const uint32_t threadsPerThreadGroup, uint32_t slmTotalSize, SlmPolicy slmPolicy); + template + static void encodeEuSchedulingPolicy(InterfaceDescriptorType *pInterfaceDescriptor, const KernelDescriptor &kernelDesc, int32_t defaultThreadArbitrationPolicy); + template static void encodeThreadData(WalkerType &walkerCmd, const uint32_t *startWorkGroup, diff --git a/shared/source/command_container/command_encoder.inl b/shared/source/command_container/command_encoder.inl index a2a789dd55..328446ed18 100644 --- a/shared/source/command_container/command_encoder.inl +++ b/shared/source/command_container/command_encoder.inl @@ -589,6 +589,11 @@ bool EncodeDispatchKernel::inlineDataProgrammingRequired(const KernelDes return false; } +template +template +void EncodeDispatchKernel::encodeEuSchedulingPolicy(InterfaceDescriptorType *pInterfaceDescriptor, const KernelDescriptor &kernelDesc, int32_t defaultThreadArbitrationPolicy) { +} + template template void EncodeDispatchKernel::adjustTimestampPacket(WalkerType &walkerCmd, const EncodeDispatchKernelArgs &args) {} diff --git a/shared/source/command_container/command_encoder_enablers.inl b/shared/source/command_container/command_encoder_enablers.inl index 55f010618e..e847293140 100644 --- a/shared/source/command_container/command_encoder_enablers.inl +++ b/shared/source/command_container/command_encoder_enablers.inl @@ -25,6 +25,7 @@ template void NEO::EncodeDispatchKernel::programBarrierEnable::setScratchAddress(uint64_t &scratchAddress, uint32_t requiredScratchSlot0Size, uint32_t requiredScratchSlot1Size, IndirectHeap *ssh, CommandStreamReceiver &csr); template void NEO::EncodeDispatchKernel::setScratchAddress(uint64_t &scratchAddress, uint32_t requiredScratchSlot0Size, uint32_t requiredScratchSlot1Size, IndirectHeap *ssh, CommandStreamReceiver &csr); template void NEO::EncodeDispatchKernel::programInlineDataHeapless(uint8_t *inlineDataPtr, EncodeDispatchKernelArgs &args, CommandContainer &container, uint64_t offsetThreadData); +template void NEO::EncodeDispatchKernel::encodeEuSchedulingPolicy(Family::INTERFACE_DESCRIPTOR_DATA *pInterfaceDescriptor, const KernelDescriptor &kernelDesc, int32_t defaultThreadArbitrationPolicy); template struct NEO::EncodeStates; template struct NEO::EncodeMath; diff --git a/shared/source/command_container/command_encoder_xehp_and_later.inl b/shared/source/command_container/command_encoder_xehp_and_later.inl index b2951674a9..049b29da6f 100644 --- a/shared/source/command_container/command_encoder_xehp_and_later.inl +++ b/shared/source/command_container/command_encoder_xehp_and_later.inl @@ -115,6 +115,10 @@ void EncodeDispatchKernel::encode(CommandContainer &container, EncodeDis kernelDescriptor.kernelAttributes.barrierCount, hwInfo); + if (args.isHeaplessStateInitEnabled) { + EncodeDispatchKernel::encodeEuSchedulingPolicy(&idd, kernelDescriptor, args.defaultThreadArbitrationPolicy); + } + auto &gfxCoreHelper = args.device->getGfxCoreHelper(); auto slmSize = static_cast( gfxCoreHelper.computeSlmValues(hwInfo, args.dispatchInterface->getSlmTotalSize())); diff --git a/shared/test/unit_test/command_container/command_encoder_tests.cpp b/shared/test/unit_test/command_container/command_encoder_tests.cpp index bb02f30728..2a8ebc6b05 100644 --- a/shared/test/unit_test/command_container/command_encoder_tests.cpp +++ b/shared/test/unit_test/command_container/command_encoder_tests.cpp @@ -15,6 +15,7 @@ #include "shared/source/helpers/gfx_core_helper.h" #include "shared/source/helpers/in_order_cmd_helpers.h" #include "shared/source/helpers/pipe_control_args.h" +#include "shared/source/kernel/kernel_descriptor.h" #include "shared/source/memory_manager/graphics_allocation.h" #include "shared/source/memory_manager/memory_manager.h" #include "shared/source/os_interface/product_helper.h" @@ -678,4 +679,21 @@ HWTEST2_F(CommandEncoderTests, whenAskingForImplicitScalingValuesThenAlwaysRetur EXPECT_EQ(static_cast(GfxCoreHelperHw::getSingleTimestampPacketSizeHw()), ImplicitScalingDispatch::getTimeStampPostSyncOffset()); EXPECT_FALSE(ImplicitScalingDispatch::platformSupportsImplicitScaling(*rootExecEnv)); -} \ No newline at end of file +} + +HWTEST_F(CommandEncoderTests, givenInterfaceDescriptorWhenEncodeEuSchedulingPolicyIsCalledThenNothingIsChanged) { + using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA; + + INTERFACE_DESCRIPTOR_DATA idd = FamilyType::cmdInitInterfaceDescriptorData; + auto expectedIdd = idd; + + KernelDescriptor kernelDescriptor; + kernelDescriptor.kernelAttributes.threadArbitrationPolicy = ThreadArbitrationPolicy::AgeBased; + int32_t defaultThreadArbitrationPolicy = ThreadArbitrationPolicy::RoundRobin; + EncodeDispatchKernel::encodeEuSchedulingPolicy(&idd, kernelDescriptor, defaultThreadArbitrationPolicy); + + constexpr uint32_t iddSizeInDW = 8; + for (uint32_t i = 0u; i < iddSizeInDW; i++) { + EXPECT_EQ(expectedIdd.getRawData(i), idd.getRawData(i)); + } +} diff --git a/shared/test/unit_test/fixtures/command_container_fixture.cpp b/shared/test/unit_test/fixtures/command_container_fixture.cpp index 577b310a20..653c101288 100644 --- a/shared/test/unit_test/fixtures/command_container_fixture.cpp +++ b/shared/test/unit_test/fixtures/command_container_fixture.cpp @@ -57,6 +57,7 @@ EncodeDispatchKernelArgs CommandEncodeStatesFixture::createDefaultDispatchKernel NEO::additionalKernelLaunchSizeParamNotSet, // additionalSizeParam 1, // partitionCount 0, // reserveExtraPayloadSpace + 0, // defaultThreadArbitrationPolicy false, // isIndirect false, // isPredicate false, // isTimestampEvent