From: Zhushuai Yin <yinzhushuai@huawei.com> Provide a public tool interface that can obtain the device ID through the device name. Signed-off-by: Zhushuai Yin <yinzhushuai@huawei.com> Signed-off-by: Zongyu Wu <wuzongyu1@huawei.com> --- uadk_tool/benchmark/uadk_benchmark.c | 33 ++++++++++++++++++++++++++++ uadk_tool/benchmark/uadk_benchmark.h | 8 +++++++ 2 files changed, 41 insertions(+) diff --git a/uadk_tool/benchmark/uadk_benchmark.c b/uadk_tool/benchmark/uadk_benchmark.c index d2826ad..24737c5 100644 --- a/uadk_tool/benchmark/uadk_benchmark.c +++ b/uadk_tool/benchmark/uadk_benchmark.c @@ -200,6 +200,29 @@ void set_run_state(int state) g_run_state = state; } +int uadk_parse_dev_id(char *dev_name) +{ + char *last_dash = NULL; + char *endptr; + int dev_id; + + if (!dev_name) + return -WD_EINVAL; + + /* Find the last '-' in the string. */ + last_dash = strrchr(dev_name, '-'); + if (!last_dash || *(last_dash + 1) == '\0') + return -WD_EINVAL; + + /* Parse the following number */ + dev_id = strtol(last_dash + 1, &endptr, 10); + /* Check whether it is truly all digits */ + if (*endptr != '\0' || dev_id < 0) + return -WD_EINVAL; + + return dev_id; +} + static int get_alg_type(const char *alg_name) { int alg = ALG_MAX; @@ -717,6 +740,7 @@ int acc_cmd_parse(int argc, char *argv[], struct acc_option *option) {"complevel", required_argument, 0, 16}, {"init2", no_argument, 0, 17}, {"device", required_argument, 0, 18}, + {"memory", required_argument, 0, 19}, {0, 0, 0, 0} }; @@ -788,6 +812,9 @@ int acc_cmd_parse(int argc, char *argv[], struct acc_option *option) } strcpy(option->device, optarg); break; + case 19: + option->mem_type = strtol(optarg, NULL, 0); + break; default: ACC_TST_PRT("invalid: bad input parameter!\n"); print_benchmark_help(); @@ -864,6 +891,12 @@ int acc_option_convert(struct acc_option *option) goto param_err; } + /* Memory mode is only valid in SVA mode */ + if (option->mem_type > UADK_PROXY) { + ACC_TST_PRT("uadk benchmark memory type set error!\n"); + goto param_err; + } + return 0; param_err: diff --git a/uadk_tool/benchmark/uadk_benchmark.h b/uadk_tool/benchmark/uadk_benchmark.h index b03db6e..81ace1b 100644 --- a/uadk_tool/benchmark/uadk_benchmark.h +++ b/uadk_tool/benchmark/uadk_benchmark.h @@ -81,6 +81,13 @@ struct acc_option { bool latency; u32 sched_type; int task_type; + int mem_type; +}; + +enum uadk_mem_mode { + UADK_AUTO, // SVA or No-SVA + UADK_MANUAL, // No-SVA User manual + UADK_PROXY, // No-SVA UADK API proxy }; enum acc_type { @@ -224,6 +231,7 @@ extern void cal_avg_latency(u32 count); extern int get_alg_name(int alg, char *alg_name); extern void segmentfault_handler(int sig); +int uadk_parse_dev_id(char *dev_name); int acc_cmd_parse(int argc, char *argv[], struct acc_option *option); int acc_default_case(struct acc_option *option); int acc_option_convert(struct acc_option *option); -- 2.33.0