1 | /* |
---|
2 | Author : Shay Gal-On, EEMBC |
---|
3 | |
---|
4 | This file is part of EEMBC(R) and CoreMark(TM), which are Copyright (C) 2009 |
---|
5 | All rights reserved. |
---|
6 | |
---|
7 | EEMBC CoreMark Software is a product of EEMBC and is provided under the terms of the |
---|
8 | CoreMark License that is distributed with the official EEMBC COREMARK Software release. |
---|
9 | If you received this EEMBC CoreMark Software without the accompanying CoreMark License, |
---|
10 | you must discontinue use and download the official release from www.coremark.org. |
---|
11 | |
---|
12 | Also, if you are publicly displaying scores generated from the EEMBC CoreMark software, |
---|
13 | make sure that you are in compliance with Run and Reporting rules specified in the accompanying readme.txt file. |
---|
14 | |
---|
15 | EEMBC |
---|
16 | 4354 Town Center Blvd. Suite 114-200 |
---|
17 | El Dorado Hills, CA, 95762 |
---|
18 | */ |
---|
19 | /* Topic: Description |
---|
20 | This file contains declarations of the various benchmark functions. |
---|
21 | */ |
---|
22 | |
---|
23 | /* Configuration: TOTAL_DATA_SIZE |
---|
24 | Define total size for data algorithms will operate on |
---|
25 | */ |
---|
26 | #ifndef TOTAL_DATA_SIZE |
---|
27 | #define TOTAL_DATA_SIZE 2*1000 |
---|
28 | #endif |
---|
29 | |
---|
30 | #define SEED_ARG 0 |
---|
31 | #define SEED_FUNC 1 |
---|
32 | #define SEED_VOLATILE 2 |
---|
33 | |
---|
34 | #define MEM_STATIC 0 |
---|
35 | #define MEM_MALLOC 1 |
---|
36 | #define MEM_STACK 2 |
---|
37 | |
---|
38 | #include "core_portme.h" |
---|
39 | |
---|
40 | #if HAS_STDIO |
---|
41 | #include <stdio.h> |
---|
42 | #endif |
---|
43 | #if HAS_PRINTF |
---|
44 | #define ee_printf printf |
---|
45 | #endif |
---|
46 | |
---|
47 | /* Actual benchmark execution in iterate */ |
---|
48 | void *iterate(void *pres); |
---|
49 | |
---|
50 | /* Typedef: secs_ret |
---|
51 | For machines that have floating point support, get number of seconds as a double. |
---|
52 | Otherwise an unsigned int. |
---|
53 | */ |
---|
54 | #if HAS_FLOAT |
---|
55 | typedef double secs_ret; |
---|
56 | #else |
---|
57 | typedef ee_u32 secs_ret; |
---|
58 | #endif |
---|
59 | |
---|
60 | #if MAIN_HAS_NORETURN |
---|
61 | #define MAIN_RETURN_VAL |
---|
62 | #define MAIN_RETURN_TYPE void |
---|
63 | #else |
---|
64 | #define MAIN_RETURN_VAL 0 |
---|
65 | #define MAIN_RETURN_TYPE int |
---|
66 | #endif |
---|
67 | |
---|
68 | void start_time(void); |
---|
69 | void stop_time(void); |
---|
70 | CORE_TICKS get_time(void); |
---|
71 | secs_ret time_in_secs(CORE_TICKS ticks); |
---|
72 | |
---|
73 | /* Misc useful functions */ |
---|
74 | ee_u16 crcu8(ee_u8 data, ee_u16 crc); |
---|
75 | ee_u16 crc16(ee_s16 newval, ee_u16 crc); |
---|
76 | ee_u16 crcu16(ee_u16 newval, ee_u16 crc); |
---|
77 | ee_u16 crcu32(ee_u32 newval, ee_u16 crc); |
---|
78 | ee_u8 check_data_types(); |
---|
79 | void *portable_malloc(ee_size_t size); |
---|
80 | void portable_free(void *p); |
---|
81 | ee_s32 parseval(char *valstring); |
---|
82 | |
---|
83 | /* Algorithm IDS */ |
---|
84 | #define ID_LIST (1<<0) |
---|
85 | #define ID_MATRIX (1<<1) |
---|
86 | #define ID_STATE (1<<2) |
---|
87 | #define ALL_ALGORITHMS_MASK (ID_LIST|ID_MATRIX|ID_STATE) |
---|
88 | #define NUM_ALGORITHMS 3 |
---|
89 | |
---|
90 | /* list data structures */ |
---|
91 | typedef struct list_data_s { |
---|
92 | ee_s16 data16; |
---|
93 | ee_s16 idx; |
---|
94 | } list_data; |
---|
95 | |
---|
96 | typedef struct list_head_s { |
---|
97 | struct list_head_s *next; |
---|
98 | struct list_data_s *info; |
---|
99 | } list_head; |
---|
100 | |
---|
101 | |
---|
102 | /*matrix benchmark related stuff */ |
---|
103 | #define MATDAT_INT 1 |
---|
104 | #if MATDAT_INT |
---|
105 | typedef ee_s16 MATDAT; |
---|
106 | typedef ee_s32 MATRES; |
---|
107 | #else |
---|
108 | typedef ee_f16 MATDAT; |
---|
109 | typedef ee_f32 MATRES; |
---|
110 | #endif |
---|
111 | |
---|
112 | typedef struct MAT_PARAMS_S { |
---|
113 | int N; |
---|
114 | MATDAT *A; |
---|
115 | MATDAT *B; |
---|
116 | MATRES *C; |
---|
117 | } mat_params; |
---|
118 | |
---|
119 | /* state machine related stuff */ |
---|
120 | /* List of all the possible states for the FSM */ |
---|
121 | typedef enum CORE_STATE { |
---|
122 | CORE_START=0, |
---|
123 | CORE_INVALID, |
---|
124 | CORE_S1, |
---|
125 | CORE_S2, |
---|
126 | CORE_INT, |
---|
127 | CORE_FLOAT, |
---|
128 | CORE_EXPONENT, |
---|
129 | CORE_SCIENTIFIC, |
---|
130 | NUM_CORE_STATES |
---|
131 | } core_state_e ; |
---|
132 | |
---|
133 | |
---|
134 | /* Helper structure to hold results */ |
---|
135 | typedef struct RESULTS_S { |
---|
136 | /* inputs */ |
---|
137 | ee_s16 seed1; /* Initializing seed */ |
---|
138 | ee_s16 seed2; /* Initializing seed */ |
---|
139 | ee_s16 seed3; /* Initializing seed */ |
---|
140 | void *memblock[4]; /* Pointer to safe memory location */ |
---|
141 | ee_u32 size; /* Size of the data */ |
---|
142 | ee_u32 iterations; /* Number of iterations to execute */ |
---|
143 | ee_u32 execs; /* Bitmask of operations to execute */ |
---|
144 | struct list_head_s *list; |
---|
145 | mat_params mat; |
---|
146 | /* outputs */ |
---|
147 | ee_u16 crc; |
---|
148 | ee_u16 crclist; |
---|
149 | ee_u16 crcmatrix; |
---|
150 | ee_u16 crcstate; |
---|
151 | ee_s16 err; |
---|
152 | /* ultithread specific */ |
---|
153 | core_portable port; |
---|
154 | } core_results; |
---|
155 | |
---|
156 | /* Multicore execution handling */ |
---|
157 | #if (MULTITHREAD>1) |
---|
158 | ee_u8 core_start_parallel(core_results *res); |
---|
159 | ee_u8 core_stop_parallel(core_results *res); |
---|
160 | #endif |
---|
161 | |
---|
162 | /* list benchmark functions */ |
---|
163 | list_head *core_list_init(ee_u32 blksize, list_head *memblock, ee_s16 seed); |
---|
164 | ee_u16 core_bench_list(core_results *res, ee_s16 finder_idx); |
---|
165 | |
---|
166 | /* state benchmark functions */ |
---|
167 | void core_init_state(ee_u32 size, ee_s16 seed, ee_u8 *p); |
---|
168 | ee_u16 core_bench_state(ee_u32 blksize, ee_u8 *memblock, |
---|
169 | ee_s16 seed1, ee_s16 seed2, ee_s16 step, ee_u16 crc); |
---|
170 | |
---|
171 | /* matrix benchmark functions */ |
---|
172 | ee_u32 core_init_matrix(ee_u32 blksize, void *memblk, ee_s32 seed, mat_params *p); |
---|
173 | ee_u16 core_bench_matrix(mat_params *p, ee_s16 seed, ee_u16 crc); |
---|
174 | |
---|