Skip to content

Commit

Permalink
sw: Add generic offload app (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
colluca committed Oct 12, 2023
1 parent 7e0e812 commit 8f9fafb
Show file tree
Hide file tree
Showing 26 changed files with 358 additions and 377 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 LENGTH=384 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
3 changes: 2 additions & 1 deletion target/sim/sw/device/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
# Luca Colagrande <colluca@iis.ee.ethz.ch>

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

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)
10 changes: 10 additions & 0 deletions target/sim/sw/device/apps/blas/gemm/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2023 ETH Zurich and University of Bologna.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
#
# Luca Colagrande <colluca@iis.ee.ethz.ch>

include ../../../../../../../deps/snitch_cluster/sw/blas/gemm/Makefile
include ../../common.mk

$(DEP): $(DATA_H)
22 changes: 17 additions & 5 deletions target/sim/sw/device/apps/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@
#
# 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)
SNRT_DIR = $(shell bender path snitch_cluster)/sw/snRuntime
SW_DIR = $(abspath ../../../)
APPSDIR = $(abspath $(MK_DIR))
RUNTIME_DIR = $(abspath $(MK_DIR)/../runtime)
SNITCH_ROOT = $(shell bender path snitch_cluster)
SNRT_DIR = $(SNITCH_ROOT)/sw/snRuntime
SW_DIR = $(abspath $(MK_DIR)/../../)

# Dependencies
INCDIRS += $(RUNTIME_DIR)/src
Expand All @@ -26,6 +30,14 @@ INCDIRS += $(SW_DIR)/shared/platform/generated
INCDIRS += $(SW_DIR)/shared/platform
INCDIRS += $(SW_DIR)/shared/runtime

# Math library override
INCDIRS += $(SNITCH_ROOT)/sw/math/arch/riscv64/bits/
INCDIRS += $(SNITCH_ROOT)/sw/math/arch/generic
INCDIRS += $(SNITCH_ROOT)/sw/math/src/include
INCDIRS += $(SNITCH_ROOT)/sw/math/src/internal
INCDIRS += $(SNITCH_ROOT)/sw/math/include/bits
INCDIRS += $(SNITCH_ROOT)/sw/math/include

# Linking sources
BASE_LD = $(abspath $(SNRT_DIR)/base.ld)
MEMORY_LD = $(abspath $(APPSDIR)/memory.ld)
Expand Down
Loading

0 comments on commit 8f9fafb

Please sign in to comment.