tests: benchmarks: move app_kernel to unified kernel.

Deleted the instance of app_kernel in tests/legacy/benchmark.

JIRA: ZEP-1980
Change-Id: I5a6e073d9b0c870be0cc7d8ae5bb352b11d7f97e
Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
This commit is contained in:
Adithya Baglody 2017-04-10 22:14:53 +05:30 committed by Anas Nashif
commit abfbcc9318
27 changed files with 348 additions and 394 deletions

View file

@ -1,5 +1,4 @@
BOARD ?= qemu_x86 BOARD ?= qemu_x86
MDEF_FILE = prj.mdef
# Boards where we want to exercise this test case with floating point # Boards where we want to exercise this test case with floating point
# and SSE instructions # and SSE instructions

View file

@ -9,4 +9,4 @@ CONFIG_NUM_COMMAND_PACKETS=20
# eliminate timer interrupts during the benchmark # eliminate timer interrupts during the benchmark
CONFIG_SYS_CLOCK_TICKS_PER_SEC=1 CONFIG_SYS_CLOCK_TICKS_PER_SEC=1
CONFIG_LEGACY_KERNEL=y CONFIG_LEGACY_KERNEL=n

View file

@ -4,4 +4,4 @@ CONFIG_NUM_COMMAND_PACKETS=20
# eliminate timer interrupts during the benchmark # eliminate timer interrupts during the benchmark
CONFIG_SYS_CLOCK_TICKS_PER_SEC=1 CONFIG_SYS_CLOCK_TICKS_PER_SEC=1
CONFIG_LEGACY_KERNEL=y CONFIG_LEGACY_KERNEL=n

View file

@ -1,6 +1,5 @@
ccflags-y += -I$(CURDIR)/misc/generated/sysgen ccflags-y += -I$(CURDIR)/misc/generated/sysgen
ccflags-y += -I$(ZEPHYR_BASE)/tests/legacy/benchmark/latency_measure/src \ ccflags-y += -I${ZEPHYR_BASE}/tests/include
-I${ZEPHYR_BASE}/tests/include
obj-y := fifo_b.o mailbox_b.o master.o mempool_b.o \ obj-y := fifo_b.o mailbox_b.o master.o mempool_b.o \
pipe_r.o sema_r.o event_b.o \ pipe_r.o sema_r.o event_b.o \

View file

@ -12,9 +12,9 @@
/* #define EVENT_CHECK */ /* #define EVENT_CHECK */
#ifdef EVENT_CHECK #ifdef EVENT_CHECK
static char EventSignalErr[] = "------------ Error signalling event.\n"; static const char EventSignalErr[] = "------------ Error signalling event.\n";
static char EventTestErr[] = "------------ Error testing event.\n"; static const char EventTestErr[] = "------------ Error testing event.\n";
static char EventHandlerErr[] = "------------ Error in event handler.\n"; static const char EventHandlerErr[] = "------------ Error in event handler.\n";
#endif #endif
/* global Event value */ /* global Event value */
@ -23,7 +23,7 @@ volatile int nEventValue;
/* /*
* Function prototypes. * Function prototypes.
*/ */
int example_handler (int event); int example_handler (struct k_alert *alert);
/* /*
* Function declarations. * Function declarations.
@ -37,16 +37,16 @@ int example_handler (int event);
*/ */
void event_test(void) void event_test(void)
{ {
int nReturn; int nReturn = 0;
int nCounter; int nCounter;
uint32_t et; /* elapsed time */ uint32_t et; /* elapsed time */
PRINT_STRING(dashline, output_file); PRINT_STRING(dashline, output_file);
et = BENCH_START(); et = BENCH_START();
for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) { for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) {
nReturn = task_event_send(TEST_EVENT); k_alert_send(&TEST_EVENT);
#ifdef EVENT_CHECK #ifdef EVENT_CHECK
if (nReturn != RC_OK) { if (nReturn != 0) {
PRINT_STRING(EventSignalErr, output_file); PRINT_STRING(EventSignalErr, output_file);
return; /* error */ return; /* error */
} }
@ -60,19 +60,19 @@ void event_test(void)
et = BENCH_START(); et = BENCH_START();
for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) { for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) {
nReturn = task_event_send(TEST_EVENT); k_alert_send(&TEST_EVENT);
#ifdef EVENT_CHECK #ifdef EVENT_CHECK
if (nReturn != RC_OK) { if (nReturn != 0) {
PRINT_STRING(EventSignalErr, output_file); PRINT_STRING(EventSignalErr, output_file);
task_sleep(SLEEP_TIME); k_sleep(1);
return; /* error */ return; /* error */
} }
#endif /* EVENT_CHECK */ #endif /* EVENT_CHECK */
nReturn = task_event_recv(TEST_EVENT, TICKS_NONE); k_alert_recv(&TEST_EVENT, K_NO_WAIT);
#ifdef EVENT_CHECK #ifdef EVENT_CHECK
if (nReturn != RC_OK) { if (nReturn != 0) {
PRINT_STRING(EventTestErr, output_file); PRINT_STRING(EventTestErr, output_file);
task_sleep(SLEEP_TIME); k_sleep(1);
return; /* error */ return; /* error */
} }
#endif /* EVENT_CHECK */ #endif /* EVENT_CHECK */
@ -85,16 +85,16 @@ void event_test(void)
et = BENCH_START(); et = BENCH_START();
for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) { for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) {
nReturn = task_event_send(TEST_EVENT); k_alert_send(&TEST_EVENT);
#ifdef EVENT_CHECK #ifdef EVENT_CHECK
if (nReturn != RC_OK) { if (nReturn != 0) {
PRINT_STRING(EventSignalErr, output_file); PRINT_STRING(EventSignalErr, output_file);
return; /* error */ return; /* error */
} }
#endif /* EVENT_CHECK */ #endif /* EVENT_CHECK */
nReturn = task_event_recv(TEST_EVENT, TICKS_UNLIMITED); k_alert_recv(&TEST_EVENT, K_FOREVER);
#ifdef EVENT_CHECK #ifdef EVENT_CHECK
if (nReturn != RC_OK) { if (nReturn != 0) {
PRINT_STRING(EventTestErr, output_file); PRINT_STRING(EventTestErr, output_file);
return; /* error */ return; /* error */
} }
@ -107,40 +107,41 @@ void event_test(void)
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_EVENT_RUNS)); SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_EVENT_RUNS));
PRINT_STRING("| Signal event with installed handler" PRINT_STRING("| Signal event with installed handler"
" |\n", output_file); " |\n", output_file);
nReturn = task_event_handler_set (TEST_EVENT, example_handler); TEST_EVENT.handler = example_handler;
if (nReturn != RC_OK) { if (nReturn != 0) {
PRINT_F(output_file, "-------- Error installing event handler.\n"); PRINT_F(output_file,
task_sleep(SLEEP_TIME); "-------- Error installing event handler.\n");
k_sleep(1);
return; /* error */ return; /* error */
} }
for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) { for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) {
nReturn = task_event_send(TEST_EVENT); k_alert_send(&TEST_EVENT);
#ifdef EVENT_CHECK #ifdef EVENT_CHECK
if (nReturn != RC_OK) { if (nReturn != 0) {
PRINT_STRING(EventSignalErr, output_file); PRINT_STRING(EventSignalErr, output_file);
task_sleep(SLEEP_TIME); k_sleep(1);
return; /* error */ return; /* error */
} }
if (nEventValue != TEST_EVENT + 1) { if (nEventValue != TEST_EVENT.send_count + 1) {
PRINT_STRING(EventHandlerErr, output_file); PRINT_STRING(EventHandlerErr, output_file);
task_sleep(SLEEP_TIME); k_sleep(1);
return; /* error */ return; /* error */
} }
#endif /* EVENT_CHECK */ #endif /* EVENT_CHECK */
nEventValue = 0; nEventValue = 0;
} }
nReturn = task_event_handler_set (TEST_EVENT, NULL); TEST_EVENT.handler = NULL;
if (nReturn != RC_OK) { if (nReturn != 0) {
PRINT_F(output_file, "Error removing event handler.\n"); PRINT_F(output_file, "Error removing event handler.\n");
task_sleep(SLEEP_TIME); k_sleep(1);
return; /* error */ return; /* error */
} }
PRINT_STRING("| Handler responds OK" PRINT_STRING("| Handler responds OK"
" |\n", " |\n",
output_file); output_file);
return; /* success */ return; /* success */
@ -156,9 +157,10 @@ void event_test(void)
* *
* @return 1 * @return 1
*/ */
int example_handler (int event) int example_handler (struct k_alert *alert)
{ {
nEventValue = event + 1; ARG_UNUSED(alert);
nEventValue = alert->send_count + 1;
return 1; return 1;
} }

View file

@ -24,7 +24,7 @@ void queue_test(void)
PRINT_STRING(dashline, output_file); PRINT_STRING(dashline, output_file);
et = BENCH_START(); et = BENCH_START();
for (i = 0; i < NR_OF_FIFO_RUNS; i++) { for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
task_fifo_put(DEMOQX1, data_bench, TICKS_UNLIMITED); k_msgq_put(&DEMOQX1, data_bench, K_FOREVER);
} }
et = TIME_STAMP_DELTA_GET(et); et = TIME_STAMP_DELTA_GET(et);
@ -33,7 +33,7 @@ void queue_test(void)
et = BENCH_START(); et = BENCH_START();
for (i = 0; i < NR_OF_FIFO_RUNS; i++) { for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
task_fifo_get(DEMOQX1, data_bench, TICKS_UNLIMITED); k_msgq_get(&DEMOQX1, data_bench, K_FOREVER);
} }
et = TIME_STAMP_DELTA_GET(et); et = TIME_STAMP_DELTA_GET(et);
check_result(); check_result();
@ -43,7 +43,7 @@ void queue_test(void)
et = BENCH_START(); et = BENCH_START();
for (i = 0; i < NR_OF_FIFO_RUNS; i++) { for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
task_fifo_put(DEMOQX4, data_bench, TICKS_UNLIMITED); k_msgq_put(&DEMOQX4, data_bench, K_FOREVER);
} }
et = TIME_STAMP_DELTA_GET(et); et = TIME_STAMP_DELTA_GET(et);
check_result(); check_result();
@ -53,7 +53,7 @@ void queue_test(void)
et = BENCH_START(); et = BENCH_START();
for (i = 0; i < NR_OF_FIFO_RUNS; i++) { for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
task_fifo_get(DEMOQX4, data_bench, TICKS_UNLIMITED); k_msgq_get(&DEMOQX4, data_bench, K_FOREVER);
} }
et = TIME_STAMP_DELTA_GET(et); et = TIME_STAMP_DELTA_GET(et);
check_result(); check_result();
@ -61,11 +61,11 @@ void queue_test(void)
PRINT_F(output_file, FORMAT, "dequeue 4 bytes msg in FIFO", PRINT_F(output_file, FORMAT, "dequeue 4 bytes msg in FIFO",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS)); SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS));
task_sem_give(STARTRCV); k_sem_give(&STARTRCV);
et = BENCH_START(); et = BENCH_START();
for (i = 0; i < NR_OF_FIFO_RUNS; i++) { for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
task_fifo_put(DEMOQX1, data_bench, TICKS_UNLIMITED); k_msgq_put(&DEMOQX1, data_bench, K_FOREVER);
} }
et = TIME_STAMP_DELTA_GET(et); et = TIME_STAMP_DELTA_GET(et);
check_result(); check_result();
@ -76,7 +76,7 @@ void queue_test(void)
et = BENCH_START(); et = BENCH_START();
for (i = 0; i < NR_OF_FIFO_RUNS; i++) { for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
task_fifo_put(DEMOQX4, data_bench, TICKS_UNLIMITED); k_msgq_put(&DEMOQX4, data_bench, K_FOREVER);
} }
et = TIME_STAMP_DELTA_GET(et); et = TIME_STAMP_DELTA_GET(et);
check_result(); check_result();

View file

@ -23,12 +23,13 @@ void dequtask(void)
int x, i; int x, i;
for (i = 0; i < NR_OF_FIFO_RUNS; i++) { for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
task_fifo_get(DEMOQX1, &x, TICKS_UNLIMITED); k_msgq_get(&DEMOQX1, &x, K_FOREVER);
} }
for (i = 0; i < NR_OF_FIFO_RUNS; i++) { for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
task_fifo_get(DEMOQX4, &x, TICKS_UNLIMITED); k_msgq_get(&DEMOQX4, &x, K_FOREVER);
} }
} }
#endif /* FIFO_BENCH */ #endif /* FIFO_BENCH */

View file

@ -10,13 +10,13 @@
#ifdef MAILBOX_BENCH #ifdef MAILBOX_BENCH
static struct k_msg Message; static struct k_mbox_msg Message;
#ifdef FLOAT #ifdef FLOAT
#define PRINT_HEADER() \ #define PRINT_HEADER() \
PRINT_STRING \ PRINT_STRING \
("| size(B) | time/packet (usec) | MB/sec" \ ("| size(B) | time/packet (usec) | MB/sec" \
" |\n", output_file); " |\n", output_file)
#define PRINT_ONE_RESULT() \ #define PRINT_ONE_RESULT() \
PRINT_F(output_file, "|%11u|%32.3f|%32f|\n", putsize, puttime / 1000.0,\ PRINT_F(output_file, "|%11u|%32.3f|%32f|\n", putsize, puttime / 1000.0,\
(1000.0 * putsize) / puttime) (1000.0 * putsize) / puttime)
@ -27,15 +27,16 @@ static struct k_msg Message;
" |\n", EmptyMsgPutTime / 1000.0) " |\n", EmptyMsgPutTime / 1000.0)
#define PRINT_XFER_RATE() \ #define PRINT_XFER_RATE() \
double NettoTransferRate; \ double NettoTransferRate; \
NettoTransferRate = 1000.0 * (putsize >> 1) / (puttime - EmptyMsgPutTime);\ NettoTransferRate = 1000.0 * \
(putsize >> 1) / (puttime - EmptyMsgPutTime); \
PRINT_F(output_file, \ PRINT_F(output_file, \
"| raw transfer rate: %10.3f MB/sec (without" \ "| raw transfer rate: %10.3f MB/sec (without" \
" overhead) |\n", NettoTransferRate) " overhead) |\n", NettoTransferRate)
#else #else
#define PRINT_HEADER() \ #define PRINT_HEADER() \
PRINT_STRING \ PRINT_STRING \
("| size(B) | time/packet (nsec) | KB/sec" \ ("| size(B) | time/packet (nsec) | KB/sec" \
" |\n", output_file); " |\n", output_file);
@ -86,28 +87,28 @@ void mailbox_test(void)
" |\n", output_file); " |\n", output_file);
PRINT_STRING(dashline, output_file); PRINT_STRING(dashline, output_file);
PRINT_STRING("| Send mailbox message to waiting high " PRINT_STRING("| Send mailbox message to waiting high "
"priority task and wait |\n", output_file); "priority task and wait |\n", output_file);
PRINT_F(output_file, "| repeat for %4d times and take the " PRINT_F(output_file, "| repeat for %4d times and take the "
"average |\n", "average |\n",
NR_OF_MBOX_RUNS); NR_OF_MBOX_RUNS);
PRINT_STRING(dashline, output_file); PRINT_STRING(dashline, output_file);
PRINT_HEADER(); PRINT_HEADER();
PRINT_STRING(dashline, output_file); PRINT_STRING(dashline, output_file);
task_sem_reset(SEM0); k_sem_reset(&SEM0);
task_sem_give(STARTRCV); k_sem_give(&STARTRCV);
putcount = NR_OF_MBOX_RUNS; putcount = NR_OF_MBOX_RUNS;
putsize = 0; putsize = 0;
mailbox_put(putsize, putcount, &puttime); mailbox_put(putsize, putcount, &puttime);
/* waiting for ack */ /* waiting for ack */
task_fifo_get(MB_COMM, &getinfo, TICKS_UNLIMITED); k_msgq_get(&MB_COMM, &getinfo, K_FOREVER);
PRINT_ONE_RESULT(); PRINT_ONE_RESULT();
EmptyMsgPutTime = puttime; EmptyMsgPutTime = puttime;
for (putsize = 8; putsize <= MESSAGE_SIZE; putsize <<= 1) { for (putsize = 8; putsize <= MESSAGE_SIZE; putsize <<= 1) {
mailbox_put(putsize, putcount, &puttime); mailbox_put(putsize, putcount, &puttime);
/* waiting for ack */ /* waiting for ack */
task_fifo_get(MB_COMM, &getinfo, TICKS_UNLIMITED); k_msgq_get(&MB_COMM, &getinfo, K_FOREVER);
PRINT_ONE_RESULT(); PRINT_ONE_RESULT();
} }
PRINT_STRING(dashline, output_file); PRINT_STRING(dashline, output_file);
@ -131,15 +132,14 @@ void mailbox_put(uint32_t size, int count, uint32_t *time)
int i; int i;
unsigned int t; unsigned int t;
Message.rx_task = ANYTASK; Message.rx_source_thread = K_ANY;
Message.tx_data = data_bench; Message.tx_target_thread = K_ANY;
Message.size = size;
/* first sync with the receiver */ /* first sync with the receiver */
task_sem_give(SEM0); k_sem_give(&SEM0);
t = BENCH_START(); t = BENCH_START();
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
task_mbox_put(MAILB1, 1, &Message, TICKS_UNLIMITED); k_mbox_put(&MAILB1, &Message, K_FOREVER);
} }
t = TIME_STAMP_DELTA_GET(t); t = TIME_STAMP_DELTA_GET(t);
*time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, count); *time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, count);

View file

@ -14,7 +14,10 @@
/* /*
* Function prototypes. * Function prototypes.
*/ */
int mailbox_get(kmbox_t mailbox,int size,int count,unsigned int* time); int mailbox_get(struct k_mbox *mailbox,
int size,
int count,
unsigned int *time);
/* /*
* Function declarations. * Function declarations.
@ -38,20 +41,20 @@ void mailrecvtask(void)
getcount = NR_OF_MBOX_RUNS; getcount = NR_OF_MBOX_RUNS;
getsize = 0; getsize = 0;
mailbox_get(MAILB1, getsize, getcount, &gettime); mailbox_get(&MAILB1, getsize, getcount, &gettime);
getinfo.time = gettime; getinfo.time = gettime;
getinfo.size = getsize; getinfo.size = getsize;
getinfo.count = getcount; getinfo.count = getcount;
/* acknowledge to master */ /* acknowledge to master */
task_fifo_put(MB_COMM, &getinfo, TICKS_UNLIMITED); k_msgq_put(&MB_COMM, &getinfo, K_FOREVER);
for (getsize = 8; getsize <= MESSAGE_SIZE; getsize <<= 1) { for (getsize = 8; getsize <= MESSAGE_SIZE; getsize <<= 1) {
mailbox_get(MAILB1, getsize, getcount, &gettime); mailbox_get(&MAILB1, getsize, getcount, &gettime);
getinfo.time = gettime; getinfo.time = gettime;
getinfo.size = getsize; getinfo.size = getsize;
getinfo.count = getcount; getinfo.count = getcount;
/* acknowledge to master */ /* acknowledge to master */
task_fifo_put(MB_COMM, &getinfo, TICKS_UNLIMITED); k_msgq_put(&MB_COMM, &getinfo, K_FOREVER);
} }
} }
@ -67,21 +70,20 @@ void mailrecvtask(void)
* @param count Number of data portions. * @param count Number of data portions.
* @param time Resulting time. * @param time Resulting time.
*/ */
int mailbox_get(kmbox_t mailbox, int size, int count, unsigned int* time) int mailbox_get(struct k_mbox *mailbox, int size, int count, unsigned int *time)
{ {
int i; int i;
unsigned int t; unsigned int t;
struct k_msg Message; struct k_mbox_msg Message;
Message.tx_task = ANYTASK; Message.rx_source_thread = K_ANY;
Message.rx_data = data_recv;
Message.size = size; Message.size = size;
/* sync with the sender */ /* sync with the sender */
task_sem_take(SEM0, TICKS_UNLIMITED); k_sem_take(&SEM0, K_FOREVER);
t = BENCH_START(); t = BENCH_START();
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
task_mbox_get(mailbox, &Message, TICKS_UNLIMITED); k_mbox_get(mailbox, &Message, &data_recv, K_FOREVER);
} }
t = TIME_STAMP_DELTA_GET(t); t = TIME_STAMP_DELTA_GET(t);

View file

@ -7,12 +7,12 @@
*/ */
/* /*
File Naming information. *File Naming information.
------------------------ * ------------------------
Files that end with: * Files that end with:
_B : Is a file that contains a benchmark function * _B : Is a file that contains a benchmark function
_R : Is a file that contains the receiver task * _R : Is a file that contains the receiver task
of a benchmark function * of a benchmark function
*/ */
#include <tc_util.h> #include <tc_util.h>
#include "master.h" #include "master.h"
@ -21,12 +21,12 @@ char Msg[MAX_MSG];
char data_bench[OCTET_TO_SIZEOFUNIT(MESSAGE_SIZE)]; char data_bench[OCTET_TO_SIZEOFUNIT(MESSAGE_SIZE)];
#ifdef PIPE_BENCH #ifdef PIPE_BENCH
kpipe_t TestPipes[] = {PIPE_NOBUFF, PIPE_SMALLBUFF, PIPE_BIGBUFF}; struct k_pipe *TestPipes[] = {&PIPE_NOBUFF, &PIPE_SMALLBUFF, &PIPE_BIGBUFF};
#endif #endif
char sline[SLINE_LEN + 1]; char sline[SLINE_LEN + 1];
const char newline[] = "\n"; const char newline[] = "\n";
FILE * output_file; FILE *output_file;
/* /*
* Time in timer cycles necessary to read time. * Time in timer cycles necessary to read time.
@ -34,6 +34,39 @@ FILE * output_file;
*/ */
uint32_t tm_off; uint32_t tm_off;
/********************************************************************/
/* static allocation */
K_THREAD_DEFINE(RECVTASK, 1024, recvtask, NULL, NULL, NULL, 5, 0, K_NO_WAIT);
K_THREAD_DEFINE(BENCHTASK, 1024, BenchTask, NULL, NULL, NULL, 6, 0, K_NO_WAIT);
K_MSGQ_DEFINE(DEMOQX1, 1, 500, 4);
K_MSGQ_DEFINE(DEMOQX4, 4, 500, 4);
K_MSGQ_DEFINE(MB_COMM, 12, 1, 4);
K_MSGQ_DEFINE(CH_COMM, 12, 1, 4);
K_MEM_SLAB_DEFINE(MAP1, 16, 2, 4);
K_SEM_DEFINE(SEM0, 0, 1);
K_SEM_DEFINE(SEM1, 0, 1);
K_SEM_DEFINE(SEM2, 0, 1);
K_SEM_DEFINE(SEM3, 0, 1);
K_SEM_DEFINE(SEM4, 0, 1);
K_SEM_DEFINE(STARTRCV, 0, 1);
K_MBOX_DEFINE(MAILB1);
K_MUTEX_DEFINE(DEMO_MUTEX);
K_PIPE_DEFINE(PIPE_NOBUFF, 0, 4);
K_PIPE_DEFINE(PIPE_SMALLBUFF, 256, 4);
K_PIPE_DEFINE(PIPE_BIGBUFF, 4096, 4);
K_MEM_POOL_DEFINE(DEMOPOOL, 16, 16, 1, 4);
K_ALERT_DEFINE(TEST_EVENT, NULL, 1);
/** /**
* *
* @brief Check for keypress * @brief Check for keypress
@ -87,7 +120,7 @@ void output_close(void)
* *
* @return N/A * @return N/A
*/ */
void BenchTask(void) void BenchTask(void *p1, void *p2, void *p3)
{ {
int autorun = 0, continuously = 0; int autorun = 0, continuously = 0;
@ -101,7 +134,6 @@ void BenchTask(void)
"M E A S U R E M E N T S | nsec |\n", "M E A S U R E M E N T S | nsec |\n",
output_file); output_file);
PRINT_STRING(dashline, output_file); PRINT_STRING(dashline, output_file);
task_start(RECVTASK);
queue_test(); queue_test();
sema_test(); sema_test();
mutex_test(); mutex_test();
@ -114,15 +146,13 @@ void BenchTask(void)
" |\n", " |\n",
output_file); output_file);
PRINT_STRING(dashline, output_file); PRINT_STRING(dashline, output_file);
PRINT_STRING("PROJECT EXECUTION SUCCESSFUL\n",output_file); PRINT_STRING("PROJECT EXECUTION SUCCESSFUL\n", output_file);
TC_PRINT_RUNID; TC_PRINT_RUNID;
} while (continuously && !kbhit()); } while (continuously && !kbhit());
WAIT_FOR_USER(); WAIT_FOR_USER();
if (autorun) { k_thread_abort(RECVTASK);
task_sleep(SECONDS(2));
}
output_close(); output_close();
} }

View file

@ -21,6 +21,7 @@
#include <misc/util.h> #include <misc/util.h>
/* uncomment the define below to use floating point arithmetic */ /* uncomment the define below to use floating point arithmetic */
/* #define FLOAT */ /* #define FLOAT */
@ -34,8 +35,10 @@
/* length of the output line */ /* length of the output line */
#define SLINE_LEN 256 #define SLINE_LEN 256
#define SLEEP_TIME ((sys_clock_ticks_per_sec / 4) > 0? sys_clock_ticks_per_sec / 4: 1) #define SLEEP_TIME ((sys_clock_ticks_per_sec / 4) > 0 ? \
#define WAIT_TIME ((sys_clock_ticks_per_sec / 10) > 0? sys_clock_ticks_per_sec / 10: 1) sys_clock_ticks_per_sec / 4 : 1)
#define WAIT_TIME ((sys_clock_ticks_per_sec / 10) > 0 ? \
sys_clock_ticks_per_sec / 10 : 1)
#define NR_OF_NOP_RUNS 10000 #define NR_OF_NOP_RUNS 10000
#define NR_OF_FIFO_RUNS 500 #define NR_OF_FIFO_RUNS 500
#define NR_OF_SEMA_RUNS 500 #define NR_OF_SEMA_RUNS 500
@ -45,12 +48,13 @@
#define NR_OF_EVENT_RUNS 1000 #define NR_OF_EVENT_RUNS 1000
#define NR_OF_MBOX_RUNS 128 #define NR_OF_MBOX_RUNS 128
#define NR_OF_PIPE_RUNS 256 #define NR_OF_PIPE_RUNS 256
#define SEMA_WAIT_TIME (5 * sys_clock_ticks_per_sec) //#define SEMA_WAIT_TIME (5 * sys_clock_ticks_per_sec)
#define SEMA_WAIT_TIME (5000)
/* global data */ /* global data */
extern char Msg[MAX_MSG]; extern char Msg[MAX_MSG];
extern char data_bench[OCTET_TO_SIZEOFUNIT(MESSAGE_SIZE)]; extern char data_bench[OCTET_TO_SIZEOFUNIT(MESSAGE_SIZE)];
extern kpipe_t TestPipes[]; extern struct k_pipe *TestPipes[];
extern FILE * output_file; extern FILE *output_file;
extern const char newline[]; extern const char newline[];
extern char sline[]; extern char sline[];
@ -58,12 +62,24 @@ extern char sline[];
"|--------------------------------------" \ "|--------------------------------------" \
"---------------------------------------|\n" "---------------------------------------|\n"
/* pipe amount of content to receive (0+, 1+, all) */
typedef enum {
_0_TO_N = 0x0,
_1_TO_N = 0x1,
_ALL_N = 0x2,
} pipe_options;
/* dummy_test is a function that is mapped when we */ /* dummy_test is a function that is mapped when we */
/* do not want to test a specific Benchmark */ /* do not want to test a specific Benchmark */
extern void dummy_test(void); extern void dummy_test(void);
/* other external functions */ /* other external functions */
extern void BenchTask(void *p1, void *p2, void *p3);
extern void recvtask(void *p1, void *p2, void *p3);
#ifdef MAILBOX_BENCH #ifdef MAILBOX_BENCH
extern void mailbox_test(void); extern void mailbox_test(void);
#else #else
@ -112,6 +128,37 @@ extern void event_test(void);
#define event_test dummy_test #define event_test dummy_test
#endif #endif
/* kernel objects needed for benchmarking */
extern struct k_mutex DEMO_MUTEX;
extern struct k_sem SEM0;
extern struct k_sem SEM1;
extern struct k_sem SEM2;
extern struct k_sem SEM3;
extern struct k_sem SEM4;
extern struct k_sem STARTRCV;
extern struct k_msgq DEMOQX1;
extern struct k_msgq DEMOQX4;
extern struct k_msgq MB_COMM;
extern struct k_msgq CH_COMM;
extern struct k_mbox MAILB1;
extern struct k_pipe PIPE_NOBUFF;
extern struct k_pipe PIPE_SMALLBUFF;
extern struct k_pipe PIPE_BIGBUFF;
extern struct k_mem_slab MAP1;
extern struct k_alert TEST_EVENT;
extern struct k_mem_pool DEMOPOOL;
/* PRINT_STRING /* PRINT_STRING
* Macro to print an ASCII NULL terminated string. fprintf is used * Macro to print an ASCII NULL terminated string. fprintf is used
* so output can go to console. * so output can go to console.
@ -125,7 +172,7 @@ extern void event_test(void);
*/ */
#define PRINT_F(stream, fmt, ...) \ #define PRINT_F(stream, fmt, ...) \
{ \ { \
snprintf(sline, SLINE_LEN, fmt, ##__VA_ARGS__); \ snprintf(sline, SLINE_LEN, fmt, ##__VA_ARGS__); \
PRINT_STRING(sline, stream); \ PRINT_STRING(sline, stream); \
} }

View file

@ -22,19 +22,19 @@ void memorymap_test(void)
{ {
uint32_t et; /* elapsed time */ uint32_t et; /* elapsed time */
int i; int i;
void* p; void *p;
PRINT_STRING(dashline, output_file); PRINT_STRING(dashline, output_file);
et = BENCH_START(); et = BENCH_START();
for (i = 0; i < NR_OF_MAP_RUNS; i++) { for (i = 0; i < NR_OF_MAP_RUNS; i++) {
task_mem_map_alloc(MAP1, &p, TICKS_UNLIMITED); k_mem_slab_alloc(&MAP1, &p, K_FOREVER);
task_mem_map_free(MAP1, &p); k_mem_slab_free(&MAP1, &p);
} }
et = TIME_STAMP_DELTA_GET(et); et = TIME_STAMP_DELTA_GET(et);
check_result(); check_result();
PRINT_F(output_file, FORMAT, "average alloc and dealloc memory page", PRINT_F(output_file, FORMAT, "average alloc and dealloc memory page",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, (2 * NR_OF_MAP_RUNS))); SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, (2 * NR_OF_MAP_RUNS)));
} }
#endif /* MEMMAP_BENCH */ #endif /* MEMMAP_BENCH */

View file

@ -20,20 +20,20 @@ void mempool_test(void)
{ {
uint32_t et; /* elapsed time */ uint32_t et; /* elapsed time */
int i; int i;
struct k_block block; struct k_mem_block block;
PRINT_STRING(dashline, output_file); PRINT_STRING(dashline, output_file);
et = BENCH_START(); et = BENCH_START();
for (i = 0; i < NR_OF_POOL_RUNS; i++) { for (i = 0; i < NR_OF_POOL_RUNS; i++) {
task_mem_pool_alloc(&block, DEMOPOOL, 16, TICKS_UNLIMITED); k_mem_pool_alloc(&DEMOPOOL, &block, 16, K_FOREVER);
task_mem_pool_free(&block); k_mem_pool_free(&block);
} }
et = TIME_STAMP_DELTA_GET(et); et = TIME_STAMP_DELTA_GET(et);
check_result(); check_result();
PRINT_F(output_file, FORMAT, PRINT_F(output_file, FORMAT,
"average alloc and dealloc memory pool block", "average alloc and dealloc memory pool block",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, (2 * NR_OF_POOL_RUNS))); SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, (2 * NR_OF_POOL_RUNS)));
} }
#endif /* MEMPOOL_BENCH */ #endif /* MEMPOOL_BENCH */

View file

@ -24,14 +24,14 @@ void mutex_test(void)
PRINT_STRING(dashline, output_file); PRINT_STRING(dashline, output_file);
et = BENCH_START(); et = BENCH_START();
for (i = 0; i < NR_OF_MUTEX_RUNS; i++) { for (i = 0; i < NR_OF_MUTEX_RUNS; i++) {
task_mutex_lock(DEMO_MUTEX, TICKS_UNLIMITED); k_mutex_lock(&DEMO_MUTEX, K_FOREVER);
task_mutex_unlock(DEMO_MUTEX); k_mutex_unlock(&DEMO_MUTEX);
} }
et = TIME_STAMP_DELTA_GET(et); et = TIME_STAMP_DELTA_GET(et);
check_result(); check_result();
PRINT_F(output_file, FORMAT, "average lock and unlock mutex", PRINT_F(output_file, FORMAT, "average lock and unlock mutex",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, (2 * NR_OF_MUTEX_RUNS))); SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, (2 * NR_OF_MUTEX_RUNS)));
} }
#endif /* MUTEX_BENCH */ #endif /* MUTEX_BENCH */

View file

@ -76,7 +76,7 @@
/* /*
* Function prototypes. * Function prototypes.
*/ */
int pipeput(kpipe_t pipe, K_PIPE_OPTION int pipeput(struct k_pipe *pipe, pipe_options
option, int size, int count, uint32_t *time); option, int size, int count, uint32_t *time);
/* /*
@ -96,12 +96,12 @@ void pipe_test(void)
uint32_t puttime[3]; uint32_t puttime[3];
int putcount; int putcount;
int pipe; int pipe;
kpriority_t TaskPrio = UINT32_MAX; uint32_t TaskPrio = UINT32_MAX;
int prio; int prio;
GetInfo getinfo; GetInfo getinfo;
task_sem_reset(SEM0); k_sem_reset(&SEM0);
task_sem_give(STARTRCV); k_sem_give(&STARTRCV);
/* action: */ /* action: */
@ -112,17 +112,17 @@ void pipe_test(void)
" |\n", output_file); " |\n", output_file);
PRINT_STRING(dashline, output_file); PRINT_STRING(dashline, output_file);
PRINT_STRING("| Send data into a pipe towards a " PRINT_STRING("| Send data into a pipe towards a "
"receiving high priority task and wait |\n", "receiving high priority task and wait |\n",
output_file); output_file);
PRINT_STRING(dashline, output_file); PRINT_STRING(dashline, output_file);
PRINT_STRING("| " PRINT_STRING("| "
"matching sizes (_ALL_N)" "matching sizes (_ALL_N)"
" |\n", output_file); " |\n", output_file);
PRINT_STRING(dashline, output_file); PRINT_STRING(dashline, output_file);
PRINT_ALL_TO_N_HEADER_UNIT(); PRINT_ALL_TO_N_HEADER_UNIT();
PRINT_STRING(dashline, output_file); PRINT_STRING(dashline, output_file);
PRINT_STRING("| put | get | no buf | small buf| big buf |" PRINT_STRING("| put | get | no buf | small buf| big buf |"
" no buf | small buf| big buf |\n", output_file); " no buf | small buf| big buf |\n", output_file);
PRINT_STRING(dashline, output_file); PRINT_STRING(dashline, output_file);
for (putsize = 8; putsize <= MESSAGE_SIZE_PIPE; putsize <<= 1) { for (putsize = 8; putsize <= MESSAGE_SIZE_PIPE; putsize <<= 1) {
@ -132,7 +132,7 @@ void pipe_test(void)
&puttime[pipe]); &puttime[pipe]);
/* waiting for ack */ /* waiting for ack */
task_fifo_get(CH_COMM, &getinfo, TICKS_UNLIMITED); k_msgq_get(&CH_COMM, &getinfo, K_FOREVER);
} }
PRINT_ALL_TO_N(); PRINT_ALL_TO_N();
} }
@ -143,36 +143,36 @@ void pipe_test(void)
/* non-buffered operation, non-matching (1_TO_N) */ /* non-buffered operation, non-matching (1_TO_N) */
if (prio == 0) { if (prio == 0) {
PRINT_STRING("| " PRINT_STRING("| "
"non-matching sizes (1_TO_N) to higher priority" "non-matching sizes (1_TO_N) to higher priority"
" |\n", output_file); " |\n", output_file);
TaskPrio = task_priority_get(); TaskPrio = k_thread_priority_get(k_current_get());
} }
if (prio == 1) { if (prio == 1) {
PRINT_STRING("| " PRINT_STRING("| "
"non-matching sizes (1_TO_N) to lower priority" "non-matching sizes (1_TO_N) to lower priority"
" |\n", output_file); " |\n", output_file);
task_priority_set(task_id_get(), TaskPrio - 2); k_thread_priority_set(k_current_get(), TaskPrio - 2);
} }
PRINT_STRING(dashline, output_file); PRINT_STRING(dashline, output_file);
PRINT_1_TO_N_HEADER(); PRINT_1_TO_N_HEADER();
PRINT_STRING("| put | get | no buf | small buf| big buf | " PRINT_STRING("| put | get | no buf | small buf| big buf | "
"no buf | small buf| big buf |\n", output_file); "no buf | small buf| big buf |\n", output_file);
PRINT_STRING(dashline, output_file); PRINT_STRING(dashline, output_file);
for (putsize = 8; putsize <= (MESSAGE_SIZE_PIPE); putsize <<= 1) { for (putsize = 8; putsize <= (MESSAGE_SIZE_PIPE); putsize <<= 1) {
putcount = MESSAGE_SIZE_PIPE / putsize; putcount = MESSAGE_SIZE_PIPE / putsize;
for (pipe = 0; pipe < 3; pipe++) { for (pipe = 0; pipe < 3; pipe++) {
pipeput(TestPipes[pipe], _1_TO_N, putsize, pipeput(TestPipes[pipe], _1_TO_N, putsize,
putcount, &puttime[pipe]); putcount, &puttime[pipe]);
/* size*count == MESSAGE_SIZE_PIPE */ /* size*count == MESSAGE_SIZE_PIPE */
/* waiting for ack */ /* waiting for ack */
task_fifo_get(CH_COMM, &getinfo, TICKS_UNLIMITED); k_msgq_get(&CH_COMM, &getinfo, K_FOREVER);
getsize = getinfo.size; getsize = getinfo.size;
} }
PRINT_1_TO_N(); PRINT_1_TO_N();
} }
PRINT_STRING(dashline, output_file); PRINT_STRING(dashline, output_file);
task_priority_set(task_id_get(), TaskPrio); k_thread_priority_set(k_current_get(), TaskPrio);
} }
} }
@ -189,24 +189,33 @@ void pipe_test(void)
* @param count Number of data chunks. * @param count Number of data chunks.
* @param time Total write time. * @param time Total write time.
*/ */
int pipeput(kpipe_t pipe, K_PIPE_OPTION option, int size, int count, uint32_t *time) int pipeput(struct k_pipe *pipe,
pipe_options option,
int size,
int count,
uint32_t *time)
{ {
int i; int i;
unsigned int t; unsigned int t;
int sizexferd_total = 0; size_t sizexferd_total = 0;
int size2xfer_total = size * count; size_t size2xfer_total = size * count;
/* first sync with the receiver */ /* first sync with the receiver */
task_sem_give(SEM0); k_sem_give(&SEM0);
t = BENCH_START(); t = BENCH_START();
for (i = 0; _1_TO_N == option || (i < count); i++) { for (i = 0; _1_TO_N == option || (i < count); i++) {
int sizexferd = 0; size_t sizexferd = 0;
int size2xfer = min(size, size2xfer_total - sizexferd_total); size_t size2xfer = min(size, size2xfer_total - sizexferd_total);
int ret; int ret;
ret = task_pipe_put(pipe, data_bench, size2xfer, size_t mim_num_of_bytes = 0;
&sizexferd, option, TICKS_UNLIMITED); if (option == _ALL_N) {
if (RC_OK != ret) { mim_num_of_bytes = size2xfer;
}
ret = k_pipe_put(pipe, data_bench, size2xfer,
&sizexferd, mim_num_of_bytes, K_FOREVER);
if (0 != ret) {
return 1; return 1;
} }
if (_ALL_N == option && sizexferd != size2xfer) { if (_ALL_N == option && sizexferd != size2xfer) {
@ -227,10 +236,10 @@ int pipeput(kpipe_t pipe, K_PIPE_OPTION option, int size, int count, uint32_t *t
*time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, count); *time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, count);
if (bench_test_end() < 0) { if (bench_test_end() < 0) {
if (high_timer_overflow()) { if (high_timer_overflow()) {
PRINT_STRING("| Timer overflow. Results are invalid ", PRINT_STRING("| Timer overflow. Results are invalid ",
output_file); output_file);
} else { } else {
PRINT_STRING("| Tick occurred. Results may be inaccurate ", PRINT_STRING("| Tick occurred. Results may be inaccurate ",
output_file); output_file);
} }
PRINT_STRING(" |\n", output_file); PRINT_STRING(" |\n", output_file);

View file

@ -11,11 +11,12 @@
#ifdef PIPE_BENCH #ifdef PIPE_BENCH
/* /*
* Function prototypes. * Function prototypes.
*/ */
int pipeget(kpipe_t pipe, K_PIPE_OPTION option, int pipeget(struct k_pipe *pipe, pipe_options option,
int size, int count, unsigned int* time); int size, int count, unsigned int *time);
/* /*
* Function declarations. * Function declarations.
@ -49,13 +50,13 @@ void piperecvtask(void)
getinfo.size = getsize; getinfo.size = getsize;
getinfo.count = getcount; getinfo.count = getcount;
/* acknowledge to master */ /* acknowledge to master */
task_fifo_put(CH_COMM, &getinfo, TICKS_UNLIMITED); k_msgq_put(&CH_COMM, &getinfo, K_FOREVER);
} }
} }
for (prio = 0; prio < 2; prio++) { for (prio = 0; prio < 2; prio++) {
/* non-matching (1_TO_N) */ /* non-matching (1_TO_N) */
for (getsize = (MESSAGE_SIZE_PIPE); getsize >= 8; getsize >>= 1) { for (getsize = (MESSAGE_SIZE_PIPE); getsize >= 8; getsize >>= 1) {
getcount = MESSAGE_SIZE_PIPE / getsize; getcount = MESSAGE_SIZE_PIPE / getsize;
for (pipe = 0; pipe < 3; pipe++) { for (pipe = 0; pipe < 3; pipe++) {
/* size*count == MESSAGE_SIZE_PIPE */ /* size*count == MESSAGE_SIZE_PIPE */
@ -65,7 +66,7 @@ void piperecvtask(void)
getinfo.size = getsize; getinfo.size = getsize;
getinfo.count = getcount; getinfo.count = getcount;
/* acknowledge to master */ /* acknowledge to master */
task_fifo_put(CH_COMM, &getinfo, TICKS_UNLIMITED); k_msgq_put(&CH_COMM, &getinfo, K_FOREVER);
} }
} }
} }
@ -85,25 +86,26 @@ void piperecvtask(void)
* @param count Number of data chunks. * @param count Number of data chunks.
* @param time Total write time. * @param time Total write time.
*/ */
int pipeget(kpipe_t pipe, K_PIPE_OPTION option, int size, int count, int pipeget(struct k_pipe *pipe, pipe_options option, int size, int count,
unsigned int* time) unsigned int *time)
{ {
int i; int i;
unsigned int t; unsigned int t;
int sizexferd_total = 0; size_t sizexferd_total = 0;
int size2xfer_total = size * count; size_t size2xfer_total = size * count;
/* sync with the sender */ /* sync with the sender */
task_sem_take(SEM0, TICKS_UNLIMITED); k_sem_take(&SEM0, K_FOREVER);
t = BENCH_START(); t = BENCH_START();
for (i = 0; _1_TO_N == option || (i < count); i++) { for (i = 0; _1_TO_N == option || (i < count); i++) {
int sizexferd = 0; size_t sizexferd = 0;
int size2xfer = min(size, size2xfer_total - sizexferd_total); size_t size2xfer = min(size, size2xfer_total - sizexferd_total);
int ret; int ret;
ret = task_pipe_get(pipe, data_recv, size2xfer, ret = k_pipe_get(pipe, data_recv, size2xfer,
&sizexferd, option, TICKS_UNLIMITED); &sizexferd, option, K_FOREVER);
if (RC_OK != ret) {
if (0 != ret) {
return 1; return 1;
} }

View file

@ -7,12 +7,12 @@
*/ */
/* /*
File Naming information. * File Naming information.
------------------------ * ------------------------
Files that end with: * Files that end with:
_B : Is a file that contains a benchmark function * _B : Is a file that contains a benchmark function
_R : Is a file that contains the receiver task * _R : Is a file that contains the receiver task
of a benchmark function * of a benchmark function
*/ */
#include "receiver.h" #include "receiver.h"
@ -30,23 +30,23 @@ void piperecvtask(void);
* *
* @return N/A * @return N/A
*/ */
void recvtask(void) void recvtask(void *p1, void *p2, void *p3)
{ {
/* order must be compatible with master.c ! */ /* order must be compatible with master.c ! */
#ifdef FIFO_BENCH #ifdef FIFO_BENCH
task_sem_take(STARTRCV, TICKS_UNLIMITED); k_sem_take(&STARTRCV, K_FOREVER);
dequtask(); dequtask();
#endif #endif
#ifdef SEMA_BENCH #ifdef SEMA_BENCH
task_sem_take(STARTRCV, TICKS_UNLIMITED); k_sem_take(&STARTRCV, K_FOREVER);
waittask(); waittask();
#endif #endif
#ifdef MAILBOX_BENCH #ifdef MAILBOX_BENCH
task_sem_take(STARTRCV, TICKS_UNLIMITED); k_sem_take(&STARTRCV, K_FOREVER);
mailrecvtask(); mailrecvtask();
#endif #endif
#ifdef PIPE_BENCH #ifdef PIPE_BENCH
task_sem_take(STARTRCV, TICKS_UNLIMITED); k_sem_take(&STARTRCV, K_FOREVER);
piperecvtask(); piperecvtask();
#endif #endif
} }

View file

@ -12,6 +12,7 @@
#include <zephyr.h> #include <zephyr.h>
#include "config.h" #include "config.h"
#include "memcfg.h" #include "memcfg.h"
#include "master.h"
/* type defines. */ /* type defines. */
typedef struct { typedef struct {

View file

@ -0,0 +1,62 @@
/* sema_b.c */
/*
* Copyright (c) 1997-2010, 2013-2015 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "master.h"
#ifdef SEMA_BENCH
/**
*
* @brief Semaphore signal speed test
*
* @return N/A
*/
void sema_test(void)
{
uint32_t et; /* elapsed Time */
int i;
PRINT_STRING(dashline, output_file);
et = BENCH_START();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
k_sem_give(&SEM0);
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT, "signal semaphore",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
k_sem_reset(&SEM1);
k_sem_give(&STARTRCV);
et = BENCH_START();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
k_sem_give(&SEM1);
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT, "signal to waiting high pri task",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
et = BENCH_START();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
k_sem_give(&SEM1);
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT,
"signal to waiting high pri task, with timeout",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
}
#endif /* SEMA_BENCH */

View file

@ -0,0 +1,35 @@
/* sema_r.c */
/*
* Copyright (c) 1997-2010, 2013-2014 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "receiver.h"
#include "master.h"
#ifdef SEMA_BENCH
/* semaphore signal speed test */
/**
*
* @brief Receive task (Wait task)
*
* @return N/A
*/
void waittask(void)
{
int i;
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
k_sem_take(&SEM1, K_FOREVER);
}
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
k_sem_take(&SEM1, SEMA_WAIT_TIME);
}
}
#endif /* SEMA_BENCH */

View file

@ -1,49 +0,0 @@
% Application : AppKernel benchmark
% Part common for all platforms
% TASK NAME PRIO ENTRY STACK GROUPS
% ===================================================
TASK RECVTASK 5 recvtask 1024 []
TASK BENCHTASK 6 BenchTask 2048 [EXE]
% FIFO NAME DEPTH WIDTH
% ==============================
FIFO DEMOQX1 500 1
FIFO DEMOQX4 500 4
FIFO MB_COMM 1 12
FIFO CH_COMM 1 12
% MAP NAME BLOCKS BLOCKSIZE
% ==================================
MAP MAP1 4 16
% SEMA NAME
% =========
SEMA SEM0
SEMA SEM1
SEMA SEM2
SEMA SEM3
SEMA SEM4
SEMA STARTRCV
% MAILBOX NAME
% ==============
MAILBOX MAILB1
% MUTEX NAME
% ================
MUTEX DEMO_MUTEX
% PIPE NAME DEPTH
% ===========================
PIPE PIPE_NOBUFF 0
PIPE PIPE_SMALLBUFF 256
PIPE PIPE_BIGBUFF 4096
% POOL NAME SIZE_SMALL SIZE_LARGE BLOCK_NUMBER
% ====================================================
POOL DEMOPOOL 16 16 1
% EVENT NAME ENTRY
% =========================
EVENT TEST_EVENT NULL

View file

@ -1,121 +0,0 @@
/* sema_b.c */
/*
* Copyright (c) 1997-2010, 2013-2015 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "master.h"
#ifdef SEMA_BENCH
/**
*
* @brief Semaphore signal speed test
*
* @return N/A
*/
void sema_test(void)
{
uint32_t et; /* elapsed Time */
int i;
PRINT_STRING(dashline, output_file);
et = BENCH_START();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_give(SEM0);
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT, "signal semaphore",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
task_sem_reset(SEM1);
task_sem_give(STARTRCV);
et = BENCH_START();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_give(SEM1);
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT, "signal to waiting high pri task",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
et = BENCH_START();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_give(SEM1);
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT,
"signal to waiting high pri task, with timeout",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
et = BENCH_START();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_give(SEM2);
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT, "signal to waitm (2)",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
et = BENCH_START();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_give(SEM2);
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT, "signal to waitm (2), with timeout",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
et = BENCH_START();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_give(SEM3);
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT, "signal to waitm (3)",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
et = BENCH_START();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_give(SEM3);
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT, "signal to waitm (3), with timeout",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
et = BENCH_START();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_give(SEM4);
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT, "signal to waitm (4)",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
et = BENCH_START();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_give(SEM4);
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT, "signal to waitm (4), with timeout",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
}
#endif /* SEMA_BENCH */

View file

@ -1,65 +0,0 @@
/* sema_r.c */
/*
* Copyright (c) 1997-2010, 2013-2014 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "receiver.h"
#include "master.h"
#ifdef SEMA_BENCH
/* semaphore signal speed test */
/**
*
* @brief Receive task (Wait task)
*
* @return N/A
*/
void waittask(void)
{
int i;
ksem_t slist[5];
slist[0] = SEM1;
slist[1] = SEM2;
slist[2] = ENDLIST;
slist[3] = ENDLIST;
slist[4] = ENDLIST;
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_take(SEM1, TICKS_UNLIMITED);
}
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_take(SEM1, SEMA_WAIT_TIME);
}
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_group_take(slist, TICKS_UNLIMITED);
}
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_group_take(slist, SEMA_WAIT_TIME);
}
slist[2] = SEM3;
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_group_take(slist, TICKS_UNLIMITED);
}
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_group_take(slist, SEMA_WAIT_TIME);
}
slist[3] = SEM4;
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_group_take(slist, TICKS_UNLIMITED);
}
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_group_take(slist, SEMA_WAIT_TIME);
}
}
#endif /* SEMA_BENCH */