1 diff -u coremark_v1.0/core_main.c coremark-r3ka/core_main.c
2 --- coremark_v1.0/core_main.c 2009-08-25 20:11:26.000000000 +0200
3 +++ coremark-r3ka/core_main.c 2021-04-24 14:05:30.165120854 +0200
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");
27 /* And last call any target specific code for finalizing */
28 portable_fini(&(results[0].port));
32 return MAIN_RETURN_VAL;
34 diff -u coremark_v1.0/core_portme.c coremark-r3ka/core_portme.c
35 --- coremark_v1.0/core_portme.c 2021-04-24 12:00:51.953682684 +0200
36 +++ coremark-r3ka/core_portme.c 2021-04-24 12:28:28.405108427 +0200
38 Author : Shay Gal-On, EEMBC
44 -#include "core_portme.h"
46 +#define ITERATIONS 100
49 volatile ee_s32 seed1_volatile=0x3415;
51 e.g. Read value from on board RTC, read value from cpu clock cycles performance counter etc.
52 Sample implementation for standard time.h and windows.h definitions included.
54 -CORETIMETYPE barebones_clock() {
55 - #error "You must implement a method to measure time in barebones_clock()! This function should return current time.\n"
57 /* Define : TIMER_RES_DIVIDER
58 Divider to trade off timer resolution and total time that can be measured.
60 Use lower values to increase resolution, but make sure that overflow does not occur.
61 If there are issues with the return value overflowing, increase this value.
63 -#define GETMYTIME(_t) (*_t=barebones_clock())
64 +#define CLOCKS_PER_SEC 32768
65 +#define NSECS_PER_SEC CLOCKS_PER_SEC
66 +unsigned long clock(void);
67 +//#define CORETIMETYPE clock_t
68 +#define CORETIMETYPE unsigned long
69 +#define GETMYTIME(_t) (*_t=clock())
70 #define MYTIMEDIFF(fin,ini) ((fin)-(ini))
71 #define TIMER_RES_DIVIDER 1
72 #define SAMPLE_TIME_IMPLEMENTATION 1
73 -#define EE_TICKS_PER_SEC (CLOCKS_PER_SEC / TIMER_RES_DIVIDER)
74 +#define EE_TICKS_PER_SEC (NSECS_PER_SEC / TIMER_RES_DIVIDER)
76 /** Define Host specific (POSIX), or target specific global time variables. */
77 static CORETIMETYPE start_time_val, stop_time_val;
80 ee_u32 default_num_contexts=1;
84 /* Function : portable_init
85 Target specific initialization code
86 Test for some common mistakes.
88 void portable_init(core_portable *p, int *argc, char *argv[])
90 - #error "Call board initialization routines in portable init (if needed), in particular initialize UART!\n"
93 if (sizeof(ee_ptr_int) != sizeof(ee_u8 *)) {
94 ee_printf("ERROR! Please define ee_ptr_int to a type that holds a pointer!\n");
103 +#define REG(addr, reg) __sfr __at(addr) reg
105 +REG(0x00, GCSR); // global control / status register
106 +REG(0x01, RTCCR); // Real Time Clock Control Register
107 +REG(0x02, RTC0R); // Real Time Clock Data Register 0
108 +REG(0x03, RTC1R); // Real Time Clock Data Register 1
109 +REG(0x04, RTC2R); // Real Time Clock Data Register 2
110 +REG(0x05, RTC3R); // Real Time Clock Data Register 3
111 +REG(0x06, RTC4R); // Real Time Clock Data Register 4
112 +REG(0x07, RTC5R); // Real Time Clock Data Register 5
113 +REG(0x08, WDTCR); // watch-dog timer control register
114 +REG(0x09, WDTTR); // watch-dog timer test register
115 +REG(0x0F, GCDR); // global clock double register
116 +REG(0x14, MB0CR); // Memory Bank 0 Control Register
117 +REG(0x16, MB2CR); // Memory Bank 2 Control Register
118 +REG(0x55, PCFR); // Port C Function Register
119 +REG(0xA0, TACSR); // Timer A Control/Status Register
120 +REG(0xA9, TAT4R); // Timer A Time Constant 4 Register
121 +REG(0xC0, SADR); // Serial Port A Data Register
122 +REG(0xC3, SASR); // Serial Port A Status Register
123 +REG(0xC4, SACR); // Serial Port A Control Register
125 +void _sdcc_external_startup(void)
127 + // Disable watchdog
131 + // normal oscillator, processor and peripheral from main clock, no periodic interrupt
134 + GCDR = 0x07; // Double clock to get more speed
136 + // Configure memory wait states
137 + MB0CR = 0x88; // Flash - 1 wait state (for 45 ns Flash @ 44.2 MHz) with write-protection
138 + MB2CR = 0x85; // RAM - 1 wait states (for 55 ns RAM @ 44.2 MHz)
143 + PCFR = 0x40; // Use pin PC6 as TXA
144 + TAT4R = 36 - 1; // Use divider for 38400 baud - value in register is one less than the divider used (e.g. a value of 0 will result in clock division by 1).
145 + TACSR = 0x01; // Enable timer A
146 + SACR = 0x00; // No interrupts, 8-bit async mode
149 +unsigned long clock(void)
151 + unsigned long clock0, clock1;
155 + clock0 = ((unsigned long)(RTC0R) << 0) | ((unsigned long)(RTC1R) << 8) | ((unsigned long)(RTC2R) << 16) | ((unsigned long)(RTC3R) << 24);
156 + clock1 = ((unsigned long)(RTC0R) << 0) | ((unsigned long)(RTC1R) << 8) | ((unsigned long)(RTC2R) << 16) | ((unsigned long)(RTC3R) << 24);
157 + } while (clock0 != clock1);
161 +#if defined(__SDCC) && __SDCC_REVISION < 9624 // Old SDCC weirdness
162 +void putchar(char c)
164 + while (SASR & 0x04); // Wait for empty transmitter data register
170 + while (SASR & 0x04); // Wait for empty transmitter data register
176 diff -u coremark_v1.0/core_portme.h coremark-r3ka/core_portme.h
177 --- coremark_v1.0/core_portme.h 2021-04-24 12:00:51.953682684 +0200
178 +++ coremark-r3ka/core_portme.h 2021-04-24 12:08:35.390414932 +0200
180 Define to 1 if the platform supports floating point.
186 /* Configuration : HAS_TIME_H
187 Define to 1 if platform has the time.h header file,
188 and implementation of functions thereof.
191 -#define HAS_TIME_H 1
192 +#define HAS_TIME_H 0
194 /* Configuration : USE_CLOCK
195 Define to 1 if platform has the time.h header file,
196 and implementation of functions thereof.
202 /* Configuration : HAS_STDIO
203 Define to 1 if the platform has stdio.h.
205 Define to 1 if the platform has stdio.h and implements the printf function.
208 -#define HAS_PRINTF 0
209 +#define HAS_PRINTF 1
213 +/* Configuration : CORE_TICKS
214 + Define type of return from the timing functions.
217 +//typedef clock_t CORE_TICKS;
218 +unsigned long clock(void);
219 +typedef unsigned long CORE_TICKS;
220 /* Definitions : COMPILER_VERSION, COMPILER_FLAGS, MEM_LOCATION
221 Initialize these strings per platform
226 #ifndef COMPILER_FLAGS
227 - #define COMPILER_FLAGS FLAGS_STR /* "Please put compiler flags here (e.g. -o3)" */
228 + #define COMPILER_FLAGS "Please put compiler flags here (e.g. -o3)"
231 #define MEM_LOCATION "STACK"
234 ee_ptr_int needs to be the data type used to hold pointers, otherwise coremark may fail!!!
236 -typedef signed short ee_s16;
237 -typedef unsigned short ee_u16;
238 -typedef signed int ee_s32;
239 -typedef double ee_f32;
240 -typedef unsigned char ee_u8;
241 -typedef unsigned int ee_u32;
242 -typedef ee_u32 ee_ptr_int;
247 +typedef int16_t ee_s16;
248 +typedef uint16_t ee_u16;
249 +typedef int32_t ee_s32;
250 +typedef float ee_f32;
251 +typedef uint8_t ee_u8;
252 +typedef uint32_t ee_u32;
253 +typedef uintptr_t ee_ptr_int;
254 typedef size_t ee_size_t;
255 -#define NULL ((void *)0)
257 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.
259 #define align_mem(x) (void *)(4 + (((ee_ptr_int)(x) - 1) & ~3))
261 -/* Configuration : CORE_TICKS
262 - Define type of return from the timing functions.
264 -#define CORETIMETYPE ee_u32
265 -typedef ee_u32 CORE_TICKS;
267 /* Configuration : SEED_METHOD
268 Defines method to get seed values that cannot be computed at compile time.
271 This flag only matters if MULTITHREAD has been defined to a value greater then 1.
273 #ifndef MAIN_HAS_NOARGC
274 -#define MAIN_HAS_NOARGC 0
275 +#define MAIN_HAS_NOARGC 1
278 /* Configuration : MAIN_HAS_NORETURN
280 1 - platform does not support returning a value from main
282 #ifndef MAIN_HAS_NORETURN
283 -#define MAIN_HAS_NORETURN 0
284 +#define MAIN_HAS_NORETURN 1
287 /* Variable : default_num_contexts
292 -int ee_printf(const char *fmt, ...);
294 #endif /* CORE_PORTME_H */
295 diff -u coremark_v1.0/Makefile coremark-r3ka/Makefile
296 --- coremark_v1.0/Makefile 2009-07-10 19:48:43.000000000 +0200
297 +++ coremark-r3ka/Makefile 2021-04-24 11:59:52.296562209 +0200
299 -#Author : Shay Gal-On, EEMBC
301 -#This file is part of EEMBC(R) and CoreMark(TM), which are Copyright (C) 2009
302 -#All rights reserved.
304 -#EEMBC CoreMark Software is a product of EEMBC and is provided under the terms of the
305 -#CoreMark License that is distributed with the official EEMBC COREMARK Software release.
306 -#If you received this EEMBC CoreMark Software without the accompanying CoreMark License,
307 -#you must discontinue use and download the official release from www.coremark.org.
309 -#Also, if you are publicly displaying scores generated from the EEMBC CoreMark software,
310 -#make sure that you are in compliance with Run and Reporting rules specified in the accompanying readme.txt file.
313 -#4354 Town Center Blvd. Suite 114-200
314 -#El Dorado Hills, CA, 95762
315 +SOURCES = core_list_join.c core_main.c core_matrix.c core_state.c core_util.c core_portme.c
316 +OBJ = $(SOURCES:.c=.rel)
321 -# Make sure the default target is to simply build and run the benchmark.
325 -run: $(OUTFILE) rerun score
328 - @echo "Check run1.log and run2.log for results."
329 - @echo "See readme.txt for run and reporting rules."
332 -# Ports for a couple of common self hosted platforms
333 -UNAME=$(shell if [[ `uname 2> /dev/null` ]] ; then uname ; fi)
334 -ifneq (,$(findstring CYGWIN,$(UNAME)))
337 -ifneq (,$(findstring Linux,$(UNAME)))
338 -MACHINE=$(shell uname -m)
339 -ifneq (,$(findstring 64,$(MACHINE)))
347 -$(error PLEASE define PORT_DIR! (e.g. make PORT_DIR=simple))
349 -vpath %.c $(PORT_DIR)
350 -vpath %.h $(PORT_DIR)
351 -vpath %.mak $(PORT_DIR)
352 -include $(PORT_DIR)/core_portme.mak
354 -ifndef $(ITERATIONS)
358 -FORCE_REBUILD=force_rebuild
361 -CFLAGS += -DITERATIONS=$(ITERATIONS)
363 -CORE_FILES = core_list_join core_main core_matrix core_state core_util
364 -ORIG_SRCS = $(addsuffix .c,$(CORE_FILES))
365 -SRCS = $(ORIG_SRCS) $(PORT_SRCS)
366 -OBJS = $(addprefix $(OPATH),$(addsuffix $(OEXT),$(CORE_FILES)) $(PORT_OBJS))
367 -OUTNAME = coremark$(EXE)
368 -OUTFILE = $(OPATH)$(OUTNAME)
369 -LOUTCMD = $(OFLAG) $(OUTFILE) $(LFLAGS_END)
370 -OUTCMD = $(OUTFLAG) $(OUTFILE) $(LFLAGS_END)
372 -HEADERS = coremark.h
373 -CHECK_FILES = $(ORIG_SRCS) $(HEADERS)
378 -.PHONY: compile link
379 -ifdef SEPARATE_COMPILE
380 -$(OPATH)$(PORT_DIR):
381 - $(MKDIR) $(OPATH)$(PORT_DIR)
383 -compile: $(OPATH) $(OPATH)$(PORT_DIR) $(OBJS) $(HEADERS)
385 - $(LD) $(LFLAGS) $(XLFLAGS) $(OBJS) $(LOUTCMD)
389 -compile: $(OPATH) $(SRCS) $(HEADERS)
390 - $(CC) $(CFLAGS) $(XCFLAGS) $(SRCS) $(OUTCMD)
392 - @echo "Link performed along with compile"
396 -$(OUTFILE): $(SRCS) $(HEADERS) Makefile core_portme.mak $(FORCE_REBUILD)
397 - $(MAKE) port_prebuild
399 - $(MAKE) port_postbuild
403 - $(MAKE) XCFLAGS="$(XCFLAGS) -DPERFORMANCE_RUN=1" load run1.log
404 - $(MAKE) XCFLAGS="$(XCFLAGS) -DVALIDATION_RUN=1" load run2.log
406 -PARAM1=$(PORT_PARAMS) 0x0 0x0 0x66 $(ITERATIONS)
407 -PARAM2=$(PORT_PARAMS) 0x3415 0x3415 0x66 $(ITERATIONS)
408 -PARAM3=$(PORT_PARAMS) 8 8 8 $(ITERATIONS)
410 -run1.log-PARAM=$(PARAM1) 7 1 2000
411 -run2.log-PARAM=$(PARAM2) 7 1 2000
412 -run3.log-PARAM=$(PARAM3) 7 1 1200
414 -run1.log run2.log run3.log: load
415 - $(MAKE) port_prerun
416 - $(RUN) $(OUTFILE) $($(@)-PARAM) > $(OPATH)$@
417 - $(MAKE) port_postrun
419 -.PHONY: gen_pgo_data
420 -gen_pgo_data: run3.log
424 - $(MAKE) port_preload
426 - $(MAKE) port_postload
430 - rm -f $(OUTFILE) $(OPATH)*.log *.info $(OPATH)index.html $(PORT_CLEAN)
431 + rm -f *.ihx *.lnk *.lst *.noi *.rel *.sym *.size *.dot *.lk *.rst *.asm
434 + $(SDCC) -c --std-c99 --fverbose-asm $(SDCCFLAGS) --fverbose-asm $< ||:
436 -.PHONY: force_rebuild
438 - echo "Forcing Rebuild"
442 - md5sum -c coremark.md5
444 + $(SDCC) $(SDCCFLAGS) *.rel -o Coremark.ihx
447 -# Targets related to testing and releasing CoreMark. Not part of the general release!
448 -include Makefile.internal