Skip to content

Commit

Permalink
fix: check read, write, loop count range
Browse files Browse the repository at this point in the history
Signed-off-by: anandaravuri <[email protected]>
  • Loading branch information
anandaravuri committed Oct 12, 2023
1 parent 3109705 commit 00253a1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 22 deletions.
6 changes: 3 additions & 3 deletions samples/cxl_mem_tg/cxl_mem_tg.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,17 +200,17 @@ class cxl_mem_tg : public test_afu {

// Loops
app_.add_option("--loops", loop_, "Number of read/write loops to be run")
->default_val("1");
->transform(CLI::Range(0, 268435456))->default_val(0);

// Writes
app_.add_option("-w,--writes", wcnt_,
"Number of unique write transactions per loop")
->default_val("1");
->transform(CLI::Range(0, 4095))->default_val(0);

// Reads
app_.add_option("-r,--reads", rcnt_,
"Number of unique read transactions per loop")
->default_val("1");
->transform(CLI::Range(0, 4095))->default_val("1");

// Address Stride
app_.add_option("--stride", stride_,
Expand Down
50 changes: 31 additions & 19 deletions samples/cxl_mem_tg/cxl_tg_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,47 +133,59 @@ class cxl_tg_test : public test_command {
tg_exe_->logger_->debug("TG performance ...");

if (tg_exe_->status_ == TG_STATUS_TIMEOUT) {
std::cerr << "TG timeout" << std::endl;
cerr << "TG timeout" << endl;
} else if (tg_exe_->status_ == TG_STATUS_ERROR) {
uint32_t tg_fail_exp;
uint32_t tg_fail_act;
uint64_t tg_fail_addr;
tg_fail_addr = tg_exe_->read64(TG_FIRST_FAIL_ADDR_L);
tg_fail_exp = tg_exe_->read64(TG_FAIL_EXPECTED_DATA);
tg_fail_act = tg_exe_->read64(TG_FAIL_READ_DATA);
std::cerr << "TG status error" << std::endl;
std::cout << "Failed at address 0x" << std::hex << tg_fail_addr
cerr << "TG status error" << std::endl;
cout << "Failed at address 0x" << std::hex << tg_fail_addr
<< " exp=0x" << tg_fail_exp << " act=0x" << tg_fail_act
<< std::endl;
<< endl;
} else {
tg_exe_->logger_->debug("TG pass");
}

uint64_t clk_count = tg_exe_->read64(MEM_TG_CLK_COUNT);
std::cout << "TG Read and Write Clock Cycles: " << std::dec << clk_count
<< std::endl;
cout << "TG Read and Write Clock Cycles: " << dec << clk_count
<< endl;
uint64_t wr_clk_count = tg_exe_->read64(MEM_TG_WR_COUNT);
std::cout << "TG Write Clock Cycles: " << std::dec << wr_clk_count << std::endl;
cout << "TG Write Clock Cycles: " << dec << wr_clk_count << endl;

uint64_t rd_clk_count = clk_count - wr_clk_count;
std::cout << "TG Read Clock Cycles: " << std::dec << rd_clk_count
<< std::endl;
cout << "TG Read Clock Cycles: " << dec << rd_clk_count
<< endl;

uint64_t write_bytes =
64 * (tg_exe_->loop_ * tg_exe_->wcnt_ * tg_exe_->bcnt_);
uint64_t read_bytes =
64 * (tg_exe_->loop_ * tg_exe_->rcnt_ * tg_exe_->bcnt_);

std::cout << "Write bytes: " << std::dec << write_bytes
<< std::endl;
std::cout << "Read bytes: " << std::dec << read_bytes
<< std::endl;
std::cout << "Write BW: " << bw_calc(write_bytes, wr_clk_count) << " GB/s"
<< std::endl;
std::cout << "Read BW: " << bw_calc(read_bytes, rd_clk_count) << " GB/s"
<< std::endl;
std::cout << "Total BW: " << bw_calc(write_bytes + read_bytes, clk_count) << " GB/s\n"
<< std::endl;
cout << "Write bytes: " << std::dec << write_bytes
<< endl;
cout << "Read bytes: " << std::dec << read_bytes
<< endl;

if (wr_clk_count > 0)
cout << "Write BW: " << bw_calc(write_bytes, wr_clk_count) << " GB/s"
<< endl;
else
cout << "Write BW: N/A" << endl;

if (rd_clk_count > 0)
cout << "Read BW: " << bw_calc(read_bytes, rd_clk_count) << " GB/s"
<< endl;
else
cout << "Read BW: N/A" << endl;

if (clk_count > 0)
cout << "Total BW: " << bw_calc(write_bytes + read_bytes, clk_count) << " GB/s\n"
<< endl;
else
cout << "Total BW: N/A" << endl;
}

void tg_print_fail_info() {
Expand Down

0 comments on commit 00253a1

Please sign in to comment.