18#include <odp/helper/odph_api.h>
20#include <bench_common.h>
21#include <export_results.h>
30#define REPEAT_COUNT 1000
39#define TIMER_NSEC 50000000
42#define TEST_MAX_BENCH 20
44#define BENCH_INFO(run_fn, init_fn, term_fn) \
45 {.name = #run_fn, .run = run_fn, .init = init_fn, .term = term_fn}
47#define BENCH_INFO_TM(run_fn, init_fn, term_fn) \
48 {.name = #run_fn, .run = run_fn, .init = init_fn, .term = term_fn}
87 int (*suite_fn)(
void *args);
89 int (*export_fn)(
void *data);
108 uint64_t a1[REPEAT_COUNT];
120 double b[TEST_MAX_BENCH];
122 bench_tm_result_t t[TEST_MAX_BENCH];
127static gbl_args_t *gbl_args;
131 if (gbl_args == NULL)
136static int setup_sig_handler(
void)
138 struct sigaction action;
140 memset(&action, 0,
sizeof(action));
141 action.sa_handler = sig_handler;
145 if (sigemptyset(&action.sa_mask))
148 if (sigaction(SIGINT, &action, NULL))
154static void cancel_timers(
void)
160 for (
int i = 0; i < REPEAT_COUNT; i++) {
164 ODPH_ABORT(
"Failed to cancel timer, ret: %d, index: %d\n", ret, i);
168static void start_timers(
void)
174 for (
int i = 0; i < REPEAT_COUNT; i++) {
178 ODPH_ABORT(
"Failed to start timer, ret: %d, index: %d\n", ret, i);
182static int timer_current_tick(
void)
186 uint64_t *a1 = gbl_args->a1;
188 for (i = 0; i < REPEAT_COUNT; i++)
194static int timer_current_tick_tm(bench_tm_result_t *res,
int repeat_count)
198 uint64_t *a1 = gbl_args->a1;
199 const uint8_t id1 = bench_tm_func_register(res,
"odp_timer_current_tick()");
200 bench_tm_stamp_t s1, s2;
202 for (i = 0; i < repeat_count; i++) {
203 bench_tm_now(res, &s1);
205 bench_tm_now(res, &s2);
206 bench_tm_func_record(&s2, &s1, res, id1);
212static int timer_tick_to_ns(
void)
216 uint64_t *a1 = gbl_args->a1;
217 uint64_t tick = gbl_args->tick;
219 for (i = 0; i < REPEAT_COUNT; i++)
225static int timer_tick_to_ns_tm(bench_tm_result_t *res,
int repeat_count)
229 uint64_t *a1 = gbl_args->a1;
230 uint64_t tick = gbl_args->tick;
231 const uint8_t id1 = bench_tm_func_register(res,
"odp_timer_tick_to_ns()");
232 bench_tm_stamp_t s1, s2;
234 for (i = 0; i < repeat_count; i++) {
235 bench_tm_now(res, &s1);
237 bench_tm_now(res, &s2);
238 bench_tm_func_record(&s2, &s1, res, id1);
244static int timer_ns_to_tick(
void)
248 uint64_t *a1 = gbl_args->a1;
249 uint64_t nsec = gbl_args->nsec;
251 for (i = 0; i < REPEAT_COUNT; i++)
257static int timer_ns_to_tick_tm(bench_tm_result_t *res,
int repeat_count)
261 uint64_t *a1 = gbl_args->a1;
262 uint64_t nsec = gbl_args->nsec;
263 const uint8_t id1 = bench_tm_func_register(res,
"odp_timer_ns_to_tick()");
264 bench_tm_stamp_t s1, s2;
266 for (i = 0; i < repeat_count; i++) {
267 bench_tm_now(res, &s1);
269 bench_tm_now(res, &s2);
270 bench_tm_func_record(&s2, &s1, res, id1);
276static int timeout_to_event(
void)
282 for (i = 0; i < REPEAT_COUNT; i++)
290static int timeout_to_event_tm(bench_tm_result_t *res,
int repeat_count)
295 const uint8_t id1 = bench_tm_func_register(res,
"odp_timeout_to_event()");
296 bench_tm_stamp_t s1, s2;
298 for (i = 0; i < repeat_count; i++) {
299 bench_tm_now(res, &s1);
301 bench_tm_now(res, &s2);
302 bench_tm_func_record(&s2, &s1, res, id1);
310static int timeout_from_event(
void)
316 for (i = 0; i < REPEAT_COUNT; i++)
324static int timeout_from_event_tm(bench_tm_result_t *res,
int repeat_count)
329 const uint8_t id1 = bench_tm_func_register(res,
"odp_timeout_from_event()");
330 bench_tm_stamp_t s1, s2;
332 for (i = 0; i < repeat_count; i++) {
333 bench_tm_now(res, &s1);
335 bench_tm_now(res, &s2);
336 bench_tm_func_record(&s2, &s1, res, id1);
344static int timeout_timer(
void)
350 for (i = 0; i < REPEAT_COUNT; i++)
358static int timeout_timer_tm(bench_tm_result_t *res,
int repeat_count)
363 const uint8_t id1 = bench_tm_func_register(res,
"odp_timeout_timer()");
364 bench_tm_stamp_t s1, s2;
366 for (i = 0; i < repeat_count; i++) {
367 bench_tm_now(res, &s1);
369 bench_tm_now(res, &s2);
370 bench_tm_func_record(&s2, &s1, res, id1);
378static int timeout_tick(
void)
382 uint64_t *a1 = gbl_args->a1;
384 for (i = 0; i < REPEAT_COUNT; i++)
390static int timeout_tick_tm(bench_tm_result_t *res,
int repeat_count)
394 uint64_t *a1 = gbl_args->a1;
395 const uint8_t id1 = bench_tm_func_register(res,
"odp_timeout_tick()");
396 bench_tm_stamp_t s1, s2;
398 for (i = 0; i < repeat_count; i++) {
399 bench_tm_now(res, &s1);
401 bench_tm_now(res, &s2);
402 bench_tm_func_record(&s2, &s1, res, id1);
408static int timeout_user_ptr(
void)
412 uint64_t *a1 = gbl_args->a1;
414 for (i = 0; i < REPEAT_COUNT; i++)
420static int timeout_user_ptr_tm(bench_tm_result_t *res,
int repeat_count)
424 uint64_t *a1 = gbl_args->a1;
425 const uint8_t id1 = bench_tm_func_register(res,
"odp_timeout_user_ptr()");
426 bench_tm_stamp_t s1, s2;
428 for (i = 0; i < repeat_count; i++) {
429 bench_tm_now(res, &s1);
431 bench_tm_now(res, &s2);
432 bench_tm_func_record(&s2, &s1, res, id1);
438static int timeout_user_area(
void)
442 uint64_t *a1 = gbl_args->a1;
444 for (i = 0; i < REPEAT_COUNT; i++)
450static int timeout_user_area_tm(bench_tm_result_t *res,
int repeat_count)
454 uint64_t *a1 = gbl_args->a1;
455 const uint8_t id1 = bench_tm_func_register(res,
"odp_timeout_user_area()");
456 bench_tm_stamp_t s1, s2;
458 for (i = 0; i < repeat_count; i++) {
459 bench_tm_now(res, &s1);
461 bench_tm_now(res, &s2);
462 bench_tm_func_record(&s2, &s1, res, id1);
468static int timeout_is_periodic(
void)
472 uint64_t *a1 = gbl_args->a1;
474 for (i = 0; i < REPEAT_COUNT; i++)
480static int timeout_is_periodic_tm(bench_tm_result_t *res,
int repeat_count)
484 uint64_t *a1 = gbl_args->a1;
485 const uint8_t id1 = bench_tm_func_register(res,
"odp_timeout_is_periodic()");
486 bench_tm_stamp_t s1, s2;
488 for (i = 0; i < repeat_count; i++) {
489 bench_tm_now(res, &s1);
491 bench_tm_now(res, &s2);
492 bench_tm_func_record(&s2, &s1, res, id1);
498static int timeout_to_u64(
void)
502 uint64_t *a1 = gbl_args->a1;
504 for (i = 0; i < REPEAT_COUNT; i++)
510static int timeout_to_u64_tm(bench_tm_result_t *res,
int repeat_count)
514 uint64_t *a1 = gbl_args->a1;
515 const uint8_t id1 = bench_tm_func_register(res,
"odp_timeout_to_u64()");
516 bench_tm_stamp_t s1, s2;
518 for (i = 0; i < repeat_count; i++) {
519 bench_tm_now(res, &s1);
521 bench_tm_now(res, &s2);
522 bench_tm_func_record(&s2, &s1, res, id1);
528static int timer_to_u64(
void)
532 uint64_t *a1 = gbl_args->a1;
534 for (i = 0; i < REPEAT_COUNT; i++)
540static int timer_to_u64_tm(bench_tm_result_t *res,
int repeat_count)
544 uint64_t *a1 = gbl_args->a1;
545 const uint8_t id1 = bench_tm_func_register(res,
"odp_timer_to_u64()");
546 bench_tm_stamp_t s1, s2;
548 for (i = 0; i < repeat_count; i++) {
549 bench_tm_now(res, &s1);
551 bench_tm_now(res, &s2);
552 bench_tm_func_record(&s2, &s1, res, id1);
558static int timer_pool_to_u64(
void)
562 uint64_t *a1 = gbl_args->a1;
564 for (i = 0; i < REPEAT_COUNT; i++)
570static int timer_pool_to_u64_tm(bench_tm_result_t *res,
int repeat_count)
574 uint64_t *a1 = gbl_args->a1;
575 const uint8_t id1 = bench_tm_func_register(res,
"odp_timer_pool_to_u64()");
576 bench_tm_stamp_t s1, s2;
578 for (i = 0; i < repeat_count; i++) {
579 bench_tm_now(res, &s1);
581 bench_tm_now(res, &s2);
582 bench_tm_func_record(&s2, &s1, res, id1);
588static int timer_start(
void)
594 for (i = 0; i < REPEAT_COUNT; i++) {
603static int timer_start_tm(bench_tm_result_t *res,
int repeat_count)
608 const uint8_t id1 = bench_tm_func_register(res,
"odp_timer_start()");
609 bench_tm_stamp_t s1, s2;
611 for (i = 0; i < repeat_count; i++) {
612 bench_tm_now(res, &s1);
617 bench_tm_now(res, &s2);
618 bench_tm_func_record(&s2, &s1, res, id1);
624static int timer_cancel(
void)
630 for (i = 0; i < REPEAT_COUNT; i++) {
639static int timer_cancel_tm(bench_tm_result_t *res,
int repeat_count)
644 const uint8_t id1 = bench_tm_func_register(res,
"odp_timer_cancel()");
645 bench_tm_stamp_t s1, s2;
647 for (i = 0; i < repeat_count; i++) {
648 bench_tm_now(res, &s1);
653 bench_tm_now(res, &s2);
654 bench_tm_func_record(&s2, &s1, res, id1);
660static int timer_start_cancel(
void)
667 for (i = 0; i < REPEAT_COUNT; i++) {
680static int timer_start_cancel_tm(bench_tm_result_t *res,
int repeat_count)
686 const uint8_t id1 = bench_tm_func_register(res,
"odp_timer_start()/_cancel()");
687 bench_tm_stamp_t s1, s2;
689 for (i = 0; i < repeat_count; i++) {
690 bench_tm_now(res, &s1);
699 bench_tm_now(res, &s2);
700 bench_tm_func_record(&s2, &s1, res, id1);
706static int bench_timer_tm_export(
void *data)
708 gbl_args_t *gbl_args = data;
709 bench_tm_result_t *res;
712 const char *unit = gbl_args->opt.time ?
"nsec" :
"cpu cycles";
714 if (test_common_write(
"function name,min %s per function call,"
715 "average %s per function call,"
716 "max %s per function call\n", unit, unit, unit)) {
721 for (uint32_t i = 0; i < gbl_args->suite.t.num_bench; i++) {
722 res = &gbl_args->suite.t.result[i];
724 for (
int j = 0; j < res->num; j++) {
725 num = res->func[j].num ? res->func[j].num : 1;
726 if (test_common_write(
"%s,%" PRIu64
",%" PRIu64
",%" PRIu64
"\n",
728 bench_tm_to_u64(res, &res->func[j].min),
729 bench_tm_to_u64(res, &res->func[j].tot) / num,
730 bench_tm_to_u64(res, &res->func[j].max))) {
738 test_common_write_term();
743static int bench_timer_export(
void *data)
745 gbl_args_t *gbl_args = data;
748 if (test_common_write(
"%s", gbl_args->opt.time ?
749 "function name,average nsec per function call\n" :
750 "function name,average cpu cycles per function call\n")) {
755 for (
int i = 0; i < gbl_args->suite.b.num_bench; i++) {
756 if (test_common_write(
"odp_%s,%f\n",
757 gbl_args->suite.b.bench[i].name,
758 gbl_args->suite.b.result[i])) {
765 test_common_write_term();
770bench_info_t test_suite[] = {
771 BENCH_INFO(timer_current_tick, NULL, NULL),
772 BENCH_INFO(timer_tick_to_ns, NULL, NULL),
773 BENCH_INFO(timer_ns_to_tick, NULL, NULL),
774 BENCH_INFO(timeout_to_event, NULL, NULL),
775 BENCH_INFO(timeout_from_event, NULL, NULL),
776 BENCH_INFO(timeout_timer, NULL, NULL),
777 BENCH_INFO(timeout_tick, NULL, NULL),
778 BENCH_INFO(timeout_user_ptr, NULL, NULL),
779 BENCH_INFO(timeout_user_area, NULL, NULL),
780 BENCH_INFO(timeout_is_periodic, NULL, NULL),
781 BENCH_INFO(timeout_to_u64, NULL, NULL),
782 BENCH_INFO(timer_to_u64, NULL, NULL),
783 BENCH_INFO(timer_pool_to_u64, NULL, NULL),
784 BENCH_INFO(timer_start, NULL, cancel_timers),
785 BENCH_INFO(timer_cancel, start_timers, NULL),
786 BENCH_INFO(timer_start_cancel, NULL, NULL),
790 "Result array is too small to hold all the results");
792bench_tm_info_t test_suite_tm[] = {
793 BENCH_INFO_TM(timer_current_tick_tm, NULL, NULL),
794 BENCH_INFO_TM(timer_tick_to_ns_tm, NULL, NULL),
795 BENCH_INFO_TM(timer_ns_to_tick_tm, NULL, NULL),
796 BENCH_INFO_TM(timeout_to_event_tm, NULL, NULL),
797 BENCH_INFO_TM(timeout_from_event_tm, NULL, NULL),
798 BENCH_INFO_TM(timeout_timer_tm, NULL, NULL),
799 BENCH_INFO_TM(timeout_tick_tm, NULL, NULL),
800 BENCH_INFO_TM(timeout_user_ptr_tm, NULL, NULL),
801 BENCH_INFO_TM(timeout_user_area_tm, NULL, NULL),
802 BENCH_INFO_TM(timeout_is_periodic_tm, NULL, NULL),
803 BENCH_INFO_TM(timeout_to_u64_tm, NULL, NULL),
804 BENCH_INFO_TM(timer_to_u64_tm, NULL, NULL),
805 BENCH_INFO_TM(timer_pool_to_u64_tm, NULL, NULL),
806 BENCH_INFO_TM(timer_start_tm, NULL, cancel_timers),
807 BENCH_INFO_TM(timer_cancel_tm, start_timers, NULL),
808 BENCH_INFO_TM(timer_start_cancel_tm, NULL, NULL),
812 "Result array is too small to hold all the results");
815static void usage(
void)
818 "ODP timer API micro benchmarks\n"
821 " -s, --clk_src Clock source select (default 0):\n"
822 " 0: ODP_CLOCK_DEFAULT\n"
823 " 1: ODP_CLOCK_SRC_1, ...\n"
824 " -t, --time <opt> Time measurement. 0: measure CPU cycles (default), 1: measure time\n"
825 " -i, --index <idx> Benchmark index to run indefinitely.\n"
826 " -r, --rounds <num> Run each test case 'num' times (default %u).\n"
827 " -m, --mode <mode> Measurement mode. 0: measure throughput, track average execution\n"
828 " time (default), 1: measure latency, track function minimum and\n"
829 " maximum in addition to average execution time.\n"
830 " -h, --help Display help and exit.\n\n"
835static int parse_args(
int argc,
char *argv[])
838 static const struct option longopts[] = {
839 {
"clk_src", required_argument, NULL,
's'},
840 {
"time", required_argument, NULL,
't'},
841 {
"index", required_argument, NULL,
'i'},
842 {
"rounds", required_argument, NULL,
'r'},
843 {
"mode", required_argument, NULL,
'm'},
844 {
"help", no_argument, NULL,
'h'},
848 static const char *shortopts =
"s:t:i:r:m:h";
851 gbl_args->opt.time = 0;
852 gbl_args->opt.bench_idx = 0;
853 gbl_args->opt.rounds = ROUNDS;
854 gbl_args->opt.mode = M_TPUT;
857 opt = getopt_long(argc, argv, shortopts, longopts, NULL);
864 gbl_args->opt.clk_src = atoi(optarg);
867 gbl_args->opt.time = atoi(optarg);
870 gbl_args->opt.bench_idx = atoi(optarg);
873 gbl_args->opt.rounds = atoi(optarg);
876 gbl_args->opt.mode = atoi(optarg);
882 ODPH_ERR(
"Bad option. Use -h for help.\n");
887 if (gbl_args->opt.rounds < 1) {
888 ODPH_ERR(
"Invalid test cycle repeat count: %u\n", gbl_args->opt.rounds);
892 if (gbl_args->opt.bench_idx < 0 ||
893 gbl_args->opt.bench_idx > (
int)ODPH_ARRAY_SIZE(test_suite)) {
894 ODPH_ERR(
"Bad bench index %i\n", gbl_args->opt.bench_idx);
898 if (gbl_args->opt.mode != M_TPUT && gbl_args->opt.mode != M_LATENCY) {
899 printf(
"Invalid measurement mode: %d\n", gbl_args->opt.mode);
909static void print_info(
void)
914 "odp_bench_timer options\n"
915 "-----------------------\n");
917 printf(
"CPU mask: %s\n", gbl_args->cpumask_str);
918 printf(
"Clock source: %i\n", gbl_args->opt.clk_src);
919 printf(
"Measurement unit: %s\n", gbl_args->opt.time ?
"nsec" :
"CPU cycles");
920 printf(
"Test rounds: %u\n", gbl_args->opt.rounds);
921 printf(
"Timer duration: %" PRIu64
" nsec\n", gbl_args->timer_nsec);
922 printf(
"Timer tick freq: %.2f Hz\n", gbl_args->tick_hz);
923 printf(
"Measurement mode: %s\n", gbl_args->opt.mode == M_TPUT ?
"throughput" :
"latency");
927static int create_timers(
void)
940 uint64_t t1, t2, diff, tick1, tick2;
941 const uint32_t num_timers = REPEAT_COUNT + 1;
944 ODPH_ERR(
"Pool capa failed\n");
948 clk_src = gbl_args->opt.clk_src;
950 ODPH_ERR(
"Timer capa failed\n");
955 ODPH_ERR(
"Not enough timers supported\n");
969 ODPH_ERR(
"Timer pool create failed\n");
974 ODPH_ERR(
"Timer pool start failed\n");
978 gbl_args->timer_pool = tp;
980 gbl_args->timer_nsec = TIMER_NSEC;
981 if (TIMER_NSEC < tp_param.
min_tmo)
982 gbl_args->timer_nsec = tp_param.
min_tmo;
983 else if (TIMER_NSEC > tp_param.
max_tmo)
984 gbl_args->timer_nsec = tp_param.
max_tmo;
996 ODPH_ERR(
"Timeout pool create failed\n");
1000 gbl_args->pool = pool;
1005 ODPH_ERR(
"Timeout alloc failed\n");
1009 gbl_args->timeout = tmo;
1034 gbl_args->plain_queue = 1;
1039 ODPH_ERR(
"Queue create failed\n");
1043 gbl_args->queue = queue;
1047 ODPH_ERR(
"Timer alloc failed\n");
1051 gbl_args->timer = timer;
1053 for (
int i = 0; i < REPEAT_COUNT; i++) {
1057 ODPH_ERR(
"Timer alloc failed\n");
1065static int wait_timer(
void)
1070 uint64_t wait_nsec = 2 * gbl_args->timer_nsec;
1080 ODPH_ERR(
"Timer start failed\n");
1088 if (gbl_args->plain_queue) {
1097 ODPH_ERR(
"Timeout event missing\n");
1102 gbl_args->event = ev;
1107 ODPH_ERR(
"Timeout event missing\n");
1111 gbl_args->event = ev;
1115 ODPH_ERR(
"Extra timeout event\n");
1121 ODPH_ERR(
"Bad event type\n");
1130static void init_suite(gbl_args_t *gbl_args)
1132 if (gbl_args->opt.mode == M_LATENCY) {
1133 bench_tm_suite_init(&gbl_args->suite.t);
1134 gbl_args->suite.t.bench = test_suite_tm;
1135 gbl_args->suite.t.num_bench = ODPH_ARRAY_SIZE(test_suite_tm);
1136 gbl_args->suite.t.rounds = REPEAT_COUNT;
1137 gbl_args->suite.t.bench_idx = gbl_args->opt.bench_idx;
1138 gbl_args->suite.t.measure_time = !!gbl_args->opt.time;
1139 gbl_args->suite.exit = &gbl_args->suite.t.exit_worker;
1140 gbl_args->suite.retval = &gbl_args->suite.t.retval;
1141 gbl_args->suite.args = &gbl_args->suite.t;
1142 gbl_args->suite.suite_fn = bench_tm_run;
1143 gbl_args->suite.export_fn = bench_timer_tm_export;
1144 gbl_args->suite.t.result = gbl_args->result.t;
1146 bench_suite_init(&gbl_args->suite.b);
1147 gbl_args->suite.b.bench = test_suite;
1148 gbl_args->suite.b.num_bench = ODPH_ARRAY_SIZE(test_suite);
1149 gbl_args->suite.b.indef_idx = gbl_args->opt.bench_idx;
1150 gbl_args->suite.b.rounds = gbl_args->opt.rounds;
1151 gbl_args->suite.b.repeat_count = REPEAT_COUNT;
1152 gbl_args->suite.b.measure_time = !!gbl_args->opt.time;
1153 gbl_args->suite.exit = &gbl_args->suite.b.exit_worker;
1154 gbl_args->suite.retval = &gbl_args->suite.b.retval;
1155 gbl_args->suite.args = &gbl_args->suite.b;
1156 gbl_args->suite.suite_fn = bench_run;
1157 gbl_args->suite.export_fn = bench_timer_export;
1158 gbl_args->suite.b.result = gbl_args->result.b;
1162static void drain_timeouts(
void)
1164 const int is_plain = gbl_args->plain_queue;
1179int main(
int argc,
char *argv[])
1181 odph_helper_options_t helper_options;
1182 test_common_options_t common_options;
1183 odph_thread_t worker_thread;
1184 odph_thread_common_param_t thr_common;
1185 odph_thread_param_t thr_param;
1194 argc = odph_parse_options(argc, argv);
1195 if (odph_options(&helper_options)) {
1196 ODPH_ERR(
"Reading ODP helper options failed\n");
1200 argc = test_common_parse_options(argc, argv);
1201 if (test_common_options(&common_options)) {
1202 ODPH_ERR(
"Reading test options failed\n");
1207 init_param.
mem_model = helper_options.mem_model;
1211 ODPH_ERR(
"Global init failed\n");
1217 ODPH_ERR(
"Local init failed\n");
1221 if (setup_sig_handler()) {
1222 ODPH_ERR(
"Signal handler setup failed\n");
1229 shm =
odp_shm_reserve(
"shm_args",
sizeof(gbl_args_t), ODP_CACHE_LINE_SIZE, 0);
1231 ODPH_ERR(
"Shared mem reserve failed\n");
1236 if (gbl_args == NULL) {
1237 ODPH_ERR(
"Shared mem alloc failed\n");
1241 memset(gbl_args, 0,
sizeof(gbl_args_t));
1248 for (i = 0; i < REPEAT_COUNT; i++) {
1249 gbl_args->a1[i] = i;
1257 ret = parse_args(argc, argv);
1261 init_suite(gbl_args);
1265 ODPH_ERR(
"Unable to allocate worker thread\n");
1271 sizeof(gbl_args->cpumask_str));
1274 ret = create_timers();
1286 memset(&worker_thread, 0,
sizeof(odph_thread_t));
1294 odph_thread_common_param_init(&thr_common);
1295 thr_common.instance = instance;
1296 thr_common.cpumask = &cpumask;
1297 thr_common.share_param = 1;
1299 odph_thread_param_init(&thr_param);
1300 thr_param.start = gbl_args->suite.suite_fn;
1301 thr_param.arg = gbl_args->suite.args;
1304 odph_thread_create(&worker_thread, &thr_common, &thr_param, 1);
1306 odph_thread_join(&worker_thread, 1);
1310 if (gbl_args->suite.dummy)
1311 printf(
"(dummy result: 0x%" PRIx64
")\n\n", gbl_args->suite.dummy);
1313 ret = *gbl_args->suite.retval;
1315 if (ret == 0 && common_options.is_export) {
1316 if (gbl_args->suite.export_fn(gbl_args)) {
1317 ODPH_ERR(
"Error: Export failed\n");
1331 ODPH_ERR(
"Timer free failed\n");
1336 for (i = 0; i < REPEAT_COUNT; i++) {
1339 ODPH_ERR(
"Timer free failed\n");
1350 ODPH_ERR(
"Queue destroy failed\n");
1356 ODPH_ERR(
"Shared mem free failed\n");
1361 ODPH_ERR(
"Local term failed\n");
1366 ODPH_ERR(
"Global term failed\n");
1371 return EXIT_FAILURE;
1373 return EXIT_SUCCESS;
void odp_atomic_store_u32(odp_atomic_u32_t *atom, uint32_t val)
Store value to atomic uint32 variable.
#define ODP_UNUSED
Intentionally unused variables of functions.
void odp_cpumask_set(odp_cpumask_t *mask, int cpu)
Add CPU to mask.
int odp_cpumask_default_worker(odp_cpumask_t *mask, int num)
Default CPU mask for worker threads.
int odp_cpumask_first(const odp_cpumask_t *mask)
Find first set CPU in mask.
void odp_cpumask_zero(odp_cpumask_t *mask)
Clear entire CPU mask.
int32_t odp_cpumask_to_str(const odp_cpumask_t *mask, char *str, int32_t size)
Format a string from CPU mask.
#define ODP_CPUMASK_STR_SIZE
The maximum number of characters needed to record any CPU mask as a string (output of odp_cpumask_to_...
odp_event_type_t odp_event_type(odp_event_t event)
Event type of an event.
uint64_t odp_event_to_u64(odp_event_t hdl)
Get printable value for an odp_event_t.
#define ODP_EVENT_INVALID
Invalid event.
void odp_init_param_init(odp_init_t *param)
Initialize the odp_init_t to default values for all fields.
#define ODP_STATIC_ASSERT(cond, msg)
Compile time assertion macro.
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.
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_TIMEOUT
Timeout pool.
void odp_queue_param_init(odp_queue_param_t *param)
Initialize queue params.
#define ODP_QUEUE_INVALID
Invalid queue.
odp_event_t odp_queue_deq(odp_queue_t queue)
Dequeue an event from a 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.
@ ODP_QUEUE_TYPE_PLAIN
Plain queue.
#define ODP_SCHED_SYNC_ATOMIC
Atomic queue synchronization.
#define ODP_SCHED_NO_WAIT
Do not wait.
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.
odp_event_t odp_schedule(odp_queue_t *from, uint64_t wait)
Schedule an event.
#define ODP_SCHED_GROUP_ALL
Group of all threads.
int odp_shm_free(odp_shm_t shm)
Free a contiguous block of shared memory.
void * odp_shm_addr(odp_shm_t shm)
Shared memory block address.
#define ODP_SHM_INVALID
Invalid shared memory block.
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.
void odp_sys_info_print(void)
Print system info.
@ ODP_THREAD_WORKER
Worker thread.
@ ODP_THREAD_CONTROL
Control thread.
#define ODP_TIME_SEC_IN_NS
A second in nanoseconds.
void odp_time_wait_ns(uint64_t ns)
Wait the specified number of nanoseconds.
uint64_t odp_time_global_strict_ns(void)
Current global time in nanoseconds (strict)
#define ODP_TIME_MSEC_IN_NS
A millisecond in nanoseconds.
uint64_t odp_time_global_ns(void)
Current global time in nanoseconds.
void odp_timeout_free(odp_timeout_t tmo)
Timeout free.
uint64_t odp_timer_tick_to_ns(odp_timer_pool_t timer_pool, uint64_t ticks)
Convert timer ticks to nanoseconds.
int odp_timer_pool_start_multi(odp_timer_pool_t timer_pool[], int num)
Start timer pools.
void * odp_timeout_user_ptr(odp_timeout_t tmo)
Return user pointer for the timeout.
odp_timeout_t odp_timeout_alloc(odp_pool_t pool)
Timeout alloc.
uint64_t odp_timeout_tick(odp_timeout_t tmo)
Timeout expiration tick.
void * odp_timeout_user_area(odp_timeout_t tmo)
Timeout user area.
int odp_timer_free(odp_timer_t timer)
Free a timer.
odp_timeout_t odp_timeout_from_event(odp_event_t ev)
Get timeout handle from an ODP_EVENT_TIMEOUT type event.
#define ODP_TIMER_POOL_INVALID
Invalid timer pool handle.
odp_timer_pool_t odp_timer_pool_create(const char *name, const odp_timer_pool_param_t *params)
Create a timer pool.
odp_timer_t odp_timeout_timer(odp_timeout_t tmo)
Return timer handle for the timeout.
int odp_timer_cancel(odp_timer_t timer, odp_event_t *tmo_ev)
Cancel a single shot timer.
uint64_t odp_timer_current_tick(odp_timer_pool_t timer_pool)
Current tick value.
int odp_timer_capability(odp_timer_clk_src_t clk_src, odp_timer_capability_t *capa)
Query timer capabilities per clock source.
uint64_t odp_timer_ns_to_tick(odp_timer_pool_t timer_pool, uint64_t ns)
Convert nanoseconds to timer ticks.
uint64_t odp_timeout_to_u64(odp_timeout_t tmo)
Get printable value for an odp_timeout_t.
odp_timer_clk_src_t
Clock sources for timer pools.
int odp_timer_start(odp_timer_t timer, const odp_timer_start_t *start_param)
Start a single shot timer.
odp_event_t odp_timeout_to_event(odp_timeout_t tmo)
Convert timeout handle to event handle.
#define ODP_TIMEOUT_INVALID
Invalid timeout handle.
odp_timer_t odp_timer_alloc(odp_timer_pool_t timer_pool, odp_queue_t queue, const void *user_ptr)
Allocate a single shot timer.
#define ODP_CLOCK_DEFAULT
The default clock source.
uint64_t odp_timer_pool_to_u64(odp_timer_pool_t timer_pool)
Get printable value for an odp_timer_pool_t.
int odp_timeout_is_periodic(odp_timeout_t tmo)
Check if timeout is from a periodic timer.
#define ODP_TIMER_INVALID
Invalid timer handle.
uint64_t odp_timer_to_u64(odp_timer_t timer)
Get printable value for an odp_timer_t.
void odp_timer_pool_param_init(odp_timer_pool_param_t *param)
Initialize timer pool parameters.
void odp_timer_pool_destroy(odp_timer_pool_t timer_pool)
Destroy a timer pool.
@ ODP_TIMER_SUCCESS
Timer operation succeeded.
@ ODP_TIMER_FAIL
Timer operation failed.
@ ODP_TIMER_TICK_REL
Relative ticks.
Global initialization parameters.
odp_mem_model_t mem_model
Application memory model.
struct odp_pool_capability_t::@135 tmo
Timeout pool capabilities
uint32_t max_uarea_size
Maximum user area size in bytes.
uint32_t uarea_size
Minimum user area size in bytes.
uint32_t num
Number of buffers in the pool.
odp_pool_type_t type
Pool type.
struct odp_pool_param_t::@140 tmo
Parameters for timeout pools.
odp_schedule_param_t sched
Scheduler parameters.
odp_queue_type_t type
Queue type.
odp_schedule_group_t group
Thread group.
odp_schedule_prio_t prio
Priority level.
odp_schedule_sync_t sync
Synchronization method.
uint32_t max_timers
Maximum number of single shot timers in a pool.
odp_timer_res_capability_t max_res
Maximum resolution.
odp_bool_t queue_type_sched
Scheduled queue destination support.
uint64_t res_ns
Timeout resolution in nanoseconds.
uint64_t min_tmo
Minimum relative timeout in nanoseconds.
uint32_t num_timers
Number of timers in the pool.
odp_timer_clk_src_t clk_src
Clock source for timers.
uint64_t max_tmo
Maximum relative timeout in nanoseconds.
uint64_t max_tmo
Maximum relative timeout in nanoseconds.
uint64_t min_tmo
Minimum relative timeout in nanoseconds.
uint64_t res_ns
Timeout resolution in nanoseconds.
uint64_t tick
Expiration time in ticks.
odp_event_t tmo_ev
Timeout event.
odp_timer_tick_type_t tick_type
Tick type.