Create Level Zero command queue based on queue desc ordinal

And correctly return the number of engines available.

Related-to: NEO-4590

Change-Id: I637b3a94473e146003ea5e1c86d38e311406ce7e
Signed-off: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
This commit is contained in:
Jaime Arteaga
2020-05-03 12:33:11 -07:00
committed by sys_ocldev
parent b7e65150d3
commit 77791ba889
5 changed files with 64 additions and 2 deletions

View File

@@ -117,7 +117,21 @@ ze_result_t DeviceImp::createCommandQueue(const ze_command_queue_desc_t *desc,
auto &selectorCopyEngine = this->neoDevice->getDeviceById(0)->getSelectorCopyEngine();
csr = this->neoDevice->getDeviceById(0)->getEngine(NEO::EngineHelpers::getBcsEngineType(neoDevice->getHardwareInfo(), selectorCopyEngine), false).commandStreamReceiver;
} else {
csr = neoDevice->getDefaultEngine().commandStreamReceiver;
const auto &hardwareInfo = this->neoDevice->getHardwareInfo();
auto &hwHelper = NEO::HwHelper::get(hardwareInfo.platform.eRenderCoreFamily);
if (desc->ordinal >= NEO::HwHelper::getEnginesCount(hardwareInfo)) {
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
}
if (desc->ordinal == 0) {
csr = neoDevice->getEngine(0).commandStreamReceiver;
} else {
// Skip low-priority and internal engines in engines vector
csr = neoDevice->getEngine(desc->ordinal + hwHelper.internalUsageEngineIndex).commandStreamReceiver;
}
UNRECOVERABLE_IF(csr == nullptr);
}
*commandQueue = CommandQueue::create(productFamily, this, csr, desc, useBliter);

View File

@@ -49,6 +49,40 @@ TEST_F(CommandQueueCreate, whenCreatingCommandQueueThenItIsInitialized) {
commandQueue->destroy();
}
TEST_F(CommandQueueCreate, givenOrdinalThenQueueIsCreatedOnlyIfOrdinalIsLessThanNumOfAsyncComputeEngines) {
ze_device_properties_t deviceProperties;
ze_result_t res = device->getProperties(&deviceProperties);
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
ze_command_queue_desc_t desc = {};
desc.version = ZE_COMMAND_QUEUE_DESC_VERSION_CURRENT;
desc.ordinal = deviceProperties.numAsyncComputeEngines;
ze_command_queue_handle_t commandQueue = {};
res = device->createCommandQueue(&desc, &commandQueue);
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, res);
EXPECT_EQ(nullptr, commandQueue);
desc.ordinal = 0;
res = device->createCommandQueue(&desc, &commandQueue);
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
EXPECT_NE(nullptr, commandQueue);
L0::CommandQueue::fromHandle(commandQueue)->destroy();
const auto &hardwareInfo = neoDevice->getHardwareInfo();
auto &hwHelper = NEO::HwHelper::get(hardwareInfo.platform.eRenderCoreFamily);
for (uint32_t i = hwHelper.internalUsageEngineIndex; i < NEO::HwHelper::getEnginesCount(hardwareInfo); i++) {
desc.ordinal = i;
res = device->createCommandQueue(&desc, &commandQueue);
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
EXPECT_NE(nullptr, commandQueue);
L0::CommandQueue::fromHandle(commandQueue)->destroy();
}
}
using CommandQueueSBASupport = IsWithinProducts<IGFX_SKYLAKE, IGFX_TIGERLAKE_LP>;
struct MockMemoryManagerCommandQueueSBA : public MemoryManagerMock {