see http://mbed.org/users/no2chem/notebook/mbed-clock-control--benchmarks/

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers core_portme.h Source File

core_portme.h

00001 /* File : core_portme.h */
00002 
00003 /*
00004     Author : Shay Gal-On, EEMBC
00005     Legal : TODO!
00006 */ 
00007 /* Topic : Description
00008     This file contains configuration constants required to execute on different platforms
00009 */
00010 
00011 #ifndef CORE_PORTME_H
00012 #define CORE_PORTME_H
00013 
00014 #define ITERATIONS 5000
00015 int mainCoreMark(void); //to start coremark from main program
00016 
00017 #include <stddef.h> // for size_t
00018 /************************/
00019 /* Data types and settings */
00020 /************************/
00021 /* Configuration : HAS_FLOAT 
00022     Define to 1 if the platform supports floating point.
00023 */
00024 #ifndef HAS_FLOAT 
00025 #define HAS_FLOAT 1
00026 #endif
00027 /* Configuration : HAS_TIME_H
00028     Define to 1 if platform has the time.h header file,
00029     and implementation of functions thereof.
00030 */
00031 #ifndef HAS_TIME_H
00032 #define HAS_TIME_H 0
00033 #endif
00034 /* Configuration : USE_CLOCK
00035     Define to 1 if platform has the time.h header file,
00036     and implementation of functions thereof.
00037 */
00038 #ifndef USE_CLOCK
00039 #define USE_CLOCK 0
00040 #endif
00041 /* Configuration : HAS_STDIO
00042     Define to 1 if the platform has stdio.h.
00043 */
00044 #ifndef HAS_STDIO
00045 #define HAS_STDIO 1
00046 #endif
00047 /* Configuration : HAS_PRINTF
00048     Define to 1 if the platform has stdio.h and implements the printf function.
00049 */
00050 #ifndef HAS_PRINTF
00051 #define HAS_PRINTF 1
00052 #endif
00053 
00054 
00055 /* Definitions : COMPILER_VERSION, COMPILER_FLAGS, MEM_LOCATION
00056     Initialize these strings per platform
00057 */
00058 #ifndef COMPILER_VERSION 
00059  #ifdef __GNUC__
00060  #define COMPILER_VERSION __VERSION__
00061  #else
00062  #define COMPILER_VERSION "Please put compiler version here (e.g. gcc 4.1)"
00063  #endif
00064 #endif
00065 #ifndef COMPILER_FLAGS 
00066  #define COMPILER_FLAGS ""/* "Please put compiler flags here (e.g. -o3)" */
00067 #endif
00068 #ifndef MEM_LOCATION 
00069  #define MEM_LOCATION "STACK"
00070 #endif
00071 
00072 /* Data Types :
00073     To avoid compiler issues, define the data types that need ot be used for 8b, 16b and 32b in <core_portme.h>.
00074     
00075     *Imprtant* :
00076     ee_ptr_int needs to be the data type used to hold pointers, otherwise coremark may fail!!!
00077 */
00078 typedef signed short ee_s16;
00079 typedef unsigned short ee_u16;
00080 typedef signed int ee_s32;
00081 typedef double ee_f32;
00082 typedef unsigned char ee_u8;
00083 typedef unsigned int ee_u32;
00084 typedef ee_u32 ee_ptr_int;
00085 typedef size_t ee_size_t;
00086 /* align_mem :
00087     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.
00088 */
00089 #define align_mem(x) (void *)(4 + (((ee_ptr_int)(x) - 1) & ~3))
00090 
00091 /* Configuration : CORE_TICKS
00092     Define type of return from the timing functions.
00093  */
00094 #define CORETIMETYPE ee_u32 
00095 typedef ee_u32 CORE_TICKS;
00096 
00097 /* Configuration : SEED_METHOD
00098     Defines method to get seed values that cannot be computed at compile time.
00099     
00100     Valid values :
00101     SEED_ARG - from command line.
00102     SEED_FUNC - from a system function.
00103     SEED_VOLATILE - from volatile variables.
00104 */
00105 #ifndef SEED_METHOD
00106 #define SEED_METHOD SEED_VOLATILE
00107 #endif
00108 
00109 /* Configuration : MEM_METHOD
00110     Defines method to get a block of memry.
00111     
00112     Valid values :
00113     MEM_MALLOC - for platforms that implement malloc and have malloc.h.
00114     MEM_STATIC - to use a static memory array.
00115     MEM_STACK - to allocate the data block on the stack (NYI).
00116 */
00117 #ifndef MEM_METHOD
00118 #define MEM_METHOD MEM_STACK
00119 #endif
00120 
00121 /* Configuration : MULTITHREAD
00122     Define for parallel execution 
00123     
00124     Valid values :
00125     1 - only one context (default).
00126     N>1 - will execute N copies in parallel.
00127     
00128     Note : 
00129     If this flag is defined to more then 1, an implementation for launching parallel contexts must be defined.
00130     
00131     Two sample implementations are provided. Use <USE_PTHREAD> or <USE_FORK> to enable them.
00132     
00133     It is valid to have a different implementation of <core_start_parallel> and <core_end_parallel> in <core_portme.c>,
00134     to fit a particular architecture. 
00135 */
00136 #ifndef MULTITHREAD
00137 #define MULTITHREAD 1
00138 #define USE_PTHREAD 0
00139 #define USE_FORK 0
00140 #define USE_SOCKET 0
00141 #endif
00142 
00143 /* Configuration : MAIN_HAS_NOARGC
00144     Needed if platform does not support getting arguments to main. 
00145     
00146     Valid values :
00147     0 - argc/argv to main is supported
00148     1 - argc/argv to main is not supported
00149     
00150     Note : 
00151     This flag only matters if MULTITHREAD has been defined to a value greater then 1.
00152 */
00153 #ifndef MAIN_HAS_NOARGC 
00154 #define MAIN_HAS_NOARGC 1
00155 #endif
00156 
00157 /* Configuration : MAIN_HAS_NORETURN
00158     Needed if platform does not support returning a value from main. 
00159     
00160     Valid values :
00161     0 - main returns an int, and return value will be 0.
00162     1 - platform does not support returning a value from main
00163 */
00164 #ifndef MAIN_HAS_NORETURN
00165 #define MAIN_HAS_NORETURN 0
00166 #endif
00167 
00168 /* Variable : default_num_contexts
00169     Not used for this simple port, must cintain the value 1.
00170 */
00171 extern ee_u32 default_num_contexts;
00172 
00173 typedef struct CORE_PORTABLE_S {
00174     ee_u8   portable_id;
00175 } core_portable;
00176 
00177 /* target specific init/fini */
00178 void portable_init(core_portable *p, int *argc, char *argv[]);
00179 void portable_fini(core_portable *p);
00180 
00181 #if !defined(PROFILE_RUN) && !defined(PERFORMANCE_RUN) && !defined(VALIDATION_RUN)
00182 #if (TOTAL_DATA_SIZE==1200)
00183 #define PROFILE_RUN 1
00184 #elif (TOTAL_DATA_SIZE==2000)
00185 #define PERFORMANCE_RUN 1
00186 #else
00187 #define VALIDATION_RUN 1
00188 #endif
00189 #endif
00190 
00191 #endif /* CORE_PORTME_H */