Skip to content

Commit

Permalink
Perftest: Fix average BW calculation bug
Browse files Browse the repository at this point in the history
As part of the gap_cycles calculation inside
run_iter_bw, Perftest calculate number_of_bursts.
when using SW_RATE_LIMIT with rate_limit smaller
than the message size we can get into a scenario where
number_of_bursts equal 0 because its an unsigned int.
this commit fix this problem by changing number_of_bursts
into double and allows it to be fraction.
this also increase the accurate of the calculation.

Signed-off-by: Shmuel Shaul <sshaul@nvidia.com>
  • Loading branch information
sshaulnv authored and HassanKhadour committed Dec 7, 2022
1 parent 98c8b01 commit 1ef49c4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/perftest_resources.c
Original file line number Diff line number Diff line change
Expand Up @@ -3582,7 +3582,7 @@ int run_iter_bw(struct pingpong_context *ctx,struct perftest_parameters *user_pa
double gap_time = 0; /* in usec */
cycles_t gap_cycles = 0; /* in cycles */
cycles_t gap_deadline = 0;
unsigned int number_of_bursts = 0;
double number_of_bursts = 0;
int burst_iter = 0;
int is_sending_burst = 0;
int cpu_mhz = 0;
Expand Down Expand Up @@ -3649,7 +3649,7 @@ int run_iter_bw(struct pingpong_context *ctx,struct perftest_parameters *user_pa
if (cpu_mhz <= 0) {
fprintf(stderr, "Failed: couldn't acquire cpu frequency for rate limiter.\n");
}
number_of_bursts = rate_limit_pps / user_param->burst_size;
number_of_bursts = (double)rate_limit_pps / (double)user_param->burst_size;
gap_time = 1000000 * (1.0 / number_of_bursts);
gap_cycles = cpu_mhz * gap_time;
}
Expand Down

1 comment on commit 1ef49c4

@doctormin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for finding & fixing it!

Please sign in to comment.