mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 23:03:02 +08:00
refactor: don't call OsLibrary::load directly, use function pointer
this allows mocking this call in ULT Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
006285105d
commit
579af57161
@@ -114,7 +114,7 @@ ze_result_t MetricEnumeration::loadMetricsDiscovery() {
|
||||
getMetricsDiscoveryFilename(libnames);
|
||||
|
||||
for (auto &name : libnames) {
|
||||
hMetricsDiscovery.reset(OaMetricSourceImp::osLibraryLoadFunction(name));
|
||||
hMetricsDiscovery.reset(NEO::OsLibrary::loadFunc(name));
|
||||
|
||||
// Load exported functions.
|
||||
if (hMetricsDiscovery) {
|
||||
|
||||
@@ -179,7 +179,7 @@ void MetricsLibrary::release() {
|
||||
|
||||
bool MetricsLibrary::load() {
|
||||
// Load library.
|
||||
handle = OaMetricSourceImp::osLibraryLoadFunction(getFilename());
|
||||
handle = NEO::OsLibrary::loadFunc(getFilename());
|
||||
|
||||
// Load exported functions.
|
||||
if (handle) {
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
|
||||
namespace L0 {
|
||||
|
||||
OaMetricSourceImp::OsLibraryLoadPtr OaMetricSourceImp::osLibraryLoadFunction(NEO::OsLibrary::load);
|
||||
|
||||
std::unique_ptr<OaMetricSourceImp> OaMetricSourceImp::create(const MetricDeviceContext &metricDeviceContext) {
|
||||
return std::unique_ptr<OaMetricSourceImp>(new (std::nothrow) OaMetricSourceImp(metricDeviceContext));
|
||||
}
|
||||
|
||||
@@ -9,10 +9,6 @@
|
||||
|
||||
#include "level_zero/tools/source/metrics/metric.h"
|
||||
|
||||
namespace NEO {
|
||||
class OsLibrary;
|
||||
} // namespace NEO
|
||||
|
||||
namespace L0 {
|
||||
struct MetricEnumeration;
|
||||
struct MetricsLibrary;
|
||||
@@ -57,8 +53,6 @@ class OaMetricSourceImp : public MetricSource {
|
||||
static std::unique_ptr<OaMetricSourceImp> create(const MetricDeviceContext &metricDeviceContext);
|
||||
void setMetricOsInterface(std::unique_ptr<MetricOAOsInterface> &metricOAOsInterface);
|
||||
MetricOAOsInterface *getMetricOsInterface() { return metricOAOsInterface.get(); }
|
||||
using OsLibraryLoadPtr = std::add_pointer<NEO::OsLibrary *(const std::string &)>::type;
|
||||
static OsLibraryLoadPtr osLibraryLoadFunction;
|
||||
|
||||
protected:
|
||||
ze_result_t initializationState = ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022-2023 Intel Corporation
|
||||
* Copyright (C) 2022-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -61,8 +61,6 @@ static void progressFunc(uint32_t done, uint32_t total, void *ctx) {
|
||||
PRINT_DEBUG_STRING(NEO::debugManager.flags.PrintDebugMessages.get(), stdout, "Progess: %d/%d:%d/%\n", done, total, percent);
|
||||
}
|
||||
|
||||
FirmwareUtilImp::OsLibraryLoadPtr FirmwareUtilImp::osLibraryLoadFunction(NEO::OsLibrary::load);
|
||||
|
||||
ze_result_t FirmwareUtilImp::getFirstDevice(igsc_device_info *info) {
|
||||
igsc_device_iterator *iter;
|
||||
int ret = deviceIteratorCreate(&iter);
|
||||
@@ -194,7 +192,7 @@ FirmwareUtilImp::~FirmwareUtilImp() {
|
||||
FirmwareUtil *FirmwareUtil::create(uint16_t domain, uint8_t bus, uint8_t device, uint8_t function) {
|
||||
FirmwareUtilImp *pFwUtilImp = new FirmwareUtilImp(domain, bus, device, function);
|
||||
UNRECOVERABLE_IF(nullptr == pFwUtilImp);
|
||||
pFwUtilImp->libraryHandle = FirmwareUtilImp::osLibraryLoadFunction(FirmwareUtilImp::fwUtilLibraryName);
|
||||
pFwUtilImp->libraryHandle = NEO::OsLibrary::loadFunc(FirmwareUtilImp::fwUtilLibraryName);
|
||||
if (pFwUtilImp->libraryHandle == nullptr || pFwUtilImp->loadEntryPoints() == false || pFwUtilImp->fwDeviceInit() != ZE_RESULT_SUCCESS) {
|
||||
if (nullptr != pFwUtilImp->libraryHandle) {
|
||||
delete pFwUtilImp->libraryHandle;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022-2023 Intel Corporation
|
||||
* Copyright (C) 2022-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -127,8 +127,6 @@ class FirmwareUtilImp : public FirmwareUtil, NEO::NonCopyableOrMovableClass {
|
||||
ze_result_t fwFlashIafPsc(void *pImage, uint32_t size);
|
||||
ze_result_t fwCallGetstatusExt(uint32_t &supportedTests, uint32_t &ifrApplied, uint32_t &prevErrors, uint32_t &pendingReset);
|
||||
|
||||
using OsLibraryLoadPtr = std::add_pointer<NEO::OsLibrary *(const std::string &)>::type;
|
||||
static OsLibraryLoadPtr osLibraryLoadFunction;
|
||||
static std::string fwUtilLibraryName;
|
||||
std::string fwDevicePath{};
|
||||
struct igsc_device_handle fwDeviceHandle = {};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
* Copyright (C) 2020-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -264,7 +264,7 @@ int NlApi::nlaNestEnd(struct nl_msg *msg, struct nlattr *attr) {
|
||||
}
|
||||
|
||||
NlApi::NlApi() {
|
||||
genlLibraryHandle.reset(NEO::OsLibrary::load(std::string(libgenlFile)));
|
||||
genlLibraryHandle.reset(NEO::OsLibrary::loadFunc(std::string(libgenlFile)));
|
||||
}
|
||||
|
||||
NlApi::~NlApi() = default;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
* Copyright (C) 2022-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -79,7 +79,7 @@ UdevLibImp::~UdevLibImp(){};
|
||||
UdevLib *UdevLib::create() {
|
||||
UdevLibImp *pUdevLib = new UdevLibImp();
|
||||
UNRECOVERABLE_IF(nullptr == pUdevLib);
|
||||
pUdevLib->libraryHandle.reset(NEO::OsLibrary::load(std::string(libUdevlFile)));
|
||||
pUdevLib->libraryHandle.reset(NEO::OsLibrary::loadFunc(std::string(libUdevlFile)));
|
||||
if (pUdevLib->libraryHandle == nullptr || pUdevLib->loadEntryPoints() == false || !pUdevLib->init()) {
|
||||
delete pUdevLib;
|
||||
return nullptr;
|
||||
|
||||
Reference in New Issue
Block a user