Skip to content

Commit

Permalink
app/compress-perf: add weak functions for multicore test
Browse files Browse the repository at this point in the history
This patch adds template functions for multi-cores performance
version of compress-perf-tool

Signed-off-by: Tomasz Jozwiak <tomaszx.jozwiak@intel.com>
Acked-by: Artur Trybula <arturx.trybula@intel.com>
Acked-by: Shally Verma <shallyv@marvell.com>
  • Loading branch information
TomekJozwiak authored and akhilnxp committed Jul 19, 2019
1 parent 316095e commit 424dd6c
Show file tree
Hide file tree
Showing 8 changed files with 646 additions and 402 deletions.
3 changes: 1 addition & 2 deletions app/test-compress-perf/Makefile
Expand Up @@ -12,7 +12,6 @@ CFLAGS += -O3
# all source are stored in SRCS-y
SRCS-y := main.c
SRCS-y += comp_perf_options_parse.c
SRCS-y += comp_perf_test_verify.c
SRCS-y += comp_perf_test_benchmark.c
SRCS-y += comp_perf_test_common.c

include $(RTE_SDK)/mk/rte.app.mk
50 changes: 50 additions & 0 deletions app/test-compress-perf/comp_perf.h
@@ -0,0 +1,50 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2019 Intel Corporation
*/

#ifndef _COMP_PERF_
#define _COMP_PERF_

#include <rte_mempool.h>

struct comp_test_data;

typedef void *(*cperf_constructor_t)(
uint8_t dev_id,
uint16_t qp_id,
struct comp_test_data *options);

typedef int (*cperf_runner_t)(void *test_ctx);
typedef void (*cperf_destructor_t)(void *test_ctx);

struct cperf_test {
cperf_constructor_t constructor;
cperf_runner_t runner;
cperf_destructor_t destructor;
};

/* Needed for weak functions*/

void *
cperf_benchmark_test_constructor(uint8_t dev_id __rte_unused,
uint16_t qp_id __rte_unused,
struct comp_test_data *options __rte_unused);

void
cperf_benchmark_test_destructor(void *arg __rte_unused);

int
cperf_benchmark_test_runner(void *test_ctx __rte_unused);

void *
cperf_verify_test_constructor(uint8_t dev_id __rte_unused,
uint16_t qp_id __rte_unused,
struct comp_test_data *options __rte_unused);

void
cperf_verify_test_destructor(void *arg __rte_unused);

int
cperf_verify_test_runner(void *test_ctx __rte_unused);

#endif /* _COMP_PERF_ */
44 changes: 25 additions & 19 deletions app/test-compress-perf/comp_perf_options.h
Expand Up @@ -13,6 +13,23 @@
#define MAX_MBUF_DATA_SIZE (UINT16_MAX - RTE_PKTMBUF_HEADROOM)
#define MAX_SEG_SIZE ((int)(MAX_MBUF_DATA_SIZE / EXPANSE_RATIO))

extern const char *cperf_test_type_strs[];

/* Cleanup state machine */
enum cleanup_st {
ST_CLEAR = 0,
ST_TEST_DATA,
ST_COMPDEV,
ST_INPUT_DATA,
ST_MEMORY_ALLOC,
ST_DURING_TEST
};

enum cperf_perf_test_type {
CPERF_TEST_TYPE_BENCHMARK,
CPERF_TEST_TYPE_VERIFY
};

enum comp_operation {
COMPRESS_ONLY,
DECOMPRESS_ONLY,
Expand All @@ -30,37 +47,26 @@ struct range_list {
struct comp_test_data {
char driver_name[64];
char input_file[64];
struct rte_mbuf **comp_bufs;
struct rte_mbuf **decomp_bufs;
uint32_t total_bufs;
enum cperf_perf_test_type test;

uint8_t *input_data;
size_t input_data_sz;
uint8_t *compressed_data;
uint8_t *decompressed_data;
struct rte_mempool *comp_buf_pool;
struct rte_mempool *decomp_buf_pool;
struct rte_mempool *op_pool;
int8_t cdev_id;
uint16_t nb_qps;
uint16_t seg_sz;
uint16_t out_seg_sz;
uint16_t burst_sz;
uint32_t pool_sz;
uint32_t num_iter;
uint16_t max_sgl_segs;

enum rte_comp_huffman huffman_enc;
enum comp_operation test_op;
int window_sz;
struct range_list level;
/* Store TSC duration for all levels (including level 0) */
uint64_t comp_tsc_duration[RTE_COMP_LEVEL_MAX + 1];
uint64_t decomp_tsc_duration[RTE_COMP_LEVEL_MAX + 1];
size_t comp_data_sz;
size_t decomp_data_sz;
struct range_list level_lst;
uint8_t level;

double ratio;
double comp_gbps;
double decomp_gbps;
double comp_tsc_byte;
double decomp_tsc_byte;
enum cleanup_st cleanup;
};

int
Expand Down
24 changes: 12 additions & 12 deletions app/test-compress-perf/comp_perf_options_parse.c
Expand Up @@ -468,19 +468,20 @@ parse_level(struct comp_test_data *test_data, const char *arg)
* Try parsing the argument as a range, if it fails,
* arse it as a list
*/
if (parse_range(arg, &test_data->level.min, &test_data->level.max,
&test_data->level.inc) < 0) {
ret = parse_list(arg, test_data->level.list,
&test_data->level.min,
&test_data->level.max);
if (parse_range(arg, &test_data->level_lst.min,
&test_data->level_lst.max,
&test_data->level_lst.inc) < 0) {
ret = parse_list(arg, test_data->level_lst.list,
&test_data->level_lst.min,
&test_data->level_lst.max);
if (ret < 0) {
RTE_LOG(ERR, USER1,
"Failed to parse compression level/s\n");
return -1;
}
test_data->level.count = ret;
test_data->level_lst.count = ret;

if (test_data->level.max > RTE_COMP_LEVEL_MAX) {
if (test_data->level_lst.max > RTE_COMP_LEVEL_MAX) {
RTE_LOG(ERR, USER1, "Level cannot be higher than %u\n",
RTE_COMP_LEVEL_MAX);
return -1;
Expand All @@ -500,7 +501,6 @@ struct long_opt_parser {
};

static struct option lgopts[] = {

{ CPERF_DRIVER_NAME, required_argument, 0, 0 },
{ CPERF_TEST_FILE, required_argument, 0, 0 },
{ CPERF_SEG_SIZE, required_argument, 0, 0 },
Expand Down Expand Up @@ -574,7 +574,6 @@ comp_perf_options_parse(struct comp_test_data *test_data, int argc, char **argv)
void
comp_perf_options_default(struct comp_test_data *test_data)
{
test_data->cdev_id = -1;
test_data->seg_sz = 2048;
test_data->burst_sz = 32;
test_data->pool_sz = 8192;
Expand All @@ -583,9 +582,10 @@ comp_perf_options_default(struct comp_test_data *test_data)
test_data->huffman_enc = RTE_COMP_HUFFMAN_DYNAMIC;
test_data->test_op = COMPRESS_DECOMPRESS;
test_data->window_sz = -1;
test_data->level.min = 1;
test_data->level.max = 9;
test_data->level.inc = 1;
test_data->level_lst.min = 1;
test_data->level_lst.max = 9;
test_data->level_lst.inc = 1;
test_data->test = CPERF_TEST_TYPE_BENCHMARK;
}

int
Expand Down

0 comments on commit 424dd6c

Please sign in to comment.