mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-18 22:08:53 +08:00
Read frequency from file system based on drm version
Related-To: NEO-7300 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
11b43a341f
commit
9bde277184
@@ -792,7 +792,7 @@ bool Drm::isDebugAttachAvailable() {
|
||||
|
||||
int getMaxGpuFrequencyOfDevice(Drm &drm, std::string &sysFsPciPath, int &maxGpuFrequency) {
|
||||
maxGpuFrequency = 0;
|
||||
std::string clockSysFsPath = sysFsPciPath + "/gt_max_freq_mhz";
|
||||
std::string clockSysFsPath = sysFsPciPath + drm.getIoctlHelper()->getFileForMaxGpuFrequency();
|
||||
|
||||
std::ifstream ifs(clockSysFsPath.c_str(), std::ifstream::in);
|
||||
if (ifs.fail()) {
|
||||
@@ -806,7 +806,7 @@ int getMaxGpuFrequencyOfDevice(Drm &drm, std::string &sysFsPciPath, int &maxGpuF
|
||||
|
||||
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::string clockSysFsPath = sysFsPciPath + drm.getIoctlHelper()->getFileForMaxGpuFrequencyOfSubDevice(subDeviceId);
|
||||
|
||||
std::ifstream ifs(clockSysFsPath.c_str(), std::ifstream::in);
|
||||
if (ifs.fail()) {
|
||||
@@ -837,7 +837,7 @@ int Drm::getMaxGpuFrequency(HardwareInfo &hwInfo, int &maxGpuFrequency) {
|
||||
}
|
||||
|
||||
bool Drm::getDeviceMemoryMaxClockRateInMhz(uint32_t tileId, uint32_t &clkRate) {
|
||||
const std::string relativefilePath = "/gt/gt" + std::to_string(tileId) + "/mem_RP0_freq_mhz";
|
||||
const std::string relativefilePath = ioctlHelper->getFileForMaxMemoryFrequencyOfSubDevice(tileId);
|
||||
std::string readString(64, '\0');
|
||||
errno = 0;
|
||||
if (readSysFsAsString(relativefilePath, readString) == false) {
|
||||
|
||||
@@ -357,4 +357,16 @@ std::string IoctlHelper::getIoctlStringBase(DrmIoctl ioctlRequest) const {
|
||||
}
|
||||
}
|
||||
|
||||
std::string IoctlHelper::getFileForMaxGpuFrequency() const {
|
||||
return "/gt_max_freq_mhz";
|
||||
}
|
||||
|
||||
std::string IoctlHelper::getFileForMaxGpuFrequencyOfSubDevice(int subDeviceId) const {
|
||||
return "/gt/gt" + std::to_string(subDeviceId) + "/rps_max_freq_mhz";
|
||||
}
|
||||
|
||||
std::string IoctlHelper::getFileForMaxMemoryFrequencyOfSubDevice(int subDeviceId) const {
|
||||
return "/gt/gt" + std::to_string(subDeviceId) + "/mem_RP0_freq_mhz";
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -128,6 +128,9 @@ class IoctlHelper {
|
||||
|
||||
std::string getDrmParamStringBase(DrmParam param) const;
|
||||
std::string getIoctlStringBase(DrmIoctl ioctlRequest) const;
|
||||
std::string getFileForMaxGpuFrequency() const;
|
||||
std::string getFileForMaxGpuFrequencyOfSubDevice(int subDeviceId) const;
|
||||
std::string getFileForMaxMemoryFrequencyOfSubDevice(int subDeviceId) const;
|
||||
|
||||
uint32_t getFlagsForPrimeHandleToFd() const;
|
||||
|
||||
|
||||
@@ -1481,6 +1481,15 @@ TEST(IoctlHelperTest, whenGettingDrmParamValueThenProperValueIsReturned) {
|
||||
EXPECT_THROW(ioctlHelper->getDrmParamValueBase(DrmParam::EngineClassCompute), std::runtime_error);
|
||||
}
|
||||
|
||||
TEST(IoctlHelperTest, whenGettingFileNameForFrequencyFilesThenProperStringIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
auto ioctlHelper = drm.getIoctlHelper();
|
||||
EXPECT_STREQ("/gt_max_freq_mhz", ioctlHelper->getFileForMaxGpuFrequency().c_str());
|
||||
EXPECT_STREQ("/gt/gt2/rps_max_freq_mhz", ioctlHelper->getFileForMaxGpuFrequencyOfSubDevice(2).c_str());
|
||||
EXPECT_STREQ("/gt/gt1/mem_RP0_freq_mhz", ioctlHelper->getFileForMaxMemoryFrequencyOfSubDevice(1).c_str());
|
||||
}
|
||||
|
||||
TEST(DistanceInfoTest, givenDistanceInfosWhenAssignRegionsFromDistancesThenCorrectRegionsSet) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
Reference in New Issue
Block a user