feature: get zet_metric_global_timestamps_resolution_exp_t for OA from MDAPI
Related-To: NEO-14161 Signed-off-by: shubham kumar <shubham.kumar@intel.com>
This commit is contained in:
parent
da4a5d0389
commit
ec5283bb3b
|
@ -84,24 +84,4 @@ MetricsDiscovery::IAdapter_1_13 *getDrmMetricsAdapter(MetricEnumeration *metricE
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
MetricOALinuxImp::MetricOALinuxImp(Device &device) : device(device) {}
|
|
||||||
|
|
||||||
ze_result_t MetricOALinuxImp::getMetricsTimerResolution(uint64_t &timerResolution) {
|
|
||||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
|
||||||
|
|
||||||
const auto drm = device.getOsInterface()->getDriverModel()->as<NEO::Drm>();
|
|
||||||
int32_t timestampFrequency;
|
|
||||||
int32_t ret = drm->getOaTimestampFrequency(timestampFrequency);
|
|
||||||
if (ret < 0 || timestampFrequency == 0) {
|
|
||||||
timerResolution = 0;
|
|
||||||
result = ZE_RESULT_ERROR_UNKNOWN;
|
|
||||||
METRICS_LOG_ERR("getOATimestampFrequenc() failed errno = %d | ret = %d", errno, ret);
|
|
||||||
} else {
|
|
||||||
timerResolution = static_cast<uint64_t>(timestampFrequency);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace L0
|
} // namespace L0
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2024 Intel Corporation
|
* Copyright (C) 2024-2025 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
|
@ -17,15 +17,4 @@ struct MetricEnumeration;
|
||||||
bool getDrmAdapterId(uint32_t &adapterMajor, uint32_t &adapterMinor, Device &device);
|
bool getDrmAdapterId(uint32_t &adapterMajor, uint32_t &adapterMinor, Device &device);
|
||||||
|
|
||||||
MetricsDiscovery::IAdapter_1_13 *getDrmMetricsAdapter(MetricEnumeration *metricEnumeration);
|
MetricsDiscovery::IAdapter_1_13 *getDrmMetricsAdapter(MetricEnumeration *metricEnumeration);
|
||||||
|
|
||||||
class MetricOALinuxImp : public MetricOAOsInterface {
|
|
||||||
public:
|
|
||||||
MetricOALinuxImp(Device &device);
|
|
||||||
~MetricOALinuxImp() override = default;
|
|
||||||
ze_result_t getMetricsTimerResolution(uint64_t &timerResolution) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
Device &device;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace L0
|
} // namespace L0
|
||||||
|
|
|
@ -18,6 +18,7 @@ namespace L0 {
|
||||||
|
|
||||||
static constexpr std::string_view globalSymbolOaMaxBufferSize = "OABufferMaxSize";
|
static constexpr std::string_view globalSymbolOaMaxBufferSize = "OABufferMaxSize";
|
||||||
static constexpr std::string_view globalSymbolOaMaxTimestamp = "MaxTimestamp";
|
static constexpr std::string_view globalSymbolOaMaxTimestamp = "MaxTimestamp";
|
||||||
|
static constexpr std::string_view globalSymbolOaGpuTimestampFrequency = "GpuTimestampFrequency";
|
||||||
|
|
||||||
struct MetricEnumeration {
|
struct MetricEnumeration {
|
||||||
MetricEnumeration(OaMetricSourceImp &metricSource);
|
MetricEnumeration(OaMetricSourceImp &metricSource);
|
||||||
|
|
|
@ -28,7 +28,6 @@ std::unique_ptr<OaMetricSourceImp> OaMetricSourceImp::create(const MetricDeviceC
|
||||||
OaMetricSourceImp::OaMetricSourceImp(const MetricDeviceContext &metricDeviceContext) : metricDeviceContext(metricDeviceContext),
|
OaMetricSourceImp::OaMetricSourceImp(const MetricDeviceContext &metricDeviceContext) : metricDeviceContext(metricDeviceContext),
|
||||||
metricEnumeration(std::unique_ptr<MetricEnumeration>(new(std::nothrow) MetricEnumeration(*this))),
|
metricEnumeration(std::unique_ptr<MetricEnumeration>(new(std::nothrow) MetricEnumeration(*this))),
|
||||||
metricsLibrary(std::unique_ptr<MetricsLibrary>(new(std::nothrow) MetricsLibrary(*this))) {
|
metricsLibrary(std::unique_ptr<MetricsLibrary>(new(std::nothrow) MetricsLibrary(*this))) {
|
||||||
metricOAOsInterface = MetricOAOsInterface::create(metricDeviceContext.getDevice());
|
|
||||||
activationTracker = std::make_unique<MultiDomainDeferredActivationTracker>(metricDeviceContext.getSubDeviceIndex());
|
activationTracker = std::make_unique<MultiDomainDeferredActivationTracker>(metricDeviceContext.getSubDeviceIndex());
|
||||||
type = MetricSource::metricSourceTypeOa;
|
type = MetricSource::metricSourceTypeOa;
|
||||||
}
|
}
|
||||||
|
@ -40,13 +39,12 @@ void OaMetricSourceImp::enable() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ze_result_t OaMetricSourceImp::getTimerResolution(uint64_t &resolution) {
|
ze_result_t OaMetricSourceImp::getTimerResolution(uint64_t &resolution) {
|
||||||
|
if (!metricEnumeration->readGlobalSymbol(globalSymbolOaGpuTimestampFrequency.data(), resolution)) {
|
||||||
ze_result_t result = getMetricOsInterface()->getMetricsTimerResolution(resolution);
|
|
||||||
if (result != ZE_RESULT_SUCCESS) {
|
|
||||||
resolution = 0;
|
resolution = 0;
|
||||||
|
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return ZE_RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
ze_result_t OaMetricSourceImp::getTimestampValidBits(uint64_t &validBits) {
|
ze_result_t OaMetricSourceImp::getTimestampValidBits(uint64_t &validBits) {
|
||||||
|
@ -171,10 +169,6 @@ bool OaMetricSourceImp::isImplicitScalingCapable() const {
|
||||||
return metricDeviceContext.isImplicitScalingCapable();
|
return metricDeviceContext.isImplicitScalingCapable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OaMetricSourceImp::setMetricOsInterface(std::unique_ptr<MetricOAOsInterface> &metricOAOsInterface) {
|
|
||||||
this->metricOAOsInterface = std::move(metricOAOsInterface);
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t OaMetricSourceImp::activateMetricGroupsPreferDeferred(uint32_t count,
|
ze_result_t OaMetricSourceImp::activateMetricGroupsPreferDeferred(uint32_t count,
|
||||||
zet_metric_group_handle_t *phMetricGroups) {
|
zet_metric_group_handle_t *phMetricGroups) {
|
||||||
activationTracker->activateMetricGroupsDeferred(count, phMetricGroups);
|
activationTracker->activateMetricGroupsDeferred(count, phMetricGroups);
|
||||||
|
|
|
@ -51,8 +51,6 @@ class OaMetricSourceImp : public MetricSource {
|
||||||
bool isImplicitScalingCapable() const;
|
bool isImplicitScalingCapable() const;
|
||||||
const MetricDeviceContext &getMetricDeviceContext() const { return metricDeviceContext; }
|
const MetricDeviceContext &getMetricDeviceContext() const { return metricDeviceContext; }
|
||||||
static std::unique_ptr<OaMetricSourceImp> create(const MetricDeviceContext &metricDeviceContext);
|
static std::unique_ptr<OaMetricSourceImp> create(const MetricDeviceContext &metricDeviceContext);
|
||||||
void setMetricOsInterface(std::unique_ptr<MetricOAOsInterface> &metricOAOsInterface);
|
|
||||||
MetricOAOsInterface *getMetricOsInterface() { return metricOAOsInterface.get(); }
|
|
||||||
ze_result_t metricGroupCreateFromMetric(const char *pName, const char *pDescription,
|
ze_result_t metricGroupCreateFromMetric(const char *pName, const char *pDescription,
|
||||||
zet_metric_group_sampling_type_flags_t samplingType, zet_metric_handle_t hMetric,
|
zet_metric_group_sampling_type_flags_t samplingType, zet_metric_handle_t hMetric,
|
||||||
zet_metric_group_handle_t *phMetricGroup);
|
zet_metric_group_handle_t *phMetricGroup);
|
||||||
|
@ -81,7 +79,6 @@ class OaMetricSourceImp : public MetricSource {
|
||||||
std::unique_ptr<MetricsLibrary> metricsLibrary;
|
std::unique_ptr<MetricsLibrary> metricsLibrary;
|
||||||
MetricStreamer *pMetricStreamer = nullptr;
|
MetricStreamer *pMetricStreamer = nullptr;
|
||||||
bool useCompute = false;
|
bool useCompute = false;
|
||||||
std::unique_ptr<MetricOAOsInterface> metricOAOsInterface = nullptr;
|
|
||||||
std::unique_ptr<MultiDomainDeferredActivationTracker> activationTracker{};
|
std::unique_ptr<MultiDomainDeferredActivationTracker> activationTracker{};
|
||||||
ze_result_t getTimerResolution(uint64_t &resolution);
|
ze_result_t getTimerResolution(uint64_t &resolution);
|
||||||
ze_result_t getTimestampValidBits(uint64_t &validBits);
|
ze_result_t getTimestampValidBits(uint64_t &validBits);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2022-2024 Intel Corporation
|
* Copyright (C) 2022-2025 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
|
@ -40,10 +40,4 @@ class MetricIpSamplingOsInterface : public MetricOsInterface {
|
||||||
uint32_t unitReportSize = 64u;
|
uint32_t unitReportSize = 64u;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MetricOAOsInterface : public MetricOsInterface {
|
|
||||||
public:
|
|
||||||
~MetricOAOsInterface() override = default;
|
|
||||||
static std::unique_ptr<MetricOAOsInterface> create(Device &device);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace L0
|
} // namespace L0
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2024 Intel Corporation
|
* Copyright (C) 2024-2025 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
|
@ -19,8 +19,4 @@ MetricsDiscovery::IAdapter_1_13 *MetricEnumeration::getMetricsAdapter() {
|
||||||
return getDrmMetricsAdapter(this);
|
return getDrmMetricsAdapter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<MetricOAOsInterface> MetricOAOsInterface::create(Device &device) {
|
|
||||||
return std::make_unique<MetricOALinuxImp>(device);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace L0
|
} // namespace L0
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2024 Intel Corporation
|
* Copyright (C) 2024-2025 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
|
@ -35,14 +35,4 @@ MetricsDiscovery::IAdapter_1_13 *MetricEnumeration::getMetricsAdapter() {
|
||||||
else
|
else
|
||||||
return getDrmMetricsAdapter(this);
|
return getDrmMetricsAdapter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<MetricOAOsInterface> MetricOAOsInterface::create(Device &device) {
|
|
||||||
auto osInterface = device.getNEODevice()->getRootDeviceEnvironment().osInterface.get();
|
|
||||||
|
|
||||||
if (osInterface && osInterface->getDriverModel()->getDriverModelType() == NEO::DriverModelType::wddm)
|
|
||||||
return std::make_unique<MetricOAWindowsImp>();
|
|
||||||
else
|
|
||||||
return std::make_unique<MetricOALinuxImp>(device);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace L0
|
} // namespace L0
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2024 Intel Corporation
|
* Copyright (C) 2024-2025 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
|
@ -19,8 +19,4 @@ MetricsDiscovery::IAdapter_1_13 *MetricEnumeration::getMetricsAdapter() {
|
||||||
return getDrmMetricsAdapter(this);
|
return getDrmMetricsAdapter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<MetricOAOsInterface> MetricOAOsInterface::create(Device &device) {
|
|
||||||
return std::make_unique<MetricOALinuxImp>(device);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace L0
|
} // namespace L0
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2024 Intel Corporation
|
* Copyright (C) 2024-2025 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
|
@ -19,8 +19,4 @@ MetricsDiscovery::IAdapter_1_13 *MetricEnumeration::getMetricsAdapter() {
|
||||||
return getWddmMetricsAdapter(this);
|
return getWddmMetricsAdapter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<MetricOAOsInterface> MetricOAOsInterface::create(Device &device) {
|
|
||||||
return std::make_unique<MetricOAWindowsImp>();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace L0
|
} // namespace L0
|
||||||
|
|
|
@ -56,9 +56,4 @@ MetricsDiscovery::IAdapter_1_13 *getWddmMetricsAdapter(MetricEnumeration *metric
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ze_result_t MetricOAWindowsImp::getMetricsTimerResolution(uint64_t &timerResolution) {
|
|
||||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace L0
|
} // namespace L0
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2024 Intel Corporation
|
* Copyright (C) 2024-2025 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
|
@ -19,11 +19,4 @@ bool getWddmAdapterId(uint32_t &major, uint32_t &minor, Device &device);
|
||||||
|
|
||||||
MetricsDiscovery::IAdapter_1_13 *getWddmMetricsAdapter(MetricEnumeration *metricEnumeration);
|
MetricsDiscovery::IAdapter_1_13 *getWddmMetricsAdapter(MetricEnumeration *metricEnumeration);
|
||||||
|
|
||||||
class MetricOAWindowsImp : public MetricOAOsInterface {
|
|
||||||
public:
|
|
||||||
MetricOAWindowsImp() = default;
|
|
||||||
~MetricOAWindowsImp() override = default;
|
|
||||||
ze_result_t getMetricsTimerResolution(uint64_t &timerResolution) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace L0
|
} // namespace L0
|
||||||
|
|
|
@ -707,6 +707,97 @@ bool testExportData() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////
|
||||||
|
/// metricGetTimestampTest
|
||||||
|
//////////////////////////
|
||||||
|
bool metricGetTimestampTest() {
|
||||||
|
// This test verifies zetMetricGroupGetGlobalTimestampsExp for all devices OR specific device
|
||||||
|
bool status = true;
|
||||||
|
|
||||||
|
zmu::TestMachineConfiguration machineConfig = {};
|
||||||
|
zmu::getTestMachineConfiguration(machineConfig);
|
||||||
|
|
||||||
|
auto metricTimestamp = [](uint32_t deviceId, int32_t subDeviceId, std::string &metricGroupName) {
|
||||||
|
auto metricGroupGetGlobalTimestamp = [](zet_metric_group_handle_t metricGroup, ze_bool_t synchronizedWithHost) {
|
||||||
|
uint64_t globalTimestamp = 0;
|
||||||
|
uint64_t metricTimestamp = 0;
|
||||||
|
auto status = zetMetricGroupGetGlobalTimestampsExp(metricGroup, synchronizedWithHost, &globalTimestamp, &metricTimestamp);
|
||||||
|
if (status != ZE_RESULT_SUCCESS) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
if (synchronizedWithHost) {
|
||||||
|
LOG(zmu::LogLevel::INFO) << "[Host|Metric] timestamp is " << globalTimestamp << " | " << metricTimestamp << std::endl;
|
||||||
|
} else {
|
||||||
|
LOG(zmu::LogLevel::INFO) << "[Device|Metric] timestamp is " << globalTimestamp << " | " << metricTimestamp << std::endl;
|
||||||
|
}
|
||||||
|
return ZE_RESULT_SUCCESS;
|
||||||
|
};
|
||||||
|
|
||||||
|
auto metricGroupGetExtendedTimestampResolutionProperties = [](zet_metric_group_handle_t metricGroup) {
|
||||||
|
const zet_metric_group_handle_t metricGroupHandle = metricGroup;
|
||||||
|
zet_metric_group_properties_t metricGroupProperties = {};
|
||||||
|
zet_metric_global_timestamps_resolution_exp_t metricGlobalTimestampsResolution = {};
|
||||||
|
metricGlobalTimestampsResolution.stype = ZET_STRUCTURE_TYPE_METRIC_GLOBAL_TIMESTAMPS_RESOLUTION_EXP;
|
||||||
|
metricGroupProperties.pNext = &metricGlobalTimestampsResolution;
|
||||||
|
auto status = zetMetricGroupGetProperties(metricGroupHandle, &metricGroupProperties);
|
||||||
|
if (status != ZE_RESULT_SUCCESS) {
|
||||||
|
LOG(zmu::LogLevel::DEBUG) << "zetMetricGroupGetProperties status: " << status << std::endl;
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG(zmu::LogLevel::INFO) << "METRIC GROUP[" << metricGroupProperties.name << "]: "
|
||||||
|
<< "desc: " << metricGroupProperties.description << "\n";
|
||||||
|
LOG(zmu::LogLevel::INFO) << "\t -> timerResolution: " << metricGlobalTimestampsResolution.timerResolution << " | "
|
||||||
|
<< "timestampValidBits: " << metricGlobalTimestampsResolution.timestampValidBits << std::endl;
|
||||||
|
return ZE_RESULT_SUCCESS;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!zmu::isDeviceAvailable(deviceId, subDeviceId)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG(zmu::LogLevel::INFO) << "Running zetMetricGroupGetGlobalTimestampsExp() : Device [" << deviceId << ", " << subDeviceId << " ] : Metric Group :" << metricGroupName.c_str() << "\n";
|
||||||
|
|
||||||
|
std::unique_ptr<SingleDeviceSingleQueueExecutionCtxt> executionCtxt =
|
||||||
|
std::make_unique<SingleDeviceSingleQueueExecutionCtxt>(deviceId, subDeviceId);
|
||||||
|
|
||||||
|
auto metricGroup = zmu::findMetricGroup(metricGroupName.c_str(),
|
||||||
|
static_cast<zet_metric_group_sampling_type_flag_t>(ZET_METRIC_GROUP_SAMPLING_TYPE_FLAG_TIME_BASED | ZET_METRIC_GROUP_SAMPLING_TYPE_FLAG_EVENT_BASED | ZET_METRIC_GROUP_SAMPLING_TYPE_FLAG_EXP_TRACER_BASED), // NOLINT(clang-analyzer-optin.core.EnumCastOutOfRange), NEO-12901
|
||||||
|
executionCtxt->getDeviceHandle(0));
|
||||||
|
|
||||||
|
ze_result_t status;
|
||||||
|
status = metricGroupGetGlobalTimestamp(metricGroup, true);
|
||||||
|
if (status != ZE_RESULT_SUCCESS) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
status = metricGroupGetGlobalTimestamp(metricGroup, false);
|
||||||
|
if (status != ZE_RESULT_SUCCESS) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = metricGroupGetExtendedTimestampResolutionProperties(metricGroup);
|
||||||
|
return status == ZE_RESULT_SUCCESS;
|
||||||
|
};
|
||||||
|
|
||||||
|
auto testSettings = zmu::TestSettings::get();
|
||||||
|
|
||||||
|
if (testSettings->deviceId.get() == -1) {
|
||||||
|
for (uint32_t deviceId = 0; deviceId < machineConfig.deviceCount; deviceId++) {
|
||||||
|
// Run for all subdevices
|
||||||
|
for (uint32_t subDeviceId = 0; subDeviceId < machineConfig.devices[deviceId].subDeviceCount; subDeviceId++) {
|
||||||
|
status &= metricTimestamp(deviceId, subDeviceId, testSettings->metricGroupName.get());
|
||||||
|
}
|
||||||
|
// Run for root device
|
||||||
|
status &= metricTimestamp(deviceId, -1, testSettings->metricGroupName.get());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Run for specific device
|
||||||
|
status &= metricTimestamp(testSettings->deviceId.get(), testSettings->subDeviceId.get(), testSettings->metricGroupName.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
ZELLO_METRICS_ADD_TEST(queryTest)
|
ZELLO_METRICS_ADD_TEST(queryTest)
|
||||||
ZELLO_METRICS_ADD_TEST(streamTest)
|
ZELLO_METRICS_ADD_TEST(streamTest)
|
||||||
ZELLO_METRICS_ADD_TEST(streamMultiMetricDomainTest)
|
ZELLO_METRICS_ADD_TEST(streamMultiMetricDomainTest)
|
||||||
|
@ -718,4 +809,5 @@ ZELLO_METRICS_ADD_TEST(streamPowerFrequencyTest)
|
||||||
ZELLO_METRICS_ADD_TEST(displayAllMetricGroups)
|
ZELLO_METRICS_ADD_TEST(displayAllMetricGroups)
|
||||||
ZELLO_METRICS_ADD_TEST(queryImmediateCommandListTest)
|
ZELLO_METRICS_ADD_TEST(queryImmediateCommandListTest)
|
||||||
ZELLO_METRICS_ADD_TEST(collectIndefinitely)
|
ZELLO_METRICS_ADD_TEST(collectIndefinitely)
|
||||||
ZELLO_METRICS_ADD_TEST(testExportData)
|
ZELLO_METRICS_ADD_TEST(testExportData)
|
||||||
|
ZELLO_METRICS_ADD_TEST(metricGetTimestampTest)
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2022-2024 Intel Corporation
|
* Copyright (C) 2022-2025 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
|
@ -24,12 +24,14 @@ void createL0() {
|
||||||
|
|
||||||
ze_driver_handle_t getDriver() {
|
ze_driver_handle_t getDriver() {
|
||||||
uint32_t driverCount = 0;
|
uint32_t driverCount = 0;
|
||||||
ze_driver_handle_t driverHandle = {};
|
std::vector<ze_driver_handle_t> driverHandles = {};
|
||||||
// Obtain driver.
|
// Obtain driver.
|
||||||
VALIDATECALL(zeDriverGet(&driverCount, nullptr));
|
VALIDATECALL(zeDriverGet(&driverCount, nullptr));
|
||||||
EXPECT(driverCount > 0);
|
EXPECT(driverCount > 0);
|
||||||
VALIDATECALL(zeDriverGet(&driverCount, &driverHandle));
|
driverHandles.resize(driverCount);
|
||||||
return driverHandle;
|
|
||||||
|
VALIDATECALL(zeDriverGet(&driverCount, driverHandles.data()));
|
||||||
|
return driverHandles[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
ze_context_handle_t createContext(ze_driver_handle_t &driverHandle) {
|
ze_context_handle_t createContext(ze_driver_handle_t &driverHandle) {
|
||||||
|
|
|
@ -257,32 +257,6 @@ class MetricEnumerationTestLinux : public MetricContextFixture,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(MetricEnumerationTestLinux, givenCorrectLinuxDrmAdapterWhenGettingOATimerResolutionThenReturnSuccess) {
|
|
||||||
|
|
||||||
std::unique_ptr<MetricOAOsInterface> oaOsInterface = MetricOAOsInterface::create(*device);
|
|
||||||
uint64_t timerResolution;
|
|
||||||
oaOsInterface->getMetricsTimerResolution(timerResolution);
|
|
||||||
EXPECT_EQ(oaOsInterface->getMetricsTimerResolution(timerResolution), ZE_RESULT_SUCCESS);
|
|
||||||
EXPECT_EQ(timerResolution, 123456UL);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(MetricEnumerationTestLinux, givenDrmFailureWhenGettingOATimerResolutionThenReturnError) {
|
|
||||||
|
|
||||||
std::unique_ptr<MetricOAOsInterface> oaOsInterface = MetricOAOsInterface::create(*device);
|
|
||||||
uint64_t timerResolution;
|
|
||||||
oaOsInterface->getMetricsTimerResolution(timerResolution);
|
|
||||||
auto drm = static_cast<DrmMock *>(device->getOsInterface()->getDriverModel()->as<NEO::Drm>());
|
|
||||||
drm->storedRetVal = -1;
|
|
||||||
|
|
||||||
EXPECT_EQ(oaOsInterface->getMetricsTimerResolution(timerResolution), ZE_RESULT_ERROR_UNKNOWN);
|
|
||||||
EXPECT_EQ(timerResolution, 0UL);
|
|
||||||
|
|
||||||
drm->storedRetVal = 0;
|
|
||||||
drm->storedOaTimestampFrequency = 0;
|
|
||||||
EXPECT_EQ(oaOsInterface->getMetricsTimerResolution(timerResolution), ZE_RESULT_ERROR_UNKNOWN);
|
|
||||||
EXPECT_EQ(timerResolution, 0UL);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(MetricEnumerationTestLinux, givenCorrectLinuxDrmAdapterWhenGetMetricsAdapterThenReturnSuccess) {
|
TEST_F(MetricEnumerationTestLinux, givenCorrectLinuxDrmAdapterWhenGetMetricsAdapterThenReturnSuccess) {
|
||||||
|
|
||||||
auto adapterGroupParams = TAdapterGroupParams_1_6{};
|
auto adapterGroupParams = TAdapterGroupParams_1_6{};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2020-2024 Intel Corporation
|
* Copyright (C) 2020-2025 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
|
@ -28,11 +28,7 @@ void MetricContextFixture::setUp() {
|
||||||
DeviceFixture::setUp();
|
DeviceFixture::setUp();
|
||||||
|
|
||||||
// Initialize metric api.
|
// Initialize metric api.
|
||||||
mockOAOsInterface = new MockOAOsInterface();
|
|
||||||
std::unique_ptr<MetricOAOsInterface> metricOAOsInterface =
|
|
||||||
std::unique_ptr<MetricOAOsInterface>(mockOAOsInterface);
|
|
||||||
auto &metricSource = device->getMetricDeviceContext().getMetricSource<OaMetricSourceImp>();
|
auto &metricSource = device->getMetricDeviceContext().getMetricSource<OaMetricSourceImp>();
|
||||||
metricSource.setMetricOsInterface(metricOAOsInterface);
|
|
||||||
metricSource.setInitializationState(ZE_RESULT_SUCCESS);
|
metricSource.setInitializationState(ZE_RESULT_SUCCESS);
|
||||||
|
|
||||||
mockIpSamplingOsInterface = new MockIpSamplingOsInterface();
|
mockIpSamplingOsInterface = new MockIpSamplingOsInterface();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2020-2024 Intel Corporation
|
* Copyright (C) 2020-2025 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
|
@ -239,25 +239,6 @@ class MockIpSamplingOsInterface : public MetricIpSamplingOsInterface {
|
||||||
return getMetricsTimerResolutionReturn;
|
return getMetricsTimerResolutionReturn;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
class MockOAOsInterface : public MetricOAOsInterface {
|
|
||||||
public:
|
|
||||||
~MockOAOsInterface() override = default;
|
|
||||||
ze_result_t getMetricsTimerResolutionReturn = ZE_RESULT_SUCCESS;
|
|
||||||
uint8_t failGetResolutionOnCall = 0;
|
|
||||||
uint8_t getResolutionCallCount = 0;
|
|
||||||
ze_result_t getMetricsTimerResolution(uint64_t &timerResolution) override {
|
|
||||||
ze_result_t retVal;
|
|
||||||
getResolutionCallCount++;
|
|
||||||
if ((failGetResolutionOnCall) && (getResolutionCallCount >= failGetResolutionOnCall)) {
|
|
||||||
timerResolution = 0UL;
|
|
||||||
retVal = getMetricsTimerResolutionReturn;
|
|
||||||
} else {
|
|
||||||
timerResolution = 25000000UL; // PVC as reference
|
|
||||||
retVal = ZE_RESULT_SUCCESS;
|
|
||||||
}
|
|
||||||
return retVal;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class MetricContextFixture : public DeviceFixture {
|
class MetricContextFixture : public DeviceFixture {
|
||||||
|
|
||||||
|
@ -284,7 +265,6 @@ class MetricContextFixture : public DeviceFixture {
|
||||||
MetricsDiscovery::TMetricsDeviceParams_1_2 metricsDeviceParams = {};
|
MetricsDiscovery::TMetricsDeviceParams_1_2 metricsDeviceParams = {};
|
||||||
MetricsDiscovery::TTypedValue_1_0 defaultMaximumOaBufferSize = {};
|
MetricsDiscovery::TTypedValue_1_0 defaultMaximumOaBufferSize = {};
|
||||||
void setupDefaultMocksForMetricDevice(Mock<IMetricsDevice_1_13> &metricDevice);
|
void setupDefaultMocksForMetricDevice(Mock<IMetricsDevice_1_13> &metricDevice);
|
||||||
MockOAOsInterface *mockOAOsInterface;
|
|
||||||
MockIpSamplingOsInterface *mockIpSamplingOsInterface;
|
MockIpSamplingOsInterface *mockIpSamplingOsInterface;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2020-2024 Intel Corporation
|
* Copyright (C) 2020-2025 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
|
@ -134,6 +134,9 @@ class Mock<IMetricsDevice_1_13> : public IMetricsDevice_1_13 {
|
||||||
MetricsDiscovery::TTypedValue_1_0 symbolValue = {};
|
MetricsDiscovery::TTypedValue_1_0 symbolValue = {};
|
||||||
bool forceGetSymbolByNameFail = false;
|
bool forceGetSymbolByNameFail = false;
|
||||||
bool forceGetGpuCpuTimestampsFail = false;
|
bool forceGetGpuCpuTimestampsFail = false;
|
||||||
|
bool forceGetMaxTimestampFail = false;
|
||||||
|
uint32_t failGetGpuTimestampFrequencyOnCall = 0;
|
||||||
|
uint32_t getGpuTimestampFrequencyCallCount = 0;
|
||||||
TTypedValue_1_0 *GetGlobalSymbolValueByName(const char *name) override {
|
TTypedValue_1_0 *GetGlobalSymbolValueByName(const char *name) override {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
if (forceGetSymbolByNameFail) {
|
if (forceGetSymbolByNameFail) {
|
||||||
|
@ -143,8 +146,19 @@ class Mock<IMetricsDevice_1_13> : public IMetricsDevice_1_13 {
|
||||||
symbolValue.ValueUInt32 = 1024;
|
symbolValue.ValueUInt32 = 1024;
|
||||||
found = true;
|
found = true;
|
||||||
} else if (std::strcmp(name, "MaxTimestamp") == 0) {
|
} else if (std::strcmp(name, "MaxTimestamp") == 0) {
|
||||||
|
if (forceGetMaxTimestampFail) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
symbolValue.ValueType = MetricsDiscovery::TValueType::VALUE_TYPE_UINT64;
|
symbolValue.ValueType = MetricsDiscovery::TValueType::VALUE_TYPE_UINT64;
|
||||||
symbolValue.ValueUInt64 = 171798691800UL; // PVC as refference
|
symbolValue.ValueUInt64 = 171798691800UL; // PVC as reference
|
||||||
|
found = true;
|
||||||
|
} else if (std::strcmp(name, "GpuTimestampFrequency") == 0) {
|
||||||
|
getGpuTimestampFrequencyCallCount++;
|
||||||
|
if (failGetGpuTimestampFrequencyOnCall && (getGpuTimestampFrequencyCallCount >= failGetGpuTimestampFrequencyOnCall)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
symbolValue.ValueType = MetricsDiscovery::TValueType::VALUE_TYPE_UINT64;
|
||||||
|
symbolValue.ValueUInt64 = 25000000UL; // PVC as reference
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
if (found) {
|
if (found) {
|
||||||
|
@ -168,6 +182,14 @@ class Mock<IMetricsDevice_1_13> : public IMetricsDevice_1_13 {
|
||||||
return MetricsDiscovery::CC_OK;
|
return MetricsDiscovery::CC_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void resetMockVars() {
|
||||||
|
forceGetSymbolByNameFail = false;
|
||||||
|
forceGetGpuCpuTimestampsFail = false;
|
||||||
|
forceGetMaxTimestampFail = false;
|
||||||
|
failGetGpuTimestampFrequencyOnCall = 0;
|
||||||
|
getGpuTimestampFrequencyCallCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<IConcurrentGroup_1_13 *> getConcurrentGroupResults;
|
std::vector<IConcurrentGroup_1_13 *> getConcurrentGroupResults;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -757,23 +757,17 @@ TEST_F(MetricEnumerationTest, GivenValidMetricGroupWhenReadingFrequencyAndIntern
|
||||||
EXPECT_NE(metricGroupHandle, nullptr);
|
EXPECT_NE(metricGroupHandle, nullptr);
|
||||||
|
|
||||||
// Metric group properties.
|
// Metric group properties.
|
||||||
mockOAOsInterface->getMetricsTimerResolutionReturn = ZE_RESULT_ERROR_UNKNOWN;
|
EXPECT_EQ(zetMetricGroupGetProperties(metricGroupHandle, &metricGroupProperties), ZE_RESULT_SUCCESS);
|
||||||
mockOAOsInterface->failGetResolutionOnCall = 1;
|
|
||||||
|
|
||||||
EXPECT_EQ(zetMetricGroupGetProperties(metricGroupHandle, &metricGroupProperties), ZE_RESULT_ERROR_UNKNOWN);
|
|
||||||
EXPECT_EQ(metricGroupProperties.domain, 0u);
|
EXPECT_EQ(metricGroupProperties.domain, 0u);
|
||||||
EXPECT_EQ(metricGroupProperties.samplingType, ZET_METRIC_GROUP_SAMPLING_TYPE_FLAG_EVENT_BASED);
|
EXPECT_EQ(metricGroupProperties.samplingType, ZET_METRIC_GROUP_SAMPLING_TYPE_FLAG_EVENT_BASED);
|
||||||
EXPECT_EQ(metricGroupProperties.metricCount, metricsSetParams.MetricsCount);
|
EXPECT_EQ(metricGroupProperties.metricCount, metricsSetParams.MetricsCount);
|
||||||
EXPECT_EQ(strcmp(metricGroupProperties.description, metricsSetParams.ShortName), 0);
|
EXPECT_EQ(strcmp(metricGroupProperties.description, metricsSetParams.ShortName), 0);
|
||||||
EXPECT_EQ(strcmp(metricGroupProperties.name, metricsSetParams.SymbolName), 0);
|
EXPECT_EQ(strcmp(metricGroupProperties.name, metricsSetParams.SymbolName), 0);
|
||||||
|
|
||||||
EXPECT_EQ(metricTimestampProperties.timerResolution, 0UL);
|
EXPECT_NE(metricTimestampProperties.timerResolution, 0UL);
|
||||||
EXPECT_EQ(metricTimestampProperties.timestampValidBits, 0UL);
|
EXPECT_NE(metricTimestampProperties.timestampValidBits, 0UL);
|
||||||
|
|
||||||
mockOAOsInterface->getMetricsTimerResolutionReturn = ZE_RESULT_SUCCESS;
|
metricsDevice.failGetGpuTimestampFrequencyOnCall = true;
|
||||||
mockOAOsInterface->failGetResolutionOnCall = 0;
|
|
||||||
|
|
||||||
metricsDevice.forceGetSymbolByNameFail = true;
|
|
||||||
|
|
||||||
EXPECT_EQ(zetMetricGroupGetProperties(metricGroupHandle, &metricGroupProperties), ZE_RESULT_ERROR_NOT_AVAILABLE);
|
EXPECT_EQ(zetMetricGroupGetProperties(metricGroupHandle, &metricGroupProperties), ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||||
EXPECT_EQ(metricGroupProperties.domain, 0u);
|
EXPECT_EQ(metricGroupProperties.domain, 0u);
|
||||||
|
@ -785,13 +779,10 @@ TEST_F(MetricEnumerationTest, GivenValidMetricGroupWhenReadingFrequencyAndIntern
|
||||||
EXPECT_EQ(metricTimestampProperties.timerResolution, 0UL);
|
EXPECT_EQ(metricTimestampProperties.timerResolution, 0UL);
|
||||||
EXPECT_EQ(metricTimestampProperties.timestampValidBits, 0UL);
|
EXPECT_EQ(metricTimestampProperties.timestampValidBits, 0UL);
|
||||||
|
|
||||||
metricsDevice.forceGetSymbolByNameFail = false;
|
metricsDevice.resetMockVars();
|
||||||
|
metricsDevice.forceGetMaxTimestampFail = true;
|
||||||
|
|
||||||
mockOAOsInterface->getMetricsTimerResolutionReturn = ZE_RESULT_ERROR_UNKNOWN;
|
EXPECT_EQ(zetMetricGroupGetProperties(metricGroupHandle, &metricGroupProperties), ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||||
mockOAOsInterface->getResolutionCallCount = 0;
|
|
||||||
mockOAOsInterface->failGetResolutionOnCall = 2; // getTimestampValidBits() also calls getTimerResolution()
|
|
||||||
|
|
||||||
EXPECT_EQ(zetMetricGroupGetProperties(metricGroupHandle, &metricGroupProperties), ZE_RESULT_ERROR_UNKNOWN);
|
|
||||||
EXPECT_EQ(metricGroupProperties.domain, 0u);
|
EXPECT_EQ(metricGroupProperties.domain, 0u);
|
||||||
EXPECT_EQ(metricGroupProperties.samplingType, ZET_METRIC_GROUP_SAMPLING_TYPE_FLAG_EVENT_BASED);
|
EXPECT_EQ(metricGroupProperties.samplingType, ZET_METRIC_GROUP_SAMPLING_TYPE_FLAG_EVENT_BASED);
|
||||||
EXPECT_EQ(metricGroupProperties.metricCount, metricsSetParams.MetricsCount);
|
EXPECT_EQ(metricGroupProperties.metricCount, metricsSetParams.MetricsCount);
|
||||||
|
@ -801,8 +792,15 @@ TEST_F(MetricEnumerationTest, GivenValidMetricGroupWhenReadingFrequencyAndIntern
|
||||||
EXPECT_EQ(metricTimestampProperties.timerResolution, 0UL);
|
EXPECT_EQ(metricTimestampProperties.timerResolution, 0UL);
|
||||||
EXPECT_EQ(metricTimestampProperties.timestampValidBits, 0UL);
|
EXPECT_EQ(metricTimestampProperties.timestampValidBits, 0UL);
|
||||||
|
|
||||||
mockOAOsInterface->getMetricsTimerResolutionReturn = ZE_RESULT_SUCCESS;
|
metricsDevice.resetMockVars();
|
||||||
mockOAOsInterface->failGetResolutionOnCall = 0;
|
metricsDevice.failGetGpuTimestampFrequencyOnCall = 2;
|
||||||
|
|
||||||
|
EXPECT_EQ(zetMetricGroupGetProperties(metricGroupHandle, &metricGroupProperties), ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||||
|
EXPECT_EQ(metricGroupProperties.domain, 0u);
|
||||||
|
EXPECT_EQ(metricGroupProperties.samplingType, ZET_METRIC_GROUP_SAMPLING_TYPE_FLAG_EVENT_BASED);
|
||||||
|
EXPECT_EQ(metricGroupProperties.metricCount, metricsSetParams.MetricsCount);
|
||||||
|
EXPECT_EQ(strcmp(metricGroupProperties.description, metricsSetParams.ShortName), 0);
|
||||||
|
EXPECT_EQ(strcmp(metricGroupProperties.name, metricsSetParams.SymbolName), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MetricEnumerationTest, GivenEnumerationIsSuccessfulWhenReadingMetricsFrequencyThenValuesAreUpdated) {
|
TEST_F(MetricEnumerationTest, GivenEnumerationIsSuccessfulWhenReadingMetricsFrequencyThenValuesAreUpdated) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2024 Intel Corporation
|
* Copyright (C) 2024-2025 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
|
@ -39,8 +39,6 @@ TEST_F(MetricEnumerationTestWddm, givenCorrectWddmAdapterWhenGetMetricsAdapterTh
|
||||||
|
|
||||||
setupDefaultMocksForMetricDevice(metricsDevice);
|
setupDefaultMocksForMetricDevice(metricsDevice);
|
||||||
|
|
||||||
std::unique_ptr<MetricOAOsInterface> oaOsInterface = MetricOAOsInterface::create(*device);
|
|
||||||
|
|
||||||
adapterGroup.GetParamsResult = &adapterGroupParams;
|
adapterGroup.GetParamsResult = &adapterGroupParams;
|
||||||
adapterGroup.GetAdapterResult = &adapter;
|
adapterGroup.GetAdapterResult = &adapter;
|
||||||
adapter.GetParamsResult = &adapterParams;
|
adapter.GetParamsResult = &adapterParams;
|
||||||
|
@ -51,9 +49,6 @@ TEST_F(MetricEnumerationTestWddm, givenCorrectWddmAdapterWhenGetMetricsAdapterTh
|
||||||
mockMetricEnumeration->getMetricsAdapterResult = &adapter;
|
mockMetricEnumeration->getMetricsAdapterResult = &adapter;
|
||||||
|
|
||||||
EXPECT_EQ(mockMetricEnumeration->openMetricsDiscovery(), ZE_RESULT_SUCCESS);
|
EXPECT_EQ(mockMetricEnumeration->openMetricsDiscovery(), ZE_RESULT_SUCCESS);
|
||||||
|
|
||||||
uint64_t timerResolution;
|
|
||||||
EXPECT_EQ(oaOsInterface->getMetricsTimerResolution(timerResolution), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
|
|
||||||
}
|
}
|
||||||
} // namespace ult
|
} // namespace ult
|
||||||
} // namespace L0
|
} // namespace L0
|
||||||
|
|
Loading…
Reference in New Issue