Skip to content

Commit

Permalink
sw: Add generic offload app
Browse files Browse the repository at this point in the history
  • Loading branch information
colluca committed Aug 30, 2023
1 parent 7e0e812 commit 1a3ab98
Show file tree
Hide file tree
Showing 23 changed files with 313 additions and 371 deletions.
33 changes: 19 additions & 14 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,32 @@ docs:
script:
- mkdocs build

#########################
# Build Occamy software #
#########################

occamy-single-cluster-sw:
script:
- cd target/sim
- make CFG_OVERRIDE=cfg/single-cluster.hjson sw
artifacts:
paths:
- target/sim/sw/**/build/*.elf
expire_in: 1 day

###############################
# Single-cluster Occamy tests #
###############################

# Questa
occamy-single-cluster-vsim:
needs: [occamy-single-cluster-sw]
script:
- cd target/sim
- make CFG_OVERRIDE=cfg/single-cluster.hjson rtl
- make sw
- $QUESTA make bin/occamy_top.vsim
- $QUESTA ../../deps/snitch_cluster/util/sim/simulate.py
sw/run-single-cluster.yaml --simulator vsim
--sim-bin bin/occamy_top.vsim

#####################
# Full Occamy tests #
#####################

# Questa
occamy-full-vsim:
script:
- cd target/sim
- make CFG_OVERRIDE=cfg/full.hjson rtl
- make sw
- $QUESTA make bin/occamy_top.vsim
- $QUESTA ../../deps/snitch_cluster/util/sim/simulate.py
sw/run-full-occamy.yaml --simulator vsim
--sim-bin bin/occamy_top.vsim
35 changes: 17 additions & 18 deletions target/sim/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ VLT_FLAGS += --prof-cfuncs # Enable code profiling
# C testbench #
###############

TB_CC_SOURCES = $(SNITCH_TEST_DIR)/rtl_lib.cc
TB_CC_SOURCES = $(SNITCH_TEST_DIR)/bootrom.cc
TB_CC_SOURCES += $(SNITCH_TEST_DIR)/ipc.cc
TB_CC_SOURCES += $(SNITCH_TEST_DIR)/rtl_lib.cc
TB_CC_SOURCES += $(SNITCH_TEST_DIR)/common_lib.cc
TB_CC_SOURCES += $(TARGET_TEST_DIR)/bootdata.cc
TB_CC_SOURCES += $(TARGET_TEST_DIR)/uartdpi/uartdpi.c
Expand All @@ -127,7 +129,9 @@ TB_CC_FLAGS +=-I$(SNITCH_TEST_DIR)
TB_CC_FLAGS +=-I$(TARGET_TEST_DIR)/uartdpi

# Required C sources for the verilator TB that are linked against the verilated model
VLT_COBJ = $(VLT_BUILDDIR)/tb/common_lib.o
VLT_COBJ = $(VLT_BUILDDIR)/tb/bootrom.o
VLT_COBJ += $(VLT_BUILDDIR)/tb/ipc.o
VLT_COBJ += $(VLT_BUILDDIR)/tb/common_lib.o
VLT_COBJ += $(VLT_BUILDDIR)/tb/verilator_lib.o
VLT_COBJ += $(VLT_BUILDDIR)/tb/tb_bin.o
VLT_COBJ += $(VLT_BUILDDIR)/test/uartdpi/uartdpi.o
Expand Down Expand Up @@ -450,34 +454,29 @@ $(PLATFORM_HEADERS_DIR)/occamy_base_addr.h: $(CFG)
# Traces #
##########

# CVA6 trace should use binary written in logs/.rtlbinary
# which is retrieved by the Makefrag in the BINARY variable,
# but the Snitch traces use another binary which is expected to
# be passed on the command-line, overriding the BINARY variable.
# So we define a new variable to store the CVA6 binary
CVA6_BINARY ?= $(shell cat $(LOGS_DIR)/.rtlbinary)

$(LOGS_DIR)/hart_00000_perf.json: $(LOGS_DIR)/trace_hart_00000.txt $(ROOT)/util/trace/events.py
$(PYTHON) $(ROOT)/util/trace/events.py -f cva6 $< -o $@
$(LOGS_DIR)/hart_00000_perf.json: $(LOGS_DIR)/trace_hart_00000.txt $(EVENTS_PY)
$(PYTHON) $(EVENTS_PY) -f cva6 $< -o $@

$(LOGS_DIR)/trace_hart_00000.s: $(LOGS_DIR)/trace_hart_00000.txt ${ANNOTATE}
$(PYTHON) ${ANNOTATE} ${ANNOTATE_FLAGS} -o $@ $(CVA6_BINARY) $<
$(LOGS_DIR)/trace_hart_00000.s: $(LOGS_DIR)/trace_hart_00000.txt $(ANNOTATE_PY)
$(PYTHON) $(ANNOTATE_PY) $(ANNOTATE_FLAGS) -o $@ $(CVA6_BINARY) $<

$(LOGS_DIR)/trace_hart_00000.diff: $(LOGS_DIR)/trace_hart_00000.txt ${ANNOTATE}
$(PYTHON) ${ANNOTATE} ${ANNOTATE_FLAGS} -o $@ $(CVA6_BINARY) $< -d
$(LOGS_DIR)/trace_hart_00000.diff: $(LOGS_DIR)/trace_hart_00000.txt $(ANNOTATE_PY)
$(PYTHON) $(ANNOTATE_PY) $(ANNOTATE_FLAGS) -o $@ $(CVA6_BINARY) $< -d

traces: $(LOGS_DIR)/hart_00000_perf.json

annotate: $(shell (echo $(LOGS_DIR)/trace_hart_00000.txt | sed 's/\.txt/\.s/') || echo "") \
$(shell (echo $(LOGS_DIR)/trace_hart_00000.txt | sed 's/\.txt/\.diff/') || echo "")

$(LOGS_DIR)/perf.csv: $(shell (ls $(LOGS_DIR)/trace_hart_*.dasm 2>/dev/null | sed 's/trace_hart/hart/' | sed 's/.dasm/_perf.json/')) \
$(LOGS_DIR)/hart_00000_perf.json $(ROOT)/util/trace/perf_csv.py
$(PYTHON) $(ROOT)/util/trace/perf_csv.py -o $@ -i $(LOGS_DIR)/hart_*_perf.json
$(LOGS_DIR)/hart_00000_perf.json $(PERF_CSV_PY)
$(PYTHON) $(PERF_CSV_PY) -o $@ -i $(LOGS_DIR)/hart_*_perf.json

$(LOGS_DIR)/event.csv: $(shell (ls $(LOGS_DIR)/trace_hart_*.dasm 2>/dev/null | sed 's/trace_hart/hart/' | sed 's/.dasm/_perf.json/')) \
$(LOGS_DIR)/hart_00000_perf.json $(ROOT)/util/trace/perf_csv.py
$(PYTHON) $(ROOT)/util/trace/perf_csv.py -o $@ -i $(LOGS_DIR)/hart_*_perf.json --filter tstart tend
$(LOGS_DIR)/hart_00000_perf.json $(PERF_CSV_PY)
$(PYTHON) $(PERF_CSV_PY) -o $@ -i $(LOGS_DIR)/hart_*_perf.json --filter tstart tend

#############
# Verilator #
Expand Down Expand Up @@ -575,7 +574,7 @@ clean-work:
rm -rf work

clean-bender:
rm -rf Bender.lock .bender/ work/
rm -rf $(ROOT)/Bender.lock $(ROOT)/.bender/ $(ROOT)/deps

clean-logs:
rm -rf $(LOGS_DIR)/
Expand Down
2 changes: 1 addition & 1 deletion target/sim/sw/device/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Luca Colagrande <colluca@iis.ee.ethz.ch>

# Add user applications to APPS variable
APPS = offload
APPS = blas/axpy

TARGET ?= all

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
#
# Luca Colagrande <colluca@iis.ee.ethz.ch>

APP = offload
SRCS = src/offload.c
INCDIRS = ../../../host/apps/offload/src
include ../../../../../../../deps/snitch_cluster/sw/blas/axpy/Makefile
include ../../common.mk

include ../common.mk
$(DEP): $(DATA_H)
11 changes: 7 additions & 4 deletions target/sim/sw/device/apps/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@
#
# Luca Colagrande <colluca@iis.ee.ethz.ch>

include ../../toolchain.mk
# Usage of absolute paths is required to externally include
# this Makefile from multiple different locations
MK_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
include $(MK_DIR)/../toolchain.mk

###################
# Build variables #
###################

# Directories
BUILDDIR = $(abspath build)
APPSDIR = $(abspath ../)
RUNTIME_DIR = $(abspath ../../runtime)
APPSDIR = $(abspath $(MK_DIR))
RUNTIME_DIR = $(abspath $(MK_DIR)/../runtime)
SNRT_DIR = $(shell bender path snitch_cluster)/sw/snRuntime
SW_DIR = $(abspath ../../../)
SW_DIR = $(abspath $(MK_DIR)/../../)

# Dependencies
INCDIRS += $(RUNTIME_DIR)/src
Expand Down
205 changes: 0 additions & 205 deletions target/sim/sw/device/apps/offload/src/offload.c

This file was deleted.

2 changes: 2 additions & 0 deletions target/sim/sw/device/runtime/src/occamy_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ extern volatile uint32_t* snrt_cluster_clint_set_ptr();
extern volatile uint32_t* snrt_cluster_clint_clr_ptr();

extern uint32_t snrt_cluster_hw_barrier_addr();

extern volatile uint32_t* snrt_zero_memory_ptr();
4 changes: 4 additions & 0 deletions target/sim/sw/device/runtime/src/occamy_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ inline volatile uint32_t* __attribute__((const)) snrt_cluster_clint_clr_ptr() {
inline uint32_t __attribute__((const)) snrt_cluster_hw_barrier_addr() {
return _snrt_cluster_hw_barrier;
}

inline volatile uint32_t* __attribute__((const)) snrt_zero_memory_ptr() {
return cluster_zero_memory_ptr(snrt_cluster_idx());
}
Loading

0 comments on commit 1a3ab98

Please sign in to comment.