Skip to content

Commit 1a34586

Browse files
Make sure sip kernel is initialized for aub tests
Signed-off-by: Kamil Kopryk <[email protected]>
1 parent 8482eb6 commit 1a34586

File tree

11 files changed

+68
-9
lines changed

11 files changed

+68
-9
lines changed

level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_enqueue_cmdlist.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,7 @@ HWTEST2_F(MultiDeviceCommandQueueExecuteCommandLists, givenMultiplePartitionCoun
814814
desc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS;
815815

816816
ze_result_t returnValue;
817+
817818
auto commandQueue = whitebox_cast(CommandQueue::create(productFamily,
818819
device,
819820
device->getNEODevice()->getDefaultEngine().commandStreamReceiver,
@@ -823,6 +824,11 @@ HWTEST2_F(MultiDeviceCommandQueueExecuteCommandLists, givenMultiplePartitionCoun
823824
returnValue));
824825
EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue);
825826

827+
auto &commandStreamReceiver = device->getNEODevice()->getDefaultEngine().commandStreamReceiver;
828+
if (device->getNEODevice()->getPreemptionMode() == PreemptionMode::MidThread || device->getNEODevice()->isDebuggerActive()) {
829+
commandStreamReceiver->createPreemptionAllocation();
830+
}
831+
826832
ze_fence_desc_t fenceDesc{};
827833
auto fence = whitebox_cast(Fence::create(commandQueue, &fenceDesc));
828834
ASSERT_NE(nullptr, fence);

level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ TEST(Debugger, givenL0DebuggerOFFWhenGettingStateSaveAreaHeaderThenValidSipTypeI
100100
auto &stateSaveAreaHeader = SipKernel::getSipKernel(*neoDevice).getStateSaveAreaHeader();
101101

102102
if (isHexadecimalArrayPreferred) {
103-
auto &expectedStateSaveAreaHeader = neoDevice->getRootDeviceEnvironment().sipKernels[static_cast<uint32_t>(sipType)]->getStateSaveAreaHeader();
103+
auto sipKernel = neoDevice->getRootDeviceEnvironment().sipKernels[static_cast<uint32_t>(sipType)].get();
104+
ASSERT_NE(sipKernel, nullptr);
105+
auto &expectedStateSaveAreaHeader = sipKernel->getStateSaveAreaHeader();
104106
EXPECT_EQ(expectedStateSaveAreaHeader, stateSaveAreaHeader);
105107
} else {
106108
auto &expectedStateSaveAreaHeader = neoDevice->getBuiltIns()->getSipKernel(sipType, *neoDevice).getStateSaveAreaHeader();

level_zero/core/test/unit_tests/sources/image/test_image.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "shared/test/common/helpers/default_hw_info.h"
1212
#include "shared/test/common/mocks/mock_device.h"
1313
#include "shared/test/common/mocks/mock_gmm_client_context.h"
14+
#include "shared/test/common/mocks/mock_sip.h"
1415

1516
#include "test.h"
1617

@@ -424,6 +425,7 @@ class FailMemoryManagerMock : public NEO::OsAgnosticMemoryManager {
424425

425426
HWTEST2_F(ImageCreate, givenImageDescWhenFailImageAllocationThenProperErrorIsReturned, ImageSupport) {
426427
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
428+
VariableBackup<bool> backupSipInitType{&MockSipData::useMockSip};
427429

428430
ze_image_desc_t desc = {};
429431

@@ -440,6 +442,11 @@ HWTEST2_F(ImageCreate, givenImageDescWhenFailImageAllocationThenProperErrorIsRet
440442
desc.format.z = ZE_IMAGE_FORMAT_SWIZZLE_1;
441443
desc.format.w = ZE_IMAGE_FORMAT_SWIZZLE_X;
442444

445+
auto isHexadecimalArrayPrefered = NEO::HwHelper::get(NEO::defaultHwInfo->platform.eRenderCoreFamily).isSipKernelAsHexadecimalArrayPreferred();
446+
if (isHexadecimalArrayPrefered) {
447+
backupSipInitType = true;
448+
}
449+
443450
NEO::MockDevice *neoDevice = nullptr;
444451
neoDevice = NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(NEO::defaultHwInfo.get());
445452
NEO::MemoryManager *currMemoryManager = new FailMemoryManagerMock(*neoDevice->executionEnvironment);

opencl/test/unit_test/command_queue/dispatch_walker_tests_xehp_and_later.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,6 +1431,9 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPAndLaterDispatchWalkerBasicTestDynamicPartition
14311431
size_t gws[] = {128, 1, 1};
14321432
size_t lws[] = {8, 1, 1};
14331433
auto &commandStreamReceiver = cmdQ->getUltCommandStreamReceiver();
1434+
if (device->getPreemptionMode() == PreemptionMode::MidThread || device->isDebuggerActive()) {
1435+
commandStreamReceiver.createPreemptionAllocation();
1436+
}
14341437
EXPECT_EQ(1u, commandStreamReceiver.activePartitions);
14351438
cmdQ->enqueueKernel(kernel->mockKernel, 1, nullptr, gws, lws, 0, nullptr, nullptr);
14361439
EXPECT_EQ(1u, commandStreamReceiver.activePartitions);
@@ -1464,6 +1467,9 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPAndLaterDispatchWalkerBasicTestStaticPartition,
14641467
size_t gws[] = {128, 1, 1};
14651468
size_t lws[] = {8, 1, 1};
14661469
auto &commandStreamReceiver = cmdQ->getUltCommandStreamReceiver();
1470+
if (device->getPreemptionMode() == PreemptionMode::MidThread || device->isDebuggerActive()) {
1471+
commandStreamReceiver.createPreemptionAllocation();
1472+
}
14671473
EXPECT_EQ(1u, commandStreamReceiver.activePartitions);
14681474
cmdQ->enqueueKernel(kernel->mockKernel, 1, nullptr, gws, lws, 0, nullptr, nullptr);
14691475
EXPECT_EQ(1u, commandStreamReceiver.activePartitions);

opencl/test/unit_test/command_queue/enqueue_with_walker_partition_tests.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, EnqueueWithWalkerPartitionTests, givenCsrWithSpecif
4444

4545
MockCommandQueueHw<FamilyType> commandQueue(context.get(), rootDevice.get(), nullptr);
4646
commandQueue.gpgpuEngine = &engineControlForFusedQueue;
47+
rootDevice->setPreemptionMode(PreemptionMode::Disabled);
4748
MockKernelWithInternals kernel(*rootDevice, context.get());
4849

4950
size_t offset[3] = {0, 0, 0};

opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_1_tests.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,6 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, GivenEnoughMemoryOnlyForPreambleAn
10011001
hardwareInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 1;
10021002
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hardwareInfo, 0u));
10031003
auto &commandStreamReceiver = mockDevice->getUltCommandStreamReceiver<FamilyType>();
1004-
10051004
commandStreamReceiver.timestampPacketWriteEnabled = false;
10061005
// Force a PIPE_CONTROL through a taskLevel transition
10071006
taskLevel = commandStreamReceiver.peekTaskLevel() + 1;

opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_tests_xehp_and_later.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,9 @@ struct CommandStreamReceiverFlushTaskXeHPAndLaterMultiTileTests : public Command
813813
HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverFlushTaskXeHPAndLaterMultiTileTests,
814814
givenMultipleStaticActivePartitionsWhenFlushingTaskThenExpectTagUpdatePipeControlWithPartitionFlagOnAndActivePartitionConfig) {
815815
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
816+
if (pDevice->getPreemptionMode() == PreemptionMode::MidThread || pDevice->isDebuggerActive()) {
817+
commandStreamReceiver.createPreemptionAllocation();
818+
}
816819
EXPECT_EQ(1u, commandStreamReceiver.activePartitionsConfig);
817820
commandStreamReceiver.activePartitions = 2;
818821
commandStreamReceiver.taskCount = 3;
@@ -830,6 +833,9 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverFlushTaskXeHPAndLaterMultiTile
830833
HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverFlushTaskXeHPAndLaterMultiTileTests,
831834
givenMultipleDynamicActivePartitionsWhenFlushingTaskThenExpectTagUpdatePipeControlWithoutPartitionFlagOnAndNoActivePartitionConfig) {
832835
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
836+
if (pDevice->getPreemptionMode() == PreemptionMode::MidThread || pDevice->isDebuggerActive()) {
837+
commandStreamReceiver.createPreemptionAllocation();
838+
}
833839
commandStreamReceiver.activePartitions = 2;
834840
commandStreamReceiver.taskCount = 3;
835841
commandStreamReceiver.staticWorkPartitioningEnabled = false;
@@ -846,6 +852,9 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverFlushTaskXeHPAndLaterMultiTile
846852
HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverFlushTaskXeHPAndLaterMultiTileTests,
847853
givenSingleStaticActivePartitionWhenFlushingTaskThenExpectTagUpdatePipeControlWithoutPartitionFlagOnAndNoActivePartitionConfig) {
848854
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
855+
if (pDevice->getPreemptionMode() == PreemptionMode::MidThread || pDevice->isDebuggerActive()) {
856+
commandStreamReceiver.createPreemptionAllocation();
857+
}
849858
commandStreamReceiver.activePartitions = 1;
850859
commandStreamReceiver.taskCount = 3;
851860
flushTask(commandStreamReceiver, true);
@@ -864,6 +873,9 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverFlushTaskXeHPAndLaterMultiTile
864873
HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverFlushTaskXeHPAndLaterMultiTileTests,
865874
givenMultipleStaticActivePartitionsWhenFlushingTaskTwiceThenExpectTagUpdatePipeControlWithPartitionFlagOnAndNoActivePartitionConfigAtSecondFlush) {
866875
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
876+
if (pDevice->getPreemptionMode() == PreemptionMode::MidThread || pDevice->isDebuggerActive()) {
877+
commandStreamReceiver.createPreemptionAllocation();
878+
}
867879
EXPECT_EQ(1u, commandStreamReceiver.activePartitionsConfig);
868880
commandStreamReceiver.activePartitions = 2;
869881
commandStreamReceiver.taskCount = 3;

opencl/test/unit_test/command_stream/command_stream_receiver_hw_1_tests.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,27 @@ HWTEST_F(UltCommandStreamReceiverTest, givenSentStateSipFlagSetWhenGetRequiredSt
102102
EXPECT_EQ(sizeForStateSip, sizeWithStateSipIsNotSent - sizeWhenSipIsSent);
103103
}
104104

105+
HWTEST_F(UltCommandStreamReceiverTest, whenGetCmdSizeForPerDssBackedBufferIsCalledThenCorrectResultIsReturned) {
106+
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
107+
DispatchFlags dispatchFlags = DispatchFlagsHelper::createDefaultDispatchFlags();
108+
dispatchFlags.usePerDssBackedBuffer = false;
109+
commandStreamReceiver.isPerDssBackedBufferSent = true;
110+
auto basicSize = commandStreamReceiver.getRequiredCmdStreamSize(dispatchFlags, *pDevice);
111+
112+
{
113+
dispatchFlags.usePerDssBackedBuffer = true;
114+
commandStreamReceiver.isPerDssBackedBufferSent = true;
115+
auto newSize = commandStreamReceiver.getRequiredCmdStreamSize(dispatchFlags, *pDevice);
116+
EXPECT_EQ(basicSize, newSize);
117+
}
118+
{
119+
dispatchFlags.usePerDssBackedBuffer = true;
120+
commandStreamReceiver.isPerDssBackedBufferSent = false;
121+
auto newSize = commandStreamReceiver.getRequiredCmdStreamSize(dispatchFlags, *pDevice);
122+
EXPECT_EQ(basicSize, newSize - commandStreamReceiver.getCmdSizeForPerDssBackedBuffer(pDevice->getHardwareInfo()));
123+
}
124+
}
125+
105126
HWTEST_F(UltCommandStreamReceiverTest, givenSentStateSipFlagSetAndSourceLevelDebuggerIsActiveWhenGetRequiredStateSipCmdSizeIsCalledThenStateSipCmdSizeIsIncluded) {
106127
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
107128
DispatchFlags dispatchFlags = DispatchFlagsHelper::createDefaultDispatchFlags();

shared/source/built_ins/sip.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,18 @@ std::string SipKernel::createHeaderFilename(const std::string &fileName) {
152152
}
153153

154154
bool SipKernel::initHexadecimalArraySipKernel(SipKernelType type, Device &device) {
155+
uint32_t sipIndex = static_cast<uint32_t>(type);
156+
uint32_t rootDeviceIndex = device.getRootDeviceIndex();
157+
auto sipKenel = device.getExecutionEnvironment()->rootDeviceEnvironments[rootDeviceIndex]->sipKernels[sipIndex].get();
158+
if (sipKenel != nullptr) {
159+
return true;
160+
}
161+
155162
uint32_t *sipKernelBinary = nullptr;
156163
size_t kernelBinarySize = 0u;
157164
auto &hwInfo = device.getHardwareInfo();
158165
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
159166
hwHelper.setSipKernelData(sipKernelBinary, kernelBinarySize);
160-
161-
uint32_t sipIndex = static_cast<uint32_t>(type);
162-
uint32_t rootDeviceIndex = device.getRootDeviceIndex();
163-
if (device.getExecutionEnvironment()->rootDeviceEnvironments[rootDeviceIndex]->sipKernels[sipIndex].get() != nullptr) {
164-
return true;
165-
}
166167
const auto allocType = GraphicsAllocation::AllocationType::KERNEL_ISA_INTERNAL;
167168
AllocationProperties properties = {rootDeviceIndex, kernelBinarySize, allocType, device.getDeviceBitfield()};
168169
properties.flags.use32BitFrontWindow = false;

shared/source/command_stream/command_stream_receiver_hw_base.inl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,9 @@ size_t CommandStreamReceiverHw<GfxFamily>::getRequiredCmdStreamSize(const Dispat
815815
size += getCmdSizeForMediaSampler(dispatchFlags.pipelineSelectArgs.mediaSamplerRequired);
816816
size += getCmdSizeForPipelineSelect();
817817
size += getCmdSizeForPreemption(dispatchFlags);
818-
size += getCmdSizeForPerDssBackedBuffer(device.getHardwareInfo());
818+
if (dispatchFlags.usePerDssBackedBuffer && !isPerDssBackedBufferSent) {
819+
size += getCmdSizeForPerDssBackedBuffer(device.getHardwareInfo());
820+
}
819821
size += getCmdSizeForEpilogue(dispatchFlags);
820822
size += getCmdsSizeForHardwareContext();
821823
size += getCmdSizeForActivePartitionConfig();

0 commit comments

Comments
 (0)