feature(sysman): Boilerplate for Sysman Product Helper

- Added the product specific files and some functions
- Have added APIs to call the interface to the Sysman product helper
- Have added ULTs for the new APIs

Related-To: NEO-8584

Signed-off-by: Bari, Pratik <pratik.bari@intel.com>
This commit is contained in:
Bari, Pratik
2023-09-19 19:47:11 +00:00
committed by Compute-Runtime-Automation
parent 65337482ff
commit 3c2ef4fbbf
18 changed files with 355 additions and 0 deletions

View File

@@ -22,6 +22,7 @@
#include "level_zero/sysman/source/linux/sysman_fs_access.h"
#include "level_zero/sysman/source/pci/linux/sysman_os_pci_imp.h"
#include "level_zero/sysman/source/pci/sysman_pci_utils.h"
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h"
#include "level_zero/sysman/source/shared/linux/sysman_kmd_interface.h"
namespace L0 {
@@ -66,6 +67,7 @@ ze_result_t LinuxSysmanImp::init() {
pSysfsAccess->getRealPath(deviceDir, gtDevicePath);
pSysmanKmdInterface = SysmanKmdInterface::create(*getDrm());
pSysmanProductHelper = SysmanProductHelper::create(getProductFamily());
osInterface.getDriverModel()->as<NEO::Drm>()->cleanup();
// Close Drm handles
@@ -184,6 +186,10 @@ uint32_t LinuxSysmanImp::getSubDeviceCount() {
return subDeviceCount;
}
SysmanProductHelper *LinuxSysmanImp::getSysmanProductHelper() {
return pSysmanProductHelper.get();
}
LinuxSysmanImp::LinuxSysmanImp(SysmanDeviceImp *pParentSysmanDeviceImp) {
this->pParentSysmanDeviceImp = pParentSysmanDeviceImp;
executionEnvironment = pParentSysmanDeviceImp->getExecutionEnvironment();

View File

@@ -24,6 +24,8 @@ class Drm;
namespace L0 {
namespace Sysman {
class SysmanProductHelper;
class PlatformMonitoringTech;
class PmuInterface;
class FsAccess;
@@ -45,6 +47,7 @@ class LinuxSysmanImp : public OsSysman, NEO::NonCopyableOrMovableClass {
ProcfsAccess &getProcfsAccess();
SysfsAccess &getSysfsAccess();
SysmanDeviceImp *getSysmanDeviceImp();
SysmanProductHelper *getSysmanProductHelper();
uint32_t getSubDeviceCount() override;
std::string getPciCardBusDirectoryPath(std::string realPciPath);
uint32_t getMemoryType();
@@ -77,6 +80,7 @@ class LinuxSysmanImp : public OsSysman, NEO::NonCopyableOrMovableClass {
SysmanKmdInterface *getSysmanKmdInterface() { return pSysmanKmdInterface.get(); }
protected:
std::unique_ptr<SysmanProductHelper> pSysmanProductHelper;
std::unique_ptr<SysmanKmdInterface> pSysmanKmdInterface;
FsAccess *pFsAccess = nullptr;
ProcfsAccess *pProcfsAccess = nullptr;

View File

@@ -12,4 +12,8 @@ if(UNIX)
${CMAKE_CURRENT_SOURCE_DIR}/sysman_kmd_interface.h
${CMAKE_CURRENT_SOURCE_DIR}/sysman_fs_access_interface.h
)
add_subdirectories()
endif()

View File

@@ -0,0 +1,17 @@
#
# Copyright (C) 2023 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
target_sources(${L0_STATIC_LIB_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper.h
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_hw.h
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_hw.inl
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper.cpp
)
add_subdirectories()

View File

@@ -0,0 +1,14 @@
#
# Copyright (C) 2023 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(SUPPORT_DG1)
target_sources(${L0_STATIC_LIB_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/enable_sysman_product_helper_dg1.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_dg1.cpp
)
endif()

View File

@@ -0,0 +1,18 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h"
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.h"
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.inl"
namespace L0 {
namespace Sysman {
static EnableSysmanProductHelper<IGFX_DG1> enableDG1;
} // namespace Sysman
} // namespace L0

View File

@@ -0,0 +1,22 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h"
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.h"
namespace L0 {
namespace Sysman {
constexpr static auto gfxProduct = IGFX_DG1;
template <>
ze_result_t SysmanProductHelperHw<gfxProduct>::getMemoryProperties(zes_mem_properties_t *pProperties, const LinuxSysmanImp *pLinuxSysmanImp) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
} // namespace Sysman
} // namespace L0

View File

@@ -0,0 +1,14 @@
#
# Copyright (C) 2023 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(SUPPORT_DG2)
target_sources(${L0_STATIC_LIB_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/enable_sysman_product_helper_dg2.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_dg2.cpp
)
endif()

View File

@@ -0,0 +1,18 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h"
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.h"
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.inl"
namespace L0 {
namespace Sysman {
static EnableSysmanProductHelper<IGFX_DG2> enableDG2;
} // namespace Sysman
} // namespace L0

View File

@@ -0,0 +1,22 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h"
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.h"
namespace L0 {
namespace Sysman {
constexpr static auto gfxProduct = IGFX_DG2;
template <>
ze_result_t SysmanProductHelperHw<gfxProduct>::getMemoryBandwidth(zes_mem_bandwidth_t *pBandwidth, const LinuxSysmanImp *pLinuxSysmanImp) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
} // namespace Sysman
} // namespace L0

View File

@@ -0,0 +1,13 @@
#
# Copyright (C) 2023 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(SUPPORT_PVC)
target_sources(${L0_STATIC_LIB_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/enable_sysman_product_helper_pvc.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_pvc.cpp
)
endif()

View File

@@ -0,0 +1,18 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h"
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.h"
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.inl"
namespace L0 {
namespace Sysman {
static EnableSysmanProductHelper<IGFX_PVC> enablePVC;
} // namespace Sysman
} // namespace L0

View File

@@ -0,0 +1,27 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h"
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.h"
namespace L0 {
namespace Sysman {
constexpr static auto gfxProduct = IGFX_PVC;
template <>
ze_result_t SysmanProductHelperHw<gfxProduct>::getMemoryProperties(zes_mem_properties_t *pProperties, const LinuxSysmanImp *pLinuxSysmanImp) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
template <>
ze_result_t SysmanProductHelperHw<gfxProduct>::getMemoryBandwidth(zes_mem_bandwidth_t *pBandwidth, const LinuxSysmanImp *pLinuxSysmanImp) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
} // namespace Sysman
} // namespace L0

View File

@@ -0,0 +1,16 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h"
namespace L0 {
namespace Sysman {
SysmanProductHelperCreateFunctionType SysmanProductHelperFactory[IGFX_MAX_PRODUCT] = {};
}
} // namespace L0

View File

@@ -0,0 +1,46 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include <level_zero/ze_api.h>
#include <level_zero/zes_api.h>
#include "igfxfmid.h"
#include <memory>
namespace L0 {
namespace Sysman {
class SysmanProductHelper;
class LinuxSysmanImp;
using SysmanProductHelperCreateFunctionType = std::unique_ptr<SysmanProductHelper> (*)();
extern SysmanProductHelperCreateFunctionType SysmanProductHelperFactory[IGFX_MAX_PRODUCT];
class SysmanProductHelper {
public:
static std::unique_ptr<SysmanProductHelper> create(PRODUCT_FAMILY product) {
auto productHelperCreateFunction = SysmanProductHelperFactory[product];
if (productHelperCreateFunction == nullptr) {
return nullptr;
}
auto productHelper = productHelperCreateFunction();
return productHelper;
}
virtual ze_result_t getMemoryProperties(zes_mem_properties_t *pProperties, const LinuxSysmanImp *pLinuxSysmanImp) = 0;
virtual ze_result_t getMemoryBandwidth(zes_mem_bandwidth_t *pBandwidth, const LinuxSysmanImp *pLinuxSysmanImp) = 0;
virtual ~SysmanProductHelper() = default;
protected:
SysmanProductHelper() = default;
};
} // namespace Sysman
} // namespace L0

View File

@@ -0,0 +1,40 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h"
namespace L0 {
namespace Sysman {
template <PRODUCT_FAMILY gfxProduct>
class SysmanProductHelperHw : public SysmanProductHelper {
public:
static std::unique_ptr<SysmanProductHelper> create() {
auto pSysmanProductHelper = std::unique_ptr<SysmanProductHelper>(new SysmanProductHelperHw());
return pSysmanProductHelper;
}
ze_result_t getMemoryProperties(zes_mem_properties_t *pProperties, const LinuxSysmanImp *pLinuxSysmanImp) override;
ze_result_t getMemoryBandwidth(zes_mem_bandwidth_t *pBandwidth, const LinuxSysmanImp *pLinuxSysmanImp) override;
~SysmanProductHelperHw() override = default;
protected:
SysmanProductHelperHw() = default;
};
template <PRODUCT_FAMILY gfxProduct>
struct EnableSysmanProductHelper {
EnableSysmanProductHelper() {
auto sysmanProductHelperCreateFunction = SysmanProductHelperHw<gfxProduct>::create;
SysmanProductHelperFactory[gfxProduct] = sysmanProductHelperCreateFunction;
}
};
} // namespace Sysman
} // namespace L0

View File

@@ -0,0 +1,25 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h"
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.h"
namespace L0 {
namespace Sysman {
template <PRODUCT_FAMILY gfxProduct>
ze_result_t SysmanProductHelperHw<gfxProduct>::getMemoryProperties(zes_mem_properties_t *pProperties, const LinuxSysmanImp *pLinuxSysmanImp) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
template <PRODUCT_FAMILY gfxProduct>
ze_result_t SysmanProductHelperHw<gfxProduct>::getMemoryBandwidth(zes_mem_bandwidth_t *pBandwidth, const LinuxSysmanImp *pLinuxSysmanImp) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
} // namespace Sysman
} // namespace L0

View File

@@ -5,6 +5,7 @@
*
*/
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h"
#include "level_zero/sysman/source/sysman_device_imp.h"
#include "level_zero/sysman/test/unit_tests/sources/linux/mock_sysman_fixture.h"
#include "level_zero/sysman/test/unit_tests/sources/memory/linux/mock_memory.h"
@@ -48,6 +49,36 @@ class SysmanDeviceMemoryFixture : public SysmanDeviceFixture {
L0::Sysman::SysmanDevice *device = nullptr;
};
HWTEST2_F(SysmanDeviceMemoryFixture, GivenSysmanProductHelperInstanceWhenCallingMemoryAPIsThenErrorIsReturned, IsPVC) {
auto pSysmanProductHelper = L0::Sysman::SysmanProductHelper::create(defaultHwInfo->platform.eProductFamily);
zes_mem_properties_t properties;
ze_result_t result = pSysmanProductHelper->getMemoryProperties(&properties, static_cast<const L0::Sysman::LinuxSysmanImp *>(pLinuxSysmanImp));
EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
zes_mem_bandwidth_t bandwidth;
result = pSysmanProductHelper->getMemoryBandwidth(&bandwidth, static_cast<const L0::Sysman::LinuxSysmanImp *>(pLinuxSysmanImp));
EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
}
HWTEST2_F(SysmanDeviceMemoryFixture, GivenSysmanProductHelperInstanceWhenCallingMemoryAPIsThenErrorIsReturned, IsDG1) {
auto pSysmanProductHelper = L0::Sysman::SysmanProductHelper::create(defaultHwInfo->platform.eProductFamily);
zes_mem_properties_t properties;
ze_result_t result = pSysmanProductHelper->getMemoryProperties(&properties, static_cast<const L0::Sysman::LinuxSysmanImp *>(pLinuxSysmanImp));
EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
zes_mem_bandwidth_t bandwidth;
result = pSysmanProductHelper->getMemoryBandwidth(&bandwidth, static_cast<const L0::Sysman::LinuxSysmanImp *>(pLinuxSysmanImp));
EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
}
HWTEST2_F(SysmanDeviceMemoryFixture, GivenSysmanProductHelperInstanceWhenCallingMemoryAPIsThenErrorIsReturned, IsDG2) {
auto pSysmanProductHelper = L0::Sysman::SysmanProductHelper::create(defaultHwInfo->platform.eProductFamily);
zes_mem_properties_t properties;
ze_result_t result = pSysmanProductHelper->getMemoryProperties(&properties, static_cast<const L0::Sysman::LinuxSysmanImp *>(pLinuxSysmanImp));
EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
zes_mem_bandwidth_t bandwidth;
result = pSysmanProductHelper->getMemoryBandwidth(&bandwidth, static_cast<const L0::Sysman::LinuxSysmanImp *>(pLinuxSysmanImp));
EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
}
TEST_F(SysmanDeviceMemoryFixture, GivenComponentCountZeroWhenEnumeratingMemoryModulesWithLocalMemorySupportThenValidCountIsReturned) {
setLocalSupportedAndReinit(false);
uint32_t count = 0;