Skip to content

Commit f827cda

Browse files
fix: override correctly priority when primary engine
and set properly priority when priorityLevel set Resolves: HSD-18043591896 Signed-off-by: Katarzyna Cencelewska <katarzyna.cencelewska@intel.com>
1 parent b27059d commit f827cda

File tree

7 files changed

+57
-19
lines changed

7 files changed

+57
-19
lines changed

level_zero/core/source/cmdlist/cmdlist_imp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ void CommandListImp::enableCopyOperationOffload() {
300300
NEO::CommandStreamReceiver *copyCsr = nullptr;
301301
uint32_t ordinal = static_cast<DeviceImp *>(device)->getCopyEngineOrdinal();
302302

303-
device->getCsrForOrdinalAndIndex(&copyCsr, ordinal, 0, immediateQueuePriority, 0, false);
303+
device->getCsrForOrdinalAndIndex(&copyCsr, ordinal, 0, immediateQueuePriority, std::nullopt, false);
304304
UNRECOVERABLE_IF(!copyCsr);
305305

306306
ze_command_queue_desc_t copyQueueDesc = {ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC};

level_zero/core/source/device/device_imp.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,11 +1944,8 @@ ze_result_t DeviceImp::getCsrForOrdinalAndIndex(NEO::CommandStreamReceiver **csr
19441944
bool copyOnly = NEO::EngineHelper::isCopyOnlyEngineType(engineGroupType);
19451945

19461946
if (priorityLevel.has_value()) {
1947-
if (priorityLevel.value() < 0) {
1947+
if (priorityLevel.value() <= 0) {
19481948
priority = ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_HIGH;
1949-
} else if (priorityLevel.value() == this->queuePriorityLow) {
1950-
DEBUG_BREAK_IF(this->queuePriorityLow == 0);
1951-
priority = ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_LOW;
19521949
} else if (priorityLevel.value() > 0) {
19531950
priority = ZE_COMMAND_QUEUE_PRIORITY_NORMAL;
19541951
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,7 @@ HWTEST_F(ExecuteCommandListTests, givenFailingSubmitBatchBufferThenResetGraphics
13011301
ze_command_queue_desc_t desc = {};
13021302

13031303
NEO::CommandStreamReceiver *csr;
1304-
device->getCsrForOrdinalAndIndex(&csr, 0u, 0u, ZE_COMMAND_QUEUE_PRIORITY_NORMAL, 0, false);
1304+
device->getCsrForOrdinalAndIndex(&csr, 0u, 0u, ZE_COMMAND_QUEUE_PRIORITY_NORMAL, std::nullopt, false);
13051305

13061306
auto commandQueue = new MockCommandQueueSubmitBatchBuffer<FamilyType::gfxCoreFamily>(device, csr, &desc);
13071307
commandQueue->submitBatchBufferResult = NEO::SubmissionStatus::failed;
@@ -1333,7 +1333,7 @@ HWTEST_F(ExecuteCommandListTests, givenFailingSubmitBatchBufferThenResetGraphics
13331333
ze_command_queue_desc_t desc = {};
13341334

13351335
NEO::CommandStreamReceiver *csr;
1336-
device->getCsrForOrdinalAndIndex(&csr, 0u, 0u, ZE_COMMAND_QUEUE_PRIORITY_NORMAL, 0, false);
1336+
device->getCsrForOrdinalAndIndex(&csr, 0u, 0u, ZE_COMMAND_QUEUE_PRIORITY_NORMAL, std::nullopt, false);
13371337

13381338
auto commandQueue = new MockCommandQueueSubmitBatchBuffer<FamilyType::gfxCoreFamily>(device, csr, &desc);
13391339
commandQueue->submitBatchBufferResult = NEO::SubmissionStatus::failed;
@@ -1369,7 +1369,7 @@ HWTEST_F(ExecuteCommandListTests, givenFailingSubmitBatchBufferThenWaitForComple
13691369

13701370
ze_command_queue_desc_t desc = {};
13711371
NEO::CommandStreamReceiver *csr;
1372-
device->getCsrForOrdinalAndIndex(&csr, 0u, 0u, ZE_COMMAND_QUEUE_PRIORITY_NORMAL, 0, false);
1372+
device->getCsrForOrdinalAndIndex(&csr, 0u, 0u, ZE_COMMAND_QUEUE_PRIORITY_NORMAL, std::nullopt, false);
13731373
auto commandQueue = new MockCommandQueueSubmitBatchBuffer<FamilyType::gfxCoreFamily>(device, csr, &desc);
13741374
commandQueue->submitBatchBufferResult = NEO::SubmissionStatus::failed;
13751375

@@ -1908,7 +1908,7 @@ HWTEST_F(ExecuteCommandListTests, givenDirectSubmissionEnabledWhenExecutingCmdLi
19081908
using MI_BATCH_BUFFER_START = typename FamilyType::MI_BATCH_BUFFER_START;
19091909
ze_command_queue_desc_t desc = {};
19101910
NEO::CommandStreamReceiver *csr;
1911-
device->getCsrForOrdinalAndIndex(&csr, 0u, 0u, ZE_COMMAND_QUEUE_PRIORITY_NORMAL, 0, false);
1911+
device->getCsrForOrdinalAndIndex(&csr, 0u, 0u, ZE_COMMAND_QUEUE_PRIORITY_NORMAL, std::nullopt, false);
19121912
static_cast<NEO::UltCommandStreamReceiver<FamilyType> *>(csr)->directSubmissionAvailable = true;
19131913
ze_result_t returnValue;
19141914
auto commandQueue = whiteboxCast(CommandQueue::create(productFamily,
@@ -1954,7 +1954,7 @@ HWTEST_F(ExecuteCommandListTests, givenDirectSubmissionEnabledAndDebugFlagSetWhe
19541954
using MI_BATCH_BUFFER_START = typename FamilyType::MI_BATCH_BUFFER_START;
19551955
ze_command_queue_desc_t desc = {};
19561956
NEO::CommandStreamReceiver *csr;
1957-
device->getCsrForOrdinalAndIndex(&csr, 0u, 0u, ZE_COMMAND_QUEUE_PRIORITY_NORMAL, 0, false);
1957+
device->getCsrForOrdinalAndIndex(&csr, 0u, 0u, ZE_COMMAND_QUEUE_PRIORITY_NORMAL, std::nullopt, false);
19581958
static_cast<NEO::UltCommandStreamReceiver<FamilyType> *>(csr)->directSubmissionAvailable = true;
19591959
ze_result_t returnValue;
19601960
auto commandQueue = whiteboxCast(CommandQueue::create(productFamily,

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,21 @@ TEST(CommandQueuePriorityExtensionTest, givenQueueDescWithZeroPriorityExtensionW
9393
EXPECT_EQ(0, queueProperties.priorityLevel.value());
9494
}
9595

96+
TEST(CommandQueuePriorityExtensionTest, givenQueueDescWithNoPriorityDescWhenExtractingPropertiesThenPriorityLevelHasNoValue) {
97+
ze_command_queue_desc_t queueDesc = {};
98+
queueDesc.stype = ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC;
99+
queueDesc.pNext = nullptr;
100+
queueDesc.ordinal = 0;
101+
queueDesc.index = 0;
102+
queueDesc.flags = 0;
103+
queueDesc.mode = ZE_COMMAND_QUEUE_MODE_DEFAULT;
104+
queueDesc.priority = ZE_COMMAND_QUEUE_PRIORITY_NORMAL;
105+
106+
auto queueProperties = CommandQueue::extractQueueProperties(queueDesc);
107+
108+
EXPECT_FALSE(queueProperties.priorityLevel.has_value());
109+
}
110+
96111
TEST(CommandQueuePriorityExtensionTest, givenQueueDescWithMultipleExtensionsIncludingPriorityWhenExtractingPropertiesThenAllAreProcessedCorrectly) {
97112
zex_intel_queue_copy_operations_offload_hint_exp_desc_t copyOffloadDesc = {};
98113
copyOffloadDesc.stype = ZEX_INTEL_STRUCTURE_TYPE_QUEUE_COPY_OPERATIONS_OFFLOAD_HINT_EXP_PROPERTIES;

level_zero/core/test/unit_tests/sources/device/test_l0_device.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4727,7 +4727,7 @@ HWTEST_F(DeviceTest, givenContextGroupSupportedWhenGettingHighPriorityCsrThenCor
47274727
ASSERT_NE(nullptr, bcsEngine);
47284728
EXPECT_TRUE(bcsEngine->getOsContext().isHighPriority());
47294729

4730-
result = deviceImp.getCsrForOrdinalAndIndex(&bcsEngine2, ordinalCopy, index, ZE_COMMAND_QUEUE_PRIORITY_NORMAL, 0, false);
4730+
result = deviceImp.getCsrForOrdinalAndIndex(&bcsEngine2, ordinalCopy, index, ZE_COMMAND_QUEUE_PRIORITY_NORMAL, std::nullopt, false);
47314731
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
47324732
ASSERT_EQ(bcsEngine2, bcsEngine->getPrimaryCsr());
47334733
EXPECT_TRUE(bcsEngine2->getOsContext().isRegular());
@@ -5043,7 +5043,7 @@ TEST_F(MultiSubDeviceEnabledImplicitScalingTest, GivenEnabledImplicitScalingWhen
50435043
NEO::CommandStreamReceiver *csr = nullptr;
50445044
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, deviceImp->getCsrForLowPriority(&csr, false));
50455045

5046-
auto ret = deviceImp->getCsrForOrdinalAndIndex(&csr, 0, 0, ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_LOW, 0, false);
5046+
auto ret = deviceImp->getCsrForOrdinalAndIndex(&csr, 0, 0, ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_LOW, std::nullopt, false);
50475047

50485048
EXPECT_EQ(ZE_RESULT_SUCCESS, ret);
50495049
EXPECT_EQ(defaultEngine.commandStreamReceiver, csr);
@@ -5055,7 +5055,7 @@ HWTEST2_F(MultiSubDeviceWithContextGroupAndImplicitScalingTest, GivenRootDeviceW
50555055
NEO::CommandStreamReceiver *csr = nullptr;
50565056
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, deviceImp->getCsrForLowPriority(&csr, false));
50575057

5058-
auto ret = deviceImp->getCsrForOrdinalAndIndex(&csr, 0, 0, ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_LOW, 0, false);
5058+
auto ret = deviceImp->getCsrForOrdinalAndIndex(&csr, 0, 0, ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_LOW, std::nullopt, false);
50595059

50605060
EXPECT_EQ(ZE_RESULT_SUCCESS, ret);
50615061
EXPECT_EQ(defaultEngine.commandStreamReceiver, csr);
@@ -5066,7 +5066,7 @@ HWTEST2_F(MultiSubDeviceWithContextGroupAndImplicitScalingTest, GivenRootDeviceW
50665066
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, deviceImp->getCsrForLowPriority(&csr, true));
50675067

50685068
auto ordinal = deviceImp->getCopyEngineOrdinal();
5069-
auto ret = deviceImp->getCsrForOrdinalAndIndex(&csr, ordinal, 0, ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_LOW, 0, false);
5069+
auto ret = deviceImp->getCsrForOrdinalAndIndex(&csr, ordinal, 0, ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_LOW, std::nullopt, false);
50705070

50715071
EXPECT_EQ(ZE_RESULT_SUCCESS, ret);
50725072
EXPECT_NE(nullptr, csr);
@@ -5079,7 +5079,7 @@ HWTEST2_F(MultiSubDeviceWithContextGroupAndImplicitScalingTest, GivenRootDeviceW
50795079
NEO::CommandStreamReceiver *csr = nullptr;
50805080
auto ordinal = deviceImp->getCopyEngineOrdinal();
50815081

5082-
auto ret = deviceImp->getCsrForOrdinalAndIndex(&csr, ordinal, 0, ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_HIGH, 0, false);
5082+
auto ret = deviceImp->getCsrForOrdinalAndIndex(&csr, ordinal, 0, ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_HIGH, std::nullopt, false);
50835083

50845084
EXPECT_EQ(ZE_RESULT_SUCCESS, ret);
50855085
EXPECT_NE(nullptr, csr);
@@ -6200,21 +6200,21 @@ HWTEST_F(SingleDeviceModeTests, givenContextGroupSupportedWhenGettingCsrsThenSec
62006200
NEO::CommandStreamReceiver *bcsEngine = nullptr, *bcsEngine2 = nullptr;
62016201
EXPECT_EQ(nullptr, neoMockDevice->getHpCopyEngine());
62026202

6203-
result = device->getCsrForOrdinalAndIndex(&bcsEngine, ordinalCopy, index, ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_HIGH, 0, false);
6203+
result = device->getCsrForOrdinalAndIndex(&bcsEngine, ordinalCopy, index, ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_HIGH, std::nullopt, false);
62046204
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
62056205
ASSERT_NE(nullptr, bcsEngine);
62066206
EXPECT_TRUE(bcsEngine->getOsContext().isHighPriority());
62076207
EXPECT_EQ(1u, bcsEngine->getOsContext().getDeviceBitfield().count());
62086208

6209-
result = device->getCsrForOrdinalAndIndex(&bcsEngine2, ordinalCopy, index, ZE_COMMAND_QUEUE_PRIORITY_NORMAL, 0, false);
6209+
result = device->getCsrForOrdinalAndIndex(&bcsEngine2, ordinalCopy, index, ZE_COMMAND_QUEUE_PRIORITY_NORMAL, std::nullopt, false);
62106210
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
62116211
ASSERT_EQ(bcsEngine2, bcsEngine->getPrimaryCsr());
62126212
EXPECT_TRUE(bcsEngine2->getOsContext().getIsPrimaryEngine());
62136213
EXPECT_EQ(1u, bcsEngine2->getOsContext().getDeviceBitfield().count());
62146214
EXPECT_TRUE(bcsEngine2->getOsContext().getDeviceBitfield().test(0));
62156215

62166216
bcsEngine2 = nullptr;
6217-
result = device->getCsrForOrdinalAndIndex(&bcsEngine2, ordinalCopy + 1, index, ZE_COMMAND_QUEUE_PRIORITY_NORMAL, 0, false);
6217+
result = device->getCsrForOrdinalAndIndex(&bcsEngine2, ordinalCopy + 1, index, ZE_COMMAND_QUEUE_PRIORITY_NORMAL, std::nullopt, false);
62186218
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
62196219
ASSERT_NE(bcsEngine2, bcsEngine->getPrimaryCsr());
62206220
EXPECT_TRUE(bcsEngine2->getOsContext().getIsPrimaryEngine());

shared/source/device/device.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,8 @@ EngineControl *SecondaryContexts::getEngine(EngineUsage usage, std::optional<int
13031303
if (regularEnginesTotal == 0) {
13041304
return nullptr;
13051305
}
1306-
if (npIndices.size() == 0) {
1306+
bool isSamePriorityLevel = priorityLevel.has_value() ? priorityLevel.value() == engines[secondaryEngineIndex].osContext->getPriorityLevel() : true;
1307+
if (npIndices.size() == 0 && isSamePriorityLevel) {
13071308
regularCounter.fetch_add(1);
13081309
npIndices.push_back(secondaryEngineIndex);
13091310
}

shared/test/unit_test/device/neo_device_tests.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2189,6 +2189,31 @@ HWTEST_F(DeviceTests, givenDebugFlagSetWhenCreatingSecondaryEnginesThenCreateCor
21892189
}
21902190
}
21912191

2192+
HWTEST_F(DeviceTests, givenNonDefaultPriorityLevelWhenGetEngineThenReturnNotPrimaryEngine) {
2193+
DebugManagerStateRestore dbgRestorer;
2194+
2195+
debugManager.flags.ContextGroupSize.set(6);
2196+
2197+
HardwareInfo hwInfo = *defaultHwInfo;
2198+
hwInfo.featureTable.flags.ftrCCSNode = true;
2199+
hwInfo.featureTable.ftrBcsInfo = 0;
2200+
hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_CCS;
2201+
hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 1;
2202+
int nonDefaultPriorityLevel = 4;
2203+
{
2204+
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo));
2205+
auto &secondaryEngines = device->secondaryEngines[EngineHelpers::mapCcsIndexToEngineType(0)];
2206+
auto engine = secondaryEngines.getEngine(EngineUsage::regular, std::nullopt);
2207+
EXPECT_TRUE(engine->osContext->getIsPrimaryEngine());
2208+
EXPECT_NE(nonDefaultPriorityLevel, engine->osContext->getPriorityLevel());
2209+
}
2210+
{
2211+
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo));
2212+
auto &secondaryEngines = device->secondaryEngines[EngineHelpers::mapCcsIndexToEngineType(0)];
2213+
EXPECT_FALSE(secondaryEngines.getEngine(EngineUsage::regular, nonDefaultPriorityLevel)->osContext->getIsPrimaryEngine());
2214+
}
2215+
}
2216+
21922217
HWTEST_F(DeviceTests, givenContextGroupEnabledWhenGettingSecondaryEngineThenResourcesAndContextAreInitialized) {
21932218

21942219
HardwareInfo hwInfo = *defaultHwInfo;

0 commit comments

Comments
 (0)