1 diff -u coremark_v1.0/core_main.c coremark-stm8/core_main.c
2 --- coremark_v1.0/core_main.c 2009-08-25 20:11:26.000000000 +0200
3 +++ coremark-stm8/core_main.c 2018-01-31 15:06:33.249348900 +0100
5 if (divisor==0) /* some machines cast float to int as 0 since this conversion is not defined by ANSI, but we know at least one second passed */
7 results[0].iterations*=1+10/divisor;
9 + }results[0].iterations = 60;
10 /* perform actual benchmark */
14 if (time_in_secs(total_time) > 0)
15 ee_printf("Iterations/Sec : %f\n",default_num_contexts*results[0].iterations/time_in_secs(total_time));
17 - ee_printf("Total time (secs): %d\n",time_in_secs(total_time));
18 + ee_printf("Total time (secs): %lu\n",time_in_secs(total_time));
19 if (time_in_secs(total_time) > 0)
20 - ee_printf("Iterations/Sec : %d\n",default_num_contexts*results[0].iterations/time_in_secs(total_time));
21 + ee_printf("Iterations/Sec : %lu\n",default_num_contexts*results[0].iterations/time_in_secs(total_time));
23 if (time_in_secs(total_time) < 10) {
24 ee_printf("ERROR! Must execute for at least 10 secs for a valid result!\n");
25 diff -u coremark_v1.0/core_portme.c coremark-stm8/core_portme.c
26 --- coremark_v1.0/core_portme.c 2018-01-31 15:14:02.207818287 +0100
27 +++ coremark-stm8/core_portme.c 2018-01-31 15:12:39.884267347 +0100
29 Author : Shay Gal-On, EEMBC
35 -#include "core_portme.h"
37 +#define ITERATIONS 100
40 volatile ee_s32 seed1_volatile=0x3415;
42 e.g. Read value from on board RTC, read value from cpu clock cycles performance counter etc.
43 Sample implementation for standard time.h and windows.h definitions included.
45 -CORETIMETYPE barebones_clock() {
46 - #error "You must implement a method to measure time in barebones_clock()! This function should return current time.\n"
48 /* Define : TIMER_RES_DIVIDER
49 Divider to trade off timer resolution and total time that can be measured.
51 Use lower values to increase resolution, but make sure that overflow does not occur.
52 If there are issues with the return value overflowing, increase this value.
54 -#define GETMYTIME(_t) (*_t=barebones_clock())
55 +#define CLOCKS_PER_SEC 1000
56 +#define NSECS_PER_SEC CLOCKS_PER_SEC
57 +unsigned int clock(void);
58 +//#define CORETIMETYPE clock_t
59 +#define CORETIMETYPE unsigned
60 +#define GETMYTIME(_t) (*_t=clock())
61 #define MYTIMEDIFF(fin,ini) ((fin)-(ini))
62 #define TIMER_RES_DIVIDER 1
63 #define SAMPLE_TIME_IMPLEMENTATION 1
64 -#define EE_TICKS_PER_SEC (CLOCKS_PER_SEC / TIMER_RES_DIVIDER)
65 +#define EE_TICKS_PER_SEC (NSECS_PER_SEC / TIMER_RES_DIVIDER)
67 /** Define Host specific (POSIX), or target specific global time variables. */
68 static CORETIMETYPE start_time_val, stop_time_val;
71 ee_u32 default_num_contexts=1;
75 /* Function : portable_init
76 Target specific initialization code
77 Test for some common mistakes.
79 void portable_init(core_portable *p, int *argc, char *argv[])
81 - #error "Call board initialization routines in portable init (if needed), in particular initialize UART!\n"
84 if (sizeof(ee_ptr_int) != sizeof(ee_u8 *)) {
85 ee_printf("ERROR! Please define ee_ptr_int to a type that holds a pointer!\n");
94 +#define PA_DDR (*(volatile uint8_t *)0x5002)
95 +#define PA_CR1 (*(volatile uint8_t *)0x5003)
97 +#define CLK_DIVR (*(volatile uint8_t *)0x50c6)
98 +#define CLK_PCKENR1 (*(volatile uint8_t *)0x50c7)
99 +#define CLK_PCKENR2 (*(volatile uint8_t *)0x50ca)
101 +#define USART3_SR (*(volatile uint8_t *)0x5240)
102 +#define USART3_DR (*(volatile uint8_t *)0x5241)
103 +#define USART3_BRR1 (*(volatile uint8_t *)0x5242)
104 +#define USART3_BRR2 (*(volatile uint8_t *)0x5243)
105 +#define USART3_CR2 (*(volatile uint8_t *)0x5245)
106 +#define USART3_CR3 (*(volatile uint8_t *)0x5246)
108 +#define TIM1_CR1 (*(volatile uint8_t *)0x5250)
109 +#define TIM1_CNTRH (*(volatile uint8_t *)0x525e)
110 +#define TIM1_CNTRL (*(volatile uint8_t *)0x525f)
111 +#define TIM1_PSCRH (*(volatile uint8_t *)0x5260)
112 +#define TIM1_PSCRL (*(volatile uint8_t *)0x5261)
114 +#define USART_CR2_TEN (1 << 3)
115 +#define USART_CR3_STOP2 (1 << 5)
116 +#define USART_CR3_STOP1 (1 << 4)
117 +#define USART_SR_TXE (1 << 7)
121 + CLK_DIVR = 0x00; // Set the frequency to 16 MHz
122 + CLK_PCKENR2 |= 0x02; // Enable clock to timer
125 + // 1000 ticks per second
131 + CLK_PCKENR1 = 0xFF; // Enable peripherals
133 + PA_DDR = 0x08; // Put TX line on
136 + USART3_CR2 = USART_CR2_TEN; // Allow TX & RX
137 + USART3_CR3 &= ~(USART_CR3_STOP1 | USART_CR3_STOP2); // 1 stop bit
138 + USART3_BRR2 = 0x03; USART3_BRR1 = 0x68; // 9600 baud
141 +unsigned int clock(void)
143 + unsigned char h = TIM1_CNTRH;
144 + unsigned char l = TIM1_CNTRL;
145 + return((unsigned int)(h) << 8 | l);
148 +#if defined(__CSMC__) // Cosmic weirdness
149 +char putchar(char c)
151 + while(!(USART3_SR & USART_SR_TXE));
157 +#elif defined(__RCSTM8__) // Raisonance weirdness
160 + while(!(USART3_SR & USART_SR_TXE));
166 +#elif defined(__SDCC) && __SDCC_REVISION < 9624 // Old SDCC weirdness
167 +void putchar(char c)
169 + while(!(USART3_SR & USART_SR_TXE));
176 + while(!(USART3_SR & USART_SR_TXE));
184 diff -u coremark_v1.0/core_portme.h coremark-stm8/core_portme.h
185 --- coremark_v1.0/core_portme.h 2018-01-31 15:14:02.207818287 +0100
186 +++ coremark-stm8/core_portme.h 2018-01-31 15:06:33.249348900 +0100
188 Define to 1 if the platform supports floating point.
194 /* Configuration : HAS_TIME_H
195 Define to 1 if platform has the time.h header file,
196 and implementation of functions thereof.
199 -#define HAS_TIME_H 1
200 +#define HAS_TIME_H 0
202 /* Configuration : USE_CLOCK
203 Define to 1 if platform has the time.h header file,
204 and implementation of functions thereof.
210 /* Configuration : HAS_STDIO
211 Define to 1 if the platform has stdio.h.
213 Define to 1 if the platform has stdio.h and implements the printf function.
216 -#define HAS_PRINTF 0
217 +#define HAS_PRINTF 1
221 +/* Configuration : CORE_TICKS
222 + Define type of return from the timing functions.
225 +//typedef clock_t CORE_TICKS;
226 +unsigned int clock(void);
227 +typedef unsigned int CORE_TICKS;
228 /* Definitions : COMPILER_VERSION, COMPILER_FLAGS, MEM_LOCATION
229 Initialize these strings per platform
234 #ifndef COMPILER_FLAGS
235 - #define COMPILER_FLAGS FLAGS_STR /* "Please put compiler flags here (e.g. -o3)" */
236 + #define COMPILER_FLAGS "Please put compiler flags here (e.g. -o3)"
239 #define MEM_LOCATION "STACK"
242 ee_ptr_int needs to be the data type used to hold pointers, otherwise coremark may fail!!!
244 -typedef signed short ee_s16;
245 -typedef unsigned short ee_u16;
246 -typedef signed int ee_s32;
247 -typedef double ee_f32;
248 -typedef unsigned char ee_u8;
249 -typedef unsigned int ee_u32;
250 -typedef ee_u32 ee_ptr_int;
255 +typedef int16_t ee_s16;
256 +typedef uint16_t ee_u16;
257 +typedef int32_t ee_s32;
258 +typedef float ee_f32;
259 +typedef uint8_t ee_u8;
260 +typedef uint32_t ee_u32;
261 +typedef uintptr_t ee_ptr_int;
262 typedef size_t ee_size_t;
263 -#define NULL ((void *)0)
265 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.
267 #define align_mem(x) (void *)(4 + (((ee_ptr_int)(x) - 1) & ~3))
269 -/* Configuration : CORE_TICKS
270 - Define type of return from the timing functions.
272 -#define CORETIMETYPE ee_u32
273 -typedef ee_u32 CORE_TICKS;
275 /* Configuration : SEED_METHOD
276 Defines method to get seed values that cannot be computed at compile time.
279 This flag only matters if MULTITHREAD has been defined to a value greater then 1.
281 #ifndef MAIN_HAS_NOARGC
282 -#define MAIN_HAS_NOARGC 0
283 +#define MAIN_HAS_NOARGC 1
286 /* Configuration : MAIN_HAS_NORETURN
288 1 - platform does not support returning a value from main
290 #ifndef MAIN_HAS_NORETURN
291 -#define MAIN_HAS_NORETURN 0
292 +#define MAIN_HAS_NORETURN 1
295 /* Variable : default_num_contexts
300 -int ee_printf(const char *fmt, ...);
302 #endif /* CORE_PORTME_H */
303 diff -u coremark_v1.0/Makefile coremark-stm8/Makefile
304 --- coremark_v1.0/Makefile 2009-07-10 19:48:43.000000000 +0200
305 +++ coremark-stm8/Makefile 2018-01-31 15:10:27.276856198 +0100
307 -#Author : Shay Gal-On, EEMBC
309 -#This file is part of EEMBC(R) and CoreMark(TM), which are Copyright (C) 2009
310 -#All rights reserved.
312 -#EEMBC CoreMark Software is a product of EEMBC and is provided under the terms of the
313 -#CoreMark License that is distributed with the official EEMBC COREMARK Software release.
314 -#If you received this EEMBC CoreMark Software without the accompanying CoreMark License,
315 -#you must discontinue use and download the official release from www.coremark.org.
317 -#Also, if you are publicly displaying scores generated from the EEMBC CoreMark software,
318 -#make sure that you are in compliance with Run and Reporting rules specified in the accompanying readme.txt file.
321 -#4354 Town Center Blvd. Suite 114-200
322 -#El Dorado Hills, CA, 95762
323 +SOURCES = core_list_join.c core_main.c core_matrix.c core_state.c core_util.c core_portme.c
324 +OBJ = $(SOURCES:.c=.rel)
329 -# Make sure the default target is to simply build and run the benchmark.
333 -run: $(OUTFILE) rerun score
336 - @echo "Check run1.log and run2.log for results."
337 - @echo "See readme.txt for run and reporting rules."
340 -# Ports for a couple of common self hosted platforms
341 -UNAME=$(shell if [[ `uname 2> /dev/null` ]] ; then uname ; fi)
342 -ifneq (,$(findstring CYGWIN,$(UNAME)))
345 -ifneq (,$(findstring Linux,$(UNAME)))
346 -MACHINE=$(shell uname -m)
347 -ifneq (,$(findstring 64,$(MACHINE)))
355 -$(error PLEASE define PORT_DIR! (e.g. make PORT_DIR=simple))
357 -vpath %.c $(PORT_DIR)
358 -vpath %.h $(PORT_DIR)
359 -vpath %.mak $(PORT_DIR)
360 -include $(PORT_DIR)/core_portme.mak
362 -ifndef $(ITERATIONS)
366 -FORCE_REBUILD=force_rebuild
369 -CFLAGS += -DITERATIONS=$(ITERATIONS)
371 -CORE_FILES = core_list_join core_main core_matrix core_state core_util
372 -ORIG_SRCS = $(addsuffix .c,$(CORE_FILES))
373 -SRCS = $(ORIG_SRCS) $(PORT_SRCS)
374 -OBJS = $(addprefix $(OPATH),$(addsuffix $(OEXT),$(CORE_FILES)) $(PORT_OBJS))
375 -OUTNAME = coremark$(EXE)
376 -OUTFILE = $(OPATH)$(OUTNAME)
377 -LOUTCMD = $(OFLAG) $(OUTFILE) $(LFLAGS_END)
378 -OUTCMD = $(OUTFLAG) $(OUTFILE) $(LFLAGS_END)
380 -HEADERS = coremark.h
381 -CHECK_FILES = $(ORIG_SRCS) $(HEADERS)
386 -.PHONY: compile link
387 -ifdef SEPARATE_COMPILE
388 -$(OPATH)$(PORT_DIR):
389 - $(MKDIR) $(OPATH)$(PORT_DIR)
391 -compile: $(OPATH) $(OPATH)$(PORT_DIR) $(OBJS) $(HEADERS)
393 - $(LD) $(LFLAGS) $(XLFLAGS) $(OBJS) $(LOUTCMD)
397 -compile: $(OPATH) $(SRCS) $(HEADERS)
398 - $(CC) $(CFLAGS) $(XCFLAGS) $(SRCS) $(OUTCMD)
400 - @echo "Link performed along with compile"
404 -$(OUTFILE): $(SRCS) $(HEADERS) Makefile core_portme.mak $(FORCE_REBUILD)
405 - $(MAKE) port_prebuild
407 - $(MAKE) port_postbuild
411 - $(MAKE) XCFLAGS="$(XCFLAGS) -DPERFORMANCE_RUN=1" load run1.log
412 - $(MAKE) XCFLAGS="$(XCFLAGS) -DVALIDATION_RUN=1" load run2.log
414 -PARAM1=$(PORT_PARAMS) 0x0 0x0 0x66 $(ITERATIONS)
415 -PARAM2=$(PORT_PARAMS) 0x3415 0x3415 0x66 $(ITERATIONS)
416 -PARAM3=$(PORT_PARAMS) 8 8 8 $(ITERATIONS)
418 -run1.log-PARAM=$(PARAM1) 7 1 2000
419 -run2.log-PARAM=$(PARAM2) 7 1 2000
420 -run3.log-PARAM=$(PARAM3) 7 1 1200
422 -run1.log run2.log run3.log: load
423 - $(MAKE) port_prerun
424 - $(RUN) $(OUTFILE) $($(@)-PARAM) > $(OPATH)$@
425 - $(MAKE) port_postrun
427 -.PHONY: gen_pgo_data
428 -gen_pgo_data: run3.log
432 - $(MAKE) port_preload
434 - $(MAKE) port_postload
438 - rm -f $(OUTFILE) $(OPATH)*.log *.info $(OPATH)index.html $(PORT_CLEAN)
439 + rm -f *.ihx *.lnk *.lst *.noi *.rel *.sym *.size *.dot *.lk *.rst *.asm
442 + $(SDCC) -c --std-c99 --fverbose-asm $(SDCCFLAGS) --fverbose-asm $< ||:
444 -.PHONY: force_rebuild
446 - echo "Forcing Rebuild"
450 - md5sum -c coremark.md5
452 + $(SDCC) $(SDCCFLAGS) *.rel -o Coremark.ihx
455 -# Targets related to testing and releasing CoreMark. Not part of the general release!
456 -include Makefile.internal