mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 22:12:59 +08:00
refactor: allow using different engine types for secondary contexts
Related-To: NEO-7824 Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
b39e99a17a
commit
0a74d718f2
@@ -313,32 +313,31 @@ bool Device::createEngines() {
|
||||
}
|
||||
|
||||
if (gfxCoreHelper.areSecondaryContextsSupported()) {
|
||||
auto engineGroupType = EngineGroupType::compute;
|
||||
|
||||
auto &hardwareInfo = this->getHardwareInfo();
|
||||
auto engineType = aub_stream::EngineType::ENGINE_CCS;
|
||||
auto engineGroup = tryGetRegularEngineGroup(engineGroupType);
|
||||
|
||||
if (tryGetEngine(engineType, EngineUsage::regular)) {
|
||||
if (engineGroup) {
|
||||
auto contextCount = gfxCoreHelper.getContextGroupContextsCount();
|
||||
auto highPriorityContextCount = std::min(contextCount / 2, 4u);
|
||||
|
||||
const EngineGroupType engineGroupType = gfxCoreHelper.getEngineGroupType(engineType, EngineUsage::regular, hardwareInfo);
|
||||
const auto engineGroupIndex = this->getEngineGroupIndexFromEngineGroupType(engineGroupType);
|
||||
auto &engineGroup = this->getRegularEngineGroups()[engineGroupIndex];
|
||||
for (uint32_t engineIndex = 0; engineIndex < static_cast<uint32_t>(engineGroup->engines.size()); engineIndex++) {
|
||||
auto engineType = engineGroup->engines[engineIndex].getEngineType();
|
||||
|
||||
secondaryEngines.resize(engineGroup.engines.size());
|
||||
UNRECOVERABLE_IF(secondaryEngines.find(engineType) != secondaryEngines.end());
|
||||
auto &secondaryEnginesForType = secondaryEngines[engineType];
|
||||
|
||||
for (uint32_t engineIndex = 0; engineIndex < static_cast<uint32_t>(engineGroup.engines.size()); engineIndex++) {
|
||||
auto primaryEngine = engineGroup.engines[engineIndex];
|
||||
auto primaryEngine = engineGroup->engines[engineIndex];
|
||||
|
||||
secondaryEngines[engineIndex].regularEnginesTotal = contextCount - highPriorityContextCount;
|
||||
secondaryEngines[engineIndex].highPriorityEnginesTotal = highPriorityContextCount;
|
||||
secondaryEngines[engineIndex].regularCounter = 0;
|
||||
secondaryEngines[engineIndex].highPriorityCounter = 0;
|
||||
secondaryEnginesForType.regularEnginesTotal = contextCount - highPriorityContextCount;
|
||||
secondaryEnginesForType.highPriorityEnginesTotal = highPriorityContextCount;
|
||||
secondaryEnginesForType.regularCounter = 0;
|
||||
secondaryEnginesForType.highPriorityCounter = 0;
|
||||
|
||||
NEO::EngineTypeUsage engineTypeUsage;
|
||||
engineTypeUsage.first = primaryEngine.getEngineType();
|
||||
|
||||
secondaryEngines[engineIndex].engines.push_back(primaryEngine);
|
||||
secondaryEnginesForType.engines.push_back(primaryEngine);
|
||||
|
||||
for (uint32_t i = 1; i < contextCount; i++) {
|
||||
engineTypeUsage.second = EngineUsage::regular;
|
||||
@@ -346,7 +345,7 @@ bool Device::createEngines() {
|
||||
if (i >= contextCount - highPriorityContextCount) {
|
||||
engineTypeUsage.second = EngineUsage::highPriority;
|
||||
}
|
||||
createSecondaryEngine(primaryEngine.commandStreamReceiver, engineIndex, engineTypeUsage);
|
||||
createSecondaryEngine(primaryEngine.commandStreamReceiver, engineTypeUsage);
|
||||
}
|
||||
|
||||
primaryEngine.osContext->setContextGroup(true);
|
||||
@@ -486,7 +485,7 @@ bool Device::createEngine(uint32_t deviceCsrIndex, EngineTypeUsage engineTypeUsa
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Device::createSecondaryEngine(CommandStreamReceiver *primaryCsr, uint32_t index, EngineTypeUsage engineTypeUsage) {
|
||||
bool Device::createSecondaryEngine(CommandStreamReceiver *primaryCsr, EngineTypeUsage engineTypeUsage) {
|
||||
auto engineUsage = engineTypeUsage.second;
|
||||
std::unique_ptr<CommandStreamReceiver> commandStreamReceiver = createCommandStreamReceiver();
|
||||
if (!commandStreamReceiver) {
|
||||
@@ -506,30 +505,32 @@ bool Device::createSecondaryEngine(CommandStreamReceiver *primaryCsr, uint32_t i
|
||||
commandStreamReceiver->setPrimaryCsr(primaryCsr);
|
||||
|
||||
EngineControl engine{commandStreamReceiver.get(), osContext};
|
||||
secondaryEngines[index].engines.push_back(engine);
|
||||
|
||||
secondaryEngines[engineTypeUsage.first].engines.push_back(engine);
|
||||
secondaryCsrs.push_back(std::move(commandStreamReceiver));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
EngineControl *Device::getSecondaryEngineCsr(uint32_t engineIndex, EngineTypeUsage engineTypeUsage) {
|
||||
|
||||
if (secondaryEngines.size() == 0 || !EngineHelpers::isCcs(engineTypeUsage.first) || engineIndex >= secondaryEngines.size()) {
|
||||
EngineControl *Device::getSecondaryEngineCsr(EngineTypeUsage engineTypeUsage) {
|
||||
if (secondaryEngines.find(engineTypeUsage.first) == secondaryEngines.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto &secondaryEnginesForType = secondaryEngines[engineTypeUsage.first];
|
||||
|
||||
auto secondaryEngineIndex = 0;
|
||||
if (engineTypeUsage.second == EngineUsage::highPriority) {
|
||||
secondaryEngineIndex = (secondaryEngines[engineIndex].highPriorityCounter.fetch_add(1)) % (secondaryEngines[engineIndex].highPriorityEnginesTotal);
|
||||
secondaryEngineIndex += secondaryEngines[engineIndex].regularEnginesTotal;
|
||||
secondaryEngineIndex = (secondaryEnginesForType.highPriorityCounter.fetch_add(1)) % (secondaryEnginesForType.highPriorityEnginesTotal);
|
||||
secondaryEngineIndex += secondaryEnginesForType.regularEnginesTotal;
|
||||
} else if (engineTypeUsage.second == EngineUsage::regular) {
|
||||
secondaryEngineIndex = (secondaryEngines[engineIndex].regularCounter.fetch_add(1)) % (secondaryEngines[engineIndex].regularEnginesTotal);
|
||||
secondaryEngineIndex = (secondaryEnginesForType.regularCounter.fetch_add(1)) % (secondaryEnginesForType.regularEnginesTotal);
|
||||
} else {
|
||||
DEBUG_BREAK_IF(true);
|
||||
}
|
||||
|
||||
if (secondaryEngineIndex > 0) {
|
||||
auto commandStreamReceiver = secondaryEngines[engineIndex].engines[secondaryEngineIndex].commandStreamReceiver;
|
||||
auto commandStreamReceiver = secondaryEnginesForType.engines[secondaryEngineIndex].commandStreamReceiver;
|
||||
|
||||
auto lock = commandStreamReceiver->obtainUniqueOwnership();
|
||||
|
||||
@@ -554,7 +555,7 @@ EngineControl *Device::getSecondaryEngineCsr(uint32_t engineIndex, EngineTypeUsa
|
||||
}
|
||||
}
|
||||
}
|
||||
return &secondaryEngines[engineIndex].engines[secondaryEngineIndex];
|
||||
return &secondaryEnginesForType.engines[secondaryEngineIndex];
|
||||
}
|
||||
|
||||
const HardwareInfo &Device::getHardwareInfo() const { return *getRootDeviceEnvironment().getHardwareInfo(); }
|
||||
@@ -1145,4 +1146,13 @@ bool Device::isMultiRegularContextSelectionAllowed(aub_stream::EngineType engine
|
||||
|
||||
return EngineHelpers::isCcs(engineType);
|
||||
}
|
||||
|
||||
const EngineGroupT *Device::tryGetRegularEngineGroup(EngineGroupType engineGroupType) const {
|
||||
for (auto &engineGroup : regularEngineGroups) {
|
||||
if (engineGroup.engineGroupType == engineGroupType) {
|
||||
return &engineGroup;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
} // namespace NEO
|
||||
|
||||
@@ -102,6 +102,7 @@ class Device : public ReferenceTrackedObject<Device> {
|
||||
EngineGroupsT &getRegularEngineGroups() {
|
||||
return this->regularEngineGroups;
|
||||
}
|
||||
const EngineGroupT *tryGetRegularEngineGroup(EngineGroupType engineGroupType) const;
|
||||
size_t getEngineGroupIndexFromEngineGroupType(EngineGroupType engineGroupType) const;
|
||||
EngineControl &getEngine(uint32_t index);
|
||||
EngineControl &getDefaultEngine();
|
||||
@@ -192,7 +193,7 @@ class Device : public ReferenceTrackedObject<Device> {
|
||||
return getPreemptionMode() == PreemptionMode::MidThread || getDebugger() != nullptr;
|
||||
}
|
||||
|
||||
MOCKABLE_VIRTUAL EngineControl *getSecondaryEngineCsr(uint32_t engineIndex, EngineTypeUsage engineTypeUsage);
|
||||
MOCKABLE_VIRTUAL EngineControl *getSecondaryEngineCsr(EngineTypeUsage engineTypeUsage);
|
||||
bool isSecondaryContextEngineType(aub_stream::EngineType type) {
|
||||
return EngineHelpers::isCcs(type);
|
||||
}
|
||||
@@ -219,7 +220,7 @@ class Device : public ReferenceTrackedObject<Device> {
|
||||
|
||||
void addEngineToEngineGroup(EngineControl &engine);
|
||||
MOCKABLE_VIRTUAL bool createEngine(uint32_t deviceCsrIndex, EngineTypeUsage engineTypeUsage);
|
||||
MOCKABLE_VIRTUAL bool createSecondaryEngine(CommandStreamReceiver *primaryCsr, uint32_t index, EngineTypeUsage engineTypeUsage);
|
||||
MOCKABLE_VIRTUAL bool createSecondaryEngine(CommandStreamReceiver *primaryCsr, EngineTypeUsage engineTypeUsage);
|
||||
|
||||
MOCKABLE_VIRTUAL std::unique_ptr<CommandStreamReceiver> createCommandStreamReceiver() const;
|
||||
MOCKABLE_VIRTUAL SubDevice *createSubDevice(uint32_t subDeviceIndex);
|
||||
@@ -241,7 +242,7 @@ class Device : public ReferenceTrackedObject<Device> {
|
||||
std::vector<std::unique_ptr<CommandStreamReceiver>> commandStreamReceivers;
|
||||
EnginesT allEngines;
|
||||
|
||||
std::vector<SecondaryContexts> secondaryEngines;
|
||||
std::unordered_map<aub_stream::EngineType, SecondaryContexts> secondaryEngines;
|
||||
std::vector<std::unique_ptr<CommandStreamReceiver>> secondaryCsrs;
|
||||
|
||||
EngineGroupsT regularEngineGroups;
|
||||
|
||||
@@ -5307,36 +5307,37 @@ HWTEST_F(CommandStreamReceiverContextGroupTest, givenSecondaryCsrWhenGettingInte
|
||||
const auto &gfxCoreHelper = device->getRootDeviceEnvironment().getHelper<GfxCoreHelper>();
|
||||
|
||||
const auto ccsIndex = 0;
|
||||
auto secondaryEnginesCount = device->secondaryEngines[ccsIndex].engines.size();
|
||||
auto &secondaryEngines = device->secondaryEngines[EngineHelpers::mapCcsIndexToEngineType(ccsIndex)];
|
||||
auto secondaryEnginesCount = secondaryEngines.engines.size();
|
||||
ASSERT_EQ(5u, secondaryEnginesCount);
|
||||
|
||||
EXPECT_TRUE(device->secondaryEngines[ccsIndex].engines[0].commandStreamReceiver->isInitialized());
|
||||
EXPECT_TRUE(secondaryEngines.engines[0].commandStreamReceiver->isInitialized());
|
||||
|
||||
auto primaryCsr = device->secondaryEngines[ccsIndex].engines[0].commandStreamReceiver;
|
||||
auto primaryCsr = secondaryEngines.engines[0].commandStreamReceiver;
|
||||
primaryCsr->createGlobalStatelessHeap();
|
||||
|
||||
for (uint32_t secondaryIndex = 1; secondaryIndex < secondaryEnginesCount; secondaryIndex++) {
|
||||
device->getSecondaryEngineCsr(ccsIndex, {EngineHelpers::mapCcsIndexToEngineType(ccsIndex), EngineUsage::regular});
|
||||
device->getSecondaryEngineCsr({EngineHelpers::mapCcsIndexToEngineType(ccsIndex), EngineUsage::regular});
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < device->secondaryEngines[ccsIndex].highPriorityEnginesTotal; i++) {
|
||||
device->getSecondaryEngineCsr(ccsIndex, {EngineHelpers::mapCcsIndexToEngineType(ccsIndex), EngineUsage::highPriority});
|
||||
for (uint32_t i = 0; i < secondaryEngines.highPriorityEnginesTotal; i++) {
|
||||
device->getSecondaryEngineCsr({EngineHelpers::mapCcsIndexToEngineType(ccsIndex), EngineUsage::highPriority});
|
||||
}
|
||||
|
||||
for (uint32_t secondaryIndex = 0; secondaryIndex < secondaryEnginesCount; secondaryIndex++) {
|
||||
|
||||
if (secondaryIndex > 0) {
|
||||
EXPECT_NE(primaryCsr->getTagAllocation(), device->secondaryEngines[ccsIndex].engines[secondaryIndex].commandStreamReceiver->getTagAllocation());
|
||||
EXPECT_NE(primaryCsr->getTagAllocation(), secondaryEngines.engines[secondaryIndex].commandStreamReceiver->getTagAllocation());
|
||||
}
|
||||
|
||||
if (gfxCoreHelper.isFenceAllocationRequired(hwInfo)) {
|
||||
EXPECT_EQ(primaryCsr->getGlobalFenceAllocation(), device->secondaryEngines[ccsIndex].engines[secondaryIndex].commandStreamReceiver->getGlobalFenceAllocation());
|
||||
EXPECT_EQ(primaryCsr->getGlobalFenceAllocation(), secondaryEngines.engines[secondaryIndex].commandStreamReceiver->getGlobalFenceAllocation());
|
||||
}
|
||||
|
||||
EXPECT_EQ(primaryCsr->getPreemptionAllocation(), device->secondaryEngines[ccsIndex].engines[secondaryIndex].commandStreamReceiver->getPreemptionAllocation());
|
||||
EXPECT_EQ(primaryCsr->getGlobalStatelessHeapAllocation(), device->secondaryEngines[ccsIndex].engines[secondaryIndex].commandStreamReceiver->getGlobalStatelessHeapAllocation());
|
||||
EXPECT_EQ(primaryCsr->getGlobalStatelessHeap(), device->secondaryEngines[ccsIndex].engines[secondaryIndex].commandStreamReceiver->getGlobalStatelessHeap());
|
||||
EXPECT_EQ(primaryCsr->getPrimaryScratchSpaceController(), device->secondaryEngines[ccsIndex].engines[secondaryIndex].commandStreamReceiver->getPrimaryScratchSpaceController());
|
||||
EXPECT_EQ(primaryCsr->getPreemptionAllocation(), secondaryEngines.engines[secondaryIndex].commandStreamReceiver->getPreemptionAllocation());
|
||||
EXPECT_EQ(primaryCsr->getGlobalStatelessHeapAllocation(), secondaryEngines.engines[secondaryIndex].commandStreamReceiver->getGlobalStatelessHeapAllocation());
|
||||
EXPECT_EQ(primaryCsr->getGlobalStatelessHeap(), secondaryEngines.engines[secondaryIndex].commandStreamReceiver->getGlobalStatelessHeap());
|
||||
EXPECT_EQ(primaryCsr->getPrimaryScratchSpaceController(), secondaryEngines.engines[secondaryIndex].commandStreamReceiver->getPrimaryScratchSpaceController());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5357,8 +5358,8 @@ HWTEST_F(CommandStreamReceiverContextGroupTest, givenSecondaryCsrsWhenSameResour
|
||||
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo));
|
||||
|
||||
const auto ccsIndex = 0;
|
||||
auto &commandStreamReceiver0 = *device->getSecondaryEngineCsr(ccsIndex, {EngineHelpers::mapCcsIndexToEngineType(ccsIndex), EngineUsage::regular})->commandStreamReceiver;
|
||||
auto &commandStreamReceiver1 = *device->getSecondaryEngineCsr(ccsIndex, {EngineHelpers::mapCcsIndexToEngineType(ccsIndex), EngineUsage::regular})->commandStreamReceiver;
|
||||
auto &commandStreamReceiver0 = *device->getSecondaryEngineCsr({EngineHelpers::mapCcsIndexToEngineType(ccsIndex), EngineUsage::regular})->commandStreamReceiver;
|
||||
auto &commandStreamReceiver1 = *device->getSecondaryEngineCsr({EngineHelpers::mapCcsIndexToEngineType(ccsIndex), EngineUsage::regular})->commandStreamReceiver;
|
||||
|
||||
auto csr0ContextId = commandStreamReceiver0.getOsContext().getContextId();
|
||||
auto csr1ContextId = commandStreamReceiver1.getOsContext().getContextId();
|
||||
|
||||
@@ -1173,51 +1173,53 @@ HWTEST_F(DeviceTests, givenCCSEnginesAndContextGroupSizeEnabledWhenDeviceIsCreat
|
||||
}
|
||||
|
||||
ASSERT_EQ(computeEnginesCount, device->secondaryEngines.size());
|
||||
ASSERT_EQ(contextGroupSize, device->secondaryEngines[0].engines.size());
|
||||
ASSERT_EQ(contextGroupSize, device->secondaryEngines[aub_stream::EngineType::ENGINE_CCS].engines.size());
|
||||
|
||||
auto defaultEngine = device->getDefaultEngine();
|
||||
EXPECT_EQ(defaultEngine.commandStreamReceiver, device->secondaryEngines[0].engines[0].commandStreamReceiver);
|
||||
EXPECT_EQ(defaultEngine.commandStreamReceiver, device->secondaryEngines[aub_stream::EngineType::ENGINE_CCS].engines[0].commandStreamReceiver);
|
||||
|
||||
const uint32_t regularContextCount = std::min(contextGroupSize / 2, 4u);
|
||||
|
||||
for (uint32_t ccsIndex = 0; ccsIndex < computeEnginesCount; ccsIndex++) {
|
||||
EXPECT_TRUE(device->secondaryEngines[ccsIndex].engines[0].osContext->isPartOfContextGroup());
|
||||
EXPECT_EQ(nullptr, device->secondaryEngines[ccsIndex].engines[0].osContext->getPrimaryContext());
|
||||
auto &secondaryEngines = device->secondaryEngines[EngineHelpers::mapCcsIndexToEngineType(ccsIndex)];
|
||||
|
||||
for (size_t i = 1; i < device->secondaryEngines[0].engines.size(); i++) {
|
||||
EXPECT_EQ(device->secondaryEngines[ccsIndex].engines[0].osContext, device->secondaryEngines[ccsIndex].engines[i].osContext->getPrimaryContext());
|
||||
EXPECT_TRUE(device->secondaryEngines[ccsIndex].engines[i].osContext->isPartOfContextGroup());
|
||||
EXPECT_TRUE(secondaryEngines.engines[0].osContext->isPartOfContextGroup());
|
||||
EXPECT_EQ(nullptr, secondaryEngines.engines[0].osContext->getPrimaryContext());
|
||||
|
||||
for (size_t i = 1; i < device->secondaryEngines[aub_stream::EngineType::ENGINE_CCS].engines.size(); i++) {
|
||||
EXPECT_EQ(secondaryEngines.engines[0].osContext, secondaryEngines.engines[i].osContext->getPrimaryContext());
|
||||
EXPECT_TRUE(secondaryEngines.engines[i].osContext->isPartOfContextGroup());
|
||||
}
|
||||
|
||||
EXPECT_EQ(0u, device->secondaryEngines[ccsIndex].regularCounter.load());
|
||||
EXPECT_EQ(0u, device->secondaryEngines[ccsIndex].highPriorityCounter.load());
|
||||
EXPECT_EQ(0u, secondaryEngines.regularCounter.load());
|
||||
EXPECT_EQ(0u, secondaryEngines.highPriorityCounter.load());
|
||||
|
||||
EXPECT_EQ(regularContextCount, device->secondaryEngines[ccsIndex].regularEnginesTotal);
|
||||
EXPECT_EQ(contextGroupSize - regularContextCount, device->secondaryEngines[ccsIndex].highPriorityEnginesTotal);
|
||||
EXPECT_EQ(regularContextCount, secondaryEngines.regularEnginesTotal);
|
||||
EXPECT_EQ(contextGroupSize - regularContextCount, secondaryEngines.highPriorityEnginesTotal);
|
||||
|
||||
for (size_t contextId = 0; contextId < regularContextCount + 1; contextId++) {
|
||||
auto engine = device->getSecondaryEngineCsr(ccsIndex, {EngineHelpers::mapCcsIndexToEngineType(ccsIndex), EngineUsage::regular});
|
||||
auto engine = device->getSecondaryEngineCsr({EngineHelpers::mapCcsIndexToEngineType(ccsIndex), EngineUsage::regular});
|
||||
ASSERT_NE(nullptr, engine);
|
||||
|
||||
EXPECT_EQ(contextId + 1, device->secondaryEngines[ccsIndex].regularCounter.load());
|
||||
EXPECT_EQ(contextId + 1, secondaryEngines.regularCounter.load());
|
||||
if (contextId == regularContextCount) {
|
||||
EXPECT_EQ(&device->secondaryEngines[ccsIndex].engines[0], engine);
|
||||
EXPECT_EQ(&secondaryEngines.engines[0], engine);
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t contextId = 0; contextId < contextGroupSize - regularContextCount + 1; contextId++) {
|
||||
auto engine = device->getSecondaryEngineCsr(ccsIndex, {EngineHelpers::mapCcsIndexToEngineType(ccsIndex), EngineUsage::highPriority});
|
||||
auto engine = device->getSecondaryEngineCsr({EngineHelpers::mapCcsIndexToEngineType(ccsIndex), EngineUsage::highPriority});
|
||||
ASSERT_NE(nullptr, engine);
|
||||
|
||||
EXPECT_EQ(contextId + 1, device->secondaryEngines[ccsIndex].highPriorityCounter.load());
|
||||
EXPECT_EQ(contextId + 1, secondaryEngines.highPriorityCounter.load());
|
||||
if (contextId == contextGroupSize - regularContextCount) {
|
||||
EXPECT_EQ(&device->secondaryEngines[ccsIndex].engines[regularContextCount], engine);
|
||||
EXPECT_EQ(&secondaryEngines.engines[regularContextCount], engine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto internalEngine = device->getInternalEngine();
|
||||
EXPECT_NE(internalEngine.commandStreamReceiver, device->getSecondaryEngineCsr(0, {aub_stream::EngineType::ENGINE_CCS, EngineUsage::internal})->commandStreamReceiver);
|
||||
EXPECT_NE(internalEngine.commandStreamReceiver, device->getSecondaryEngineCsr({aub_stream::EngineType::ENGINE_CCS, EngineUsage::internal})->commandStreamReceiver);
|
||||
}
|
||||
|
||||
HWTEST_F(DeviceTests, givenContextGroupEnabledWhenGettingSecondaryEngineThenResourcesAndContextAreInitialized) {
|
||||
@@ -1239,43 +1241,46 @@ HWTEST_F(DeviceTests, givenContextGroupEnabledWhenGettingSecondaryEngineThenReso
|
||||
const auto &gfxCoreHelper = device->getRootDeviceEnvironment().getHelper<GfxCoreHelper>();
|
||||
|
||||
const auto ccsIndex = 0;
|
||||
auto secondaryEnginesCount = device->secondaryEngines[ccsIndex].engines.size();
|
||||
|
||||
auto &secondaryEngines = device->secondaryEngines[EngineHelpers::mapCcsIndexToEngineType(ccsIndex)];
|
||||
|
||||
auto secondaryEnginesCount = secondaryEngines.engines.size();
|
||||
ASSERT_EQ(5u, secondaryEnginesCount);
|
||||
|
||||
EXPECT_TRUE(device->secondaryEngines[ccsIndex].engines[0].commandStreamReceiver->isInitialized());
|
||||
EXPECT_EQ(1u, device->secondaryEngines[ccsIndex].engines[0].commandStreamReceiver->peekLatestSentTaskCount());
|
||||
EXPECT_TRUE(secondaryEngines.engines[0].commandStreamReceiver->isInitialized());
|
||||
EXPECT_EQ(1u, secondaryEngines.engines[0].commandStreamReceiver->peekLatestSentTaskCount());
|
||||
|
||||
auto primaryCsr = device->secondaryEngines[ccsIndex].engines[0].commandStreamReceiver;
|
||||
auto primaryCsr = secondaryEngines.engines[0].commandStreamReceiver;
|
||||
for (uint32_t secondaryIndex = 1; secondaryIndex < secondaryEnginesCount; secondaryIndex++) {
|
||||
|
||||
EXPECT_FALSE(device->secondaryEngines[ccsIndex].engines[secondaryIndex].osContext->isInitialized());
|
||||
EXPECT_FALSE(device->secondaryEngines[ccsIndex].engines[secondaryIndex].commandStreamReceiver->isInitialized());
|
||||
EXPECT_FALSE(secondaryEngines.engines[secondaryIndex].osContext->isInitialized());
|
||||
EXPECT_FALSE(secondaryEngines.engines[secondaryIndex].commandStreamReceiver->isInitialized());
|
||||
|
||||
EXPECT_EQ(nullptr, device->secondaryEngines[ccsIndex].engines[secondaryIndex].commandStreamReceiver->getTagAllocation());
|
||||
EXPECT_EQ(primaryCsr->getGlobalFenceAllocation(), device->secondaryEngines[ccsIndex].engines[secondaryIndex].commandStreamReceiver->getGlobalFenceAllocation());
|
||||
EXPECT_EQ(nullptr, secondaryEngines.engines[secondaryIndex].commandStreamReceiver->getTagAllocation());
|
||||
EXPECT_EQ(primaryCsr->getGlobalFenceAllocation(), secondaryEngines.engines[secondaryIndex].commandStreamReceiver->getGlobalFenceAllocation());
|
||||
if (device->getPreemptionMode() == PreemptionMode::MidThread) {
|
||||
EXPECT_EQ(primaryCsr->getPreemptionAllocation(), device->secondaryEngines[ccsIndex].engines[secondaryIndex].commandStreamReceiver->getPreemptionAllocation());
|
||||
EXPECT_EQ(primaryCsr->getPreemptionAllocation(), secondaryEngines.engines[secondaryIndex].commandStreamReceiver->getPreemptionAllocation());
|
||||
}
|
||||
|
||||
device->getSecondaryEngineCsr(ccsIndex, {EngineHelpers::mapCcsIndexToEngineType(ccsIndex), EngineUsage::regular});
|
||||
device->getSecondaryEngineCsr({EngineHelpers::mapCcsIndexToEngineType(ccsIndex), EngineUsage::regular});
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < device->secondaryEngines[ccsIndex].highPriorityEnginesTotal; i++) {
|
||||
device->getSecondaryEngineCsr(ccsIndex, {EngineHelpers::mapCcsIndexToEngineType(ccsIndex), EngineUsage::highPriority});
|
||||
for (uint32_t i = 0; i < secondaryEngines.highPriorityEnginesTotal; i++) {
|
||||
device->getSecondaryEngineCsr({EngineHelpers::mapCcsIndexToEngineType(ccsIndex), EngineUsage::highPriority});
|
||||
}
|
||||
|
||||
for (uint32_t secondaryIndex = 0; secondaryIndex < secondaryEnginesCount; secondaryIndex++) {
|
||||
|
||||
EXPECT_TRUE(device->secondaryEngines[ccsIndex].engines[secondaryIndex].osContext->isInitialized());
|
||||
EXPECT_TRUE(device->secondaryEngines[ccsIndex].engines[secondaryIndex].commandStreamReceiver->isInitialized());
|
||||
EXPECT_TRUE(secondaryEngines.engines[secondaryIndex].osContext->isInitialized());
|
||||
EXPECT_TRUE(secondaryEngines.engines[secondaryIndex].commandStreamReceiver->isInitialized());
|
||||
|
||||
EXPECT_NE(nullptr, device->secondaryEngines[ccsIndex].engines[secondaryIndex].commandStreamReceiver->getTagAllocation());
|
||||
EXPECT_NE(nullptr, secondaryEngines.engines[secondaryIndex].commandStreamReceiver->getTagAllocation());
|
||||
|
||||
if (gfxCoreHelper.isFenceAllocationRequired(hwInfo)) {
|
||||
EXPECT_NE(nullptr, device->secondaryEngines[ccsIndex].engines[secondaryIndex].commandStreamReceiver->getGlobalFenceAllocation());
|
||||
EXPECT_NE(nullptr, secondaryEngines.engines[secondaryIndex].commandStreamReceiver->getGlobalFenceAllocation());
|
||||
}
|
||||
if (device->getPreemptionMode() == PreemptionMode::MidThread) {
|
||||
EXPECT_NE(nullptr, device->secondaryEngines[ccsIndex].engines[secondaryIndex].commandStreamReceiver->getPreemptionAllocation());
|
||||
EXPECT_NE(nullptr, secondaryEngines.engines[secondaryIndex].commandStreamReceiver->getPreemptionAllocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1300,7 +1305,8 @@ HWTEST_F(DeviceTests, givenContextGroupEnabledWhenDeviceIsDestroyedThenSecondary
|
||||
auto memoryManager = static_cast<MockMemoryManager *>(executionEnvironment->memoryManager.get());
|
||||
|
||||
const auto ccsIndex = 0;
|
||||
auto secondaryEnginesCount = device->secondaryEngines[ccsIndex].engines.size();
|
||||
auto &secondaryEngines = device->secondaryEngines[EngineHelpers::mapCcsIndexToEngineType(ccsIndex)];
|
||||
auto secondaryEnginesCount = secondaryEngines.engines.size();
|
||||
ASSERT_EQ(5u, secondaryEnginesCount);
|
||||
ASSERT_LE(1u, memoryManager->secondaryEngines.size());
|
||||
EXPECT_EQ(secondaryEnginesCount - 1, memoryManager->secondaryEngines[0].size());
|
||||
@@ -1330,14 +1336,15 @@ HWTEST_F(DeviceTests, givenContextGroupEnabledAndAllocationUsedBySeconadryContex
|
||||
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithExecutionEnvironment<MockDevice>(&hwInfo, executionEnvironment, 0));
|
||||
auto memoryManager = static_cast<MockMemoryManager *>(executionEnvironment->memoryManager.get());
|
||||
|
||||
const auto ccsIndex = 0;
|
||||
auto secondaryEnginesCount = device->secondaryEngines[ccsIndex].engines.size();
|
||||
EXPECT_NE(device->secondaryEngines.end(), device->secondaryEngines.find(aub_stream::ENGINE_CCS));
|
||||
auto &secondaryEngines = device->secondaryEngines[aub_stream::ENGINE_CCS];
|
||||
auto secondaryEnginesCount = secondaryEngines.engines.size();
|
||||
ASSERT_EQ(5u, secondaryEnginesCount);
|
||||
|
||||
auto engine = device->getSecondaryEngineCsr(ccsIndex, {aub_stream::ENGINE_CCS, EngineUsage::regular});
|
||||
auto engine = device->getSecondaryEngineCsr({aub_stream::ENGINE_CCS, EngineUsage::regular});
|
||||
ASSERT_NE(nullptr, engine);
|
||||
auto csr = engine->commandStreamReceiver;
|
||||
auto engine2 = device->getSecondaryEngineCsr(ccsIndex, {aub_stream::ENGINE_CCS, EngineUsage::regular});
|
||||
auto engine2 = device->getSecondaryEngineCsr({aub_stream::ENGINE_CCS, EngineUsage::regular});
|
||||
ASSERT_NE(nullptr, engine2);
|
||||
auto csr2 = engine2->commandStreamReceiver;
|
||||
ASSERT_NE(csr, csr2);
|
||||
|
||||
Reference in New Issue
Block a user