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 <jaime.a.arteaga.molina@intel.com>
This commit is contained in:
Jaime Arteaga
2020-08-12 13:34:36 -07:00
parent cdc7649e77
commit cc3186c413
8 changed files with 97 additions and 28 deletions

View File

@ -83,10 +83,9 @@ ze_result_t DeviceImp::canAccessPeer(ze_device_handle_t hPeerDevice, ze_bool_t *
ze_result_t DeviceImp::createCommandList(const ze_command_list_desc_t *desc,
ze_command_list_handle_t *commandList) {
auto productFamily = neoDevice->getHardwareInfo().platform.eProductFamily;
bool useBliter = false;
if (desc->commandQueueGroupOrdinal == static_cast<uint32_t>(NEO::EngineGroupType::Copy)) {
useBliter = true;
}
uint32_t engineGroupIndex = desc->commandQueueGroupOrdinal;
mapOrdinalForAvailableEngineGroup(&engineGroupIndex);
bool useBliter = engineGroupIndex == static_cast<uint32_t>(NEO::EngineGroupType::Copy);
*commandList = CommandList::create(productFamily, this, useBliter);
return ZE_RESULT_SUCCESS;
@ -141,7 +140,7 @@ ze_result_t DeviceImp::getCommandQueueGroupProperties(uint32_t *pCount,
*pCount = std::min(numEngineGroups, *pCount);
for (uint32_t i = 0, engineGroupCount = 0;
i < static_cast<uint32_t>(NEO::EngineGroupType::MaxEngineGroups) && engineGroupCount < *pCount;
i++, engineGroupCount++) {
i++) {
if (engines[i].empty()) {
continue;
@ -162,6 +161,7 @@ ze_result_t DeviceImp::getCommandQueueGroupProperties(uint32_t *pCount,
}
pCommandQueueGroupProperties[engineGroupCount].maxMemoryFillPatternSize = sizeof(uint32_t);
pCommandQueueGroupProperties[engineGroupCount].numQueues = static_cast<uint32_t>(engines[i].size());
engineGroupCount++;
}
return ZE_RESULT_SUCCESS;

View File

@ -93,24 +93,6 @@ struct DeviceImp : public Device {
CommandList *pageFaultCommandList = nullptr;
protected:
template <typename DescriptionType, typename ExpectedFlagType>
ze_result_t isCreatedCommandListCopyOnly(const DescriptionType *desc, bool *useBliter, ExpectedFlagType flag) {
*useBliter = false;
if (desc->flags & flag) {
auto hwInfo = neoDevice->getHardwareInfo();
if (hwInfo.capabilityTable.blitterOperationsSupported) {
if (NEO::DebugManager.flags.EnableCopyOnlyCommandListsAndCommandQueues.get() == -1) {
*useBliter = true;
} else {
*useBliter = NEO::DebugManager.flags.EnableCopyOnlyCommandListsAndCommandQueues.get();
}
return ZE_RESULT_SUCCESS;
}
return ZE_RESULT_ERROR_INVALID_ENUMERATION;
}
return ZE_RESULT_SUCCESS;
}
NEO::GraphicsAllocation *debugSurface = nullptr;
SysmanDevice *pSysmanDevice = nullptr;
};

View File

@ -182,5 +182,59 @@ HWTEST2_F(DeviceQueueGroupTest,
}
}
HWTEST2_F(DeviceQueueGroupTest,
givenQueueGroupsReturnedThenCommandListsAreCreatedCorrectly, IsGen12LP) {
const uint32_t rootDeviceIndex = 0u;
NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get();
hwInfo.featureTable.ftrCCSNode = false;
hwInfo.capabilityTable.blitterOperationsSupported = true;
hwInfo.featureTable.ftrBcsInfo.set(0);
auto *neoMockDevice = NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(&hwInfo,
rootDeviceIndex);
Mock<L0::DeviceImp> deviceImp(neoMockDevice, neoMockDevice->getExecutionEnvironment());
uint32_t count = 0;
ze_result_t res = deviceImp.getCommandQueueGroupProperties(&count, nullptr);
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
EXPECT_EQ(count, 2u);
std::vector<ze_command_queue_group_properties_t> properties(count);
res = deviceImp.getCommandQueueGroupProperties(&count, properties.data());
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
ze_context_handle_t hContext;
ze_context_desc_t desc;
res = driverHandle->createContext(&desc, &hContext);
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
L0::Context *context = Context::fromHandle(hContext);
for (uint32_t i = 0; i < count; i++) {
if (i == static_cast<uint32_t>(NEO::EngineGroupType::RenderCompute)) {
EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE);
EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY);
EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COOPERATIVE_KERNELS);
EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_METRICS);
EXPECT_EQ(properties[i].maxMemoryFillPatternSize, sizeof(uint32_t));
EXPECT_EQ(properties[i].numQueues, 1u);
} else if (i == static_cast<uint32_t>(NEO::EngineGroupType::Copy)) {
EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY);
EXPECT_EQ(properties[i].maxMemoryFillPatternSize, sizeof(uint32_t));
EXPECT_EQ(properties[i].numQueues, 1u);
}
ze_command_list_desc_t desc = {};
desc.commandQueueGroupOrdinal = i;
ze_command_list_handle_t hCommandList = {};
res = context->createCommandList(device, &desc, &hCommandList);
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
CommandList *commandList = CommandList::fromHandle(hCommandList);
commandList->destroy();
}
context->destroy();
}
} // namespace ult
} // namespace L0

View File

@ -54,5 +54,41 @@ HWTEST2_F(DeviceQueueGroupTest, givenCommandQueuePropertiesCallThenCorrectNumber
EXPECT_EQ(properties.maxMemoryFillPatternSize, sizeof(uint32_t));
}
HWTEST2_F(DeviceQueueGroupTest, givenQueueGroupsReturnedThenCommandListIsCreatedCorrectly, IsGen9) {
uint32_t count = 0;
ze_result_t res = device->getCommandQueueGroupProperties(&count, nullptr);
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
EXPECT_EQ(1u, count);
ze_command_queue_group_properties_t properties;
res = device->getCommandQueueGroupProperties(&count, &properties);
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
EXPECT_TRUE(properties.flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE);
EXPECT_TRUE(properties.flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY);
EXPECT_TRUE(properties.flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COOPERATIVE_KERNELS);
EXPECT_TRUE(properties.flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_METRICS);
EXPECT_EQ(properties.numQueues, 1u);
EXPECT_EQ(properties.maxMemoryFillPatternSize, sizeof(uint32_t));
ze_context_handle_t hContext;
ze_context_desc_t contextDesc;
res = driverHandle->createContext(&contextDesc, &hContext);
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
L0::Context *context = Context::fromHandle(hContext);
ze_command_list_desc_t listDesc = {};
listDesc.commandQueueGroupOrdinal = 0;
ze_command_list_handle_t hCommandList = {};
res = context->createCommandList(device, &listDesc, &hCommandList);
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
CommandList *commandList = CommandList::fromHandle(hCommandList);
commandList->destroy();
context->destroy();
}
} // namespace ult
} // namespace L0

View File

@ -264,7 +264,6 @@ struct Mock<Device> : public Device {
template <>
struct Mock<L0::DeviceImp> : public L0::DeviceImp {
using Base = L0::DeviceImp;
using Base::isCreatedCommandListCopyOnly;
explicit Mock(NEO::Device *device, NEO::ExecutionEnvironment *execEnv) {
device->incRefInternal();

View File

@ -162,8 +162,8 @@ TEST_F(DeviceTest, givenCommandQueuePropertiesCallThenCallSucceeds) {
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
EXPECT_GE(count, 1u);
ze_command_queue_group_properties_t queueProperties = {};
res = device->getCommandQueueGroupProperties(&count, &queueProperties);
std::vector<ze_command_queue_group_properties_t> queueProperties(count);
res = device->getCommandQueueGroupProperties(&count, queueProperties.data());
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
}

View File

@ -114,7 +114,6 @@ ForceSamplerLowFilteringPrecision = 0
UseBindlessBuffers = 0
UseBindlessImages = 0
MakeAllBuffersResident = 0
EnableCopyOnlyCommandListsAndCommandQueues = -1
EnableIntelVme = -1
EnableIntelAdvancedVme = -1
EnableBlitterOperationsSupport = -1

View File

@ -133,7 +133,6 @@ DECLARE_DEBUG_VARIABLE(bool, DisableZeroCopyForUseHostPtr, false, "When active a
/*FEATURE FLAGS*/
DECLARE_DEBUG_VARIABLE(bool, EnableNV12, true, "Enables NV12 extension")
DECLARE_DEBUG_VARIABLE(int32_t, EnableCopyOnlyCommandListsAndCommandQueues, -1, "-1: default behavior, 0: disabled, 1: enabled, Enable copy only commandlists and commandQueues")
DECLARE_DEBUG_VARIABLE(int32_t, EnableIntelVme, -1, "-1: default, 0: disabled, 1: Enables cl_intel_motion_estimation extension")
DECLARE_DEBUG_VARIABLE(int32_t, EnableIntelAdvancedVme, -1, "-1: default, 0: disabled, 1: Enables cl_intel_advanced_motion_estimation extension")
DECLARE_DEBUG_VARIABLE(int32_t, EnableBlitterOperationsSupport, -1, "-1: default, 0: disable, 1: enable")