Skip to content

Commit 58e7a2d

Browse files
authored
Merge pull request #173 from intel-innersource/rdobrowo/raw_printout_upgrade
fixes and upgrades to pcm-raw transposed prints
2 parents cbc5b67 + 9565040 commit 58e7a2d

File tree

4 files changed

+88
-35
lines changed

4 files changed

+88
-35
lines changed

.github/workflows/ci-test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,9 @@ jobs:
5757
with:
5858
name: pcm-csv-${{ github.sha }}
5959
path: build/bin/pcm.csv
60+
61+
- name: upload-artifact
62+
uses: actions/upload-artifact@v2
63+
with:
64+
name: test-log-raw-tr-wi_ext-single_header-${{ github.sha }}
65+
path: build/bin/raw_tr_wi_ext_single_header.csv

src/pcm-raw.cpp

Lines changed: 73 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ void print_usage(const string progname)
7373
cerr << " -f | /f => enforce flushing each line for interactive output\n";
7474
cerr << " -i[=number] | /i[=number] => allow to determine number of iterations\n";
7575
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";
7778
cerr << " -s | /s => print a sample separator line between samples in transposed output\n";
7879
cerr << " -v | /v => verbose mode (print additional diagnostic messages)\n";
7980
cerr << " -l => use locale for printing values, calls -tab for readability\n";
@@ -932,7 +933,8 @@ bool show_partial_core_output = false;
932933
bitset<MAX_CORES> ycores;
933934
bool flushLine = false;
934935
bool transpose = false;
935-
bool extend_printout = false;
936+
bool extendPrintout = false;
937+
bool singleHeader = false;
936938
std::string separator = ",";
937939
bool sampleSeparator = false;
938940

@@ -974,13 +976,17 @@ void printRow(const std::string & EventName, MetricFunc metricFunc, const std::v
974976
if (!(m->isCoreOnline(core) == false || (show_partial_core_output && ycores.test(core) == false)))
975977
{
976978
if (outputType == Header1) {
977-
cout << "SKT" << m->getSocketId(core) << "CORE" << core << separator;
979+
cout << separator << "SKT" << m->getSocketId(core) << "CORE" << core;
978980
printOffset.end++;
979981
}
980982
else if (outputType == Header2)
981-
cout << "core" << separator;
983+
cout << separator << "core" ;
982984
else if (outputType == Data)
983985
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+
}
984990
else
985991
assert(!"unknown output type");
986992
}
@@ -1034,7 +1040,7 @@ void printTransposed(const PCM::RawPMUConfigs& curPMUConfigs,
10341040
const CsvOutputType outputType,
10351041
const bool& isLastGroup)
10361042
{
1037-
const bool is_header = (outputType == Header1 || outputType == Header2);
1043+
const bool is_header = (outputType == Header1 || outputType == Header2 || outputType == Header21);
10381044
for (const auto & typeEvents : curPMUConfigs)
10391045
{
10401046
bool is_header_printed = false;
@@ -1045,7 +1051,7 @@ void printTransposed(const PCM::RawPMUConfigs& curPMUConfigs,
10451051
PrintOffset printOffset{type, 0, 0};
10461052
const auto print_idx = getPrintOffsetIdx(printOffsets, type);
10471053

1048-
if (outputType == Header1) {
1054+
if (outputType == Header1 || outputType == Header21) {
10491055
if (print_idx != -1)
10501056
continue; // header already printed
10511057
else {
@@ -1077,14 +1083,17 @@ void printTransposed(const PCM::RawPMUConfigs& curPMUConfigs,
10771083
{
10781084
if (outputType == Header1)
10791085
{
1080-
cout << "SKT" << s << miscName << u << separator;
1086+
cout << separator << "SKT" << s << miscName << u;
10811087
printOffset.end++;
10821088
}
10831089
else if (outputType == Header2)
1084-
cout << miscName << separator;
1090+
cout << separator << miscName ;
10851091
else if (outputType == Data)
10861092
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
10881097
assert(!"unknown output type");
10891098
}
10901099
}
@@ -1115,17 +1124,22 @@ void printTransposed(const PCM::RawPMUConfigs& curPMUConfigs,
11151124
{
11161125
if (outputType == Header1)
11171126
{
1118-
cout << "SKT" << s << miscName << u << separator;
1127+
cout << separator << "SKT_" << s << miscName << u;
11191128
printOffset.end++;
11201129
}
11211130
else if (outputType == Header2)
11221131
{
1123-
cout << miscName << separator;
1132+
cout << separator << miscName ;
11241133
}
11251134
else if (outputType == Data)
11261135
{
11271136
cout << separator << metricFunc(u, i, BeforeUncoreState[s], AfterUncoreState[s]);
11281137
}
1138+
else if (outputType == Header21)
1139+
{
1140+
cout << separator << type << "_SKT" << s << "_" << miscName << u;
1141+
printOffset.end++;
1142+
}
11291143
else
11301144
{
11311145
assert(!"unknown output type");
@@ -1165,17 +1179,22 @@ void printTransposed(const PCM::RawPMUConfigs& curPMUConfigs,
11651179
{
11661180
if (outputType == Header1)
11671181
{
1168-
cout << "SKT" << s << separator;
1182+
cout << separator << "SKT" << s ;
11691183
printOffset.end++;
11701184
}
11711185
else if (outputType == Header2)
11721186
{
1173-
cout << type << separator;
1187+
cout << separator << type ;
11741188
}
11751189
else if (outputType == Data)
11761190
{
11771191
cout << separator << getMSREvent(index, msrType, BeforeSocketState[s], AfterSocketState[s]);
11781192
}
1193+
else if (outputType == Header21)
1194+
{
1195+
cout << separator << type << "_SKT" << s ;
1196+
printOffset.end++;
1197+
}
11791198
else
11801199
{
11811200
assert(!"unknown output type");
@@ -1187,17 +1206,22 @@ void printTransposed(const PCM::RawPMUConfigs& curPMUConfigs,
11871206
{
11881207
if (outputType == Header1)
11891208
{
1190-
cout << "SKT" << m->getSocketId(core) << "CORE" << core << separator;
1209+
cout << separator << "SKT" << m->getSocketId(core) << "CORE" << core;
11911210
printOffset.end++;
11921211
}
11931212
else if (outputType == Header2)
11941213
{
1195-
cout << type << separator;
1214+
cout << separator << type ;
11961215
}
11971216
else if (outputType == Data)
11981217
{
11991218
cout << separator << getMSREvent(index, msrType, BeforeState[core], AfterState[core]);
12001219
}
1220+
else if (outputType == Header21)
1221+
{
1222+
cout << separator << type << "_SKT" << m->getSocketId(core) << "_CORE" << core;
1223+
printOffset.end++;
1224+
}
12011225
else
12021226
{
12031227
assert(!"unknown output type");
@@ -1367,7 +1391,7 @@ void printTransposed(const PCM::RawPMUConfigs& curPMUConfigs,
13671391
std::cerr << "ERROR: unrecognized PMU type \"" << type << "\"\n";
13681392
}
13691393

1370-
if (outputType == Header1)
1394+
if (outputType == Header1 || outputType == Header21)
13711395
printOffsets.push_back(printOffset);
13721396
}
13731397
if (sampleSeparator)
@@ -1695,28 +1719,36 @@ void printAll(const PCM::RawPMUConfigs& curPMUConfigs,
16951719
{
16961720
static bool displayHeader = true;
16971721

1698-
if (!extend_printout && transpose)
1722+
if (!extendPrintout && transpose)
16991723
displayHeader = false;
17001724

17011725
if (transpose) {
17021726
if (displayHeader) {
17031727
// 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;
17201752
}
17211753
printTransposed(curPMUConfigs, m, BeforeState, AfterState, BeforeUncoreState, AfterUncoreState, BeforeSocketState, AfterSocketState, Data, isLastGroup);
17221754
} else {
@@ -1812,7 +1844,14 @@ int main(int argc, char* argv[])
18121844
strncmp(*argv, "-ext", 4) == 0 ||
18131845
strncmp(*argv, "/ext", 4) == 0)
18141846
{
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;
18161855
continue;
18171856
}
18181857
else if (strncmp(*argv, "-l", 2) == 0) {

src/utils.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ enum CsvOutputType
238238
{
239239
Header1,
240240
Header2,
241-
Data
241+
Data,
242+
Header21 // merged headers 2 and 1
242243
};
243244

244245
template <class H1, class H2, class D>
@@ -247,6 +248,7 @@ inline void choose(const CsvOutputType outputType, H1 h1Func, H2 h2Func, D dataF
247248
switch (outputType)
248249
{
249250
case Header1:
251+
case Header21:
250252
h1Func();
251253
break;
252254
case Header2:

tests/test.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,4 +276,10 @@ if [ "$?" -ne "0" ]; then
276276
exit 1
277277
fi
278278

279+
./pcm-raw -el event_file_test.txt -tr -ext -single-header -csv=raw_tr_wi_ext_single_header.csv -i=4 0.25
280+
if [ "$?" -ne "0" ]; then
281+
echo "Error in pcm-raw"
282+
exit 1
283+
fi
284+
279285
popd

0 commit comments

Comments
 (0)