Remove "Update Device::engineGroups"

Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
Lukasz Jobczyk
2021-12-03 09:10:49 +00:00
committed by Compute-Runtime-Automation
parent 9481d8a88b
commit c455c0f9c6
23 changed files with 302 additions and 196 deletions

View File

@@ -297,11 +297,8 @@ void Device::addEngineToEngineGroup(EngineControl &engine) {
return;
}
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);
const uint32_t engineGroupIndex = static_cast<uint32_t>(engineGroupType);
this->engineGroups[engineGroupIndex].push_back(engine);
}
std::unique_ptr<CommandStreamReceiver> Device::createCommandStreamReceiver() const {
@@ -421,14 +418,36 @@ bool Device::areSharedSystemAllocationsAllowed() const {
return sharedSystemAllocationsSupport;
}
size_t Device::getEngineGroupIndexFromEngineGroupType(EngineGroupType engineGroupType) const {
for (size_t i = 0; i < engineGroups.size(); i++) {
if (engineGroups[i].engineGroupType == engineGroupType) {
return i;
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++;
}
}
UNRECOVERABLE_IF(true);
return 0;
return result;
}
EngineControl *Device::tryGetEngine(aub_stream::EngineType engineType, EngineUsage engineUsage) {
@@ -567,11 +586,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->getEngineGroupIndexFromEngineGroupType(engineGroupType);
auto &engineGroup = this->getEngineGroups()[defaultEngineGroupIndex];
const auto defaultEngineGroupIndex = this->getIndexOfNonEmptyEngineGroup(engineGroupType);
const auto &engines = this->getEngineGroups()[defaultEngineGroupIndex];
const auto engineIndex = this->regularCommandQueuesCreatedWithinDeviceCount++ % engineGroup.engines.size();
return engineGroup.engines[engineIndex];
const auto engineIndex = this->regularCommandQueuesCreatedWithinDeviceCount++ % engines.size();
return this->getEngineGroups()[defaultEngineGroupIndex][engineIndex];
}
EngineControl *Device::getInternalCopyEngine() {

View File

@@ -32,12 +32,8 @@ struct SelectorCopyEngine : NonCopyableOrMovableClass {
class Device : public ReferenceTrackedObject<Device> {
public:
using EnginesT = std::vector<EngineControl>;
struct EngineGroupT {
EngineGroupType engineGroupType;
EnginesT engines;
};
using EngineGroupsT = std::vector<EngineGroupT>;
using EngineGroupT = std::vector<EngineControl>;
using EngineGroupsT = EngineGroupT[CommonConstants::engineGroupCount];
Device &operator=(const Device &) = delete;
Device(const Device &) = delete;
@@ -65,7 +61,8 @@ class Device : public ReferenceTrackedObject<Device> {
EngineGroupsT &getEngineGroups() {
return this->engineGroups;
}
size_t getEngineGroupIndexFromEngineGroupType(EngineGroupType engineGroupType) const;
const std::vector<EngineControl> *getNonEmptyEngineGroup(size_t index) const;
size_t getIndexOfNonEmptyEngineGroup(EngineGroupType engineGroupType) const;
EngineControl &getEngine(uint32_t index);
EngineControl &getDefaultEngine();
EngineControl &getNextEngineForCommandQueue();
@@ -86,7 +83,7 @@ class Device : public ReferenceTrackedObject<Device> {
MOCKABLE_VIRTUAL bool isDebuggerActive() const;
Debugger *getDebugger() const { return getRootDeviceEnvironment().debugger.get(); }
NEO::SourceLevelDebugger *getSourceLevelDebugger();
const EnginesT &getEngines() const;
const std::vector<EngineControl> &getEngines() const;
const std::string getDeviceName(const HardwareInfo &hwInfo) const;
ExecutionEnvironment *getExecutionEnvironment() const { return executionEnvironment; }
@@ -165,7 +162,7 @@ class Device : public ReferenceTrackedObject<Device> {
std::unique_ptr<PerformanceCounters> performanceCounters;
std::vector<std::unique_ptr<CommandStreamReceiver>> commandStreamReceivers;
EnginesT engines;
std::vector<EngineControl> engines;
EngineGroupsT engineGroups;
std::vector<SubDevice *> subdevices;