@@ -73,7 +73,8 @@ void print_usage(const string progname)
73
73
cerr << " -f | /f => enforce flushing each line for interactive output\n " ;
74
74
cerr << " -i[=number] | /i[=number] => allow to determine number of iterations\n " ;
75
75
cerr << " -tr | /tr => transpose output (print single event data in a row)\n " ;
76
- cerr << " -ext => add headers to transposed output and extend printout to match it\n " ;
76
+ cerr << " -ext | /ext => add headers to transposed output and extend printout to match it\n " ;
77
+ cerr << " -single-header | /single-header => headers for transposed output are merged into single header\n " ;
77
78
cerr << " -s | /s => print a sample separator line between samples in transposed output\n " ;
78
79
cerr << " -v | /v => verbose mode (print additional diagnostic messages)\n " ;
79
80
cerr << " -l => use locale for printing values, calls -tab for readability\n " ;
@@ -932,7 +933,8 @@ bool show_partial_core_output = false;
932
933
bitset<MAX_CORES> ycores;
933
934
bool flushLine = false ;
934
935
bool transpose = false ;
935
- bool extend_printout = false ;
936
+ bool extendPrintout = false ;
937
+ bool singleHeader = false ;
936
938
std::string separator = " ," ;
937
939
bool sampleSeparator = false ;
938
940
@@ -974,13 +976,17 @@ void printRow(const std::string & EventName, MetricFunc metricFunc, const std::v
974
976
if (!(m->isCoreOnline (core) == false || (show_partial_core_output && ycores.test (core) == false )))
975
977
{
976
978
if (outputType == Header1) {
977
- cout << " SKT" << m->getSocketId (core) << " CORE" << core << separator ;
979
+ cout << separator << " SKT" << m->getSocketId (core) << " CORE" << core;
978
980
printOffset.end ++;
979
981
}
980
982
else if (outputType == Header2)
981
- cout << " core " << separator ;
983
+ cout << separator << " core " ;
982
984
else if (outputType == Data)
983
985
cout << separator << metricFunc (BeforeState[core], AfterState[core]);
986
+ else if (outputType == Header21) {
987
+ cout << separator << " core_SKT" << m->getSocketId (core) << " _CORE" << core;
988
+ printOffset.end ++;
989
+ }
984
990
else
985
991
assert (!" unknown output type" );
986
992
}
@@ -1034,7 +1040,7 @@ void printTransposed(const PCM::RawPMUConfigs& curPMUConfigs,
1034
1040
const CsvOutputType outputType,
1035
1041
const bool & isLastGroup)
1036
1042
{
1037
- const bool is_header = (outputType == Header1 || outputType == Header2);
1043
+ const bool is_header = (outputType == Header1 || outputType == Header2 || outputType == Header21 );
1038
1044
for (const auto & typeEvents : curPMUConfigs)
1039
1045
{
1040
1046
bool is_header_printed = false ;
@@ -1045,7 +1051,7 @@ void printTransposed(const PCM::RawPMUConfigs& curPMUConfigs,
1045
1051
PrintOffset printOffset{type, 0 , 0 };
1046
1052
const auto print_idx = getPrintOffsetIdx (printOffsets, type);
1047
1053
1048
- if (outputType == Header1) {
1054
+ if (outputType == Header1 || outputType == Header21 ) {
1049
1055
if (print_idx != -1 )
1050
1056
continue ; // header already printed
1051
1057
else {
@@ -1077,14 +1083,17 @@ void printTransposed(const PCM::RawPMUConfigs& curPMUConfigs,
1077
1083
{
1078
1084
if (outputType == Header1)
1079
1085
{
1080
- cout << " SKT" << s << miscName << u << separator ;
1086
+ cout << separator << " SKT" << s << miscName << u;
1081
1087
printOffset.end ++;
1082
1088
}
1083
1089
else if (outputType == Header2)
1084
- cout << miscName << separator ;
1090
+ cout << separator << miscName ;
1085
1091
else if (outputType == Data)
1086
1092
cout << separator << fixedMetricFunc (u, BeforeUncoreState[s], AfterUncoreState[s]);
1087
- else
1093
+ else if (outputType == Header21) {
1094
+ cout << separator << type << " _SKT" << s << " _" << miscName << u;
1095
+ printOffset.end ++;
1096
+ } else
1088
1097
assert (!" unknown output type" );
1089
1098
}
1090
1099
}
@@ -1115,17 +1124,22 @@ void printTransposed(const PCM::RawPMUConfigs& curPMUConfigs,
1115
1124
{
1116
1125
if (outputType == Header1)
1117
1126
{
1118
- cout << " SKT " << s << miscName << u << separator ;
1127
+ cout << separator << " SKT_ " << s << miscName << u;
1119
1128
printOffset.end ++;
1120
1129
}
1121
1130
else if (outputType == Header2)
1122
1131
{
1123
- cout << miscName << separator ;
1132
+ cout << separator << miscName ;
1124
1133
}
1125
1134
else if (outputType == Data)
1126
1135
{
1127
1136
cout << separator << metricFunc (u, i, BeforeUncoreState[s], AfterUncoreState[s]);
1128
1137
}
1138
+ else if (outputType == Header21)
1139
+ {
1140
+ cout << separator << type << " _SKT" << s << " _" << miscName << u;
1141
+ printOffset.end ++;
1142
+ }
1129
1143
else
1130
1144
{
1131
1145
assert (!" unknown output type" );
@@ -1165,17 +1179,22 @@ void printTransposed(const PCM::RawPMUConfigs& curPMUConfigs,
1165
1179
{
1166
1180
if (outputType == Header1)
1167
1181
{
1168
- cout << " SKT" << s << separator ;
1182
+ cout << separator << " SKT" << s ;
1169
1183
printOffset.end ++;
1170
1184
}
1171
1185
else if (outputType == Header2)
1172
1186
{
1173
- cout << type << separator ;
1187
+ cout << separator << type ;
1174
1188
}
1175
1189
else if (outputType == Data)
1176
1190
{
1177
1191
cout << separator << getMSREvent (index, msrType, BeforeSocketState[s], AfterSocketState[s]);
1178
1192
}
1193
+ else if (outputType == Header21)
1194
+ {
1195
+ cout << separator << type << " _SKT" << s ;
1196
+ printOffset.end ++;
1197
+ }
1179
1198
else
1180
1199
{
1181
1200
assert (!" unknown output type" );
@@ -1187,17 +1206,22 @@ void printTransposed(const PCM::RawPMUConfigs& curPMUConfigs,
1187
1206
{
1188
1207
if (outputType == Header1)
1189
1208
{
1190
- cout << " SKT" << m->getSocketId (core) << " CORE" << core << separator ;
1209
+ cout << separator << " SKT" << m->getSocketId (core) << " CORE" << core;
1191
1210
printOffset.end ++;
1192
1211
}
1193
1212
else if (outputType == Header2)
1194
1213
{
1195
- cout << type << separator ;
1214
+ cout << separator << type ;
1196
1215
}
1197
1216
else if (outputType == Data)
1198
1217
{
1199
1218
cout << separator << getMSREvent (index, msrType, BeforeState[core], AfterState[core]);
1200
1219
}
1220
+ else if (outputType == Header21)
1221
+ {
1222
+ cout << separator << type << " _SKT" << m->getSocketId (core) << " _CORE" << core;
1223
+ printOffset.end ++;
1224
+ }
1201
1225
else
1202
1226
{
1203
1227
assert (!" unknown output type" );
@@ -1367,7 +1391,7 @@ void printTransposed(const PCM::RawPMUConfigs& curPMUConfigs,
1367
1391
std::cerr << " ERROR: unrecognized PMU type \" " << type << " \"\n " ;
1368
1392
}
1369
1393
1370
- if (outputType == Header1)
1394
+ if (outputType == Header1 || outputType == Header21 )
1371
1395
printOffsets.push_back (printOffset);
1372
1396
}
1373
1397
if (sampleSeparator)
@@ -1695,28 +1719,36 @@ void printAll(const PCM::RawPMUConfigs& curPMUConfigs,
1695
1719
{
1696
1720
static bool displayHeader = true ;
1697
1721
1698
- if (!extend_printout && transpose)
1722
+ if (!extendPrintout && transpose)
1699
1723
displayHeader = false ;
1700
1724
1701
1725
if (transpose) {
1702
1726
if (displayHeader) {
1703
1727
// Need to go through all possible print on first run to form header.
1704
- for (int i = 0 ; i < 5 ; i++)
1705
- std::cout << separator;
1706
-
1707
- // print header_1 and get all offsets
1708
- for (auto &config : PMUConfigs)
1709
- printTransposed (config, m, BeforeState, AfterState, BeforeUncoreState, AfterUncoreState, BeforeSocketState, AfterSocketState, Header1, isLastGroup);
1710
-
1711
- std::cout << std::endl;
1712
-
1713
- // print header_2
1714
- std::cout << " Date" << separator << " Time" << separator << " Event" << separator;
1715
- std::cout << " ms, InvariantTSC" << separator;
1716
- for (auto &config : PMUConfigs)
1717
- printTransposed (config, m, BeforeState, AfterState, BeforeUncoreState, AfterUncoreState, BeforeSocketState, AfterSocketState, Header2, isLastGroup);
1718
-
1719
- std::cout << std::endl;
1728
+ if (singleHeader) {
1729
+ // merge header 2 and 1, print and get all offsets
1730
+ cout << " Date" << separator << " Time" << separator << " Event" << separator;
1731
+ cout << " ms" << separator << " InvariantTSC" ;
1732
+ for (auto &config : PMUConfigs)
1733
+ printTransposed (config, m, BeforeState, AfterState, BeforeUncoreState, AfterUncoreState, BeforeSocketState, AfterSocketState, Header21, isLastGroup);
1734
+ } else {
1735
+ // print 2 headers in 2 rows
1736
+ for (int i = 0 ; i < 4 ; i++)
1737
+ cout << separator;
1738
+
1739
+ // print header_1 and get all offsets
1740
+ for (auto &config : PMUConfigs)
1741
+ printTransposed (config, m, BeforeState, AfterState, BeforeUncoreState, AfterUncoreState, BeforeSocketState, AfterSocketState, Header1, isLastGroup);
1742
+
1743
+ cout << endl;
1744
+
1745
+ // print header_2
1746
+ cout << " Date" << separator << " Time" << separator << " Event" << separator;
1747
+ cout << " ms" << separator << " InvariantTSC" ;
1748
+ for (auto &config : PMUConfigs)
1749
+ printTransposed (config, m, BeforeState, AfterState, BeforeUncoreState, AfterUncoreState, BeforeSocketState, AfterSocketState, Header2, isLastGroup);
1750
+ }
1751
+ cout << endl;
1720
1752
}
1721
1753
printTransposed (curPMUConfigs, m, BeforeState, AfterState, BeforeUncoreState, AfterUncoreState, BeforeSocketState, AfterSocketState, Data, isLastGroup);
1722
1754
} else {
@@ -1812,7 +1844,14 @@ int main(int argc, char* argv[])
1812
1844
strncmp (*argv, " -ext" , 4 ) == 0 ||
1813
1845
strncmp (*argv, " /ext" , 4 ) == 0 )
1814
1846
{
1815
- extend_printout = true ;
1847
+ extendPrintout = true ;
1848
+ continue ;
1849
+ }
1850
+ else if (
1851
+ strncmp (*argv, " -single-header" , 14 ) == 0 ||
1852
+ strncmp (*argv, " /single-header" , 14 ) == 0 )
1853
+ {
1854
+ singleHeader = true ;
1816
1855
continue ;
1817
1856
}
1818
1857
else if (strncmp (*argv, " -l" , 2 ) == 0 ) {
0 commit comments