libwd/0056-uadk-tools-support-new-parameters-for-compression.patch
2023-11-23 10:41:04 +08:00

428 lines
14 KiB
Diff

From 8591a69ee1ce5a796390bde817813aaa61f40cf8 Mon Sep 17 00:00:00 2001
From: Yang Shen <shenyang39@huawei.com>
Date: Fri, 10 Nov 2023 11:52:25 +0800
Subject: [PATCH 56/85] uadk/tools - support new parameters for compression
Support the new configure parameters for uadk compression.
Signed-off-by: Yang Shen <shenyang39@huawei.com>
---
uadk_tool/benchmark/uadk_benchmark.c | 46 ++++++++++--------
uadk_tool/benchmark/uadk_benchmark.h | 8 ++--
uadk_tool/benchmark/zip_uadk_benchmark.c | 61 +++++++++++++++---------
uadk_tool/benchmark/zip_wd_benchmark.c | 34 ++++++++-----
4 files changed, 91 insertions(+), 58 deletions(-)
diff --git a/uadk_tool/benchmark/uadk_benchmark.c b/uadk_tool/benchmark/uadk_benchmark.c
index f903829..d869688 100644
--- a/uadk_tool/benchmark/uadk_benchmark.c
+++ b/uadk_tool/benchmark/uadk_benchmark.c
@@ -429,7 +429,7 @@ void cal_perfermance_data(struct acc_option *option, u32 sttime)
ops = perfops / option->times;
cpu_rate = (double)ptime / option->times;
ACC_TST_PRT("algname: length: perf: iops: CPU_rate:\n"
- "%s %-2uBytes %.1fKB/s %.1fKops %.2f%%\n",
+ "%s %-2uBytes %.1fKB/s %.1fKops %.2f%%\n",
palgname, option->pktlen, perfermance, ops, cpu_rate);
}
@@ -572,7 +572,7 @@ int acc_default_case(struct acc_option *option)
option->multis = 1;
option->ctxnums = 2;
- return acc_benchmark_run(option);
+ return acc_benchmark_run(option);
}
static void print_help(void)
@@ -634,21 +634,23 @@ int acc_cmd_parse(int argc, char *argv[], struct acc_option *option)
int c;
static struct option long_options[] = {
- {"alg", required_argument, 0, 1},
- {"mode", required_argument, 0, 2},
- {"opt", required_argument, 0, 3},
- {"sync", no_argument, 0,4},
- {"async", no_argument, 0,5},
- {"pktlen", required_argument, 0, 6},
- {"seconds", required_argument, 0, 7},
- {"thread", required_argument, 0, 8},
- {"multi", required_argument, 0, 9},
- {"ctxnum", required_argument, 0, 10},
- {"prefetch", no_argument, 0,11},
- {"engine", required_argument, 0,12},
- {"alglist", no_argument, 0, 13},
- {"latency", no_argument, 0, 14},
- {"help", no_argument, 0, 15},
+ {"help", no_argument, 0, 0},
+ {"alg", required_argument, 0, 1},
+ {"mode", required_argument, 0, 2},
+ {"opt", required_argument, 0, 3},
+ {"sync", no_argument, 0, 4},
+ {"async", no_argument, 0, 5},
+ {"pktlen", required_argument, 0, 6},
+ {"seconds", required_argument, 0, 7},
+ {"thread", required_argument, 0, 8},
+ {"multi", required_argument, 0, 9},
+ {"ctxnum", required_argument, 0, 10},
+ {"prefetch", no_argument, 0, 11},
+ {"engine", required_argument, 0, 12},
+ {"alglist", no_argument, 0, 13},
+ {"latency", no_argument, 0, 14},
+ {"winsize", required_argument, 0, 15},
+ {"complevel", required_argument, 0, 16},
{0, 0, 0, 0}
};
@@ -658,6 +660,9 @@ int acc_cmd_parse(int argc, char *argv[], struct acc_option *option)
break;
switch (c) {
+ case 0:
+ print_help();
+ goto to_exit;
case 1:
option->algtype = get_alg_type(optarg);
strcpy(option->algname, optarg);
@@ -702,8 +707,11 @@ int acc_cmd_parse(int argc, char *argv[], struct acc_option *option)
option->latency = true;
break;
case 15:
- print_help();
- goto to_exit;
+ option->winsize = strtol(optarg, NULL, 0);
+ break;
+ case 16:
+ option->complevel = strtol(optarg, NULL, 0);
+ break;
default:
ACC_TST_PRT("bad input test parameter!\n");
print_help();
diff --git a/uadk_tool/benchmark/uadk_benchmark.h b/uadk_tool/benchmark/uadk_benchmark.h
index 44e2dd9..71fe2dc 100644
--- a/uadk_tool/benchmark/uadk_benchmark.h
+++ b/uadk_tool/benchmark/uadk_benchmark.h
@@ -55,7 +55,9 @@ typedef unsigned char u8;
* @latency: test packet running time
*/
struct acc_option {
- char algname[64];
+ char algname[64];
+ char algclass[64];
+ char engine[64];
u32 algtype;
u32 modetype;
u32 optype;
@@ -65,12 +67,12 @@ struct acc_option {
u32 threads;
u32 multis;
u32 ctxnums;
- char algclass[64];
u32 acctype;
u32 subtype;
- char engine[64];
u32 engine_flag;
u32 prefetch;
+ u32 winsize;
+ u32 complevel;
bool latency;
};
diff --git a/uadk_tool/benchmark/zip_uadk_benchmark.c b/uadk_tool/benchmark/zip_uadk_benchmark.c
index d74d3fb..747172a 100644
--- a/uadk_tool/benchmark/zip_uadk_benchmark.c
+++ b/uadk_tool/benchmark/zip_uadk_benchmark.c
@@ -8,11 +8,11 @@
#include "include/wd_sched.h"
#include "include/fse.h"
-#define ZIP_TST_PRT printf
-#define PATH_SIZE 64
-#define ZIP_FILE "./zip"
-#define COMP_LEN_RATE 2
-#define DECOMP_LEN_RATE 2
+#define ZIP_TST_PRT printf
+#define PATH_SIZE 64
+#define ZIP_FILE "./zip"
+#define COMP_LEN_RATE 2
+#define DECOMP_LEN_RATE 2
struct uadk_bd {
u8 *src;
@@ -44,9 +44,11 @@ struct zip_async_tag {
typedef struct uadk_thread_res {
u32 alg;
- u32 mode; // block/stream
+ u32 mode;
u32 optype;
u32 td_id;
+ u32 win_sz;
+ u32 comp_lv;
} thread_data;
struct zip_file_head {
@@ -240,10 +242,10 @@ static int zip_uadk_param_parse(thread_data *tddata, struct acc_option *options)
return -EINVAL;
} else if (optype >= WD_DIR_MAX) {
mode = STREAM_MODE;
+ optype = optype % WD_DIR_MAX;
+ options->optype = optype;
}
- optype = optype % WD_DIR_MAX;
-
switch(algtype) {
case ZLIB:
alg = WD_ZLIB;
@@ -268,17 +270,20 @@ static int zip_uadk_param_parse(thread_data *tddata, struct acc_option *options)
tddata->alg = alg;
tddata->mode = mode;
tddata->optype = optype;
+ tddata->win_sz = options->winsize;
+ tddata->comp_lv = options->complevel;
return 0;
}
+static struct sched_params param;
static int init_ctx_config(char *alg, int mode, int optype)
{
struct uacce_dev_list *list;
- struct sched_params param;
int i, max_node;
int ret = 0;
+ optype = optype % WD_DIR_MAX;
max_node = numa_max_node() + 1;
if (max_node <= 0)
return -EINVAL;
@@ -306,7 +311,7 @@ static int init_ctx_config(char *alg, int mode, int optype)
for (i = 0; i < g_ctxnum; i++) {
g_ctx_cfg.ctxs[i].ctx = wd_request_ctx(list->dev);
- g_ctx_cfg.ctxs[i].op_type = 0; // default op_type
+ g_ctx_cfg.ctxs[i].op_type = optype; // default op_type
g_ctx_cfg.ctxs[i].ctx_mode = (__u8)mode;
}
g_sched->name = SCHED_SINGLE;
@@ -315,7 +320,6 @@ static int init_ctx_config(char *alg, int mode, int optype)
* All contexts for 2 modes & 2 types.
* The test only uses one kind of contexts at the same time.
*/
- optype = optype % WD_DIR_MAX;
param.numa_id = list->dev->numa_id;
param.type = optype;
param.mode = mode;
@@ -546,8 +550,9 @@ static void *zip_uadk_blk_lz77_sync_run(void *arg)
comp_setup.alg_type = pdata->alg;
comp_setup.op_type = pdata->optype;
- comp_setup.comp_lv = WD_COMP_L8;
- comp_setup.win_sz = WD_COMP_WS_8K;
+ comp_setup.win_sz = pdata->win_sz;
+ comp_setup.comp_lv = pdata->comp_lv;
+ comp_setup.sched_param = &param;
h_sess = wd_comp_alloc_sess(&comp_setup);
if (!h_sess)
return NULL;
@@ -639,8 +644,9 @@ static void *zip_uadk_stm_lz77_sync_run(void *arg)
comp_setup.alg_type = pdata->alg;
comp_setup.op_type = pdata->optype;
- comp_setup.comp_lv = WD_COMP_L8;
- comp_setup.win_sz = WD_COMP_WS_8K;
+ comp_setup.win_sz = pdata->win_sz;
+ comp_setup.comp_lv = pdata->comp_lv;
+ comp_setup.sched_param = &param;
h_sess = wd_comp_alloc_sess(&comp_setup);
if (!h_sess)
return NULL;
@@ -733,8 +739,9 @@ static void *zip_uadk_blk_lz77_async_run(void *arg)
comp_setup.alg_type = pdata->alg;
comp_setup.op_type = pdata->optype;
- comp_setup.comp_lv = WD_COMP_L8;
- comp_setup.win_sz = WD_COMP_WS_8K;
+ comp_setup.win_sz = pdata->win_sz;
+ comp_setup.comp_lv = pdata->comp_lv;
+ comp_setup.sched_param = &param;
h_sess = wd_comp_alloc_sess(&comp_setup);
if (!h_sess)
return NULL;
@@ -837,8 +844,9 @@ static void *zip_uadk_blk_sync_run(void *arg)
comp_setup.alg_type = pdata->alg;
comp_setup.op_type = pdata->optype;
- comp_setup.comp_lv = WD_COMP_L8;
- comp_setup.win_sz = WD_COMP_WS_8K;
+ comp_setup.win_sz = pdata->win_sz;
+ comp_setup.comp_lv = pdata->comp_lv;
+ comp_setup.sched_param = &param;
h_sess = wd_comp_alloc_sess(&comp_setup);
if (!h_sess)
return NULL;
@@ -896,8 +904,9 @@ static void *zip_uadk_stm_sync_run(void *arg)
comp_setup.alg_type = pdata->alg;
comp_setup.op_type = pdata->optype;
- comp_setup.comp_lv = WD_COMP_L8;
- comp_setup.win_sz = WD_COMP_WS_8K;
+ comp_setup.win_sz = pdata->win_sz;
+ comp_setup.comp_lv = pdata->comp_lv;
+ comp_setup.sched_param = &param;
h_sess = wd_comp_alloc_sess(&comp_setup);
if (!h_sess)
return NULL;
@@ -961,8 +970,9 @@ static void *zip_uadk_blk_async_run(void *arg)
comp_setup.alg_type = pdata->alg;
comp_setup.op_type = pdata->optype;
- comp_setup.comp_lv = WD_COMP_L8;
- comp_setup.win_sz = WD_COMP_WS_8K;
+ comp_setup.win_sz = pdata->win_sz;
+ comp_setup.comp_lv = pdata->comp_lv;
+ comp_setup.sched_param = &param;
h_sess = wd_comp_alloc_sess(&comp_setup);
if (!h_sess)
return NULL;
@@ -1044,6 +1054,7 @@ static int zip_uadk_sync_threads(struct acc_option *options)
if (ret)
return ret;
+ threads_option.optype = options->optype;
if (threads_option.mode == 1) {// stream mode
if (threads_option.alg == LZ77_ZSTD)
uadk_zip_sync_run = zip_uadk_stm_lz77_sync_run;
@@ -1059,6 +1070,8 @@ static int zip_uadk_sync_threads(struct acc_option *options)
threads_args[i].alg = threads_option.alg;
threads_args[i].mode = threads_option.mode;
threads_args[i].optype = threads_option.optype;
+ threads_args[i].win_sz = threads_option.win_sz;
+ threads_args[i].comp_lv = threads_option.comp_lv;
threads_args[i].td_id = i;
ret = pthread_create(&tdid[i], NULL, uadk_zip_sync_run, &threads_args[i]);
if (ret) {
@@ -1119,6 +1132,8 @@ static int zip_uadk_async_threads(struct acc_option *options)
threads_args[i].alg = threads_option.alg;
threads_args[i].mode = threads_option.mode;
threads_args[i].optype = threads_option.optype;
+ threads_args[i].win_sz = threads_option.win_sz;
+ threads_args[i].comp_lv = threads_option.comp_lv;
threads_args[i].td_id = i;
ret = pthread_create(&tdid[i], NULL, uadk_zip_async_run, &threads_args[i]);
if (ret) {
diff --git a/uadk_tool/benchmark/zip_wd_benchmark.c b/uadk_tool/benchmark/zip_wd_benchmark.c
index cbbbb5d..dc00631 100644
--- a/uadk_tool/benchmark/zip_wd_benchmark.c
+++ b/uadk_tool/benchmark/zip_wd_benchmark.c
@@ -57,9 +57,11 @@ struct zip_async_tag {
typedef struct uadk_thread_res {
u32 alg;
- u32 mode; // block/stream
+ u32 mode;
u32 optype;
u32 td_id;
+ u32 comp_lv;
+ u32 win_size;
} thread_data;
struct zip_file_head {
@@ -277,6 +279,8 @@ static int zip_wd_param_parse(thread_data *tddata, struct acc_option *options)
tddata->alg = alg;
tddata->mode = mode;
tddata->optype = optype;
+ tddata->win_size = options->winsize;
+ tddata->comp_lv = options->complevel;
return 0;
}
@@ -528,8 +532,8 @@ static void *zip_wd_blk_lz77_sync_run(void *arg)
comp_setup.alg_type = pdata->alg;
comp_setup.op_type = pdata->optype;
- comp_setup.comp_lv = WCRYPTO_COMP_L8;
- comp_setup.win_size = WCRYPTO_COMP_WS_8K;
+ comp_setup.comp_lv = pdata->comp_lv;
+ comp_setup.win_size = pdata->win_size;
comp_setup.stream_mode = WCRYPTO_COMP_STATELESS;
ctx = wcrypto_create_comp_ctx(queue, &comp_setup);
@@ -636,8 +640,8 @@ static void *zip_wd_stm_lz77_sync_run(void *arg)
comp_setup.alg_type = pdata->alg;
comp_setup.op_type = pdata->optype;
- comp_setup.comp_lv = WCRYPTO_COMP_L8;
- comp_setup.win_size = WCRYPTO_COMP_WS_8K;
+ comp_setup.comp_lv = pdata->comp_lv;
+ comp_setup.win_size = pdata->win_size;
comp_setup.stream_mode = WCRYPTO_COMP_STATEFUL;
ctx = wcrypto_create_comp_ctx(queue, &comp_setup);
@@ -745,8 +749,8 @@ static void *zip_wd_blk_lz77_async_run(void *arg)
comp_setup.alg_type = pdata->alg;
comp_setup.op_type = pdata->optype;
- comp_setup.comp_lv = WCRYPTO_COMP_L8;
- comp_setup.win_size = WCRYPTO_COMP_WS_8K;
+ comp_setup.comp_lv = pdata->comp_lv;
+ comp_setup.win_size = pdata->win_size;
comp_setup.stream_mode = WCRYPTO_COMP_STATELESS;
comp_setup.cb = zip_lz77_async_cb;
@@ -866,8 +870,8 @@ static void *zip_wd_blk_sync_run(void *arg)
comp_setup.alg_type = pdata->alg;
comp_setup.op_type = pdata->optype;
- comp_setup.comp_lv = WCRYPTO_COMP_L8;
- comp_setup.win_size = WCRYPTO_COMP_WS_8K;
+ comp_setup.comp_lv = pdata->comp_lv;
+ comp_setup.win_size = pdata->win_size;
comp_setup.stream_mode = WCRYPTO_COMP_STATELESS;
ctx = wcrypto_create_comp_ctx(queue, &comp_setup);
@@ -939,8 +943,8 @@ static void *zip_wd_stm_sync_run(void *arg)
comp_setup.alg_type = pdata->alg;
comp_setup.op_type = pdata->optype;
- comp_setup.comp_lv = WCRYPTO_COMP_L8;
- comp_setup.win_size = WCRYPTO_COMP_WS_8K;
+ comp_setup.comp_lv = pdata->comp_lv;
+ comp_setup.win_size = pdata->win_size;
comp_setup.stream_mode = WCRYPTO_COMP_STATEFUL;
ctx = wcrypto_create_comp_ctx(queue, &comp_setup);
@@ -1018,8 +1022,8 @@ static void *zip_wd_blk_async_run(void *arg)
comp_setup.alg_type = pdata->alg;
comp_setup.op_type = pdata->optype;
- comp_setup.comp_lv = WCRYPTO_COMP_L8;
- comp_setup.win_size = WCRYPTO_COMP_WS_8K;
+ comp_setup.comp_lv = pdata->comp_lv;
+ comp_setup.win_size = pdata->win_size;
comp_setup.stream_mode = WCRYPTO_COMP_STATELESS;
comp_setup.cb = zip_async_cb;
@@ -1123,6 +1127,8 @@ static int zip_wd_sync_threads(struct acc_option *options)
threads_args[i].alg = threads_option.alg;
threads_args[i].mode = threads_option.mode;
threads_args[i].optype = threads_option.optype;
+ threads_args[i].comp_lv = threads_option.comp_lv;
+ threads_args[i].win_size = threads_option.win_size;
threads_args[i].td_id = i;
ret = pthread_create(&tdid[i], NULL, wd_zip_sync_run, &threads_args[i]);
if (ret) {
@@ -1183,6 +1189,8 @@ static int zip_wd_async_threads(struct acc_option *options)
threads_args[i].alg = threads_option.alg;
threads_args[i].mode = threads_option.mode;
threads_args[i].optype = threads_option.optype;
+ threads_args[i].comp_lv = threads_option.comp_lv;
+ threads_args[i].win_size = threads_option.win_size;
threads_args[i].td_id = i;
ret = pthread_create(&tdid[i], NULL, wd_zip_async_run, &threads_args[i]);
if (ret) {
--
2.25.1