@@ -374,19 +374,46 @@ void print_usage(const string & progname)
374
374
375
375
struct Metric
376
376
{
377
- typedef std::variant<double , uint64, int64, int32> ValueType;
377
+ typedef std::variant<double , uint64, int64, int32, bool > ValueType;
378
378
std::string name{};
379
379
ValueType value{};
380
380
std::string unit{};
381
381
Metric (const std::string & n, const ValueType & v, const std::string & u) : name(n), value(v), unit(u) {}
382
382
Metric () = default ;
383
383
};
384
384
385
- void printMetrics (const std::string & header, const std::vector<Metric> & metrics)
385
+ void printMetrics (const std::string & header, const std::vector<Metric> & metrics, const bool skipZeroValues = false )
386
386
{
387
387
cout << header << " ; " ;
388
388
for (const auto & metric : metrics)
389
389
{
390
+ if (skipZeroValues)
391
+ {
392
+ if (std::holds_alternative<uint64>(metric.value ) && std::get<uint64>(metric.value ) == 0 )
393
+ {
394
+ continue ;
395
+ }
396
+ if (std::holds_alternative<double >(metric.value ) && std::get<double >(metric.value ) == 0.0 )
397
+ {
398
+ continue ;
399
+ }
400
+ if (std::holds_alternative<int64>(metric.value ) && std::get<int64>(metric.value ) == 0 )
401
+ {
402
+ continue ;
403
+ }
404
+ if (std::holds_alternative<int32>(metric.value ) && std::get<int32>(metric.value ) == 0 )
405
+ {
406
+ continue ;
407
+ }
408
+ }
409
+ if (std::holds_alternative<bool >(metric.value ))
410
+ {
411
+ if (std::get<bool >(metric.value ))
412
+ {
413
+ cout << metric.name << " ;" ;
414
+ }
415
+ continue ;
416
+ }
390
417
cout << metric.name << " : " ;
391
418
if (std::holds_alternative<uint64>(metric.value ))
392
419
{
@@ -417,14 +444,14 @@ void printMetrics(const std::string & header, const std::vector<Metric> & metric
417
444
cout << " \n " ;
418
445
}
419
446
420
- void printMetrics (const std::string & header, const std::initializer_list<Metric> & metrics)
447
+ void printMetrics (const std::string & header, const std::initializer_list<Metric> & metrics, const bool skipZeroValues = false )
421
448
{
422
449
std::vector<Metric> metricsVec;
423
450
for (const auto & metric : metrics)
424
451
{
425
452
metricsVec.push_back (metric);
426
453
}
427
- printMetrics (header, metricsVec);
454
+ printMetrics (header, metricsVec, skipZeroValues );
428
455
}
429
456
430
457
PCM_MAIN_NOTHROW;
@@ -737,7 +764,7 @@ int mainThrows(int argc, char * argv[])
737
764
case 0 :
738
765
if (cpu_family_model == PCM::HASWELLX || cpu_family_model == PCM::BDX_DE || cpu_family_model == PCM::SKX)
739
766
break ;
740
-
767
+
741
768
printMetrics (getHeader (),
742
769
{
743
770
Metric (" PCUClocks" , getPCUClocks (u, BeforeState[socket], AfterState[socket]), " " ),
@@ -886,13 +913,13 @@ int mainThrows(int argc, char * argv[])
886
913
{
887
914
for (auto die = 0ULL ; die < PERF_LIMIT_REASON_TPMI_dies_data[instance].size (); ++die)
888
915
{
889
- cout << " S " << instance << " D " << die << " ; PERF LIMIT REASONS (DIE LEVEL): " ;
916
+ std::vector<Metric> metrics ;
890
917
const auto data = PERF_LIMIT_REASON_TPMI_dies_data[instance][die];
891
918
for (auto l = 0 ; l < PERF_LIMIT_REASON_TPMI::Coarse_Grained_PLR_Bit_Definition::MAX; ++l)
892
919
{
893
- if ( extract_bits (data, l, l)) cout << PERF_LIMIT_REASON_TPMI::Coarse_Grained_PLR_Bit_Definition_Strings[l] << " ; " ;
920
+ metrics. push_back ( Metric (PERF_LIMIT_REASON_TPMI::Coarse_Grained_PLR_Bit_Definition_Strings[l], extract_bits (data, l, l) ? true : false , " " )) ;
894
921
}
895
- cout << " \n " ;
922
+ printMetrics ( " S " + std::to_string (instance) + " D " + std::to_string (die) + " PERF LIMIT REASONS (DIE LEVEL) " , metrics) ;
896
923
}
897
924
}
898
925
for (auto instance = 0ULL ; instance < PERF_LIMIT_REASON_TPMI_modules_data.size (); ++instance)
@@ -923,20 +950,17 @@ int mainThrows(int argc, char * argv[])
923
950
}
924
951
for (auto die = 0ULL ; die < coarseGrainedData.size (); ++die)
925
952
{
926
- cout << " S " << instance << " D " << die << " ; PERF LIMIT REASONS (#CORE MODULES): " ;
953
+ std::vector<Metric> metrics ;
927
954
for (auto l = 0 ; l < PERF_LIMIT_REASON_TPMI::Coarse_Grained_PLR_Bit_Definition::MAX; ++l)
928
955
{
929
- if (coarseGrainedData[die][l]) cout << PERF_LIMIT_REASON_TPMI::Coarse_Grained_PLR_Bit_Definition_Strings[l] << " : " << coarseGrainedData[die][l] << " ; " ;
956
+ metrics. push_back ( Metric ( PERF_LIMIT_REASON_TPMI::Coarse_Grained_PLR_Bit_Definition_Strings[l], coarseGrainedData[die][l], " " )) ;
930
957
}
931
958
for (auto l = 0 ; l < PERF_LIMIT_REASON_TPMI::Fine_Grained_PLR_Bit_Definition::MAX_FINE; ++l)
932
959
{
933
- if (fineGrainedData[die][l])
934
- {
935
- cout << PERF_LIMIT_REASON_TPMI::Coarse_Grained_PLR_Bit_Definition_Strings[PERF_LIMIT_REASON_TPMI::Fine_Grained_PLR_Bit_Definition_Data[l].coarse_grained_mapping ]
936
- << " ." << PERF_LIMIT_REASON_TPMI::Fine_Grained_PLR_Bit_Definition_Data[l].name << " : " << fineGrainedData[die][l] << " ; " ;
937
- }
960
+ metrics.push_back (Metric (std::string (PERF_LIMIT_REASON_TPMI::Coarse_Grained_PLR_Bit_Definition_Strings[PERF_LIMIT_REASON_TPMI::Fine_Grained_PLR_Bit_Definition_Data[l].coarse_grained_mapping ]) + " ." +
961
+ PERF_LIMIT_REASON_TPMI::Fine_Grained_PLR_Bit_Definition_Data[l].name , fineGrainedData[die][l], " " ));
938
962
}
939
- cout << " \n " ;
963
+ printMetrics ( " S " + std::to_string (instance) + " D " + std::to_string (die) + " PERF LIMIT REASONS (#CORE MODULES) " , metrics, true ) ;
940
964
}
941
965
}
942
966
};
0 commit comments