Refactor Device::engineGroups to store only available engine groups

Simplify logic around engine groups.
Remove no longer needed code.
Ensure correct device is used when verifying engine groups.

Related-To: NEO-6219

Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
Filip Hazubski
2021-12-03 14:30:46 +00:00
committed by Compute-Runtime-Automation
parent a1121ccb6b
commit 2098b0c3fa
23 changed files with 268 additions and 302 deletions

View File

@@ -136,7 +136,6 @@ struct Device : _ze_device_handle_t {
virtual SysmanDevice *getSysmanHandle() = 0;
virtual ze_result_t getCsrForOrdinalAndIndex(NEO::CommandStreamReceiver **csr, uint32_t ordinal, uint32_t index) = 0;
virtual ze_result_t getCsrForLowPriority(NEO::CommandStreamReceiver **csr) = 0;
virtual ze_result_t mapOrdinalForAvailableEngineGroup(uint32_t *ordinal) = 0;
virtual NEO::GraphicsAllocation *obtainReusableAllocation(size_t requiredSize, NEO::GraphicsAllocation::AllocationType type) = 0;
virtual void storeReusableAllocation(NEO::GraphicsAllocation &alloc) = 0;

View File

@@ -150,26 +150,28 @@ 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;
uint32_t engineGroupIndex = desc->commandQueueGroupOrdinal;
ze_result_t returnValue = mapOrdinalForAvailableEngineGroup(&engineGroupIndex);
if (returnValue != ZE_RESULT_SUCCESS) {
return returnValue;
auto &engineGroups = getActiveDevice()->getEngineGroups();
if (desc->commandQueueGroupOrdinal >= engineGroups.size()) {
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
}
*commandList = CommandList::create(productFamily, this, static_cast<NEO::EngineGroupType>(engineGroupIndex), desc->flags, returnValue);
auto productFamily = neoDevice->getHardwareInfo().platform.eProductFamily;
ze_result_t returnValue = ZE_RESULT_SUCCESS;
auto engineGroupType = engineGroups[desc->commandQueueGroupOrdinal].engineGroupType;
*commandList = CommandList::create(productFamily, this, engineGroupType, desc->flags, returnValue);
return returnValue;
}
ze_result_t DeviceImp::createCommandListImmediate(const ze_command_queue_desc_t *desc,
ze_command_list_handle_t *phCommandList) {
auto productFamily = neoDevice->getHardwareInfo().platform.eProductFamily;
uint32_t engineGroupIndex = desc->ordinal;
ze_result_t returnValue = mapOrdinalForAvailableEngineGroup(&engineGroupIndex);
if (returnValue != ZE_RESULT_SUCCESS) {
return returnValue;
auto &engineGroups = getActiveDevice()->getEngineGroups();
if (desc->ordinal >= engineGroups.size()) {
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
}
*phCommandList = CommandList::createImmediate(productFamily, this, desc, false, static_cast<NEO::EngineGroupType>(engineGroupIndex), returnValue);
auto productFamily = neoDevice->getHardwareInfo().platform.eProductFamily;
auto engineGroupType = engineGroups[desc->ordinal].engineGroupType;
ze_result_t returnValue = ZE_RESULT_SUCCESS;
*phCommandList = CommandList::createImmediate(productFamily, this, desc, false, engineGroupType, returnValue);
return returnValue;
}
@@ -179,10 +181,9 @@ ze_result_t DeviceImp::createCommandQueue(const ze_command_queue_desc_t *desc,
auto &platform = neoDevice->getHardwareInfo().platform;
NEO::CommandStreamReceiver *csr = nullptr;
uint32_t engineGroupIndex = desc->ordinal;
ze_result_t returnValue = mapOrdinalForAvailableEngineGroup(&engineGroupIndex);
if (returnValue != ZE_RESULT_SUCCESS) {
return returnValue;
auto &engineGroups = getActiveDevice()->getEngineGroups();
if (desc->ordinal >= engineGroups.size()) {
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
}
if (desc->priority == ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_LOW) {
getCsrForLowPriority(&csr);
@@ -196,8 +197,9 @@ ze_result_t DeviceImp::createCommandQueue(const ze_command_queue_desc_t *desc,
UNRECOVERABLE_IF(csr == nullptr);
auto &hwHelper = NEO::HwHelper::get(platform.eRenderCoreFamily);
bool isCopyOnly = hwHelper.isCopyOnlyEngineType(static_cast<NEO::EngineGroupType>(engineGroupIndex));
bool isCopyOnly = hwHelper.isCopyOnlyEngineType(engineGroups[desc->ordinal].engineGroupType);
ze_result_t returnValue = ZE_RESULT_SUCCESS;
*commandQueue = CommandQueue::create(platform.eProductFamily, this, csr, desc, isCopyOnly, false, returnValue);
return returnValue;
@@ -207,9 +209,7 @@ ze_result_t DeviceImp::getCommandQueueGroupProperties(uint32_t *pCount,
ze_command_queue_group_properties_t *pCommandQueueGroupProperties) {
NEO::Device *activeDevice = getActiveDevice();
auto &engineGroups = activeDevice->getEngineGroups();
auto numEngineGroups = static_cast<uint32_t>(std::count_if(std::begin(engineGroups), std::end(engineGroups), [](const auto &engines) {
return !engines.empty();
}));
uint32_t numEngineGroups = static_cast<uint32_t>(engineGroups.size());
if (*pCount == 0) {
*pCount = numEngineGroups;
@@ -221,32 +221,26 @@ ze_result_t DeviceImp::getCommandQueueGroupProperties(uint32_t *pCount,
auto &l0HwHelper = L0HwHelper::get(hardwareInfo.platform.eRenderCoreFamily);
*pCount = std::min(numEngineGroups, *pCount);
for (uint32_t i = 0, engineGroupCount = 0; engineGroupCount < *pCount; i++) {
if (engineGroups[i].empty()) {
continue;
for (uint32_t i = 0; i < *pCount; i++) {
if (engineGroups[i].engineGroupType == NEO::EngineGroupType::RenderCompute) {
pCommandQueueGroupProperties[i].flags = ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE |
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY |
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_METRICS |
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COOPERATIVE_KERNELS;
pCommandQueueGroupProperties[i].maxMemoryFillPatternSize = std::numeric_limits<size_t>::max();
}
if (i == static_cast<uint32_t>(NEO::EngineGroupType::RenderCompute)) {
pCommandQueueGroupProperties[engineGroupCount].flags = ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE |
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY |
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_METRICS |
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COOPERATIVE_KERNELS;
pCommandQueueGroupProperties[engineGroupCount].maxMemoryFillPatternSize = std::numeric_limits<size_t>::max();
if (engineGroups[i].engineGroupType == NEO::EngineGroupType::Compute) {
pCommandQueueGroupProperties[i].flags = ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE |
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY |
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COOPERATIVE_KERNELS;
pCommandQueueGroupProperties[i].maxMemoryFillPatternSize = std::numeric_limits<size_t>::max();
}
if (i == static_cast<uint32_t>(NEO::EngineGroupType::Compute)) {
pCommandQueueGroupProperties[engineGroupCount].flags = ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE |
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY |
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COOPERATIVE_KERNELS;
pCommandQueueGroupProperties[engineGroupCount].maxMemoryFillPatternSize = std::numeric_limits<size_t>::max();
if (engineGroups[i].engineGroupType == NEO::EngineGroupType::Copy) {
pCommandQueueGroupProperties[i].flags = ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY;
pCommandQueueGroupProperties[i].maxMemoryFillPatternSize = hwHelper.getMaxFillPaternSizeForCopyEngine();
}
if (i == static_cast<uint32_t>(NEO::EngineGroupType::Copy)) {
pCommandQueueGroupProperties[engineGroupCount].flags = ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY;
pCommandQueueGroupProperties[engineGroupCount].maxMemoryFillPatternSize = hwHelper.getMaxFillPaternSizeForCopyEngine();
}
l0HwHelper.setAdditionalGroupProperty(pCommandQueueGroupProperties[engineGroupCount], i);
pCommandQueueGroupProperties[engineGroupCount].numQueues = static_cast<uint32_t>(engineGroups[i].size());
engineGroupCount++;
l0HwHelper.setAdditionalGroupProperty(pCommandQueueGroupProperties[i], engineGroups[i].engineGroupType);
pCommandQueueGroupProperties[i].numQueues = static_cast<uint32_t>(engineGroups[i].engines.size());
}
return ZE_RESULT_SUCCESS;
@@ -1025,19 +1019,12 @@ void DeviceImp::storeReusableAllocation(NEO::GraphicsAllocation &alloc) {
}
ze_result_t DeviceImp::getCsrForOrdinalAndIndex(NEO::CommandStreamReceiver **csr, uint32_t ordinal, uint32_t index) {
if (ordinal >= CommonConstants::engineGroupCount) {
auto &engineGroups = getActiveDevice()->getEngineGroups();
if ((ordinal >= engineGroups.size()) ||
(index >= engineGroups[ordinal].engines.size())) {
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
}
uint32_t engineGroupIndex = ordinal;
auto ret = mapOrdinalForAvailableEngineGroup(&engineGroupIndex);
if (ret != ZE_RESULT_SUCCESS) {
return ret;
}
NEO::Device *activeDevice = getActiveDevice();
if (index >= activeDevice->getEngineGroups()[engineGroupIndex].size()) {
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
}
*csr = activeDevice->getEngineGroups()[engineGroupIndex][index].commandStreamReceiver;
*csr = engineGroups[ordinal].engines[index].commandStreamReceiver;
return ZE_RESULT_SUCCESS;
}
@@ -1054,23 +1041,6 @@ ze_result_t DeviceImp::getCsrForLowPriority(NEO::CommandStreamReceiver **csr) {
return ZE_RESULT_ERROR_UNKNOWN;
}
ze_result_t DeviceImp::mapOrdinalForAvailableEngineGroup(uint32_t *ordinal) {
NEO::Device *activeDevice = getActiveDevice();
const auto &engines = activeDevice->getEngineGroups();
uint32_t numNonEmptyGroups = 0;
uint32_t i = 0;
for (; i < CommonConstants::engineGroupCount && numNonEmptyGroups <= *ordinal; i++) {
if (!engines[i].empty()) {
numNonEmptyGroups++;
}
}
if (*ordinal + 1 > numNonEmptyGroups) {
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
}
*ordinal = i - 1;
return ZE_RESULT_SUCCESS;
};
DebugSession *DeviceImp::getDebugSession(const zet_debug_config_t &config) {
return debugSession.get();
}

View File

@@ -95,7 +95,6 @@ struct DeviceImp : public Device {
SysmanDevice *getSysmanHandle() override;
ze_result_t getCsrForOrdinalAndIndex(NEO::CommandStreamReceiver **csr, uint32_t ordinal, uint32_t index) override;
ze_result_t getCsrForLowPriority(NEO::CommandStreamReceiver **csr) override;
ze_result_t mapOrdinalForAvailableEngineGroup(uint32_t *ordinal) override;
NEO::GraphicsAllocation *obtainReusableAllocation(size_t requiredSize, NEO::GraphicsAllocation::AllocationType type) override;
void storeReusableAllocation(NEO::GraphicsAllocation &alloc) override;
NEO::Device *getActiveDevice() const;

View File

@@ -15,8 +15,9 @@
#include <vector>
namespace NEO {
enum class EngineGroupType : uint32_t;
struct HardwareInfo;
}
} // namespace NEO
namespace L0 {
@@ -27,7 +28,7 @@ struct EventPool;
class L0HwHelper {
public:
static L0HwHelper &get(GFXCORE_FAMILY gfxCore);
virtual void setAdditionalGroupProperty(ze_command_queue_group_properties_t &groupProperty, uint32_t groupType) const = 0;
virtual void setAdditionalGroupProperty(ze_command_queue_group_properties_t &groupProperty, NEO::EngineGroupType groupType) const = 0;
virtual L0::Event *createEvent(L0::EventPool *eventPool, const ze_event_desc_t *desc, L0::Device *device) const = 0;
virtual bool isResumeWARequired() = 0;
@@ -46,7 +47,7 @@ class L0HwHelperHw : public L0HwHelper {
static L0HwHelperHw<GfxFamily> l0HwHelper;
return l0HwHelper;
}
void setAdditionalGroupProperty(ze_command_queue_group_properties_t &groupProperty, uint32_t groupType) const override;
void setAdditionalGroupProperty(ze_command_queue_group_properties_t &groupProperty, NEO::EngineGroupType groupType) const override;
L0::Event *createEvent(L0::EventPool *eventPool, const ze_event_desc_t *desc, L0::Device *device) const override;
L0HwHelperHw() = default;

View File

@@ -10,7 +10,7 @@
namespace L0 {
template <typename Family>
void L0HwHelperHw<Family>::setAdditionalGroupProperty(ze_command_queue_group_properties_t &groupProperty, uint32_t groupType) const {
void L0HwHelperHw<Family>::setAdditionalGroupProperty(ze_command_queue_group_properties_t &groupProperty, NEO::EngineGroupType groupType) const {
}
} // namespace L0

View File

@@ -99,8 +99,8 @@ HWTEST2_F(DeviceCopyQueueGroupTest,
res = deviceImp.getCommandQueueGroupProperties(&count, properties.data());
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
for (uint32_t i = 0; i < count; i++) {
EXPECT_NE(i, static_cast<uint32_t>(NEO::EngineGroupType::Copy));
for (auto &engineGroup : neoMockDevice->getEngineGroups()) {
EXPECT_NE(NEO::EngineGroupType::Copy, engineGroup.engineGroupType);
}
}
@@ -125,21 +125,22 @@ HWTEST2_F(DeviceQueueGroupTest,
res = deviceImp.getCommandQueueGroupProperties(&count, properties.data());
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
auto &engineGroups = neoMockDevice->getEngineGroups();
for (uint32_t i = 0; i < count; i++) {
if (i == static_cast<uint32_t>(NEO::EngineGroupType::RenderCompute)) {
if (engineGroups[i].engineGroupType == 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].numQueues, 1u);
EXPECT_EQ(properties[i].maxMemoryFillPatternSize, std::numeric_limits<size_t>::max());
} else if (i == static_cast<uint32_t>(NEO::EngineGroupType::Compute)) {
} else if (engineGroups[i].engineGroupType == NEO::EngineGroupType::Compute) {
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_EQ(properties[i].numQueues, 1u);
EXPECT_EQ(properties[i].maxMemoryFillPatternSize, std::numeric_limits<size_t>::max());
} else if (i == static_cast<uint32_t>(NEO::EngineGroupType::Copy)) {
} else if (engineGroups[i].engineGroupType == NEO::EngineGroupType::Copy) {
EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY);
EXPECT_EQ(properties[i].numQueues, 1u);
EXPECT_EQ(properties[i].maxMemoryFillPatternSize, 4 * sizeof(uint32_t));
@@ -170,21 +171,22 @@ HWTEST2_F(DeviceQueueGroupTest,
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
EXPECT_EQ(2u, count);
auto &engineGroups = neoMockDevice->getEngineGroups();
for (uint32_t i = 0; i < count; i++) {
if (i == static_cast<uint32_t>(NEO::EngineGroupType::RenderCompute)) {
if (engineGroups[i].engineGroupType == 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].numQueues, 1u);
EXPECT_EQ(properties[i].maxMemoryFillPatternSize, std::numeric_limits<size_t>::max());
} else if (i == static_cast<uint32_t>(NEO::EngineGroupType::Compute)) {
} else if (engineGroups[i].engineGroupType == NEO::EngineGroupType::Compute) {
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_EQ(properties[i].numQueues, 1u);
EXPECT_EQ(properties[i].maxMemoryFillPatternSize, std::numeric_limits<size_t>::max());
} else if (i == static_cast<uint32_t>(NEO::EngineGroupType::Copy)) {
} else if (engineGroups[i].engineGroupType == NEO::EngineGroupType::Copy) {
EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY);
EXPECT_EQ(properties[i].numQueues, 1u);
EXPECT_EQ(properties[i].maxMemoryFillPatternSize, 4 * sizeof(uint32_t));
@@ -212,15 +214,16 @@ HWTEST2_F(DeviceQueueGroupTest,
res = deviceImp.getCommandQueueGroupProperties(&count, properties.data());
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
auto &engineGroups = neoMockDevice->getEngineGroups();
for (uint32_t i = 0; i < count; i++) {
if (i == neoMockDevice->getIndexOfNonEmptyEngineGroup(NEO::EngineGroupType::RenderCompute)) {
if (engineGroups[i].engineGroupType == 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, std::numeric_limits<size_t>::max());
EXPECT_EQ(properties[i].numQueues, 1u);
} else if (i == neoMockDevice->getIndexOfNonEmptyEngineGroup(NEO::EngineGroupType::Copy)) {
} else if (engineGroups[i].engineGroupType == NEO::EngineGroupType::Copy) {
EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY);
EXPECT_EQ(properties[i].maxMemoryFillPatternSize, 4 * sizeof(uint32_t));
EXPECT_EQ(properties[i].numQueues, 1u);
@@ -254,15 +257,16 @@ HWTEST2_F(DeviceQueueGroupTest,
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
L0::Context *context = Context::fromHandle(hContext);
auto &engineGroups = neoMockDevice->getEngineGroups();
for (uint32_t i = 0; i < count; i++) {
if (i == neoMockDevice->getIndexOfNonEmptyEngineGroup(NEO::EngineGroupType::RenderCompute)) {
if (engineGroups[i].engineGroupType == 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, std::numeric_limits<size_t>::max());
EXPECT_EQ(properties[i].numQueues, 1u);
} else if (i == neoMockDevice->getIndexOfNonEmptyEngineGroup(NEO::EngineGroupType::Copy)) {
} else if (engineGroups[i].engineGroupType == NEO::EngineGroupType::Copy) {
EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY);
EXPECT_EQ(properties[i].maxMemoryFillPatternSize, 4 * sizeof(uint32_t));
EXPECT_EQ(properties[i].numQueues, 1u);

View File

@@ -212,8 +212,9 @@ HWTEST2_F(CommandQueueGroupMultiDevice,
L0::CommandQueueImp *cmdQueue = reinterpret_cast<CommandQueueImp *>(commandList0->cmdQImmediate);
L0::DeviceImp *deviceImp = reinterpret_cast<L0::DeviceImp *>(device);
const auto rcsIndex = static_cast<size_t>(NEO::EngineGroupType::RenderCompute);
auto expectedCSR = deviceImp->neoDevice->getNearestGenericSubDevice(0)->getEngineGroups()[rcsIndex][queueGroupIndex].commandStreamReceiver;
auto &nearestSubDevice = *deviceImp->neoDevice->getNearestGenericSubDevice(0);
const auto rcsIndex = nearestSubDevice.getEngineGroupIndexFromEngineGroupType(NEO::EngineGroupType::RenderCompute);
auto expectedCSR = nearestSubDevice.getEngineGroups()[rcsIndex].engines[queueGroupIndex].commandStreamReceiver;
EXPECT_EQ(cmdQueue->getCsr(), expectedCSR);
}

View File

@@ -75,7 +75,6 @@ struct Mock<Device> : public Device {
ADDMETHOD_NOBASE(getSysmanHandle, SysmanDevice *, nullptr, ());
ADDMETHOD_NOBASE(getCsrForOrdinalAndIndex, ze_result_t, ZE_RESULT_SUCCESS, (NEO::CommandStreamReceiver * *csr, uint32_t ordinal, uint32_t index));
ADDMETHOD_NOBASE(getCsrForLowPriority, ze_result_t, ZE_RESULT_SUCCESS, (NEO::CommandStreamReceiver * *csr));
ADDMETHOD_NOBASE(mapOrdinalForAvailableEngineGroup, ze_result_t, ZE_RESULT_SUCCESS, (uint32_t * ordinal));
ADDMETHOD_NOBASE(getDebugProperties, ze_result_t, ZE_RESULT_SUCCESS, (zet_device_debug_properties_t * properties));
ADDMETHOD_NOBASE(getDebugSession, DebugSession *, nullptr, (const zet_debug_config_t &config));
ADDMETHOD_NOBASE_VOIDRETURN(removeDebugSession, ());

View File

@@ -1224,17 +1224,9 @@ TEST_F(CommandListCreate, whenInvokingAppendMemoryCopyFromContextForImmediateCom
}
TEST_F(CommandListCreate, givenQueueDescriptionwhenCreatingImmediateCommandListForEveryEnigneThenItHasImmediateCommandQueueCreated) {
auto &engines = neoDevice->getEngineGroups();
uint32_t numaAvailableEngineGroups = 0;
for (uint32_t ordinal = 0; ordinal < CommonConstants::engineGroupCount; ordinal++) {
if (engines[ordinal].size()) {
numaAvailableEngineGroups++;
}
}
for (uint32_t ordinal = 0; ordinal < numaAvailableEngineGroups; ordinal++) {
uint32_t engineGroupIndex = ordinal;
device->mapOrdinalForAvailableEngineGroup(&engineGroupIndex);
for (uint32_t index = 0; index < engines[engineGroupIndex].size(); index++) {
auto &engineGroups = neoDevice->getEngineGroups();
for (uint32_t ordinal = 0; ordinal < engineGroups.size(); ordinal++) {
for (uint32_t index = 0; index < engineGroups[ordinal].engines.size(); index++) {
ze_command_queue_desc_t desc = {};
desc.ordinal = ordinal;
desc.index = index;

View File

@@ -1217,17 +1217,9 @@ TEST_F(CommandListCreate, whenCreatingImmCmdListWithASyncModeAndAppendEventReset
}
TEST_F(CommandListCreateWithBcs, givenQueueDescriptionwhenCreatingImmediateCommandListForCopyEnigneThenItHasImmediateCommandQueueCreated) {
auto &engines = neoDevice->getEngineGroups();
uint32_t numaAvailableEngineGroups = 0;
for (uint32_t ordinal = 0; ordinal < CommonConstants::engineGroupCount; ordinal++) {
if (engines[ordinal].size()) {
numaAvailableEngineGroups++;
}
}
for (uint32_t ordinal = 0; ordinal < numaAvailableEngineGroups; ordinal++) {
uint32_t engineGroupIndex = ordinal;
device->mapOrdinalForAvailableEngineGroup(&engineGroupIndex);
for (uint32_t index = 0; index < engines[engineGroupIndex].size(); index++) {
auto &engineGroups = neoDevice->getEngineGroups();
for (uint32_t ordinal = 0; ordinal < engineGroups.size(); ordinal++) {
for (uint32_t index = 0; index < engineGroups[ordinal].engines.size(); index++) {
ze_command_queue_desc_t desc = {};
desc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS;
desc.ordinal = ordinal;

View File

@@ -7,6 +7,7 @@
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
#include "shared/test/common/mocks/mock_graphics_allocation.h"
#include "shared/test/common/mocks/ult_device_factory.h"
#include "test.h"
@@ -923,14 +924,7 @@ HWTEST_F(CommandListCreate, WhenReservingSpaceThenCommandsAddedToBatchBuffer) {
}
TEST_F(CommandListCreate, givenOrdinalBiggerThanAvailableEnginesWhenCreatingCommandListThenInvalidArgumentErrorIsReturned) {
auto &engineGroups = neoDevice->getEngineGroups();
uint32_t numAvailableEngineGroups = 0;
for (uint32_t ordinal = 0; ordinal < CommonConstants::engineGroupCount; ordinal++) {
if (engineGroups[ordinal].size()) {
numAvailableEngineGroups++;
}
}
auto numAvailableEngineGroups = static_cast<uint32_t>(neoDevice->getEngineGroups().size());
ze_command_list_handle_t commandList = nullptr;
ze_command_list_desc_t desc = {ZE_STRUCTURE_TYPE_COMMAND_LIST_DESC};
desc.commandQueueGroupOrdinal = numAvailableEngineGroups;
@@ -952,5 +946,46 @@ TEST_F(CommandListCreate, givenOrdinalBiggerThanAvailableEnginesWhenCreatingComm
EXPECT_EQ(nullptr, commandList);
}
TEST_F(CommandListCreate, givenRootDeviceAndImplicitScalingDisabledWhenCreatingCommandListThenValidateQueueOrdinalUsingSubDeviceEngines) {
NEO::UltDeviceFactory deviceFactory{1, 2};
auto &rootDevice = *deviceFactory.rootDevices[0];
auto &subDevice0 = *deviceFactory.subDevices[0];
rootDevice.engineGroups.resize(1);
subDevice0.getEngineGroups().push_back(NEO::Device::EngineGroupT{});
subDevice0.getEngineGroups().back().engineGroupType = EngineGroupType::Compute;
subDevice0.getEngineGroups().back().engines.resize(1);
subDevice0.getEngineGroups().back().engines[0].commandStreamReceiver = &rootDevice.getGpgpuCommandStreamReceiver();
auto ordinal = static_cast<uint32_t>(subDevice0.getEngineGroups().size() - 1);
Mock<L0::DeviceImp> l0RootDevice(&rootDevice, rootDevice.getExecutionEnvironment());
ze_command_list_handle_t commandList = nullptr;
ze_command_list_desc_t cmdDesc = {ZE_STRUCTURE_TYPE_COMMAND_LIST_DESC};
cmdDesc.commandQueueGroupOrdinal = ordinal;
ze_command_queue_desc_t queueDesc = {ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC};
queueDesc.ordinal = ordinal;
queueDesc.index = 0;
l0RootDevice.multiDeviceCapable = true;
auto returnValue = l0RootDevice.createCommandList(&cmdDesc, &commandList);
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, returnValue);
EXPECT_EQ(nullptr, commandList);
returnValue = l0RootDevice.createCommandListImmediate(&queueDesc, &commandList);
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, returnValue);
EXPECT_EQ(nullptr, commandList);
l0RootDevice.multiDeviceCapable = false;
returnValue = l0RootDevice.createCommandList(&cmdDesc, &commandList);
EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue);
EXPECT_NE(nullptr, commandList);
L0::CommandList::fromHandle(commandList)->destroy();
commandList = nullptr;
returnValue = l0RootDevice.createCommandListImmediate(&queueDesc, &commandList);
EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue);
EXPECT_NE(nullptr, commandList);
L0::CommandList::fromHandle(commandList)->destroy();
}
} // namespace ult
} // namespace L0

View File

@@ -9,6 +9,7 @@
#include "shared/test/common/libult/ult_command_stream_receiver.h"
#include "shared/test/common/mocks/mock_memory_manager.h"
#include "shared/test/common/mocks/mock_memory_operations_handler.h"
#include "shared/test/common/mocks/ult_device_factory.h"
#include "test.h"
@@ -37,17 +38,9 @@ TEST_F(ContextCreateCommandQueueTest, givenCallToContextCreateCommandQueueThenCa
HWTEST_F(ContextCreateCommandQueueTest, givenEveryPossibleGroupIndexWhenCreatingCommandQueueThenCommandQueueIsCreated) {
ze_command_queue_handle_t commandQueue = {};
auto &engines = neoDevice->getEngineGroups();
uint32_t numaAvailableEngineGroups = 0;
for (uint32_t ordinal = 0; ordinal < CommonConstants::engineGroupCount; ordinal++) {
if (engines[ordinal].size()) {
numaAvailableEngineGroups++;
}
}
for (uint32_t ordinal = 0; ordinal < numaAvailableEngineGroups; ordinal++) {
uint32_t engineGroupIndex = ordinal;
device->mapOrdinalForAvailableEngineGroup(&engineGroupIndex);
for (uint32_t index = 0; index < engines[engineGroupIndex].size(); index++) {
auto &engineGroups = neoDevice->getEngineGroups();
for (uint32_t ordinal = 0; ordinal < engineGroups.size(); ordinal++) {
for (uint32_t index = 0; index < engineGroups[ordinal].engines.size(); index++) {
ze_command_queue_desc_t desc = {};
desc.ordinal = ordinal;
desc.index = index;
@@ -60,17 +53,11 @@ HWTEST_F(ContextCreateCommandQueueTest, givenEveryPossibleGroupIndexWhenCreating
}
}
HWTEST_F(ContextCreateCommandQueueTest, givenOrdinalBigerThanAvailableEnginesWhenCreatingCommandQueueThenInvalidArgReturned) {
HWTEST_F(ContextCreateCommandQueueTest, givenOrdinalBiggerThanAvailableEnginesWhenCreatingCommandQueueThenInvalidArgumentErrorIsReturned) {
ze_command_queue_handle_t commandQueue = {};
auto &engines = neoDevice->getEngineGroups();
uint32_t numaAvailableEngineGroups = 0;
for (uint32_t ordinal = 0; ordinal < CommonConstants::engineGroupCount; ordinal++) {
if (engines[ordinal].size()) {
numaAvailableEngineGroups++;
}
}
ze_command_queue_desc_t desc = {ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC};
desc.ordinal = numaAvailableEngineGroups;
auto &engineGroups = neoDevice->getEngineGroups();
ze_command_queue_desc_t desc = {};
desc.ordinal = static_cast<uint32_t>(engineGroups.size());
desc.index = 0;
ze_result_t res = context->createCommandQueue(device, &desc, &commandQueue);
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, res);
@@ -83,6 +70,35 @@ HWTEST_F(ContextCreateCommandQueueTest, givenOrdinalBigerThanAvailableEnginesWhe
EXPECT_EQ(nullptr, commandQueue);
}
HWTEST_F(ContextCreateCommandQueueTest, givenRootDeviceAndImplicitScalingDisabledWhenCreatingCommandQueueThenValidateQueueOrdinalUsingSubDeviceEngines) {
NEO::UltDeviceFactory deviceFactory{1, 2};
auto &rootDevice = *deviceFactory.rootDevices[0];
auto &subDevice0 = *deviceFactory.subDevices[0];
rootDevice.engineGroups.resize(1);
subDevice0.getEngineGroups().push_back(NEO::Device::EngineGroupT{});
subDevice0.getEngineGroups().back().engineGroupType = EngineGroupType::Compute;
subDevice0.getEngineGroups().back().engines.resize(1);
subDevice0.getEngineGroups().back().engines[0].commandStreamReceiver = &rootDevice.getGpgpuCommandStreamReceiver();
auto ordinal = static_cast<uint32_t>(subDevice0.getEngineGroups().size() - 1);
Mock<L0::DeviceImp> l0RootDevice(&rootDevice, rootDevice.getExecutionEnvironment());
ze_command_queue_handle_t commandQueue = nullptr;
ze_command_queue_desc_t desc = {ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC};
desc.ordinal = ordinal;
desc.index = 0;
l0RootDevice.multiDeviceCapable = true;
ze_result_t res = context->createCommandQueue(l0RootDevice.toHandle(), &desc, &commandQueue);
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, res);
EXPECT_EQ(nullptr, commandQueue);
l0RootDevice.multiDeviceCapable = false;
res = context->createCommandQueue(l0RootDevice.toHandle(), &desc, &commandQueue);
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
EXPECT_NE(nullptr, commandQueue);
L0::CommandQueue::fromHandle(commandQueue)->destroy();
}
using AubCsrTest = Test<AubCsrFixture>;
HWTEST_TEMPLATED_F(AubCsrTest, givenAubCsrWhenCallingExecuteCommandListsThenPollForCompletionIsCalled) {

View File

@@ -80,22 +80,23 @@ HWTEST2_F(DeviceQueueGroupTest, givenBlitterSupportAndCCSThenThreeQueueGroupsAre
res = deviceImp.getCommandQueueGroupProperties(&count, properties.data());
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
auto &engineGroups = neoMockDevice->getEngineGroups();
for (uint32_t i = 0; i < count; i++) {
if (i == static_cast<uint32_t>(NEO::EngineGroupType::RenderCompute)) {
if (engineGroups[i].engineGroupType == 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].numQueues, 1u);
EXPECT_EQ(properties[i].maxMemoryFillPatternSize, std::numeric_limits<size_t>::max());
} else if (i == static_cast<uint32_t>(NEO::EngineGroupType::Compute)) {
} else if (engineGroups[i].engineGroupType == NEO::EngineGroupType::Compute) {
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);
uint32_t numerOfCCSEnabled = hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled;
EXPECT_EQ(properties[i].numQueues, numerOfCCSEnabled);
EXPECT_EQ(properties[i].maxMemoryFillPatternSize, std::numeric_limits<size_t>::max());
} else if (i == static_cast<uint32_t>(NEO::EngineGroupType::Copy)) {
} else if (engineGroups[i].engineGroupType == NEO::EngineGroupType::Copy) {
EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY);
EXPECT_EQ(properties[i].numQueues, hwInfo.featureTable.ftrBcsInfo.count());
EXPECT_EQ(properties[i].maxMemoryFillPatternSize, 4 * sizeof(uint32_t));
@@ -137,8 +138,8 @@ HWTEST2_F(DeviceCopyQueueGroupTest,
res = deviceImp.getCommandQueueGroupProperties(&count, properties.data());
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
for (uint32_t i = 0; i < count; i++) {
EXPECT_NE(i, static_cast<uint32_t>(NEO::EngineGroupType::Copy));
for (auto &engineGroup : neoMockDevice->getEngineGroups()) {
EXPECT_NE(NEO::EngineGroupType::Copy, engineGroup.engineGroupType);
}
}

View File

@@ -60,22 +60,23 @@ HWTEST2_F(DeviceQueueGroupTest, givenBlitterSupportAndCCSThenThreeQueueGroupsAre
res = deviceImp.getCommandQueueGroupProperties(&count, properties.data());
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
auto &engineGroups = neoMockDevice->getEngineGroups();
for (uint32_t i = 0; i < count; i++) {
if (i == static_cast<uint32_t>(NEO::EngineGroupType::RenderCompute)) {
if (engineGroups[i].engineGroupType == 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].numQueues, 1u);
EXPECT_EQ(properties[i].maxMemoryFillPatternSize, std::numeric_limits<size_t>::max());
} else if (i == static_cast<uint32_t>(NEO::EngineGroupType::Compute)) {
} else if (engineGroups[i].engineGroupType == NEO::EngineGroupType::Compute) {
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);
uint32_t numerOfCCSEnabled = hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled;
EXPECT_EQ(properties[i].numQueues, numerOfCCSEnabled);
EXPECT_EQ(properties[i].maxMemoryFillPatternSize, std::numeric_limits<size_t>::max());
} else if (i == static_cast<uint32_t>(NEO::EngineGroupType::Copy)) {
} else if (engineGroups[i].engineGroupType == NEO::EngineGroupType::Copy) {
EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY);
EXPECT_EQ(properties[i].numQueues, hwInfo.featureTable.ftrBcsInfo.count());
EXPECT_EQ(properties[i].maxMemoryFillPatternSize, 4 * sizeof(uint32_t));
@@ -117,8 +118,8 @@ HWTEST2_F(DeviceCopyQueueGroupTest,
res = deviceImp.getCommandQueueGroupProperties(&count, properties.data());
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
for (uint32_t i = 0; i < count; i++) {
EXPECT_NE(i, static_cast<uint32_t>(NEO::EngineGroupType::Copy));
for (auto &engineGroup : neoMockDevice->getEngineGroups()) {
EXPECT_NE(NEO::EngineGroupType::Copy, engineGroup.engineGroupType);
}
}