From: Hao Fang fanghao11@huawei.com
Signed-off-by: Hao Fang fanghao11@huawei.com Signed-off-by: Qi Tao taoqi10@huawei.com --- uadk_tool/test/comp_lib.c | 147 +----------------------------------- uadk_tool/test/comp_lib.h | 23 ------ uadk_tool/test/comp_main.c | 150 ++----------------------------------- 3 files changed, 6 insertions(+), 314 deletions(-)
diff --git a/uadk_tool/test/comp_lib.c b/uadk_tool/test/comp_lib.c index 9a8a39d..4eee19f 100644 --- a/uadk_tool/test/comp_lib.c +++ b/uadk_tool/test/comp_lib.c @@ -391,24 +391,6 @@ static void *async2_cb(struct wd_comp_req *req, void *data) return NULL; }
-/* used in BATCH mode */ -static void *async5_cb(struct wd_comp_req *req, void *data) -{ - thread_data_t *tdata = (thread_data_t *)data; - - pthread_spin_lock(&lock); - tdata->pcnt++; - if (tdata->batch_flag && (tdata->pcnt == tdata->bcnt)) { - tdata->pcnt = 0; - tdata->bcnt = 0; - tdata->batch_flag = 0; - pthread_spin_unlock(&lock); - sem_post(&tdata->sem); - } else - pthread_spin_unlock(&lock); - return NULL; -} - void init_chunk_list(chunk_list_t *list, void *buf, size_t buf_sz, size_t chunk_sz) { @@ -707,128 +689,6 @@ out: return ret; }
-/* used in BATCH mode */ -int hw_deflate5(handle_t h_dfl, - chunk_list_t *in_list, - chunk_list_t *out_list, - thread_data_t *tdata) -{ - struct hizip_test_info *info = tdata->info; - struct test_options *opts = info->opts; - struct wd_comp_req *reqs = tdata->reqs; - chunk_list_t *p = in_list, *q = out_list; - int i = 0, ret = 0; - - if (!in_list || !out_list || !opts) - return -EINVAL; - for (p = in_list, q = out_list; p && q; p = p->next, q = q->next) { - reqs[i].src = p->addr; - reqs[i].src_len = p->size; - reqs[i].dst = q->addr; - reqs[i].dst_len = q->size; - reqs[i].op_type = WD_DIR_COMPRESS; - reqs[i].data_fmt = opts->data_fmt; - if (opts->sync_mode) { - reqs[i].cb = async5_cb; - reqs[i].cb_param = tdata; - } else { - reqs[i].cb = NULL; - reqs[i].cb_param = NULL; - } - if (opts->sync_mode) { - do { - ret = wd_do_comp_async(h_dfl, &reqs[i]); - } while (ret == -WD_EBUSY); - if (ret < 0) - goto out; - __atomic_add_fetch(&sum_pend, 1, __ATOMIC_ACQ_REL); - pthread_spin_lock(&lock); - tdata->bcnt++; - if (((i + 1) == opts->batch_num) || !p->next) { - tdata->batch_flag = 1; - pthread_spin_unlock(&lock); - sem_wait(&tdata->sem); - } else - pthread_spin_unlock(&lock); - } else { - do { - ret = wd_do_comp_sync(h_dfl, &reqs[i]); - } while (ret == -WD_EBUSY); - if (ret) - goto out; - } - q->size = reqs[i].dst_len; - i = (i + 1) % opts->batch_num; - /* make sure olist has the same length with ilist */ - if (!p->next) - q->next = NULL; - } - return 0; -out: - return ret; -} - -/* used in BATCH mode */ -int hw_inflate5(handle_t h_ifl, - chunk_list_t *in_list, - chunk_list_t *out_list, - thread_data_t *tdata) -{ - struct hizip_test_info *info = tdata->info; - struct test_options *opts = info->opts; - struct wd_comp_req *reqs = tdata->reqs; - chunk_list_t *p = in_list, *q = out_list; - int ret = 0, i = 0; - - if (!in_list || !out_list || !opts) - return -EINVAL; - for (p = in_list, q = out_list; p && q; p = p->next, q = q->next) { - reqs[i].src = p->addr; - reqs[i].src_len = p->size; - reqs[i].dst = q->addr; - reqs[i].dst_len = q->size; - reqs[i].op_type = WD_DIR_DECOMPRESS; - reqs[i].data_fmt = opts->data_fmt; - if (opts->sync_mode) { - reqs[i].cb = async5_cb; - reqs[i].cb_param = tdata; - } else { - reqs[i].cb = NULL; - reqs[i].cb_param = NULL; - } - if (opts->sync_mode) { - do { - ret = wd_do_comp_async(h_ifl, &reqs[i]); - } while (ret == -WD_EBUSY); - if (ret < 0) - goto out; - __atomic_add_fetch(&sum_pend, 1, __ATOMIC_ACQ_REL); - pthread_spin_lock(&lock); - tdata->bcnt++; - if (((i + 1) == opts->batch_num) || !p->next) { - tdata->batch_flag = 1; - pthread_spin_unlock(&lock); - sem_wait(&tdata->sem); - } else - pthread_spin_unlock(&lock); - } else { - do { - ret = wd_do_comp_sync(h_ifl, &reqs[i]); - } while (ret == -WD_EBUSY); - if (ret) - goto out; - } - q->size = reqs[i].dst_len; - i = (i + 1) % opts->batch_num; - /* make sure olist has the same length with ilist */ - if (!p->next) - q->next = NULL; - } - return 0; -out: - return ret; -} - /* * info->in_buf & info->out_buf should be allocated first. * Thread 0 shares info->out_buf. Other threads need to create its own @@ -853,10 +713,6 @@ int create_send_tdata(struct test_options *opts, ret = -ENOMEM; goto out; } - if (!opts->batch_num) - opts->batch_num = 1; - else if (opts->batch_num > HIZIP_CHUNK_LIST_ENTRIES) - opts->batch_num = HIZIP_CHUNK_LIST_ENTRIES; if (opts->is_stream) { in_list = create_chunk_list(info->in_buf, info->in_size, info->in_size); @@ -915,8 +771,7 @@ int create_send_tdata(struct test_options *opts, goto out_list; } calculate_md5(&tdata->md5, tdata->src, tdata->src_sz); - tdata->reqs = malloc(sizeof(struct wd_comp_req) * - opts->batch_num); + tdata->reqs = malloc(sizeof(struct wd_comp_req)); if (!tdata->reqs) goto out_list; sem_init(&tdata->sem, 0, 0); diff --git a/uadk_tool/test/comp_lib.h b/uadk_tool/test/comp_lib.h index cd16b1d..bbd7db0 100644 --- a/uadk_tool/test/comp_lib.h +++ b/uadk_tool/test/comp_lib.h @@ -80,12 +80,6 @@ struct test_options { int poll_num; /* 0: sync mode, 1: async mode */ int sync_mode; - /* - * positive value: the number of messages are sent at a time. - * 0: batch mode is disabled. - * batch mode is only valid for ASYNC operations. - */ - int batch_num; /* input file */ int fd_in; /* output file */ @@ -143,15 +137,6 @@ typedef struct _thread_data_t { size_t dst_sz; size_t sum; /* produced bytes for OUT */ int tid; /* thread ID */ - int bcnt; /* batch mode: count */ - int pcnt; /* batch mode: poll count */ - int flush_bcnt; /* batch mode: flush count that is less batch_num */ - /* - * batch mode: set flag and wait batch end in sending thread. - * Clear batch flag if pcnt == bcnt in polling thread. - * batch_flag could replace flush_bcnt. - */ - int batch_flag; sem_t sem; chunk_list_t *in_list; chunk_list_t *out_list; @@ -219,14 +204,6 @@ int hw_inflate(handle_t h_ifl, struct test_options *opts, sem_t *sem);
-int hw_deflate5(handle_t h_dfl, - chunk_list_t *in_list, - chunk_list_t *out_list, - thread_data_t *tdata); -int hw_inflate5(handle_t h_ifl, - chunk_list_t *in_list, - chunk_list_t *out_list, - thread_data_t *tdata); int create_send_tdata(struct test_options *opts, struct hizip_test_info *info); int create_poll_tdata(struct test_options *opts, diff --git a/uadk_tool/test/comp_main.c b/uadk_tool/test/comp_main.c index 21fb920..aabb8cc 100644 --- a/uadk_tool/test/comp_main.c +++ b/uadk_tool/test/comp_main.c @@ -635,126 +635,6 @@ out: return (void *)(uintptr_t)(ret); }
-/* BATCH mode is used */ -void *hw_dfl_perf3(void *arg) -{ - thread_data_t *tdata = (thread_data_t *)arg; - struct hizip_test_info *info = tdata->info; - struct test_options *opts = info->opts; - struct wd_comp_sess_setup setup = {0}; - struct sched_params param = {0}; - handle_t h_dfl; - int i, ret; - uint32_t tout_sz; - - if (opts->is_stream) { - for (i = 0; i < opts->compact_run_num; i++) { - tout_sz = tdata->dst_sz; - ret = hw_stream_compress(opts, - tdata->dst, - &tout_sz, - tdata->src, - tdata->src_sz); - if (ret) { - COMP_TST_PRT("Fail to deflate by HW: %d\n", ret); - return (void *)(uintptr_t)ret; - } - } - tdata->out_list->addr = tdata->dst; - tdata->out_list->size = tout_sz; - tdata->out_list->next = NULL; - return NULL; - } - - setup.alg_type = opts->alg_type; - setup.op_type = WD_DIR_COMPRESS; - param.type = setup.op_type; - param.numa_id = 0; - setup.sched_param = ¶m; - h_dfl = wd_comp_alloc_sess(&setup); - if (!h_dfl) - return (void *)(uintptr_t)(-EINVAL); - - for (i = 0; i < opts->compact_run_num; i++) { - init_chunk_list(tdata->out_list, tdata->dst, - tdata->dst_sz, - info->out_chunk_sz); - ret = hw_deflate5(h_dfl, tdata->in_list, tdata->out_list, - tdata); - if (ret) { - COMP_TST_PRT("Fail to deflate by HW: %d\n", ret); - goto out; - } - } - wd_comp_free_sess(h_dfl); - /* mark sending thread to end */ - __atomic_add_fetch(&sum_thread_end, 1, __ATOMIC_ACQ_REL); - return NULL; -out: - wd_comp_free_sess(h_dfl); - return (void *)(uintptr_t)(ret); -} - -/* BATCH mode is used */ -void *hw_ifl_perf3(void *arg) -{ - thread_data_t *tdata = (thread_data_t *)arg; - struct hizip_test_info *info = tdata->info; - struct test_options *opts = info->opts; - struct wd_comp_sess_setup setup = {0}; - struct sched_params param = {0}; - handle_t h_ifl; - int i, ret; - uint32_t tout_sz; - - if (opts->is_stream) { - for (i = 0; i < opts->compact_run_num; i++) { - tout_sz = tdata->dst_sz; - ret = hw_stream_compress(opts, - tdata->dst, - &tout_sz, - tdata->src, - tdata->src_sz); - if (ret) { - COMP_TST_PRT("Fail to inflate by HW: %d\n", ret); - return (void *)(uintptr_t)ret; - } - tdata->out_list->addr = tdata->dst; - tdata->out_list->size = tout_sz; - tdata->out_list->next = NULL; - } - return NULL; - } - - setup.alg_type = opts->alg_type; - setup.op_type = WD_DIR_DECOMPRESS; - param.type = setup.op_type; - param.numa_id = 0; - setup.sched_param = ¶m; - h_ifl = wd_comp_alloc_sess(&setup); - if (!h_ifl) - return (void *)(uintptr_t)(-EINVAL); - - for (i = 0; i < opts->compact_run_num; i++) { - init_chunk_list(tdata->out_list, tdata->dst, - tdata->dst_sz, - info->out_chunk_sz); - ret = hw_inflate5(h_ifl, tdata->in_list, tdata->out_list, - tdata); - if (ret) { - COMP_TST_PRT("Fail to inflate by HW: %d\n", ret); - goto out; - } - } - wd_comp_free_sess(h_ifl); - /* mark sending thread to end */ - __atomic_add_fetch(&sum_thread_end, 1, __ATOMIC_ACQ_REL); - return NULL; -out: - wd_comp_free_sess(h_ifl); - return (void *)(uintptr_t)(ret); -} - /* * Load compression/decompression content. */ @@ -903,15 +783,6 @@ int test_hw(struct test_options *opts, char *model) zbuf_idx = sprintf(zbuf, "HW %s %s deflate", opts->sync_mode ? "ASYNC" : "SYNC", opts->is_stream ? "STREAM" : "BLOCK"); - } else if (!strcmp(model, "hw_dfl_perf3")) { - func = hw_dfl_perf3; - info.in_size = opts->total_len; - info.out_size = opts->total_len * EXPANSION_RATIO; - info.in_chunk_sz = opts->block_size; - info.out_chunk_sz = opts->block_size * EXPANSION_RATIO; - zbuf_idx = sprintf(zbuf, "HW %s %s deflate", - opts->sync_mode ? "ASYNC" : "SYNC", - opts->is_stream ? "STREAM" : "BLOCK"); } else if (!strcmp(model, "hw_ifl_perf")) { func = hw_ifl_perf; info.in_size = opts->total_len; @@ -922,16 +793,6 @@ int test_hw(struct test_options *opts, char *model) opts->sync_mode ? "ASYNC" : "SYNC", opts->is_stream ? "STREAM" : "BLOCK"); ifl_flag = 1; - } else if (!strcmp(model, "hw_ifl_perf3")) { - func = hw_ifl_perf3; - info.in_size = opts->total_len * EXPANSION_RATIO; - info.out_size = opts->total_len; - info.in_chunk_sz = opts->block_size; - info.out_chunk_sz = opts->block_size * INFLATION_RATIO; - zbuf_idx = sprintf(zbuf, "HW %s %s inflate", - opts->sync_mode ? "ASYNC" : "SYNC", - opts->is_stream ? "STREAM" : "BLOCK"); - ifl_flag = 1; } else { COMP_TST_PRT("Wrong model is specified:%s\n", model); ret = -EINVAL; @@ -1051,13 +912,12 @@ int test_hw(struct test_options *opts, char *model) " with %d send threads", opts->thread_num); } - if (!strcmp(model, "hw_dfl_perf") || !strcmp(model, "hw_ifl_perf") || - !strcmp(model, "hw_dfl_perf3") || !strcmp(model, "hw_ifl_perf3")) { - COMP_TST_PRT("%s at %.2fMB/s in %f usec (BLK:%d, Bnum:%d).\n", - zbuf, speed, usec, opts->block_size, opts->batch_num); + if (!strcmp(model, "hw_dfl_perf") || !strcmp(model, "hw_ifl_perf")) { + COMP_TST_PRT("%s at %.2fMB/s in %f usec (BLK:%d).\n", + zbuf, speed, usec, opts->block_size); } else { - COMP_TST_PRT("%s in %f usec (BLK:%d, Bnum:%d).\n", - zbuf, usec, opts->block_size, opts->batch_num); + COMP_TST_PRT("%s in %f usec (BLK:%d).\n", + zbuf, usec, opts->block_size); } free_threads_tdata(&info); if (opts->use_env)