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:
shubham kumar
2025-01-31 15:18:39 +00:00
committed by Compute-Runtime-Automation
parent 6d63f688eb
commit f2b48b97d2
14 changed files with 62 additions and 128 deletions

View File

@@ -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));
}

View File

@@ -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) {

View File

@@ -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) {