27 #include <odp/helper/odph_api.h>
29 #include <export_results.h>
31 #define EXIT_NOT_SUP 2
32 #define PROG_NAME "odp_dma_perf"
57 #define DEF_TRS_TYPE SYNC_DMA
58 #define DEF_SEG_CNT 1U
60 #define DEF_SEG_TYPE DENSE_PACKET
62 #define DEF_INFLIGHT 1U
64 #define DEF_WORKERS 1U
65 #define DEF_POLICY SINGLE
67 #define MAX_SEGS 1024U
68 #define MAX_WORKERS 32
69 #define MAX_MEMORY (256U * 1024U * 1024U)
71 #define GIGAS 1000000000
88 uint64_t scheduler_timeouts;
89 uint64_t transfer_errs;
96 uint64_t max_start_cc;
97 uint64_t min_start_cc;
100 uint64_t min_wait_cc;
106 uint64_t trs_poll_cnt;
115 uint64_t trs_start_cc;
116 uint64_t trs_poll_cnt;
120 typedef struct sd_s sd_t;
121 typedef void (*ver_fn_t)(trs_info_t *info, stats_t *stats);
125 trs_info_t infos[MAX_SEGS];
131 uint32_t num_in_segs;
132 uint32_t num_out_segs;
133 uint32_t src_seg_len;
134 uint32_t dst_seg_len;
135 uint32_t num_inflight;
159 void (*prep_trs_fn)(sd_t *sd, trs_info_t *info);
164 typedef struct prog_config_s prog_config_t;
168 prog_config_t *prog_config;
178 void (*trs_fn)(sd_t *sd);
184 void (*wait_fn)(sd_t *sd, stats_t *stats);
186 void (*drain_fn)(sd_t *sd);
188 void (*free_fn)(
const sd_t *sd);
191 typedef struct prog_config_s {
192 odph_thread_t threads[MAX_WORKERS];
193 thread_config_t thread_config[MAX_WORKERS];
194 sd_t sds[MAX_WORKERS];
204 uint32_t num_in_segs;
205 uint32_t num_out_segs;
206 uint32_t src_seg_len;
207 uint32_t dst_seg_len;
208 uint32_t num_inflight;
210 uint32_t num_sessions;
211 uint32_t src_cache_size;
212 uint32_t dst_cache_size;
219 test_common_options_t common_options;
222 static prog_config_t *prog_conf;
231 static void init_config(prog_config_t *config)
237 memset(config, 0,
sizeof(*config));
241 config->num_in_segs = DEF_SEG_CNT;
242 config->num_out_segs = DEF_SEG_CNT;
243 config->src_seg_len = DEF_LEN;
244 config->num_inflight = DEF_INFLIGHT;
245 config->time_sec = DEF_TIME;
246 config->num_workers = DEF_WORKERS;
247 config->trs_type = DEF_TRS_TYPE;
248 config->seg_type = DEF_SEG_TYPE;
249 config->compl_mode = DEF_MODE;
250 config->policy = DEF_POLICY;
252 for (uint32_t i = 0U; i < MAX_WORKERS; ++i) {
253 sd = &config->sds[i];
254 stats = &config->thread_config[i].stats;
255 memset(sd, 0,
sizeof(*sd));
257 for (uint32_t j = 0U; j < MAX_SEGS; ++j) {
258 info = &sd->dma.infos[j];
273 stats->min_trs_tm = UINT64_MAX;
274 stats->min_start_cc = UINT64_MAX;
275 stats->min_wait_cc = UINT64_MAX;
276 stats->min_trs_cc = UINT64_MAX;
280 static void print_usage(
void)
283 "DMA performance test. Load DMA subsystem from several workers.\n"
285 "Usage: " PROG_NAME
" [OPTIONS]\n"
287 " E.g. " PROG_NAME
"\n"
288 " " PROG_NAME
" -s 10240\n"
289 " " PROG_NAME
" -t 0 -i 1 -o 1 -s 51200 -S 2 -f 64 -T 10\n"
290 " " PROG_NAME
" -t 1 -i 10 -o 10 -s 4096 -S 0 -m 1 -f 10 -c 4 -p 1\n"
291 " " PROG_NAME
" -t 2 -i 10 -o 1 -s 1024 -S 3 -f 10 -c 4 -p 1\n"
293 "Optional OPTIONS:\n"
295 " -t, --trs_type Transfer type for test data. %u by default.\n"
297 " 0: synchronous DMA\n"
298 " 1: asynchronous DMA\n"
299 " 2: SW memory copy\n"
300 " -i, --num_in_seg Number of input segments to transfer. 0 means the maximum\n"
301 " count supported by the implementation. %u by default.\n"
302 " -o, --num_out_seg Number of output segments to transfer to. 0 means the\n"
303 " maximum count supported by the implementation. %u by\n"
305 " -s, --in_seg_len Input segment length in bytes. 0 length means the maximum\n"
306 " segment length supported by the implementation. The actual\n"
307 " maximum might be limited by what type of data is\n"
308 " transferred (packet/memory). %u by default.\n"
309 " -S, --in_seg_type Input segment data type. Dense types can load the DMA\n"
310 " subsystem more heavily as transfer resources are\n"
311 " pre-configured. Sparse types might on the other hand\n"
312 " reflect application usage more precisely as transfer\n"
313 " resources are configured in runtime. %u by default.\n"
316 " 1: sparse packet\n"
318 " 3: sparse memory\n"
319 " -m, --compl_mode Completion mode for transfers. %u by default.\n"
323 " -f, --max_in_flight Maximum transfers in-flight per session. 0 means the\n"
324 " maximum supported by the tester/implementation. %u by\n"
326 " -T, --time_sec Time in seconds to run. 0 means infinite. %u by default.\n"
327 " -c, --worker_count Amount of workers. %u by default.\n"
328 " -p, --policy DMA session policy. %u by default.\n"
330 " 0: One session shared by workers\n"
331 " 1: One session per worker\n"
332 " -v, --verify Verify transfers. Checks correctness of destination data\n"
333 " after successful transfers.\n"
334 " -h, --help This help.\n"
335 "\n", DEF_TRS_TYPE, DEF_SEG_CNT, DEF_SEG_CNT, DEF_LEN, DEF_SEG_TYPE, DEF_MODE,
336 DEF_INFLIGHT, DEF_TIME, DEF_WORKERS, DEF_POLICY);
339 static parse_result_t check_options(prog_config_t *config)
343 uint32_t num_sessions, max_seg_len, max_trs, max_in, max_out, max_segs;
347 uint64_t shm_size = 0U;
349 if (config->trs_type != SYNC_DMA && config->trs_type != ASYNC_DMA &&
350 config->trs_type != SW_COPY) {
351 ODPH_ERR(
"Invalid transfer type: %u\n", config->trs_type);
355 if (config->seg_type != DENSE_PACKET && config->seg_type != SPARSE_PACKET &&
356 config->seg_type != DENSE_MEMORY && config->seg_type != SPARSE_MEMORY) {
357 ODPH_ERR(
"Invalid segment type: %u\n", config->seg_type);
363 if (config->num_workers <= 0 || config->num_workers > max_workers) {
364 ODPH_ERR(
"Invalid thread count: %d (min: 1, max: %d)\n", config->num_workers,
369 if (config->policy != SINGLE && config->policy != MANY) {
370 ODPH_ERR(
"Invalid DMA session policy: %u\n", config->policy);
375 ODPH_ERR(
"Error querying DMA capabilities\n");
379 num_sessions = config->policy == SINGLE ? 1 : config->num_workers;
382 ODPH_ERR(
"Not enough DMA sessions supported: %u (max: %u)\n", num_sessions,
387 config->num_sessions = num_sessions;
389 if (config->num_in_segs == 0U)
392 if (config->num_out_segs == 0U)
397 config->num_in_segs + config->num_out_segs > dma_capa.
max_segs) {
398 ODPH_ERR(
"Unsupported segment count configuration, in: %u, out: %u (max in: %u, "
399 "max out: %u, max tot: %u)\n", config->num_in_segs, config->num_out_segs,
404 if (config->src_seg_len == 0U)
407 config->dst_seg_len = config->src_seg_len * config->num_in_segs /
408 config->num_out_segs + config->src_seg_len *
409 config->num_in_segs % config->num_out_segs;
411 max_seg_len = ODPH_MAX(config->src_seg_len, config->dst_seg_len);
414 ODPH_ERR(
"Unsupported total DMA segment length: %u (max: %u)\n", max_seg_len,
419 if (config->trs_type == ASYNC_DMA) {
420 if (config->compl_mode != POLL && config->compl_mode != EVENT) {
421 ODPH_ERR(
"Invalid completion mode: %u\n", config->compl_mode);
427 ODPH_ERR(
"Unsupported DMA completion mode, poll\n");
431 if (config->compl_mode == EVENT) {
433 ODPH_ERR(
"Unsupported amount of completion pools: %u (max: %u)\n",
439 ODPH_ERR(
"Unsupported DMA completion mode, event\n");
444 ODPH_ERR(
"Unsupported DMA queueing type, scheduled\n");
448 if (config->num_inflight > dma_capa.
pool.
max_num) {
449 ODPH_ERR(
"Unsupported amount of completion events: %u (max: %u)\n",
455 ODPH_ERR(
"Error querying scheduler capabilities\n");
459 if (config->num_sessions > sched_capa.
max_groups - 3U) {
460 ODPH_ERR(
"Unsupported amount of scheduler groups: %u (max: %u)\n",
461 config->num_sessions, sched_capa.
max_groups - 3U);
466 config->compl_mode_mask |= mode_map[config->compl_mode];
471 if (config->num_inflight == 0U)
472 config->num_inflight = max_trs;
474 if (config->num_inflight > max_trs) {
475 ODPH_ERR(
"Unsupported amount of in-flight DMA transfers: %u (max: %u)\n",
476 config->num_inflight, max_trs);
480 max_in = config->num_in_segs * config->num_inflight;
481 max_out = config->num_out_segs * config->num_inflight;
482 max_segs = ODPH_MAX(max_in, max_out);
484 if (max_segs > MAX_SEGS) {
485 ODPH_ERR(
"Unsupported input/output * inflight segment combination: %u (max: %u)\n",
490 if (config->seg_type == DENSE_PACKET || config->seg_type == SPARSE_PACKET) {
492 ODPH_ERR(
"Error querying pool capabilities\n");
497 ODPH_ERR(
"Unsupported amount of packet pools: 2 (max: %u)\n",
503 ODPH_ERR(
"Unsupported packet size: %u (max: %u)\n", max_seg_len,
509 max_segs * num_sessions > pool_capa.
pkt.
max_num) {
510 ODPH_ERR(
"Unsupported amount of packet pool elements: %u (max: %u)\n",
511 max_segs * num_sessions, pool_capa.
pkt.
max_num);
515 config->src_cache_size = ODPH_MIN(ODPH_MAX(max_in, pool_capa.
pkt.
min_cache_size),
517 config->dst_cache_size = ODPH_MIN(ODPH_MAX(max_out, pool_capa.
pkt.
min_cache_size),
523 ODPH_ERR(
"Error querying SHM capabilities\n");
530 ODPH_ERR(
"Unsupported amount of SHM blocks: 3 (max: %u)\n",
535 shm_size = (uint64_t)config->dst_seg_len * config->num_out_segs *
536 config->num_inflight;
539 ODPH_ERR(
"Unsupported total SHM block size: %" PRIu64
""
540 " (max: %" PRIu64
")\n", shm_size, shm_capa.
max_size);
544 if (config->seg_type == SPARSE_MEMORY && shm_size < MAX_MEMORY)
545 shm_size = shm_capa.
max_size != 0U ?
546 ODPH_MIN(shm_capa.
max_size, MAX_MEMORY) : MAX_MEMORY;
548 config->shm_size = shm_size;
554 static parse_result_t parse_options(
int argc,
char **argv, prog_config_t *config)
557 static const struct option longopts[] = {
558 {
"trs_type", required_argument, NULL,
't' },
559 {
"num_in_seg", required_argument, NULL,
'i' },
560 {
"num_out_seg", required_argument, NULL,
'o' },
561 {
"in_seg_len", required_argument, NULL,
's' },
562 {
"in_seg_type", required_argument, NULL,
'S' },
563 {
"compl_mode", required_argument, NULL,
'm' },
564 {
"max_in_flight", required_argument, NULL,
'f'},
565 {
"time_sec", required_argument, NULL,
'T' },
566 {
"worker_count", required_argument, NULL,
'c' },
567 {
"policy", required_argument, NULL,
'p' },
568 {
"verify", no_argument, NULL,
'v' },
569 {
"help", no_argument, NULL,
'h' },
572 static const char *shortopts =
"t:i:o:s:S:m:f:T:c:p:vh";
577 opt = getopt_long(argc, argv, shortopts, longopts, NULL);
584 config->trs_type = atoi(optarg);
587 config->num_in_segs = atoi(optarg);
590 config->num_out_segs = atoi(optarg);
593 config->src_seg_len = atoi(optarg);
596 config->seg_type = atoi(optarg);
599 config->compl_mode = atoi(optarg);
602 config->num_inflight = atoi(optarg);
605 config->time_sec = atof(optarg);
608 config->num_workers = atoi(optarg);
611 config->policy = atoi(optarg);
614 config->is_verify =
true;
626 return check_options(config);
629 static parse_result_t setup_program(
int argc,
char **argv, prog_config_t *config)
631 struct sigaction action = { .sa_handler = terminate };
633 if (sigemptyset(&action.sa_mask) == -1 || sigaddset(&action.sa_mask, SIGINT) == -1 ||
634 sigaddset(&action.sa_mask, SIGTERM) == -1 ||
635 sigaddset(&action.sa_mask, SIGHUP) == -1 || sigaction(SIGINT, &action, NULL) == -1 ||
636 sigaction(SIGTERM, &action, NULL) == -1 || sigaction(SIGHUP, &action, NULL) == -1) {
637 ODPH_ERR(
"Error installing signal handler\n");
641 return parse_options(argc, argv, config);
647 uint32_t num_pkts_per_worker = ODPH_MAX(prog_conf->num_inflight * prog_conf->num_in_segs,
648 prog_conf->src_cache_size);
651 return prog_conf->src_pool;
655 param.
pkt.
num = num_pkts_per_worker * prog_conf->num_workers;
656 param.
pkt.
len = prog_conf->src_seg_len;
661 return prog_conf->src_pool;
667 uint32_t num_pkts_per_worker = ODPH_MAX(prog_conf->num_inflight * prog_conf->num_out_segs,
668 prog_conf->dst_cache_size);
671 return prog_conf->dst_pool;
675 param.
pkt.
num = num_pkts_per_worker * prog_conf->num_workers;
676 param.
pkt.
len = prog_conf->dst_seg_len;
681 return prog_conf->dst_pool;
686 sd->seg.src_pool = get_src_packet_pool();
689 ODPH_ERR(
"Error creating source packet pool\n");
693 sd->seg.dst_pool = get_dst_packet_pool();
696 ODPH_ERR(
"Error creating destination packet pool\n");
705 for (uint32_t i = 0U; i < sd->dma.num_inflight * sd->dma.num_in_segs; ++i) {
706 sd->seg.src_pkt[i] =
odp_packet_alloc(sd->seg.src_pool, sd->dma.src_seg_len);
709 ODPH_ERR(
"Error allocating source segment packets\n");
714 for (uint32_t i = 0U; i < sd->dma.num_inflight * sd->dma.num_out_segs; ++i) {
715 sd->seg.dst_pkt[i] =
odp_packet_alloc(sd->seg.dst_pool, sd->dma.dst_seg_len);
718 ODPH_ERR(
"Error allocating destination segment packets\n");
726 static odp_bool_t setup_packet_segments(sd_t *sd)
728 return configure_packets(sd) &&
729 (sd->seg.seg_type == DENSE_PACKET ? allocate_packets(sd) : true);
732 static inline void fill_data(uint8_t *data, uint32_t len)
734 memset(data, DATA, len);
737 static void configure_packet_transfer(sd_t *sd)
740 uint32_t k = 0U, z = 0U, len;
744 for (uint32_t i = 0U; i < sd->dma.num_inflight; ++i) {
745 start_src_seg = &sd->dma.src_seg[k];
746 start_dst_seg = &sd->dma.dst_seg[z];
748 for (uint32_t j = 0U; j < sd->dma.num_in_segs; ++j, ++k) {
749 pkt = sd->seg.src_pkt[k];
750 seg = &start_src_seg[j];
753 seg->
len = sd->dma.src_seg_len;
759 len = sd->dma.num_in_segs * sd->dma.src_seg_len;
761 for (uint32_t j = 0U; j < sd->dma.num_out_segs; ++j, ++z) {
762 pkt = sd->seg.dst_pkt[z];
763 seg = &start_dst_seg[j];
766 seg->
len = ODPH_MIN(len, sd->dma.dst_seg_len);
767 len -= sd->dma.dst_seg_len;
770 param = &sd->dma.infos[i].trs_param;
774 param->
num_src = sd->dma.num_in_segs;
775 param->
num_dst = sd->dma.num_out_segs;
776 param->
src_seg = start_src_seg;
777 param->
dst_seg = start_dst_seg;
781 static void free_packets(
const sd_t *sd)
783 for (uint32_t i = 0U; i < sd->dma.num_inflight * sd->dma.num_in_segs; ++i) {
788 for (uint32_t i = 0U; i < sd->dma.num_inflight * sd->dma.num_out_segs; ++i) {
796 sd->seg.src_shm =
odp_shm_reserve(PROG_NAME
"_src_shm", sd->seg.shm_size,
797 ODP_CACHE_LINE_SIZE, 0U);
798 sd->seg.dst_shm =
odp_shm_reserve(PROG_NAME
"_dst_shm", sd->seg.shm_size,
799 ODP_CACHE_LINE_SIZE, 0U);
802 ODPH_ERR(
"Error allocating SHM block\n");
809 if (sd->seg.src == NULL || sd->seg.dst == NULL) {
810 ODPH_ERR(
"Error resolving SHM block address\n");
814 sd->seg.src_high = (uint8_t *)sd->seg.src + sd->seg.shm_size - sd->dma.src_seg_len;
815 sd->seg.dst_high = (uint8_t *)sd->seg.dst + sd->seg.shm_size - sd->dma.dst_seg_len;
816 sd->seg.cur_src = sd->seg.src;
817 sd->seg.cur_dst = sd->seg.dst;
822 static odp_bool_t setup_memory_segments(sd_t *sd)
824 return allocate_memory(sd);
827 static void configure_address_transfer(sd_t *sd)
830 uint32_t k = 0U, z = 0U, len;
833 for (uint32_t i = 0U; i < sd->dma.num_inflight; ++i) {
834 start_src_seg = &sd->dma.src_seg[k];
835 start_dst_seg = &sd->dma.dst_seg[z];
837 for (uint32_t j = 0U; j < sd->dma.num_in_segs; ++j, ++k) {
838 seg = &start_src_seg[j];
839 seg->
addr = sd->seg.seg_type == SPARSE_MEMORY ?
840 NULL : (uint8_t *)sd->seg.src + k * sd->dma.src_seg_len;
841 seg->
len = sd->dma.src_seg_len;
843 if (seg->
addr != NULL)
844 fill_data(seg->
addr, seg->
len);
847 len = sd->dma.num_in_segs * sd->dma.src_seg_len;
849 for (uint32_t j = 0U; j < sd->dma.num_out_segs; ++j, ++z) {
850 seg = &start_dst_seg[j];
851 seg->
addr = sd->seg.seg_type == SPARSE_MEMORY ?
852 NULL : (uint8_t *)sd->seg.dst + z * sd->dma.dst_seg_len;
853 seg->
len = ODPH_MIN(len, sd->dma.dst_seg_len);
854 len -= sd->dma.dst_seg_len;
857 param = &sd->dma.infos[i].trs_param;
861 param->
num_src = sd->dma.num_in_segs;
862 param->
num_dst = sd->dma.num_out_segs;
863 param->
src_seg = start_src_seg;
864 param->
dst_seg = start_dst_seg;
868 static void free_memory(
const sd_t *sd)
877 static void run_transfer(
odp_dma_t handle, trs_info_t *info, stats_t *stats, ver_fn_t ver_fn)
880 uint64_t start_cc, end_cc, trs_tm, trs_cc;
894 stats->max_trs_tm = ODPH_MAX(trs_tm, stats->max_trs_tm);
895 stats->min_trs_tm = ODPH_MIN(trs_tm, stats->min_trs_tm);
896 stats->trs_tm += trs_tm;
898 stats->max_trs_cc = ODPH_MAX(trs_cc, stats->max_trs_cc);
899 stats->min_trs_cc = ODPH_MIN(trs_cc, stats->min_trs_cc);
900 stats->trs_cc += trs_cc;
902 stats->max_start_cc = stats->max_trs_cc;
903 stats->min_start_cc = stats->min_trs_cc;
904 stats->start_cc += trs_cc;
908 ++stats->transfer_errs;
918 static void run_transfers_mt_unsafe(sd_t *sd, stats_t *stats)
920 const uint32_t count = sd->dma.num_inflight;
922 trs_info_t *infos = sd->dma.infos, *info;
924 for (uint32_t i = 0U; i < count; ++i) {
927 if (sd->prep_trs_fn != NULL)
928 sd->prep_trs_fn(sd, info);
930 run_transfer(handle, info, stats, sd->ver_fn);
934 static void run_transfers_mt_safe(sd_t *sd, stats_t *stats)
936 const uint32_t count = sd->dma.num_inflight;
938 trs_info_t *infos = sd->dma.infos, *info;
940 for (uint32_t i = 0U; i < count; ++i) {
944 if (sd->prep_trs_fn != NULL)
945 sd->prep_trs_fn(sd, info);
947 run_transfer(handle, info, stats, sd->ver_fn);
953 static odp_bool_t configure_poll_compl(sd_t *sd)
957 for (uint32_t i = 0U; i < sd->dma.num_inflight; ++i) {
958 param = &sd->dma.infos[i].compl_param;
961 param->
compl_mode = mode_map[sd->dma.compl_mode];
965 ODPH_ERR(
"Error allocating transfer ID\n");
973 static void poll_transfer(sd_t *sd, trs_info_t *info, stats_t *stats)
975 uint64_t start_cc, end_cc, trs_tm, trs_cc, wait_cc, start_cc_diff;
981 if (info->is_running) {
991 ++info->trs_poll_cnt;
993 stats->max_wait_cc = ODPH_MAX(wait_cc, stats->max_wait_cc);
994 stats->min_wait_cc = ODPH_MIN(wait_cc, stats->min_wait_cc);
995 stats->wait_cc += wait_cc;
1002 stats->max_trs_tm = ODPH_MAX(trs_tm, stats->max_trs_tm);
1003 stats->min_trs_tm = ODPH_MIN(trs_tm, stats->min_trs_tm);
1004 stats->trs_tm += trs_tm;
1006 stats->max_trs_cc = ODPH_MAX(trs_cc, stats->max_trs_cc);
1007 stats->min_trs_cc = ODPH_MIN(trs_cc, stats->min_trs_cc);
1008 stats->trs_cc += trs_cc;
1009 stats->trs_poll_cnt += info->trs_poll_cnt;
1013 ++stats->transfer_errs;
1017 if (sd->ver_fn != NULL)
1018 sd->ver_fn(info, stats);
1021 info->is_running =
false;
1023 if (sd->prep_trs_fn != NULL)
1024 sd->prep_trs_fn(sd, info);
1032 ++stats->start_errs;
1034 info->trs_start_tm = start_tm;
1035 info->trs_start_cc = start_cc;
1036 info->trs_poll_cnt = 0U;
1038 stats->max_start_cc = ODPH_MAX(start_cc_diff, stats->max_start_cc);
1039 stats->min_start_cc = ODPH_MIN(start_cc_diff, stats->min_start_cc);
1040 stats->start_cc += start_cc_diff;
1042 info->is_running =
true;
1047 static void poll_transfers_mt_unsafe(sd_t *sd, stats_t *stats)
1049 const uint32_t count = sd->dma.num_inflight;
1050 trs_info_t *infos = sd->dma.infos;
1052 for (uint32_t i = 0U; i < count; ++i)
1053 poll_transfer(sd, &infos[i], stats);
1056 static void poll_transfers_mt_safe(sd_t *sd, stats_t *stats)
1058 const uint32_t count = sd->dma.num_inflight;
1059 trs_info_t *infos = sd->dma.infos, *info;
1061 for (uint32_t i = 0U; i < count; ++i) {
1065 poll_transfer(sd, info, stats);
1071 static void drain_poll_transfers(sd_t *sd)
1073 const uint32_t count = sd->dma.num_inflight;
1074 trs_info_t *infos = sd->dma.infos, *info;
1078 for (uint32_t i = 0U; i < count; ++i) {
1081 if (info->is_running) {
1090 static odp_bool_t configure_event_compl_session(sd_t *sd)
1100 ODPH_ERR(
"Error creating scheduler group for DMA session\n");
1105 pool_param.
num = sd->dma.num_inflight;
1109 ODPH_ERR(
"Error creating DMA event completion pool\n");
1121 ODPH_ERR(
"Error creating DMA completion queue\n");
1128 static odp_bool_t configure_event_compl(sd_t *sd)
1133 for (uint32_t i = 0U; i < sd->dma.num_inflight; ++i) {
1134 param = &sd->dma.infos[i].compl_param;
1137 param->
compl_mode = mode_map[sd->dma.compl_mode];
1141 ODPH_ERR(
"Error allocating completion event\n");
1146 param->
queue = sd->dma.compl_q;
1147 param->
user_ptr = &sd->dma.infos[i];
1153 static odp_bool_t start_initial_transfers(sd_t *sd)
1160 for (uint32_t i = 0U; i < sd->dma.num_inflight; ++i) {
1161 info = &sd->dma.infos[i];
1163 if (sd->prep_trs_fn != NULL)
1164 sd->prep_trs_fn(sd, info);
1171 ODPH_ERR(
"Error starting DMA transfer\n");
1175 info->trs_start_tm = start_tm;
1176 info->trs_start_cc = start_cc;
1182 static void wait_compl_event(sd_t *sd, stats_t *stats)
1184 uint64_t start_cc, end_cc, wait_cc, trs_tm, trs_cc, start_cc_diff;
1196 ++stats->scheduler_timeouts;
1203 stats->max_trs_tm = ODPH_MAX(trs_tm, stats->max_trs_tm);
1204 stats->min_trs_tm = ODPH_MIN(trs_tm, stats->min_trs_tm);
1205 stats->trs_tm += trs_tm;
1207 stats->max_trs_cc = ODPH_MAX(trs_cc, stats->max_trs_cc);
1208 stats->min_trs_cc = ODPH_MIN(trs_cc, stats->min_trs_cc);
1209 stats->trs_cc += trs_cc;
1212 stats->max_wait_cc = ODPH_MAX(wait_cc, stats->max_wait_cc);
1213 stats->min_wait_cc = ODPH_MIN(wait_cc, stats->min_wait_cc);
1214 stats->wait_cc += wait_cc;
1218 ++stats->transfer_errs;
1222 if (sd->ver_fn != NULL)
1223 sd->ver_fn(info, stats);
1226 if (sd->prep_trs_fn != NULL)
1227 sd->prep_trs_fn(sd, info);
1235 ++stats->start_errs;
1237 info->trs_start_tm = start_tm;
1238 info->trs_start_cc = start_cc;
1240 stats->max_start_cc = ODPH_MAX(start_cc_diff, stats->max_start_cc);
1241 stats->min_start_cc = ODPH_MIN(start_cc_diff, stats->min_start_cc);
1242 stats->start_cc += start_cc_diff;
1247 static void drain_compl_events(
ODP_UNUSED sd_t *sd)
1259 static void run_memcpy(trs_info_t *info, stats_t *stats, ver_fn_t ver_fn)
1262 uint64_t start_cc, end_cc, trs_tm, trs_cc;
1264 uint32_t tot_len, src_len, dst_len, min_len, len, i = 0U, j = 0U, src_off = 0U,
1265 dst_off = 0U, src_rem, dst_rem;
1267 uint8_t *src_data, *dst_data;
1275 min_len = ODPH_MIN(src_len, dst_len);
1280 while (tot_len > 0U) {
1289 memcpy(dst_data + dst_off, src_data + src_off, len);
1292 src_rem = src_len - src_off;
1293 dst_rem = dst_len - dst_off;
1295 len = ODPH_MIN(ODPH_MAX(src_rem, dst_rem), min_len);
1308 stats->max_trs_tm = ODPH_MAX(trs_tm, stats->max_trs_tm);
1309 stats->min_trs_tm = ODPH_MIN(trs_tm, stats->min_trs_tm);
1310 stats->trs_tm += trs_tm;
1312 stats->max_trs_cc = ODPH_MAX(trs_cc, stats->max_trs_cc);
1313 stats->min_trs_cc = ODPH_MIN(trs_cc, stats->min_trs_cc);
1314 stats->trs_cc += trs_cc;
1316 stats->max_start_cc = stats->max_trs_cc;
1317 stats->min_start_cc = stats->min_trs_cc;
1318 stats->start_cc += trs_cc;
1323 ver_fn(info, stats);
1326 static void run_memcpy_mt_unsafe(sd_t *sd, stats_t *stats)
1328 const uint32_t count = sd->dma.num_inflight;
1329 trs_info_t *infos = sd->dma.infos, *info;
1331 for (uint32_t i = 0U; i < count; ++i) {
1334 if (sd->prep_trs_fn != NULL)
1335 sd->prep_trs_fn(sd, info);
1337 run_memcpy(info, stats, sd->ver_fn);
1341 static void run_memcpy_mt_safe(sd_t *sd, stats_t *stats)
1343 const uint32_t count = sd->dma.num_inflight;
1344 trs_info_t *infos = sd->dma.infos, *info;
1346 for (uint32_t i = 0U; i < count; ++i) {
1350 if (sd->prep_trs_fn != NULL)
1351 sd->prep_trs_fn(sd, info);
1353 run_memcpy(info, stats, sd->ver_fn);
1359 static void setup_api(prog_config_t *config)
1361 if (config->seg_type == DENSE_PACKET || config->seg_type == SPARSE_PACKET) {
1362 config->api.setup_fn = setup_packet_segments;
1363 config->api.trs_fn = configure_packet_transfer;
1364 config->api.free_fn = free_packets;
1366 config->api.setup_fn = setup_memory_segments;
1367 config->api.trs_fn = configure_address_transfer;
1368 config->api.free_fn = free_memory;
1371 if (config->trs_type == SYNC_DMA) {
1372 config->api.session_cfg_fn = NULL;
1373 config->api.compl_fn = NULL;
1374 config->api.bootstrap_fn = NULL;
1375 config->api.wait_fn = config->num_workers == 1 || config->policy == MANY ?
1376 run_transfers_mt_unsafe : run_transfers_mt_safe;
1377 config->api.drain_fn = NULL;
1378 }
else if (config->trs_type == ASYNC_DMA) {
1379 if (config->compl_mode == POLL) {
1380 config->api.session_cfg_fn = NULL;
1381 config->api.compl_fn = configure_poll_compl;
1382 config->api.bootstrap_fn = NULL;
1383 config->api.wait_fn = config->num_workers == 1 || config->policy == MANY ?
1384 poll_transfers_mt_unsafe : poll_transfers_mt_safe;
1385 config->api.drain_fn = drain_poll_transfers;
1387 config->api.session_cfg_fn = configure_event_compl_session;
1388 config->api.compl_fn = configure_event_compl;
1389 config->api.bootstrap_fn = start_initial_transfers;
1390 config->api.wait_fn = wait_compl_event;
1391 config->api.drain_fn = drain_compl_events;
1394 config->api.session_cfg_fn = NULL;
1395 config->api.compl_fn = NULL;
1396 config->api.bootstrap_fn = NULL;
1397 config->api.wait_fn = config->num_workers == 1 || config->policy == MANY ?
1398 run_memcpy_mt_unsafe : run_memcpy_mt_safe;
1399 config->api.drain_fn = NULL;
1403 static void prepare_packet_transfer(sd_t *sd, trs_info_t *info)
1408 for (uint32_t i = 0U; i < param->
num_src; ++i) {
1418 ODPH_ABORT(
"Failed to allocate packet, aborting\n");
1423 for (uint32_t i = 0U; i < param->
num_dst; ++i) {
1433 ODPH_ABORT(
"Failed to allocate packet, aborting\n");
1437 static void prepare_address_transfer(sd_t *sd, trs_info_t *info)
1440 uint8_t *addr = sd->seg.cur_src;
1443 for (uint32_t i = 0U; i < param->
num_src; ++i) {
1450 addr += sd->dma.src_seg_len;
1451 fill_data(seg->
addr, seg->
len);
1454 sd->seg.cur_src = addr + ODP_CACHE_LINE_SIZE;
1455 addr = sd->seg.cur_dst;
1457 for (uint32_t i = 0U; i < param->
num_dst; ++i) {
1462 addr += sd->dma.dst_seg_len;
1465 sd->seg.cur_dst = addr + ODP_CACHE_LINE_SIZE;
1468 static void verify_transfer(trs_info_t *info, stats_t *stats)
1475 for (uint32_t i = 0U; i < param->
num_dst; ++i) {
1479 for (uint32_t j = 0U; j < seg->
len; ++j)
1487 static odp_bool_t setup_session_descriptors(prog_config_t *config)
1493 .compl_mode_mask = config->compl_mode_mask,
1494 .mt_mode = config->num_workers == 1 || config->policy == MANY ?
1498 for (uint32_t i = 0U; i < config->num_sessions; ++i) {
1501 sd = &config->sds[i];
1502 sd->dma.num_in_segs = config->num_in_segs;
1503 sd->dma.num_out_segs = config->num_out_segs;
1504 sd->dma.src_seg_len = config->src_seg_len;
1505 sd->dma.dst_seg_len = config->dst_seg_len;
1506 sd->dma.num_inflight = config->num_inflight;
1507 sd->dma.trs_type = config->trs_type;
1508 sd->dma.compl_mode = config->compl_mode;
1509 snprintf(name,
sizeof(name), PROG_NAME
"_dma_%u", i);
1513 ODPH_ERR(
"Error creating DMA session\n");
1517 if (config->api.session_cfg_fn != NULL && !config->api.session_cfg_fn(sd))
1520 sd->seg.shm_size = config->shm_size;
1521 sd->seg.seg_type = config->seg_type;
1522 sd->prep_trs_fn = config->seg_type == SPARSE_PACKET ? prepare_packet_transfer :
1523 config->seg_type == SPARSE_MEMORY ?
1524 prepare_address_transfer : NULL;
1525 sd->ver_fn = config->is_verify ? verify_transfer : NULL;
1531 static odp_bool_t setup_data(prog_config_t *config)
1535 for (uint32_t i = 0U; i < config->num_sessions; ++i) {
1536 sd = &config->sds[i];
1538 if (!config->api.setup_fn(sd))
1541 config->api.trs_fn(sd);
1543 if (config->api.compl_fn != NULL && !config->api.compl_fn(sd))
1550 static int transfer(
void *args)
1552 thread_config_t *thr_config = args;
1553 prog_config_t *prog_config = thr_config->prog_config;
1554 sd_t *sd = thr_config->sd;
1555 stats_t *stats = &thr_config->stats;
1556 test_api_t *api = &prog_conf->api;
1567 ODPH_ERR(
"Error joining scheduler group\n");
1575 api->wait_fn(sd, stats);
1579 if (api->drain_fn != NULL)
1588 static odp_bool_t setup_workers(prog_config_t *config)
1592 odph_thread_common_param_t thr_common;
1593 odph_thread_param_t thr_params[config->num_workers], *thr_param;
1594 thread_config_t *thr_config;
1601 odph_thread_common_param_init(&thr_common);
1602 thr_common.instance = config->odp_instance;
1603 thr_common.cpumask = &cpumask;
1605 for (
int i = 0; i < config->num_workers; ++i) {
1606 thr_param = &thr_params[i];
1607 thr_config = &config->thread_config[i];
1608 sd = config->policy == SINGLE ? &config->sds[0U] : &config->sds[i];
1610 odph_thread_param_init(thr_param);
1611 thr_param->start = transfer;
1613 thr_config->prog_config = config;
1614 thr_config->sd = sd;
1615 thr_param->arg = thr_config;
1618 num_workers = odph_thread_create(config->threads, &thr_common, thr_params, num_workers);
1620 if (num_workers != config->num_workers) {
1621 ODPH_ERR(
"Error configuring worker threads\n");
1625 for (uint32_t i = 0U; i < config->num_sessions; ++i) {
1626 if (config->api.bootstrap_fn != NULL && !config->api.bootstrap_fn(&config->sds[i]))
1635 static odp_bool_t setup_test(prog_config_t *config)
1639 return setup_session_descriptors(config) && setup_data(config) && setup_workers(config);
1642 static void stop_test(prog_config_t *config)
1644 (void)odph_thread_join(config->threads, config->num_workers);
1647 static void teardown_data(
const sd_t *sd,
void (*free_fn)(
const sd_t *sd))
1651 for (uint32_t i = 0U; i < MAX_SEGS; ++i) {
1652 compl_param = &sd->dma.infos[i].compl_param;
1664 static void teardown_test(prog_config_t *config)
1668 for (uint32_t i = 0U; i < config->num_sessions; ++i) {
1669 sd = &config->sds[i];
1670 teardown_data(sd, config->api.free_fn);
1692 static void print_humanised(uint64_t value,
const char *type)
1695 printf(
"%.2f G%s\n", (
double)value / GIGAS, type);
1696 else if (value > MEGAS)
1697 printf(
"%.2f M%s\n", (
double)value / MEGAS, type);
1698 else if (value > KILOS)
1699 printf(
"%.2f k%s\n", (
double)value / KILOS, type);
1701 printf(
"%" PRIu64
" %s\n", value, type);
1704 static int output_results(
const prog_config_t *config)
1706 const stats_t *stats;
1707 uint64_t data_cnt = config->num_in_segs * config->src_seg_len, tot_completed = 0U,
1708 tot_tm = 0U, tot_trs_tm = 0U, tot_trs_cc = 0U, tot_trs_cnt = 0U, tot_min_tm = UINT64_MAX,
1709 tot_max_tm = 0U, tot_min_cc = UINT64_MAX, tot_max_cc = 0U, avg_start_cc,
1710 avg_start_cc_tot = 0U, min_start = UINT64_MAX, max_start = 0U, avg_wait_cc,
1711 avg_wait_cc_tot = 0U, min_wait = UINT64_MAX, max_wait = 0U, start_cnt_sum = 0U,
1715 printf(
"\n======================\n\n"
1716 "DMA performance test done\n\n"
1718 " input segment count: %u\n"
1719 " output segment count: %u\n"
1720 " segment length: %u\n"
1721 " segment type: %s\n"
1722 " inflight count: %u\n"
1723 " session policy: %s\n\n",
1724 config->trs_type == SYNC_DMA ?
"DMA synchronous" :
1725 config->trs_type == ASYNC_DMA && config->compl_mode == POLL ?
1726 "DMA asynchronous-poll" :
1727 config->trs_type == ASYNC_DMA && config->compl_mode == EVENT ?
1728 "DMA asynchronous-event" :
"SW", config->num_in_segs,
1729 config->num_out_segs, config->src_seg_len,
1730 config->seg_type == DENSE_PACKET ?
"dense packet" :
1731 config->seg_type == SPARSE_PACKET ?
"sparse packet" :
1732 config->seg_type == DENSE_MEMORY ?
"dense memory" :
"sparse memory",
1733 config->num_inflight, config->policy == SINGLE ?
"shared" :
"per-worker");
1735 for (
int i = 0; i < config->num_workers; ++i) {
1736 stats = &config->thread_config[i].stats;
1737 tot_completed += stats->completed;
1738 tot_tm += stats->tot_tm;
1739 tot_trs_tm += stats->trs_tm;
1740 tot_trs_cc += stats->trs_cc;
1741 tot_trs_cnt += stats->trs_cnt;
1742 tot_min_tm = ODPH_MIN(tot_min_tm, stats->min_trs_tm);
1743 tot_max_tm = ODPH_MAX(tot_max_tm, stats->max_trs_tm);
1744 tot_min_cc = ODPH_MIN(tot_min_cc, stats->min_trs_cc);
1745 tot_max_cc = ODPH_MAX(tot_max_cc, stats->max_trs_cc);
1749 printf(
" worker %d:\n", i);
1750 printf(
" successful transfers: %" PRIu64
"\n"
1751 " start errors: %" PRIu64
"\n",
1752 stats->completed, stats->start_errs);
1754 if (config->trs_type == ASYNC_DMA) {
1755 if (config->compl_mode == POLL)
1756 printf(
" poll errors: %" PRIu64
"\n",
1759 printf(
" scheduler timeouts: %" PRIu64
"\n",
1760 stats->scheduler_timeouts);
1763 printf(
" transfer errors: %" PRIu64
"\n", stats->transfer_errs);
1765 if (config->is_verify)
1766 printf(
" data errors: %" PRIu64
"\n", stats->data_errs);
1768 printf(
" run time: %" PRIu64
" ns\n", stats->tot_tm);
1770 if (config->policy == MANY) {
1771 printf(
" session:\n"
1772 " average time per transfer: %" PRIu64
" "
1773 "(min: %" PRIu64
", max: %" PRIu64
") ns\n"
1774 " average cycles per transfer: %" PRIu64
" "
1775 "(min: %" PRIu64
", max: %" PRIu64
")\n"
1777 stats->trs_cnt > 0U ? stats->trs_tm / stats->trs_cnt : 0U,
1778 stats->trs_cnt > 0U ? stats->min_trs_tm : 0U,
1779 stats->trs_cnt > 0U ? stats->max_trs_tm : 0U,
1780 stats->trs_cnt > 0U ? stats->trs_cc / stats->trs_cnt : 0U,
1781 stats->trs_cnt > 0U ? stats->min_trs_cc : 0U,
1782 stats->trs_cnt > 0U ? stats->max_trs_cc : 0U);
1783 print_humanised(stats->completed /
1787 print_humanised(stats->completed * data_cnt /
1791 if (stats->start_cnt > 0U) {
1792 avg_start_cc = stats->start_cc / stats->start_cnt;
1793 start_cnt_sum += stats->start_cnt;
1794 avg_start_cc_tot += stats->start_cc;
1795 min_start = stats->min_start_cc < min_start ?
1796 stats->min_start_cc : min_start;
1797 max_start = stats->max_start_cc > max_start ?
1798 stats->max_start_cc : max_start;
1801 printf(
" average cycles breakdown:\n");
1803 if (config->trs_type == SYNC_DMA) {
1804 printf(
" odp_dma_transfer(): %" PRIu64
" "
1805 "(min: %" PRIu64
", max: %" PRIu64
")\n", avg_start_cc,
1806 avg_start_cc > 0U ? stats->min_start_cc : 0U,
1807 avg_start_cc > 0U ? stats->max_start_cc : 0U);
1808 }
else if (config->trs_type == SW_COPY) {
1809 printf(
" memcpy(): %" PRIu64
" "
1810 "(min: %" PRIu64
", max: %" PRIu64
")\n", avg_start_cc,
1811 avg_start_cc > 0U ? stats->min_start_cc : 0U,
1812 avg_start_cc > 0U ? stats->max_start_cc : 0U);
1814 printf(
" odp_dma_transfer_start(): %" PRIu64
" "
1815 "(min: %" PRIu64
", max: %" PRIu64
")\n", avg_start_cc,
1816 avg_start_cc > 0U ? stats->min_start_cc : 0U,
1817 avg_start_cc > 0U ? stats->max_start_cc : 0U);
1819 if (stats->wait_cnt > 0U) {
1820 avg_wait_cc = stats->wait_cc / stats->wait_cnt;
1821 wait_cnt_sum += stats->wait_cnt;
1822 avg_wait_cc_tot += stats->wait_cc;
1823 min_wait = stats->min_wait_cc < min_wait ?
1824 stats->min_wait_cc : min_wait;
1825 max_wait = stats->max_wait_cc > max_wait ?
1826 stats->max_wait_cc : max_wait;
1829 if (config->compl_mode == POLL) {
1830 printf(
" odp_dma_transfer_done(): %" PRIu64
""
1831 " (min: %" PRIu64
", max: %" PRIu64
", x%" PRIu64
""
1832 " per transfer)\n", avg_wait_cc,
1833 avg_wait_cc > 0U ? stats->min_wait_cc : 0U,
1834 avg_wait_cc > 0U ? stats->max_wait_cc : 0U,
1835 stats->trs_cnt > 0U ?
1836 stats->trs_poll_cnt / stats->trs_cnt : 0U);
1838 printf(
" odp_schedule(): %" PRIu64
" "
1839 " (min: %" PRIu64
", max: %" PRIu64
")\n", avg_wait_cc,
1840 avg_wait_cc > 0U ? stats->min_wait_cc : 0U,
1841 avg_wait_cc > 0U ? stats->max_wait_cc : 0U);
1847 avg_start_cc_tot = start_cnt_sum > 0U ? avg_start_cc_tot / start_cnt_sum : 0U;
1848 avg_wait_cc_tot = wait_cnt_sum > 0U ? avg_wait_cc_tot / wait_cnt_sum : 0U;
1852 " average time per transfer: %" PRIu64
" (min: %" PRIu64
1853 ", max: %" PRIu64
") ns\n"
1854 " average cycles per transfer: %" PRIu64
" (min: %" PRIu64
1855 ", max: %" PRIu64
")\n"
1857 tot_trs_cnt > 0U ? tot_trs_tm / tot_trs_cnt : 0U,
1858 tot_trs_cnt > 0U ? tot_min_tm : 0U,
1859 tot_trs_cnt > 0U ? tot_max_tm : 0U,
1860 tot_trs_cnt > 0U ? tot_trs_cc / tot_trs_cnt : 0U,
1861 tot_trs_cnt > 0U ? tot_min_cc : 0U,
1862 tot_trs_cnt > 0U ? tot_max_cc : 0U);
1863 print_humanised(avg_tot_tm > 0U ? tot_completed / avg_tot_tm : 0U,
"OPS");
1865 print_humanised(avg_tot_tm > 0U ? tot_completed * data_cnt / avg_tot_tm : 0U,
"B/s");
1867 printf(
"======================\n");
1869 if (config->common_options.is_export) {
1871 if (test_common_write(
"time per transfer avg (ns),time per transfer min (ns),"
1872 "time per transfer max (ns),cycles per transfer avg,"
1873 "cycles per transfer min,cycles per transfer max,"
1874 "ops (OPS),speed (B/s),dma_transfer avg,"
1875 "dma_transfer min,dma_transfer max,memcpy avg,memcpy min,"
1876 "memcpy max,dma_transfer_start avg,dma_transfer_start min,"
1877 "dma_transfer_start max,dma_transfer_done avg,"
1878 "dma_transfer_done min,dma_transfer_done max,schedule avg,"
1879 "schedule min,schedule max\n"))
1882 if (test_common_write(
"%" PRIu64
",%" PRIu64
",%" PRIu64
",%" PRIu64
","
1883 "%" PRIu64
",%" PRIu64
",%" PRIu64
",%" PRIu64
",",
1884 tot_trs_cnt > 0U ? tot_trs_tm / tot_trs_cnt : 0U,
1885 tot_trs_cnt > 0U ? tot_min_tm : 0U,
1886 tot_trs_cnt > 0U ? tot_max_tm : 0U,
1887 tot_trs_cnt > 0U ? tot_trs_cc / tot_trs_cnt : 0U,
1888 tot_trs_cnt > 0U ? tot_min_cc : 0U,
1889 tot_trs_cnt > 0U ? tot_max_cc : 0U,
1890 avg_tot_tm > 0U ? (uint64_t)(tot_completed / avg_tot_tm) : 0U,
1892 (uint64_t)(tot_completed * data_cnt / avg_tot_tm) : 0U))
1895 if (config->trs_type == SYNC_DMA) {
1896 if (test_common_write(
"%" PRIu64
",%" PRIu64
",%" PRIu64
","
1897 "0,0,0,0,0,0,0,0,0,0,0,0\n",
1899 avg_start_cc_tot > 0U ? min_start : 0U,
1900 avg_start_cc_tot > 0U ? max_start : 0U))
1902 }
else if (config->trs_type == SW_COPY) {
1903 if (test_common_write(
"0,0,0 %" PRIu64
",%" PRIu64
",%" PRIu64
","
1904 "0,0,0,0,0,0,0,0,0\n",
1906 avg_start_cc_tot > 0U ? min_start : 0U,
1907 avg_start_cc_tot > 0U ? max_start : 0U))
1909 }
else if (config->trs_type == ASYNC_DMA) {
1910 if (test_common_write(
"0,0,0,0,0,0, %" PRIu64
",%" PRIu64
",%" PRIu64
",",
1912 avg_start_cc_tot > 0U ? min_start : 0U,
1913 avg_start_cc_tot > 0U ? max_start : 0U))
1916 if (config->compl_mode == POLL) {
1917 if (test_common_write(
"%" PRIu64
",%" PRIu64
",%" PRIu64
","
1920 avg_wait_cc_tot > 0U ? min_wait : 0U,
1921 avg_wait_cc_tot > 0U ? max_wait : 0U))
1923 }
else if (config->compl_mode == EVENT) {
1924 if (test_common_write(
"0,0,0 %" PRIu64
",%" PRIu64
",%" PRIu64
"\n",
1926 avg_wait_cc_tot > 0U ? min_wait : 0U,
1927 avg_wait_cc_tot > 0U ? max_wait : 0U))
1931 test_common_write_term();
1937 ODPH_ERR(
"Export failed\n");
1938 test_common_write_term();
1942 int main(
int argc,
char **argv)
1944 odph_helper_options_t odph_opts;
1948 parse_result_t parse_res;
1949 int ret = EXIT_SUCCESS;
1950 test_common_options_t common_options;
1952 argc = odph_parse_options(argc, argv);
1954 if (odph_options(&odph_opts)) {
1955 ODPH_ERR(
"Error while reading ODP helper options, exiting\n");
1959 argc = test_common_parse_options(argc, argv);
1960 if (test_common_options(&common_options)) {
1961 ODPH_ERR(
"Error while reading test options, exiting\n");
1966 init_param.
mem_model = odph_opts.mem_model;
1969 ODPH_ERR(
"ODP global init failed, exiting\n");
1974 ODPH_ERR(
"ODP local init failed, exiting\n");
1978 shm_cfg =
odp_shm_reserve(PROG_NAME
"_cfg",
sizeof(prog_config_t), ODP_CACHE_LINE_SIZE,
1982 ODPH_ERR(
"Error reserving shared memory\n");
1989 if (prog_conf == NULL) {
1990 ODPH_ERR(
"Error resolving shared memory address\n");
1995 parse_res = setup_program(argc, argv, prog_conf);
1997 if (parse_res == PRS_NOK) {
2002 if (parse_res == PRS_TERM) {
2007 if (parse_res == PRS_NOT_SUP) {
2013 ODPH_ERR(
"Error configuring scheduler\n");
2021 if (!setup_test(prog_conf)) {
2026 if (prog_conf->time_sec > 0.001) {
2029 ts.tv_sec = prog_conf->time_sec;
2031 nanosleep(&ts, NULL);
2035 stop_test(prog_conf);
2037 prog_conf->common_options = common_options;
2039 output_results(prog_conf);
2043 teardown_test(prog_conf);
2050 ODPH_ERR(
"ODP local terminate failed, exiting\n");
2055 ODPH_ERR(
"ODP global terminate failed, exiting\n");
void odp_atomic_init_u32(odp_atomic_u32_t *atom, uint32_t val)
Initialize atomic uint32 variable.
uint32_t odp_atomic_load_u32(odp_atomic_u32_t *atom)
Load value of atomic uint32 variable.
void odp_atomic_store_u32(odp_atomic_u32_t *atom, uint32_t val)
Store value to atomic uint32 variable.
void odp_barrier_init(odp_barrier_t *barr, int count)
Initialize barrier with thread count.
void odp_barrier_wait(odp_barrier_t *barr)
Synchronize thread execution on barrier.
#define ODP_ALIGNED_CACHE
Defines type/struct/variable to be cache line size aligned.
#define odp_unlikely(x)
Branch unlikely taken.
#define ODP_UNUSED
Intentionally unused variables of functions.
#define odp_likely(x)
Branch likely taken.
uint64_t odp_cpu_cycles_diff(uint64_t c2, uint64_t c1)
CPU cycle count difference.
uint64_t odp_cpu_cycles(void)
Current CPU cycle count.
int odp_cpumask_default_worker(odp_cpumask_t *mask, int num)
Default CPU mask for worker threads.
odp_dma_t odp_dma_create(const char *name, const odp_dma_param_t *param)
Create DMA session.
#define ODP_DMA_COMPL_SYNC
Synchronous transfer.
odp_pool_t odp_dma_pool_create(const char *name, const odp_dma_pool_param_t *pool_param)
Create DMA completion event pool.
uint32_t odp_dma_compl_mode_t
DMA transfer completion mode.
int odp_dma_transfer_done(odp_dma_t dma, odp_dma_transfer_id_t transfer_id, odp_dma_result_t *result)
Check if DMA transfer has completed.
#define ODP_DMA_TYPE_COPY
Copy data.
void odp_dma_transfer_id_free(odp_dma_t dma, odp_dma_transfer_id_t transfer_id)
Free DMA transfer identifier.
#define ODP_DMA_COMPL_EVENT
Asynchronous transfer with completion event.
void odp_dma_transfer_param_init(odp_dma_transfer_param_t *trs_param)
Initialize DMA transfer parameters.
int odp_dma_destroy(odp_dma_t dma)
Destroy DMA session.
int odp_dma_compl_result(odp_dma_compl_t dma_compl, odp_dma_result_t *result)
Check DMA completion event.
void odp_dma_compl_param_init(odp_dma_compl_param_t *compl_param)
Initialize DMA transfer completion parameters.
#define ODP_DMA_NAME_LEN
Maximum DMA name length, including the null character.
#define ODP_DMA_TRANSFER_ID_INVALID
Invalid DMA transfer identifier.
#define ODP_DMA_COMPL_INVALID
Invalid DMA completion event.
odp_event_t odp_dma_compl_to_event(odp_dma_compl_t dma_compl)
Convert DMA completion event to event.
void odp_dma_pool_param_init(odp_dma_pool_param_t *pool_param)
Initialize DMA completion event pool parameters.
int odp_dma_transfer_start(odp_dma_t dma, const odp_dma_transfer_param_t *trs_param, const odp_dma_compl_param_t *compl_param)
Start DMA transfer.
int odp_dma_transfer(odp_dma_t dma, const odp_dma_transfer_param_t *trs_param, odp_dma_result_t *result)
Perform DMA transfer.
odp_dma_compl_t odp_dma_compl_from_event(odp_event_t ev)
Convert event to DMA completion event.
#define ODP_DMA_MAIN_TO_MAIN
DMA transfer within the main memory.
int odp_dma_capability(odp_dma_capability_t *capa)
Query DMA capabilities.
odp_dma_transfer_id_t odp_dma_transfer_id_alloc(odp_dma_t dma)
Allocate DMA transfer identifier.
#define ODP_DMA_INVALID
Invalid DMA session.
#define ODP_DMA_COMPL_POLL
Asynchronous transfer with completion polling.
odp_dma_compl_t odp_dma_compl_alloc(odp_pool_t pool)
Allocate DMA completion event.
@ ODP_DMA_MT_SAFE
Multi-thread safe operation.
@ ODP_DMA_MT_SERIAL
Application serializes operations.
@ ODP_DMA_FORMAT_PACKET
Data format is odp_packet_t.
@ ODP_DMA_FORMAT_ADDR
Data format is raw memory address.
@ ODP_DMA_ORDER_NONE
No specific ordering between transfers.
void odp_event_free(odp_event_t event)
Free event.
#define ODP_EVENT_INVALID
Invalid event.
int odp_instance(odp_instance_t *instance)
Get instance handle.
void odp_init_param_init(odp_init_t *param)
Initialize the odp_init_t to default values for all fields.
int odp_init_local(odp_instance_t instance, odp_thread_type_t thr_type)
Thread local ODP initialization.
int odp_init_global(odp_instance_t *instance, const odp_init_t *params, const odp_platform_init_t *platform_params)
Global ODP initialization.
int odp_term_local(void)
Thread local ODP termination.
int odp_term_global(odp_instance_t instance)
Global ODP termination.
uint64_t odp_instance_t
ODP instance ID.
void odp_ticketlock_init(odp_ticketlock_t *tklock)
Initialize ticket lock.
int odp_ticketlock_trylock(odp_ticketlock_t *tklock)
Try to acquire ticket lock.
void odp_ticketlock_unlock(odp_ticketlock_t *tklock)
Release ticket lock.
void * odp_packet_data(odp_packet_t pkt)
Packet data pointer.
odp_packet_t odp_packet_alloc(odp_pool_t pool, uint32_t len)
Allocate a packet from a packet pool.
void odp_packet_free(odp_packet_t pkt)
Free packet.
#define ODP_PACKET_INVALID
Invalid packet.
odp_pool_t odp_pool_create(const char *name, const odp_pool_param_t *param)
Create a pool.
int odp_pool_capability(odp_pool_capability_t *capa)
Query pool capabilities.
void odp_pool_param_init(odp_pool_param_t *param)
Initialize pool params.
int odp_pool_destroy(odp_pool_t pool)
Destroy a pool previously created by odp_pool_create()
#define ODP_POOL_INVALID
Invalid pool.
@ ODP_POOL_PACKET
Packet pool.
void odp_queue_param_init(odp_queue_param_t *param)
Initialize queue params.
#define ODP_QUEUE_INVALID
Invalid queue.
odp_queue_t odp_queue_create(const char *name, const odp_queue_param_t *param)
Queue create.
int odp_queue_destroy(odp_queue_t queue)
Destroy ODP queue.
@ ODP_QUEUE_TYPE_SCHED
Scheduled queue.
#define ODP_SCHED_SYNC_PARALLEL
Parallel scheduled queues.
int odp_schedule_group_t
Scheduler thread group.
int odp_schedule_group_join(odp_schedule_group_t group, const odp_thrmask_t *mask)
Join a schedule group.
int odp_schedule_group_destroy(odp_schedule_group_t group)
Schedule group destroy.
#define ODP_SCHED_GROUP_INVALID
Invalid scheduler group.
int odp_schedule_default_prio(void)
Default scheduling priority level.
int odp_schedule_config(const odp_schedule_config_t *config)
Global schedule configuration.
uint64_t odp_schedule_wait_time(uint64_t ns)
Schedule wait time.
int odp_schedule_capability(odp_schedule_capability_t *capa)
Query scheduler capabilities.
odp_schedule_group_t odp_schedule_group_create(const char *name, const odp_thrmask_t *mask)
Schedule group create.
odp_event_t odp_schedule(odp_queue_t *from, uint64_t wait)
Schedule an event.
int odp_shm_free(odp_shm_t shm)
Free a contiguous block of shared memory.
#define ODP_SHM_INVALID
Invalid shared memory block.
int odp_shm_capability(odp_shm_capability_t *capa)
Query shared memory capabilities.
void * odp_shm_addr(odp_shm_t shm)
Shared memory block address.
odp_shm_t odp_shm_reserve(const char *name, uint64_t size, uint64_t align, uint32_t flags)
Reserve a contiguous block of shared memory.
bool odp_bool_t
Boolean type.
void odp_thrmask_set(odp_thrmask_t *mask, int thr)
Add thread to mask.
int odp_thread_count_max(void)
Maximum thread count.
int odp_thread_id(void)
Get thread identifier.
void odp_thrmask_zero(odp_thrmask_t *mask)
Clear entire thread mask.
@ ODP_THREAD_WORKER
Worker thread.
@ ODP_THREAD_CONTROL
Control thread.
#define ODP_TIME_SEC_IN_NS
A second in nanoseconds.
odp_time_t odp_time_global_strict(void)
Current global time (strict)
#define ODP_TIME_MSEC_IN_NS
A millisecond in nanoseconds.
odp_time_t odp_time_local_strict(void)
Current local time (strict)
uint64_t odp_time_diff_ns(odp_time_t t2, odp_time_t t1)
Time difference in nanoseconds.
uint32_t max_sessions
Maximum number of DMA sessions.
uint32_t max_transfers
Maximum number of transfers per DMA session.
odp_dma_pool_capability_t pool
DMA completion event pool capabilities.
uint32_t max_segs
Maximum number of destination and source segments combined in a single transfer.
uint32_t max_dst_segs
Maximum number of destination segments in a single transfer.
uint32_t max_src_segs
Maximum number of source segments in a single transfer.
odp_bool_t queue_type_sched
Scheduled queue support.
odp_dma_compl_mode_t compl_mode_mask
Supported completion modes.
uint32_t max_seg_len
Maximum segment length in bytes.
DMA transfer completion parameters.
odp_dma_transfer_id_t transfer_id
Transfer identifier.
void * user_ptr
User context pointer.
odp_event_t event
Completion event.
odp_dma_compl_mode_t compl_mode
Completion mode.
odp_queue_t queue
Completion queue.
odp_dma_direction_t direction
Transfer direction.
uint32_t max_pools
Maximum number of DMA completion event pools.
uint32_t max_num
Maximum number of DMA completion events in a pool.
DMA completion event pool parameters.
uint32_t num
Number of DMA completion events in the pool.
void * user_ptr
User context pointer.
odp_bool_t success
DMA transfer success.
odp_packet_t packet
Packet handle.
uint32_t len
Segment length in bytes.
uint32_t offset
Segment start offset into the packet.
void * addr
Segment start address in memory.
odp_dma_seg_t * dst_seg
Table of destination segments.
odp_dma_data_format_t dst_format
Destination data format.
uint32_t num_dst
Number of destination segments.
uint32_t num_src
Number of source segments.
odp_dma_seg_t * src_seg
Table of source segments.
odp_dma_data_format_t src_format
Source data format.
Global initialization parameters.
odp_mem_model_t mem_model
Application memory model.
struct odp_pool_capability_t::@122 pkt
Packet pool capabilities
uint32_t max_num
Maximum number of buffers of any size.
uint32_t min_cache_size
Minimum size of thread local cache.
uint32_t max_cache_size
Maximum size of thread local cache.
uint32_t max_pools
Maximum number of pools of any type (odp_pool_type_t)
uint32_t max_len
Maximum packet data length in bytes.
uint32_t num
Number of buffers in the pool.
uint32_t cache_size
Maximum number of buffers cached locally per thread.
odp_pool_type_t type
Pool type.
uint32_t len
Minimum length of 'num' packets.
uint32_t seg_len
Minimum number of packet data bytes that can be stored in the first segment of a newly allocated pack...
struct odp_pool_param_t::@126 pkt
Parameters for packet pools.
odp_schedule_param_t sched
Scheduler parameters.
odp_queue_type_t type
Queue type.
uint32_t max_groups
Maximum number of scheduling groups.
odp_schedule_group_t group
Thread group.
odp_schedule_prio_t prio
Priority level.
odp_schedule_sync_t sync
Synchronization method.
Shared memory capabilities.
uint32_t max_blocks
Maximum number of shared memory blocks.
uint64_t max_size
Maximum memory block size in bytes.