| 1 |
355 |
julius |
/*
|
| 2 |
|
|
File : core_portme.c
|
| 3 |
|
|
*/
|
| 4 |
|
|
/*
|
| 5 |
|
|
Author : Shay Gal-On, EEMBC
|
| 6 |
|
|
Legal : TODO!
|
| 7 |
|
|
*/
|
| 8 |
|
|
#include "coremark.h"
|
| 9 |
|
|
#include "core_portme.h"
|
| 10 |
|
|
#include "spr-defs.h"
|
| 11 |
|
|
#include "board.h"
|
| 12 |
|
|
#include "support.h"
|
| 13 |
|
|
#include "common.h"
|
| 14 |
|
|
|
| 15 |
|
|
/*
|
| 16 |
|
|
#if VALIDATION_RUN
|
| 17 |
|
|
volatile ee_s32 seed1_volatile = 0x3415;
|
| 18 |
|
|
volatile ee_s32 seed2_volatile = 0x3415;
|
| 19 |
|
|
volatile ee_s32 seed3_volatile = 0x66;
|
| 20 |
|
|
#endif
|
| 21 |
|
|
#if PERFORMANCE_RUN
|
| 22 |
|
|
volatile ee_s32 seed1_volatile = 0x0;
|
| 23 |
|
|
volatile ee_s32 seed2_volatile = 0x0;
|
| 24 |
|
|
volatile ee_s32 seed3_volatile = 0x66;
|
| 25 |
|
|
#endif
|
| 26 |
|
|
#if PROFILE_RUN
|
| 27 |
|
|
volatile ee_s32 seed1_volatile = 0x8;
|
| 28 |
|
|
volatile ee_s32 seed2_volatile = 0x8;
|
| 29 |
|
|
volatile ee_s32 seed3_volatile = 0x8;
|
| 30 |
|
|
#endif
|
| 31 |
|
|
volatile ee_s32 seed4_volatile = ITERATIONS;
|
| 32 |
|
|
volatile ee_s32 seed5_volatile = 0;
|
| 33 |
|
|
*/
|
| 34 |
|
|
|
| 35 |
|
|
volatile ee_s32 seed1_volatile;
|
| 36 |
|
|
volatile ee_s32 seed2_volatile;
|
| 37 |
|
|
volatile ee_s32 seed3_volatile;
|
| 38 |
|
|
volatile ee_s32 seed4_volatile = 0; // Iterations defaults to 0
|
| 39 |
|
|
volatile ee_s32 seed5_volatile = 0;
|
| 40 |
|
|
|
| 41 |
|
|
/* Porting : Timing functions
|
| 42 |
|
|
How to capture time and convert to seconds must be ported to whatever is
|
| 43 |
|
|
supported by the platform. e.g. Read value from on board RTC, read value
|
| 44 |
|
|
from cpu clock cycles performance counter etc. Sample implementation for
|
| 45 |
|
|
standard time.h and windows.h definitions included.
|
| 46 |
|
|
*/
|
| 47 |
|
|
CORETIMETYPE barebones_clock()
|
| 48 |
|
|
{
|
| 49 |
|
|
//#error "You must implement a method to measure time in
|
| 50 |
|
|
//barebones_clock()! This function should return current time.\n"
|
| 51 |
|
|
return timestamp;
|
| 52 |
|
|
}
|
| 53 |
|
|
|
| 54 |
|
|
/* Define : TIMER_RES_DIVIDER
|
| 55 |
|
|
Divider to trade off timer resolution and total time that can be measured.
|
| 56 |
|
|
|
| 57 |
|
|
Use lower values to increase resolution, but make sure that overflow does
|
| 58 |
|
|
not occur. If there are issues with the return value overflowing, increase
|
| 59 |
|
|
this value.
|
| 60 |
|
|
*/
|
| 61 |
|
|
#define GETMYTIME(_t) (*_t=barebones_clock())
|
| 62 |
|
|
#define MYTIMEDIFF(fin,ini) ((fin)-(ini))
|
| 63 |
|
|
#define TIMER_RES_DIVIDER 1 /* Unused */
|
| 64 |
|
|
#define SAMPLE_TIME_IMPLEMENTATION 1
|
| 65 |
|
|
#define EE_TICKS_PER_SEC TICKS_PER_SEC
|
| 66 |
|
|
|
| 67 |
|
|
/** Define Host specific (POSIX), or target specific global time variables. */
|
| 68 |
|
|
static CORETIMETYPE start_time_val, stop_time_val;
|
| 69 |
|
|
|
| 70 |
|
|
/* Function : start_time
|
| 71 |
|
|
This function will be called right before starting the timed portion of the
|
| 72 |
|
|
benchmark.
|
| 73 |
|
|
|
| 74 |
|
|
Implementation may be capturing a system timer (as implemented in the
|
| 75 |
|
|
example code) or zeroing some system parameters - e.g. setting the cpu
|
| 76 |
|
|
clocks cycles to 0.
|
| 77 |
|
|
*/
|
| 78 |
|
|
void start_time(void)
|
| 79 |
|
|
{
|
| 80 |
|
|
GETMYTIME(&start_time_val);
|
| 81 |
|
|
}
|
| 82 |
|
|
|
| 83 |
|
|
/* Function : stop_time
|
| 84 |
|
|
This function will be called right after ending the timed portion of the
|
| 85 |
|
|
benchmark.
|
| 86 |
|
|
|
| 87 |
|
|
Implementation may be capturing a system timer (as implemented in the
|
| 88 |
|
|
example code) or other system parameters - e.g. reading the current value of
|
| 89 |
|
|
cpu cycles counter.
|
| 90 |
|
|
*/
|
| 91 |
|
|
void stop_time(void)
|
| 92 |
|
|
{
|
| 93 |
|
|
GETMYTIME(&stop_time_val);
|
| 94 |
|
|
}
|
| 95 |
|
|
|
| 96 |
|
|
/* Function : get_time
|
| 97 |
|
|
Return an abstract "ticks" number that signifies time on the system.
|
| 98 |
|
|
|
| 99 |
|
|
Actual value returned may be cpu cycles, milliseconds or any other value,
|
| 100 |
|
|
as long as it can be converted to seconds by <time_in_secs>.
|
| 101 |
|
|
This methodology is taken to accomodate any hardware or simulated platform.
|
| 102 |
|
|
The sample implementation returns millisecs by default,
|
| 103 |
|
|
and the resolution is controlled by <TIMER_RES_DIVIDER>
|
| 104 |
|
|
*/
|
| 105 |
|
|
CORE_TICKS get_time(void)
|
| 106 |
|
|
{
|
| 107 |
|
|
CORE_TICKS elapsed =
|
| 108 |
|
|
(CORE_TICKS) (MYTIMEDIFF(stop_time_val, start_time_val));
|
| 109 |
|
|
return elapsed;
|
| 110 |
|
|
}
|
| 111 |
|
|
|
| 112 |
|
|
/* Function : time_in_secs
|
| 113 |
|
|
Convert the value returned by get_time to seconds.
|
| 114 |
|
|
|
| 115 |
|
|
The <secs_ret> type is used to accomodate systems with no support for
|
| 116 |
|
|
floating point. Default implementation implemented by the EE_TICKS_PER_SEC
|
| 117 |
|
|
macro above.
|
| 118 |
|
|
*/
|
| 119 |
|
|
secs_ret time_in_secs(CORE_TICKS ticks)
|
| 120 |
|
|
{
|
| 121 |
|
|
secs_ret retval = ((secs_ret) ticks) / (secs_ret) EE_TICKS_PER_SEC;
|
| 122 |
|
|
return retval;
|
| 123 |
|
|
}
|
| 124 |
|
|
|
| 125 |
|
|
ee_u32 default_num_contexts = 1;
|
| 126 |
|
|
|
| 127 |
|
|
/* Function : portable_init
|
| 128 |
|
|
Target specific initialization code
|
| 129 |
|
|
Test for some common mistakes.
|
| 130 |
|
|
*/
|
| 131 |
|
|
void portable_init(core_portable * p, int *argc, char *argv[])
|
| 132 |
|
|
{
|
| 133 |
|
|
|
| 134 |
|
|
// In ORPmon - UART already initialised: uart_init(DEFAULT_UART);
|
| 135 |
|
|
if (sizeof(ee_ptr_int) != sizeof(ee_u8 *)) {
|
| 136 |
|
|
ee_printf
|
| 137 |
|
|
("ERROR! Please define ee_ptr_int to a type that holds a pointer!\n");
|
| 138 |
|
|
while (1) ; // FINISH
|
| 139 |
|
|
}
|
| 140 |
|
|
if (sizeof(ee_u32) != 4) {
|
| 141 |
|
|
ee_printf
|
| 142 |
|
|
("ERROR! Please define ee_u32 to a 32b unsigned type!\n");
|
| 143 |
|
|
while (1) ; // FINISH
|
| 144 |
|
|
}
|
| 145 |
|
|
// In ORPmon - things already initialised
|
| 146 |
|
|
// Clear timer variable
|
| 147 |
|
|
//clear_timer_ticks();
|
| 148 |
|
|
// init timer
|
| 149 |
|
|
//enable_timer();
|
| 150 |
|
|
|
| 151 |
|
|
//
|
| 152 |
|
|
|
| 153 |
|
|
// Parse argv and figure out what kind of run we do
|
| 154 |
|
|
if (argc > 0)
|
| 155 |
|
|
{
|
| 156 |
|
|
switch((char) argv[0][0])
|
| 157 |
|
|
{
|
| 158 |
|
|
case 'p':
|
| 159 |
|
|
//PERFORMANCE_RUN
|
| 160 |
|
|
seed1_volatile = 0x0;
|
| 161 |
|
|
seed2_volatile = 0x0;
|
| 162 |
|
|
seed3_volatile = 0x66;
|
| 163 |
|
|
break;
|
| 164 |
|
|
case 'o':
|
| 165 |
|
|
//PROFILE_RUN
|
| 166 |
|
|
seed1_volatile = 0x8;
|
| 167 |
|
|
seed2_volatile = 0x8;
|
| 168 |
|
|
seed3_volatile = 0x8;
|
| 169 |
|
|
break;
|
| 170 |
|
|
default:
|
| 171 |
|
|
//VALIDATION_RUN
|
| 172 |
|
|
seed1_volatile = 0x3415;
|
| 173 |
|
|
seed2_volatile = 0x3415;
|
| 174 |
|
|
seed3_volatile = 0x66;
|
| 175 |
|
|
break;
|
| 176 |
|
|
}
|
| 177 |
|
|
}
|
| 178 |
|
|
|
| 179 |
|
|
if (argc > 1)
|
| 180 |
|
|
seed4_volatile = strtoul(argv[1],0,0); // Iterations as second argument
|
| 181 |
|
|
else
|
| 182 |
|
|
seed4_volatile = 0; // Zero (test runs a minimum amount of time)
|
| 183 |
|
|
|
| 184 |
|
|
seed5_volatile = 0;
|
| 185 |
|
|
|
| 186 |
|
|
p->portable_id = 1;
|
| 187 |
|
|
|
| 188 |
|
|
}
|
| 189 |
|
|
|
| 190 |
|
|
/* Function : portable_fini
|
| 191 |
|
|
Target specific final code
|
| 192 |
|
|
*/
|
| 193 |
|
|
void portable_fini(core_portable * p)
|
| 194 |
|
|
{
|
| 195 |
|
|
p->portable_id = 0;
|
| 196 |
|
|
}
|