From 07f39bdd50561dfc8ce7dff86f86766a2a8c9dce Mon Sep 17 00:00:00 2001 From: leonidk Date: Tue, 7 Oct 2008 14:57:45 +0000 Subject: [PATCH] [TOOLS] bugfix in latency tests. The tests didn't take into account that the time stamping function (QueryPerformanceCounter) can take a lot of time. But in Win2008 in takes more than 1.1 usec, which causes printing latency value 1.1 usec more than it really is ! git-svn-id: svn://openib.tc.cornell.edu/gen1@1635 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- .../tools/perftests/user/read_lat/read_lat.c | 2 +- .../tools/perftests/user/send_lat/send_lat.c | 2 +- .../perftests/user/write_lat/write_lat.c | 35 +++++++++++++------ 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/trunk/tools/perftests/user/read_lat/read_lat.c b/trunk/tools/perftests/user/read_lat/read_lat.c index 8692a1e0..d3484321 100644 --- a/trunk/tools/perftests/user/read_lat/read_lat.c +++ b/trunk/tools/perftests/user/read_lat/read_lat.c @@ -547,13 +547,13 @@ int run_iter(struct pingpong_context *ctx, struct user_parameters *user_param, if(user_param->servername) { while (scnt < user_param->iters ) { - tstamp[scnt] = get_cycles(); ib_status = ib_post_send(ctx->qp[0], &ctx->wr, &bad_wr); if (ib_status != IB_SUCCESS) { fprintf(stderr, "Couldn't post send: scnt %d ccnt %d\n",scnt,ccnt); return 1; } + tstamp[scnt] = get_cycles(); ++scnt; PERF_DEBUG("scnt = %d \n",scnt); diff --git a/trunk/tools/perftests/user/send_lat/send_lat.c b/trunk/tools/perftests/user/send_lat/send_lat.c index a4931479..a78194f4 100644 --- a/trunk/tools/perftests/user/send_lat/send_lat.c +++ b/trunk/tools/perftests/user/send_lat/send_lat.c @@ -731,13 +731,13 @@ int run_iter(struct pingpong_context *ctx, struct user_parameters *user_param, } /* client post first */ - tstamp[scnt] = get_cycles(); *post_buf = (char)++scnt; if (ib_post_send(qp,&ctx->wr, &bad_wr)) { fprintf(stderr, "Couldn't post send: scnt=%d\n", scnt); return 11; } + tstamp[scnt-1] = get_cycles(); } if (poll == 1) { ib_wc_t wc; diff --git a/trunk/tools/perftests/user/write_lat/write_lat.c b/trunk/tools/perftests/user/write_lat/write_lat.c index 4c0afff4..28d89a65 100644 --- a/trunk/tools/perftests/user/write_lat/write_lat.c +++ b/trunk/tools/perftests/user/write_lat/write_lat.c @@ -48,6 +48,7 @@ struct user_parameters { int all; /* run all msg size */ int iters; int tx_depth; + int stamp_freq; /* to measure once in 'stamp_freq' iterations */ }; static int page_size; @@ -470,6 +471,7 @@ static void usage(const char *argv0) printf(" -s, --size= size of message to exchange (default 1)\n"); printf(" -a, --all Run sizes from 2 till 2^23\n"); printf(" -t, --tx-depth= size of tx queue (default 50)\n"); + printf(" -f, --freq= frequence of taking of time stamp\n"); printf(" -n, --iters= number of exchanges (at least 2, default 1000)\n"); printf(" -C, --report-cycles report times in cpu cycle units (default microseconds)\n"); printf(" -H, --report-histogram print out all results (default print summary only)\n"); @@ -480,12 +482,13 @@ static void usage(const char *argv0) static void print_report(struct report_options * options, - unsigned int iters, cycles_t *tstamp, int size) + unsigned int full_iters, cycles_t *tstamp, int size, int freq) { double cycles_to_units; cycles_t median; unsigned int i; const char* units; + unsigned int iters = full_iters / freq; cycles_t *delta = malloc(iters * sizeof *delta); if (!delta) { @@ -494,8 +497,7 @@ static void print_report(struct report_options * options, } for (i = 0; i < iters - 1; ++i) - delta[i] = tstamp[i + 1] - tstamp[i]; - + delta[i] = (tstamp[i + 1] - tstamp[i]); if (options->cycles) { cycles_to_units = 1; @@ -516,13 +518,15 @@ static void print_report(struct report_options * options, if (options->histogram) { printf("#, %s\n", units); for (i = 0; i < iters - 1; ++i) - printf("%d, %g\n", i + 1, delta[i] / cycles_to_units / 2); + printf("%d, %g\n", i + 1, delta[i] / freq / cycles_to_units / 2); } median = get_median(iters - 1, delta); printf("%7d %d %7.2f %7.2f %7.2f\n", - size,iters,delta[0] / cycles_to_units / 2, - delta[iters - 2] / cycles_to_units / 2,median / cycles_to_units / 2); + size, + iters,delta[0] / freq / cycles_to_units / 2, + delta[iters - 2] / freq / cycles_to_units / 2, + median / freq / cycles_to_units / 2); free(delta); } @@ -537,6 +541,7 @@ int run_iter(struct pingpong_context *ctx, struct user_parameters *user_param, ib_send_wr_t *bad_wr; volatile char *poll_buf; volatile char *post_buf; + int freq = 0, tcnt; @@ -560,6 +565,7 @@ int run_iter(struct pingpong_context *ctx, struct user_parameters *user_param, scnt = 0; rcnt = 0; ccnt = 0; + tcnt = 0; if(user_param->all == ALL) { post_buf = (char*)ctx->buf + size - 1; @@ -584,7 +590,6 @@ int run_iter(struct pingpong_context *ctx, struct user_parameters *user_param, if (scnt < user_param->iters) { - tstamp[scnt] = get_cycles(); *post_buf = (char)++scnt; ib_status = ib_post_send(ctx->qp[0], &ctx->wr, &bad_wr); @@ -593,6 +598,10 @@ int run_iter(struct pingpong_context *ctx, struct user_parameters *user_param, fprintf(stderr, "Couldn't post send:scnt %d ccnt=%d \n",scnt,ccnt); return 1; } + if (++freq >= user_param->stamp_freq) { + tstamp[tcnt++] = get_cycles(); + freq = 0; + } } if (ccnt < user_param->iters) { @@ -654,6 +663,7 @@ int __cdecl main(int argc, char *argv[]) user_param.mtu = 0; /* signal choose default by device */ user_param.iters = 1000; user_param.tx_depth = 50; + user_param.stamp_freq = 1; user_param.servername = NULL; /* Parameter parsing. */ while (1) { @@ -668,6 +678,7 @@ int __cdecl main(int argc, char *argv[]) { "size", 1, NULL, 's' }, { "iters", 1, NULL, 'n' }, { "tx-depth", 1, NULL, 't' }, + { "stamp_freq", 1, NULL, 'f' }, { "all", 0, NULL, 'a' }, { "report-cycles", 0, NULL, 'C' }, { "report-histogram", 0, NULL, 'H' }, @@ -676,7 +687,7 @@ int __cdecl main(int argc, char *argv[]) { 0 } }; - c = getopt_long(argc, argv, "p:c:m:d:i:s:n:t:aCHUV", long_options, NULL); + c = getopt_long(argc, argv, "p:c:m:d:i:s:n:t:f:aCHUV", long_options, NULL); if (c == -1) break; @@ -750,6 +761,10 @@ int __cdecl main(int argc, char *argv[]) report.unsorted = 1; break; + case 'f': + user_param.stamp_freq = strtol(optarg, NULL, 0); + break; + default: usage(argv[0]); return 5; @@ -817,12 +832,12 @@ int __cdecl main(int argc, char *argv[]) size = 1 << i; if(run_iter(ctx, &user_param, rem_dest, size)) return 17; - print_report(&report, user_param.iters, tstamp, size); + print_report(&report, user_param.iters, tstamp, size, user_param.stamp_freq); } } else { if(run_iter(ctx, &user_param, rem_dest, size)) return 18; - print_report(&report, user_param.iters, tstamp, size); + print_report(&report, user_param.iters, tstamp, size, user_param.stamp_freq); } send(sockfd, "done", sizeof "done",0); closesocket(sockfd); -- 2.41.0