Skip to content

Commit 79866d2

Browse files
committed
Update benchmark scripts
1 parent 41434fd commit 79866d2

File tree

6 files changed

+102
-73
lines changed

6 files changed

+102
-73
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ Docker was the first containerization platform and still is the most widely used
1010

1111
## Run the Lab Environment
1212

13-
### 1) Using Docker Engine
13+
### 1) Using Container Engine
1414

15-
> :warning: You need [Docker Engine](https://docs.docker.com/engine/) installed on your system to proceed. You can install the engine for Ubuntu by following [installation steps](https://docs.docker.com/engine/install/ubuntu/). You can also follow [post-installation steps](https://docs.docker.com/engine/install/linux-postinstall/) to run `docker` without `sudo`.
15+
> :warning: You need [Docker Engine](https://docs.docker.com/engine/) or []installed on your system to proceed. You can install the engine for Ubuntu by following [installation steps](https://docs.docker.com/engine/install/ubuntu/). You can also follow [post-installation steps](https://docs.docker.com/engine/install/linux-postinstall/) to run `docker` without `sudo`.
1616
1717
> :warning: Windows users need to use Docker Desktop with WSL2 backend. See [the installation steps](https://docs.docker.com/desktop/install/windows-install/).
1818

benchmarks/coremark/Makefile

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
11
# Wally Coremark Makefile
2-
# Daniel Torres & David Harris 28 July 2022
3-
# Dogan Ulus 2025
2+
# SPDX-FileCopyrightText: 2022 Daniel Torres, David Harris
3+
# SPDX-FileCopyrightText: 2025 Dogan Ulus
44
# SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1
55

6+
.PHONY: clean
7+
68
WALLY ?= /opt/openhwgroup/cvw
7-
LABS344 ?= /workspaces/labs344
8-
9-
PORT_DIR = ${WALLY}/benchmarks/coremark/riscv64-baremetal
10-
cmbase= ${WALLY}/addins/coremark
11-
work_dir= ${LABS344}/benchmarks/coremark/work
12-
XLEN ?=32
13-
sources=$(cmbase)/core_main.c $(cmbase)/core_list_join.c $(cmbase)/coremark.h \
14-
$(cmbase)/core_matrix.c $(cmbase)/core_state.c $(cmbase)/core_util.c \
15-
$(PORT_DIR)/core_portme.h $(PORT_DIR)/core_portme.c $(PORT_DIR)/core_portme.mak \
16-
$(PORT_DIR)/crt.S $(PORT_DIR)/encoding.h $(PORT_DIR)/util.h $(PORT_DIR)/syscalls.c
17-
ABI := $(if $(findstring "64","$(XLEN)"),lp64,ilp32)
18-
ARCH := rv$(XLEN)im_zicsr_zba_zbb_zbs
9+
LABS344_DIR ?= /workspaces/labs344
10+
11+
COREMARK_BASEDIR = ${WALLY}/addins/coremark
12+
COREMARK_PORTDIR = ${WALLY}/benchmarks/coremark/riscv64-baremetal
13+
COREMARK_TMPDIR = ${LABS344_DIR}/benchmarks/coremark/work
14+
15+
CC = riscv64-unknown-elf-gcc
16+
LD = riscv64-unknown-elf-ld
17+
18+
ARCH := rv32gc
19+
XLEN := $(if $(findstring 32,$(ARCH)),32,64)
20+
ABI := $(if $(findstring 64,$(XLEN)),lp64,ilp32)
1921
CONFIG := rv$(XLEN)gc
20-
#ARCH := rv$(XLEN)gc
21-
#ARCH := rv$(XLEN)imc_zicsr
22-
#ARCH := rv$(XLEN)im_zicsr
23-
#ARCH := rv$(XLEN)i_zicsr
22+
23+
sources=$(COREMARK_BASEDIR)/core_main.c $(COREMARK_BASEDIR)/core_list_join.c $(COREMARK_BASEDIR)/coremark.h \
24+
$(COREMARK_BASEDIR)/core_matrix.c $(COREMARK_BASEDIR)/core_state.c $(COREMARK_BASEDIR)/core_util.c \
25+
$(COREMARK_PORTDIR)/core_portme.h $(COREMARK_PORTDIR)/core_portme.c $(COREMARK_PORTDIR)/core_portme.mak \
26+
$(COREMARK_PORTDIR)/crt.S $(COREMARK_PORTDIR)/encoding.h $(COREMARK_PORTDIR)/util.h $(COREMARK_PORTDIR)/syscalls.c
2427

2528
PORT_CFLAGS = -g -mabi=$(ABI) -march=$(ARCH) -static -falign-functions=16 \
2629
-mbranch-cost=1 -DSKIP_DEFAULT_MEMSET -mtune=sifive-3-series -O3 -finline-functions -falign-jumps=4 \
@@ -29,26 +32,22 @@ PORT_CFLAGS = -g -mabi=$(ABI) -march=$(ARCH) -static -falign-functions=16 \
2932
-nostdlib -nostartfiles -ffreestanding -mstrict-align \
3033
-DTOTAL_DATA_SIZE=2000 -DMAIN_HAS_NOARGC=1 -DPERFORMANCE_RUN=1 -DITERATIONS=10 -DXLEN=$(XLEN)
3134

32-
all: $(work_dir)/coremark.bare.riscv.elf.memfile
35+
all: $(COREMARK_TMPDIR)/coremark.bare.riscv.elf.memfile
3336

34-
run: $(work_dir)/coremark.bare.riscv.elf.memfile
35-
# python3 ${LABS344}/bin/wsim --sim verilator ${CONFIG} coremark 2>&1 | tee $(work_dir)/coremark.sim.log
36-
make -C ${LABS344}/sim/verilator WALLYCONF=${CONFIG} TEST=coremark TESTBENCH=testbench
37+
run: $(COREMARK_TMPDIR)/coremark.bare.riscv.elf.memfile
38+
make -C ${LABS344_DIR}/sim/verilator WALLYCONF=${CONFIG} TEST=coremark TESTBENCH=testbench
3739

38-
$(work_dir)/coremark.bare.riscv.elf.memfile: $(work_dir)/coremark.bare.riscv
40+
$(COREMARK_TMPDIR)/coremark.bare.riscv.elf.memfile: $(COREMARK_TMPDIR)/coremark.bare.riscv
3941
riscv64-unknown-elf-objdump -D $< > $<.elf.objdump
4042
riscv64-unknown-elf-elf2hex --bit-width $(XLEN) --input $< --output $@
4143
${WALLY}/bin/extractFunctionRadix.sh $<.elf.objdump
4244

43-
$(work_dir)/coremark.bare.riscv: $(sources) Makefile
44-
$(MAKE) -C $(cmbase) PORT_DIR=$(PORT_DIR) compile RISCV=$(RISCV) XCFLAGS="$(PORT_CFLAGS)"
45-
mkdir -p $(work_dir)
46-
mv $(cmbase)/coremark.bare.riscv $(work_dir)
47-
48-
.PHONY: clean
45+
$(COREMARK_TMPDIR)/coremark.bare.riscv: $(sources) Makefile
46+
$(MAKE) -C $(COREMARK_BASEDIR) PORT_DIR=$(COREMARK_PORTDIR) compile RISCV=$(RISCV) XCFLAGS="$(PORT_CFLAGS)"
47+
mkdir -p $(COREMARK_TMPDIR)
48+
mv $(COREMARK_BASEDIR)/coremark.bare.riscv $(COREMARK_TMPDIR)
4949

5050
clean:
51-
$(MAKE) -C $(cmbase) clean
52-
rm -f $(work_dir)/*
53-
54-
51+
rm -rf $(COREMARK_TMPDIR)
52+
$(MAKE) -C $(COREMARK_BASEDIR) clean
53+
$(MAKE) -C ${LABS344_DIR}/sim/verilator clean

benchmarks/coremark/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Wally Coremark Tests
2+
3+
This directory provides build and run scripts to execute the **Coremark benchmark** on the Wally RISC-V cores.
4+
It supports multiple RISC-V ISA configurations for both 32-bit and 64-bit variants.
5+
6+
## Running Tests
7+
8+
To build and run Coremark with a specific architecture:
9+
10+
```bash
11+
make run ARCH=rv32gc
12+
```
13+
14+
## Supported architectures
15+
16+
The following RISC-V ISA configurations are currently supported:
17+
18+
- rv32i_zicsr
19+
- rv32im_zicsr
20+
- rv32imc_zicsr
21+
- rv32im_zicsr_zba_zbb_zbs
22+
- rv32gc
23+
- rv32gc_zba_zbb_zbs
24+
- rv64i_zicsr
25+
- rv64im_zicsr
26+
- rv64imc_zicsr
27+
- rv64im_zicsr_zba_zbb_zbs
28+
- rv64gc
29+
- rv64gc_zba_zbb_zbs
30+
31+
## Notes
32+
33+
- Benchmark results may differ across architectures due to instruction set extensions and optimization differences.

containers/labs344/Dockerfile

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -117,32 +117,6 @@ RUN git clone https://github.com/riscv-software-src/riscv-isa-sim \
117117
make install && \
118118
rm -rf /tmp/riscv-isa-sim
119119

120-
# RUN git clone https://github.com/verilator/verilator \
121-
# --no-checkout \
122-
# /tmp/verilator \
123-
# &&\
124-
# cd /tmp/verilator && \
125-
# git checkout ${VERILATOR_VERSION} && \
126-
# cmake -S . -B build -G Ninja \
127-
# -DCMAKE_INSTALL_PREFIX=/usr/local \
128-
# -DCMAKE_BUILD_TYPE=Release \
129-
# && \
130-
# cmake --build build -j"$(nproc)" && \
131-
# cmake --install build && \
132-
# rm -rf /tmp/verilator
133-
134-
# RUN git clone "https://github.com/verilator/verilator" \
135-
# --no-checkout \
136-
# /tmp/verilator \
137-
# &&\
138-
# cd /tmp/verilator && \
139-
# git checkout ${VERILATOR_VERSION} && \
140-
# autoconf && \
141-
# ./configure --prefix="/usr/local" && \
142-
# make -j "$(nproc)" && \
143-
# make install && \
144-
# rm -rf /tmp/verilator
145-
146120
FROM labs344-base as labs344-runtime
147121
ARG TARGETARCH TARGETOS TARGETPLATFORM TARGETVARIANT
148122

@@ -156,11 +130,7 @@ COPY --from=labs344-toolchain ${RISCV_INSTALL_PREFIX} ${RISCV_INSTALL_PREFIX}
156130
COPY --from=labs344-toolchain /usr/local /usr/local
157131

158132
ENV WALLY_SOURCE_DIR=/opt/openhwgroup/cvw
159-
160-
ENV LABS344_HOME=/root
161133
ENV LABS344_SOURCE_DIR=/workspaces/labs344
162-
ENV LABS344_PYTHON_VENV_DIR=${LABS344_HOME}/.venv/labs344
163-
ENV LABS344_PYTHON_EXECUTABLE=${LABS344_PYTHON_VENV_DIR}/bin/python
164134

165135
# Aliases used in Wally scripts
166136
ENV RISCV=${RISCV_INSTALL_PREFIX}

sim/verilator/Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Verilator Makefile for WALLY
2-
# Kunlin Han, Rose Thompson, David Harris 2024
2+
# SPDX-FileCopyrightText: 2024 Kunlin Han, Rose Thompson, David Harris
3+
# SPDX-FileCopyrightText: 2025 Dogan Ulus
34
# SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1
45

5-
SHELL := /bin/bash
66
WALLY ?= /opt/openhwgroup/cvw
77
LABS344 ?= /workspaces/labs344
88

@@ -12,7 +12,7 @@ LABS344 ?= /workspaces/labs344
1212
OPT=--assert
1313
PARAMS?=--no-trace-top
1414
NONPROF?=--stats
15-
VERILATOR_DIR=${LABS344}/sim/verilator
15+
VERILATOR_DIR=${WALLY}/sim/verilator
1616
PLUS_ARGS=
1717
PARAM_ARGS=
1818
DEFINE_ARGS=
@@ -25,13 +25,13 @@ TESTBENCH?=testbench
2525
# constants
2626
# assume WALLY variable is correctly configured in the shell environment
2727
# INCLUDE_PATH are paths that Verilator should search for files it needs
28-
INCLUDE_PATH="-I${WALLY}/config/shared" "-I${WALLY}/config/$(WALLYCONF)" "-I${WALLY}/config/deriv/$(WALLYCONF)" "-I/usr/share/verilator/include"
28+
INCLUDE_PATH="-I${WALLY}/config/shared" "-I${WALLY}/config/$(WALLYCONF)" "-I${WALLY}/config/deriv/$(WALLYCONF)"
2929
# SOURCES are source files
3030
SOURCES=${WALLY}/src/cvw.sv ${WALLY}/testbench/${TESTBENCH}.sv ${WALLY}/testbench/common/*.sv ${WALLY}/src/*/*.sv ${WALLY}/src/*/*/*.sv ${WALLY}/addins/verilog-ethernet/*/*.sv ${WALLY}/addins/verilog-ethernet/*/*/*/*.sv
3131
# DEPENDENCIES are configuration files and source files, which leads to recompilation of executables
3232
DEPENDENCIES=${WALLY}/config/shared/*.vh $(SOURCES)
3333

34-
WORKDIR = $(VERILATOR_DIR)/wkdir/$(WALLYCONF)_$(TEST)
34+
WORKDIR = /tmp/verilator/$(WALLYCONF)_$(TEST)
3535

3636
# regular testbench requires a wrapper defining getenvval
3737
ifeq ($(TESTBENCH), testbench)

tutorials/fibonacci/README.md

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ The `fibonacci.elf` is a binary executable in the ELF format, containing the RIS
3030
Disassembling the ELF file means we convert the binary file `fibonacci.elf` in a human-readable textual file. We can disassemble ELF objects and executable using the program `objdump` as follows:
3131

3232
```bash
33-
riscv64-unknown-elf-objdump --disassemble fibonacci.elf > fibonacci.txt
33+
riscv64-unknown-elf-objdump --disassemble fibonacci.elf > fibonacci.objdump
3434
```
3535

36-
Now check out the contents of `fibonacci.txt`, which is a plain text file, in your text editor. It should look like this:
36+
Now check out the contents of `fibonacci.objdump`, which is a plain text file, in your text editor. It should look like this:
3737

3838
```
3939
fibonacci.elf: file format elf32-littleriscv
@@ -64,7 +64,34 @@ Disassembly of section .text:
6464
100d4: 0000006f j 100d4 <DONE>
6565
```
6666

67-
The `fibonacci.txt` file is a disassembled version of our assembled code. It provides a more detailed view of the instructions and data, including the assigned memory addresses and the substitution of pseudo-instructions with their corresponding RISC-V machine code. These changes are performed by the assembler during the compilation process.
67+
The `fibonacci.objdump` file is a disassembled version of our assembled code. It provides a more detailed view of the instructions and data, including the assigned memory addresses and the substitution of pseudo-instructions with their corresponding RISC-V machine code. These changes are performed by the assembler during the compilation process.
68+
69+
## Simulate using Spike
70+
71+
Our desktop computers typically use `x86_64` processors, which are incompatible with RISC-V executables like `fibonacci.elf`. If you have a computer equipped with a RISC-V processor, you can directly execute `fibonacci.elf` on it.
72+
73+
For those using `x86-64` or `arm64` processors, it is possible to simulate RISC-V executables using RISC-V ISA simulators. The `spike` simulator is a production-grade RISC-V ISA simulator available in our lab's development environment. Please check its installation by running the following command:
74+
75+
```bash
76+
spike --help
77+
```
78+
79+
If you see `spike` help text, everything is set up correctly.
80+
81+
We first use the simulator in the interactive mode, where we can instruct commands to the simulator one by one. To start the simulation of `fibonacci.elf` in the interactive mode, please run the command in your terminal as follows:
82+
83+
```
84+
spike -d fibonacci.elf
85+
```
86+
87+
Now you are in the interactive shell where you can give commands to the simulator. You can find the most commonly used commands for `spike` in the following table.
88+
89+
90+
| Interactive commands | Description |
91+
|--------------------------|------------------------------------------------------------|
92+
| `[<ENTER>]` | Proceed 1 steps. |
93+
| `run [<N>]` or `r [<N>]` | Proceed `N` steps, default is 1. |
94+
6895

6996
## Simulate using Whisper
7097

0 commit comments

Comments
 (0)