Skip to content

Commit

Permalink
util/sim: Extend simulation utilities for Occamy
Browse files Browse the repository at this point in the history
  • Loading branch information
colluca committed Sep 11, 2023
1 parent 5bd34b1 commit 85e9214
Show file tree
Hide file tree
Showing 16 changed files with 210 additions and 217 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
name: build-docker
on:
push:
branches: [main]
branches: [occamy]
workflow_dispatch:
jobs:
build-docker:
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ jobs:
- name: Run Tests
working-directory: target/snitch_cluster
run: |-
./sw/tests/run.py sw/tests/run.yaml --simulator verilator
./sw/apps/run.py sw/apps/run.yaml --simulator verilator
../../util/sim/simulate.py sw/run.yaml --simulator verilator
############################################
# Build SW on Snitch Cluster w/ Banshee #
Expand All @@ -67,5 +66,4 @@ jobs:
SNITCH_LOG: info
working-directory: target/snitch_cluster
run: |-
./sw/tests/run.py sw/tests/run.yaml --simulator banshee
./sw/apps/run.py sw/apps/run.yaml --simulator banshee
../../util/sim/simulate.py sw/run.yaml --simulator banshee
12 changes: 4 additions & 8 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ snitch-cluster-vlt:
script:
- cd target/snitch_cluster
- $VERILATOR make bin/snitch_cluster.vlt
- $VERILATOR ./sw/tests/run.py sw/tests/run.yaml --simulator verilator
- $VERILATOR ./sw/apps/run.py sw/apps/run.yaml --simulator verilator
- $VERILATOR ../../util/sim/simulate.py sw/run.yaml --simulator verilator
# yamllint enable rule:line-length

# VCS
Expand All @@ -103,17 +102,15 @@ snitch-cluster-vcs:
script:
- cd target/snitch_cluster
- $VCS make bin/snitch_cluster.vcs
- $VCS ./sw/tests/run.py sw/tests/run.yaml --simulator vcs
- $VCS ./sw/apps/run.py sw/apps/run.yaml --simulator vcs
- $VCS ../../util/sim/simulate.py sw/run.yaml --simulator vcs

# Questa
snitch-cluster-vsim:
needs: [snitch-cluster-sw]
script:
- cd target/snitch_cluster
- $QUESTA make bin/snitch_cluster.vsim
- $QUESTA ./sw/tests/run.py sw/tests/run.yaml --simulator vsim
- $QUESTA ./sw/apps/run.py sw/apps/run.yaml --simulator vsim
- $QUESTA ../../util/sim/simulate.py sw/run.yaml --simulator vsim

# Banshee
snitch-cluster-banshee:
Expand All @@ -129,5 +126,4 @@ snitch-cluster-banshee:
- cd banshee
- cargo install --debug --path .
- cd ../target/snitch_cluster
- ./sw/tests/run.py sw/tests/run.yaml --simulator banshee
- ./sw/apps/run.py sw/apps/run.yaml --simulator banshee
- ../../util/sim/simulate.py sw/run.yaml --simulator banshee
6 changes: 5 additions & 1 deletion sw/blas/axpy/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ def main():
args = verification.parse_args()
raw_results = verification.simulate(sim_bin=args.sim_bin,
snitch_bin=args.snitch_bin,
symbols_bin=args.symbols_bin,
log=args.log,
output_uids=['z'])
z_actual = np.array(bytes_to_doubles(raw_results['z']))

# Extract input operands from ELF file
elf = Elf(args.snitch_bin)
if args.symbols_bin:
elf = Elf(args.symbols_bin)
else:
elf = Elf(args.snitch_bin)
a = np.array(bytes_to_doubles(elf.get_symbol_contents('a')))
x = np.array(bytes_to_doubles(elf.get_symbol_contents('x')))
y = np.array(bytes_to_doubles(elf.get_symbol_contents('y')))
Expand Down
10 changes: 6 additions & 4 deletions sw/blas/gemm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@ MK_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
DATA_DIR := $(realpath $(MK_DIR)/data)
SRC_DIR := $(realpath $(MK_DIR)/src)

DATA_CFG ?= $(DATA_DIR)/params.hjson

APP ?= gemm
SRCS ?= $(realpath $(SRC_DIR)/main.c)
INCDIRS ?= $(DATA_DIR) $(SRC_DIR)

$(DATA_DIR)/data.h: $(DATA_DIR)/datagen.py $(DATA_CFG)
DATA_CFG ?= $(DATA_DIR)/params.hjson
DATAGEN_PY = $(DATA_DIR)/datagen.py
DATA_H = $(DATA_DIR)/data.h

$(DATA_H): $(DATAGEN_PY) $(DATA_CFG)
$< -c $(DATA_CFG) > $@

.PHONY: clean-data clean

clean-data:
rm -f $(DATA_DIR)/data.h
rm -f $(DATA_H)

clean: clean-data
File renamed without changes.
21 changes: 0 additions & 21 deletions target/snitch_cluster/sw/apps/run.py

This file was deleted.

17 changes: 0 additions & 17 deletions target/snitch_cluster/sw/apps/run.yaml

This file was deleted.

85 changes: 85 additions & 0 deletions target/snitch_cluster/sw/run.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# 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

runs:
- elf: tests/build/atomics.elf
simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x4
- elf: tests/build/barrier.elf
- elf: tests/build/data_mover.elf
- elf: tests/build/dma_simple.elf
- elf: tests/build/event_unit.elf
- elf: tests/build/fence_i.elf
- elf: tests/build/fp8_comparison_scalar.elf
simulators: [vsim, vcs, verilator] # banshee fails with segfault
- elf: tests/build/fp8_comparison_vector.elf
simulators: [vsim, vcs, verilator] # banshee fails with segfault
- elf: tests/build/fp8_computation_scalar.elf
simulators: [vsim, vcs, verilator] # banshee fails with JIT issue
- elf: tests/build/fp8_computation_vector.elf
simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x6
- elf: tests/build/fp8alt_comparison_scalar.elf
simulators: [vsim, vcs, verilator] # banshee fails with segfault
- elf: tests/build/fp8alt_comparison_vector.elf
simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x10
- elf: tests/build/fp8alt_computation_scalar.elf
simulators: [vsim, vcs, verilator] # banshee fails with JIT issue
- elf: tests/build/fp8alt_computation_vector.elf
simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x12
- elf: tests/build/fp16_comparison_scalar.elf
simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x10
- elf: tests/build/fp16_comparison_vector.elf
simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x10
- elf: tests/build/fp16_computation_scalar.elf
simulators: [vsim, vcs, verilator] # banshee fails with JIT issue
- elf: tests/build/fp16_computation_vector.elf
simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x6
- elf: tests/build/fp16alt_comparison_scalar.elf
simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x10
- elf: tests/build/fp16alt_comparison_vector.elf
simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x10
- elf: tests/build/fp16alt_computation_scalar.elf
simulators: [vsim, vcs, verilator] # banshee fails with JIT issue
- elf: tests/build/fp16alt_computation_vector.elf
simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x16
- elf: tests/build/fp32_comparison_scalar.elf
- elf: tests/build/fp32_comparison_vector.elf
- elf: tests/build/fp32_computation_scalar.elf
simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x2
- elf: tests/build/fp32_computation_vector.elf
simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x2
- elf: tests/build/fp32_conversions_scalar.elf
simulators: [vsim, vcs, verilator] # banshee fails with illegal instruction
- elf: tests/build/fp64_conversions_scalar.elf
simulators: [vsim, vcs, verilator]
# - elf: tests/build/interrupt.elf
- elf: tests/build/interrupt_local.elf
- elf: tests/build/multi_cluster.elf
- elf: tests/build/openmp_parallel.elf
- elf: tests/build/openmp_for_static_schedule.elf
- elf: tests/build/openmp_double_buffering.elf
- elf: tests/build/perf_cnt.elf
- elf: tests/build/printf_simple.elf
- elf: tests/build/printf_fmtint.elf
- elf: tests/build/simple.elf
- elf: tests/build/team_global.elf
- elf: tests/build/tls.elf
- elf: tests/build/varargs_1.elf
- elf: tests/build/varargs_2.elf
- elf: tests/build/zero_mem.elf
- elf: tests/build/non_null_exitcode.elf
exit_code: 14
- elf: apps/blas/axpy/build/axpy.elf
cmd: ../../sw/blas/axpy/verify.py {sim_bin} {elf}
- elf: apps/blas/gemm/build/gemm.elf
- elf: apps/dnn/batchnorm/build/batchnorm.elf
- elf: apps/dnn/linear/build/linear.elf
- elf: apps/dnn/maxpool/build/maxpool.elf
- elf: apps/dnn/gemm/build/gemm.elf
# - elf: apps/dnn/gelu/build/gelu.elf # seems like it stalls
# - elf: apps/dnn/conv2d/build/conv2d.elf # fails with exit code 32
# - elf: apps/dnn/fusedconv/build/fusedconv.elf # fails newly
# - elf: apps/dnn/layernorm/build/layernorm.elf
# throws illegal instruction on FDIV in simulation
# - elf: apps/dnn/softmax/build/softmax.elf
# throws illegal instruction on FDIV in simulation
2 changes: 1 addition & 1 deletion target/snitch_cluster/sw/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ RISCV_LDFLAGS += -lsnRuntime
# Outputs #
###########

APPS = $(shell $(MK_DIR)/../../../../util/sim/list_apps.py run.yaml)
APPS = $(shell $(MK_DIR)/../../../../util/sim/list_apps.py --in-dir tests/ ../run.yaml)
ELFS = $(abspath $(addprefix $(BUILDDIR)/,$(addsuffix .elf,$(APPS))))
DEPS = $(abspath $(addprefix $(BUILDDIR)/,$(addsuffix .d,$(APPS))))
DUMPS = $(abspath $(addprefix $(BUILDDIR)/,$(addsuffix .dump,$(APPS))))
Expand Down
21 changes: 0 additions & 21 deletions target/snitch_cluster/sw/tests/run.py

This file was deleted.

71 changes: 0 additions & 71 deletions target/snitch_cluster/sw/tests/run.yaml

This file was deleted.

7 changes: 3 additions & 4 deletions util/sim/elf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python3
# Copyright 2020 ETH Zurich and University of Bologna.
# Solderpad Hardware License, Version 0.51, see LICENSE for details.
# SPDX-License-Identifier: SHL-0.51
# 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 <[email protected]>
#
Expand Down
13 changes: 10 additions & 3 deletions util/sim/list_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,29 @@

import argparse
import yaml
from pathlib import Path


def main():
# Argument parsing
parser = argparse.ArgumentParser()
parser.add_argument(
'--in-dir',
type=Path,
help='Only apps below this directory (at any level) will be listed')
parser.add_argument(
'input',
help='The YAML file containing run information',
)
help='The YAML file containing run information')
args = parser.parse_args()

with open(args.input, 'r') as file:
tests = yaml.safe_load(file)['runs']

for test in tests:
print(test['app'])
elf = Path(test['elf'])
match_parts = args.in_dir.parts
if elf.parts[:len(match_parts)] == match_parts:
print(elf.stem)


if __name__ == '__main__':
Expand Down
Loading

0 comments on commit 85e9214

Please sign in to comment.