mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-25 05:24:02 +08:00
feature: get report format for IP sampling
Resolves: NEO-13998 Signed-off-by: Matias Cabral <matias.a.cabral@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
f2173f645c
commit
1a2666d4e2
@@ -85,10 +85,17 @@ ze_result_t ZE_APICALL zetIntelMetricCalculateOperationCreateExp(zet_context_han
|
||||
return L0::metricCalculateOperationCreate(hContext, hDevice, pCalculateDesc, pCount, phExcludedMetrics, phCalculateOperation);
|
||||
}
|
||||
|
||||
ze_result_t zetIntelMetricCalculateOperationDestroyExp(zet_intel_metric_calculate_operation_exp_handle_t hCalculateOperation) {
|
||||
ze_result_t ZE_APICALL zetIntelMetricCalculateOperationDestroyExp(zet_intel_metric_calculate_operation_exp_handle_t hCalculateOperation) {
|
||||
return L0::metricCalculateOperationDestroy(hCalculateOperation);
|
||||
}
|
||||
|
||||
ze_result_t ZE_APICALL zetIntelMetricCalculateGetReportFormatExp(
|
||||
zet_intel_metric_calculate_operation_exp_handle_t hCalculateOperation,
|
||||
uint32_t *pCount,
|
||||
zet_metric_handle_t *phMetrics) {
|
||||
return L0::metricCalculateGetReportFormat(hCalculateOperation, pCount, phMetrics);
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
|
||||
extern "C" {
|
||||
@@ -190,4 +197,12 @@ ze_result_t zetIntelMetricCalculateOperationDestroyExp(
|
||||
zet_intel_metric_calculate_operation_exp_handle_t hCalculateOperation) {
|
||||
return L0::zetIntelMetricCalculateOperationDestroyExp(hCalculateOperation);
|
||||
}
|
||||
|
||||
ze_result_t zetIntelMetricCalculateGetReportFormatExp(
|
||||
zet_intel_metric_calculate_operation_exp_handle_t hCalculateOperation,
|
||||
uint32_t *pCount,
|
||||
zet_metric_handle_t *phMetrics) {
|
||||
return L0::zetIntelMetricCalculateGetReportFormatExp(hCalculateOperation, pCount, phMetrics);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
@@ -883,6 +883,13 @@ ze_result_t metricCalculateOperationDestroy(
|
||||
return MetricCalcOp::fromHandle(hCalculateOperation)->destroy();
|
||||
}
|
||||
|
||||
ze_result_t metricCalculateGetReportFormat(
|
||||
zet_intel_metric_calculate_operation_exp_handle_t hCalculateOperation,
|
||||
uint32_t *pCount,
|
||||
zet_metric_handle_t *phMetrics) {
|
||||
return MetricCalcOp::fromHandle(hCalculateOperation)->getReportFormat(pCount, phMetrics);
|
||||
}
|
||||
|
||||
ze_result_t metricsEnable(zet_device_handle_t hDevice) {
|
||||
auto isFailed = false;
|
||||
|
||||
|
||||
@@ -495,6 +495,9 @@ ze_result_t metricCalculateOperationCreate(zet_context_handle_t hContext, zet_de
|
||||
|
||||
ze_result_t metricCalculateOperationDestroy(zet_intel_metric_calculate_operation_exp_handle_t hCalculateOperation);
|
||||
|
||||
ze_result_t metricCalculateGetReportFormat(zet_intel_metric_calculate_operation_exp_handle_t hCalculateOperation,
|
||||
uint32_t *pCount, zet_metric_handle_t *phMetrics);
|
||||
|
||||
ze_result_t metricsEnable(zet_device_handle_t hDevice);
|
||||
|
||||
} // namespace L0
|
||||
|
||||
@@ -137,6 +137,25 @@ ze_result_t IpSamplingMetricCalcOpImp::destroy() {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t IpSamplingMetricCalcOpImp::getReportFormat(uint32_t *pCount, zet_metric_handle_t *phMetrics) {
|
||||
|
||||
if (*pCount == 0) {
|
||||
*pCount = metricCount;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
} else if (*pCount < metricCount) {
|
||||
METRICS_LOG_ERR("%s", "Metric can't be smaller than report size");
|
||||
*pCount = 0;
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
*pCount = metricCount;
|
||||
for (uint32_t index = 0; index < metricCount; index++) {
|
||||
phMetrics[index] = metricsInReport[index]->toHandle();
|
||||
}
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t MultiDeviceIpSamplingMetricGroupImp::streamerOpen(
|
||||
zet_context_handle_t hContext,
|
||||
zet_device_handle_t hDevice,
|
||||
|
||||
@@ -56,11 +56,7 @@ struct IpSamplingMetricCalcOpImp : public MetricCalcOpImp {
|
||||
bool isMultiDevice,
|
||||
zet_intel_metric_calculate_operation_exp_handle_t *phCalculateOperation);
|
||||
ze_result_t destroy() override;
|
||||
ze_result_t getReportFormat(uint32_t *pCount, zet_metric_handle_t *phMetrics) override {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
std::vector<MetricImp *> &getMetricsInReport() { return metricsInReport; };
|
||||
uint32_t getMetricsInReportCount() { return metricCount; };
|
||||
ze_result_t getReportFormat(uint32_t *pCount, zet_metric_handle_t *phMetrics) override;
|
||||
ze_result_t metricCalculateMultipleValues(size_t rawDataSize, size_t *offset, const uint8_t *pRawData,
|
||||
uint32_t *pSetCount, uint32_t *pMetricsReportCountPerSet,
|
||||
uint32_t *pTotalMetricReportCount,
|
||||
|
||||
@@ -1219,18 +1219,64 @@ HWTEST2_F(MetricIpSamplingCalcOpTest, givenIpSamplingCalcOpCheckUnsupportedAPIs,
|
||||
&excludedMetricsCount, &phExcludedMetrics,
|
||||
&hCalculateOperation));
|
||||
auto calcOpImp = static_cast<IpSamplingMetricCalcOpImp *>(MetricCalcOp::fromHandle(hCalculateOperation));
|
||||
uint32_t count;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, calcOpImp->getReportFormat(&count, nullptr));
|
||||
std::vector<MetricImp *> metricsInReport = calcOpImp->getMetricsInReport();
|
||||
EXPECT_EQ(10U, metricsInReport.size());
|
||||
uint32_t metricsInReportCount = calcOpImp->getMetricsInReportCount();
|
||||
EXPECT_EQ(10U, metricsInReportCount);
|
||||
size_t rawDataSize = 0;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, calcOpImp->metricCalculateMultipleValues(rawDataSize, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zetIntelMetricCalculateOperationDestroyExp(hCalculateOperation));
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST2_F(MetricIpSamplingCalcOpTest, givenIpSamplingCalcOpCanGetReportFormat, EustallSupportedPlatforms) {
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, testDevices[0]->getMetricDeviceContext().enableMetricApi());
|
||||
|
||||
for (auto device : testDevices) {
|
||||
|
||||
uint32_t metricGroupCount = 1;
|
||||
zet_metric_group_handle_t metricGroupHandle = nullptr;
|
||||
EXPECT_EQ(zetMetricGroupGet(device->toHandle(), &metricGroupCount, &metricGroupHandle), ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(metricGroupCount, 1u);
|
||||
EXPECT_NE(metricGroupHandle, nullptr);
|
||||
|
||||
zet_intel_metric_calculate_exp_desc_t calculateDesc{
|
||||
ZET_INTEL_STRUCTURE_TYPE_METRIC_CALCULATE_DESC_EXP,
|
||||
nullptr, // pNext
|
||||
1, // metricGroupCount
|
||||
&metricGroupHandle, // phMetricGroups
|
||||
0, // metricCount
|
||||
nullptr, // phMetrics
|
||||
0, // timeWindowsCount
|
||||
nullptr, // pCalculateTimeWindows
|
||||
1000, // timeAggregationWindow
|
||||
};
|
||||
|
||||
zet_intel_metric_calculate_operation_exp_handle_t hCalculateOperation;
|
||||
uint32_t excludedMetricsCount = 0;
|
||||
zet_metric_handle_t phExcludedMetrics;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zetIntelMetricCalculateOperationCreateExp(context->toHandle(),
|
||||
device->toHandle(), &calculateDesc,
|
||||
&excludedMetricsCount, &phExcludedMetrics,
|
||||
&hCalculateOperation));
|
||||
|
||||
uint32_t metricsInReportCount = 0;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zetIntelMetricCalculateGetReportFormatExp(hCalculateOperation, &metricsInReportCount, nullptr));
|
||||
EXPECT_EQ(metricsInReportCount, 10u);
|
||||
|
||||
std::vector<zet_metric_handle_t> metricsInReport(metricsInReportCount);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zetIntelMetricCalculateGetReportFormatExp(hCalculateOperation, &metricsInReportCount, metricsInReport.data()));
|
||||
EXPECT_EQ(metricsInReportCount, 10u);
|
||||
|
||||
zet_metric_properties_t ipSamplingMetricProperties = {};
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zetMetricGetProperties(metricsInReport[0], &ipSamplingMetricProperties));
|
||||
EXPECT_EQ(strcmp(ipSamplingMetricProperties.name, "IP"), 0);
|
||||
|
||||
// Can't filter metrics in report
|
||||
metricsInReportCount = 1;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, zetIntelMetricCalculateGetReportFormatExp(hCalculateOperation, &metricsInReportCount, metricsInReport.data()));
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zetIntelMetricCalculateOperationDestroyExp(hCalculateOperation));
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST2_F(MetricIpSamplingCalcOpTest, WhenReadingMetricGroupTimeCalculateFilterThenCorrectValueIsReturned, EustallSupportedPlatforms) {
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, testDevices[0]->getMetricDeviceContext().enableMetricApi());
|
||||
|
||||
Reference in New Issue
Block a user