From da40ebd6d3836ed2c8827af93dcafeec6883ebdd Mon Sep 17 00:00:00 2001 From: Pablo de Lara Date: Mon, 27 Mar 2017 12:26:03 +0100 Subject: [PATCH] app/crypto-perf: display results in test runner Instead of printing the test results in the destructor function, print them just after each run. This will be useful for after the commit that allows a range of buffer and burst sizes. Signed-off-by: Pablo de Lara Acked-by: Sergio Gonzalez Monroy --- app/test-crypto-perf/cperf_test_latency.c | 150 +++++++------------ app/test-crypto-perf/cperf_test_throughput.c | 132 +++++++--------- app/test-crypto-perf/cperf_test_verify.c | 102 ++++++------- 3 files changed, 151 insertions(+), 233 deletions(-) diff --git a/app/test-crypto-perf/cperf_test_latency.c b/app/test-crypto-perf/cperf_test_latency.c index 657d0772a8..20d70699bc 100644 --- a/app/test-crypto-perf/cperf_test_latency.c +++ b/app/test-crypto-perf/cperf_test_latency.c @@ -39,26 +39,6 @@ #include "cperf_ops.h" -struct cperf_latency_results { - - uint64_t ops_failed; - - uint64_t enqd_tot; - uint64_t enqd_max; - uint64_t enqd_min; - - uint64_t deqd_tot; - uint64_t deqd_max; - uint64_t deqd_min; - - uint64_t cycles_tot; - uint64_t cycles_max; - uint64_t cycles_min; - - uint64_t burst_num; - uint64_t num; -}; - struct cperf_op_result { uint64_t tsc_start; uint64_t tsc_end; @@ -84,7 +64,6 @@ struct cperf_latency_ctx { const struct cperf_options *options; const struct cperf_test_vector *test_vector; struct cperf_op_result *res; - struct cperf_latency_results results; }; #define max(a, b) (a > b ? (uint64_t)a : (uint64_t)b) @@ -248,9 +227,6 @@ cperf_latency_test_constructor(uint8_t dev_id, uint16_t qp_id, goto err; /* Generate mbufs_in with plaintext populated for test */ - if (ctx->options->pool_sz % ctx->options->burst_sz) - goto err; - ctx->mbufs_in = rte_malloc(NULL, (sizeof(struct rte_mbuf *) * ctx->options->pool_sz), 0); @@ -325,18 +301,14 @@ cperf_latency_test_runner(void *arg) struct cperf_latency_ctx *ctx = arg; struct cperf_op_result *pres; + static int only_once; + if (ctx == NULL) return 0; struct rte_crypto_op *ops[ctx->options->burst_sz]; struct rte_crypto_op *ops_processed[ctx->options->burst_sz]; - uint64_t ops_enqd = 0, ops_deqd = 0; - uint64_t m_idx = 0, b_idx = 0, i; - - uint64_t tsc_val, tsc_end, tsc_start; - uint64_t tsc_max = 0, tsc_min = ~0UL, tsc_tot = 0, tsc_idx = 0; - uint64_t enqd_max = 0, enqd_min = ~0UL, enqd_tot = 0; - uint64_t deqd_max = 0, deqd_min = ~0UL, deqd_tot = 0; + uint64_t i; uint32_t lcore = rte_lcore_id(); @@ -359,8 +331,15 @@ cperf_latency_test_runner(void *arg) for (i = 0; i < ctx->options->total_ops; i++) rte_cryptodev_enqueue_burst(ctx->dev_id, ctx->qp_id, NULL, 0); - while (enqd_tot < ctx->options->total_ops) { + uint64_t ops_enqd = 0, ops_deqd = 0; + uint64_t m_idx = 0, b_idx = 0; + + uint64_t tsc_val, tsc_end, tsc_start; + uint64_t tsc_max = 0, tsc_min = ~0UL, tsc_tot = 0, tsc_idx = 0; + uint64_t enqd_max = 0, enqd_min = ~0UL, enqd_tot = 0; + uint64_t deqd_max = 0, deqd_min = ~0UL, deqd_tot = 0; + while (enqd_tot < ctx->options->total_ops) { uint16_t burst_size = ((enqd_tot + ctx->options->burst_sz) <= ctx->options->total_ops) ? ctx->options->burst_sz : @@ -478,69 +457,30 @@ cperf_latency_test_runner(void *arg) tsc_tot += tsc_val; } - ctx->results.enqd_tot = enqd_tot; - ctx->results.enqd_max = enqd_max; - ctx->results.enqd_min = enqd_min; - - ctx->results.deqd_tot = deqd_tot; - ctx->results.deqd_max = deqd_max; - ctx->results.deqd_min = deqd_min; - - ctx->results.cycles_tot = tsc_tot; - ctx->results.cycles_max = tsc_max; - ctx->results.cycles_min = tsc_min; - - ctx->results.burst_num = b_idx; - ctx->results.num = tsc_idx; - - return 0; -} - -void -cperf_latency_test_destructor(void *arg) -{ - struct cperf_latency_ctx *ctx = arg; - uint64_t i; - if (ctx == NULL) - return; - static int only_once; - uint64_t etot, eavg, emax, emin; - uint64_t dtot, davg, dmax, dmin; - uint64_t ctot, cavg, cmax, cmin; - double ttot, tavg, tmax, tmin; + double time_tot, time_avg, time_max, time_min; const uint64_t tunit = 1000000; /* us */ const uint64_t tsc_hz = rte_get_tsc_hz(); - etot = ctx->results.enqd_tot; - eavg = ctx->results.enqd_tot / ctx->results.burst_num; - emax = ctx->results.enqd_max; - emin = ctx->results.enqd_min; - - dtot = ctx->results.deqd_tot; - davg = ctx->results.deqd_tot / ctx->results.burst_num; - dmax = ctx->results.deqd_max; - dmin = ctx->results.deqd_min; + uint64_t enqd_avg = enqd_tot / b_idx; + uint64_t deqd_avg = deqd_tot / b_idx; + uint64_t tsc_avg = tsc_tot / tsc_idx; - ctot = ctx->results.cycles_tot; - cavg = ctx->results.cycles_tot / ctx->results.num; - cmax = ctx->results.cycles_max; - cmin = ctx->results.cycles_min; - - ttot = tunit*(double)(ctot) / tsc_hz; - tavg = tunit*(double)(cavg) / tsc_hz; - tmax = tunit*(double)(cmax) / tsc_hz; - tmin = tunit*(double)(cmin) / tsc_hz; + time_tot = tunit*(double)(tsc_tot) / tsc_hz; + time_avg = tunit*(double)(tsc_avg) / tsc_hz; + time_max = tunit*(double)(tsc_max) / tsc_hz; + time_min = tunit*(double)(tsc_min) / tsc_hz; if (ctx->options->csv) { if (!only_once) - printf("\n# lcore, Pakt Seq #, Packet Size, cycles," - " time (us)"); + printf("\n# lcore, Buffer Size, Burst Size, Pakt Seq #, " + "Packet Size, cycles, time (us)"); for (i = 0; i < ctx->options->total_ops; i++) { - printf("\n%u;%"PRIu64";%"PRIu64";%.3f", - ctx->lcore_id, i + 1, + printf("\n%u;%u;%u;%"PRIu64";%"PRIu64";%.3f", + ctx->lcore_id, ctx->options->buffer_sz, + ctx->options->burst_sz, i + 1, ctx->res[i].tsc_end - ctx->res[i].tsc_start, tunit * (double) (ctx->res[i].tsc_end - ctx->res[i].tsc_start) @@ -552,22 +492,40 @@ cperf_latency_test_destructor(void *arg) printf("\n# Device %d on lcore %u\n", ctx->dev_id, ctx->lcore_id); printf("\n# total operations: %u", ctx->options->total_ops); - printf("\n# burst number: %"PRIu64, - ctx->results.burst_num); + printf("\n# Buffer size: %u", ctx->options->buffer_sz); + printf("\n# Burst size: %u", ctx->options->burst_sz); + printf("\n# Number of bursts: %"PRIu64, + b_idx); + printf("\n#"); - printf("\n# \t Total\t Average\t Maximum\t " - " Minimum"); - printf("\n# enqueued\t%12"PRIu64"\t%10"PRIu64"\t%10"PRIu64"\t" - "%10"PRIu64, etot, eavg, emax, emin); - printf("\n# dequeued\t%12"PRIu64"\t%10"PRIu64"\t%10"PRIu64"\t" - "%10"PRIu64, dtot, davg, dmax, dmin); - printf("\n# cycles\t%12"PRIu64"\t%10"PRIu64"\t%10"PRIu64"\t" - "%10"PRIu64, ctot, cavg, cmax, cmin); - printf("\n# time [us]\t%12.0f\t%10.3f\t%10.3f\t%10.3f", ttot, - tavg, tmax, tmin); + printf("\n# \t Total\t Average\t " + "Maximum\t Minimum"); + printf("\n# enqueued\t%12"PRIu64"\t%10"PRIu64"\t" + "%10"PRIu64"\t%10"PRIu64, enqd_tot, + enqd_avg, enqd_max, enqd_min); + printf("\n# dequeued\t%12"PRIu64"\t%10"PRIu64"\t" + "%10"PRIu64"\t%10"PRIu64, deqd_tot, + deqd_avg, deqd_max, deqd_min); + printf("\n# cycles\t%12"PRIu64"\t%10"PRIu64"\t" + "%10"PRIu64"\t%10"PRIu64, tsc_tot, + tsc_avg, tsc_max, tsc_min); + printf("\n# time [us]\t%12.0f\t%10.3f\t%10.3f\t%10.3f", + time_tot, time_avg, time_max, time_min); printf("\n\n"); } + + return 0; +} + +void +cperf_latency_test_destructor(void *arg) +{ + struct cperf_latency_ctx *ctx = arg; + + if (ctx == NULL) + return; + cperf_latency_test_free(ctx, ctx->options->pool_sz); } diff --git a/app/test-crypto-perf/cperf_test_throughput.c b/app/test-crypto-perf/cperf_test_throughput.c index 710807531d..32c5bad203 100644 --- a/app/test-crypto-perf/cperf_test_throughput.c +++ b/app/test-crypto-perf/cperf_test_throughput.c @@ -38,18 +38,6 @@ #include "cperf_test_throughput.h" #include "cperf_ops.h" -struct cperf_throughput_results { - uint64_t ops_enqueued; - uint64_t ops_dequeued; - - uint64_t ops_enqueued_failed; - uint64_t ops_dequeued_failed; - - double ops_per_second; - double throughput_gbps; - double cycles_per_byte; -}; - struct cperf_throughput_ctx { uint8_t dev_id; uint16_t qp_id; @@ -68,8 +56,6 @@ struct cperf_throughput_ctx { const struct cperf_options *options; const struct cperf_test_vector *test_vector; - struct cperf_throughput_results results; - }; static void @@ -229,9 +215,6 @@ cperf_throughput_test_constructor(uint8_t dev_id, uint16_t qp_id, goto err; /* Generate mbufs_in with plaintext populated for test */ - if (ctx->options->pool_sz % ctx->options->burst_sz) - goto err; - ctx->mbufs_in = rte_malloc(NULL, (sizeof(struct rte_mbuf *) * ctx->options->pool_sz), 0); @@ -297,15 +280,11 @@ cperf_throughput_test_runner(void *test_ctx) { struct cperf_throughput_ctx *ctx = test_ctx; - uint64_t ops_enqd = 0, ops_enqd_total = 0, ops_enqd_failed = 0; - uint64_t ops_deqd = 0, ops_deqd_total = 0, ops_deqd_failed = 0; - - uint64_t i, m_idx = 0, tsc_start, tsc_end, tsc_duration; - - uint16_t ops_unused = 0; + static int only_once; struct rte_crypto_op *ops[ctx->options->burst_sz]; struct rte_crypto_op *ops_processed[ctx->options->burst_sz]; + uint64_t i; uint32_t lcore = rte_lcore_id(); @@ -324,18 +303,19 @@ cperf_throughput_test_runner(void *test_ctx) ctx->lcore_id = lcore; - if (!ctx->options->csv) - printf("\n# Running throughput test on device: %u, lcore: %u\n", - ctx->dev_id, lcore); - /* Warm up the host CPU before starting the test */ for (i = 0; i < ctx->options->total_ops; i++) rte_cryptodev_enqueue_burst(ctx->dev_id, ctx->qp_id, NULL, 0); - tsc_start = rte_rdtsc_precise(); + uint64_t ops_enqd = 0, ops_enqd_total = 0, ops_enqd_failed = 0; + uint64_t ops_deqd = 0, ops_deqd_total = 0, ops_deqd_failed = 0; + uint64_t m_idx = 0, tsc_start, tsc_end, tsc_duration; + tsc_start = rte_rdtsc_precise(); while (ops_enqd_total < ctx->options->total_ops) { + uint16_t ops_unused = 0; + uint16_t burst_size = ((ops_enqd_total + ctx->options->burst_sz) <= ctx->options->total_ops) ? ctx->options->burst_sz : @@ -433,22 +413,59 @@ cperf_throughput_test_runner(void *test_ctx) tsc_duration = (tsc_end - tsc_start); /* Calculate average operations processed per second */ - ctx->results.ops_per_second = ((double)ctx->options->total_ops / + double ops_per_second = ((double)ctx->options->total_ops / tsc_duration) * rte_get_tsc_hz(); /* Calculate average throughput (Gbps) in bits per second */ - ctx->results.throughput_gbps = ((ctx->results.ops_per_second * + double throughput_gbps = ((ops_per_second * ctx->options->buffer_sz * 8) / 1000000000); - /* Calculate average cycles per byte */ - ctx->results.cycles_per_byte = ((double)tsc_duration / - ctx->options->total_ops) / ctx->options->buffer_sz; + /* Calculate average cycles per packet */ + double cycles_per_packet = ((double)tsc_duration / + ctx->options->total_ops); - ctx->results.ops_enqueued = ops_enqd_total; - ctx->results.ops_dequeued = ops_deqd_total; + if (!ctx->options->csv) { + if (!only_once) + printf("%12s%12s%12s%12s%12s%12s%12s%12s%12s%12s\n\n", + "lcore id", "Buf Size", "Burst Size", + "Enqueued", "Dequeued", "Failed Enq", + "Failed Deq", "MOps", "Gbps", + "Cycles/Buf"); + only_once = 1; + + printf("%12u%12u%12u%12"PRIu64"%12"PRIu64"%12"PRIu64 + "%12"PRIu64"%12.4f%12.4f%12.2f\n", + ctx->lcore_id, + ctx->options->buffer_sz, + ctx->options->burst_sz, + ops_enqd_total, + ops_deqd_total, + ops_enqd_failed, + ops_deqd_failed, + ops_per_second/1000000, + throughput_gbps, + cycles_per_packet); + } else { + if (!only_once) + printf("# lcore id, Buffer Size(B)," + "Burst Size,Enqueued,Dequeued,Failed Enq," + "Failed Deq,Ops(Millions),Throughput(Gbps)," + "Cycles/Buf\n\n"); + only_once = 1; - ctx->results.ops_enqueued_failed = ops_enqd_failed; - ctx->results.ops_dequeued_failed = ops_deqd_failed; + printf("%10u;%10u;%u;%"PRIu64";%"PRIu64";%"PRIu64";%"PRIu64";" + "%.f3;%.f3;%.f3\n", + ctx->lcore_id, + ctx->options->buffer_sz, + ctx->options->burst_sz, + ops_enqd_total, + ops_deqd_total, + ops_enqd_failed, + ops_deqd_failed, + ops_per_second/1000000, + throughput_gbps, + cycles_per_packet); + } return 0; } @@ -458,50 +475,9 @@ void cperf_throughput_test_destructor(void *arg) { struct cperf_throughput_ctx *ctx = arg; - struct cperf_throughput_results *results = &ctx->results; - static int only_once; if (ctx == NULL) return; - if (!ctx->options->csv) { - printf("\n# Device %d on lcore %u\n", - ctx->dev_id, ctx->lcore_id); - printf("# Buffer Size(B)\t Enqueued\t Dequeued\tFailed Enq" - "\tFailed Deq\tOps(Millions)\tThroughput(Gbps)" - "\tCycles Per Byte\n"); - - printf("\n%16u\t%10"PRIu64"\t%10"PRIu64"\t%10"PRIu64"\t" - "%10"PRIu64"\t%16.4f\t%16.4f\t%15.2f\n", - ctx->options->buffer_sz, - results->ops_enqueued, - results->ops_dequeued, - results->ops_enqueued_failed, - results->ops_dequeued_failed, - results->ops_per_second/1000000, - results->throughput_gbps, - results->cycles_per_byte); - } else { - if (!only_once) - printf("\n# CPU lcore id, Burst Size(B), " - "Buffer Size(B),Enqueued,Dequeued,Failed Enq," - "Failed Deq,Ops(Millions),Throughput(Gbps)," - "Cycles Per Byte\n"); - only_once = 1; - - printf("%u;%u;%u;%"PRIu64";%"PRIu64";%"PRIu64";%"PRIu64";" - "%.f3;%.f3;%.f3\n", - ctx->lcore_id, - ctx->options->burst_sz, - ctx->options->buffer_sz, - results->ops_enqueued, - results->ops_dequeued, - results->ops_enqueued_failed, - results->ops_dequeued_failed, - results->ops_per_second/1000000, - results->throughput_gbps, - results->cycles_per_byte); - } - cperf_throughput_test_free(ctx, ctx->options->pool_sz); } diff --git a/app/test-crypto-perf/cperf_test_verify.c b/app/test-crypto-perf/cperf_test_verify.c index be157e63b0..b58b86c8e5 100644 --- a/app/test-crypto-perf/cperf_test_verify.c +++ b/app/test-crypto-perf/cperf_test_verify.c @@ -38,16 +38,6 @@ #include "cperf_test_verify.h" #include "cperf_ops.h" -struct cperf_verify_results { - uint64_t ops_enqueued; - uint64_t ops_dequeued; - - uint64_t ops_enqueued_failed; - uint64_t ops_dequeued_failed; - - uint64_t ops_failed; -}; - struct cperf_verify_ctx { uint8_t dev_id; uint16_t qp_id; @@ -66,8 +56,6 @@ struct cperf_verify_ctx { const struct cperf_options *options; const struct cperf_test_vector *test_vector; - struct cperf_verify_results results; - }; struct cperf_op_result { @@ -231,9 +219,6 @@ cperf_verify_test_constructor(uint8_t dev_id, uint16_t qp_id, goto err; /* Generate mbufs_in with plaintext populated for test */ - if (ctx->options->pool_sz % ctx->options->burst_sz) - goto err; - ctx->mbufs_in = rte_malloc(NULL, (sizeof(struct rte_mbuf *) * ctx->options->pool_sz), 0); @@ -388,7 +373,7 @@ cperf_verify_op(struct rte_crypto_op *op, if (options->auth_op == RTE_CRYPTO_AUTH_OP_GENERATE) res += memcmp(data + auth_offset, vector->digest.data, - vector->digest.length); + options->auth_digest_sz); } return !!res; @@ -401,6 +386,9 @@ cperf_verify_test_runner(void *test_ctx) uint64_t ops_enqd = 0, ops_enqd_total = 0, ops_enqd_failed = 0; uint64_t ops_deqd = 0, ops_deqd_total = 0, ops_deqd_failed = 0; + uint64_t ops_failed = 0; + + static int only_once; uint64_t i, m_idx = 0; uint16_t ops_unused = 0; @@ -498,15 +486,15 @@ cperf_verify_test_runner(void *test_ctx) for (i = 0; i < ops_deqd; i++) { if (cperf_verify_op(ops_processed[i], ctx->options, ctx->test_vector)) - ctx->results.ops_failed++; + ops_failed++; /* free crypto ops so they can be reused. We don't free * the mbufs here as we don't want to reuse them as * the crypto operation will change the data and cause * failures. */ rte_crypto_op_free(ops_processed[i]); - ops_deqd_total += ops_deqd; } + ops_deqd_total += ops_deqd; } /* Dequeue any operations still in the crypto device */ @@ -526,22 +514,53 @@ cperf_verify_test_runner(void *test_ctx) for (i = 0; i < ops_deqd; i++) { if (cperf_verify_op(ops_processed[i], ctx->options, ctx->test_vector)) - ctx->results.ops_failed++; + ops_failed++; /* free crypto ops so they can be reused. We don't free * the mbufs here as we don't want to reuse them as * the crypto operation will change the data and cause * failures. */ rte_crypto_op_free(ops_processed[i]); - ops_deqd_total += ops_deqd; } + ops_deqd_total += ops_deqd; } - ctx->results.ops_enqueued = ops_enqd_total; - ctx->results.ops_dequeued = ops_deqd_total; + if (!ctx->options->csv) { + if (!only_once) + printf("%12s%12s%12s%12s%12s%12s%12s%12s\n\n", + "lcore id", "Buf Size", "Burst size", + "Enqueued", "Dequeued", "Failed Enq", + "Failed Deq", "Failed Ops"); + only_once = 1; + + printf("%12u%12u%12u%12"PRIu64"%12"PRIu64"%12"PRIu64 + "%12"PRIu64"%12"PRIu64"\n", + ctx->lcore_id, + ctx->options->buffer_sz, + ctx->options->burst_sz, + ops_enqd_total, + ops_deqd_total, + ops_enqd_failed, + ops_deqd_failed, + ops_failed); + } else { + if (!only_once) + printf("\n# lcore id, Buffer Size(B), " + "Burst Size,Enqueued,Dequeued,Failed Enq," + "Failed Deq,Failed Ops\n"); + only_once = 1; - ctx->results.ops_enqueued_failed = ops_enqd_failed; - ctx->results.ops_dequeued_failed = ops_deqd_failed; + printf("%10u;%10u;%u;%"PRIu64";%"PRIu64";%"PRIu64";%"PRIu64";" + "%"PRIu64"\n", + ctx->lcore_id, + ctx->options->buffer_sz, + ctx->options->burst_sz, + ops_enqd_total, + ops_deqd_total, + ops_enqd_failed, + ops_deqd_failed, + ops_failed); + } return 0; } @@ -552,44 +571,9 @@ void cperf_verify_test_destructor(void *arg) { struct cperf_verify_ctx *ctx = arg; - struct cperf_verify_results *results = &ctx->results; - static int only_once; if (ctx == NULL) return; - if (!ctx->options->csv) { - printf("\n# Device %d on lcore %u\n", - ctx->dev_id, ctx->lcore_id); - printf("# Buffer Size(B)\t Enqueued\t Dequeued\tFailed Enq" - "\tFailed Deq\tEmpty Polls\n"); - - printf("\n%16u\t%10"PRIu64"\t%10"PRIu64"\t%10"PRIu64"\t" - "%10"PRIu64"\t%10"PRIu64"\n", - ctx->options->buffer_sz, - results->ops_enqueued, - results->ops_dequeued, - results->ops_enqueued_failed, - results->ops_dequeued_failed, - results->ops_failed); - } else { - if (!only_once) - printf("\n# CPU lcore id, Burst Size(B), " - "Buffer Size(B),Enqueued,Dequeued,Failed Enq," - "Failed Deq,Empty Polls\n"); - only_once = 1; - - printf("%u;%u;%u;%"PRIu64";%"PRIu64";%"PRIu64";%"PRIu64";" - "%"PRIu64"\n", - ctx->lcore_id, - ctx->options->burst_sz, - ctx->options->buffer_sz, - results->ops_enqueued, - results->ops_dequeued, - results->ops_enqueued_failed, - results->ops_dequeued_failed, - results->ops_failed); - } - cperf_verify_test_free(ctx, ctx->options->pool_sz); } -- 2.20.1