1 | /* File : core_portme.h */ |
---|
2 | |
---|
3 | /* |
---|
4 | Author : Shay Gal-On, EEMBC |
---|
5 | Legal : TODO! |
---|
6 | */ |
---|
7 | /* Topic : Description |
---|
8 | This file contains configuration constants required to execute on different platforms |
---|
9 | */ |
---|
10 | #ifndef CORE_PORTME_H |
---|
11 | #define CORE_PORTME_H |
---|
12 | |
---|
13 | /************************/ |
---|
14 | /* Data types and settings */ |
---|
15 | /************************/ |
---|
16 | |
---|
17 | /* Configuration : HAS_FLOAT |
---|
18 | Define to 1 if the platform supports floating point. |
---|
19 | */ |
---|
20 | #ifndef HAS_FLOAT |
---|
21 | #define HAS_FLOAT 0 |
---|
22 | #endif |
---|
23 | |
---|
24 | |
---|
25 | /* Configuration : HAS_TIME_H |
---|
26 | Define to 1 if platform has the time.h header file, |
---|
27 | and implementation of functions thereof. |
---|
28 | */ |
---|
29 | #ifndef HAS_TIME_H |
---|
30 | #define HAS_TIME_H 0 |
---|
31 | #endif |
---|
32 | |
---|
33 | |
---|
34 | /* Configuration : USE_CLOCK |
---|
35 | Define to 1 if platform has the time.h header file, |
---|
36 | and implementation of functions thereof. |
---|
37 | */ |
---|
38 | #ifndef USE_CLOCK |
---|
39 | #define USE_CLOCK 0 |
---|
40 | #endif |
---|
41 | |
---|
42 | |
---|
43 | /* Configuration : HAS_STDIO |
---|
44 | Define to 1 if the platform has stdio.h. |
---|
45 | */ |
---|
46 | #ifndef HAS_STDIO |
---|
47 | #define HAS_STDIO 1 |
---|
48 | #include <stdio.h> |
---|
49 | #endif |
---|
50 | |
---|
51 | |
---|
52 | /* Configuration : HAS_PRINTF |
---|
53 | Define to 1 if the platform has stdio.h and implements the printf function. |
---|
54 | */ |
---|
55 | #ifndef HAS_PRINTF |
---|
56 | #define HAS_PRINTF 1 |
---|
57 | |
---|
58 | /* printf wrapper macro */ |
---|
59 | #define printf(...) giet_tty_printf(__VA_ARGS__) |
---|
60 | #endif |
---|
61 | |
---|
62 | |
---|
63 | /* Configuration : CORE_TICKS |
---|
64 | Define type of return from the timing functions. |
---|
65 | */ |
---|
66 | typedef unsigned int CORE_TICKS; |
---|
67 | |
---|
68 | |
---|
69 | /* Definitions : COMPILER_VERSION, COMPILER_FLAGS, MEM_LOCATION |
---|
70 | Initialize these strings per platform |
---|
71 | */ |
---|
72 | #ifndef COMPILER_VERSION |
---|
73 | #ifdef __GNUC__ |
---|
74 | #define COMPILER_VERSION "GCC"__VERSION__ |
---|
75 | #else |
---|
76 | #define COMPILER_VERSION "Please put compiler version here (e.g. gcc 4.1)" |
---|
77 | #endif |
---|
78 | #endif |
---|
79 | #ifndef COMPILER_FLAGS |
---|
80 | #define COMPILER_FLAGS FLAGS_STR /* "Please put compiler flags here (e.g. -o3)" */ |
---|
81 | #endif |
---|
82 | #ifndef MEM_LOCATION |
---|
83 | #define MEM_LOCATION "Data on heap" |
---|
84 | #endif |
---|
85 | |
---|
86 | |
---|
87 | /* Data Types : |
---|
88 | To avoid compiler issues, define the data types that need ot be used for 8b, 16b and 32b in <core_portme.h>. |
---|
89 | |
---|
90 | *Important* : |
---|
91 | ee_ptr_int needs to be the data type used to hold pointers, otherwise coremark may fail!!! |
---|
92 | */ |
---|
93 | typedef signed short ee_s16; |
---|
94 | typedef unsigned short ee_u16; |
---|
95 | typedef signed int ee_s32; |
---|
96 | typedef unsigned char ee_u8; |
---|
97 | typedef unsigned int ee_u32; |
---|
98 | typedef ee_u32 ee_ptr_int; |
---|
99 | typedef ee_u32 ee_size_t; |
---|
100 | |
---|
101 | #if HAS_FLOAT |
---|
102 | typedef double ee_f32; |
---|
103 | #endif |
---|
104 | |
---|
105 | |
---|
106 | /* align_mem : |
---|
107 | This macro is used to align an offset to point to a 32b value. It is used in the Matrix algorithm to initialize the input memory blocks. |
---|
108 | */ |
---|
109 | #define align_mem(x) (void *)(4 + (((ee_ptr_int)(x) - 1) & ~3)) |
---|
110 | |
---|
111 | |
---|
112 | /* Configuration : SEED_METHOD |
---|
113 | Defines method to get seed values that cannot be computed at compile time. |
---|
114 | |
---|
115 | Valid values : |
---|
116 | SEED_ARG - from command line. |
---|
117 | SEED_FUNC - from a system function. |
---|
118 | SEED_VOLATILE - from volatile variables. |
---|
119 | */ |
---|
120 | #ifndef SEED_METHOD |
---|
121 | #define SEED_METHOD SEED_VOLATILE |
---|
122 | #endif |
---|
123 | |
---|
124 | |
---|
125 | /* Configuration : MEM_METHOD |
---|
126 | Defines method to get a block of memry. |
---|
127 | |
---|
128 | Valid values : |
---|
129 | MEM_MALLOC - for platforms that implement malloc and have malloc.h. |
---|
130 | MEM_STATIC - to use a static memory array. |
---|
131 | MEM_STACK - to allocate the data block on the stack (NYI). |
---|
132 | */ |
---|
133 | #ifndef MEM_METHOD |
---|
134 | #define MEM_METHOD MEM_MALLOC |
---|
135 | #endif |
---|
136 | |
---|
137 | |
---|
138 | /* Configuration : MULTITHREAD |
---|
139 | Define for parallel execution |
---|
140 | |
---|
141 | Valid values : |
---|
142 | 1 - only one context (default). |
---|
143 | N>1 - will execute N copies in parallel. |
---|
144 | |
---|
145 | Note : |
---|
146 | If this flag is defined to more then 1, an implementation for launching parallel contexts must be defined. |
---|
147 | |
---|
148 | It is valid to have a different implementation of <core_start_parallel> and <core_end_parallel> in <core_portme.c>, |
---|
149 | to fit a particular architecture. |
---|
150 | */ |
---|
151 | #ifndef MULTITHREAD |
---|
152 | #define MULTITHREAD 1 |
---|
153 | #endif |
---|
154 | |
---|
155 | #define PARALLEL_METHOD "pthread" |
---|
156 | |
---|
157 | /* Configuration : MAIN_HAS_NOARGC |
---|
158 | Needed if platform does not support getting arguments to main. |
---|
159 | |
---|
160 | Valid values : |
---|
161 | 0 - argc/argv to main is supported |
---|
162 | 1 - argc/argv to main is not supported |
---|
163 | |
---|
164 | Note : |
---|
165 | This flag only matters if MULTITHREAD has been defined to a value greater then 1. |
---|
166 | */ |
---|
167 | #ifndef MAIN_HAS_NOARGC |
---|
168 | #define MAIN_HAS_NOARGC 1 |
---|
169 | #endif |
---|
170 | |
---|
171 | |
---|
172 | /* Configuration : MAIN_HAS_NORETURN |
---|
173 | Needed if platform does not support returning a value from main. |
---|
174 | |
---|
175 | Valid values : |
---|
176 | 0 - main returns an int, and return value will be 0. |
---|
177 | 1 - platform does not support returning a value from main |
---|
178 | */ |
---|
179 | #ifndef MAIN_HAS_NORETURN |
---|
180 | #define MAIN_HAS_NORETURN 0 |
---|
181 | #endif |
---|
182 | |
---|
183 | |
---|
184 | /* Configuration : ITERATIONS |
---|
185 | Valid values : |
---|
186 | 0 - the actual number of iterations is computed by the benchmark. |
---|
187 | N > 0 - fixed number of iterations |
---|
188 | */ |
---|
189 | #ifndef ITERATIONS |
---|
190 | #define ITERATIONS 0 |
---|
191 | #endif |
---|
192 | |
---|
193 | |
---|
194 | /* Configuration : TOTAL_DATA_SIZE |
---|
195 | */ |
---|
196 | #ifndef TOTAL_DATA_SIZE |
---|
197 | #define TOTAL_DATA_SIZE 2000 |
---|
198 | #endif |
---|
199 | |
---|
200 | |
---|
201 | /* Variable : default_num_contexts |
---|
202 | */ |
---|
203 | extern ee_u32 default_num_contexts; |
---|
204 | |
---|
205 | typedef struct CORE_PORTABLE_S { |
---|
206 | ee_u8 portable_id; |
---|
207 | pthread_t thread; |
---|
208 | |
---|
209 | CORE_TICKS start_time, stop_time; |
---|
210 | } core_portable; |
---|
211 | |
---|
212 | |
---|
213 | /* target specific init/fini */ |
---|
214 | void portable_init(core_portable *p, int *argc, char *argv[]); |
---|
215 | void portable_fini(core_portable *p); |
---|
216 | void *portable_malloc(ee_size_t size); |
---|
217 | void portable_free(void *p); |
---|
218 | |
---|
219 | #endif /* CORE_PORTME_H */ |
---|