Metric Api: Return apprioprate error when dependencies not met

Change-Id: Ie47a69c4bf80004f7fbc1b91e2025d498e4bda6a
Signed-off-by: Robert Krzemien <robert.krzemien@intel.com>
This commit is contained in:
Robert Krzemien
2020-07-21 16:41:01 +02:00
committed by sys_ocldev
parent a0c22dec2d
commit 59ffe4ba4b
3 changed files with 11 additions and 5 deletions

View File

@@ -165,7 +165,7 @@ void MetricContext::enableMetricApi(ze_result_t &result) {
}
if (!isMetricApiAvailable()) {
result = ZE_RESULT_ERROR_UNKNOWN;
result = static_cast<ze_result_t>(0x70020000);
return;
}
@@ -188,7 +188,7 @@ void MetricContext::enableMetricApi(ze_result_t &result) {
for (auto deviceHandle : devices) {
Device *device = L0::Device::fromHandle(deviceHandle);
if (!device->getMetricContext().loadDependencies()) {
result = ZE_RESULT_ERROR_UNKNOWN;
result = static_cast<ze_result_t>(0x70020000);
return;
}
}
@@ -207,12 +207,14 @@ bool MetricContext::isMetricApiAvailable() {
// Check Metrics Discovery availability.
library.reset(NEO::OsLibrary::load(MetricEnumeration::getMetricsDiscoveryFilename()));
if (library == nullptr) {
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Unable to find metrics discovery %s\n", MetricEnumeration::getMetricsDiscoveryFilename());
return false;
}
// Check Metrics Library availability.
library.reset(NEO::OsLibrary::load(MetricsLibrary::getFilename()));
if (library == nullptr) {
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Unable to find metrics library %s\n", MetricsLibrary::getFilename());
return false;
}

View File

@@ -84,6 +84,7 @@ ze_result_t MetricEnumeration::loadMetricsDiscovery() {
if (openMetricsDevice == nullptr || closeMetricsDevice == nullptr ||
openMetricsDeviceFromFile == nullptr) {
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "cannot load %s exported functions\n", MetricEnumeration::getMetricsDiscoveryFilename());
cleanupMetricsDiscovery();
return ZE_RESULT_ERROR_UNKNOWN;
}

View File

@@ -191,10 +191,13 @@ bool MetricsLibrary::load() {
handle->getProcAddress(METRICS_LIBRARY_CONTEXT_DELETE_1_0));
}
if (contextCreateFunction == nullptr || contextDeleteFunction == nullptr) {
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "cannot load %s exported functions\n", MetricsLibrary::getFilename());
return false;
}
// Return success if exported functions have been loaded.
const bool result = contextCreateFunction && contextDeleteFunction;
DEBUG_BREAK_IF(!result);
return result;
return true;
}
bool MetricsLibrary::createContext() {