Michael Wei
/
ClockControl
see http://mbed.org/users/no2chem/notebook/mbed-clock-control--benchmarks/
CoreMark/core_portme.h@0:b5d3bd64d2dc, 2010-01-24 (annotated)
- Committer:
- no2chem
- Date:
- Sun Jan 24 15:46:26 2010 +0000
- Revision:
- 0:b5d3bd64d2dc
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
no2chem | 0:b5d3bd64d2dc | 1 | /* File : core_portme.h */ |
no2chem | 0:b5d3bd64d2dc | 2 | |
no2chem | 0:b5d3bd64d2dc | 3 | /* |
no2chem | 0:b5d3bd64d2dc | 4 | Author : Shay Gal-On, EEMBC |
no2chem | 0:b5d3bd64d2dc | 5 | Legal : TODO! |
no2chem | 0:b5d3bd64d2dc | 6 | */ |
no2chem | 0:b5d3bd64d2dc | 7 | /* Topic : Description |
no2chem | 0:b5d3bd64d2dc | 8 | This file contains configuration constants required to execute on different platforms |
no2chem | 0:b5d3bd64d2dc | 9 | */ |
no2chem | 0:b5d3bd64d2dc | 10 | |
no2chem | 0:b5d3bd64d2dc | 11 | #ifndef CORE_PORTME_H |
no2chem | 0:b5d3bd64d2dc | 12 | #define CORE_PORTME_H |
no2chem | 0:b5d3bd64d2dc | 13 | |
no2chem | 0:b5d3bd64d2dc | 14 | #define ITERATIONS 5000 |
no2chem | 0:b5d3bd64d2dc | 15 | int mainCoreMark(void); //to start coremark from main program |
no2chem | 0:b5d3bd64d2dc | 16 | |
no2chem | 0:b5d3bd64d2dc | 17 | #include <stddef.h> // for size_t |
no2chem | 0:b5d3bd64d2dc | 18 | /************************/ |
no2chem | 0:b5d3bd64d2dc | 19 | /* Data types and settings */ |
no2chem | 0:b5d3bd64d2dc | 20 | /************************/ |
no2chem | 0:b5d3bd64d2dc | 21 | /* Configuration : HAS_FLOAT |
no2chem | 0:b5d3bd64d2dc | 22 | Define to 1 if the platform supports floating point. |
no2chem | 0:b5d3bd64d2dc | 23 | */ |
no2chem | 0:b5d3bd64d2dc | 24 | #ifndef HAS_FLOAT |
no2chem | 0:b5d3bd64d2dc | 25 | #define HAS_FLOAT 1 |
no2chem | 0:b5d3bd64d2dc | 26 | #endif |
no2chem | 0:b5d3bd64d2dc | 27 | /* Configuration : HAS_TIME_H |
no2chem | 0:b5d3bd64d2dc | 28 | Define to 1 if platform has the time.h header file, |
no2chem | 0:b5d3bd64d2dc | 29 | and implementation of functions thereof. |
no2chem | 0:b5d3bd64d2dc | 30 | */ |
no2chem | 0:b5d3bd64d2dc | 31 | #ifndef HAS_TIME_H |
no2chem | 0:b5d3bd64d2dc | 32 | #define HAS_TIME_H 0 |
no2chem | 0:b5d3bd64d2dc | 33 | #endif |
no2chem | 0:b5d3bd64d2dc | 34 | /* Configuration : USE_CLOCK |
no2chem | 0:b5d3bd64d2dc | 35 | Define to 1 if platform has the time.h header file, |
no2chem | 0:b5d3bd64d2dc | 36 | and implementation of functions thereof. |
no2chem | 0:b5d3bd64d2dc | 37 | */ |
no2chem | 0:b5d3bd64d2dc | 38 | #ifndef USE_CLOCK |
no2chem | 0:b5d3bd64d2dc | 39 | #define USE_CLOCK 0 |
no2chem | 0:b5d3bd64d2dc | 40 | #endif |
no2chem | 0:b5d3bd64d2dc | 41 | /* Configuration : HAS_STDIO |
no2chem | 0:b5d3bd64d2dc | 42 | Define to 1 if the platform has stdio.h. |
no2chem | 0:b5d3bd64d2dc | 43 | */ |
no2chem | 0:b5d3bd64d2dc | 44 | #ifndef HAS_STDIO |
no2chem | 0:b5d3bd64d2dc | 45 | #define HAS_STDIO 1 |
no2chem | 0:b5d3bd64d2dc | 46 | #endif |
no2chem | 0:b5d3bd64d2dc | 47 | /* Configuration : HAS_PRINTF |
no2chem | 0:b5d3bd64d2dc | 48 | Define to 1 if the platform has stdio.h and implements the printf function. |
no2chem | 0:b5d3bd64d2dc | 49 | */ |
no2chem | 0:b5d3bd64d2dc | 50 | #ifndef HAS_PRINTF |
no2chem | 0:b5d3bd64d2dc | 51 | #define HAS_PRINTF 1 |
no2chem | 0:b5d3bd64d2dc | 52 | #endif |
no2chem | 0:b5d3bd64d2dc | 53 | |
no2chem | 0:b5d3bd64d2dc | 54 | |
no2chem | 0:b5d3bd64d2dc | 55 | /* Definitions : COMPILER_VERSION, COMPILER_FLAGS, MEM_LOCATION |
no2chem | 0:b5d3bd64d2dc | 56 | Initialize these strings per platform |
no2chem | 0:b5d3bd64d2dc | 57 | */ |
no2chem | 0:b5d3bd64d2dc | 58 | #ifndef COMPILER_VERSION |
no2chem | 0:b5d3bd64d2dc | 59 | #ifdef __GNUC__ |
no2chem | 0:b5d3bd64d2dc | 60 | #define COMPILER_VERSION __VERSION__ |
no2chem | 0:b5d3bd64d2dc | 61 | #else |
no2chem | 0:b5d3bd64d2dc | 62 | #define COMPILER_VERSION "Please put compiler version here (e.g. gcc 4.1)" |
no2chem | 0:b5d3bd64d2dc | 63 | #endif |
no2chem | 0:b5d3bd64d2dc | 64 | #endif |
no2chem | 0:b5d3bd64d2dc | 65 | #ifndef COMPILER_FLAGS |
no2chem | 0:b5d3bd64d2dc | 66 | #define COMPILER_FLAGS ""/* "Please put compiler flags here (e.g. -o3)" */ |
no2chem | 0:b5d3bd64d2dc | 67 | #endif |
no2chem | 0:b5d3bd64d2dc | 68 | #ifndef MEM_LOCATION |
no2chem | 0:b5d3bd64d2dc | 69 | #define MEM_LOCATION "STACK" |
no2chem | 0:b5d3bd64d2dc | 70 | #endif |
no2chem | 0:b5d3bd64d2dc | 71 | |
no2chem | 0:b5d3bd64d2dc | 72 | /* Data Types : |
no2chem | 0:b5d3bd64d2dc | 73 | To avoid compiler issues, define the data types that need ot be used for 8b, 16b and 32b in <core_portme.h>. |
no2chem | 0:b5d3bd64d2dc | 74 | |
no2chem | 0:b5d3bd64d2dc | 75 | *Imprtant* : |
no2chem | 0:b5d3bd64d2dc | 76 | ee_ptr_int needs to be the data type used to hold pointers, otherwise coremark may fail!!! |
no2chem | 0:b5d3bd64d2dc | 77 | */ |
no2chem | 0:b5d3bd64d2dc | 78 | typedef signed short ee_s16; |
no2chem | 0:b5d3bd64d2dc | 79 | typedef unsigned short ee_u16; |
no2chem | 0:b5d3bd64d2dc | 80 | typedef signed int ee_s32; |
no2chem | 0:b5d3bd64d2dc | 81 | typedef double ee_f32; |
no2chem | 0:b5d3bd64d2dc | 82 | typedef unsigned char ee_u8; |
no2chem | 0:b5d3bd64d2dc | 83 | typedef unsigned int ee_u32; |
no2chem | 0:b5d3bd64d2dc | 84 | typedef ee_u32 ee_ptr_int; |
no2chem | 0:b5d3bd64d2dc | 85 | typedef size_t ee_size_t; |
no2chem | 0:b5d3bd64d2dc | 86 | /* align_mem : |
no2chem | 0:b5d3bd64d2dc | 87 | 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. |
no2chem | 0:b5d3bd64d2dc | 88 | */ |
no2chem | 0:b5d3bd64d2dc | 89 | #define align_mem(x) (void *)(4 + (((ee_ptr_int)(x) - 1) & ~3)) |
no2chem | 0:b5d3bd64d2dc | 90 | |
no2chem | 0:b5d3bd64d2dc | 91 | /* Configuration : CORE_TICKS |
no2chem | 0:b5d3bd64d2dc | 92 | Define type of return from the timing functions. |
no2chem | 0:b5d3bd64d2dc | 93 | */ |
no2chem | 0:b5d3bd64d2dc | 94 | #define CORETIMETYPE ee_u32 |
no2chem | 0:b5d3bd64d2dc | 95 | typedef ee_u32 CORE_TICKS; |
no2chem | 0:b5d3bd64d2dc | 96 | |
no2chem | 0:b5d3bd64d2dc | 97 | /* Configuration : SEED_METHOD |
no2chem | 0:b5d3bd64d2dc | 98 | Defines method to get seed values that cannot be computed at compile time. |
no2chem | 0:b5d3bd64d2dc | 99 | |
no2chem | 0:b5d3bd64d2dc | 100 | Valid values : |
no2chem | 0:b5d3bd64d2dc | 101 | SEED_ARG - from command line. |
no2chem | 0:b5d3bd64d2dc | 102 | SEED_FUNC - from a system function. |
no2chem | 0:b5d3bd64d2dc | 103 | SEED_VOLATILE - from volatile variables. |
no2chem | 0:b5d3bd64d2dc | 104 | */ |
no2chem | 0:b5d3bd64d2dc | 105 | #ifndef SEED_METHOD |
no2chem | 0:b5d3bd64d2dc | 106 | #define SEED_METHOD SEED_VOLATILE |
no2chem | 0:b5d3bd64d2dc | 107 | #endif |
no2chem | 0:b5d3bd64d2dc | 108 | |
no2chem | 0:b5d3bd64d2dc | 109 | /* Configuration : MEM_METHOD |
no2chem | 0:b5d3bd64d2dc | 110 | Defines method to get a block of memry. |
no2chem | 0:b5d3bd64d2dc | 111 | |
no2chem | 0:b5d3bd64d2dc | 112 | Valid values : |
no2chem | 0:b5d3bd64d2dc | 113 | MEM_MALLOC - for platforms that implement malloc and have malloc.h. |
no2chem | 0:b5d3bd64d2dc | 114 | MEM_STATIC - to use a static memory array. |
no2chem | 0:b5d3bd64d2dc | 115 | MEM_STACK - to allocate the data block on the stack (NYI). |
no2chem | 0:b5d3bd64d2dc | 116 | */ |
no2chem | 0:b5d3bd64d2dc | 117 | #ifndef MEM_METHOD |
no2chem | 0:b5d3bd64d2dc | 118 | #define MEM_METHOD MEM_STACK |
no2chem | 0:b5d3bd64d2dc | 119 | #endif |
no2chem | 0:b5d3bd64d2dc | 120 | |
no2chem | 0:b5d3bd64d2dc | 121 | /* Configuration : MULTITHREAD |
no2chem | 0:b5d3bd64d2dc | 122 | Define for parallel execution |
no2chem | 0:b5d3bd64d2dc | 123 | |
no2chem | 0:b5d3bd64d2dc | 124 | Valid values : |
no2chem | 0:b5d3bd64d2dc | 125 | 1 - only one context (default). |
no2chem | 0:b5d3bd64d2dc | 126 | N>1 - will execute N copies in parallel. |
no2chem | 0:b5d3bd64d2dc | 127 | |
no2chem | 0:b5d3bd64d2dc | 128 | Note : |
no2chem | 0:b5d3bd64d2dc | 129 | If this flag is defined to more then 1, an implementation for launching parallel contexts must be defined. |
no2chem | 0:b5d3bd64d2dc | 130 | |
no2chem | 0:b5d3bd64d2dc | 131 | Two sample implementations are provided. Use <USE_PTHREAD> or <USE_FORK> to enable them. |
no2chem | 0:b5d3bd64d2dc | 132 | |
no2chem | 0:b5d3bd64d2dc | 133 | It is valid to have a different implementation of <core_start_parallel> and <core_end_parallel> in <core_portme.c>, |
no2chem | 0:b5d3bd64d2dc | 134 | to fit a particular architecture. |
no2chem | 0:b5d3bd64d2dc | 135 | */ |
no2chem | 0:b5d3bd64d2dc | 136 | #ifndef MULTITHREAD |
no2chem | 0:b5d3bd64d2dc | 137 | #define MULTITHREAD 1 |
no2chem | 0:b5d3bd64d2dc | 138 | #define USE_PTHREAD 0 |
no2chem | 0:b5d3bd64d2dc | 139 | #define USE_FORK 0 |
no2chem | 0:b5d3bd64d2dc | 140 | #define USE_SOCKET 0 |
no2chem | 0:b5d3bd64d2dc | 141 | #endif |
no2chem | 0:b5d3bd64d2dc | 142 | |
no2chem | 0:b5d3bd64d2dc | 143 | /* Configuration : MAIN_HAS_NOARGC |
no2chem | 0:b5d3bd64d2dc | 144 | Needed if platform does not support getting arguments to main. |
no2chem | 0:b5d3bd64d2dc | 145 | |
no2chem | 0:b5d3bd64d2dc | 146 | Valid values : |
no2chem | 0:b5d3bd64d2dc | 147 | 0 - argc/argv to main is supported |
no2chem | 0:b5d3bd64d2dc | 148 | 1 - argc/argv to main is not supported |
no2chem | 0:b5d3bd64d2dc | 149 | |
no2chem | 0:b5d3bd64d2dc | 150 | Note : |
no2chem | 0:b5d3bd64d2dc | 151 | This flag only matters if MULTITHREAD has been defined to a value greater then 1. |
no2chem | 0:b5d3bd64d2dc | 152 | */ |
no2chem | 0:b5d3bd64d2dc | 153 | #ifndef MAIN_HAS_NOARGC |
no2chem | 0:b5d3bd64d2dc | 154 | #define MAIN_HAS_NOARGC 1 |
no2chem | 0:b5d3bd64d2dc | 155 | #endif |
no2chem | 0:b5d3bd64d2dc | 156 | |
no2chem | 0:b5d3bd64d2dc | 157 | /* Configuration : MAIN_HAS_NORETURN |
no2chem | 0:b5d3bd64d2dc | 158 | Needed if platform does not support returning a value from main. |
no2chem | 0:b5d3bd64d2dc | 159 | |
no2chem | 0:b5d3bd64d2dc | 160 | Valid values : |
no2chem | 0:b5d3bd64d2dc | 161 | 0 - main returns an int, and return value will be 0. |
no2chem | 0:b5d3bd64d2dc | 162 | 1 - platform does not support returning a value from main |
no2chem | 0:b5d3bd64d2dc | 163 | */ |
no2chem | 0:b5d3bd64d2dc | 164 | #ifndef MAIN_HAS_NORETURN |
no2chem | 0:b5d3bd64d2dc | 165 | #define MAIN_HAS_NORETURN 0 |
no2chem | 0:b5d3bd64d2dc | 166 | #endif |
no2chem | 0:b5d3bd64d2dc | 167 | |
no2chem | 0:b5d3bd64d2dc | 168 | /* Variable : default_num_contexts |
no2chem | 0:b5d3bd64d2dc | 169 | Not used for this simple port, must cintain the value 1. |
no2chem | 0:b5d3bd64d2dc | 170 | */ |
no2chem | 0:b5d3bd64d2dc | 171 | extern ee_u32 default_num_contexts; |
no2chem | 0:b5d3bd64d2dc | 172 | |
no2chem | 0:b5d3bd64d2dc | 173 | typedef struct CORE_PORTABLE_S { |
no2chem | 0:b5d3bd64d2dc | 174 | ee_u8 portable_id; |
no2chem | 0:b5d3bd64d2dc | 175 | } core_portable; |
no2chem | 0:b5d3bd64d2dc | 176 | |
no2chem | 0:b5d3bd64d2dc | 177 | /* target specific init/fini */ |
no2chem | 0:b5d3bd64d2dc | 178 | void portable_init(core_portable *p, int *argc, char *argv[]); |
no2chem | 0:b5d3bd64d2dc | 179 | void portable_fini(core_portable *p); |
no2chem | 0:b5d3bd64d2dc | 180 | |
no2chem | 0:b5d3bd64d2dc | 181 | #if !defined(PROFILE_RUN) && !defined(PERFORMANCE_RUN) && !defined(VALIDATION_RUN) |
no2chem | 0:b5d3bd64d2dc | 182 | #if (TOTAL_DATA_SIZE==1200) |
no2chem | 0:b5d3bd64d2dc | 183 | #define PROFILE_RUN 1 |
no2chem | 0:b5d3bd64d2dc | 184 | #elif (TOTAL_DATA_SIZE==2000) |
no2chem | 0:b5d3bd64d2dc | 185 | #define PERFORMANCE_RUN 1 |
no2chem | 0:b5d3bd64d2dc | 186 | #else |
no2chem | 0:b5d3bd64d2dc | 187 | #define VALIDATION_RUN 1 |
no2chem | 0:b5d3bd64d2dc | 188 | #endif |
no2chem | 0:b5d3bd64d2dc | 189 | #endif |
no2chem | 0:b5d3bd64d2dc | 190 | |
no2chem | 0:b5d3bd64d2dc | 191 | #endif /* CORE_PORTME_H */ |