From 84d163eb73a1a0787c0466c3f1f2bee66d3adbbb Mon Sep 17 00:00:00 2001 From: Josse Van Delm Date: Wed, 25 Oct 2023 16:20:18 +0200 Subject: [PATCH] Add data generation for both simple vec examples (#36) * sw: Move files into snax-mac-simple folder * sw: Fix relative paths for CI after move * sw: Rename files for move * sw: Adapt relative paths for compilation * sw: Rename snax-mac-simple to untiled * sw: Use datagen to drive untiled example * sw: Fix C linting --- target/snitch_cluster/sw/apps/Makefile | 4 +-- .../snitch_cluster/sw/apps/snax-mac-run.yaml | 4 +-- .../sw/apps/snax-mac-simple/Makefile | 28 ++++++++++++--- .../data => snax-mac-simple}/datagen.py | 2 +- .../sw/apps/snax-mac-simple/tiled/Makefile | 13 +++++++ .../tiled/src/tiled.c} | 0 .../sw/apps/snax-mac-simple/untiled/Makefile | 12 +++++++ .../snax-mac-simple/{ => untiled}/data/data.h | 0 .../src/untiled.c} | 6 ++-- .../sw/apps/snax-mac-tiled/Makefile | 35 ------------------- 10 files changed, 56 insertions(+), 48 deletions(-) rename target/snitch_cluster/sw/apps/{snax-mac-tiled/data => snax-mac-simple}/datagen.py (97%) create mode 100644 target/snitch_cluster/sw/apps/snax-mac-simple/tiled/Makefile rename target/snitch_cluster/sw/apps/{snax-mac-tiled/src/snax-mac-tiled.c => snax-mac-simple/tiled/src/tiled.c} (100%) create mode 100644 target/snitch_cluster/sw/apps/snax-mac-simple/untiled/Makefile rename target/snitch_cluster/sw/apps/snax-mac-simple/{ => untiled}/data/data.h (100%) rename target/snitch_cluster/sw/apps/snax-mac-simple/{src/snax-mac-simple.c => untiled/src/untiled.c} (93%) delete mode 100644 target/snitch_cluster/sw/apps/snax-mac-tiled/Makefile diff --git a/target/snitch_cluster/sw/apps/Makefile b/target/snitch_cluster/sw/apps/Makefile index 744d54fc8..8321696b0 100644 --- a/target/snitch_cluster/sw/apps/Makefile +++ b/target/snitch_cluster/sw/apps/Makefile @@ -19,8 +19,8 @@ SUBDIRS += dnn/maxpool SUBDIRS += dnn/softmax SUBDIRS += montecarlo/pi_estimation SUBDIRS += snax-mac -SUBDIRS += snax-mac-simple -SUBDIRS += snax-mac-tiled +SUBDIRS += snax-mac-simple/untiled +SUBDIRS += snax-mac-simple/tiled SUBDIRS += snax-gemm-engine SUBDIRS += snax-gemm-base diff --git a/target/snitch_cluster/sw/apps/snax-mac-run.yaml b/target/snitch_cluster/sw/apps/snax-mac-run.yaml index 583ab2a0e..489c445c3 100644 --- a/target/snitch_cluster/sw/apps/snax-mac-run.yaml +++ b/target/snitch_cluster/sw/apps/snax-mac-run.yaml @@ -11,8 +11,8 @@ runs: - app: dnn/maxpool - app: dnn/gemm - app: snax-mac - - app: snax-mac-simple - - app: snax-mac-tiled + - app: snax-mac-simple/untiled + - app: snax-mac-simple/tiled # dnn/gelu # seems like it stalls # dnn/conv2d # fails with exit code 32 # dnn/fusedconv # fails newly diff --git a/target/snitch_cluster/sw/apps/snax-mac-simple/Makefile b/target/snitch_cluster/sw/apps/snax-mac-simple/Makefile index 24ea4a277..7c71b17e9 100644 --- a/target/snitch_cluster/sw/apps/snax-mac-simple/Makefile +++ b/target/snitch_cluster/sw/apps/snax-mac-simple/Makefile @@ -2,10 +2,28 @@ # Licensed under the Apache License, Version 2.0, see LICENSE for details. # SPDX-License-Identifier: Apache-2.0 # -# Ryan Antonio +# Gianna Paulin +# Josse Van Delm -APP = snax-mac-simple -SRCS = src/snax-mac-simple.c -INCDIRS = data +# Usage of absolute paths is required to externally include this Makefile +MK_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) +SRC_DIR := $(realpath $(MK_DIR)/$(APP)/src) -include ../common.mk +INCDIRS += $(SRC_DIR) + +SRCS = $(realpath $(SRC_DIR)/$(APP).c) + +LENGTH ?= 20 +TILE_SIZE ?= 4 + +DATA_H = $(SRC_DIR)/data.h + +$(DATA_H): $(MK_DIR)/datagen.py + $< --length=$(LENGTH) --tile_size=$(TILE_SIZE) > $@ + +.PHONY: clean-data clean + +clean-data: + rm -f $(DATA_H) + +clean: clean-data diff --git a/target/snitch_cluster/sw/apps/snax-mac-tiled/data/datagen.py b/target/snitch_cluster/sw/apps/snax-mac-simple/datagen.py similarity index 97% rename from target/snitch_cluster/sw/apps/snax-mac-tiled/data/datagen.py rename to target/snitch_cluster/sw/apps/snax-mac-simple/datagen.py index 83fed0631..d44cd493c 100755 --- a/target/snitch_cluster/sw/apps/snax-mac-tiled/data/datagen.py +++ b/target/snitch_cluster/sw/apps/snax-mac-simple/datagen.py @@ -6,7 +6,7 @@ # Add data utility path sys.path.append(os.path.join(os.path.dirname(__file__), - "../../../../../../util/sim/")) + "../../../../../util/sim/")) from data_utils import format_scalar_definition, \ format_vector_definition # noqa: E402 diff --git a/target/snitch_cluster/sw/apps/snax-mac-simple/tiled/Makefile b/target/snitch_cluster/sw/apps/snax-mac-simple/tiled/Makefile new file mode 100644 index 000000000..07878f52f --- /dev/null +++ b/target/snitch_cluster/sw/apps/snax-mac-simple/tiled/Makefile @@ -0,0 +1,13 @@ +# 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 +# +# Ryan Antonio +# Josse Van Delm + +APP = tiled + +include ../Makefile +include ../../common.mk + +$(DEP): $(DATA_H) diff --git a/target/snitch_cluster/sw/apps/snax-mac-tiled/src/snax-mac-tiled.c b/target/snitch_cluster/sw/apps/snax-mac-simple/tiled/src/tiled.c similarity index 100% rename from target/snitch_cluster/sw/apps/snax-mac-tiled/src/snax-mac-tiled.c rename to target/snitch_cluster/sw/apps/snax-mac-simple/tiled/src/tiled.c diff --git a/target/snitch_cluster/sw/apps/snax-mac-simple/untiled/Makefile b/target/snitch_cluster/sw/apps/snax-mac-simple/untiled/Makefile new file mode 100644 index 000000000..1e328d7d1 --- /dev/null +++ b/target/snitch_cluster/sw/apps/snax-mac-simple/untiled/Makefile @@ -0,0 +1,12 @@ +# 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 +# +# Ryan Antonio + +APP = untiled + +include ../../common.mk +include ../Makefile + +$(DEP): $(DATA_H) diff --git a/target/snitch_cluster/sw/apps/snax-mac-simple/data/data.h b/target/snitch_cluster/sw/apps/snax-mac-simple/untiled/data/data.h similarity index 100% rename from target/snitch_cluster/sw/apps/snax-mac-simple/data/data.h rename to target/snitch_cluster/sw/apps/snax-mac-simple/untiled/data/data.h diff --git a/target/snitch_cluster/sw/apps/snax-mac-simple/src/snax-mac-simple.c b/target/snitch_cluster/sw/apps/snax-mac-simple/untiled/src/untiled.c similarity index 93% rename from target/snitch_cluster/sw/apps/snax-mac-simple/src/snax-mac-simple.c rename to target/snitch_cluster/sw/apps/snax-mac-simple/untiled/src/untiled.c index 59d7e2e72..10c4d5bcd 100644 --- a/target/snitch_cluster/sw/apps/snax-mac-simple/src/snax-mac-simple.c +++ b/target/snitch_cluster/sw/apps/snax-mac-simple/untiled/src/untiled.c @@ -44,9 +44,9 @@ int main() { write_csr(0x3d3, (uint32_t)local_o); // Set configs - write_csr(0x3d4, 1); // Number of iterations - write_csr(0x3d5, 19); // Vector length - write_csr(0x3d6, 1); // Set simple multiplication + write_csr(0x3d4, 1); // Number of iterations + write_csr(0x3d5, VEC_LEN); // Vector length + write_csr(0x3d6, 1); // Set simple multiplication // Write start CSR to launch accelerator write_csr(0x3c0, 0); diff --git a/target/snitch_cluster/sw/apps/snax-mac-tiled/Makefile b/target/snitch_cluster/sw/apps/snax-mac-tiled/Makefile deleted file mode 100644 index d43e3fc3d..000000000 --- a/target/snitch_cluster/sw/apps/snax-mac-tiled/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -# 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 -# -# Ryan Antonio -# Josse Van Delm - -PYTHON = python3 -MK_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) -DATA_DIR := $(realpath $(MK_DIR)/data) -SRC_DIR := $(realpath $(MK_DIR)/src) -DATAGEN_PY = $(DATA_DIR)/datagen.py -DATA_H = $(DATA_DIR)/data.h - -LENGTH ?= 512 -TILE_SIZE ?= 32 - -APP ?= snax-mac-tiled -SRCS ?= $(SRC_DIR)/snax-mac-tiled.c -INCDIRS += $(DATA_DIR) $(SRC_DIR) - -$(DATA_H): $(DATAGEN_PY) - $< --length=$(LENGTH) --tile_size=$(TILE_SIZE) > $@ - -.PHONY: clean-data clean - -clean-data: - rm -f $(DATA_H) - -clean: clean-data - -include ../common.mk - -$(DEP): $(DATA_H) -