From b4db06615d1042a180e3a3b28117e85e5525db68 Mon Sep 17 00:00:00 2001 From: Dmitriy Korovkin Date: Tue, 1 Nov 2016 17:05:18 -0400 Subject: [PATCH] unified/tests: Remove nanokernel test part from latency_measure Nanokernel part of the latency_measure test is a subset of the microkekernel tests. For unified kernel there is no reason to have nanokernel test - for unified kernel we have to run whole the set of tests. Change-Id: Ief176fd9d25e7355e3d3697c3bbc1e953b16655c Signed-off-by: Dmitriy Korovkin --- .../legacy/benchmark/app_kernel/src/Makefile | 2 +- .../{microkernel => }/Makefile | 0 .../{microkernel => }/README.txt | 0 .../latency_measure/nanokernel/Makefile | 6 -- .../latency_measure/nanokernel/README.txt | 62 ------------------- .../latency_measure/nanokernel/prj.conf | 5 -- .../latency_measure/nanokernel/testcase.ini | 4 -- .../{microkernel => }/prj.conf | 0 .../{microkernel => }/prj.mdef | 0 .../{microkernel => }/src/Makefile | 0 .../{microkernel => }/src/main.c | 22 +------ .../{microkernel => }/src/micro_int_to_task.c | 9 +-- .../src/micro_int_to_task_evt.c | 15 ++--- .../src/micro_sema_lock_release.c | 31 +++++----- .../src/micro_task_switch_yield.c | 29 +++++---- .../{microkernel => }/src/nano_ctx_switch.c | 18 +++--- .../{microkernel => }/src/nano_int.c | 4 +- .../src/nano_int_lock_unlock.c | 7 ++- .../{microkernel => }/src/nano_int_to_fiber.c | 8 +-- .../src/nano_int_to_fiber_sem.c | 12 ++-- .../src/test_asm_inline_gcc.h | 0 .../{microkernel => }/src/timestamp.h | 27 +------- .../{microkernel => }/src/utils.c | 0 .../{microkernel => }/src/utils.h | 57 ++++++++++------- .../{microkernel => }/testcase.ini | 2 +- .../legacy/benchmark/sys_kernel/src/Makefile | 2 +- 26 files changed, 104 insertions(+), 218 deletions(-) rename tests/legacy/benchmark/latency_measure/{microkernel => }/Makefile (100%) rename tests/legacy/benchmark/latency_measure/{microkernel => }/README.txt (100%) delete mode 100644 tests/legacy/benchmark/latency_measure/nanokernel/Makefile delete mode 100644 tests/legacy/benchmark/latency_measure/nanokernel/README.txt delete mode 100644 tests/legacy/benchmark/latency_measure/nanokernel/prj.conf delete mode 100644 tests/legacy/benchmark/latency_measure/nanokernel/testcase.ini rename tests/legacy/benchmark/latency_measure/{microkernel => }/prj.conf (100%) rename tests/legacy/benchmark/latency_measure/{microkernel => }/prj.mdef (100%) rename tests/legacy/benchmark/latency_measure/{microkernel => }/src/Makefile (100%) rename tests/legacy/benchmark/latency_measure/{microkernel => }/src/main.c (86%) rename tests/legacy/benchmark/latency_measure/{microkernel => }/src/micro_int_to_task.c (92%) rename tests/legacy/benchmark/latency_measure/{microkernel => }/src/micro_int_to_task_evt.c (87%) rename tests/legacy/benchmark/latency_measure/{microkernel => }/src/micro_sema_lock_release.c (82%) rename tests/legacy/benchmark/latency_measure/{microkernel => }/src/micro_task_switch_yield.c (86%) rename tests/legacy/benchmark/latency_measure/{microkernel => }/src/nano_ctx_switch.c (88%) rename tests/legacy/benchmark/latency_measure/{microkernel => }/src/nano_int.c (94%) rename tests/legacy/benchmark/latency_measure/{microkernel => }/src/nano_int_lock_unlock.c (92%) rename tests/legacy/benchmark/latency_measure/{microkernel => }/src/nano_int_to_fiber.c (93%) rename tests/legacy/benchmark/latency_measure/{microkernel => }/src/nano_int_to_fiber_sem.c (91%) rename tests/legacy/benchmark/latency_measure/{microkernel => }/src/test_asm_inline_gcc.h (100%) rename tests/legacy/benchmark/latency_measure/{microkernel => }/src/timestamp.h (83%) rename tests/legacy/benchmark/latency_measure/{microkernel => }/src/utils.c (100%) rename tests/legacy/benchmark/latency_measure/{microkernel => }/src/utils.h (61%) rename tests/legacy/benchmark/latency_measure/{microkernel => }/testcase.ini (57%) diff --git a/tests/legacy/benchmark/app_kernel/src/Makefile b/tests/legacy/benchmark/app_kernel/src/Makefile index c2f59e6f69b..e344b1c5a86 100644 --- a/tests/legacy/benchmark/app_kernel/src/Makefile +++ b/tests/legacy/benchmark/app_kernel/src/Makefile @@ -1,5 +1,5 @@ ccflags-y += -I$(CURDIR)/misc/generated/sysgen -ccflags-y += -I$(ZEPHYR_BASE)/tests/legacy/benchmark/latency_measure/microkernel/src \ +ccflags-y += -I$(ZEPHYR_BASE)/tests/legacy/benchmark/latency_measure/src \ -I${ZEPHYR_BASE}/tests/include obj-y := fifo_b.o mailbox_b.o master.o mempool_b.o \ diff --git a/tests/legacy/benchmark/latency_measure/microkernel/Makefile b/tests/legacy/benchmark/latency_measure/Makefile similarity index 100% rename from tests/legacy/benchmark/latency_measure/microkernel/Makefile rename to tests/legacy/benchmark/latency_measure/Makefile diff --git a/tests/legacy/benchmark/latency_measure/microkernel/README.txt b/tests/legacy/benchmark/latency_measure/README.txt similarity index 100% rename from tests/legacy/benchmark/latency_measure/microkernel/README.txt rename to tests/legacy/benchmark/latency_measure/README.txt diff --git a/tests/legacy/benchmark/latency_measure/nanokernel/Makefile b/tests/legacy/benchmark/latency_measure/nanokernel/Makefile deleted file mode 100644 index 550a1b2b180..00000000000 --- a/tests/legacy/benchmark/latency_measure/nanokernel/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNEL_TYPE = nano -BOARD ?= qemu_x86 -CONF_FILE = prj.conf -SOURCE_DIR = $(ZEPHYR_BASE)/tests/legacy/benchmark/latency_measure/microkernel/src/ - -include $(ZEPHYR_BASE)/Makefile.inc diff --git a/tests/legacy/benchmark/latency_measure/nanokernel/README.txt b/tests/legacy/benchmark/latency_measure/nanokernel/README.txt deleted file mode 100644 index 7b05f82fd0e..00000000000 --- a/tests/legacy/benchmark/latency_measure/nanokernel/README.txt +++ /dev/null @@ -1,62 +0,0 @@ -Title: Latency Measurement - -Description: - -This benchmark measures the latency of selected nanokernel features. - -IMPORTANT: The results below were generated using a simulation environment, -and may not reflect the results that will be generated using other -environments (simulated or otherwise). - --------------------------------------------------------------------------------- - -Building and Running Project: - -This nanokernel project outputs to the console. It can be built and executed -on QEMU as follows: - - make qemu - --------------------------------------------------------------------------------- - -Troubleshooting: - -Problems caused by out-dated project information can be addressed by -issuing one of the following commands then rebuilding the project: - - make clean # discard results of previous builds - # but keep existing configuration info -or - make pristine # discard results of previous builds - # and restore pre-defined configuration info - --------------------------------------------------------------------------------- - -Sample Output: - -|-----------------------------------------------------------------------------| -| Nanokernel Latency Benchmark | -|-----------------------------------------------------------------------------| -| tcs = timer clock cycles: 1 tcs is N nsec | -|-----------------------------------------------------------------------------| -| 1- Measure time to switch from fiber to ISR execution | -| switching time is NNNN tcs = NNNNN nsec | -|-----------------------------------------------------------------------------| -| 2- Measure time to switch from ISR back to interrupted fiber | -| switching time is NNNN tcs = NNNNN nsec | -|-----------------------------------------------------------------------------| -| 3- Measure time from ISR to executing a different fiber (rescheduled) | -| switching time is NNNN tcs = NNNNN nsec | -|-----------------------------------------------------------------------------| -| 4- Measure average context switch time between fibers | -| Average context switch time is NNNN tcs = NNNNN nsec | -|-----------------------------------------------------------------------------| -| 5- Measure average time to lock then unlock interrupts | -| 5.1- When each lock and unlock is executed as a function call | -| Average time for lock then unlock is NNNN tcs = NNNN nsec | -| | -| 5.2- When each lock and unlock is executed as inline function call | -| Average time for lock then unlock is NNN tcs = NNNN nsec | -|-----------------------------------------------------------------------------| -| E N D | -|-----------------------------------------------------------------------------| diff --git a/tests/legacy/benchmark/latency_measure/nanokernel/prj.conf b/tests/legacy/benchmark/latency_measure/nanokernel/prj.conf deleted file mode 100644 index c352c038dfe..00000000000 --- a/tests/legacy/benchmark/latency_measure/nanokernel/prj.conf +++ /dev/null @@ -1,5 +0,0 @@ -# needed for printf output sent to console -CONFIG_STDOUT_CONSOLE=y - -# We need this API to run functions in IRQ context -CONFIG_IRQ_OFFLOAD=y diff --git a/tests/legacy/benchmark/latency_measure/nanokernel/testcase.ini b/tests/legacy/benchmark/latency_measure/nanokernel/testcase.ini deleted file mode 100644 index 3609d30092d..00000000000 --- a/tests/legacy/benchmark/latency_measure/nanokernel/testcase.ini +++ /dev/null @@ -1,4 +0,0 @@ -[test] -tags = benchmark -arch_whitelist = x86 - diff --git a/tests/legacy/benchmark/latency_measure/microkernel/prj.conf b/tests/legacy/benchmark/latency_measure/prj.conf similarity index 100% rename from tests/legacy/benchmark/latency_measure/microkernel/prj.conf rename to tests/legacy/benchmark/latency_measure/prj.conf diff --git a/tests/legacy/benchmark/latency_measure/microkernel/prj.mdef b/tests/legacy/benchmark/latency_measure/prj.mdef similarity index 100% rename from tests/legacy/benchmark/latency_measure/microkernel/prj.mdef rename to tests/legacy/benchmark/latency_measure/prj.mdef diff --git a/tests/legacy/benchmark/latency_measure/microkernel/src/Makefile b/tests/legacy/benchmark/latency_measure/src/Makefile similarity index 100% rename from tests/legacy/benchmark/latency_measure/microkernel/src/Makefile rename to tests/legacy/benchmark/latency_measure/src/Makefile diff --git a/tests/legacy/benchmark/latency_measure/microkernel/src/main.c b/tests/legacy/benchmark/latency_measure/src/main.c similarity index 86% rename from tests/legacy/benchmark/latency_measure/microkernel/src/main.c rename to tests/legacy/benchmark/latency_measure/src/main.c index dc135bdb5d1..6979a2557a6 100644 --- a/tests/legacy/benchmark/latency_measure/microkernel/src/main.c +++ b/tests/legacy/benchmark/latency_measure/src/main.c @@ -28,7 +28,7 @@ #include uint32_t tm_off; /* time necessary to read the time */ -int errorCount = 0; /* track number of errors */ +int errorCount; /* track number of errors */ /** * @@ -57,25 +57,6 @@ void nanoTest(void) printDashLine(); } -#ifdef CONFIG_NANOKERNEL -/** - * - * @brief Nanokernel-only testing entry point - * - * @return N/A - */ -void main(void) -{ - bench_test_init(); - - nanoTest(); - - PRINT_END_BANNER(); - TC_END_REPORT(errorCount); -} - -#else - int microIntToTaskEvt(void); int microIntToTask(void); int microSemaLockUnlock(void); @@ -125,4 +106,3 @@ void microMain(void) PRINT_END_BANNER(); TC_END_REPORT(errorCount); } -#endif /* CONFIG_NANOKERNEL */ diff --git a/tests/legacy/benchmark/latency_measure/microkernel/src/micro_int_to_task.c b/tests/legacy/benchmark/latency_measure/src/micro_int_to_task.c similarity index 92% rename from tests/legacy/benchmark/latency_measure/microkernel/src/micro_int_to_task.c rename to tests/legacy/benchmark/latency_measure/src/micro_int_to_task.c index 6add84b0869..f4f1ae7f75e 100644 --- a/tests/legacy/benchmark/latency_measure/microkernel/src/micro_int_to_task.c +++ b/tests/legacy/benchmark/latency_measure/src/micro_int_to_task.c @@ -22,14 +22,13 @@ * handler back to the interrupted task in microkernel. */ -#ifdef CONFIG_MICROKERNEL #include "timestamp.h" #include "utils.h" #include #include -static volatile int flagVar = 0; +static volatile int flagVar; static uint32_t timestamp; @@ -78,14 +77,12 @@ static void makeInt(void) int microIntToTask(void) { PRINT_FORMAT(" 1- Measure time to switch from ISR back to" - " interrupted task"); + " interrupted task"); TICK_SYNCH(); makeInt(); if (flagVar == 1) { PRINT_FORMAT(" switching time is %lu tcs = %lu nsec", - timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp)); + timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp)); } return 0; } - -#endif /* MICROKERNEL */ diff --git a/tests/legacy/benchmark/latency_measure/microkernel/src/micro_int_to_task_evt.c b/tests/legacy/benchmark/latency_measure/src/micro_int_to_task_evt.c similarity index 87% rename from tests/legacy/benchmark/latency_measure/microkernel/src/micro_int_to_task_evt.c rename to tests/legacy/benchmark/latency_measure/src/micro_int_to_task_evt.c index ddfdb45418e..c346f5a1718 100644 --- a/tests/legacy/benchmark/latency_measure/microkernel/src/micro_int_to_task_evt.c +++ b/tests/legacy/benchmark/latency_measure/src/micro_int_to_task_evt.c @@ -24,7 +24,6 @@ * interrupted. */ -#ifdef CONFIG_MICROKERNEL #include #include @@ -33,7 +32,7 @@ #include -static uint32_t timestamp = 0; +static uint32_t timestamp; /** * @@ -56,8 +55,8 @@ static void latencyTestIsr(void *unused) * @brief Software interrupt generating task * * Lower priority task that, when starts, waits for a semaphore. When gets - * it, released by the main task, sets up the interrupt handler and generates the - * software interrupt + * it, released by the main task, sets up the interrupt handler and generates + * the software interrupt * * @return 0 on success */ @@ -76,15 +75,13 @@ void microInt(void) */ int microIntToTaskEvt(void) { - PRINT_FORMAT(" 2- Measure time from ISR to executing a different task" - " (rescheduled)"); + PRINT_FORMAT(" 2 - Measure time from ISR to executing a different task" + " (rescheduled)"); TICK_SYNCH(); task_sem_give(INTSEMA); task_event_recv(EVENT0, TICKS_UNLIMITED); timestamp = TIME_STAMP_DELTA_GET(timestamp); PRINT_FORMAT(" switch time is %lu tcs = %lu nsec", - timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp)); + timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp)); return 0; } - -#endif /* CONFIG_MICROKERNEL */ diff --git a/tests/legacy/benchmark/latency_measure/microkernel/src/micro_sema_lock_release.c b/tests/legacy/benchmark/latency_measure/src/micro_sema_lock_release.c similarity index 82% rename from tests/legacy/benchmark/latency_measure/microkernel/src/micro_sema_lock_release.c rename to tests/legacy/benchmark/latency_measure/src/micro_sema_lock_release.c index c8f84fbed16..361d3199ece 100644 --- a/tests/legacy/benchmark/latency_measure/microkernel/src/micro_sema_lock_release.c +++ b/tests/legacy/benchmark/latency_measure/src/micro_sema_lock_release.c @@ -23,7 +23,6 @@ * mutex being tested. */ -#ifdef CONFIG_MICROKERNEL #include #include "timestamp.h" @@ -53,7 +52,7 @@ int microSemaLockUnlock(void) int i; PRINT_FORMAT(" 3- Measure average time to signal a sema then test" - " that sema"); + " that sema"); bench_test_start(); timestamp = TIME_STAMP_DELTA_GET(0); for (i = 0; i < N_TEST_SEMA; i++) { @@ -61,9 +60,11 @@ int microSemaLockUnlock(void) } timestamp = TIME_STAMP_DELTA_GET(timestamp); if (bench_test_end() == 0) { - PRINT_FORMAT(" Average semaphore signal time %lu tcs = %lu nsec", - timestamp / N_TEST_SEMA, - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, N_TEST_SEMA)); + PRINT_FORMAT(" Average semaphore signal time %lu tcs = %lu" + " nsec", + timestamp / N_TEST_SEMA, + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, + N_TEST_SEMA)); } else { errorCount++; PRINT_OVERFLOW_ERROR(); @@ -76,9 +77,11 @@ int microSemaLockUnlock(void) } timestamp = TIME_STAMP_DELTA_GET(timestamp); if (bench_test_end() == 0) { - PRINT_FORMAT(" Average semaphore test time %lu tcs = %lu nsec", - timestamp / N_TEST_SEMA, - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, N_TEST_SEMA)); + PRINT_FORMAT(" Average semaphore test time %lu tcs = %lu " + "nsec", + timestamp / N_TEST_SEMA, + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, + N_TEST_SEMA)); } else { errorCount++; PRINT_OVERFLOW_ERROR(); @@ -100,24 +103,22 @@ int microMutexLockUnlock(void) int i; PRINT_FORMAT(" 4- Measure average time to lock a mutex then" - " unlock that mutex"); + " unlock that mutex"); timestamp = TIME_STAMP_DELTA_GET(0); for (i = 0; i < N_TEST_MUTEX; i++) { task_mutex_lock(TEST_MUTEX, TICKS_UNLIMITED); } timestamp = TIME_STAMP_DELTA_GET(timestamp); PRINT_FORMAT(" Average time to lock the mutex %lu tcs = %lu nsec", - timestamp / N_TEST_MUTEX, - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, N_TEST_MUTEX)); + timestamp / N_TEST_MUTEX, + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, N_TEST_MUTEX)); timestamp = TIME_STAMP_DELTA_GET(0); for (i = 0; i <= N_TEST_MUTEX; i++) { task_mutex_unlock(TEST_MUTEX); } timestamp = TIME_STAMP_DELTA_GET(timestamp); PRINT_FORMAT(" Average time to unlock the mutex %lu tcs = %lu nsec", - timestamp / N_TEST_MUTEX, - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, N_TEST_MUTEX)); + timestamp / N_TEST_MUTEX, + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, N_TEST_MUTEX)); return 0; } - -#endif /* CONFIG_MICROKERNEL */ diff --git a/tests/legacy/benchmark/latency_measure/microkernel/src/micro_task_switch_yield.c b/tests/legacy/benchmark/latency_measure/src/micro_task_switch_yield.c similarity index 86% rename from tests/legacy/benchmark/latency_measure/microkernel/src/micro_task_switch_yield.c rename to tests/legacy/benchmark/latency_measure/src/micro_task_switch_yield.c index 1cf776dcdc3..a1d55a41302 100644 --- a/tests/legacy/benchmark/latency_measure/microkernel/src/micro_task_switch_yield.c +++ b/tests/legacy/benchmark/latency_measure/src/micro_task_switch_yield.c @@ -23,7 +23,6 @@ * context switch. */ -#ifdef CONFIG_MICROKERNEL #include #include "timestamp.h" /* reading time */ #include "utils.h" /* PRINT () and other macros */ @@ -34,7 +33,7 @@ static int abs(int i) { return (i >= 0) ? i : -i; } /* context switch enough time so our measurement is precise */ #define NB_OF_YIELD 1000 -static uint32_t helper_task_iterations = 0; +static uint32_t helper_task_iterations; /** * @@ -64,8 +63,8 @@ void microTaskSwitchYield(void) int32_t delta; uint32_t timestamp; - PRINT_FORMAT(" 5- Measure average context switch time between tasks using" - " (task_yield)"); + PRINT_FORMAT(" 5- Measure average context switch time between tasks" + " using (task_yield)"); bench_test_start(); @@ -76,7 +75,8 @@ void microTaskSwitchYield(void) timestamp = TIME_STAMP_DELTA_GET(0); /* loop until either helper or this routine reaches number of yields */ - while (iterations < NB_OF_YIELD && helper_task_iterations < NB_OF_YIELD) { + while (iterations < NB_OF_YIELD && + helper_task_iterations < NB_OF_YIELD) { task_yield(); iterations++; } @@ -84,11 +84,12 @@ void microTaskSwitchYield(void) /* get the number of cycles it took to do the test */ timestamp = TIME_STAMP_DELTA_GET(timestamp); - /* Ensure both helper and this routine were context switching back & forth. + /* Ensure both helper and this routine were context switching back & + * forth. * For execution to reach the line below, either this routine or helper * routine reached NB_OF_YIELD. The other loop must be at most one - * iteration away from reaching NB_OF_YIELD if execute was switching back - * and forth. + * iteration away from reaching NB_OF_YIELD if execute was switching + * back and forth. */ delta = iterations - helper_task_iterations; if (bench_test_end() < 0) { @@ -100,17 +101,15 @@ void microTaskSwitchYield(void) */ errorCount++; PRINT_FORMAT(" Error, iteration:%lu, helper iteration:%lu", - iterations, helper_task_iterations); + iterations, helper_task_iterations); } else { /* task_yield is called (iterations + helper_task_iterations) * times in total. */ PRINT_FORMAT(" Average task context switch using " - "yield %lu tcs = %lu nsec", - timestamp / (iterations + helper_task_iterations), - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, - (iterations + helper_task_iterations))); + "yield %lu tcs = %lu nsec", + timestamp / (iterations + helper_task_iterations), + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, + (iterations + helper_task_iterations))); } } - -#endif diff --git a/tests/legacy/benchmark/latency_measure/microkernel/src/nano_ctx_switch.c b/tests/legacy/benchmark/latency_measure/src/nano_ctx_switch.c similarity index 88% rename from tests/legacy/benchmark/latency_measure/microkernel/src/nano_ctx_switch.c rename to tests/legacy/benchmark/latency_measure/src/nano_ctx_switch.c index 9696c63d31f..cda573e93f6 100644 --- a/tests/legacy/benchmark/latency_measure/microkernel/src/nano_ctx_switch.c +++ b/tests/legacy/benchmark/latency_measure/src/nano_ctx_switch.c @@ -44,13 +44,13 @@ static char __stack fiberTwoStack[STACKSIZE]; /* semaphore used for fibers synchronization */ static struct nano_sem syncSema; -static uint32_t timestamp = 0; +static uint32_t timestamp; /* context switches counter */ -static volatile uint32_t ctxSwitchCounter = 0; +static volatile uint32_t ctxSwitchCounter; /* context switch balancer. Incremented by one fiber, decremented by another*/ -static volatile int ctxSwitchBalancer = 0; +static volatile int ctxSwitchBalancer; /** * @@ -107,18 +107,20 @@ int nanoCtxSwitch(void) bench_test_start(); task_fiber_start(&fiberOneStack[0], STACKSIZE, - (nano_fiber_entry_t) fiberOne, 0, 0, 6, 0); + (nano_fiber_entry_t) fiberOne, 0, 0, 6, 0); task_fiber_start(&fiberTwoStack[0], STACKSIZE, - (nano_fiber_entry_t) fiberTwo, 0, 0, 6, 0); + (nano_fiber_entry_t) fiberTwo, 0, 0, 6, 0); if (ctxSwitchBalancer > 3 || ctxSwitchBalancer < -3) { PRINT_FORMAT(" Balance is %d. FAILED", ctxSwitchBalancer); } else if (bench_test_end() != 0) { errorCount++; PRINT_OVERFLOW_ERROR(); } else { - PRINT_FORMAT(" Average context switch time is %lu tcs = %lu nsec", - timestamp / ctxSwitchCounter, - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, ctxSwitchCounter)); + PRINT_FORMAT(" Average context switch time is %lu tcs = %lu" + " nsec", + timestamp / ctxSwitchCounter, + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, + ctxSwitchCounter)); } return 0; } diff --git a/tests/legacy/benchmark/latency_measure/microkernel/src/nano_int.c b/tests/legacy/benchmark/latency_measure/src/nano_int.c similarity index 94% rename from tests/legacy/benchmark/latency_measure/microkernel/src/nano_int.c rename to tests/legacy/benchmark/latency_measure/src/nano_int.c index 79700fc7b60..45892ab68cf 100644 --- a/tests/legacy/benchmark/latency_measure/microkernel/src/nano_int.c +++ b/tests/legacy/benchmark/latency_measure/src/nano_int.c @@ -78,8 +78,8 @@ int nanoIntLatency(void) PRINT_FORMAT(" 1- Measure time to switch from fiber to ISR execution"); TICK_SYNCH(); task_fiber_start(&fiberStack[0], STACKSIZE, - (nano_fiber_entry_t) fiberInt, 0, 0, 6, 0); + (nano_fiber_entry_t) fiberInt, 0, 0, 6, 0); PRINT_FORMAT(" switching time is %lu tcs = %lu nsec", - timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp)); + timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp)); return 0; } diff --git a/tests/legacy/benchmark/latency_measure/microkernel/src/nano_int_lock_unlock.c b/tests/legacy/benchmark/latency_measure/src/nano_int_lock_unlock.c similarity index 92% rename from tests/legacy/benchmark/latency_measure/microkernel/src/nano_int_lock_unlock.c rename to tests/legacy/benchmark/latency_measure/src/nano_int_lock_unlock.c index cf732085dc8..59c65a40899 100644 --- a/tests/legacy/benchmark/latency_measure/microkernel/src/nano_int_lock_unlock.c +++ b/tests/legacy/benchmark/latency_measure/src/nano_int_lock_unlock.c @@ -33,7 +33,7 @@ /* total number of interrupt lock/unlock cycles */ #define NTESTS 100000 -static uint32_t timestamp = 0; +static uint32_t timestamp; /** * @@ -56,8 +56,9 @@ int nanoIntLockUnlock(void) timestamp = TIME_STAMP_DELTA_GET(timestamp); if (bench_test_end() == 0) { PRINT_FORMAT(" Average time for lock then unlock " - "is %lu tcs = %lu nsec", - timestamp / NTESTS, SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, NTESTS)); + "is %lu tcs = %lu nsec", + timestamp / NTESTS, + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, NTESTS)); } else { errorCount++; PRINT_OVERFLOW_ERROR(); diff --git a/tests/legacy/benchmark/latency_measure/microkernel/src/nano_int_to_fiber.c b/tests/legacy/benchmark/latency_measure/src/nano_int_to_fiber.c similarity index 93% rename from tests/legacy/benchmark/latency_measure/microkernel/src/nano_int_to_fiber.c rename to tests/legacy/benchmark/latency_measure/src/nano_int_to_fiber.c index c4517c4284a..0ea118d817f 100644 --- a/tests/legacy/benchmark/latency_measure/microkernel/src/nano_int_to_fiber.c +++ b/tests/legacy/benchmark/latency_measure/src/nano_int_to_fiber.c @@ -35,7 +35,7 @@ /* stack used by the fiber that generates the interrupt */ static char __stack fiberStack[STACKSIZE]; -static volatile int flagVar = 0; +static volatile int flagVar; static uint32_t timestamp; @@ -84,13 +84,13 @@ static void fiberInt(void) int nanoIntToFiber(void) { PRINT_FORMAT(" 2- Measure time to switch from ISR back to interrupted" - " fiber"); + " fiber"); TICK_SYNCH(); task_fiber_start(&fiberStack[0], STACKSIZE, - (nano_fiber_entry_t) fiberInt, 0, 0, 6, 0); + (nano_fiber_entry_t) fiberInt, 0, 0, 6, 0); if (flagVar == 1) { PRINT_FORMAT(" switching time is %lu tcs = %lu nsec", - timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp)); + timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp)); } return 0; } diff --git a/tests/legacy/benchmark/latency_measure/microkernel/src/nano_int_to_fiber_sem.c b/tests/legacy/benchmark/latency_measure/src/nano_int_to_fiber_sem.c similarity index 91% rename from tests/legacy/benchmark/latency_measure/microkernel/src/nano_int_to_fiber_sem.c rename to tests/legacy/benchmark/latency_measure/src/nano_int_to_fiber_sem.c index cba82c1fb04..bd271834e6a 100644 --- a/tests/legacy/benchmark/latency_measure/microkernel/src/nano_int_to_fiber_sem.c +++ b/tests/legacy/benchmark/latency_measure/src/nano_int_to_fiber_sem.c @@ -27,7 +27,7 @@ * interrupt handler releases the semaphore which enabled the high priority * fiberWaiter to run and exit. The high priority fiber acquire the sema and * read the time. The time delta is measured from the time - * semaphore is released in interrup handler to the time fiberWaiter + * semaphore is released in interrupt handler to the time fiberWaiter * starts to executing. */ @@ -48,7 +48,7 @@ static char __stack intStack[STACKSIZE]; /* semaphore taken by waiting fiber ad released by the interrupt handler */ static struct nano_sem testSema; -static uint32_t timestamp = 0; +static uint32_t timestamp; /** * @@ -105,16 +105,16 @@ static void fiberWaiter(void) int nanoIntToFiberSem(void) { PRINT_FORMAT(" 3- Measure time from ISR to executing a different fiber" - " (rescheduled)"); + " (rescheduled)"); nano_sem_init(&testSema); TICK_SYNCH(); task_fiber_start(&waiterStack[0], STACKSIZE, - (nano_fiber_entry_t) fiberWaiter, 0, 0, 5, 0); + (nano_fiber_entry_t) fiberWaiter, 0, 0, 5, 0); task_fiber_start(&intStack[0], STACKSIZE, - (nano_fiber_entry_t) fiberInt, 0, 0, 6, 0); + (nano_fiber_entry_t) fiberInt, 0, 0, 6, 0); PRINT_FORMAT(" switching time is %lu tcs = %lu nsec", - timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp)); + timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp)); return 0; } diff --git a/tests/legacy/benchmark/latency_measure/microkernel/src/test_asm_inline_gcc.h b/tests/legacy/benchmark/latency_measure/src/test_asm_inline_gcc.h similarity index 100% rename from tests/legacy/benchmark/latency_measure/microkernel/src/test_asm_inline_gcc.h rename to tests/legacy/benchmark/latency_measure/src/test_asm_inline_gcc.h diff --git a/tests/legacy/benchmark/latency_measure/microkernel/src/timestamp.h b/tests/legacy/benchmark/latency_measure/src/timestamp.h similarity index 83% rename from tests/legacy/benchmark/latency_measure/microkernel/src/timestamp.h rename to tests/legacy/benchmark/latency_measure/src/timestamp.h index 8b1405e68f7..c2567c3b1e5 100644 --- a/tests/legacy/benchmark/latency_measure/microkernel/src/timestamp.h +++ b/tests/legacy/benchmark/latency_measure/src/timestamp.h @@ -33,30 +33,10 @@ #include #endif -#if defined(CONFIG_NANOKERNEL) -/* number of ticks before timer overflows */ -#define BENCH_MAX_TICKS (sys_clock_ticks_per_sec - 1) - -typedef int64_t TICK_TYPE; - -static inline void TICK_SYNCH(void) -{ - TICK_TYPE reftime; - - (void) sys_tick_delta(&reftime); - while (sys_tick_delta(&reftime) == 0) { - } -} - -#elif defined(CONFIG_MICROKERNEL) typedef int64_t TICK_TYPE; #define TICK_SYNCH() task_sleep(1) -#else -#error either CONFIG_NANOKERNEL or CONFIG_MICROKERNEL must be defined -#endif /* CONFIG_NANOKERNEL */ - #define TICK_GET(x) ((TICK_TYPE) sys_tick_delta(x)) #define OS_GET_TIME() sys_cycle_get_32() @@ -71,7 +51,8 @@ static inline uint32_t TIME_STAMP_DELTA_GET(uint32_t ts) timestamp_serialize(); t = OS_GET_TIME(); - uint32_t res = (t >= ts)? (t - ts): (ULONG_MAX - ts + t); + uint32_t res = (t >= ts) ? (t - ts) : (ULONG_MAX - ts + t); + if (ts > 0) { res -= tm_off; } @@ -89,13 +70,9 @@ static inline void bench_test_init(void) tm_off = OS_GET_TIME() - t; } -#if defined(CONFIG_MICROKERNEL) - /* number of ticks before timer overflows */ #define BENCH_MAX_TICKS (sys_clock_ticks_per_sec - 1) -#endif /* CONFIG_MICROKERNEL */ - /* tickstamp used for timer counter overflow check */ static TICK_TYPE tCheck; diff --git a/tests/legacy/benchmark/latency_measure/microkernel/src/utils.c b/tests/legacy/benchmark/latency_measure/src/utils.c similarity index 100% rename from tests/legacy/benchmark/latency_measure/microkernel/src/utils.c rename to tests/legacy/benchmark/latency_measure/src/utils.c diff --git a/tests/legacy/benchmark/latency_measure/microkernel/src/utils.h b/tests/legacy/benchmark/latency_measure/src/utils.h similarity index 61% rename from tests/legacy/benchmark/latency_measure/microkernel/src/utils.h rename to tests/legacy/benchmark/latency_measure/src/utils.h index 337e3cb0a43..db6038934ce 100644 --- a/tests/legacy/benchmark/latency_measure/microkernel/src/utils.h +++ b/tests/legacy/benchmark/latency_measure/src/utils.h @@ -37,10 +37,10 @@ extern int errorCount; #define PRINT(fmt, ...) printk(fmt, ##__VA_ARGS__) #define PRINTF(fmt, ...) printf(fmt, ##__VA_ARGS__) -#define PRINT_FORMAT(fmt, ...) \ +#define PRINT_FORMAT(fmt, ...) \ do { \ - snprintf(tmpString, TMP_STRING_SIZE, fmt, ##__VA_ARGS__); \ - PRINTF("|%-77s|\n", tmpString); \ + snprintf(tmpString, TMP_STRING_SIZE, fmt, ##__VA_ARGS__); \ + PRINTF("|%-77s|\n", tmpString); \ } while (0) /** @@ -51,33 +51,42 @@ extern int errorCount; */ static inline void printDashLine(void) { - PRINTF("|-----------------------------------------------------------------" - "------------|\n"); + PRINTF("|-------------------------------------------------------" + "----------------------|\n"); } -#define PRINT_END_BANNER() \ - PRINTF("| E N D "\ - " |\n"); \ - printDashLine(); +#define PRINT_END_BANNER() \ + do { \ + PRINTF("| E N D " \ + " |\n"); \ + printDashLine(); \ + } while (0) -#define PRINT_NANO_BANNER() \ - printDashLine(); \ - PRINTF("| Nanokernel Latency Benchmark "\ - " |\n"); \ - printDashLine(); +#define PRINT_NANO_BANNER() \ + do { \ + printDashLine(); \ + PRINTF("| Nanokernel Latency Benchmark " \ + " |\n"); \ + printDashLine(); \ + } while (0) -#define PRINT_MICRO_BANNER() \ - printDashLine(); \ - PRINTF("| Microkernel Latency Benchmark "\ - " |\n"); \ - printDashLine(); +#define PRINT_MICRO_BANNER() \ + do { \ + printDashLine(); \ + PRINTF("| Microkernel Latency Benchmark " \ + " |\n"); \ + printDashLine(); \ + } while (0) -#define PRINT_TIME_BANNER() \ - PRINT_FORMAT(" tcs = timer clock cycles: 1 tcs is %lu nsec", \ - SYS_CLOCK_HW_CYCLES_TO_NS(1)); \ - printDashLine(); -#define PRINT_OVERFLOW_ERROR() \ +#define PRINT_TIME_BANNER() \ + do { \ + PRINT_FORMAT(" tcs = timer clock cycles: 1 tcs is %lu nsec", \ + SYS_CLOCK_HW_CYCLES_TO_NS(1)); \ + printDashLine(); \ + } while (0) + +#define PRINT_OVERFLOW_ERROR() \ PRINT_FORMAT(" Error: tick occurred") #else diff --git a/tests/legacy/benchmark/latency_measure/microkernel/testcase.ini b/tests/legacy/benchmark/latency_measure/testcase.ini similarity index 57% rename from tests/legacy/benchmark/latency_measure/microkernel/testcase.ini rename to tests/legacy/benchmark/latency_measure/testcase.ini index cfe01903c21..594a0a607a4 100644 --- a/tests/legacy/benchmark/latency_measure/microkernel/testcase.ini +++ b/tests/legacy/benchmark/latency_measure/testcase.ini @@ -1,5 +1,5 @@ [test] -tags = benchmark +tags = benchmark unified_capable arch_whitelist = x86 kernel = micro diff --git a/tests/legacy/benchmark/sys_kernel/src/Makefile b/tests/legacy/benchmark/sys_kernel/src/Makefile index b90ef563942..a781610741a 100644 --- a/tests/legacy/benchmark/sys_kernel/src/Makefile +++ b/tests/legacy/benchmark/sys_kernel/src/Makefile @@ -1,4 +1,4 @@ -ccflags-y = -I$(ZEPHYR_BASE)/tests/legacy/benchmark/latency_measure/microkernel/src -I${ZEPHYR_BASE}/tests/include +ccflags-y = -I$(ZEPHYR_BASE)/tests/legacy/benchmark/latency_measure/src -I${ZEPHYR_BASE}/tests/include ccflags-y += -I$(CURDIR)/misc/generated/sysgen obj-y = lifo.o \