Skip to content

Commit

Permalink
Bender.yml: Bump snitch_cluster (#16)
Browse files Browse the repository at this point in the history
* .github: Update `CODEOWNERS`

* bender.yml: Bump Snitch cluster

* sw: Align with snitch_cluster math and dnn refactoring

* target: Align with SEPP package best practices

* target: Align with Snitch cluster simulation framework refactoring
  • Loading branch information
colluca committed Jan 16, 2024
1 parent 0743f4e commit dbe67bb
Show file tree
Hide file tree
Showing 15 changed files with 96 additions and 62 deletions.
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Unless a later match takes precedence, global owners below will be
# requested for review when someone opens a pull request.

* @GiannaP @colluca @paulsc96
* @fischeti @colluca @paulsc96

target/sim/sw @colluca @viv-eth
target/sim/sw @colluca @viv-eth @fischeti
target/fpga @niwis @CyrilKoe
18 changes: 6 additions & 12 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ variables:
CLANG_FORMAT: clang-format-10.0.1
CC: gcc-9.2.0
CXX: g++-9.2.0
VCS: vcs-2020.12
VERILATOR: verilator-4.110
QUESTA: questa-2022.3
QUESTA_SEPP: questa-2022.3
LLVM_BINROOT: /usr/pack/riscv-1.0-kgf/pulp-llvm-0.12.0/bin
CLANG: /usr/pack/riscv-1.0-kgf/pulp-llvm-0.12.0/bin/clang
RISCV_GCC_VERSION: 8.3.0-2020.04.0
Expand All @@ -21,7 +19,7 @@ before_script:
# yamllint disable rule:line-length
- $PYTHON -m venv .venv
- source .venv/bin/activate
- bender update
- $BENDER update
- pip install -r python-requirements.txt
# Install CVA6 compiler toolchain
- curl -Ls -o riscv-gcc.tar.gz https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-$RISCV_GCC_VERSION-x86_64-linux-ubuntu14.tar.gz
Expand Down Expand Up @@ -52,10 +50,8 @@ occamy-single-cluster-vsim:
- 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
- make bin/occamy_top.vsim
- ./run.py sw/run-single-cluster.yaml --simulator vsim

#####################
# Full Occamy tests #
Expand All @@ -67,7 +63,5 @@ occamy-full-vsim:
- 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
- make bin/occamy_top.vsim
- ./run.py sw/run-full-occamy.yaml --simulator vsim
2 changes: 1 addition & 1 deletion Bender.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dependencies:
cva6: { path: hw/vendor/openhwgroup_cva6 }
opentitan_peripherals: { path: hw/vendor/pulp_platform_opentitan_peripherals }
register_interface: { git: https://github.com/pulp-platform/register_interface.git, version: 0.3.8 }
snitch_cluster: { git: https://github.com/pulp-platform/snitch_cluster.git, rev: occamy }
snitch_cluster: { git: https://github.com/pulp-platform/snitch_cluster.git, rev: 0c226e2b7aa884fa15bacebe1f52ba5d2b6d8e37 }
tech_cells_generic: { git: https://github.com/pulp-platform/tech_cells_generic.git, rev: v0.2.11 }

workspace:
Expand Down
1 change: 1 addition & 0 deletions target/sim/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
/*.log
/.*_targets_group
/sw/**/build/
/runs/

# Auto-generated sources
/src/
5 changes: 1 addition & 4 deletions target/sim/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ ADDRMAPGEN ?= $(ROOT)/util/addrmap/addrmapgen.py

CLANG_FORMAT ?= $(shell which clang-format-10.0.1)

VSIM = vsim
VLOG = vlog

#########################
# Files and directories #
#########################
Expand Down Expand Up @@ -526,7 +523,7 @@ clean-vlt: clean-work
############

${VSIM_BUILDDIR}/compile.vsim.tcl: $(VSIM_SOURCES) ${TB_SRCS} ${TB_CC_SOURCES} test/bootrom.bin | $(VSIM_BUILDDIR)
vlib $(dir $@)
$(VLIB) $(dir $@)
${BENDER} script vsim ${VSIM_BENDER} --vlog-arg="${VLOG_FLAGS} -work $(dir $@) " > $@
echo '${VLOG} -work $(dir $@) $(TB_CC_SOURCES) -ccflags "$(TB_CC_FLAGS)"' >> $@
echo 'return 0' >> $@
Expand Down
32 changes: 32 additions & 0 deletions target/sim/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env python3
# 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>

import sys
from pathlib import Path

sys.path.append(str(Path(__file__).parent / '../../deps/snitch_cluster/util/sim'))
from sim_utils import parser, get_simulations, run_simulations # noqa: E402
from Simulator import QuestaSimulator # noqa: E402


SIMULATORS = {
'vsim': QuestaSimulator(Path(__file__).parent.resolve() / 'bin/occamy_top.vsim')
}


def main():
args = parser('vsim', SIMULATORS.keys()).parse_args()
simulations = get_simulations(args.testlist, SIMULATORS[args.simulator])
return run_simulations(simulations,
n_procs=args.n_procs,
run_dir=Path(args.run_dir),
dry_run=args.dry_run,
early_exit=args.early_exit)


if __name__ == '__main__':
sys.exit(main())
6 changes: 3 additions & 3 deletions target/sim/sw/device/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ TARGET ?= all
APP_SUBDIRS = $(addprefix apps/,$(APPS))

SUBDIRS = runtime
SUBDIRS += math
SUBDIRS += $(APP_SUBDIRS)

.PHONY: all $(SUBDIRS)

all: $(SUBDIRS)

runtime:
$(SUBDIRS):
$(MAKE) -C $@ $(TARGET)

# Explicit dependency of apps on runtime
$(APP_SUBDIRS): runtime
$(MAKE) -C $@ $(TARGET)
$(APP_SUBDIRS): runtime math
37 changes: 21 additions & 16 deletions target/sim/sw/device/apps/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,25 @@
MK_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
include $(MK_DIR)/../toolchain.mk

###################
# Build variables #
###################
###############
# Directories #
###############

# Directories
BUILDDIR = $(abspath build)
APPSDIR = $(abspath $(MK_DIR))
RUNTIME_DIR = $(abspath $(MK_DIR)/../runtime)
# Fixed paths in repository tree
ROOT = $(abspath $(MK_DIR)/../../../../../)
SNITCH_ROOT = $(shell bender path snitch_cluster)
APPSDIR = $(abspath $(MK_DIR))
RUNTIME_DIR = $(ROOT)/target/sim/sw/device/runtime
SNRT_DIR = $(SNITCH_ROOT)/sw/snRuntime
SW_DIR = $(abspath $(MK_DIR)/../../)
SW_DIR = $(ROOT)/target/sim/sw/
MATH_DIR = $(ROOT)/target/sim/sw/device/math

# Paths relative to the app including this Makefile
BUILDDIR = $(abspath build)

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

# Dependencies
INCDIRS += $(RUNTIME_DIR)/src
Expand All @@ -29,14 +37,7 @@ INCDIRS += $(SNRT_DIR)/vendor/riscv-opcodes
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
INCDIRS += $(SNITCH_ROOT)/sw/blas

# Linking sources
BASE_LD = $(abspath $(SNRT_DIR)/base.ld)
Expand All @@ -55,6 +56,10 @@ RISCV_LDFLAGS += -T$(BASE_LD)
# Link snRuntime library
RISCV_LDFLAGS += -L$(SNRT_LIB_DIR)
RISCV_LDFLAGS += -l$(SNRT_LIB_NAME)
# Link math library
RISCV_LDFLAGS += -L$(MATH_DIR)/build
RISCV_LDFLAGS += -lmath


# Objcopy flags
OBJCOPY_FLAGS = -O binary
Expand Down
8 changes: 8 additions & 0 deletions target/sim/sw/device/math/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# 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 ../toolchain.mk
include $(SNITCH_ROOT)/sw/math/Makefile
7 changes: 1 addition & 6 deletions target/sim/sw/device/runtime/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ALL_OUTPUTS = $(DEPS) $(LIB) $(DUMP)
#########

.PHONY: all
all: math $(ALL_OUTPUTS)
all: $(ALL_OUTPUTS)

.PHONY: clean
clean:
Expand All @@ -68,11 +68,6 @@ $(LIB): $(OBJS) | $(BUILDDIR)
$(DUMP): $(LIB) | $(BUILDDIR)
$(RISCV_OBJDUMP) -D $< > $@

# Build math library sources
.PHONY: math
math:
make -C $(SNITCH_ROOT)/sw/math all

ifneq ($(MAKECMDGOALS),clean)
-include $(DEPS)
endif
1 change: 1 addition & 0 deletions target/sim/sw/device/runtime/src/snrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "cls.h"
#include "cluster_interrupts.h"
#include "dma.h"
#include "dump.h"
#include "global_interrupts.h"
#include "occamy_device.h"
#include "occamy_memory.h"
Expand Down
4 changes: 3 additions & 1 deletion target/sim/sw/device/toolchain.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
#
# Luca Colagrande <colluca@iis.ee.ethz.ch>

include $(shell bender path snitch_cluster)/target/snitch_cluster/sw/toolchain.mk
BENDER ?= bender
SNITCH_ROOT = $(shell $(BENDER) path snitch_cluster)
include $(SNITCH_ROOT)/target/snitch_cluster/sw/toolchain.mk
15 changes: 7 additions & 8 deletions target/sim/sw/host/apps/hello_world/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,16 @@
import sys

sys.path.append(str(Path(__file__).parent / '../../../../../../deps/snitch_cluster/util/sim/'))
from simulate import run_simulation # noqa: E402
from sim_utils import run_simulations # noqa: E402
from Simulator import QuestaSimulator # noqa: E402

UART_LOG = str(Path(__file__).parent / '../../../../uart0.log')
UART_LOG = 'uart0.log'
EXPECTED_OUTPUT = "Hello world!\r\n"


def parse_args():
# Argument parsing
parser = argparse.ArgumentParser(allow_abbrev=True)
parser.add_argument(
'simulator',
help='The simulator to be used',
)
parser.add_argument(
'sim_bin',
help='The simulator binary to be used to start the simulation',
Expand All @@ -35,8 +32,10 @@ def parse_args():

def main():
args = parse_args()
cmd = f"{args.sim_bin} {args.snitch_bin}"
result, _ = run_simulation(cmd, args.simulator, {})
simulator = QuestaSimulator(args.sim_bin)
simulation = simulator.get_simulation({'elf': args.snitch_bin})
result = run_simulations([simulation])

actual_output = ''
with open(UART_LOG, 'rb') as file:
actual_output = file.read().decode('ascii')
Expand Down
8 changes: 4 additions & 4 deletions target/sim/sw/run-full-occamy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

runs:
- elf: host/apps/offload/build/offload-axpy.elf
cmd: ../../deps/snitch_cluster/sw/blas/axpy/verify.py {sim_bin} {elf}
--symbols-bin ./sw/device/apps/blas/axpy/build/axpy.elf
cmd: [../../../deps/snitch_cluster/sw/blas/axpy/verify.py, --symbols-bin,
./device/apps/blas/axpy/build/axpy.elf, "${sim_bin}", "${elf}"]
- elf: host/apps/offload/build/offload-gemm.elf
cmd: ../../deps/snitch_cluster/sw/blas/gemm/verify.py {sim_bin} {elf}
--symbols-bin ./sw/device/apps/blas/gemm/build/gemm.elf
cmd: [../../../deps/snitch_cluster/sw/blas/gemm/verify.py, --symbols-bin,
./device/apps/blas/gemm/build/gemm.elf, "${sim_bin}", "${elf}"]
10 changes: 5 additions & 5 deletions target/sim/sw/run-single-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

runs:
- elf: host/apps/offload/build/offload-axpy.elf
cmd: ../../deps/snitch_cluster/sw/blas/axpy/verify.py {sim_bin} {elf}
--symbols-bin ./sw/device/apps/blas/axpy/build/axpy.elf
cmd: [../../../deps/snitch_cluster/sw/blas/axpy/verify.py, --symbols-bin,
./device/apps/blas/axpy/build/axpy.elf, "${sim_bin}", "${elf}"]
- elf: host/apps/offload/build/offload-gemm.elf
cmd: ../../deps/snitch_cluster/sw/blas/gemm/verify.py {sim_bin} {elf}
--symbols-bin ./sw/device/apps/blas/gemm/build/gemm.elf
cmd: [../../../deps/snitch_cluster/sw/blas/gemm/verify.py, --symbols-bin,
./device/apps/blas/gemm/build/gemm.elf, "${sim_bin}", "${elf}"]
- elf: host/apps/hello_world/build/hello_world.elf
cmd: sw/host/apps/hello_world/verify.py {simulator} {sim_bin} {elf}
cmd: [./host/apps/hello_world/verify.py, "${sim_bin}", "${elf}"]

0 comments on commit dbe67bb

Please sign in to comment.