Detect metrics library new name

Linux library name changing from libmd.so.1 to libigdmd.so.1

Related-To: LOCI-3159

Signed-off-by: Matias Cabral <matias.a.cabral@intel.com>
This commit is contained in:
Matias Cabral
2022-06-21 13:01:12 +00:00
committed by Compute-Runtime-Automation
parent c90f3b3c93
commit 9c1c24e35a
6 changed files with 35 additions and 12 deletions

View File

@@ -18,7 +18,11 @@
namespace L0 {
const char *MetricEnumeration::getMetricsDiscoveryFilename() { return "libmd.so.1"; }
void MetricEnumeration::getMetricsDiscoveryFilename(std::vector<const char *> &names) const {
names.clear();
names.push_back("libigdmd.so.1");
names.push_back("libmd.so.1");
}
bool MetricEnumeration::getAdapterId(uint32_t &adapterMajor, uint32_t &adapterMinor) {

View File

@@ -91,18 +91,29 @@ ze_result_t MetricEnumeration::initialize() {
ze_result_t MetricEnumeration::loadMetricsDiscovery() {
// Load library.
hMetricsDiscovery.reset(OaMetricSourceImp::osLibraryLoadFunction(getMetricsDiscoveryFilename()));
std::vector<const char *> libnames;
getMetricsDiscoveryFilename(libnames);
// Load exported functions.
if (hMetricsDiscovery) {
openAdapterGroup = reinterpret_cast<MetricsDiscovery::OpenAdapterGroup_fn>(
hMetricsDiscovery->getProcAddress("OpenAdapterGroup"));
for (auto &name : libnames) {
hMetricsDiscovery.reset(OaMetricSourceImp::osLibraryLoadFunction(name));
// Load exported functions.
if (hMetricsDiscovery) {
openAdapterGroup = reinterpret_cast<MetricsDiscovery::OpenAdapterGroup_fn>(
hMetricsDiscovery->getProcAddress("OpenAdapterGroup"));
}
if (openAdapterGroup == nullptr) {
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "cannot load %s exported functions\n", name);
} else {
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "loaded %s exported functions\n", name);
break;
}
}
if (openAdapterGroup == nullptr) {
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "cannot load %s exported functions\n", MetricEnumeration::getMetricsDiscoveryFilename());
cleanupMetricsDiscovery();
return ZE_RESULT_ERROR_NOT_AVAILABLE;
return ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE;
}
// Return success if exported functions have been loaded.

View File

@@ -28,7 +28,7 @@ struct MetricEnumeration {
virtual bool isInitialized();
virtual ze_result_t loadMetricsDiscovery();
static const char *getMetricsDiscoveryFilename();
void getMetricsDiscoveryFilename(std::vector<const char *> &names) const;
protected:
ze_result_t initialize();

View File

@@ -75,7 +75,7 @@ bool OaMetricSourceImp::loadDependencies() {
// Set metric context initialization state.
setInitializationState(result
? ZE_RESULT_SUCCESS
: ZE_RESULT_ERROR_UNKNOWN);
: ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE);
return result;
}

View File

@@ -22,7 +22,10 @@
namespace L0 {
const char *MetricEnumeration::getMetricsDiscoveryFilename() { return METRICS_DISCOVERY_NAME; }
void MetricEnumeration::getMetricsDiscoveryFilename(std::vector<const char *> &names) const {
names.clear();
names.push_back(METRICS_DISCOVERY_NAME);
}
bool MetricEnumeration::getAdapterId(uint32_t &major, uint32_t &minor) {