Skip to content

Commit cc3186c

Browse files
author
Jaime Arteaga
committed
Add support for queue groups (2/N)
- Correctly store available groups in vector passed by user. - Some cleanup. Change-Id: I4d3f24a4af38fed261809edf85ac043eba4d831f Signed-off-by: Jaime Arteaga <[email protected]>
1 parent cdc7649 commit cc3186c

File tree

8 files changed

+97
-28
lines changed

8 files changed

+97
-28
lines changed

level_zero/core/source/device/device_imp.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,9 @@ ze_result_t DeviceImp::canAccessPeer(ze_device_handle_t hPeerDevice, ze_bool_t *
8383
ze_result_t DeviceImp::createCommandList(const ze_command_list_desc_t *desc,
8484
ze_command_list_handle_t *commandList) {
8585
auto productFamily = neoDevice->getHardwareInfo().platform.eProductFamily;
86-
bool useBliter = false;
87-
if (desc->commandQueueGroupOrdinal == static_cast<uint32_t>(NEO::EngineGroupType::Copy)) {
88-
useBliter = true;
89-
}
86+
uint32_t engineGroupIndex = desc->commandQueueGroupOrdinal;
87+
mapOrdinalForAvailableEngineGroup(&engineGroupIndex);
88+
bool useBliter = engineGroupIndex == static_cast<uint32_t>(NEO::EngineGroupType::Copy);
9089
*commandList = CommandList::create(productFamily, this, useBliter);
9190

9291
return ZE_RESULT_SUCCESS;
@@ -141,7 +140,7 @@ ze_result_t DeviceImp::getCommandQueueGroupProperties(uint32_t *pCount,
141140
*pCount = std::min(numEngineGroups, *pCount);
142141
for (uint32_t i = 0, engineGroupCount = 0;
143142
i < static_cast<uint32_t>(NEO::EngineGroupType::MaxEngineGroups) && engineGroupCount < *pCount;
144-
i++, engineGroupCount++) {
143+
i++) {
145144

146145
if (engines[i].empty()) {
147146
continue;
@@ -162,6 +161,7 @@ ze_result_t DeviceImp::getCommandQueueGroupProperties(uint32_t *pCount,
162161
}
163162
pCommandQueueGroupProperties[engineGroupCount].maxMemoryFillPatternSize = sizeof(uint32_t);
164163
pCommandQueueGroupProperties[engineGroupCount].numQueues = static_cast<uint32_t>(engines[i].size());
164+
engineGroupCount++;
165165
}
166166

167167
return ZE_RESULT_SUCCESS;

level_zero/core/source/device/device_imp.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,24 +93,6 @@ struct DeviceImp : public Device {
9393
CommandList *pageFaultCommandList = nullptr;
9494

9595
protected:
96-
template <typename DescriptionType, typename ExpectedFlagType>
97-
ze_result_t isCreatedCommandListCopyOnly(const DescriptionType *desc, bool *useBliter, ExpectedFlagType flag) {
98-
*useBliter = false;
99-
if (desc->flags & flag) {
100-
auto hwInfo = neoDevice->getHardwareInfo();
101-
if (hwInfo.capabilityTable.blitterOperationsSupported) {
102-
if (NEO::DebugManager.flags.EnableCopyOnlyCommandListsAndCommandQueues.get() == -1) {
103-
*useBliter = true;
104-
} else {
105-
*useBliter = NEO::DebugManager.flags.EnableCopyOnlyCommandListsAndCommandQueues.get();
106-
}
107-
return ZE_RESULT_SUCCESS;
108-
}
109-
110-
return ZE_RESULT_ERROR_INVALID_ENUMERATION;
111-
}
112-
return ZE_RESULT_SUCCESS;
113-
}
11496
NEO::GraphicsAllocation *debugSurface = nullptr;
11597
SysmanDevice *pSysmanDevice = nullptr;
11698
};

level_zero/core/test/unit_tests/gen12lp/test_device_gen12lp.cpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,5 +182,59 @@ HWTEST2_F(DeviceQueueGroupTest,
182182
}
183183
}
184184

185+
HWTEST2_F(DeviceQueueGroupTest,
186+
givenQueueGroupsReturnedThenCommandListsAreCreatedCorrectly, IsGen12LP) {
187+
const uint32_t rootDeviceIndex = 0u;
188+
NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get();
189+
hwInfo.featureTable.ftrCCSNode = false;
190+
hwInfo.capabilityTable.blitterOperationsSupported = true;
191+
hwInfo.featureTable.ftrBcsInfo.set(0);
192+
auto *neoMockDevice = NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(&hwInfo,
193+
rootDeviceIndex);
194+
Mock<L0::DeviceImp> deviceImp(neoMockDevice, neoMockDevice->getExecutionEnvironment());
195+
196+
uint32_t count = 0;
197+
ze_result_t res = deviceImp.getCommandQueueGroupProperties(&count, nullptr);
198+
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
199+
EXPECT_EQ(count, 2u);
200+
201+
std::vector<ze_command_queue_group_properties_t> properties(count);
202+
res = deviceImp.getCommandQueueGroupProperties(&count, properties.data());
203+
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
204+
205+
ze_context_handle_t hContext;
206+
ze_context_desc_t desc;
207+
res = driverHandle->createContext(&desc, &hContext);
208+
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
209+
L0::Context *context = Context::fromHandle(hContext);
210+
211+
for (uint32_t i = 0; i < count; i++) {
212+
if (i == static_cast<uint32_t>(NEO::EngineGroupType::RenderCompute)) {
213+
EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE);
214+
EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY);
215+
EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COOPERATIVE_KERNELS);
216+
EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_METRICS);
217+
EXPECT_EQ(properties[i].maxMemoryFillPatternSize, sizeof(uint32_t));
218+
EXPECT_EQ(properties[i].numQueues, 1u);
219+
} else if (i == static_cast<uint32_t>(NEO::EngineGroupType::Copy)) {
220+
EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY);
221+
EXPECT_EQ(properties[i].maxMemoryFillPatternSize, sizeof(uint32_t));
222+
EXPECT_EQ(properties[i].numQueues, 1u);
223+
}
224+
225+
ze_command_list_desc_t desc = {};
226+
desc.commandQueueGroupOrdinal = i;
227+
ze_command_list_handle_t hCommandList = {};
228+
229+
res = context->createCommandList(device, &desc, &hCommandList);
230+
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
231+
232+
CommandList *commandList = CommandList::fromHandle(hCommandList);
233+
commandList->destroy();
234+
}
235+
236+
context->destroy();
237+
}
238+
185239
} // namespace ult
186240
} // namespace L0

level_zero/core/test/unit_tests/gen9/test_device_gen9.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,41 @@ HWTEST2_F(DeviceQueueGroupTest, givenCommandQueuePropertiesCallThenCorrectNumber
5454
EXPECT_EQ(properties.maxMemoryFillPatternSize, sizeof(uint32_t));
5555
}
5656

57+
HWTEST2_F(DeviceQueueGroupTest, givenQueueGroupsReturnedThenCommandListIsCreatedCorrectly, IsGen9) {
58+
uint32_t count = 0;
59+
ze_result_t res = device->getCommandQueueGroupProperties(&count, nullptr);
60+
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
61+
EXPECT_EQ(1u, count);
62+
63+
ze_command_queue_group_properties_t properties;
64+
res = device->getCommandQueueGroupProperties(&count, &properties);
65+
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
66+
67+
EXPECT_TRUE(properties.flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE);
68+
EXPECT_TRUE(properties.flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY);
69+
EXPECT_TRUE(properties.flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COOPERATIVE_KERNELS);
70+
EXPECT_TRUE(properties.flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_METRICS);
71+
EXPECT_EQ(properties.numQueues, 1u);
72+
EXPECT_EQ(properties.maxMemoryFillPatternSize, sizeof(uint32_t));
73+
74+
ze_context_handle_t hContext;
75+
ze_context_desc_t contextDesc;
76+
res = driverHandle->createContext(&contextDesc, &hContext);
77+
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
78+
L0::Context *context = Context::fromHandle(hContext);
79+
80+
ze_command_list_desc_t listDesc = {};
81+
listDesc.commandQueueGroupOrdinal = 0;
82+
ze_command_list_handle_t hCommandList = {};
83+
84+
res = context->createCommandList(device, &listDesc, &hCommandList);
85+
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
86+
87+
CommandList *commandList = CommandList::fromHandle(hCommandList);
88+
commandList->destroy();
89+
90+
context->destroy();
91+
}
92+
5793
} // namespace ult
5894
} // namespace L0

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ struct Mock<Device> : public Device {
264264
template <>
265265
struct Mock<L0::DeviceImp> : public L0::DeviceImp {
266266
using Base = L0::DeviceImp;
267-
using Base::isCreatedCommandListCopyOnly;
268267

269268
explicit Mock(NEO::Device *device, NEO::ExecutionEnvironment *execEnv) {
270269
device->incRefInternal();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ TEST_F(DeviceTest, givenCommandQueuePropertiesCallThenCallSucceeds) {
162162
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
163163
EXPECT_GE(count, 1u);
164164

165-
ze_command_queue_group_properties_t queueProperties = {};
166-
res = device->getCommandQueueGroupProperties(&count, &queueProperties);
165+
std::vector<ze_command_queue_group_properties_t> queueProperties(count);
166+
res = device->getCommandQueueGroupProperties(&count, queueProperties.data());
167167
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
168168
}
169169

opencl/test/unit_test/test_files/igdrcl.config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ ForceSamplerLowFilteringPrecision = 0
114114
UseBindlessBuffers = 0
115115
UseBindlessImages = 0
116116
MakeAllBuffersResident = 0
117-
EnableCopyOnlyCommandListsAndCommandQueues = -1
118117
EnableIntelVme = -1
119118
EnableIntelAdvancedVme = -1
120119
EnableBlitterOperationsSupport = -1

shared/source/debug_settings/debug_variables_base.inl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ DECLARE_DEBUG_VARIABLE(bool, DisableZeroCopyForUseHostPtr, false, "When active a
133133

134134
/*FEATURE FLAGS*/
135135
DECLARE_DEBUG_VARIABLE(bool, EnableNV12, true, "Enables NV12 extension")
136-
DECLARE_DEBUG_VARIABLE(int32_t, EnableCopyOnlyCommandListsAndCommandQueues, -1, "-1: default behavior, 0: disabled, 1: enabled, Enable copy only commandlists and commandQueues")
137136
DECLARE_DEBUG_VARIABLE(int32_t, EnableIntelVme, -1, "-1: default, 0: disabled, 1: Enables cl_intel_motion_estimation extension")
138137
DECLARE_DEBUG_VARIABLE(int32_t, EnableIntelAdvancedVme, -1, "-1: default, 0: disabled, 1: Enables cl_intel_advanced_motion_estimation extension")
139138
DECLARE_DEBUG_VARIABLE(int32_t, EnableBlitterOperationsSupport, -1, "-1: default, 0: disable, 1: enable")

0 commit comments

Comments
 (0)