mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-30 09:58:55 +08:00
feature: Enable EuStall Metrics with xeKMD
Related-To: NEO-9645 Signed-off-by: Neil R. Spruit <neil.r.spruit@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
fe6809ac04
commit
960664f352
@@ -12,6 +12,7 @@ set(NEO_CORE_OS_INTERFACE_LINUX_XE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ioctl_helper_xe.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/ioctl_helper_xe_query_hw_ip_version.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/ioctl_helper_xe_vm_bind_flags.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/ioctl_helper_xe_perf.cpp
|
||||
)
|
||||
|
||||
if(NEO_ENABLE_XE_EU_DEBUG_SUPPORT)
|
||||
|
||||
@@ -1138,6 +1138,9 @@ int IoctlHelperXe::ioctl(DrmIoctl request, void *arg) {
|
||||
case DrmIoctl::metadataDestroy: {
|
||||
ret = debuggerMetadataDestroyIoctl(request, arg);
|
||||
} break;
|
||||
case DrmIoctl::perfOpen: {
|
||||
ret = perfOpenIoctl(request, arg);
|
||||
} break;
|
||||
|
||||
default:
|
||||
xeLog("Not handled 0x%x\n", request);
|
||||
@@ -1500,18 +1503,6 @@ void IoctlHelperXe::setContextProperties(const OsContextLinux &osContext, void *
|
||||
}
|
||||
}
|
||||
|
||||
bool IoctlHelperXe::perfOpenEuStallStream(uint32_t euStallFdParameter, std::array<uint64_t, 12u> &properties, 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::getIoctlRequestValue(DrmIoctl ioctlRequest) const {
|
||||
xeLog(" -> IoctlHelperXe::%s 0x%x\n", __FUNCTION__, ioctlRequest);
|
||||
switch (ioctlRequest) {
|
||||
@@ -1547,12 +1538,20 @@ unsigned int IoctlHelperXe::getIoctlRequestValue(DrmIoctl ioctlRequest) const {
|
||||
case DrmIoctl::metadataCreate:
|
||||
case DrmIoctl::metadataDestroy:
|
||||
return getIoctlRequestValueDebugger(ioctlRequest);
|
||||
case DrmIoctl::perfOpen:
|
||||
case DrmIoctl::perfEnable:
|
||||
case DrmIoctl::perfDisable:
|
||||
return getIoctlRequestValuePerf(ioctlRequest);
|
||||
default:
|
||||
UNRECOVERABLE_IF(true);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int IoctlHelperXe::ioctl(int fd, DrmIoctl request, void *arg) {
|
||||
return NEO::SysCalls::ioctl(fd, getIoctlRequestValue(request), arg);
|
||||
}
|
||||
|
||||
std::string IoctlHelperXe::getIoctlString(DrmIoctl ioctlRequest) const {
|
||||
switch (ioctlRequest) {
|
||||
case DrmIoctl::gemClose:
|
||||
|
||||
@@ -36,7 +36,7 @@ class IoctlHelperXe : public IoctlHelper {
|
||||
IoctlHelperXe(Drm &drmArg);
|
||||
~IoctlHelperXe() override;
|
||||
int ioctl(DrmIoctl request, void *arg) override;
|
||||
|
||||
int ioctl(int fd, DrmIoctl request, void *arg) override;
|
||||
bool initialize() override;
|
||||
bool isSetPairAvailable() override;
|
||||
bool isChunkingAvailable() override;
|
||||
@@ -84,6 +84,8 @@ class IoctlHelperXe : public IoctlHelper {
|
||||
uint32_t getEuStallFdParameter() override;
|
||||
bool perfOpenEuStallStream(uint32_t euStallFdParameter, std::array<uint64_t, 12u> &properties, int32_t *stream) override;
|
||||
bool perfDisableEuStallStream(int32_t *stream) override;
|
||||
MOCKABLE_VIRTUAL int perfOpenIoctl(DrmIoctl request, void *arg);
|
||||
unsigned int getIoctlRequestValuePerf(DrmIoctl ioctlRequest) const;
|
||||
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;
|
||||
int unregisterUuid(uint32_t handle) override;
|
||||
|
||||
35
shared/source/os_interface/linux/xe/ioctl_helper_xe_perf.cpp
Normal file
35
shared/source/os_interface/linux/xe/ioctl_helper_xe_perf.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/os_interface/linux/sys_calls.h"
|
||||
#include "shared/source/os_interface/linux/xe/ioctl_helper_xe.h"
|
||||
|
||||
#include "xe_drm.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
bool IoctlHelperXe::perfOpenEuStallStream(uint32_t euStallFdParameter, std::array<uint64_t, 12u> &properties, 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;
|
||||
}
|
||||
|
||||
int IoctlHelperXe::perfOpenIoctl(DrmIoctl request, void *arg) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
@@ -7,6 +7,7 @@
|
||||
set(NEO_CORE_OS_INTERFACE_TESTS_LINUX_XE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ioctl_helper_xe_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/ioctl_helper_xe_perf_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ioctl_helper_xe_tests.h
|
||||
)
|
||||
if(NEO_ENABLE_XE_EU_DEBUG_SUPPORT)
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/os_interface/linux/os_context_linux.h"
|
||||
#include "shared/test/common/helpers/engine_descriptor_helper.h"
|
||||
#include "shared/test/common/mocks/linux/mock_drm_memory_manager.h"
|
||||
#include "shared/test/common/mocks/linux/mock_os_context_linux.h"
|
||||
#include "shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
TEST(IoctlHelperXeTest, whenCallingGetEuStallPropertiesThenFailueIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMockXe drm{*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(IoctlHelperXeTest, whenCallingPerfOpenEuStallStreamThenFailueIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMockXe drm{*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));
|
||||
}
|
||||
|
||||
TEST(IoctlHelperXeTest, whenCallingPerfDisableEuStallStreamThenFailueIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMockXe drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(drm);
|
||||
EXPECT_NE(nullptr, xeIoctlHelper);
|
||||
int32_t invalidFd = -1;
|
||||
EXPECT_FALSE(xeIoctlHelper.get()->perfDisableEuStallStream(&invalidFd));
|
||||
}
|
||||
|
||||
TEST(IoctlHelperXeTest, whenCallingGetIoctlRequestValuePerfOpenThenZeroisReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMockXe drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(drm);
|
||||
EXPECT_NE(nullptr, xeIoctlHelper);
|
||||
EXPECT_EQ(0u, xeIoctlHelper.get()->getIoctlRequestValuePerf(DrmIoctl::perfOpen));
|
||||
}
|
||||
|
||||
TEST(IoctlHelperXeTest, whenCallingGetIoctlRequestValuePerfEnableThenZeroisReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMockXe drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(drm);
|
||||
EXPECT_NE(nullptr, xeIoctlHelper);
|
||||
EXPECT_EQ(0u, xeIoctlHelper.get()->getIoctlRequestValuePerf(DrmIoctl::perfEnable));
|
||||
}
|
||||
|
||||
TEST(IoctlHelperXeTest, whenCallingGetIoctlRequestValuePerfDisableThenZeroisReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMockXe drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(drm);
|
||||
EXPECT_NE(nullptr, xeIoctlHelper);
|
||||
EXPECT_EQ(0u, xeIoctlHelper.get()->getIoctlRequestValuePerf(DrmIoctl::perfDisable));
|
||||
}
|
||||
|
||||
TEST(IoctlHelperXeTest, whenCallingPerfOpenIoctlWithInvalidValuesThenZeroisReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMockXe drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(drm);
|
||||
EXPECT_NE(nullptr, xeIoctlHelper);
|
||||
EXPECT_EQ(0, xeIoctlHelper.get()->perfOpenIoctl(DrmIoctl::perfOpen, nullptr));
|
||||
}
|
||||
|
||||
TEST(IoctlHelperXeTest, whenCallingGetIoctlRequestValueWithInvalidValueThenErrorReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMockXe drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(drm);
|
||||
EXPECT_NE(nullptr, xeIoctlHelper);
|
||||
EXPECT_EQ(0u, xeIoctlHelper.get()->getIoctlRequestValuePerf(DrmIoctl::version));
|
||||
}
|
||||
|
||||
TEST(IoctlHelperXeTest, whenCallingPerfOpenIoctlThenProperValueIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMockXe drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(drm);
|
||||
EXPECT_NE(nullptr, xeIoctlHelper);
|
||||
EXPECT_EQ(0, xeIoctlHelper.get()->ioctl(DrmIoctl::perfOpen, nullptr));
|
||||
}
|
||||
|
||||
TEST(IoctlHelperXeTest, whenCallingPerfDisableIoctlThenProperValueIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMockXe drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(drm);
|
||||
EXPECT_NE(nullptr, xeIoctlHelper);
|
||||
int32_t invalidFd = -1;
|
||||
EXPECT_EQ(0, xeIoctlHelper.get()->ioctl(invalidFd, DrmIoctl::perfDisable, nullptr));
|
||||
}
|
||||
@@ -305,9 +305,6 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingAnyMethodThenDummyValueIsRe
|
||||
|
||||
EXPECT_EQ(-1, xeIoctlHelper->vmUnbind(vmBindParams));
|
||||
|
||||
std::array<uint64_t, 12u> properties;
|
||||
EXPECT_FALSE(xeIoctlHelper->getEuStallProperties(properties, 0, 0, 0, 0, 0));
|
||||
|
||||
EXPECT_EQ(0u, xeIoctlHelper->getEuStallFdParameter());
|
||||
|
||||
std::string uuid{};
|
||||
@@ -2102,34 +2099,6 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingGetFlagsForVmBindThenExpect
|
||||
}
|
||||
}
|
||||
|
||||
TEST(IoctlHelperXeTest, whenCallingGetEuStallPropertiesThenFailueIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMock drm{*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(IoctlHelperXeTest, whenCallingPerfOpenEuStallStreamThenFailueIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMock drm{*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));
|
||||
}
|
||||
|
||||
TEST(IoctlHelperXeTest, whenCallingPerfDisableEuStallStreamThenFailueIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(drm);
|
||||
EXPECT_NE(nullptr, xeIoctlHelper);
|
||||
int32_t invalidFd = -1;
|
||||
EXPECT_FALSE(xeIoctlHelper.get()->perfDisableEuStallStream(&invalidFd));
|
||||
}
|
||||
|
||||
TEST(IoctlHelperXeTest, whenGetFdFromVmExportIsCalledThenFalseIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMockXe drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
@@ -33,6 +33,7 @@ struct MockIoctlHelperXe : IoctlHelperXe {
|
||||
using IoctlHelperXe::defaultEngine;
|
||||
using IoctlHelperXe::getDefaultEngineClass;
|
||||
using IoctlHelperXe::getFdFromVmExport;
|
||||
using IoctlHelperXe::ioctl;
|
||||
using IoctlHelperXe::IoctlHelperXe;
|
||||
using IoctlHelperXe::maxContextSetProperties;
|
||||
using IoctlHelperXe::maxExecQueuePriority;
|
||||
@@ -46,6 +47,30 @@ struct MockIoctlHelperXe : IoctlHelperXe {
|
||||
using IoctlHelperXe::xeGetengineClassName;
|
||||
using IoctlHelperXe::xeGtListData;
|
||||
using IoctlHelperXe::xeShowBindTable;
|
||||
|
||||
int perfOpenIoctl(DrmIoctl request, void *arg) override {
|
||||
if (failPerfOpen) {
|
||||
return -1;
|
||||
}
|
||||
return IoctlHelperXe::perfOpenIoctl(request, arg);
|
||||
}
|
||||
|
||||
int ioctl(int fd, DrmIoctl request, void *arg) override {
|
||||
if (request == DrmIoctl::perfDisable) {
|
||||
if (failPerfDisable) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (request == DrmIoctl::perfEnable) {
|
||||
if (failPerfEnable) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return IoctlHelperXe::ioctl(fd, request, arg);
|
||||
}
|
||||
bool failPerfDisable = false;
|
||||
bool failPerfEnable = false;
|
||||
bool failPerfOpen = false;
|
||||
};
|
||||
|
||||
inline constexpr int testValueVmId = 0x5764;
|
||||
@@ -295,6 +320,9 @@ class DrmMockXe : public DrmMockCustom {
|
||||
ret = 0;
|
||||
}
|
||||
} break;
|
||||
case DrmIoctl::perfOpen: {
|
||||
ret = 0;
|
||||
} break;
|
||||
case DrmIoctl::gemContextSetparam:
|
||||
case DrmIoctl::gemContextGetparam:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user