mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Add getting gpu frequency for multitile devices
Signed-off-by: Szymon Morek <szymon.morek@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
55723d0b18
commit
d47751d3a7
@ -739,4 +739,122 @@ TEST(DrmQueryTest, givenDrmWhenGettingTopologyMapThenCorrectMapIsReturned) {
|
||||
for (uint32_t i = 0; i < topologyMap.size(); i++) {
|
||||
EXPECT_EQ(drmMock.storedSVal, static_cast<int>(topologyMap.at(i).sliceIndices.size()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(DrmQueryTest, GivenNonTileArchitectureWhenFrequencyIsQueriedThenFallbackToLegacyInterface) {
|
||||
int expectedMaxFrequency = 2000;
|
||||
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
auto hwInfo = *defaultHwInfo;
|
||||
hwInfo.gtSystemInfo.MultiTileArchInfo.TileCount = 0;
|
||||
hwInfo.gtSystemInfo.MultiTileArchInfo.IsValid = true;
|
||||
|
||||
std::string gtMaxFreqFile = "test_files/linux/devices/device/drm/card1/gt_max_freq_mhz";
|
||||
EXPECT_TRUE(fileExists(gtMaxFreqFile));
|
||||
|
||||
drm.setPciPath("device");
|
||||
|
||||
int maxFrequency = 0;
|
||||
int ret = drm.getMaxGpuFrequency(hwInfo, maxFrequency);
|
||||
EXPECT_EQ(0, ret);
|
||||
|
||||
EXPECT_EQ(expectedMaxFrequency, maxFrequency);
|
||||
}
|
||||
|
||||
TEST(DrmQueryTest, GivenTileArchitectureIsInvalidWhenFrequencyIsQueriedThenFallbackToLegacyInterface) {
|
||||
int expectedMaxFrequency = 2000;
|
||||
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
auto hwInfo = *defaultHwInfo;
|
||||
hwInfo.gtSystemInfo.MultiTileArchInfo.TileCount = 2;
|
||||
hwInfo.gtSystemInfo.MultiTileArchInfo.IsValid = false;
|
||||
|
||||
std::string gtMaxFreqFile = "test_files/linux/devices/device/drm/card1/gt_max_freq_mhz";
|
||||
EXPECT_TRUE(fileExists(gtMaxFreqFile));
|
||||
|
||||
drm.setPciPath("device");
|
||||
|
||||
int maxFrequency = 0;
|
||||
int ret = drm.getMaxGpuFrequency(hwInfo, maxFrequency);
|
||||
EXPECT_EQ(0, ret);
|
||||
|
||||
EXPECT_EQ(expectedMaxFrequency, maxFrequency);
|
||||
}
|
||||
|
||||
TEST(DrmQueryTest, GivenRpsMaxFreqFileExistsWhenFrequencyIsQueriedThenValidValueIsReturned) {
|
||||
int expectedMaxFrequency = 3000;
|
||||
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
auto hwInfo = *defaultHwInfo;
|
||||
hwInfo.gtSystemInfo.MultiTileArchInfo.TileCount = 1;
|
||||
hwInfo.gtSystemInfo.MultiTileArchInfo.IsValid = true;
|
||||
|
||||
std::string rpsMaxFreqFile = "test_files/linux/devices/device/drm/card1/gt/gt0/rps_max_freq_mhz";
|
||||
EXPECT_TRUE(fileExists(rpsMaxFreqFile));
|
||||
|
||||
drm.setPciPath("device");
|
||||
|
||||
int maxFrequency = 0;
|
||||
int ret = drm.getMaxGpuFrequency(hwInfo, maxFrequency);
|
||||
EXPECT_EQ(0, ret);
|
||||
|
||||
EXPECT_EQ(expectedMaxFrequency, maxFrequency);
|
||||
}
|
||||
|
||||
TEST(DrmQueryTest, GivenRpsMaxFreqFilesExistWhenFrequenciesAreQueriedThenValidValueIsReturned) {
|
||||
int expectedMaxFrequency = 4000;
|
||||
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
auto hwInfo = *defaultHwInfo;
|
||||
hwInfo.gtSystemInfo.MultiTileArchInfo.TileCount = 2;
|
||||
hwInfo.gtSystemInfo.MultiTileArchInfo.IsValid = true;
|
||||
|
||||
std::string rpsMaxFreqFile = "test_files/linux/devices/device/drm/card1/gt/gt1/rps_max_freq_mhz";
|
||||
EXPECT_TRUE(fileExists(rpsMaxFreqFile));
|
||||
|
||||
drm.setPciPath("device");
|
||||
|
||||
int maxFrequency = 0;
|
||||
int ret = drm.getMaxGpuFrequency(hwInfo, maxFrequency);
|
||||
EXPECT_EQ(0, ret);
|
||||
|
||||
EXPECT_EQ(expectedMaxFrequency, maxFrequency);
|
||||
}
|
||||
|
||||
TEST(DrmQueryTest, GivenRpsMaxFreqFileDoesntExistWhenFrequencyIsQueriedThenFallbackToLegacyInterface) {
|
||||
int expectedMaxFrequency = 2000;
|
||||
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
auto hwInfo = *defaultHwInfo;
|
||||
hwInfo.gtSystemInfo.MultiTileArchInfo.TileCount = 3;
|
||||
hwInfo.gtSystemInfo.MultiTileArchInfo.IsValid = true;
|
||||
|
||||
std::string rpsMaxFreqFile = "test_files/linux/devices/device/drm/card1/gt/gt2/rps_max_freq_mhz";
|
||||
EXPECT_FALSE(fileExists(rpsMaxFreqFile));
|
||||
|
||||
std::string gtMaxFreqFile = "test_files/linux/devices/device/drm/card1/gt_max_freq_mhz";
|
||||
EXPECT_TRUE(fileExists(gtMaxFreqFile));
|
||||
|
||||
drm.setPciPath("device");
|
||||
|
||||
int maxFrequency = 0;
|
||||
int ret = drm.getMaxGpuFrequency(hwInfo, maxFrequency);
|
||||
EXPECT_EQ(0, ret);
|
||||
|
||||
EXPECT_EQ(expectedMaxFrequency, maxFrequency);
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
3000
|
@ -0,0 +1 @@
|
||||
4000
|
@ -1 +1 @@
|
||||
1000
|
||||
2000
|
@ -788,4 +788,50 @@ bool Drm::sysmanQueryEngineInfo() {
|
||||
return Drm::queryEngineInfo(true);
|
||||
}
|
||||
|
||||
int getMaxGpuFrequencyOfDevice(Drm &drm, std::string &sysFsPciPath, int &maxGpuFrequency) {
|
||||
maxGpuFrequency = 0;
|
||||
std::string clockSysFsPath = sysFsPciPath + "/gt_max_freq_mhz";
|
||||
|
||||
std::ifstream ifs(clockSysFsPath.c_str(), std::ifstream::in);
|
||||
if (ifs.fail()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ifs >> maxGpuFrequency;
|
||||
ifs.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int getMaxGpuFrequencyOfSubDevice(Drm &drm, std::string &sysFsPciPath, int subDeviceId, int &maxGpuFrequency) {
|
||||
maxGpuFrequency = 0;
|
||||
std::string clockSysFsPath = sysFsPciPath + "/gt/gt" + std::to_string(subDeviceId) + "/rps_max_freq_mhz";
|
||||
|
||||
std::ifstream ifs(clockSysFsPath.c_str(), std::ifstream::in);
|
||||
if (ifs.fail()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ifs >> maxGpuFrequency;
|
||||
ifs.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Drm::getMaxGpuFrequency(HardwareInfo &hwInfo, int &maxGpuFrequency) {
|
||||
int ret = 0;
|
||||
std::string sysFsPciPath = getSysFsPciPath();
|
||||
auto tileCount = hwInfo.gtSystemInfo.MultiTileArchInfo.TileCount;
|
||||
|
||||
if (hwInfo.gtSystemInfo.MultiTileArchInfo.IsValid && tileCount > 0) {
|
||||
for (auto tileId = 0; tileId < tileCount; tileId++) {
|
||||
int maxGpuFreqOfSubDevice = 0;
|
||||
ret |= getMaxGpuFrequencyOfSubDevice(*this, sysFsPciPath, tileId, maxGpuFreqOfSubDevice);
|
||||
maxGpuFrequency = std::max(maxGpuFrequency, maxGpuFreqOfSubDevice);
|
||||
}
|
||||
if (ret == 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return getMaxGpuFrequencyOfDevice(*this, sysFsPciPath, maxGpuFrequency);
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
@ -33,22 +33,6 @@ std::string getIoctlParamStringRemaining(int param) {
|
||||
}
|
||||
} // namespace IoctlHelper
|
||||
|
||||
int Drm::getMaxGpuFrequency(HardwareInfo &hwInfo, int &maxGpuFrequency) {
|
||||
maxGpuFrequency = 0;
|
||||
std::string clockSysFsPath = getSysFsPciPath();
|
||||
|
||||
clockSysFsPath += "/gt_max_freq_mhz";
|
||||
|
||||
std::ifstream ifs(clockSysFsPath.c_str(), std::ifstream::in);
|
||||
if (ifs.fail()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ifs >> maxGpuFrequency;
|
||||
ifs.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Drm::querySystemInfo() {
|
||||
return false;
|
||||
}
|
||||
|
@ -35,22 +35,6 @@ std::string getIoctlParamStringRemaining(int param) {
|
||||
}
|
||||
} // namespace IoctlHelper
|
||||
|
||||
int Drm::getMaxGpuFrequency(HardwareInfo &hwInfo, int &maxGpuFrequency) {
|
||||
maxGpuFrequency = 0;
|
||||
std::string clockSysFsPath = getSysFsPciPath();
|
||||
|
||||
clockSysFsPath += "/gt_max_freq_mhz";
|
||||
|
||||
std::ifstream ifs(clockSysFsPath.c_str(), std::ifstream::in);
|
||||
if (ifs.fail()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ifs >> maxGpuFrequency;
|
||||
ifs.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Drm::querySystemInfo() {
|
||||
return false;
|
||||
}
|
||||
|
@ -18,26 +18,6 @@
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
TEST(DrmQueryTest, GivenGtMaxFreqFileExistsWhenFrequencyIsQueriedThenValidValueIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
int expectedMaxFrequency = 1000;
|
||||
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
auto hwInfo = *defaultHwInfo;
|
||||
|
||||
std::string gtMaxFreqFile = "test_files/linux/devices/device/drm/card1/gt_max_freq_mhz";
|
||||
|
||||
EXPECT_TRUE(fileExists(gtMaxFreqFile));
|
||||
drm.setPciPath("device");
|
||||
|
||||
int maxFrequency = 0;
|
||||
int ret = drm.getMaxGpuFrequency(hwInfo, maxFrequency);
|
||||
EXPECT_EQ(0, ret);
|
||||
|
||||
EXPECT_EQ(expectedMaxFrequency, maxFrequency);
|
||||
}
|
||||
|
||||
TEST(DrmQueryTest, WhenCallingIsDebugAttachAvailableThenReturnValueIsFalse) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
|
Reference in New Issue
Block a user