Skip to content

Commit b0ac4da

Browse files
Set all needed values in SCM
Related-To: NEO-6215 Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
1 parent abbe98b commit b0ac4da

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed

level_zero/core/source/cmdlist/cmdlist_hw.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ struct CommandListCoreFamily : CommandListImp {
223223
ze_result_t appendLaunchKernelSplit(ze_kernel_handle_t hKernel, const ze_group_count_t *pThreadGroupDimensions, ze_event_handle_t hEvent);
224224
ze_result_t prepareIndirectParams(const ze_group_count_t *pThreadGroupDimensions);
225225
void updateStreamProperties(Kernel &kernel, bool isMultiOsContextCapable, bool isCooperative);
226+
void clearComputeModePropertiesIfNeeded(bool requiresCoherency, uint32_t numGrfRequired, uint32_t threadArbitrationPolicy);
226227
void clearCommandsToPatch();
227228

228229
void applyMemoryRangesBarrier(uint32_t numRanges, const size_t *pRangeSizes,

level_zero/core/source/cmdlist/cmdlist_hw.inl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2185,11 +2185,15 @@ void CommandListCoreFamily<gfxCoreFamily>::updateStreamProperties(Kernel &kernel
21852185
finalStreamState.stateComputeMode.setProperties(false, kernelAttributes.numGrfRequired, threadArbitrationPolicy);
21862186

21872187
if (finalStreamState.stateComputeMode.isDirty()) {
2188+
clearComputeModePropertiesIfNeeded(false, kernelAttributes.numGrfRequired, threadArbitrationPolicy);
21882189
NEO::EncodeWA<GfxFamily>::encodeAdditionalPipelineSelect(neoDevice, *commandContainer.getCommandStream(), true);
21892190
NEO::EncodeComputeMode<GfxFamily>::adjustComputeMode(*commandContainer.getCommandStream(), nullptr, finalStreamState.stateComputeMode, hwInfo);
21902191
NEO::EncodeWA<GfxFamily>::encodeAdditionalPipelineSelect(neoDevice, *commandContainer.getCommandStream(), false);
21912192
}
21922193
}
2194+
template <GFXCORE_FAMILY gfxCoreFamily>
2195+
void CommandListCoreFamily<gfxCoreFamily>::clearComputeModePropertiesIfNeeded(bool requiresCoherency, uint32_t numGrfRequired, uint32_t threadArbitrationPolicy) {
2196+
}
21932197

21942198
template <GFXCORE_FAMILY gfxCoreFamily>
21952199
void CommandListCoreFamily<gfxCoreFamily>::clearCommandsToPatch() {

level_zero/core/source/xe_hp_core/xehp/cmdlist_xehp.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313

1414
namespace L0 {
1515

16+
template <>
17+
void CommandListCoreFamily<IGFX_XE_HP_CORE>::clearComputeModePropertiesIfNeeded(bool requiresCoherency, uint32_t numGrfRequired, uint32_t threadArbitrationPolicy) {
18+
finalStreamState.stateComputeMode = {};
19+
finalStreamState.stateComputeMode.setProperties(requiresCoherency, numGrfRequired, threadArbitrationPolicy);
20+
}
21+
1622
template struct CommandListCoreFamily<IGFX_XE_HP_CORE>;
1723

1824
template <>

level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_4.cpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111

1212
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
1313
#include "level_zero/core/test/unit_tests/fixtures/host_pointer_manager_fixture.h"
14+
#include "level_zero/core/test/unit_tests/fixtures/module_fixture.h"
1415
#include "level_zero/core/test/unit_tests/mocks/mock_cmdlist.h"
1516
#include "level_zero/core/test/unit_tests/mocks/mock_cmdqueue.h"
17+
#include "level_zero/core/test/unit_tests/mocks/mock_module.h"
1618

1719
namespace L0 {
1820
namespace ult {
@@ -161,6 +163,56 @@ HWTEST2_F(CommandListCreate, whenCommandListIsCreatedThenFlagsAreCorrectlySet, P
161163
EXPECT_EQ(flag, pCommandListCoreFamily->flags);
162164
}
163165
}
166+
using CommandListAppendLaunchKernel = Test<ModuleFixture>;
167+
HWTEST2_F(CommandListAppendLaunchKernel, GivenComputeModePropertiesWhenUpdateStreamPropertiesIsCalledTwiceThenChangedFieldsAreDirty, IsAtLeastGen12lp) {
168+
using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE;
169+
DebugManagerStateRestore restorer;
170+
171+
Mock<::L0::Kernel> kernel;
172+
auto pMockModule = std::unique_ptr<Module>(new Mock<Module>(device, nullptr));
173+
kernel.module = pMockModule.get();
174+
175+
auto pCommandList = std::make_unique<WhiteBox<::L0::CommandListCoreFamily<gfxCoreFamily>>>();
176+
auto result = pCommandList->initialize(device, NEO::EngineGroupType::Compute, 0u);
177+
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
178+
179+
const_cast<NEO::KernelDescriptor *>(&kernel.getKernelDescriptor())->kernelAttributes.numGrfRequired = 0x100;
180+
pCommandList->updateStreamProperties(kernel, false, false);
181+
EXPECT_TRUE(pCommandList->finalStreamState.stateComputeMode.isCoherencyRequired.isDirty);
182+
EXPECT_TRUE(pCommandList->finalStreamState.stateComputeMode.largeGrfMode.isDirty);
183+
184+
const_cast<NEO::KernelDescriptor *>(&kernel.getKernelDescriptor())->kernelAttributes.numGrfRequired = 0x80;
185+
pCommandList->updateStreamProperties(kernel, false, false);
186+
EXPECT_TRUE(pCommandList->finalStreamState.stateComputeMode.largeGrfMode.isDirty);
187+
if (IsXEHP::isMatched<productFamily>()) {
188+
EXPECT_TRUE(pCommandList->finalStreamState.stateComputeMode.isCoherencyRequired.isDirty);
189+
} else {
190+
EXPECT_FALSE(pCommandList->finalStreamState.stateComputeMode.isCoherencyRequired.isDirty);
191+
}
192+
}
193+
194+
HWTEST2_F(CommandListAppendLaunchKernel, GivenComputeModePropertiesWhenPropertesNotChangedThenAllFieldsAreNotDirty, IsAtLeastGen12lp) {
195+
using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE;
196+
DebugManagerStateRestore restorer;
197+
198+
Mock<::L0::Kernel> kernel;
199+
auto pMockModule = std::unique_ptr<Module>(new Mock<Module>(device, nullptr));
200+
kernel.module = pMockModule.get();
201+
202+
auto pCommandList = std::make_unique<WhiteBox<::L0::CommandListCoreFamily<gfxCoreFamily>>>();
203+
auto result = pCommandList->initialize(device, NEO::EngineGroupType::Compute, 0u);
204+
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
205+
206+
const_cast<NEO::KernelDescriptor *>(&kernel.getKernelDescriptor())->kernelAttributes.numGrfRequired = 0x100;
207+
pCommandList->updateStreamProperties(kernel, false, false);
208+
EXPECT_TRUE(pCommandList->finalStreamState.stateComputeMode.isCoherencyRequired.isDirty);
209+
EXPECT_TRUE(pCommandList->finalStreamState.stateComputeMode.largeGrfMode.isDirty);
210+
211+
pCommandList->updateStreamProperties(kernel, false, false);
212+
EXPECT_FALSE(pCommandList->finalStreamState.stateComputeMode.isCoherencyRequired.isDirty);
213+
214+
EXPECT_FALSE(pCommandList->finalStreamState.stateComputeMode.largeGrfMode.isDirty);
215+
}
164216

165217
using HostPointerManagerCommandListTest = Test<HostPointerManagerFixure>;
166218
HWTEST2_F(HostPointerManagerCommandListTest,

0 commit comments

Comments
 (0)