From 1e8a88b052b32183f26eebb445e4f94fdb16e05d Mon Sep 17 00:00:00 2001 From: Brooks Davis Date: Mon, 20 Jan 2020 14:06:37 +0000 Subject: [PATCH] Support systems with 128-bit pointers. In order to allow meaningful comparisons between 32- and 64-bit systems, core_list_init hardcodes the size of pointers to be 8 bytes. This controls the number list elements allocated for a buffer of a given size. On a system with 128-bit pointers this results in data corruption as the list data is written over list_head objects. Address this by adding a POINTER_SPACE define which can be changed to 16. Update the checksums in the known_crc arrays for the run1.log and run2.log cases. --- Makefile | 4 ++++ core_list_join.c | 2 +- core_main.c | 11 +++++++++++ coremark.h | 5 +++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5f90912..973ccdf 100644 --- a/Makefile +++ b/Makefile @@ -68,6 +68,10 @@ OUTCMD = $(OUTFLAG) $(OUTFILE) $(LFLAGS_END) HEADERS = coremark.h CHECK_FILES = $(ORIG_SRCS) $(HEADERS) +ifdef POINTER_SPACE +CFLAGS+= -DPOINTER_SPACE=$(POINTER_SPACE) +endif + $(OPATH): $(MKDIR) $(OPATH) diff --git a/core_list_join.c b/core_list_join.c index a515428..4a78b58 100644 --- a/core_list_join.c +++ b/core_list_join.c @@ -211,7 +211,7 @@ ee_u16 core_bench_list(core_results *res, ee_s16 finder_idx) { */ list_head *core_list_init(ee_u32 blksize, list_head *memblock, ee_s16 seed) { /* calculated pointers for the list */ - ee_u32 per_item=16+sizeof(struct list_data_s); + ee_u32 per_item=(2*POINTER_SPACE)+sizeof(struct list_data_s); ee_u32 size=(blksize/per_item)-2; /* to accomodate systems with 64b pointers, and make sure same code is executed, set max list elements */ list_head *memblock_end=memblock+size; list_data *datablock=(list_data *)(memblock_end); diff --git a/core_main.c b/core_main.c index 6161974..9e197d7 100644 --- a/core_main.c +++ b/core_main.c @@ -32,9 +32,19 @@ Original Author: Shay Gal-on Returns: NULL. */ +#if POINTER_SPACE == 8 static ee_u16 list_known_crc[] = {(ee_u16)0xd4b0,(ee_u16)0x3340,(ee_u16)0x6a79,(ee_u16)0xe714,(ee_u16)0xe3c1}; static ee_u16 matrix_known_crc[] = {(ee_u16)0xbe52,(ee_u16)0x1199,(ee_u16)0x5608,(ee_u16)0x1fd7,(ee_u16)0x0747}; static ee_u16 state_known_crc[] = {(ee_u16)0x5e47,(ee_u16)0x39bf,(ee_u16)0xe5a4,(ee_u16)0x8e3a,(ee_u16)0x8d84}; +#elif POINTER_SPACE == 16 +/* Reference CRCs from amd64 */ +/* FIXME, cases 0-2 need updating */ +static ee_u16 list_known_crc[] = {(ee_u16)0,(ee_u16)0,(ee_u16)0,(ee_u16)0x70a5,(ee_u16)0x6329}; +static ee_u16 matrix_known_crc[] = {(ee_u16)0,(ee_u16)0,(ee_u16)0,(ee_u16)0xdb4b,(ee_u16)0xbf03}; +static ee_u16 state_known_crc[] = {(ee_u16)0,(ee_u16)0,(ee_u16)0,(ee_u16)0x905f,(ee_u16)0x5735}; +#else +#error Unhandled POINTER_SPACE value +#endif void *iterate(void *pres) { ee_u32 i; ee_u16 crc; @@ -284,6 +294,7 @@ MAIN_RETURN_TYPE main(int argc, char *argv[]) { } total_errors+=check_data_types(); /* and report results */ + ee_printf("Pointer space : %d\n", POINTER_SPACE); ee_printf("CoreMark Size : %lu\n", (long unsigned) results[0].size); ee_printf("Total ticks : %lu\n", (long unsigned) total_time); #if HAS_FLOAT diff --git a/coremark.h b/coremark.h index dc9f8c7..7fbcfef 100644 --- a/coremark.h +++ b/coremark.h @@ -65,6 +65,11 @@ typedef ee_u32 secs_ret; #define MAIN_RETURN_TYPE int #endif +#ifndef POINTER_SPACE +/* Reserve 64b per pointer */ +#define POINTER_SPACE 8 +#endif + void start_time(void); void stop_time(void); CORE_TICKS get_time(void);