mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-18 22:08:53 +08:00
refactor: Prework to get sampling unit through ioctl query on xe
Related-To: NEO-13777 Signed-off-by: shubham kumar <shubham.kumar@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
6d63f688eb
commit
f2b48b97d2
@@ -96,4 +96,5 @@ inline constexpr uint32_t maxWorkgroupSize = 1024u;
|
||||
inline constexpr uint32_t minimalSyncBufferSize = 12;
|
||||
inline constexpr uint32_t gpuHangCheckTimeInUS = 500'000;
|
||||
inline constexpr double defaultProfilingTimerResolution = 83.333;
|
||||
} // namespace CommonConstants
|
||||
inline constexpr uint64_t nsecPerSec = 1000000000ull;
|
||||
} // namespace CommonConstants
|
||||
@@ -152,11 +152,9 @@ class IoctlHelper {
|
||||
virtual int vmBind(const VmBindParams &vmBindParams) = 0;
|
||||
virtual int vmUnbind(const VmBindParams &vmBindParams) = 0;
|
||||
virtual int getResetStats(ResetStats &resetStats, uint32_t *status, ResetStatsFault *resetStatsFault) = 0;
|
||||
virtual bool getEuStallProperties(std::array<uint64_t, 12u> &properties, uint64_t dssBufferSize,
|
||||
uint64_t samplingRate, uint64_t pollPeriod, uint64_t engineInstance, uint64_t notifyNReports) = 0;
|
||||
virtual bool isEuStallSupported() = 0;
|
||||
virtual uint32_t getEuStallFdParameter() = 0;
|
||||
virtual bool perfOpenEuStallStream(uint32_t euStallFdParameter, std::array<uint64_t, 12u> &properties, int32_t *stream) = 0;
|
||||
virtual bool perfOpenEuStallStream(uint32_t euStallFdParameter, uint32_t &samplingPeriodNs, uint64_t engineInstance, uint64_t notifyNReports, uint64_t gpuTimeStampfrequency, int32_t *stream) = 0;
|
||||
virtual bool perfDisableEuStallStream(int32_t *stream) = 0;
|
||||
virtual UuidRegisterResult registerUuid(const std::string &uuid, uint32_t uuidClass, uint64_t ptr, uint64_t size) = 0;
|
||||
virtual UuidRegisterResult registerStringClassUuid(const std::string &uuid, uint64_t ptr, uint64_t size) = 0;
|
||||
@@ -325,10 +323,8 @@ class IoctlHelperUpstream : public IoctlHelperI915 {
|
||||
int vmUnbind(const VmBindParams &vmBindParams) override;
|
||||
int getResetStats(ResetStats &resetStats, uint32_t *status, ResetStatsFault *resetStatsFault) override;
|
||||
bool isEuStallSupported() override;
|
||||
bool getEuStallProperties(std::array<uint64_t, 12u> &properties, uint64_t dssBufferSize, uint64_t samplingRate,
|
||||
uint64_t pollPeriod, uint64_t engineInstance, uint64_t notifyNReports) override;
|
||||
uint32_t getEuStallFdParameter() override;
|
||||
bool perfOpenEuStallStream(uint32_t euStallFdParameter, std::array<uint64_t, 12u> &properties, int32_t *stream) override;
|
||||
bool perfOpenEuStallStream(uint32_t euStallFdParameter, uint32_t &samplingPeriodNs, uint64_t engineInstance, uint64_t notifyNReports, uint64_t gpuTimeStampfrequency, int32_t *stream) override;
|
||||
bool perfDisableEuStallStream(int32_t *stream) override;
|
||||
UuidRegisterResult registerUuid(const std::string &uuid, uint32_t uuidClass, uint64_t ptr, uint64_t size) override;
|
||||
UuidRegisterResult registerStringClassUuid(const std::string &uuid, uint64_t ptr, uint64_t size) override;
|
||||
@@ -401,9 +397,7 @@ class IoctlHelperPrelim20 : public IoctlHelperI915 {
|
||||
int vmBind(const VmBindParams &vmBindParams) override;
|
||||
int vmUnbind(const VmBindParams &vmBindParams) override;
|
||||
int getResetStats(ResetStats &resetStats, uint32_t *status, ResetStatsFault *resetStatsFault) override;
|
||||
bool getEuStallProperties(std::array<uint64_t, 12u> &properties, uint64_t dssBufferSize, uint64_t samplingRate,
|
||||
uint64_t pollPeriod, uint64_t engineInstance, uint64_t notifyNReports) override;
|
||||
bool perfOpenEuStallStream(uint32_t euStallFdParameter, std::array<uint64_t, 12u> &properties, int32_t *stream) override;
|
||||
bool perfOpenEuStallStream(uint32_t euStallFdParameter, uint32_t &samplingPeriodNs, uint64_t engineInstance, uint64_t notifyNReports, uint64_t gpuTimeStampfrequency, int32_t *stream) override;
|
||||
bool perfDisableEuStallStream(int32_t *stream) override;
|
||||
bool isEuStallSupported() override;
|
||||
uint32_t getEuStallFdParameter() override;
|
||||
|
||||
@@ -587,14 +587,35 @@ bool IoctlHelperPrelim20::isEuStallSupported() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IoctlHelperPrelim20::getEuStallProperties(std::array<uint64_t, 12u> &properties, uint64_t dssBufferSize, uint64_t samplingRate,
|
||||
uint64_t pollPeriod, uint64_t engineInstance, uint64_t notifyNReports) {
|
||||
uint32_t IoctlHelperPrelim20::getEuStallFdParameter() {
|
||||
return PRELIM_I915_PERF_FLAG_FD_EU_STALL;
|
||||
}
|
||||
|
||||
bool IoctlHelperPrelim20::perfOpenEuStallStream(uint32_t euStallFdParameter, uint32_t &samplingPeriodNs, uint64_t engineInstance, uint64_t notifyNReports, uint64_t gpuTimeStampfrequency, int32_t *stream) {
|
||||
static constexpr uint32_t maxDssBufferSize = 512 * MemoryConstants::kiloByte;
|
||||
static constexpr uint32_t defaultPollPeriodNs = 10000000u;
|
||||
|
||||
// Get sampling unit.
|
||||
static constexpr uint32_t samplingClockGranularity = 251u;
|
||||
static constexpr uint32_t minSamplingUnit = 1u;
|
||||
static constexpr uint32_t maxSamplingUnit = 7u;
|
||||
|
||||
uint64_t gpuClockPeriodNs = CommonConstants::nsecPerSec / gpuTimeStampfrequency;
|
||||
uint64_t numberOfClocks = samplingPeriodNs / gpuClockPeriodNs;
|
||||
|
||||
uint32_t samplingUnit = 0;
|
||||
samplingUnit = std::clamp(static_cast<uint32_t>(numberOfClocks / samplingClockGranularity), minSamplingUnit, maxSamplingUnit);
|
||||
samplingPeriodNs = samplingUnit * samplingClockGranularity * static_cast<uint32_t>(gpuClockPeriodNs);
|
||||
|
||||
// Populate the EU stall properties.
|
||||
std::array<uint64_t, 12u> properties;
|
||||
|
||||
properties[0] = prelim_drm_i915_eu_stall_property_id::PRELIM_DRM_I915_EU_STALL_PROP_BUF_SZ;
|
||||
properties[1] = dssBufferSize;
|
||||
properties[1] = maxDssBufferSize;
|
||||
properties[2] = prelim_drm_i915_eu_stall_property_id::PRELIM_DRM_I915_EU_STALL_PROP_SAMPLE_RATE;
|
||||
properties[3] = samplingRate;
|
||||
properties[3] = samplingUnit;
|
||||
properties[4] = prelim_drm_i915_eu_stall_property_id::PRELIM_DRM_I915_EU_STALL_PROP_POLL_PERIOD;
|
||||
properties[5] = pollPeriod;
|
||||
properties[5] = defaultPollPeriodNs;
|
||||
properties[6] = prelim_drm_i915_eu_stall_property_id::PRELIM_DRM_I915_EU_STALL_PROP_ENGINE_CLASS;
|
||||
properties[7] = prelim_drm_i915_gem_engine_class::PRELIM_I915_ENGINE_CLASS_COMPUTE;
|
||||
properties[8] = prelim_drm_i915_eu_stall_property_id::PRELIM_DRM_I915_EU_STALL_PROP_ENGINE_INSTANCE;
|
||||
@@ -602,14 +623,7 @@ bool IoctlHelperPrelim20::getEuStallProperties(std::array<uint64_t, 12u> &proper
|
||||
properties[10] = prelim_drm_i915_eu_stall_property_id::PRELIM_DRM_I915_EU_STALL_PROP_EVENT_REPORT_COUNT;
|
||||
properties[11] = notifyNReports;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t IoctlHelperPrelim20::getEuStallFdParameter() {
|
||||
return PRELIM_I915_PERF_FLAG_FD_EU_STALL;
|
||||
}
|
||||
|
||||
bool IoctlHelperPrelim20::perfOpenEuStallStream(uint32_t euStallFdParameter, std::array<uint64_t, 12u> &properties, int32_t *stream) {
|
||||
// Call perf open ioctl.
|
||||
NEO::PrelimI915::drm_i915_perf_open_param param = {};
|
||||
param.flags = I915_PERF_FLAG_FD_CLOEXEC |
|
||||
euStallFdParameter |
|
||||
|
||||
@@ -199,17 +199,11 @@ bool IoctlHelperUpstream::isEuStallSupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IoctlHelperUpstream::getEuStallProperties(std::array<uint64_t, 12u> &properties, uint64_t dssBufferSize,
|
||||
uint64_t samplingRate, uint64_t pollPeriod, uint64_t engineInstance,
|
||||
uint64_t notifyNReports) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t IoctlHelperUpstream::getEuStallFdParameter() {
|
||||
return 0u;
|
||||
}
|
||||
|
||||
bool IoctlHelperUpstream::perfOpenEuStallStream(uint32_t euStallFdParameter, std::array<uint64_t, 12u> &properties, int32_t *stream) {
|
||||
bool IoctlHelperUpstream::perfOpenEuStallStream(uint32_t euStallFdParameter, uint32_t &samplingPeriodNs, uint64_t engineInstance, uint64_t notifyNReports, uint64_t gpuTimeStampfrequency, int32_t *stream) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,11 +82,9 @@ class IoctlHelperXe : public IoctlHelper {
|
||||
int vmBind(const VmBindParams &vmBindParams) override;
|
||||
int vmUnbind(const VmBindParams &vmBindParams) override;
|
||||
int getResetStats(ResetStats &resetStats, uint32_t *status, ResetStatsFault *resetStatsFault) override;
|
||||
bool getEuStallProperties(std::array<uint64_t, 12u> &properties, uint64_t dssBufferSize, uint64_t samplingRate, uint64_t pollPeriod,
|
||||
uint64_t engineInstance, uint64_t notifyNReports) override;
|
||||
bool isEuStallSupported() override;
|
||||
uint32_t getEuStallFdParameter() override;
|
||||
bool perfOpenEuStallStream(uint32_t euStallFdParameter, std::array<uint64_t, 12u> &properties, int32_t *stream) override;
|
||||
bool perfOpenEuStallStream(uint32_t euStallFdParameter, uint32_t &samplingPeriodNs, uint64_t engineInstance, uint64_t notifyNReports, uint64_t gpuTimeStampfrequency, int32_t *stream) override;
|
||||
bool perfDisableEuStallStream(int32_t *stream) override;
|
||||
MOCKABLE_VIRTUAL int perfOpenIoctl(DrmIoctl request, void *arg);
|
||||
unsigned int getIoctlRequestValuePerf(DrmIoctl ioctlRequest) const;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Intel Corporation
|
||||
* Copyright (C) 2024-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -11,17 +11,13 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
bool IoctlHelperXe::perfOpenEuStallStream(uint32_t euStallFdParameter, std::array<uint64_t, 12u> &properties, int32_t *stream) {
|
||||
bool IoctlHelperXe::perfOpenEuStallStream(uint32_t euStallFdParameter, uint32_t &samplingPeriodNs, uint64_t engineInstance, uint64_t notifyNReports, uint64_t gpuTimeStampfrequency, int32_t *stream) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IoctlHelperXe::perfDisableEuStallStream(int32_t *stream) {
|
||||
return false;
|
||||
}
|
||||
bool IoctlHelperXe::getEuStallProperties(std::array<uint64_t, 12u> &properties, uint64_t dssBufferSize, uint64_t samplingRate,
|
||||
uint64_t pollPeriod, uint64_t engineInstance, uint64_t notifyNReports) {
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int IoctlHelperXe::getIoctlRequestValuePerf(DrmIoctl ioctlRequest) const {
|
||||
return 0;
|
||||
|
||||
@@ -374,28 +374,12 @@ TEST_F(IoctlPrelimHelperTests, givenPrelimWhenCallingIsEuStallSupportedThenTrueI
|
||||
EXPECT_TRUE(ioctlHelper.isEuStallSupported());
|
||||
}
|
||||
|
||||
TEST_F(IoctlPrelimHelperTests, givenPrelimWhenGettingEuStallPropertiesThenCorrectPropertiesAreReturned) {
|
||||
std::array<uint64_t, 12u> properties = {};
|
||||
EXPECT_TRUE(ioctlHelper.getEuStallProperties(properties, 0x101, 0x102, 0x103, 1, 20u));
|
||||
EXPECT_EQ(properties[0], prelim_drm_i915_eu_stall_property_id::PRELIM_DRM_I915_EU_STALL_PROP_BUF_SZ);
|
||||
EXPECT_EQ(properties[1], 0x101u);
|
||||
EXPECT_EQ(properties[2], prelim_drm_i915_eu_stall_property_id::PRELIM_DRM_I915_EU_STALL_PROP_SAMPLE_RATE);
|
||||
EXPECT_EQ(properties[3], 0x102u);
|
||||
EXPECT_EQ(properties[4], prelim_drm_i915_eu_stall_property_id::PRELIM_DRM_I915_EU_STALL_PROP_POLL_PERIOD);
|
||||
EXPECT_EQ(properties[5], 0x103u);
|
||||
EXPECT_EQ(properties[6], prelim_drm_i915_eu_stall_property_id::PRELIM_DRM_I915_EU_STALL_PROP_ENGINE_CLASS);
|
||||
EXPECT_EQ(properties[7], prelim_drm_i915_gem_engine_class::PRELIM_I915_ENGINE_CLASS_COMPUTE);
|
||||
EXPECT_EQ(properties[8], prelim_drm_i915_eu_stall_property_id::PRELIM_DRM_I915_EU_STALL_PROP_ENGINE_INSTANCE);
|
||||
|
||||
EXPECT_EQ(properties[11], 20u);
|
||||
}
|
||||
|
||||
TEST_F(IoctlPrelimHelperTests, givenPrelimWhenCallingPerfOpenEuStallStreamWithInvalidArgumentsThenFailureReturned) {
|
||||
std::array<uint64_t, 12u> properties = {};
|
||||
int32_t invalidStream = -1;
|
||||
DrmMock *mockDrm = reinterpret_cast<DrmMock *>(drm.get());
|
||||
mockDrm->failPerfOpen = true;
|
||||
EXPECT_FALSE(ioctlHelper.perfOpenEuStallStream(0u, properties, &invalidStream));
|
||||
uint32_t samplingPeridNs = 10000u;
|
||||
EXPECT_FALSE(ioctlHelper.perfOpenEuStallStream(0u, samplingPeridNs, 1, 20u, 10000u, &invalidStream));
|
||||
}
|
||||
|
||||
TEST_F(IoctlPrelimHelperTests, givenPrelimWhenGettingEuStallFdParameterThenCorrectIoctlValueIsReturned) {
|
||||
@@ -583,8 +567,8 @@ TEST(IoctlPrelimHelperPerfTests, givenCalltoPerfOpenEuStallStreamWithInvalidStre
|
||||
mockIoctlHelper.initialize();
|
||||
int32_t invalidFd = -1;
|
||||
mockIoctlHelper.failPerfEnable = true;
|
||||
std::array<uint64_t, 12u> properties = {};
|
||||
EXPECT_FALSE(mockIoctlHelper.perfOpenEuStallStream(0u, properties, &invalidFd));
|
||||
uint32_t samplingPeridNs = 10000u;
|
||||
EXPECT_FALSE(mockIoctlHelper.perfOpenEuStallStream(0u, samplingPeridNs, 1, 20u, 10000u, &invalidFd));
|
||||
}
|
||||
|
||||
TEST(IoctlPrelimHelperPerfTests, givenCalltoPerfDisableEuStallStreamWithValidStreamThenSuccessIsReturned) {
|
||||
@@ -594,9 +578,8 @@ TEST(IoctlPrelimHelperPerfTests, givenCalltoPerfDisableEuStallStreamWithValidStr
|
||||
|
||||
mockIoctlHelper.initialize();
|
||||
int32_t validFd = -1;
|
||||
std::array<uint64_t, 12u> properties = {};
|
||||
EXPECT_TRUE(mockIoctlHelper.getEuStallProperties(properties, 0x101, 0x102, 0x103, 1, 20u));
|
||||
EXPECT_TRUE(mockIoctlHelper.perfOpenEuStallStream(0u, properties, &validFd));
|
||||
uint32_t samplingPeridNs = 10000u;
|
||||
EXPECT_TRUE(mockIoctlHelper.perfOpenEuStallStream(0u, samplingPeridNs, 1, 20u, 10000u, &validFd));
|
||||
EXPECT_TRUE(mockIoctlHelper.perfDisableEuStallStream(&validFd));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021-2024 Intel Corporation
|
||||
* Copyright (C) 2021-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -523,21 +523,13 @@ TEST(IoctlHelperTestsUpstream, whenCallingIsEuStallSupportedThenFalseIsReturned)
|
||||
EXPECT_FALSE(ioctlHelper->isEuStallSupported());
|
||||
}
|
||||
|
||||
TEST(IoctlHelperTestsUpstream, whenCallingGetEuStallPropertiesThenFailueIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
std::array<uint64_t, 12u> properties = {};
|
||||
EXPECT_FALSE(ioctlHelper->getEuStallProperties(properties, 0x101, 0x102, 0x103, 1, 20u));
|
||||
}
|
||||
|
||||
TEST(IoctlHelperTestsUpstream, whenCallingPerfOpenEuStallStreamThenFailueIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
int32_t invalidFd = -1;
|
||||
std::array<uint64_t, 12u> properties = {};
|
||||
EXPECT_FALSE(ioctlHelper->perfOpenEuStallStream(0u, properties, &invalidFd));
|
||||
uint32_t samplingPeridNs = 10000u;
|
||||
EXPECT_FALSE(ioctlHelper->perfOpenEuStallStream(0u, samplingPeridNs, 1, 20u, 10000u, &invalidFd));
|
||||
}
|
||||
|
||||
TEST(IoctlHelperTestsUpstream, whenCallingPerfDisableEuStallStreamThenFailueIsReturned) {
|
||||
@@ -675,12 +667,13 @@ TEST(IoctlHelperTestsUpstream, whenVmUnbindIsCalledThenZeroIsReturned) {
|
||||
EXPECT_EQ(0, ioctlHelper.vmUnbind(vmBindParams));
|
||||
}
|
||||
|
||||
TEST(IoctlHelperTestsUpstream, givenUpstreamWhenGettingEuStallPropertiesThenFailureIsReturned) {
|
||||
TEST(IoctlHelperTestsUpstream, givenUpstreamWhenCallingPerfOpenEuStallStreamThenFailueIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
IoctlHelperUpstream ioctlHelper{*drm};
|
||||
std::array<uint64_t, 12u> properties = {};
|
||||
EXPECT_FALSE(ioctlHelper.getEuStallProperties(properties, 0x101, 0x102, 0x103, 1, 1));
|
||||
int32_t invalidFd = -1;
|
||||
uint32_t samplingPeridNs = 10000u;
|
||||
EXPECT_FALSE(ioctlHelper.perfOpenEuStallStream(0u, samplingPeridNs, 1, 20u, 10000u, &invalidFd));
|
||||
}
|
||||
|
||||
TEST(IoctlHelperTestsUpstream, givenUpstreamWhenGettingEuStallFdParameterThenZeroIsReturned) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Intel Corporation
|
||||
* Copyright (C) 2024-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -17,23 +17,14 @@
|
||||
using namespace NEO;
|
||||
using IoctlHelperXeTest = Test<XeConfigFixture>;
|
||||
|
||||
TEST_F(IoctlHelperXeTest, whenCallingGetEuStallPropertiesThenFailueIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(*drm);
|
||||
EXPECT_NE(nullptr, xeIoctlHelper);
|
||||
std::array<uint64_t, 12u> properties = {};
|
||||
EXPECT_FALSE(xeIoctlHelper.get()->getEuStallProperties(properties, 0x101, 0x102, 0x103, 1, 20u));
|
||||
}
|
||||
|
||||
TEST_F(IoctlHelperXeTest, whenCallingPerfOpenEuStallStreamThenFailueIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(*drm);
|
||||
EXPECT_NE(nullptr, xeIoctlHelper);
|
||||
int32_t invalidFd = -1;
|
||||
std::array<uint64_t, 12u> properties = {};
|
||||
EXPECT_FALSE(xeIoctlHelper.get()->perfOpenEuStallStream(0u, properties, &invalidFd));
|
||||
uint32_t samplingPeriodNs = 10000u;
|
||||
EXPECT_FALSE(xeIoctlHelper.get()->perfOpenEuStallStream(0u, samplingPeriodNs, 1, 20u, 10000u, &invalidFd));
|
||||
}
|
||||
|
||||
TEST_F(IoctlHelperXeTest, whenCallingPerfDisableEuStallStreamThenFailueIsReturned) {
|
||||
|
||||
Reference in New Issue
Block a user