mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
feature: Added changes for Porting Memory API with XE driver
The Memory Info object is used in the getState function for memory. Some of the ULTS in the memory modules has been modified. A function to return the sysfs nodes for the Memory address range has been added in the IoctlHelper class corresponding to the XE and i915 driver. Related-To: LOCI-4397 Signed-off-by: Bari, Pratik <pratik.bari@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
111b112729
commit
a15e8a9679
@@ -387,6 +387,10 @@ std::string IoctlHelper::getFileForMaxMemoryFrequencyOfSubDevice(int subDeviceId
|
||||
return "/gt/gt" + std::to_string(subDeviceId) + "/mem_RP0_freq_mhz";
|
||||
}
|
||||
|
||||
std::string IoctlHelper::getFileForMemoryAddrRange(int subDeviceId) const {
|
||||
return "gt/gt" + std::to_string(subDeviceId) + "/addr_range";
|
||||
}
|
||||
|
||||
bool IoctlHelper::checkIfIoctlReinvokeRequired(int error, DrmIoctl ioctlRequest) const {
|
||||
return (error == EINTR || error == EAGAIN || error == EBUSY || error == -EBUSY);
|
||||
}
|
||||
|
||||
@@ -142,6 +142,7 @@ class IoctlHelper {
|
||||
virtual std::string getFileForMaxGpuFrequency() const;
|
||||
virtual std::string getFileForMaxGpuFrequencyOfSubDevice(int subDeviceId) const;
|
||||
virtual std::string getFileForMaxMemoryFrequencyOfSubDevice(int subDeviceId) const;
|
||||
virtual std::string getFileForMemoryAddrRange(int subdeviceId) const;
|
||||
virtual bool getFabricLatency(uint32_t fabricId, uint32_t &latency, uint32_t &bandwidth) = 0;
|
||||
virtual bool isWaitBeforeBindRequired(bool bind) const = 0;
|
||||
virtual void *pciBarrierMmap() { return nullptr; };
|
||||
|
||||
@@ -1356,6 +1356,10 @@ std::string IoctlHelperXe::getFileForMaxMemoryFrequencyOfSubDevice(int subDevice
|
||||
return "/device/gt" + std::to_string(subDeviceId) + "/freq_rp0";
|
||||
}
|
||||
|
||||
std::string IoctlHelperXe::getFileForMemoryAddrRange(int subDeviceId) const {
|
||||
return "device/tile" + std::to_string(subDeviceId) + "/addr_range";
|
||||
}
|
||||
|
||||
struct drm_xe_engine_class_instance *
|
||||
IoctlHelperXe::xeFindMatchingEngine(uint16_t engineClass, uint16_t engineInstance) {
|
||||
for (auto &engine : allEngines) {
|
||||
|
||||
@@ -96,6 +96,7 @@ class IoctlHelperXe : public IoctlHelper {
|
||||
std::string getFileForMaxGpuFrequency() const override;
|
||||
std::string getFileForMaxGpuFrequencyOfSubDevice(int subDeviceId) const override;
|
||||
std::string getFileForMaxMemoryFrequencyOfSubDevice(int subDeviceId) const override;
|
||||
std::string getFileForMemoryAddrRange(int subdeviceId) const override;
|
||||
bool getFabricLatency(uint32_t fabricId, uint32_t &latency, uint32_t &bandwidth) override;
|
||||
bool isWaitBeforeBindRequired(bool bind) const override;
|
||||
std::unique_ptr<EngineInfo> createEngineInfo(bool isSysmanEnabled) override;
|
||||
|
||||
@@ -6,12 +6,23 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/helpers/constants.h"
|
||||
#include "shared/source/os_interface/linux/ioctl_helper.h"
|
||||
#include "shared/source/os_interface/linux/memory_info.h"
|
||||
|
||||
#include "drm/i915_drm.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
constexpr uint64_t probedSizeRegionZero = 8 * GB;
|
||||
constexpr uint64_t probedSizeRegionOne = 16 * GB;
|
||||
constexpr uint64_t probedSizeRegionFour = 32 * GB;
|
||||
constexpr uint64_t unallocatedSizeRegionZero = 6 * GB;
|
||||
constexpr uint64_t unallocatedSizeRegionOne = 12 * GB;
|
||||
constexpr uint64_t unallocatedSizeRegionFour = 4 * GB;
|
||||
|
||||
class MockIoctlHelper : public IoctlHelperPrelim20 {
|
||||
public:
|
||||
using IoctlHelperPrelim20::IoctlHelperPrelim20;
|
||||
@@ -20,6 +31,9 @@ class MockIoctlHelper : public IoctlHelperPrelim20 {
|
||||
};
|
||||
|
||||
int getDrmParamValue(DrmParam drmParam) const override {
|
||||
if (drmParam == DrmParam::MemoryClassSystem || drmParam == DrmParam::MemoryClassDevice) {
|
||||
return IoctlHelperPrelim20::getDrmParamValue(drmParam);
|
||||
}
|
||||
return drmParamValue;
|
||||
}
|
||||
int vmBind(const VmBindParams &vmBindParams) override {
|
||||
@@ -41,6 +55,23 @@ class MockIoctlHelper : public IoctlHelperPrelim20 {
|
||||
return IoctlHelperPrelim20::isWaitBeforeBindRequired(bind);
|
||||
}
|
||||
|
||||
std::unique_ptr<MemoryInfo> createMemoryInfo() override {
|
||||
|
||||
std::vector<MemoryRegion> regionInfo(3);
|
||||
regionInfo[0].region = {drm_i915_gem_memory_class::I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[0].probedSize = probedSizeRegionZero;
|
||||
regionInfo[0].unallocatedSize = unallocatedSizeRegionZero;
|
||||
regionInfo[1].region = {drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0};
|
||||
regionInfo[1].probedSize = probedSizeRegionOne;
|
||||
regionInfo[1].unallocatedSize = unallocatedSizeRegionOne;
|
||||
regionInfo[2].region = {drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 1};
|
||||
regionInfo[2].probedSize = probedSizeRegionFour;
|
||||
regionInfo[2].unallocatedSize = unallocatedSizeRegionFour;
|
||||
|
||||
std::unique_ptr<MemoryInfo> memoryInfo = std::make_unique<MemoryInfo>(regionInfo, drm);
|
||||
return memoryInfo;
|
||||
}
|
||||
|
||||
unsigned int ioctlRequestValue = 1234u;
|
||||
int drmParamValue = 1234;
|
||||
std::optional<bool> failBind{};
|
||||
|
||||
@@ -1563,6 +1563,13 @@ TEST(IoctlHelperTest, whenGettingFileNameForFrequencyFilesThenProperStringIsRetu
|
||||
EXPECT_STREQ("/gt/gt1/mem_RP0_freq_mhz", ioctlHelper->getFileForMaxMemoryFrequencyOfSubDevice(1).c_str());
|
||||
}
|
||||
|
||||
TEST(IoctlHelperTest, whenGettingFileNameForMemoryAddrRangeThenProperStringIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
auto ioctlHelper = drm.getIoctlHelper();
|
||||
EXPECT_STREQ("gt/gt0/addr_range", ioctlHelper->getFileForMemoryAddrRange(0).c_str());
|
||||
}
|
||||
|
||||
TEST(DistanceInfoTest, givenDistanceInfosWhenAssignRegionsFromDistancesThenCorrectRegionsSet) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
@@ -494,6 +494,13 @@ TEST(IoctlHelperXeTest, whenGettingFileNamesForFrequencyThenProperStringIsReturn
|
||||
EXPECT_STREQ("/device/gt1/freq_rp0", ioctlHelper->getFileForMaxMemoryFrequencyOfSubDevice(1).c_str());
|
||||
}
|
||||
|
||||
TEST(IoctlHelperXeTest, whenGettingFileNameForMemoryAddrRangeThenProperStringIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
auto ioctlHelper = std::make_unique<IoctlHelperXe>(drm);
|
||||
EXPECT_STREQ("device/tile0/addr_range", ioctlHelper->getFileForMemoryAddrRange(0).c_str());
|
||||
}
|
||||
|
||||
inline constexpr int testValueVmId = 0x5764;
|
||||
inline constexpr int testValueMapOff = 0x7788;
|
||||
inline constexpr int testValuePrime = 0x4321;
|
||||
|
||||
Reference in New Issue
Block a user