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

Dependencies:   mbed

Committer:
no2chem
Date:
Sun Jan 24 15:46:26 2010 +0000
Revision:
0:b5d3bd64d2dc

        

Who changed what in which revision?

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