Skip to content

Commit 7298f8d

Browse files
authored
improved output formatting in metrics result validation (#279)
Signed-off-by: Matias Cabral <[email protected]>
1 parent 9afd6f2 commit 7298f8d

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed

utils/test_harness/tools/src/test_harness_metric.cpp

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -664,33 +664,39 @@ void append_metric_memory_barrier(zet_command_list_handle_t commandList) {
664664
}
665665

666666
void verify_typed_metric_value(zet_typed_value_t result,
667-
zet_value_type_t metricValueType) {
667+
zet_value_type_t metricValueType, char *name) {
668668
EXPECT_EQ(metricValueType, result.type);
669+
LOG_DEBUG << "Metric: " << name;
669670
switch (result.type) {
670671
case zet_value_type_t::ZET_VALUE_TYPE_BOOL8:
671672
EXPECT_GE(result.value.b8, std::numeric_limits<unsigned char>::min());
672673
EXPECT_LE(result.value.b8, std::numeric_limits<unsigned char>::max());
673-
LOG_DEBUG << "BOOL " << result.value.b8;
674+
LOG_DEBUG << ". BOOL " << result.value.b8
675+
<< (result.value.b8 ? " TRUE " : "\t FALSE");
674676
break;
675677
case zet_value_type_t::ZET_VALUE_TYPE_FLOAT32:
676678
EXPECT_GE(result.value.fp32, std::numeric_limits<float>::lowest());
677679
EXPECT_LE(result.value.fp32, std::numeric_limits<float>::max());
678-
LOG_DEBUG << "fp32 " << result.value.fp32;
680+
LOG_DEBUG << ". fp32 " << result.value.fp32
681+
<< (result.value.fp32 ? " OK " : "\t ZERO");
679682
break;
680683
case zet_value_type_t::ZET_VALUE_TYPE_FLOAT64:
681684
EXPECT_GE(result.value.fp64, std::numeric_limits<double>::lowest());
682685
EXPECT_LE(result.value.fp64, std::numeric_limits<double>::max());
683-
LOG_DEBUG << "fp64 " << result.value.fp64;
686+
LOG_DEBUG << ". fp64 " << result.value.fp64
687+
<< (result.value.fp64 ? " OK " : "\t ZERO");
684688
break;
685689
case zet_value_type_t::ZET_VALUE_TYPE_UINT32:
686690
EXPECT_GE(result.value.ui32, 0);
687691
EXPECT_LE(result.value.ui32, std::numeric_limits<uint32_t>::max());
688-
LOG_DEBUG << "uint32_t " << result.value.ui32;
692+
LOG_DEBUG << ". uint32_t " << result.value.ui32
693+
<< (result.value.ui32 ? " OK " : "\t ZERO");
689694
break;
690695
case zet_value_type_t::ZET_VALUE_TYPE_UINT64:
691696
EXPECT_GE(result.value.ui64, 0);
692697
EXPECT_LE(result.value.ui64, std::numeric_limits<uint64_t>::max());
693-
LOG_DEBUG << "uint64_t " << result.value.ui64;
698+
LOG_DEBUG << ". uint64_t " << result.value.ui64
699+
<< (result.value.ui64 ? " OK " : "\t ZERO");
694700
break;
695701
default:
696702
ADD_FAILURE() << "Unexpected value type returned for metric query";
@@ -771,7 +777,8 @@ void validate_metrics_common(
771777
const size_t metricIndex = report * metricCount + metric;
772778
zet_typed_value_t typed_value =
773779
totalMetricValues[startIndex + metricIndex];
774-
verify_typed_metric_value(typed_value, properties.resultType);
780+
verify_typed_metric_value(typed_value, properties.resultType,
781+
properties.name);
775782
if ((metricNameForTest != nullptr)) {
776783
if (strncmp(metricNameForTest, properties.name,
777784
strnlen(metricNameForTest, 1024)) == 0) {
@@ -781,9 +788,7 @@ void validate_metrics_common(
781788
}
782789
LOG_DEBUG << "END METRIC INSTANCE";
783790
}
784-
785791
LOG_DEBUG << "END METRIC SET";
786-
787792
if ((metricNameForTest != nullptr)) {
788793
typedValuesFound.push_back(valueVector);
789794
}
@@ -840,14 +845,19 @@ void validate_metrics_std(zet_metric_group_handle_t hMetricGroup,
840845
LOG_DEBUG << "metricValueCount " << metricValueCount << " metricCount "
841846
<< metricCount;
842847

843-
for (uint32_t count = 0; count < metricValueCount; count++) {
844-
zet_metric_properties_t properties = {ZET_STRUCTURE_TYPE_METRIC_PROPERTIES,
845-
nullptr};
846-
EXPECT_ZE_RESULT_SUCCESS(
847-
848-
zetMetricGetProperties(phMetrics[count % metricCount], &properties));
849-
zet_typed_value_t typed_value = metricValues[count];
850-
verify_typed_metric_value(typed_value, properties.resultType);
848+
uint32_t reportNumber = metricValueCount / metricCount;
849+
for (uint32_t count = 0; count < reportNumber; count++) {
850+
LOG_DEBUG << "--- Result Report : " << count;
851+
for (uint32_t metric = 0; metric < metricCount; metric++) {
852+
zet_metric_properties_t properties = {
853+
ZET_STRUCTURE_TYPE_METRIC_PROPERTIES, nullptr};
854+
EXPECT_ZE_RESULT_SUCCESS(
855+
zetMetricGetProperties(phMetrics[metric], &properties));
856+
zet_typed_value_t typed_value =
857+
metricValues[count * metricCount + metric];
858+
verify_typed_metric_value(typed_value, properties.resultType,
859+
properties.name);
860+
}
851861
}
852862
}
853863

0 commit comments

Comments
 (0)