mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-10 12:53:42 +08:00
Adjust ccs on reinit
Parse and adjust ccs count on reset so that initial environment is restored. Related-To: LOCI-3435 Signed-off-by: Bellekallu Rajkiran <bellekallu.rajkiran@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
a95ab1d16b
commit
7f8e9378b6
@ -199,6 +199,7 @@ static_assert(sizeof(ExecutionEnvironment) == sizeof(std::unique_ptr<HardwareInf
|
||||
sizeof(std::vector<RootDeviceEnvironment>) +
|
||||
sizeof(std::unique_ptr<OsEnvironment>) +
|
||||
sizeof(std::unique_ptr<DirectSubmissionController>) +
|
||||
sizeof(std::unordered_map<uint32_t, uint32_t>) +
|
||||
sizeof(bool) +
|
||||
(is64bit ? 23 : 15),
|
||||
"New members detected in ExecutionEnvironment, please ensure that destruction sequence of objects is correct");
|
||||
|
@ -200,20 +200,35 @@ void ExecutionEnvironment::parseAffinityMask() {
|
||||
rootDeviceEnvironments.swap(filteredEnvironments);
|
||||
}
|
||||
|
||||
void ExecutionEnvironment::adjustCcsCount() const {
|
||||
void ExecutionEnvironment::adjustCcsCountImpl(RootDeviceEnvironment *rootDeviceEnvironment) const {
|
||||
auto hwInfo = rootDeviceEnvironment->getMutableHardwareInfo();
|
||||
auto hwInfoConfig = HwInfoConfig::get(hwInfo->platform.eProductFamily);
|
||||
hwInfoConfig->adjustNumberOfCcs(*hwInfo);
|
||||
}
|
||||
|
||||
void ExecutionEnvironment::adjustCcsCount() {
|
||||
parseCcsCountLimitations();
|
||||
|
||||
for (auto &rootDeviceEnvironment : rootDeviceEnvironments) {
|
||||
for (auto rootDeviceIndex = 0u; rootDeviceIndex < rootDeviceEnvironments.size(); rootDeviceIndex++) {
|
||||
auto &rootDeviceEnvironment = rootDeviceEnvironments[rootDeviceIndex];
|
||||
UNRECOVERABLE_IF(!rootDeviceEnvironment);
|
||||
if (!rootDeviceEnvironment->isNumberOfCcsLimited()) {
|
||||
auto hwInfo = rootDeviceEnvironment->getMutableHardwareInfo();
|
||||
auto hwInfoConfig = HwInfoConfig::get(hwInfo->platform.eProductFamily);
|
||||
hwInfoConfig->adjustNumberOfCcs(*hwInfo);
|
||||
adjustCcsCountImpl(rootDeviceEnvironment.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ExecutionEnvironment::parseCcsCountLimitations() const {
|
||||
void ExecutionEnvironment::adjustCcsCount(const uint32_t rootDeviceIndex) const {
|
||||
auto &rootDeviceEnvironment = rootDeviceEnvironments[rootDeviceIndex];
|
||||
UNRECOVERABLE_IF(!rootDeviceEnvironment);
|
||||
if (rootDeviceNumCcsMap.find(rootDeviceIndex) != rootDeviceNumCcsMap.end()) {
|
||||
rootDeviceEnvironment->limitNumberOfCcs(rootDeviceNumCcsMap.at(rootDeviceIndex));
|
||||
} else {
|
||||
adjustCcsCountImpl(rootDeviceEnvironment.get());
|
||||
}
|
||||
}
|
||||
|
||||
void ExecutionEnvironment::parseCcsCountLimitations() {
|
||||
const auto &numberOfCcsString = DebugManager.flags.ZEX_NUMBER_OF_CCS.get();
|
||||
|
||||
if (numberOfCcsString.compare("default") == 0 ||
|
||||
@ -232,6 +247,7 @@ void ExecutionEnvironment::parseCcsCountLimitations() const {
|
||||
if (rootDeviceIndex < numRootDevices) {
|
||||
if (subEntries.size() > 1) {
|
||||
uint32_t maxCcsCount = StringHelpers::toUint32t(subEntries[1]);
|
||||
rootDeviceNumCcsMap.insert({rootDeviceIndex, maxCcsCount});
|
||||
rootDeviceEnvironments[rootDeviceIndex]->limitNumberOfCcs(maxCcsCount);
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#pragma once
|
||||
#include "shared/source/utilities/reference_tracked_object.h"
|
||||
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace NEO {
|
||||
@ -27,7 +28,8 @@ class ExecutionEnvironment : public ReferenceTrackedObject<ExecutionEnvironment>
|
||||
virtual void prepareRootDeviceEnvironments(uint32_t numRootDevices);
|
||||
void prepareRootDeviceEnvironment(const uint32_t rootDeviceIndexForReInit);
|
||||
void parseAffinityMask();
|
||||
void adjustCcsCount() const;
|
||||
void adjustCcsCount();
|
||||
void adjustCcsCount(const uint32_t rootDeviceIndex) const;
|
||||
void sortNeoDevices();
|
||||
void sortNeoDevicesDRM();
|
||||
void sortNeoDevicesWDDM();
|
||||
@ -45,7 +47,9 @@ class ExecutionEnvironment : public ReferenceTrackedObject<ExecutionEnvironment>
|
||||
void releaseRootDeviceEnvironmentResources(RootDeviceEnvironment *rootDeviceEnvironment);
|
||||
|
||||
protected:
|
||||
void parseCcsCountLimitations() const;
|
||||
void parseCcsCountLimitations();
|
||||
void adjustCcsCountImpl(RootDeviceEnvironment *rootDeviceEnvironment) const;
|
||||
bool debuggingEnabled = false;
|
||||
std::unordered_map<uint32_t, uint32_t> rootDeviceNumCcsMap;
|
||||
};
|
||||
} // namespace NEO
|
||||
|
@ -176,7 +176,12 @@ bool DeviceFactory::prepareDeviceEnvironment(ExecutionEnvironment &executionEnvi
|
||||
|
||||
// HwDeviceIds should contain only one entry corresponding to osPciPath
|
||||
UNRECOVERABLE_IF(hwDeviceIds.size() > 1);
|
||||
return initHwDeviceIdResources(executionEnvironment, std::move(hwDeviceIds[0]), rootDeviceIndex);
|
||||
if (!initHwDeviceIdResources(executionEnvironment, std::move(hwDeviceIds[0]), rootDeviceIndex)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
executionEnvironment.adjustCcsCount(rootDeviceIndex);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::unique_ptr<Device> DeviceFactory::createDevice(ExecutionEnvironment &executionEnvironment, std::string &osPciPath, const uint32_t rootDeviceIndex) {
|
||||
|
@ -430,7 +430,6 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, DeviceTests, givenZexNumberOfCssEnvVariableDefinedW
|
||||
|
||||
MockExecutionEnvironment executionEnvironment(&hwInfo, false, 4);
|
||||
executionEnvironment.incRefInternal();
|
||||
|
||||
UltDeviceFactory deviceFactory{4, 0, executionEnvironment};
|
||||
|
||||
{
|
||||
@ -465,6 +464,67 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, DeviceTests, givenZexNumberOfCssEnvVariableDefinedW
|
||||
}
|
||||
}
|
||||
|
||||
HWCMDTEST_F(IGFX_XE_HP_CORE, DeviceTests, givenDeviceIsCreatedWithZexNumberOfCssEnvVariableDefinedAndHwInfoCcsCountIsSetToDefaultWhenAdjustCcsCountForSpecificRootDeviceIsInvokedThenVerifyHwInfoCcsCountIsRestored) {
|
||||
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
||||
ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false;
|
||||
DebugManagerStateRestore restorer;
|
||||
|
||||
DebugManager.flags.ZEX_NUMBER_OF_CCS.set("0:1,1:2");
|
||||
DebugManager.flags.SetCommandStreamReceiver.set(1);
|
||||
|
||||
auto hwInfo = *defaultHwInfo;
|
||||
|
||||
MockExecutionEnvironment executionEnvironment(&hwInfo, false, 2);
|
||||
executionEnvironment.incRefInternal();
|
||||
|
||||
UltDeviceFactory deviceFactory{1, 0, executionEnvironment};
|
||||
{
|
||||
auto hardwareInfo = executionEnvironment.rootDeviceEnvironments[0]->getMutableHardwareInfo();
|
||||
hardwareInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled = defaultHwInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled;
|
||||
|
||||
executionEnvironment.adjustCcsCount(0);
|
||||
EXPECT_EQ(1u, hardwareInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled);
|
||||
}
|
||||
|
||||
{
|
||||
auto hardwareInfo = executionEnvironment.rootDeviceEnvironments[1]->getMutableHardwareInfo();
|
||||
hardwareInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled = defaultHwInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled;
|
||||
|
||||
executionEnvironment.adjustCcsCount(1);
|
||||
EXPECT_EQ(std::min(2u, defaultHwInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled), hardwareInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST2_F(DeviceTests, givenDeviceIsCreatedWithAmbiguousZexNumberOfCssEnvVariableAndHwInfoCcsCountIsModifiedWhenAdjustCcsCountForSpecificDeviceIsInvokedThenVerifyCcsCountIsAdjustedToOne, IsPVC) {
|
||||
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
||||
ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false;
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.SetCommandStreamReceiver.set(1);
|
||||
|
||||
for (const auto &numberOfCcsString : {"default", "", "0"}) {
|
||||
DebugManager.flags.ZEX_NUMBER_OF_CCS.set(numberOfCcsString);
|
||||
|
||||
auto hwInfo = *defaultHwInfo;
|
||||
|
||||
MockExecutionEnvironment executionEnvironment(&hwInfo);
|
||||
executionEnvironment.incRefInternal();
|
||||
|
||||
UltDeviceFactory deviceFactory{1, 0, executionEnvironment};
|
||||
|
||||
auto device = deviceFactory.rootDevices[0];
|
||||
|
||||
auto computeEngineGroupIndex = device->getEngineGroupIndexFromEngineGroupType(EngineGroupType::Compute);
|
||||
auto computeEngineGroup = device->getRegularEngineGroups()[computeEngineGroupIndex];
|
||||
EXPECT_EQ(1u, computeEngineGroup.engines.size());
|
||||
|
||||
auto hardwareInfo = executionEnvironment.rootDeviceEnvironments[0]->getMutableHardwareInfo();
|
||||
hardwareInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled = defaultHwInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled;
|
||||
|
||||
executionEnvironment.adjustCcsCount(0);
|
||||
EXPECT_EQ(1u, hardwareInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
HWCMDTEST_F(IGFX_XE_HP_CORE, DeviceTests, givenZexNumberOfCssAndZeAffinityMaskSetWhenDeviceIsCreatedThenProperNumberOfCcsIsExposed) {
|
||||
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
||||
ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false;
|
||||
|
Reference in New Issue
Block a user