mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
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:

committed by
Compute-Runtime-Automation

parent
a1121ccb6b
commit
2098b0c3fa
@ -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;
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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, ());
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -379,18 +379,13 @@ void ClDevice::initializeCaps() {
|
||||
}
|
||||
}
|
||||
|
||||
const auto &queueFamilies = this->getDevice().getEngineGroups();
|
||||
for (size_t queueFamilyIndex = 0u; queueFamilyIndex < CommonConstants::engineGroupCount; queueFamilyIndex++) {
|
||||
const std::vector<EngineControl> &enginesInFamily = queueFamilies[queueFamilyIndex];
|
||||
if (enginesInFamily.size() > 0) {
|
||||
const auto engineGroupType = static_cast<EngineGroupType>(queueFamilyIndex);
|
||||
cl_queue_family_properties_intel properties = {};
|
||||
properties.capabilities = getQueueFamilyCapabilities(engineGroupType);
|
||||
properties.count = static_cast<cl_uint>(enginesInFamily.size());
|
||||
properties.properties = deviceInfo.queueOnHostProperties;
|
||||
getQueueFamilyName(properties.name, engineGroupType);
|
||||
deviceInfo.queueFamilyProperties.push_back(properties);
|
||||
}
|
||||
for (auto &engineGroup : this->getDevice().getEngineGroups()) {
|
||||
cl_queue_family_properties_intel properties = {};
|
||||
properties.capabilities = getQueueFamilyCapabilities(engineGroup.engineGroupType);
|
||||
properties.count = static_cast<cl_uint>(engineGroup.engines.size());
|
||||
properties.properties = deviceInfo.queueOnHostProperties;
|
||||
getQueueFamilyName(properties.name, engineGroup.engineGroupType);
|
||||
deviceInfo.queueFamilyProperties.push_back(properties);
|
||||
}
|
||||
auto &clHwHelper = NEO::ClHwHelper::get(hwInfo.platform.eRenderCoreFamily);
|
||||
const std::vector<uint32_t> &supportedThreadArbitrationPolicies = clHwHelper.getSupportedThreadArbitrationPolicies();
|
||||
|
@ -668,7 +668,7 @@ cl_uint CommandQueue::getQueueFamilyIndex() const {
|
||||
const auto &hwInfo = device->getHardwareInfo();
|
||||
const auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
|
||||
const auto engineGroupType = hwHelper.getEngineGroupType(gpgpuEngine->getEngineType(), gpgpuEngine->getEngineUsage(), hwInfo);
|
||||
const auto familyIndex = device->getDevice().getIndexOfNonEmptyEngineGroup(engineGroupType);
|
||||
const auto familyIndex = device->getDevice().getEngineGroupIndexFromEngineGroupType(engineGroupType);
|
||||
return static_cast<cl_uint>(familyIndex);
|
||||
}
|
||||
}
|
||||
@ -907,8 +907,7 @@ void CommandQueue::processProperties(const cl_queue_properties *properties) {
|
||||
if (specificEngineSelected) {
|
||||
this->queueFamilySelected = true;
|
||||
if (!getDevice().hasRootCsr()) {
|
||||
auto queueFamily = getDevice().getNonEmptyEngineGroup(selectedQueueFamilyIndex);
|
||||
const auto &engine = queueFamily->at(selectedQueueIndex);
|
||||
const auto &engine = getDevice().getEngineGroups()[selectedQueueFamilyIndex].engines[selectedQueueIndex];
|
||||
auto engineType = engine.getEngineType();
|
||||
auto engineUsage = engine.getEngineUsage();
|
||||
this->overrideEngine(engineType, engineUsage);
|
||||
|
@ -1371,7 +1371,7 @@ struct CsrSelectionCommandQueueTests : ::testing::Test {
|
||||
cl_command_queue_properties queueProperties[5] = {};
|
||||
if (selectBlitterWithQueueFamilies) {
|
||||
queueProperties[0] = CL_QUEUE_FAMILY_INTEL;
|
||||
queueProperties[1] = device->getIndexOfNonEmptyEngineGroup(EngineGroupType::Copy);
|
||||
queueProperties[1] = device->getEngineGroupIndexFromEngineGroupType(EngineGroupType::Copy);
|
||||
queueProperties[2] = CL_QUEUE_INDEX_INTEL;
|
||||
queueProperties[3] = 0;
|
||||
}
|
||||
@ -2055,7 +2055,7 @@ HWTEST_F(CommandQueueOnSpecificEngineTests, givenNotInitializedRcsOsContextWhenC
|
||||
OsContext &osContext = *context.getDevice(0)->getEngine(aub_stream::ENGINE_CCS, EngineUsage::Regular).osContext;
|
||||
EXPECT_FALSE(osContext.isInitialized());
|
||||
|
||||
const auto ccsFamilyIndex = static_cast<cl_uint>(context.getDevice(0)->getDevice().getIndexOfNonEmptyEngineGroup(EngineGroupType::Compute));
|
||||
const auto ccsFamilyIndex = static_cast<cl_uint>(context.getDevice(0)->getDevice().getEngineGroupIndexFromEngineGroupType(EngineGroupType::Compute));
|
||||
fillProperties(properties, ccsFamilyIndex, 0);
|
||||
MockCommandQueueHw<FamilyType> queue(&context, context.getDevice(0), properties);
|
||||
ASSERT_EQ(&osContext, queue.gpgpuEngine->osContext);
|
||||
@ -2076,7 +2076,7 @@ HWTEST_F(CommandQueueOnSpecificEngineTests, givenNotInitializedCcsOsContextWhenC
|
||||
OsContext &osContext = *context.getDevice(0)->getEngine(aub_stream::ENGINE_RCS, EngineUsage::Regular).osContext;
|
||||
EXPECT_FALSE(osContext.isInitialized());
|
||||
|
||||
const auto rcsFamilyIndex = static_cast<cl_uint>(context.getDevice(0)->getDevice().getIndexOfNonEmptyEngineGroup(EngineGroupType::RenderCompute));
|
||||
const auto rcsFamilyIndex = static_cast<cl_uint>(context.getDevice(0)->getDevice().getEngineGroupIndexFromEngineGroupType(EngineGroupType::RenderCompute));
|
||||
fillProperties(properties, rcsFamilyIndex, 0);
|
||||
MockCommandQueueHw<FamilyType> queue(&context, context.getDevice(0), properties);
|
||||
ASSERT_EQ(&osContext, queue.gpgpuEngine->osContext);
|
||||
@ -2130,12 +2130,13 @@ struct CopyOnlyQueueTests : ::testing::Test {
|
||||
typeUsageRcs.first = EngineHelpers::remapEngineTypeToHwSpecific(typeUsageRcs.first, *defaultHwInfo);
|
||||
|
||||
auto device = MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get());
|
||||
if (device->engineGroups[static_cast<uint32_t>(EngineGroupType::Copy)].empty()) {
|
||||
auto copyEngineGroup = std::find_if(device->engineGroups.begin(), device->engineGroups.end(), [](const auto &engineGroup) {
|
||||
return engineGroup.engineGroupType == EngineGroupType::Copy;
|
||||
});
|
||||
if (copyEngineGroup == device->engineGroups.end()) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
for (auto &engineGroup : device->engineGroups) {
|
||||
engineGroup.clear();
|
||||
}
|
||||
device->engineGroups.clear();
|
||||
device->engines.clear();
|
||||
|
||||
device->createEngine(0, typeUsageRcs);
|
||||
@ -2146,7 +2147,7 @@ struct CopyOnlyQueueTests : ::testing::Test {
|
||||
|
||||
context = std::make_unique<MockContext>(clDevice.get());
|
||||
|
||||
properties[1] = device->getIndexOfNonEmptyEngineGroup(EngineGroupType::Copy);
|
||||
properties[1] = device->getEngineGroupIndexFromEngineGroupType(EngineGroupType::Copy);
|
||||
}
|
||||
|
||||
EngineTypeUsage typeUsageBcs = EngineTypeUsage{aub_stream::EngineType::ENGINE_BCS, EngineUsage::Regular};
|
||||
@ -2234,7 +2235,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, MultiEngineQueueHwTests, givenQueueFamilyPropertyWh
|
||||
};
|
||||
auto addTestValueIfAvailable = [&](std::vector<CommandQueueTestValues> &vec, EngineGroupType engineGroup, cl_queue_properties queueIndex, aub_stream::EngineType engineType, bool csEnabled) {
|
||||
if (csEnabled) {
|
||||
const auto familyIndex = device->getDevice().getIndexOfNonEmptyEngineGroup(engineGroup);
|
||||
const auto familyIndex = device->getDevice().getEngineGroupIndexFromEngineGroupType(engineGroup);
|
||||
vec.push_back(CommandQueueTestValues(static_cast<cl_queue_properties>(familyIndex), queueIndex, engineType));
|
||||
}
|
||||
};
|
||||
|
@ -137,7 +137,7 @@ TEST_F(GetCommandQueueFamilyInfoTests, givenQueueFamilyNotSelectedWhenGettingFam
|
||||
const auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
|
||||
const auto engineGroupType = hwHelper.getEngineGroupType(context.getDevice(0)->getDefaultEngine().getEngineType(),
|
||||
context.getDevice(0)->getDefaultEngine().getEngineUsage(), hwInfo);
|
||||
const auto expectedFamilyIndex = context.getDevice(0)->getDevice().getIndexOfNonEmptyEngineGroup(engineGroupType);
|
||||
const auto expectedFamilyIndex = context.getDevice(0)->getDevice().getEngineGroupIndexFromEngineGroupType(engineGroupType);
|
||||
|
||||
cl_uint familyIndex{};
|
||||
retVal = queue.getCommandQueueInfo(
|
||||
@ -191,7 +191,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, GetCommandQueueFamilyInfoTests, givenFamilyIdWhenGe
|
||||
|
||||
const cl_device_id deviceId = &mockClDevice;
|
||||
auto context = clCreateContext(nullptr, 1, &deviceId, nullptr, nullptr, nullptr);
|
||||
auto ccsFamily = mockClDevice.getDevice().getIndexOfNonEmptyEngineGroup(EngineGroupType::Compute);
|
||||
auto ccsFamily = mockClDevice.getDevice().getEngineGroupIndexFromEngineGroupType(EngineGroupType::Compute);
|
||||
cl_command_queue_properties properties[] = {CL_QUEUE_FAMILY_INTEL, ccsFamily, CL_QUEUE_INDEX_INTEL, 0, 0};
|
||||
EXPECT_EQ(0u, mockClDevice.getNumGenericSubDevices());
|
||||
auto commandQueue = clCreateCommandQueueWithProperties(context, deviceId, properties, nullptr);
|
||||
@ -252,7 +252,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, MultiEngineQueueHwTests, givenLimitedNumberOfCcsWhe
|
||||
|
||||
const uint32_t ccsCount = 4;
|
||||
|
||||
auto ccsEngine = device->getDevice().getIndexOfNonEmptyEngineGroup(EngineGroupType::Compute);
|
||||
auto ccsEngine = device->getDevice().getEngineGroupIndexFromEngineGroupType(EngineGroupType::Compute);
|
||||
cl_queue_properties properties[5] = {CL_QUEUE_FAMILY_INTEL, ccsEngine, CL_QUEUE_INDEX_INTEL, 0, 0};
|
||||
|
||||
auto mutableHwInfo = device->getRootDeviceEnvironment().getMutableHardwareInfo();
|
||||
|
@ -525,12 +525,33 @@ TEST(DeviceCreation, givenDeviceWhenCheckingParentDeviceThenCorrectValueIsReturn
|
||||
}
|
||||
|
||||
TEST(DeviceCreation, givenRootDeviceWithSubDevicesWhenCheckingEngineGroupsThenItHasOneNonEmptyGroup) {
|
||||
static_assert(sizeof(Device::EngineGroupsT) == sizeof(std::vector<EngineControl>) * static_cast<size_t>(EngineGroupType::MaxEngineGroups),
|
||||
"Expect size of EngineGroupsT to match EngineGroupType::MaxEngineGroups");
|
||||
|
||||
UltDeviceFactory deviceFactory{1, 2};
|
||||
EXPECT_NE(nullptr, deviceFactory.rootDevices[0]->getNonEmptyEngineGroup(0));
|
||||
EXPECT_EQ(nullptr, deviceFactory.rootDevices[0]->getNonEmptyEngineGroup(1));
|
||||
EXPECT_EQ(1u, deviceFactory.rootDevices[0]->getEngineGroups().size());
|
||||
}
|
||||
|
||||
TEST(DeviceCreation, whenCheckingEngineGroupsThenGroupsAreUnique) {
|
||||
VariableBackup<HardwareInfo> backupHwInfo(defaultHwInfo.get());
|
||||
defaultHwInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 4;
|
||||
|
||||
for (auto ftrGpGpuMidThreadLevelPreempt : ::testing::Bool()) {
|
||||
defaultHwInfo->featureTable.flags.ftrGpGpuMidThreadLevelPreempt = ftrGpGpuMidThreadLevelPreempt;
|
||||
for (auto blitterOperationsSupported : ::testing::Bool()) {
|
||||
defaultHwInfo->capabilityTable.blitterOperationsSupported = blitterOperationsSupported;
|
||||
for (auto ftrRcsNode : ::testing::Bool()) {
|
||||
defaultHwInfo->featureTable.flags.ftrRcsNode = ftrRcsNode;
|
||||
for (auto ftrCCSNode : ::testing::Bool()) {
|
||||
defaultHwInfo->featureTable.flags.ftrCCSNode = ftrCCSNode;
|
||||
|
||||
UltDeviceFactory deviceFactory{1, 0};
|
||||
std::set<EngineGroupType> uniqueEngineGroupTypes;
|
||||
for (auto &engineGroup : deviceFactory.rootDevices[0]->getEngineGroups()) {
|
||||
uniqueEngineGroupTypes.insert(engineGroup.engineGroupType);
|
||||
}
|
||||
EXPECT_EQ(uniqueEngineGroupTypes.size(), deviceFactory.rootDevices[0]->getEngineGroups().size());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using DeviceHwTest = ::testing::Test;
|
||||
@ -591,7 +612,7 @@ HWTEST_F(DeviceHwTest, givenDeviceCreationWhenCsrFailsToCreateGlobalSyncAllocati
|
||||
EXPECT_EQ(nullptr, mockDevice);
|
||||
}
|
||||
|
||||
HWTEST_F(DeviceHwTest, givenBothCcsAndRcsEnginesInDeviceWhenGettingFirstEngineGroupsThenReturnCcs) {
|
||||
HWTEST_F(DeviceHwTest, givenBothCcsAndRcsEnginesInDeviceWhenGettingEngineGroupsThenReturnInCorrectOrder) {
|
||||
struct MyHwHelper : HwHelperHw<FamilyType> {
|
||||
EngineGroupType getEngineGroupType(aub_stream::EngineType engineType, EngineUsage engineUsage, const HardwareInfo &hwInfo) const override {
|
||||
if (engineType == aub_stream::ENGINE_RCS) {
|
||||
@ -612,13 +633,27 @@ HWTEST_F(DeviceHwTest, givenBothCcsAndRcsEnginesInDeviceWhenGettingFirstEngineGr
|
||||
EngineControl ccsEngine{nullptr, &ccsContext};
|
||||
|
||||
MockDevice device{};
|
||||
ASSERT_EQ(nullptr, device.getNonEmptyEngineGroup(0u));
|
||||
ASSERT_EQ(0u, device.getEngineGroups().size());
|
||||
device.addEngineToEngineGroup(ccsEngine);
|
||||
device.addEngineToEngineGroup(rcsEngine);
|
||||
auto &engineGroups = device.getEngineGroups();
|
||||
EXPECT_EQ(1u, engineGroups[0].engines.size());
|
||||
EXPECT_EQ(EngineGroupType::Compute, engineGroups[0].engineGroupType);
|
||||
EXPECT_EQ(aub_stream::EngineType::ENGINE_CCS, engineGroups[0].engines[0].getEngineType());
|
||||
EXPECT_EQ(1u, engineGroups[1].engines.size());
|
||||
EXPECT_EQ(EngineGroupType::RenderCompute, engineGroups[1].engineGroupType);
|
||||
EXPECT_EQ(aub_stream::EngineType::ENGINE_RCS, engineGroups[1].engines[0].getEngineType());
|
||||
|
||||
device.getEngineGroups().clear();
|
||||
device.addEngineToEngineGroup(rcsEngine);
|
||||
device.addEngineToEngineGroup(ccsEngine);
|
||||
|
||||
const auto firstGroup = device.getNonEmptyEngineGroup(0u);
|
||||
EXPECT_EQ(1u, firstGroup->size());
|
||||
EXPECT_EQ(aub_stream::EngineType::ENGINE_CCS, firstGroup->at(0).getEngineType());
|
||||
engineGroups = device.getEngineGroups();
|
||||
EXPECT_EQ(1u, engineGroups[0].engines.size());
|
||||
EXPECT_EQ(EngineGroupType::RenderCompute, engineGroups[0].engineGroupType);
|
||||
EXPECT_EQ(aub_stream::EngineType::ENGINE_RCS, engineGroups[0].engines[0].getEngineType());
|
||||
EXPECT_EQ(1u, engineGroups[1].engines.size());
|
||||
EXPECT_EQ(EngineGroupType::Compute, engineGroups[1].engineGroupType);
|
||||
EXPECT_EQ(aub_stream::EngineType::ENGINE_CCS, engineGroups[1].engines[0].getEngineType());
|
||||
}
|
||||
|
||||
TEST(DeviceGetEngineTest, givenHwCsrModeWhenGetEngineThenDedicatedForInternalUsageEngineIsReturned) {
|
||||
@ -644,79 +679,21 @@ TEST(DeviceGetEngineTest, givenCreatedDeviceWhenRetrievingDefaultEngineThenOsCon
|
||||
EXPECT_TRUE(defaultEngine.osContext->isDefaultContext());
|
||||
}
|
||||
|
||||
TEST(DeviceGetEngineTest, givenNoEmptyGroupsWhenGettingNonEmptyGroupsThenReturnCorrectResults) {
|
||||
TEST(DeviceGetEngineTest, givenVariousIndicesWhenGettingEngineGroupIndexFromEngineGroupTypeThenReturnCorrectResults) {
|
||||
const auto nonEmptyEngineGroup = std::vector<EngineControl>{EngineControl{nullptr, nullptr}};
|
||||
|
||||
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
|
||||
auto &engineGroups = device->getEngineGroups();
|
||||
for (auto &engineGroup : engineGroups) {
|
||||
engineGroup.clear();
|
||||
}
|
||||
engineGroups[0] = nonEmptyEngineGroup;
|
||||
engineGroups[1] = nonEmptyEngineGroup;
|
||||
engineGroups[2] = nonEmptyEngineGroup;
|
||||
engineGroups.resize(3);
|
||||
engineGroups[0].engineGroupType = static_cast<EngineGroupType>(4);
|
||||
engineGroups[1].engineGroupType = static_cast<EngineGroupType>(3);
|
||||
engineGroups[2].engineGroupType = static_cast<EngineGroupType>(2);
|
||||
|
||||
EXPECT_EQ(&engineGroups[0], device->getNonEmptyEngineGroup(0));
|
||||
EXPECT_EQ(&engineGroups[1], device->getNonEmptyEngineGroup(1));
|
||||
EXPECT_EQ(&engineGroups[2], device->getNonEmptyEngineGroup(2));
|
||||
EXPECT_EQ(nullptr, device->getNonEmptyEngineGroup(3));
|
||||
}
|
||||
|
||||
TEST(DeviceGetEngineTest, givenEmptyGroupsWhenGettingNonEmptyGroupsThenReturnCorrectResults) {
|
||||
const auto emptyEngineGroup = std::vector<EngineControl>{};
|
||||
const auto nonEmptyEngineGroup = std::vector<EngineControl>{EngineControl{nullptr, nullptr}};
|
||||
|
||||
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
|
||||
auto &engineGroups = device->getEngineGroups();
|
||||
for (auto &engineGroup : engineGroups) {
|
||||
engineGroup.clear();
|
||||
}
|
||||
engineGroups[0] = nonEmptyEngineGroup;
|
||||
engineGroups[1] = emptyEngineGroup;
|
||||
engineGroups[2] = nonEmptyEngineGroup;
|
||||
|
||||
EXPECT_EQ(&engineGroups[0], device->getNonEmptyEngineGroup(0));
|
||||
EXPECT_EQ(&engineGroups[2], device->getNonEmptyEngineGroup(1));
|
||||
EXPECT_EQ(nullptr, device->getNonEmptyEngineGroup(2));
|
||||
}
|
||||
|
||||
TEST(DeviceGetEngineTest, givenNoEmptyGroupsWhenGettingNonEmptyGroupIndexThenReturnCorrectResults) {
|
||||
const auto nonEmptyEngineGroup = std::vector<EngineControl>{EngineControl{nullptr, nullptr}};
|
||||
|
||||
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
|
||||
auto &engineGroups = device->getEngineGroups();
|
||||
for (auto &engineGroup : engineGroups) {
|
||||
engineGroup.clear();
|
||||
}
|
||||
engineGroups[0] = nonEmptyEngineGroup;
|
||||
engineGroups[1] = nonEmptyEngineGroup;
|
||||
engineGroups[2] = nonEmptyEngineGroup;
|
||||
|
||||
EXPECT_EQ(0u, device->getIndexOfNonEmptyEngineGroup(static_cast<EngineGroupType>(0u)));
|
||||
EXPECT_EQ(1u, device->getIndexOfNonEmptyEngineGroup(static_cast<EngineGroupType>(1u)));
|
||||
EXPECT_EQ(2u, device->getIndexOfNonEmptyEngineGroup(static_cast<EngineGroupType>(2u)));
|
||||
EXPECT_ANY_THROW(device->getIndexOfNonEmptyEngineGroup(static_cast<EngineGroupType>(3u)));
|
||||
EXPECT_ANY_THROW(device->getIndexOfNonEmptyEngineGroup(static_cast<EngineGroupType>(4u)));
|
||||
}
|
||||
|
||||
TEST(DeviceGetEngineTest, givenEmptyGroupsWhenGettingNonEmptyGroupIndexThenReturnCorrectResults) {
|
||||
const auto emptyEngineGroup = std::vector<EngineControl>{};
|
||||
const auto nonEmptyEngineGroup = std::vector<EngineControl>{EngineControl{nullptr, nullptr}};
|
||||
|
||||
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
|
||||
auto &engineGroups = device->getEngineGroups();
|
||||
for (auto &engineGroup : engineGroups) {
|
||||
engineGroup.clear();
|
||||
}
|
||||
engineGroups[0] = nonEmptyEngineGroup;
|
||||
engineGroups[1] = emptyEngineGroup;
|
||||
engineGroups[2] = nonEmptyEngineGroup;
|
||||
|
||||
EXPECT_EQ(0u, device->getIndexOfNonEmptyEngineGroup(static_cast<EngineGroupType>(0u)));
|
||||
EXPECT_ANY_THROW(device->getIndexOfNonEmptyEngineGroup(static_cast<EngineGroupType>(1u)));
|
||||
EXPECT_EQ(1u, device->getIndexOfNonEmptyEngineGroup(static_cast<EngineGroupType>(2u)));
|
||||
EXPECT_ANY_THROW(device->getIndexOfNonEmptyEngineGroup(static_cast<EngineGroupType>(3u)));
|
||||
EXPECT_ANY_THROW(device->getIndexOfNonEmptyEngineGroup(static_cast<EngineGroupType>(4u)));
|
||||
EXPECT_EQ(0u, device->getEngineGroupIndexFromEngineGroupType(static_cast<EngineGroupType>(4u)));
|
||||
EXPECT_EQ(1u, device->getEngineGroupIndexFromEngineGroupType(static_cast<EngineGroupType>(3u)));
|
||||
EXPECT_EQ(2u, device->getEngineGroupIndexFromEngineGroupType(static_cast<EngineGroupType>(2u)));
|
||||
EXPECT_ANY_THROW(device->getEngineGroupIndexFromEngineGroupType(static_cast<EngineGroupType>(1u)));
|
||||
EXPECT_ANY_THROW(device->getEngineGroupIndexFromEngineGroupType(static_cast<EngineGroupType>(0u)));
|
||||
}
|
||||
|
||||
TEST(DeviceGetEngineTest, givenDeferredContextInitializationEnabledWhenCreatingEnginesThenInitializeOnlyOsContextsWhichRequireIt) {
|
||||
|
@ -1005,8 +1005,8 @@ HWTEST_F(EngineInstancedDeviceTests, whenCreateMultipleCommandQueuesThenEnginesA
|
||||
const auto &hwHelper = NEO::HwHelper::get(hwInfo.platform.eRenderCoreFamily);
|
||||
const auto engineGroupType = hwHelper.getEngineGroupType(defaultEngine.getEngineType(), defaultEngine.getEngineUsage(), hwInfo);
|
||||
|
||||
auto defaultEngineGroupIndex = clRootDevice->getDevice().getIndexOfNonEmptyEngineGroup(engineGroupType);
|
||||
auto engines = clRootDevice->getDevice().getEngineGroups()[defaultEngineGroupIndex];
|
||||
auto defaultEngineGroupIndex = clRootDevice->getDevice().getEngineGroupIndexFromEngineGroupType(engineGroupType);
|
||||
auto engines = clRootDevice->getDevice().getEngineGroups()[defaultEngineGroupIndex].engines;
|
||||
|
||||
for (size_t i = 0; i < cmdQs.size(); i++) {
|
||||
auto engineIndex = i % engines.size();
|
||||
|
@ -1348,7 +1348,7 @@ HWTEST_TEMPLATED_F(BcsBufferTests, givenBcsQueueWhenEnqueueingCopyBufferToBuffer
|
||||
|
||||
cl_command_queue_properties properties[] = {
|
||||
CL_QUEUE_FAMILY_INTEL,
|
||||
device->getDevice().getIndexOfNonEmptyEngineGroup(EngineGroupType::Copy),
|
||||
device->getDevice().getEngineGroupIndexFromEngineGroupType(EngineGroupType::Copy),
|
||||
CL_QUEUE_INDEX_INTEL,
|
||||
0,
|
||||
0,
|
||||
|
@ -297,8 +297,11 @@ void Device::addEngineToEngineGroup(EngineControl &engine) {
|
||||
return;
|
||||
}
|
||||
|
||||
const uint32_t engineGroupIndex = static_cast<uint32_t>(engineGroupType);
|
||||
this->engineGroups[engineGroupIndex].push_back(engine);
|
||||
if (this->engineGroups.empty() || this->engineGroups.back().engineGroupType != engineGroupType) {
|
||||
this->engineGroups.push_back(EngineGroupT{});
|
||||
this->engineGroups.back().engineGroupType = engineGroupType;
|
||||
}
|
||||
this->engineGroups.back().engines.push_back(engine);
|
||||
}
|
||||
|
||||
std::unique_ptr<CommandStreamReceiver> Device::createCommandStreamReceiver() const {
|
||||
@ -418,36 +421,14 @@ bool Device::areSharedSystemAllocationsAllowed() const {
|
||||
return sharedSystemAllocationsSupport;
|
||||
}
|
||||
|
||||
const std::vector<EngineControl> *Device::getNonEmptyEngineGroup(size_t index) const {
|
||||
auto nonEmptyGroupIndex = 0u;
|
||||
for (auto groupIndex = 0u; groupIndex < CommonConstants::engineGroupCount; groupIndex++) {
|
||||
const std::vector<EngineControl> *currentGroup = &engineGroups[groupIndex];
|
||||
if (currentGroup->empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (index == nonEmptyGroupIndex) {
|
||||
return currentGroup;
|
||||
}
|
||||
|
||||
nonEmptyGroupIndex++;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
size_t Device::getIndexOfNonEmptyEngineGroup(EngineGroupType engineGroupType) const {
|
||||
const auto groupIndex = static_cast<size_t>(engineGroupType);
|
||||
UNRECOVERABLE_IF(groupIndex >= CommonConstants::engineGroupCount);
|
||||
UNRECOVERABLE_IF(engineGroups[groupIndex].empty());
|
||||
|
||||
size_t result = 0u;
|
||||
for (auto currentGroupIndex = 0u; currentGroupIndex < groupIndex; currentGroupIndex++) {
|
||||
if (!engineGroups[currentGroupIndex].empty()) {
|
||||
result++;
|
||||
size_t Device::getEngineGroupIndexFromEngineGroupType(EngineGroupType engineGroupType) const {
|
||||
for (size_t i = 0; i < engineGroups.size(); i++) {
|
||||
if (engineGroups[i].engineGroupType == engineGroupType) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
UNRECOVERABLE_IF(true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
EngineControl *Device::tryGetEngine(aub_stream::EngineType engineType, EngineUsage engineUsage) {
|
||||
@ -586,11 +567,11 @@ EngineControl &Device::getNextEngineForCommandQueue() {
|
||||
const auto &hwHelper = NEO::HwHelper::get(hardwareInfo.platform.eRenderCoreFamily);
|
||||
const auto engineGroupType = hwHelper.getEngineGroupType(defaultEngine.getEngineType(), defaultEngine.getEngineUsage(), hardwareInfo);
|
||||
|
||||
const auto defaultEngineGroupIndex = this->getIndexOfNonEmptyEngineGroup(engineGroupType);
|
||||
const auto &engines = this->getEngineGroups()[defaultEngineGroupIndex];
|
||||
const auto defaultEngineGroupIndex = this->getEngineGroupIndexFromEngineGroupType(engineGroupType);
|
||||
auto &engineGroup = this->getEngineGroups()[defaultEngineGroupIndex];
|
||||
|
||||
const auto engineIndex = this->regularCommandQueuesCreatedWithinDeviceCount++ % engines.size();
|
||||
return this->getEngineGroups()[defaultEngineGroupIndex][engineIndex];
|
||||
const auto engineIndex = this->regularCommandQueuesCreatedWithinDeviceCount++ % engineGroup.engines.size();
|
||||
return engineGroup.engines[engineIndex];
|
||||
}
|
||||
|
||||
EngineControl *Device::getInternalCopyEngine() {
|
||||
|
@ -32,8 +32,12 @@ struct SelectorCopyEngine : NonCopyableOrMovableClass {
|
||||
|
||||
class Device : public ReferenceTrackedObject<Device> {
|
||||
public:
|
||||
using EngineGroupT = std::vector<EngineControl>;
|
||||
using EngineGroupsT = EngineGroupT[CommonConstants::engineGroupCount];
|
||||
using EnginesT = std::vector<EngineControl>;
|
||||
struct EngineGroupT {
|
||||
EngineGroupType engineGroupType;
|
||||
EnginesT engines;
|
||||
};
|
||||
using EngineGroupsT = std::vector<EngineGroupT>;
|
||||
|
||||
Device &operator=(const Device &) = delete;
|
||||
Device(const Device &) = delete;
|
||||
@ -61,8 +65,7 @@ class Device : public ReferenceTrackedObject<Device> {
|
||||
EngineGroupsT &getEngineGroups() {
|
||||
return this->engineGroups;
|
||||
}
|
||||
const std::vector<EngineControl> *getNonEmptyEngineGroup(size_t index) const;
|
||||
size_t getIndexOfNonEmptyEngineGroup(EngineGroupType engineGroupType) const;
|
||||
size_t getEngineGroupIndexFromEngineGroupType(EngineGroupType engineGroupType) const;
|
||||
EngineControl &getEngine(uint32_t index);
|
||||
EngineControl &getDefaultEngine();
|
||||
EngineControl &getNextEngineForCommandQueue();
|
||||
@ -83,7 +86,7 @@ class Device : public ReferenceTrackedObject<Device> {
|
||||
MOCKABLE_VIRTUAL bool isDebuggerActive() const;
|
||||
Debugger *getDebugger() const { return getRootDeviceEnvironment().debugger.get(); }
|
||||
NEO::SourceLevelDebugger *getSourceLevelDebugger();
|
||||
const std::vector<EngineControl> &getEngines() const;
|
||||
const EnginesT &getEngines() const;
|
||||
const std::string getDeviceName(const HardwareInfo &hwInfo) const;
|
||||
|
||||
ExecutionEnvironment *getExecutionEnvironment() const { return executionEnvironment; }
|
||||
@ -162,7 +165,7 @@ class Device : public ReferenceTrackedObject<Device> {
|
||||
|
||||
std::unique_ptr<PerformanceCounters> performanceCounters;
|
||||
std::vector<std::unique_ptr<CommandStreamReceiver>> commandStreamReceivers;
|
||||
std::vector<EngineControl> engines;
|
||||
EnginesT engines;
|
||||
EngineGroupsT engineGroups;
|
||||
std::vector<SubDevice *> subdevices;
|
||||
|
||||
|
Reference in New Issue
Block a user