Skip to content

Commit 7d109c4

Browse files
Do not execute multi-tile command list on single-tile command queue
Signed-off-by: Zbigniew Zdanowicz <[email protected]>
1 parent d087c6a commit 7d109c4

File tree

8 files changed

+62
-5
lines changed

8 files changed

+62
-5
lines changed

level_zero/core/source/cmdqueue/cmdqueue.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ ze_result_t CommandQueueImp::initialize(bool copyOnly, bool isInternal) {
5353
commandStream->replaceGraphicsAllocation(bufferAllocation);
5454
isCopyOnlyCommandQueue = copyOnly;
5555
preemptionCmdSyncProgramming = getPreemptionCmdProgramming();
56+
activeSubDevices = static_cast<uint32_t>(csr->getOsContext().getDeviceBitfield().count());
5657
}
5758
return returnValue;
5859
}
@@ -156,8 +157,9 @@ CommandQueue *CommandQueue::create(uint32_t productFamily, Device *device, NEO::
156157
}
157158
}
158159

159-
csr->getOsContext().ensureContextInitialized();
160-
csr->initDirectSubmission(*device->getNEODevice(), csr->getOsContext());
160+
auto &osContext = csr->getOsContext();
161+
osContext.ensureContextInitialized();
162+
csr->initDirectSubmission(*device->getNEODevice(), osContext);
161163
return commandQueue;
162164
}
163165

level_zero/core/source/cmdqueue/cmdqueue.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ struct CommandQueue : _ze_command_queue_handle_t {
5858
protected:
5959
NEO::PreemptionMode commandQueuePreemptionMode = NEO::PreemptionMode::Initial;
6060
uint32_t partitionCount = 1;
61+
uint32_t activeSubDevices = 1;
6162
bool preemptionCmdSyncProgramming = true;
6263
bool commandQueueDebugCmdsProgrammed = false;
6364
bool isCopyOnlyCommandQueue = false;

level_zero/core/source/cmdqueue/cmdqueue_hw.inl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ ze_result_t CommandQueueHw<gfxCoreFamily>::executeCommandLists(
8888
return ZE_RESULT_ERROR_INVALID_COMMAND_LIST_TYPE;
8989
}
9090

91+
if (this->activeSubDevices < commandList->partitionCount) {
92+
return ZE_RESULT_ERROR_INVALID_COMMAND_LIST_TYPE;
93+
}
94+
9195
if (commandList->containsCooperativeKernels()) {
9296
anyCommandListWithCooperativeKernels = true;
9397
} else {

level_zero/core/test/unit_tests/fixtures/device_fixture.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,5 +138,13 @@ void MultipleDevicesWithCustomHwInfo::SetUp() {
138138
driverHandle->initialize(std::move(devices));
139139
}
140140

141+
void SingleRootMultiSubDeviceFixture::SetUp() {
142+
MultiDeviceFixture::numRootDevices = 1u;
143+
MultiDeviceFixture::SetUp();
144+
145+
device = driverHandle->devices[0];
146+
neoDevice = device->getNEODevice();
147+
}
148+
141149
} // namespace ult
142150
} // namespace L0

level_zero/core/test/unit_tests/fixtures/device_fixture.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ struct MultiDeviceFixture {
7171
L0::ContextImp *context = nullptr;
7272
};
7373

74+
struct SingleRootMultiSubDeviceFixture : public MultiDeviceFixture {
75+
void SetUp() override;
76+
77+
L0::Device *device = nullptr;
78+
NEO::Device *neoDevice = nullptr;
79+
};
80+
7481
struct ContextFixture : DeviceFixture {
7582
void SetUp() override;
7683
void TearDown() override;

level_zero/core/test/unit_tests/mocks/mock_cmdqueue.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ struct WhiteBox<::L0::CommandQueue> : public ::L0::CommandQueueImp {
2828
using BaseClass::submitBatchBuffer;
2929
using BaseClass::synchronizeByPollingForTaskCount;
3030
using BaseClass::taskCount;
31+
using CommandQueue::activeSubDevices;
3132
using CommandQueue::commandQueuePreemptionMode;
3233
using CommandQueue::internalUsage;
3334
using CommandQueue::partitionCount;
@@ -86,6 +87,7 @@ struct MockCommandQueueHw : public L0::CommandQueueHw<gfxCoreFamily> {
8687
using BaseClass = ::L0::CommandQueueHw<gfxCoreFamily>;
8788
using BaseClass::commandStream;
8889
using BaseClass::printfFunctionContainer;
90+
using L0::CommandQueue::activeSubDevices;
8991
using L0::CommandQueue::internalUsage;
9092
using L0::CommandQueue::partitionCount;
9193
using L0::CommandQueue::preemptionCmdSyncProgramming;

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

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,6 +1592,7 @@ HWTEST_TEMPLATED_F(AubCsrTest, givenAubCsrWhenCallingExecuteCommandListsThenPoll
15921592
L0::CommandQueue::fromHandle(commandQueue)->destroy();
15931593
}
15941594
using CommandQueueSynchronizeTest = Test<ContextFixture>;
1595+
using MultiTileCommandQueueSynchronizeTest = Test<SingleRootMultiSubDeviceFixture>;
15951596

15961597
template <typename GfxFamily>
15971598
struct SynchronizeCsr : public NEO::UltCommandStreamReceiver<GfxFamily> {
@@ -1698,7 +1699,7 @@ HWTEST_F(CommandQueueSynchronizeTest, givenDebugOverrideEnabledWhenCallToSynchro
16981699
L0::CommandQueue::fromHandle(commandQueue)->destroy();
16991700
}
17001701

1701-
HWTEST_F(CommandQueueSynchronizeTest, givenMultiplePartitionCountWhenCallingSynchronizeThenExpectTheSameNumberCsrSynchronizeCalls) {
1702+
HWTEST2_F(MultiTileCommandQueueSynchronizeTest, givenMultiplePartitionCountWhenCallingSynchronizeThenExpectTheSameNumberCsrSynchronizeCalls, IsWithinXeGfxFamily) {
17021703
const ze_command_queue_desc_t desc{};
17031704
ze_result_t returnValue;
17041705

@@ -1717,13 +1718,15 @@ HWTEST_F(CommandQueueSynchronizeTest, givenMultiplePartitionCountWhenCallingSync
17171718
returnValue));
17181719
EXPECT_EQ(returnValue, ZE_RESULT_SUCCESS);
17191720
ASSERT_NE(nullptr, commandQueue);
1721+
EXPECT_EQ(2u, commandQueue->activeSubDevices);
17201722

17211723
auto commandList = std::unique_ptr<CommandList>(whitebox_cast(CommandList::create(productFamily, device, NEO::EngineGroupType::RenderCompute, 0u, returnValue)));
17221724
ASSERT_NE(nullptr, commandList);
17231725
commandList->partitionCount = 2;
17241726

17251727
ze_command_list_handle_t cmdListHandle = commandList->toHandle();
1726-
commandQueue->executeCommandLists(1, &cmdListHandle, nullptr, false);
1728+
returnValue = commandQueue->executeCommandLists(1, &cmdListHandle, nullptr, false);
1729+
EXPECT_EQ(returnValue, ZE_RESULT_SUCCESS);
17271730

17281731
uint64_t timeout = std::numeric_limits<uint64_t>::max();
17291732
commandQueue->synchronize(timeout);
@@ -1733,7 +1736,7 @@ HWTEST_F(CommandQueueSynchronizeTest, givenMultiplePartitionCountWhenCallingSync
17331736
L0::CommandQueue::fromHandle(commandQueue)->destroy();
17341737
}
17351738

1736-
HWTEST_F(CommandQueueSynchronizeTest, givenCsrHasMultipleActivePartitionWhenExecutingCmdListOnNewCmdQueueThenExpectCmdPartitionCountMatchCsrActivePartitions) {
1739+
HWTEST2_F(MultiTileCommandQueueSynchronizeTest, givenCsrHasMultipleActivePartitionWhenExecutingCmdListOnNewCmdQueueThenExpectCmdPartitionCountMatchCsrActivePartitions, IsWithinXeGfxFamily) {
17371740
const ze_command_queue_desc_t desc{};
17381741
ze_result_t returnValue;
17391742

@@ -1753,18 +1756,46 @@ HWTEST_F(CommandQueueSynchronizeTest, givenCsrHasMultipleActivePartitionWhenExec
17531756
returnValue));
17541757
EXPECT_EQ(returnValue, ZE_RESULT_SUCCESS);
17551758
ASSERT_NE(nullptr, commandQueue);
1759+
EXPECT_EQ(2u, commandQueue->activeSubDevices);
17561760

17571761
auto commandList = std::unique_ptr<CommandList>(whitebox_cast(CommandList::create(productFamily, device, NEO::EngineGroupType::RenderCompute, 0u, returnValue)));
17581762
ASSERT_NE(nullptr, commandList);
17591763

17601764
ze_command_list_handle_t cmdListHandle = commandList->toHandle();
17611765
commandQueue->executeCommandLists(1, &cmdListHandle, nullptr, false);
1766+
EXPECT_EQ(returnValue, ZE_RESULT_SUCCESS);
17621767

17631768
EXPECT_EQ(2u, commandQueue->partitionCount);
17641769

17651770
L0::CommandQueue::fromHandle(commandQueue)->destroy();
17661771
}
17671772

1773+
HWTEST_F(CommandQueueSynchronizeTest, givenSingleTileCsrWhenExecutingMultiTileCommandListThenExpectErrorOnExecute) {
1774+
const ze_command_queue_desc_t desc{};
1775+
ze_result_t returnValue;
1776+
1777+
auto commandQueue = whitebox_cast(CommandQueue::create(productFamily,
1778+
device,
1779+
neoDevice->getDefaultEngine().commandStreamReceiver,
1780+
&desc,
1781+
false,
1782+
false,
1783+
returnValue));
1784+
EXPECT_EQ(returnValue, ZE_RESULT_SUCCESS);
1785+
ASSERT_NE(nullptr, commandQueue);
1786+
EXPECT_EQ(1u, commandQueue->activeSubDevices);
1787+
1788+
auto commandList = std::unique_ptr<CommandList>(whitebox_cast(CommandList::create(productFamily, device, NEO::EngineGroupType::RenderCompute, 0u, returnValue)));
1789+
ASSERT_NE(nullptr, commandList);
1790+
commandList->partitionCount = 2;
1791+
1792+
ze_command_list_handle_t cmdListHandle = commandList->toHandle();
1793+
returnValue = commandQueue->executeCommandLists(1, &cmdListHandle, nullptr, false);
1794+
EXPECT_EQ(returnValue, ZE_RESULT_ERROR_INVALID_COMMAND_LIST_TYPE);
1795+
1796+
L0::CommandQueue::fromHandle(commandQueue)->destroy();
1797+
}
1798+
17681799
template <typename GfxFamily>
17691800
struct TestCmdQueueCsr : public NEO::UltCommandStreamReceiver<GfxFamily> {
17701801
TestCmdQueueCsr(const NEO::ExecutionEnvironment &executionEnvironment, const DeviceBitfield deviceBitfield)

shared/test/common/test_macros/header/test.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,8 @@ using IsAtLeastGen12lp = IsAtLeastGfxCore<IGFX_GEN12LP_CORE>;
11161116
using IsAtLeastXeHpCore = IsAtLeastGfxCore<IGFX_XE_HP_CORE>;
11171117
using IsAtMostXeHpCore = IsAtMostGfxCore<IGFX_XE_HP_CORE>;
11181118

1119+
using IsWithinXeGfxFamily = IsWithinGfxCore<IGFX_XE_HP_CORE, IGFX_XE_HP_CORE>;
1120+
11191121
using IsADLS = IsProduct<IGFX_ALDERLAKE_S>;
11201122
using IsBXT = IsProduct<IGFX_BROXTON>;
11211123
using IsCFL = IsProduct<IGFX_COFFEELAKE>;

0 commit comments

Comments
 (0)