Skip to content

Commit

Permalink
Port coremark to FRISCV
Browse files Browse the repository at this point in the history
  • Loading branch information
dpretet committed Dec 9, 2023
1 parent 8c878e7 commit 1b356f0
Show file tree
Hide file tree
Showing 25 changed files with 4,627 additions and 886 deletions.
25 changes: 25 additions & 0 deletions doc/perf_benchmark.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,28 @@ Algorithms:
- Printf execution: 49904 cycles
- Xoshiro128++ execution: 236723 cycles
- Pool Arena execution: 1640273 cycles

# 231201

First coremark run!

10 iterations within

2K performance run parameters for coremark.
CoreMark Size : 666
Total ticks : 22799229
Total time (secs): 22
Iterations/Sec : 0
Iterations : 10
Compiler version : GCC11.1.0
Compiler flags : -O0 -g
Memory location : STACK
seedcrc : 0xe9f5
[0]crclist : 0xe714
[0]crcmatrix : 0x1fd7
[0]crcstate : 0x8e3a
[0]crcfinal : 0xfcaf

22799229 * 2 = 45598458 ns = 45 ms pour 10 iterations @ 500 MHz

10 / 0.045ms = 222 => * 1000 = 222000 => / 500MHz = 444 coremarks / MHz
2 changes: 1 addition & 1 deletion doc/project_mgt_hw.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DOING

- [ ] v1.6.0: Kernel-capable Hart
- [ ] Kernel-capable Hart
- [X] Supporter des set de config du core en test bench.
- [X] Support U-mode
- [X] Support PMP/PMA
Expand Down
5 changes: 3 additions & 2 deletions test/apps/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ TIMEOUT=0
MIN_PC=65692

# Don't drop VCD, to avoid storing GB of raw data
NO_VCD=0
NO_VCD=1

# Enable UART link to the processor (platform only)
INTERACTIVE=1
Expand All @@ -38,6 +38,7 @@ TRACE_BLOCKS=0
TRACE_FETCHER=0
TRACE_PUSHER=0
TRACE_TB_RAM=0
TRACE_REGISTERS=0

# Disable external IRQ generation
GEN_EIRQ=0
Expand Down Expand Up @@ -92,7 +93,7 @@ main() {
for dir in tests/*/; do
if [ "$dir" != "tests/common/" ]; then
echo "INFO: Compile $dir"
make -C "$dir";
make -C "$dir" all;
fi
done

Expand Down
1,276 changes: 1,276 additions & 0 deletions test/apps/tests/coremark.v

Large diffs are not rendered by default.

89 changes: 51 additions & 38 deletions test/apps/tests/coremark/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# Original Author: Shay Gal-on

# Make sure the default target is to simply build and run the benchmark.
Expand All @@ -22,39 +22,34 @@ run: $(OUTFILE) rerun score

score:
@echo "Check run1.log and run2.log for results."
@echo "See README.md for run and reporting rules."

ifndef PORT_DIR
# Ports for a couple of common self hosted platforms
UNAME=$(shell if command -v uname 2> /dev/null; then uname ; fi)
ifneq (,$(findstring CYGWIN,$(UNAME)))
PORT_DIR=cygwin
endif
ifneq (,$(findstring Darwin,$(UNAME)))
PORT_DIR=macos
endif
ifneq (,$(findstring FreeBSD,$(UNAME)))
PORT_DIR=freebsd
endif
ifneq (,$(findstring Linux,$(UNAME)))
PORT_DIR=linux
endif
endif
ifndef PORT_DIR
$(error PLEASE define PORT_DIR! (e.g. make PORT_DIR=simple))
endif
@echo "See README.md for run and reporting rules."

PORT_DIR=barebones

vpath %.c $(PORT_DIR)
vpath %.S $(PORT_DIR)
vpath %.h $(PORT_DIR)
vpath %.mak $(PORT_DIR)
include $(PORT_DIR)/core_portme.mak

ifndef ITERATIONS
ITERATIONS=0
endif
ITERATIONS=10

ifdef REBUILD
FORCE_REBUILD=force_rebuild
endif

# Select architecure and ABI
CFLAGS += -march=rv32im \
-mabi=ilp32 \
-O0 \
-g \
-I./ \
-I./barebones \
-I$(RISCV_CLIB) \
-mcmodel=medany \
-static \
-std=gnu99 \

CFLAGS += -DITERATIONS=$(ITERATIONS)

CORE_FILES = core_list_join core_main core_matrix core_state core_util
Expand All @@ -65,8 +60,9 @@ OUTNAME = coremark$(EXE)
OUTFILE = $(OPATH)$(OUTNAME)
LOUTCMD = $(OFLAG) $(OUTFILE) $(LFLAGS_END)
OUTCMD = $(OUTFLAG) $(OUTFILE) $(LFLAGS_END)
CRT = ./crt0.S

HEADERS = coremark.h
HEADERS = coremark.h
CHECK_FILES = $(ORIG_SRCS) $(HEADERS)

$(OPATH):
Expand All @@ -77,26 +73,42 @@ ifdef SEPARATE_COMPILE
$(OPATH)$(PORT_DIR):
$(MKDIR) $(OPATH)$(PORT_DIR)

compile: $(OPATH) $(OPATH)$(PORT_DIR) $(OBJS) $(HEADERS)
link: compile
compile: $(OPATH) $(OPATH)$(PORT_DIR) $(OBJS) $(HEADERS)
link: compile
$(LD) $(LFLAGS) $(XLFLAGS) $(OBJS) $(LOUTCMD)

@echo "Link NOT performed along with compile"

else

compile: $(OPATH) $(SRCS) $(HEADERS)
$(CC) $(CFLAGS) $(XCFLAGS) $(SRCS) $(OUTCMD)
link: compile
#$(PROJ_NAME).elf: compile

compile: $(OPATH) $(SRCS) $(HEADERS)
$(RISCV_CC) -c $(CFLAGS) -o ctr0.o $(CRT) -D__ASSEMBLY__=1
$(CC) $(CFLAGS) $(XCFLAGS) $(SRCS) ctr0.o $(OUTCMD) $(LDFLAGS)
link: compile
@echo "Link performed along with compile"

endif

########################################################
all: $(OUTFILE)
$(RISCV_OBJCOPY) -O ihex $(PROJ_NAME).elf $(PROJ_NAME).hex
$(RISCV_OBJCOPY) -O binary $(PROJ_NAME).elf $(PROJ_NAME).bin
$(RISCV_OBJCOPY) -O verilog $(PROJ_NAME).elf $(PROJ_NAME).v
$(RISCV_OBJDUMP) -S -d $(PROJ_NAME).elf > $(PROJ_NAME).asm
@cp *.v ../
$(RISCV_NM) *.elf > $(PROJ_NAME).symbols
@cp *.symbols ../
@echo "done"
########################################################

$(OUTFILE): $(SRCS) $(HEADERS) Makefile core_portme.mak $(EXTRA_DEPENDS) $(FORCE_REBUILD)
$(MAKE) port_prebuild
$(MAKE) link
$(MAKE) port_postbuild

.PHONY: rerun
rerun:
rerun:
$(MAKE) XCFLAGS="$(XCFLAGS) -DPERFORMANCE_RUN=1" load run1.log
$(MAKE) XCFLAGS="$(XCFLAGS) -DVALIDATION_RUN=1" load run2.log

Expand All @@ -105,14 +117,14 @@ PARAM2=$(PORT_PARAMS) 0x3415 0x3415 0x66 $(ITERATIONS)
PARAM3=$(PORT_PARAMS) 8 8 8 $(ITERATIONS)

run1.log-PARAM=$(PARAM1) 7 1 2000
run2.log-PARAM=$(PARAM2) 7 1 2000
run2.log-PARAM=$(PARAM2) 7 1 2000
run3.log-PARAM=$(PARAM3) 7 1 1200

run1.log run2.log run3.log: load
$(MAKE) port_prerun
$(RUN) $(OUTFILE) $($(@)-PARAM) > $(OPATH)$@
$(MAKE) port_postrun

.PHONY: gen_pgo_data
gen_pgo_data: run3.log

Expand All @@ -125,16 +137,17 @@ load: $(OUTFILE)
.PHONY: clean
clean:
rm -f $(OUTFILE) $(OBJS) $(OPATH)*.log *.info $(OPATH)index.html $(PORT_CLEAN)
rm -f *.elf $(PROJ_NAME) *.map *.bin *.md5 *.hex *.v *.asm *.symbols

.PHONY: force_rebuild
force_rebuild:
echo "Forcing Rebuild"

.PHONY: check
check:
md5sum -c coremark.md5
md5sum -c coremark.md5

ifdef ETC
# Targets related to testing and releasing CoreMark. Not part of the general release!
include Makefile.internal
endif
endif
Loading

0 comments on commit 1b356f0

Please sign in to comment.