xref: /dpdk/app/test-mldev/test_inference_common.h (revision 0efea35a2bb0ae9df6e204151c7f96b5eb93e130)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2022 Marvell.
3  */
4 
5 #ifndef TEST_INFERENCE_COMMON_H
6 #define TEST_INFERENCE_COMMON_H
7 
8 #include <rte_common.h>
9 #include <rte_mempool.h>
10 #include <rte_mldev.h>
11 
12 #include "test_model_common.h"
13 
14 #define ML_TEST_MAX_IO_SIZE 32
15 
16 struct ml_request {
17 	uint8_t *input;
18 	uint8_t *output;
19 	uint16_t fid;
20 	uint64_t niters;
21 
22 	struct rte_ml_buff_seg *inp_buf_segs[ML_TEST_MAX_IO_SIZE];
23 	struct rte_ml_buff_seg *out_buf_segs[ML_TEST_MAX_IO_SIZE];
24 };
25 
26 struct ml_core_args {
27 	uint64_t nb_reqs;
28 	uint16_t start_fid;
29 	uint16_t end_fid;
30 	uint32_t qp_id;
31 
32 	struct rte_ml_op **enq_ops;
33 	struct rte_ml_op **deq_ops;
34 	struct ml_request **reqs;
35 
36 	uint64_t start_cycles;
37 	uint64_t end_cycles;
38 };
39 
40 struct __rte_cache_aligned test_inference {
41 	/* common data */
42 	struct test_common cmn;
43 
44 	/* test specific data */
45 	struct ml_model model[ML_TEST_MAX_MODELS];
46 	struct rte_mempool *buf_seg_pool;
47 	struct rte_mempool *op_pool;
48 
49 	uint64_t nb_used;
50 	uint64_t nb_valid;
51 	uint16_t fid;
52 
53 	int (*enqueue)(void *arg);
54 	int (*dequeue)(void *arg);
55 
56 	struct ml_core_args args[RTE_MAX_LCORE];
57 	uint64_t error_count[RTE_MAX_LCORE];
58 
59 	struct rte_ml_dev_xstats_map *xstats_map;
60 	uint64_t *xstats_values;
61 	int xstats_size;
62 };
63 
64 bool test_inference_cap_check(struct ml_options *opt);
65 int test_inference_opt_check(struct ml_options *opt);
66 void test_inference_opt_dump(struct ml_options *opt);
67 int test_inference_setup(struct ml_test *test, struct ml_options *opt);
68 void test_inference_destroy(struct ml_test *test, struct ml_options *opt);
69 
70 int ml_inference_mldev_setup(struct ml_test *test, struct ml_options *opt);
71 int ml_inference_mldev_destroy(struct ml_test *test, struct ml_options *opt);
72 int ml_inference_iomem_setup(struct ml_test *test, struct ml_options *opt, uint16_t fid);
73 void ml_inference_iomem_destroy(struct ml_test *test, struct ml_options *opt, uint16_t fid);
74 int ml_inference_mem_setup(struct ml_test *test, struct ml_options *opt);
75 void ml_inference_mem_destroy(struct ml_test *test, struct ml_options *opt);
76 int ml_inference_result(struct ml_test *test, struct ml_options *opt, uint16_t fid);
77 int ml_inference_launch_cores(struct ml_test *test, struct ml_options *opt, uint16_t start_fid,
78 			      uint16_t end_fid);
79 
80 #endif /* TEST_INFERENCE_COMMON_H */
81