Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | /* master.h */
/*
* Copyright (c) 1997-2010, 2014-2015 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _MASTER_H
#define _MASTER_H
#include <zephyr.h>
#include <stdio.h>
#include "receiver.h"
#include <timestamp.h>
#include <string.h>
#include <sys/util.h>
/* uncomment the define below to use floating point arithmetic */
/* #define FLOAT */
/* printf format defines. */
#define FORMAT "| %-65s|%10u|\n"
/* length of the output line */
#define SLINE_LEN 256
#define SLEEP_TIME ((CONFIG_SYS_CLOCK_TICKS_PER_SEC / 4) > 0 ? \
CONFIG_SYS_CLOCK_TICKS_PER_SEC / 4 : 1)
#define WAIT_TIME ((CONFIG_SYS_CLOCK_TICKS_PER_SEC / 10) > 0 ? \
CONFIG_SYS_CLOCK_TICKS_PER_SEC / 10 : 1)
#define NR_OF_NOP_RUNS 10000
#define NR_OF_FIFO_RUNS 500
#define NR_OF_SEMA_RUNS 500
#define NR_OF_MUTEX_RUNS 1000
#define NR_OF_POOL_RUNS 1000
#define NR_OF_MAP_RUNS 1000
#define NR_OF_EVENT_RUNS 1000
#define NR_OF_MBOX_RUNS 128
#define NR_OF_PIPE_RUNS 256
/* #define SEMA_WAIT_TIME (5 * CONFIG_SYS_CLOCK_TICKS_PER_SEC) */
#define SEMA_WAIT_TIME (5000)
/* global data */
extern char msg[MAX_MSG];
extern char data_bench[MESSAGE_SIZE];
extern struct k_pipe *test_pipes[];
extern FILE *output_file;
extern const char newline[];
extern char sline[];
#define dashline \
"|--------------------------------------" \
"---------------------------------------|\n"
/*
* To avoid divisions by 0 faults, wrap the divisor with this macro
*/
#define SAFE_DIVISOR(a) (((a) != 0)?(a):1)
/* pipe amount of content to receive (0+, 1+, all) */
enum pipe_options {
_0_TO_N = 0x0,
_1_TO_N = 0x1,
_ALL_N = 0x2,
};
/* dummy_test is a function that is mapped when we */
/* do not want to test a specific Benchmark */
extern void dummy_test(void);
/* other external functions */
extern void bench_task(void *p1, void *p2, void *p3);
extern void recvtask(void *p1, void *p2, void *p3);
#ifdef MAILBOX_BENCH
extern void mailbox_test(void);
#else
#define mailbox_test dummy_test
#endif
#ifdef SEMA_BENCH
extern void sema_test(void);
#else
#define sema_test dummy_test
#endif
#ifdef FIFO_BENCH
extern void queue_test(void);
#else
#define queue_test dummy_test
#endif
#ifdef MUTEX_BENCH
extern void mutex_test(void);
#else
#define mutex_test dummy_test
#endif
#ifdef MEMMAP_BENCH
extern void memorymap_test(void);
#else
#define memorymap_test dummy_test
#endif
#ifdef MEMPOOL_BENCH
extern void mempool_test(void);
#else
#define mempool_test dummy_test
#endif
#ifdef PIPE_BENCH
extern void pipe_test(void);
#else
#define pipe_test dummy_test
#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_mem_pool DEMOPOOL;
/* PRINT_STRING
* Macro to print an ASCII NULL terminated string. fprintf is used
* so output can go to console.
*/
#define PRINT_STRING(string, stream) fputs(string, stream)
/* PRINT_F
* Macro to print a formatted output string. fprintf is used when
* Assumed that sline character array of SLINE_LEN + 1 characters
* is defined in the main file
*/
#define PRINT_F(stream, fmt, ...) \
{ \
snprintf(sline, SLINE_LEN, fmt, ##__VA_ARGS__); \
PRINT_STRING(sline, stream); \
}
#define PRINT_OVERFLOW_ERROR() \
PRINT_F(output_file, __FILE__":%d Error: tick occurred\n", __LINE__)
static inline u32_t BENCH_START(void)
{
u32_t et;
bench_test_start();
et = TIME_STAMP_DELTA_GET(0);
return et;
}
static inline void check_result(void)
{
if (bench_test_end() < 0) {
PRINT_OVERFLOW_ERROR();
return; /* error */
}
}
#endif /* _MASTER_H */
|