Skip to content

Commit 08e5f75

Browse files
committed
pcm-memory: implement --nocxl option
Change-Id: I4fc9b2021209a51d0a60daaff34d5baf1c9dfad6
1 parent 0bac747 commit 08e5f75

File tree

2 files changed

+59
-45
lines changed

2 files changed

+59
-45
lines changed

src/pcm-memory.cpp

Lines changed: 58 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ void print_help(const string & prog_name)
9393
cout << " -mixed => monitor PMM mixed mode (AppDirect + Memory Mode).\n";
9494
cout << " -partial => monitor partial writes instead of PMM (default on systems without PMM support).\n";
9595
cout << " -nc | --nochannel | /nc => suppress output for individual channels.\n";
96+
cout << " --nocxl => suppress output for CXL ports.\n";
9697
cout << " -csv[=file.csv] | /csv[=file.csv] => output compact CSV format to screen or\n"
9798
<< " to a file, in case filename is provided\n";
9899
cout << " -columns=X | /columns=X => Number of columns to display the NUMA Nodes, defaults to 2.\n";
@@ -446,7 +447,7 @@ void printSocketBWFooter(PCM *m, uint32 no_columns, uint32 skt, const memdata_t
446447
cout << "\n";
447448
}
448449

449-
void display_bandwidth(PCM *m, memdata_t *md, const uint32 no_columns, const bool show_channel_output, const bool print_update, const float CXL_Read_BW)
450+
void display_bandwidth(PCM *m, memdata_t *md, const uint32 no_columns, const bool show_channel_output, const bool print_update, const float CXL_Read_BW, const bool show_cxl_bandwidth)
450451
{
451452
float sysReadDRAM = 0.0, sysWriteDRAM = 0.0, sysReadPMM = 0.0, sysWritePMM = 0.0;
452453
uint32 numSockets = m->getNumSockets();
@@ -533,13 +534,16 @@ void display_bandwidth(PCM *m, memdata_t *md, const uint32 no_columns, const boo
533534
sysWriteDRAM += (md->iMC_Wr_socket[skt] + md->EDC_Wr_socket[skt]);
534535
skt += 1;
535536
};
536-
auto printRow = [&skt,&show_channel_output,&m,&md,&sysReadDRAM,&sysWriteDRAM, &sysReadPMM, &sysWritePMM](const uint32 no_columns)
537+
auto printRow = [&skt,&show_channel_output,&m,&md,&sysReadDRAM,&sysWriteDRAM, &sysReadPMM, &sysWritePMM, &show_cxl_bandwidth](const uint32 no_columns)
537538
{
538539
printSocketBWHeader(no_columns, skt, show_channel_output);
539540
if (show_channel_output)
540541
printSocketChannelBW(m, md, no_columns, skt);
541542
printSocketBWFooter(m, no_columns, skt, md);
542-
printSocketCXLBW(m, md, no_columns, skt);
543+
if (show_cxl_bandwidth)
544+
{
545+
printSocketCXLBW(m, md, no_columns, skt);
546+
}
543547
for (uint32 i = skt; i < (skt + no_columns); i++)
544548
{
545549
sysReadDRAM += md->iMC_Rd_socket[i];
@@ -588,7 +592,7 @@ void display_bandwidth(PCM *m, memdata_t *md, const uint32 no_columns, const boo
588592

589593
constexpr float CXLBWWrScalingFactor = 0.5;
590594

591-
void display_bandwidth_csv(PCM *m, memdata_t *md, uint64 /*elapsedTime*/, const bool show_channel_output, const CsvOutputType outputType, const float CXL_Read_BW)
595+
void display_bandwidth_csv(PCM *m, memdata_t *md, uint64 /*elapsedTime*/, const bool show_channel_output, const CsvOutputType outputType, const float CXL_Read_BW, const bool show_cxl_output)
592596
{
593597
const uint32 numSockets = m->getNumSockets();
594598
printDateForCSV(outputType);
@@ -810,41 +814,44 @@ void display_bandwidth_csv(PCM *m, memdata_t *md, uint64 /*elapsedTime*/, const
810814
sysWriteDRAM += md->EDC_Wr_socket[skt];
811815
});
812816
}
813-
for (uint64 port = 0; port < m->getNumCXLPorts(skt); ++port)
817+
if (show_cxl_output)
814818
{
815-
choose(outputType,
816-
[printSKT, &md]() {
817-
printSKT((md->BHS)? 4 : 2 );
818-
},
819-
[&port,&md]() {
820-
if (md->BHS)
821-
{
822-
cout << "CXL.mem_P" << port << "Read,"
823-
<< "CXL.mem_P" << port << "Write,"
824-
<< "CXL.cache_P" << port << "dv->hst,"
825-
<< "CXL.cache_P" << port << "hst->dv,";
826-
}
827-
else
828-
{
829-
cout
830-
<< "CXL.mem_P" << port << "Write,"
831-
<< "CXL.cache_P" << port << "hst->dv,";
832-
}
833-
},
834-
[&md, &skt, &port]() {
835-
if (md->BHS)
836-
{
837-
cout << setw(8) << md->CXLMEM_Rd_socket_port[skt][port] << ','
838-
<< setw(8) << md->CXLMEM_Wr_socket_port[skt][port] << ','
839-
<< setw(8) << md->CXLCACHE_Rd_socket_port[skt][port] << ','
840-
<< setw(8) << md->CXLCACHE_Wr_socket_port[skt][port] << ',';
841-
}
842-
else
843-
{
844-
cout << setw(8) << md->CXLMEM_Wr_socket_port[skt][port] << ','
845-
<< setw(8) << md->CXLCACHE_Wr_socket_port[skt][port] << ',';
846-
}
847-
});
819+
for (uint64 port = 0; port < m->getNumCXLPorts(skt); ++port)
820+
{
821+
choose(outputType,
822+
[printSKT, &md]() {
823+
printSKT((md->BHS)? 4 : 2 );
824+
},
825+
[&port,&md]() {
826+
if (md->BHS)
827+
{
828+
cout << "CXL.mem_P" << port << "Read,"
829+
<< "CXL.mem_P" << port << "Write,"
830+
<< "CXL.cache_P" << port << "dv->hst,"
831+
<< "CXL.cache_P" << port << "hst->dv,";
832+
}
833+
else
834+
{
835+
cout
836+
<< "CXL.mem_P" << port << "Write,"
837+
<< "CXL.cache_P" << port << "hst->dv,";
838+
}
839+
},
840+
[&md, &skt, &port]() {
841+
if (md->BHS)
842+
{
843+
cout << setw(8) << md->CXLMEM_Rd_socket_port[skt][port] << ','
844+
<< setw(8) << md->CXLMEM_Wr_socket_port[skt][port] << ','
845+
<< setw(8) << md->CXLCACHE_Rd_socket_port[skt][port] << ','
846+
<< setw(8) << md->CXLCACHE_Wr_socket_port[skt][port] << ',';
847+
}
848+
else
849+
{
850+
cout << setw(8) << md->CXLMEM_Wr_socket_port[skt][port] << ','
851+
<< setw(8) << md->CXLCACHE_Wr_socket_port[skt][port] << ',';
852+
}
853+
});
854+
}
848855
}
849856
}
850857

@@ -903,7 +910,8 @@ void calculate_bandwidth(PCM *m,
903910
const ServerUncoreMemoryMetrics & metrics,
904911
const bool show_channel_output,
905912
const bool print_update,
906-
const uint64 SPR_CHA_CXL_Count)
913+
const uint64 SPR_CHA_CXL_Count,
914+
const bool show_cxl_output)
907915
{
908916
//const uint32 num_imc_channels = m->getMCChannelsPerSocket();
909917
//const uint32 num_edc_channels = m->getEDCChannelsPerSocket();
@@ -1156,15 +1164,15 @@ void calculate_bandwidth(PCM *m,
11561164
{
11571165
if (csvheader)
11581166
{
1159-
display_bandwidth_csv(m, &md, elapsedTime, show_channel_output, Header1, CXL_Read_BW);
1160-
display_bandwidth_csv(m, &md, elapsedTime, show_channel_output, Header2, CXL_Read_BW);
1167+
display_bandwidth_csv(m, &md, elapsedTime, show_channel_output, Header1, CXL_Read_BW, show_cxl_output);
1168+
display_bandwidth_csv(m, &md, elapsedTime, show_channel_output, Header2, CXL_Read_BW, show_cxl_output);
11611169
csvheader = false;
11621170
}
1163-
display_bandwidth_csv(m, &md, elapsedTime, show_channel_output, Data, CXL_Read_BW);
1171+
display_bandwidth_csv(m, &md, elapsedTime, show_channel_output, Data, CXL_Read_BW, show_cxl_output);
11641172
}
11651173
else
11661174
{
1167-
display_bandwidth(m, &md, no_columns, show_channel_output, print_update, CXL_Read_BW);
1175+
display_bandwidth(m, &md, no_columns, show_channel_output, print_update, CXL_Read_BW, show_cxl_output);
11681176
}
11691177
}
11701178

@@ -1367,6 +1375,7 @@ int mainThrows(int argc, char * argv[])
13671375

13681376
double delay = -1.0;
13691377
bool csv = false, csvheader = false, show_channel_output = true, print_update = false;
1378+
bool show_cxl_output = true;
13701379
uint32 no_columns = DEFAULT_DISPLAY_COLUMNS; // Default number of columns is 2
13711380
char * sysCmd = NULL;
13721381
char ** sysArgv = NULL;
@@ -1456,6 +1465,11 @@ int mainThrows(int argc, char * argv[])
14561465
show_channel_output = false;
14571466
continue;
14581467
}
1468+
else if (check_argument_equals(*argv, {"--nocxl"}))
1469+
{
1470+
show_cxl_output = false;
1471+
continue;
1472+
}
14591473
else if (check_argument_equals(*argv, {"-pmm", "/pmm", "-pmem", "/pmem"}))
14601474
{
14611475
metrics = Pmem;
@@ -1640,7 +1654,7 @@ int mainThrows(int argc, char * argv[])
16401654
calculate_bandwidth_rank(m,BeforeState, AfterState, AfterTime - BeforeTime, csv, csvheader, no_columns, rankA, rankB);
16411655
else
16421656
calculate_bandwidth(m,BeforeState,AfterState,AfterTime-BeforeTime,csv,csvheader, no_columns, metrics,
1643-
show_channel_output, print_update, SPR_CHA_CXL_Event_Count);
1657+
show_channel_output, print_update, SPR_CHA_CXL_Event_Count, show_cxl_output);
16441658

16451659
swap(BeforeTime, AfterTime);
16461660
swap(BeforeState, AfterState);

tests/pcm-memory-fuzz.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
110110
calculate_bandwidth_rank(m,BeforeState, AfterState, AfterTime - BeforeTime, csv, csvheader, no_columns, rankA, rankB);
111111
else
112112
calculate_bandwidth(m,BeforeState,AfterState,AfterTime-BeforeTime,csv,csvheader, no_columns, metrics,
113-
show_channel_output, print_update, 0);
113+
show_channel_output, print_update, 0, true);
114114

115115
return 0;
116116
}

0 commit comments

Comments
 (0)