Skip to content

Commit ce68d22

Browse files
viv-ethViviane Potocnikcollucafischeti
authored
sw: Restructuring of BLAS and DNN kernels (#137)
Co-authored-by: Viviane Potocnik <vivianep@iis.ee.ethz.ch> Co-authored-by: Luca Colagrande <luca.colagrande3@gmail.com> Co-authored-by: Tim Fischer <fischeti@iis.ee.ethz.ch>
1 parent 2fb4c70 commit ce68d22

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+2635
-1366
lines changed

.clang-format-ignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
33
# SPDX-License-Identifier: Apache-2.0
44

5-
# Ignore vendored third-party code
6-
./sw/math/*
5+
./sw/saris

.github/workflows/lint.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,6 @@ jobs:
7878
match_regex: true
7979
exclude_paths: |
8080
sw/snRuntime/src/omp/interface.h
81-
sw/math/arch/generic/*
82-
sw/math/arch/riscv64/bits/*
83-
sw/math/include/*
84-
sw/math/src/include/*
85-
sw/math/src/internal/*
86-
sw/math/src/math/*
87-
sw/math/Makefile
8881
8982
##################
9083
# Lint YML Files #
@@ -129,7 +122,6 @@ jobs:
129122
- uses: actions/checkout@v3
130123
- uses: DoozyX/clang-format-lint-action@v0.16.2
131124
with:
132-
exclude: './sw/saris'
133125
clangFormatVersion: 10
134126

135127
######################

.gitlab-ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ snitch-cluster-sw:
3434
- make sw
3535
artifacts:
3636
paths:
37-
- sw/math/include/bits/alltypes.h
3837
- target/snitch_cluster/sw/**/build/*.elf
3938
expire_in: 1 day
4039

@@ -44,7 +43,6 @@ snitch-cluster-sw-banshee:
4443
- make SELECT_RUNTIME=banshee sw
4544
artifacts:
4645
paths:
47-
- sw/math/include/bits/alltypes.h
4846
- target/snitch_cluster/sw/**/build/*.elf
4947
expire_in: 1 day
5048

@@ -103,8 +101,8 @@ snitch-cluster-vsim:
103101
# Test trace annotation
104102
- make SIM_DIR=./runs/vsim/simple annotate -j
105103
# Run additional, more extensive tests
106-
- cd sw/apps/blas/gemm/test
107-
- ./run.py runs.yaml --cfg $PWD/cfg/* --simulator vsim -j
104+
- cd sw/apps/blas/gemm/test && ./test.sh && cd -
105+
- cd sw/apps/dnn/transpose/test && ./test.sh && cd -
108106

109107
# Banshee
110108
snitch-cluster-banshee:
@@ -129,6 +127,8 @@ snitch-cluster-fdiv-vsim:
129127
- make CFG_OVERRIDE=cfg/fdiv.hjson sw
130128
- make bin/snitch_cluster.vsim
131129
- ./util/run.py sw/fdiv.yaml --simulator vsim -j --run-dir runs/vsim
130+
# Run additional, more extensive tests
131+
- cd sw/apps/dnn/flashattention_2/test && ./test.sh && cd -
132132

133133
# Test OmegaNet TCDM interconnect
134134
snitch-cluster-omega-vsim:

docs/rm/snitch_target_utils/build.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
::: build

docs/rm/snitch_target_utils/run.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
::: run

iis-setup.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# SPDX-License-Identifier: Apache-2.0
55

66
# Define environment variables
7-
export PYTHON=/usr/local/anaconda3-2022.05/bin/python3
87
export BENDER=bender-0.27.1
98
export CC=gcc-9.2.0
109
export CXX=g++-9.2.0
@@ -14,7 +13,7 @@ export QUESTA_SEPP=questa-2022.3
1413
export LLVM_BINROOT=/usr/pack/riscv-1.0-kgf/pulp-llvm-0.12.0/bin
1514

1615
# Create Python virtual environment with required packages
17-
$PYTHON -m venv .venv
16+
/usr/local/anaconda3-2022.05/bin/python3 -m venv .venv
1817
source .venv/bin/activate
1918
# Unpack packages in a local temporary directory which can be safely cleaned
2019
# after installation. Also protects against "No space left on device" errors

mkdocs.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ plugins:
2525
- mkdocstrings:
2626
handlers:
2727
python:
28-
paths: [util/sim]
28+
paths:
29+
- util/sim
30+
- target/snitch_cluster/util
2931
- macros:
3032
on_error_fail: true
3133
use_directory_urls: false
@@ -62,6 +64,9 @@ nav:
6264
- rm/sim/Simulation.md
6365
- rm/sim/Simulator.md
6466
- rm/sim/Elf.md
67+
- Snitch Target Utilities:
68+
- run.py: rm/snitch_target_utils/run.md
69+
- build.py: rm/snitch_target_utils/build.md
6570
- Snitch Runtime:
6671
- Pages: runtime/Pages/index.md
6772
- Files: runtime/Files/index.md

sw/README.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,6 @@ This subdirectory contains the various bits and pieces of software for the Snitc
1111
- `snRuntime`: The fundamental, bare-metal runtime for Snitch systems. Exposes a minimal API to manage execution of code across the available cores and clusters, query information about a thread's context, and to coordinate and exchange data with other threads. Hardware configuration dependent implementations of the `snRuntime` can be found, e.g., under `target/snitch_cluster/sw/snRuntime`.
1212
- `snBLAS`: A minimal reference implementation of the basic linear algebra subprograms that demonstrates the use of Snitch and its extensions.
1313

14-
#### math
15-
16-
The math sources are taken from the musl library, patched with our own modifications. The bender vendor snippet in `Bender.yml` was used to copy in the original sources. Patches were generated using the following command (from the root of the repo):
17-
```
18-
git format-patch --relative -o sw/deps/patches/musl/ HEAD^1
19-
```
20-
And can be applied by running (in the root of the repo):
21-
```
22-
git apply sw/deps/patches/musl/0001-musl-Patch-to-build-math-library-for-Snitch.patch
23-
```
24-
25-
The `all` target in `sw/math/Makefile` should be run to generate some files.
26-
2714
### Tests
2815

2916
- `benchmark`: Benchmarking executables that evaluate the performance characteristics of a system.

sw/apps/atax/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ DATAGEN_PY = $(MK_DIR)/scripts/datagen.py
2020
DATA_H = $(DATA_DIR)/data.h
2121

2222
$(DATA_H): $(DATAGEN_PY) $(DATA_CFG)
23-
$< -c $(DATA_CFG) --section="$(SECTION)" > $@
23+
$< -c $(DATA_CFG) --section="$(SECTION)" $@
2424

2525
.PHONY: clean-data clean
2626

sw/apps/correlation/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ DATAGEN_PY = $(MK_DIR)/scripts/datagen.py
2020
DATA_H = $(DATA_DIR)/data.h
2121

2222
$(DATA_H): $(DATAGEN_PY) $(DATA_CFG)
23-
$< -c $(DATA_CFG) --section="$(SECTION)" > $@
23+
$< -c $(DATA_CFG) --section="$(SECTION)" $@
2424

2525
.PHONY: clean-data clean
2626

sw/apps/covariance/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ DATAGEN_PY = $(MK_DIR)/scripts/datagen.py
2020
DATA_H = $(DATA_DIR)/data.h
2121

2222
$(DATA_H): $(DATAGEN_PY) $(DATA_CFG)
23-
$< -c $(DATA_CFG) --section="$(SECTION)" > $@
23+
$< -c $(DATA_CFG) --section="$(SECTION)" $@
2424

2525
.PHONY: clean-data clean
2626

sw/blas/axpy/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ $(dir $(DATA_H)):
2323
mkdir -p $@
2424

2525
$(DATA_H): $(DATAGEN_PY) $(DATA_CFG) | $(dir $(DATA_H))
26-
$< -c $(DATA_CFG) --section="$(SECTION)" > $@
26+
$< -c $(DATA_CFG) --section="$(SECTION)" $@
2727

2828
.PHONY: clean-data clean
2929

sw/blas/dot/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ $(dir $(DATA_H)):
2121
mkdir -p $@
2222

2323
$(DATA_H): $(DATAGEN_PY) $(DATA_CFG) | $(dir $(DATA_H))
24-
$< -c $(DATA_CFG) --section="$(SECTION)" > $@
24+
$< -c $(DATA_CFG) --section="$(SECTION)" $@
2525

2626
.PHONY: clean-data clean
2727

sw/blas/gemm/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ $(dir $(DATA_H)):
2323
mkdir -p $@
2424

2525
$(DATA_H): $(DATAGEN_PY) $(DATA_CFG) | $(dir $(DATA_H))
26-
$< -c $(DATA_CFG) --section="$(SECTION)" > $@
26+
$< -c $(DATA_CFG) --section="$(SECTION)" $@
2727

2828
.PHONY: clean-data clean
2929

sw/blas/gemm/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright 2024 ETH Zurich and University of Bologna.
2+
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
# Luca Colagrande <colluca@iis.ee.ethz.ch>
6+
7+
from .scripts import datagen
8+
9+
__all__ = ['datagen']

sw/blas/gemm/data/params.json

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
// Copyright 2023 ETH Zurich and University of Bologna.
2-
// Solderpad Hardware License, Version 0.51, see LICENSE for details.
3-
// SPDX-License-Identifier: SHL-0.51
4-
5-
// Parameters for a GEMM
1+
// Copyright 2024 ETH Zurich and University of Bologna.
2+
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3+
// SPDX-License-Identifier: Apache-2.0
64

75
{
8-
M: 192,
6+
setup_ssr: 1,
7+
parallelize_m: 0,
8+
parallelize_k: 0,
9+
m_tiles: 2, // number of tiles in M dimension
10+
n_tiles: 1, // number of tiles in N dimension
11+
k_tiles: 1, // number of tiles in K dimension
12+
load_a: 1,
13+
load_b: 1,
14+
load_c: 1,
15+
transa: false,
16+
transb: true, // must be true for SIMD
17+
M: 16,
918
N: 16,
1019
K: 16,
20+
alpha: 1,
1121
beta: 0,
12-
ta: false,
13-
tb: true, // must be true for SIMD
14-
prec: "FP64",
15-
expand: 0,
16-
m_tiles: 2, // number of tiles in M dimension
17-
k_tiles: 1, // number of tiles in K dimension
18-
n_tiles: 1, // number of tiles in N dimension
19-
parallelize_k: 0,
20-
parallelize_m: 0,
21-
baseline: false
22+
gemm_fp: "gemm_fp32_opt"
2223
}

0 commit comments

Comments
 (0)