Skip to content

Commit 6377675

Browse files
Add implementation for flag NodeOrdinal to l0
create method adjustCommandQueueDesc Signed-off-by: Katarzyna Cencelewska <katarzyna.cencelewska@intel.com>
1 parent 3efdfba commit 6377675

File tree

4 files changed

+66
-6
lines changed

4 files changed

+66
-6
lines changed

level_zero/core/source/device/device_imp.cpp

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,25 @@ ze_result_t DeviceImp::createCommandListImmediate(const ze_command_queue_desc_t
198198
return returnValue;
199199
}
200200

201+
void DeviceImp::adjustCommandQueueDesc(ze_command_queue_desc_t &desc) {
202+
auto nodeOrdinal = NEO::DebugManager.flags.NodeOrdinal.get();
203+
if (nodeOrdinal != -1) {
204+
const NEO::HardwareInfo &hwInfo = neoDevice->getHardwareInfo();
205+
const NEO::HwHelper &hwHelper = NEO::HwHelper::get(hwInfo.platform.eRenderCoreFamily);
206+
auto &engineGroups = getActiveDevice()->getRegularEngineGroups();
207+
208+
auto engineGroupTyp = hwHelper.getEngineGroupType(static_cast<aub_stream::EngineType>(nodeOrdinal), NEO::EngineUsage::Regular, hwInfo);
209+
uint32_t currentEngineIndex = 0u;
210+
for (const auto &engine : engineGroups) {
211+
if (engine.engineGroupType == engineGroupTyp) {
212+
desc.ordinal = currentEngineIndex;
213+
break;
214+
}
215+
currentEngineIndex++;
216+
}
217+
}
218+
}
219+
201220
ze_result_t DeviceImp::createCommandQueue(const ze_command_queue_desc_t *desc,
202221
ze_command_queue_handle_t *commandQueue) {
203222
auto &platform = neoDevice->getHardwareInfo().platform;
@@ -207,21 +226,24 @@ ze_result_t DeviceImp::createCommandQueue(const ze_command_queue_desc_t *desc,
207226
uint32_t numEngineGroups = static_cast<uint32_t>(engineGroups.size());
208227
auto &subDeviceEngineGroups = this->getSubDeviceCopyEngineGroups();
209228

229+
ze_command_queue_desc_t commandQueueDesc = *desc;
230+
adjustCommandQueueDesc(commandQueueDesc);
231+
210232
if (!this->isQueueGroupOrdinalValid(desc->ordinal)) {
211233
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
212234
}
213235

214236
bool isCopyOnly = false;
215-
if (desc->ordinal < numEngineGroups) {
216-
isCopyOnly = NEO::EngineHelper::isCopyOnlyEngineType(engineGroups[desc->ordinal].engineGroupType);
237+
if (commandQueueDesc.ordinal < numEngineGroups) {
238+
isCopyOnly = NEO::EngineHelper::isCopyOnlyEngineType(engineGroups[commandQueueDesc.ordinal].engineGroupType);
217239
} else {
218-
isCopyOnly = NEO::EngineHelper::isCopyOnlyEngineType(subDeviceEngineGroups[desc->ordinal - numEngineGroups].engineGroupType);
240+
isCopyOnly = NEO::EngineHelper::isCopyOnlyEngineType(subDeviceEngineGroups[commandQueueDesc.ordinal - numEngineGroups].engineGroupType);
219241
}
220242

221-
if (desc->priority == ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_LOW && !isCopyOnly) {
243+
if (commandQueueDesc.priority == ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_LOW && !isCopyOnly) {
222244
getCsrForLowPriority(&csr);
223245
} else {
224-
auto ret = getCsrForOrdinalAndIndex(&csr, desc->ordinal, desc->index);
246+
auto ret = getCsrForOrdinalAndIndex(&csr, commandQueueDesc.ordinal, commandQueueDesc.index);
225247
if (ret != ZE_RESULT_SUCCESS) {
226248
return ret;
227249
}
@@ -230,7 +252,7 @@ ze_result_t DeviceImp::createCommandQueue(const ze_command_queue_desc_t *desc,
230252
UNRECOVERABLE_IF(csr == nullptr);
231253

232254
ze_result_t returnValue = ZE_RESULT_SUCCESS;
233-
*commandQueue = CommandQueue::create(platform.eProductFamily, this, csr, desc, isCopyOnly, false, returnValue);
255+
*commandQueue = CommandQueue::create(platform.eProductFamily, this, csr, &commandQueueDesc, isCopyOnly, false, returnValue);
234256

235257
return returnValue;
236258
}

level_zero/core/source/device/device_imp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ struct DeviceImp : public Device {
134134
CmdListCreateFunT getCmdListCreateFunc(const ze_command_list_desc_t *desc);
135135

136136
protected:
137+
void adjustCommandQueueDesc(ze_command_queue_desc_t &desc);
137138
NEO::Device::EngineGroupsT subDeviceCopyEngineGroups{};
138139

139140
NEO::GraphicsAllocation *debugSurface = nullptr;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ struct Mock<Device> : public Device {
9898
template <>
9999
struct Mock<L0::DeviceImp> : public L0::DeviceImp {
100100
using Base = L0::DeviceImp;
101+
using Base::adjustCommandQueueDesc;
101102
using Base::debugSession;
102103
using Base::implicitScalingCapable;
103104

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,42 @@ TEST_F(DeviceTest, whenCheckingIfStatelessCompressionIsSupportedThenReturnFalse)
10851085
EXPECT_FALSE(hwInfoConfig.allowStatelessCompression(*defaultHwInfo));
10861086
}
10871087

1088+
TEST_F(DeviceTest, givenNodeOrdinalFlagNotSetWhenCallAdjustCommandQueueDescThenDescOrdinalIsNotModified) {
1089+
DebugManagerStateRestore restore;
1090+
auto nodeOrdinal = EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, *defaultHwInfo);
1091+
DebugManager.flags.NodeOrdinal.set(nodeOrdinal);
1092+
1093+
auto deviceImp = static_cast<Mock<L0::DeviceImp> *>(device);
1094+
ze_command_queue_desc_t desc = {};
1095+
EXPECT_EQ(desc.ordinal, 0u);
1096+
1097+
auto &engineGroups = deviceImp->getActiveDevice()->getRegularEngineGroups();
1098+
engineGroups.clear();
1099+
NEO::Device::EngineGroupT engineGroupCompute{};
1100+
engineGroupCompute.engineGroupType = NEO::EngineGroupType::Compute;
1101+
NEO::Device::EngineGroupT engineGroupRender{};
1102+
engineGroupRender.engineGroupType = NEO::EngineGroupType::RenderCompute;
1103+
engineGroups.push_back(engineGroupCompute);
1104+
engineGroups.push_back(engineGroupRender);
1105+
1106+
uint32_t expectedOrdinal = 1u;
1107+
deviceImp->adjustCommandQueueDesc(desc);
1108+
EXPECT_EQ(desc.ordinal, expectedOrdinal);
1109+
}
1110+
1111+
TEST_F(DeviceTest, givenNodeOrdinalFlagWhenCallAdjustCommandQueueDescThenDescOrdinalProperlySet) {
1112+
DebugManagerStateRestore restore;
1113+
int nodeOrdinal = -1;
1114+
DebugManager.flags.NodeOrdinal.set(nodeOrdinal);
1115+
1116+
auto deviceImp = static_cast<Mock<L0::DeviceImp> *>(device);
1117+
ze_command_queue_desc_t desc = {};
1118+
EXPECT_EQ(desc.ordinal, 0u);
1119+
1120+
deviceImp->adjustCommandQueueDesc(desc);
1121+
EXPECT_EQ(desc.ordinal, 0u);
1122+
}
1123+
10881124
struct DeviceHwInfoTest : public ::testing::Test {
10891125
void SetUp() override {
10901126
executionEnvironment = new NEO::ExecutionEnvironment();

0 commit comments

Comments
 (0)