diff --git a/sw/apps/atax/Makefile b/sw/apps/atax/Makefile deleted file mode 100644 index c926fdcc2..000000000 --- a/sw/apps/atax/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright 2024 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 - -# Usage of absolute paths is required to externally include this Makefile -MK_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) -DATA_DIR := $(realpath $(MK_DIR)/data) -SRC_DIR := $(realpath $(MK_DIR)/src) - -DATA_CFG ?= $(DATA_DIR)/params.json -SECTION ?= - -APP ?= atax -SRCS ?= $(realpath $(SRC_DIR)/main.c) -INCDIRS ?= $(DATA_DIR) $(SRC_DIR) - -DATAGEN_PY = $(MK_DIR)/scripts/datagen.py -DATA_H = $(DATA_DIR)/data.h - -$(DATA_H): $(DATAGEN_PY) $(DATA_CFG) - $< -c $(DATA_CFG) --section="$(SECTION)" $@ - -.PHONY: clean-data clean - -clean-data: - rm -f $(DATA_H) - -clean: clean-data diff --git a/sw/apps/common.mk b/sw/apps/common.mk new file mode 100644 index 000000000..89f5da9f6 --- /dev/null +++ b/sw/apps/common.mk @@ -0,0 +1,23 @@ +# 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 + +DATA_DIR := $(realpath $(SRC_DIR)/../data) +SCRIPTS_DIR := $(realpath $(SRC_DIR)/../scripts) + +$(APP)_DATA_CFG ?= $(DATA_DIR)/params.json +SECTION ?= +DATA_H := $($(APP)_BUILD_DIR)/data.h +DATAGEN_PY = $(SCRIPTS_DIR)/datagen.py + +$(APP)_HEADERS := $(DATA_H) +$(APP)_INCDIRS := $(dir $(DATA_H)) $(SRC_DIR) + +$(dir $(DATA_H)): + mkdir -p $@ + +$(DATA_H): DATA_CFG := $($(APP)_DATA_CFG) +$(DATA_H): $(DATAGEN_PY) $($(APP)_DATA_CFG) | $(dir $(DATA_H)) + $< -c $(DATA_CFG) --section="$(SECTION)" $@ diff --git a/sw/apps/correlation/Makefile b/sw/apps/correlation/Makefile deleted file mode 100644 index 0f6487830..000000000 --- a/sw/apps/correlation/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright 2024 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 - -# Usage of absolute paths is required to externally include this Makefile -MK_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) -DATA_DIR := $(realpath $(MK_DIR)/data) -SRC_DIR := $(realpath $(MK_DIR)/src) - -DATA_CFG ?= $(DATA_DIR)/params.json -SECTION ?= - -APP ?= correlation -SRCS ?= $(realpath $(SRC_DIR)/main.c) -INCDIRS ?= $(DATA_DIR) $(SRC_DIR) - -DATAGEN_PY = $(MK_DIR)/scripts/datagen.py -DATA_H = $(DATA_DIR)/data.h - -$(DATA_H): $(DATAGEN_PY) $(DATA_CFG) - $< -c $(DATA_CFG) --section="$(SECTION)" $@ - -.PHONY: clean-data clean - -clean-data: - rm -f $(DATA_H) - -clean: clean-data diff --git a/sw/apps/covariance/Makefile b/sw/apps/covariance/Makefile deleted file mode 100644 index b24c2e872..000000000 --- a/sw/apps/covariance/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright 2024 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 - -# Usage of absolute paths is required to externally include this Makefile -MK_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) -DATA_DIR := $(realpath $(MK_DIR)/data) -SRC_DIR := $(realpath $(MK_DIR)/src) - -DATA_CFG ?= $(DATA_DIR)/params.json -SECTION ?= - -APP ?= covariance -SRCS ?= $(realpath $(SRC_DIR)/main.c) -INCDIRS ?= $(DATA_DIR) $(SRC_DIR) - -DATAGEN_PY = $(MK_DIR)/scripts/datagen.py -DATA_H = $(DATA_DIR)/data.h - -$(DATA_H): $(DATAGEN_PY) $(DATA_CFG) - $< -c $(DATA_CFG) --section="$(SECTION)" $@ - -.PHONY: clean-data clean - -clean-data: - rm -f $(DATA_H) - -clean: clean-data diff --git a/sw/apps/lto/Makefile b/sw/apps/lto/Makefile deleted file mode 100644 index 83a6ea21f..000000000 --- a/sw/apps/lto/Makefile +++ /dev/null @@ -1,11 +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 -# -# Luca Colagrande - -# Usage of absolute paths is required to externally include this Makefile -MK_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) - -APP := lto -SRCS := $(addprefix $(MK_DIR),lto.c lto_a.c) diff --git a/sw/apps/lto/lto.c b/sw/apps/lto/lto.c deleted file mode 100644 index 112ed6bab..000000000 --- a/sw/apps/lto/lto.c +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2020 ETH Zurich and University of Bologna. -// Licensed under the Apache License, Version 2.0, see LICENSE for details. -// SPDX-License-Identifier: Apache-2.0 - -#include "lto_a.h" -#include "snrt.h" - -void foo4(void) { printf("Hi\n"); } - -int main() { - // The call to foo1() is optimized by the linker if LTO is enabled - // so the number of cycles t1-t0 should be 1 - size_t t0 = read_csr(minstret); - int res = foo1(); - size_t t1 = read_csr(minstret); - - return (t1 - t0 - 1); -} diff --git a/sw/apps/lto/lto_a.c b/sw/apps/lto/lto_a.c deleted file mode 100644 index 8726f2843..000000000 --- a/sw/apps/lto/lto_a.c +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2020 ETH Zurich and University of Bologna. -// Licensed under the Apache License, Version 2.0, see LICENSE for details. -// SPDX-License-Identifier: Apache-2.0 - -#include "lto_a.h" - -static signed int i = 0; - -void foo2(void) { i = -1; } - -static int foo3() { - foo4(); - return 10; -} - -int foo1(void) { - int data = 0; - - if (i < 0) data = foo3(); - - data = data + 42; - return data; -} diff --git a/sw/apps/lto/lto_a.h b/sw/apps/lto/lto_a.h deleted file mode 100644 index 3aae4d9d4..000000000 --- a/sw/apps/lto/lto_a.h +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2020 ETH Zurich and University of Bologna. -// Licensed under the Apache License, Version 2.0, see LICENSE for details. -// SPDX-License-Identifier: Apache-2.0 - -extern int foo1(void); -extern void foo2(void); -extern void foo4(void); diff --git a/sw/blas/axpy/Makefile b/sw/blas/axpy/Makefile deleted file mode 100644 index 2a755a640..000000000 --- a/sw/blas/axpy/Makefile +++ /dev/null @@ -1,33 +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 -# -# Luca Colagrande - -# Usage of absolute paths is required to externally include this Makefile -MK_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) -DATA_DIR := $(realpath $(MK_DIR)/data) -SRC_DIR := $(realpath $(MK_DIR)/src) - -DATA_CFG ?= $(DATA_DIR)/params.json -SECTION ?= - -APP ?= axpy -SRCS ?= $(realpath $(SRC_DIR)/main.c) -INCDIRS ?= $(dir $(DATA_H)) $(SRC_DIR) - -DATAGEN_PY = $(MK_DIR)/scripts/datagen.py -DATA_H ?= $(DATA_DIR)/data.h - -$(dir $(DATA_H)): - mkdir -p $@ - -$(DATA_H): $(DATAGEN_PY) $(DATA_CFG) | $(dir $(DATA_H)) - $< -c $(DATA_CFG) --section="$(SECTION)" $@ - -.PHONY: clean-data clean - -clean-data: - rm -f $(DATA_H) - -clean: clean-data diff --git a/sw/blas/gemm/Makefile b/sw/blas/gemm/Makefile deleted file mode 100644 index 889cb44f3..000000000 --- a/sw/blas/gemm/Makefile +++ /dev/null @@ -1,33 +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 -# -# Tim Fischer - -# Usage of absolute paths is required to externally include this Makefile -MK_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) -DATA_DIR := $(realpath $(MK_DIR)/data) -SRC_DIR := $(realpath $(MK_DIR)/src) - -DATA_CFG ?= $(DATA_DIR)/params.json -SECTION ?= - -APP ?= gemm -SRCS ?= $(realpath $(SRC_DIR)/main.c) -INCDIRS ?= $(dir $(DATA_H)) $(SRC_DIR) - -DATAGEN_PY = $(MK_DIR)/scripts/datagen.py -DATA_H ?= $(DATA_DIR)/data.h - -$(dir $(DATA_H)): - mkdir -p $@ - -$(DATA_H): $(DATAGEN_PY) $(DATA_CFG) | $(dir $(DATA_H)) - $< -c $(DATA_CFG) --section="$(SECTION)" $@ - -.PHONY: clean-data clean - -clean-data: - rm -f $(DATA_H) - -clean: clean-data diff --git a/sw/dnn/common.mk b/sw/dnn/common.mk index 7bd84a3d7..2e3f45233 100644 --- a/sw/dnn/common.mk +++ b/sw/dnn/common.mk @@ -4,32 +4,6 @@ # # Luca Colagrande -# Usage of absolute paths is required to externally include this Makefile -MK_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) - -DATA_DIR := $(realpath $(MK_DIR)/$(APP)/data) -SCRIPTS_DIR := $(realpath $(MK_DIR)/$(APP)/scripts) -SRC_DIR := $(realpath $(MK_DIR)/$(APP)/src) -COMMON_SRC_DIR := $(realpath $(MK_DIR)/src) - -DATA_CFG ?= $(DATA_DIR)/params.json -SECTION ?= - -SRCS ?= $(realpath $(SRC_DIR)/main.c) -INCDIRS ?= $(dir $(DATA_H)) $(SRC_DIR) $(COMMON_SRC_DIR) - -DATAGEN_PY = $(SCRIPTS_DIR)/datagen.py -DATA_H ?= $(DATA_DIR)/data.h - -$(dir $(DATA_H)): - mkdir -p $@ - -$(DATA_H): $(DATAGEN_PY) $(DATA_CFG) | $(dir $(DATA_H)) - $< -c $(DATA_CFG) --section="$(SECTION)" $@ - -.PHONY: clean-data clean - -clean-data: - rm -f $(DATA_H) - -clean: clean-data +include $(ROOT)/sw/apps/common.mk +$(APP)_INCDIRS += $(ROOT)/sw/dnn/src +$(APP)_INCDIRS += $(ROOT)/sw/blas diff --git a/sw/examples/.gitignore b/sw/examples/.gitignore deleted file mode 100644 index 796b96d1c..000000000 --- a/sw/examples/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/sw/examples/CMakeLists.txt b/sw/examples/CMakeLists.txt deleted file mode 100644 index 2c83d4b58..000000000 --- a/sw/examples/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2020 ETH Zurich and University of Bologna. -# Licensed under the Apache License, Version 2.0, see LICENSE for details. -# SPDX-License-Identifier: Apache-2.0 - -cmake_minimum_required(VERSION 3.13) - -# Read SnitchUtilities -list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) -include(SnitchUtilities) - -# Link simulator -set(SNITCH_SIMULATOR ../../../hw/system/snitch_cluster/bin/snitch_cluster.vlt) - -# Create project -project(Examples LANGUAGES C ASM) - -# Compile options -add_compile_options(-O3 -g -ffunction-sections) - -# Build the runtime -add_subdirectory(../snRuntime snRuntime) - -# Includes -include_directories(${SNRUNTIME_INCLUDE_DIRS}) - -# Programs -add_snitch_executable(hello_world hello_world.c) -add_snitch_executable(memory memory.c) - diff --git a/sw/examples/README.md b/sw/examples/README.md deleted file mode 100644 index ad235f2e9..000000000 --- a/sw/examples/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# Snitch Software Examples - -Build the examples with - -```bash -mkdir build; cd build -cmake -DCMAKE_TOOLCHAIN_FILE=toolchain-llvm -DSNITCH_RUNTIME=snRuntime-banshee .. -make -``` - -Where -- `CMAKE_TOOLCHAIN_FILE` can choose between the LLVM toolchain (`toolchain-llvm`) or GNU GCC (`toolchain-gcc`) -- `SNITCH_RUNTIME` to choose between banshee simulator (`snRuntime-banshee`, default) and RTL simulator (`snRuntime-cluster`) - -To run with banshee -```bash -# Using the generated target -make run-banshee-hello_world -# Manually invoke banshee -banshee --no-opt-llvm --no-opt-jit hello_world --num-cores=4 --num-clusters=1 -``` - -To run with verilator RTL simulator -```bash -# Using the generated target -make run-rtl-hello_world -# Manually invoke RTL simulator -../../../hw/system/snitch_cluster/bin/snitch_cluster.vlt hello_world -``` diff --git a/sw/examples/hello_world.c b/sw/examples/hello_world.c deleted file mode 100644 index 7d8b03095..000000000 --- a/sw/examples/hello_world.c +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2020 ETH Zurich and University of Bologna. -// Licensed under the Apache License, Version 2.0, see LICENSE for details. -// SPDX-License-Identifier: Apache-2.0 - -#include "printf.h" -#include "snrt.h" - -int main() { - uint32_t core_idx = snrt_global_core_idx(); - uint32_t core_num = snrt_global_core_num(); - - printf("# hart %d global core %d(%d) ", snrt_hartid(), - snrt_global_core_idx(), snrt_global_core_num()); - printf("in cluster %d(%d) ", snrt_cluster_idx(), snrt_cluster_num()); - printf("cluster core %d(%d) ", snrt_cluster_core_idx(), - snrt_cluster_core_num()); - printf("compute core %d(%d) ", snrt_cluster_compute_core_idx(), - snrt_cluster_compute_core_num()); - printf("dm core %d(%d) ", snrt_cluster_dm_core_idx(), - snrt_cluster_dm_core_num()); - printf("compute: %d dm: %d ", snrt_is_compute_core(), snrt_is_dm_core()); - printf("\n"); - - printf("# global mem [%#llx:%#llx] cluster mem [%#llx:%#llx] ", - snrt_global_memory().start, snrt_global_memory().end, - snrt_cluster_memory().start, snrt_cluster_memory().end); - printf("\n"); - - return 0; -} diff --git a/sw/examples/memory.c b/sw/examples/memory.c deleted file mode 100644 index b32ee20be..000000000 --- a/sw/examples/memory.c +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2020 ETH Zurich and University of Bologna. -// Licensed under the Apache License, Version 2.0, see LICENSE for details. -// SPDX-License-Identifier: Apache-2.0 - -#include "printf.h" -#include "snrt.h" - -__thread uint32_t private_int; - -int main() { - uint32_t core_idx = snrt_global_core_idx(); - uint32_t core_num = snrt_global_core_num(); - - // Thread-private memory can be used with the __thread specifier. It makes - // use of TLS and buts initialized and non-initialized data in the TCDM - // memory region reserved for the stack. __thread variable must have global - // storage - private_int = 1000 + core_idx; - for (uint32_t i = 0; i < core_num; i++) { - if (i == core_idx) - printf("thread-private: %d at %#x\n", private_int, &private_int); - snrt_barrier(); - } - - // local storage is allocated on stack and also thread-private - uint32_t private_int_stack = 2000 + core_idx; - for (uint32_t i = 0; i < core_num; i++) { - if (i == core_idx) - printf("thread-private on stack: %d at %#x\n", private_int_stack, - &private_int_stack); - snrt_barrier(); - } - - // Use snrt_l1alloc() to allocate a chunk of memory in the cluster-private - // TCMD L1 scratchpad memory. Free is currently not possible. Store the - // pointer in a static variable that is shared amongst the cluster cores - static void* p; - if (core_idx == 0) { - p = snrt_l1alloc(1024); - printf("Allocated at %#x\n", p); - } - for (uint32_t i = 0; i < core_num; i++) { - if (i == core_idx) printf(" %#x pointer location: %#x\n", p, &p); - snrt_barrier(); - } - - return 0; -} diff --git a/target/snitch_cluster/Makefile b/target/snitch_cluster/Makefile index bcd86d5da..bb4f837c6 100644 --- a/target/snitch_cluster/Makefile +++ b/target/snitch_cluster/Makefile @@ -9,14 +9,16 @@ # Makefile invocation # ####################### -DEBUG ?= OFF # ON to turn on debugging symbols and wave logging -CFG_OVERRIDE ?= # Override default config file -SELECT_RUNTIME ?= # Select snRuntime implementation: "banshee" or "rtl" (default) +# ON to turn on debugging symbols and wave logging +DEBUG ?= OFF +# Override default config file +CFG_OVERRIDE ?= +# Select snRuntime implementation: "banshee" or "rtl" (default) +SELECT_RUNTIME ?= rtl .DEFAULT_GOAL := help .PHONY: all clean -all: sw -clean: clean-sw clean-work clean-vcs clean-logs clean-bender clean-generated +clean: clean-work clean-vcs clean-logs clean-bender clean-generated ########## # Common # @@ -24,7 +26,7 @@ clean: clean-sw clean-work clean-vcs clean-logs clean-bender clean-generated MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) MKFILE_DIR := $(dir $(MKFILE_PATH)) -ROOT := ${MKFILE_DIR}../.. +ROOT := $(realpath ${MKFILE_DIR}../..) SNITCH_ROOT := $(ROOT) TARGET = snitch_cluster @@ -204,7 +206,7 @@ clean-work: rm -rf work clean-bender: - rm -rf $(ROOT)/Bender.lock $(ROOT)/.bender/ + rm -rf $(ROOT)/.bender/ clean-logs: rm -rf $(LOGS_DIR) diff --git a/target/snitch_cluster/sw.mk b/target/snitch_cluster/sw.mk index c9d6e7e7a..ca8246124 100644 --- a/target/snitch_cluster/sw.mk +++ b/target/snitch_cluster/sw.mk @@ -4,14 +4,14 @@ # # Luca Colagrande -MK_TARGET ?= all -SELECT_RUNTIME ?= rtl +################### +# General targets # +################### -ifeq ($(SELECT_RUNTIME), banshee) -RUNTIME = sw/runtime/banshee -else -RUNTIME = sw/runtime/rtl -endif +.PHONY: sw clean-sw + +all: sw +clean: clean-sw #################### # Platform headers # @@ -22,10 +22,10 @@ CLUSTER_GEN_HEADERS = snitch_cluster_cfg.h \ REGGEN_HEADERS = snitch_cluster_peripheral.h -TARGET_C_HDRS_DIR = sw/runtime/common +TARGET_C_HDRS_DIR = $(ROOT)/target/snitch_cluster/sw/runtime/common TARGET_C_HDRS = $(addprefix $(TARGET_C_HDRS_DIR)/,$(CLUSTER_GEN_HEADERS) $(REGGEN_HEADERS)) -# CLUSTERGEN headers +# CLUSTERGEN headers, $(addprefix $(TARGET_C_HDRS_DIR)/,$(CLUSTER_GEN_HEADERS)): %.h: $(CFG) $(CLUSTER_GEN_PREREQ) %.h.tpl @echo "[CLUSTERGEN] Generate $@" $(CLUSTER_GEN) -c $< --outdir $(TARGET_C_HDRS_DIR) --template $@.tpl @@ -34,12 +34,20 @@ $(addprefix $(TARGET_C_HDRS_DIR)/,$(CLUSTER_GEN_HEADERS)): %.h: $(CFG) $(CLUSTER $(TARGET_C_HDRS_DIR)/snitch_cluster_peripheral.h: $(ROOT)/hw/snitch_cluster/src/snitch_cluster_peripheral/snitch_cluster_peripheral_reg.hjson $(REGGEN) $(call reggen_generate_header,$@,$<) -######## -# Apps # -######## +.PHONY: clean-headers +clean-sw: clean-headers +clean-headers: + rm -f $(TARGET_C_HDRS) + +################## +# Subdirectories # +################## -APPS = sw/apps/lto -APPS += sw/apps/nop +include sw/toolchain.mk +include sw/runtime/runtime.mk +include sw/tests/tests.mk + +APPS = sw/apps/nop APPS += sw/apps/blas/axpy APPS += sw/apps/blas/gemm APPS += sw/apps/blas/dot @@ -59,19 +67,7 @@ APPS += sw/apps/atax APPS += sw/apps/correlation APPS += sw/apps/covariance -SUBDIRS = sw/runtime/banshee sw/runtime/rtl $(APPS) sw/tests - -.PHONY: sw clean-sw $(SUBDIRS) - -sw: $(SUBDIRS) -clean-sw: - $(MAKE) sw MK_TARGET=clean - rm -f $(TARGET_C_HDRS) - -# Runtime libraries depend on platform headers -sw/runtime/rtl sw/runtime/banshee: $(TARGET_C_HDRS) - $(MAKE) -C $@ $(MK_TARGET) - -# Apps depend on runtime libraries -$(APPS) sw/tests: $(RUNTIME) - $(MAKE) -C $@ $(MK_TARGET) +# Include Makefile from each app subdirectory +$(foreach app,$(APPS), \ + $(eval include $(app)/app.mk) \ +) diff --git a/target/snitch_cluster/sw/apps/atax/Makefile b/target/snitch_cluster/sw/apps/atax/Makefile deleted file mode 100644 index 1962a43fe..000000000 --- a/target/snitch_cluster/sw/apps/atax/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright 2024 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 - -include ../../../../../sw/apps/atax/Makefile -include ../common.mk - -$(DEP): $(DATA_H) diff --git a/target/snitch_cluster/sw/apps/atax/app.mk b/target/snitch_cluster/sw/apps/atax/app.mk new file mode 100644 index 000000000..87e94ca8a --- /dev/null +++ b/target/snitch_cluster/sw/apps/atax/app.mk @@ -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 +# +# Luca Colagrande + +APP := atax +$(APP)_BUILD_DIR ?= $(ROOT)/target/snitch_cluster/sw/apps/$(APP)/build +SRC_DIR := $(ROOT)/sw/apps/$(APP)/src +SRCS := $(SRC_DIR)/main.c + +include $(ROOT)/sw/apps/common.mk +include $(ROOT)/target/snitch_cluster/sw/apps/common.mk diff --git a/target/snitch_cluster/sw/apps/blas/axpy/Makefile b/target/snitch_cluster/sw/apps/blas/axpy/Makefile deleted file mode 100644 index cc9164f30..000000000 --- a/target/snitch_cluster/sw/apps/blas/axpy/Makefile +++ /dev/null @@ -1,10 +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 -# -# Luca Colagrande - -include ../../../../../../sw/blas/axpy/Makefile -include ../../common.mk - -$(DEP): $(DATA_H) diff --git a/target/snitch_cluster/sw/apps/blas/axpy/app.mk b/target/snitch_cluster/sw/apps/blas/axpy/app.mk new file mode 100644 index 000000000..76c4f90e2 --- /dev/null +++ b/target/snitch_cluster/sw/apps/blas/axpy/app.mk @@ -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 +# +# Luca Colagrande + +APP := axpy +$(APP)_BUILD_DIR ?= $(ROOT)/target/snitch_cluster/sw/apps/blas/$(APP)/build +SRC_DIR := $(ROOT)/sw/blas/$(APP)/src +SRCS := $(SRC_DIR)/main.c + +include $(ROOT)/sw/apps/common.mk +include $(ROOT)/target/snitch_cluster/sw/apps/common.mk diff --git a/target/snitch_cluster/sw/apps/blas/dot/Makefile b/target/snitch_cluster/sw/apps/blas/dot/Makefile deleted file mode 100644 index 41e58a534..000000000 --- a/target/snitch_cluster/sw/apps/blas/dot/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright 2024 ETH Zurich and University of Bologna. -# Licensed under the Apache License, Version 2.0, see LICENSE for details. -# SPDX-License-Identifier: Apache-2.0 -# -# Matteo Perotti - -include ../../../../../../sw/blas/dot/Makefile -include ../../common.mk - -$(DEP): $(DATA_H) diff --git a/target/snitch_cluster/sw/apps/blas/dot/app.mk b/target/snitch_cluster/sw/apps/blas/dot/app.mk new file mode 100644 index 000000000..2e62f6bdf --- /dev/null +++ b/target/snitch_cluster/sw/apps/blas/dot/app.mk @@ -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 +# +# Luca Colagrande + +APP := dot +$(APP)_BUILD_DIR ?= $(ROOT)/target/snitch_cluster/sw/apps/blas/$(APP)/build +SRC_DIR := $(ROOT)/sw/blas/$(APP)/src +SRCS := $(SRC_DIR)/main.c + +include $(ROOT)/sw/apps/common.mk +include $(ROOT)/target/snitch_cluster/sw/apps/common.mk diff --git a/target/snitch_cluster/sw/apps/blas/gemm/Makefile b/target/snitch_cluster/sw/apps/blas/gemm/Makefile deleted file mode 100644 index 7625cda9c..000000000 --- a/target/snitch_cluster/sw/apps/blas/gemm/Makefile +++ /dev/null @@ -1,10 +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 -# -# Tim Fischer - -include ../../../../../../sw/blas/gemm/Makefile -include ../../common.mk - -$(DEP): $(DATA_H) diff --git a/target/snitch_cluster/sw/apps/blas/gemm/app.mk b/target/snitch_cluster/sw/apps/blas/gemm/app.mk new file mode 100644 index 000000000..5d2b54068 --- /dev/null +++ b/target/snitch_cluster/sw/apps/blas/gemm/app.mk @@ -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 +# +# Luca Colagrande + +APP := gemm +$(APP)_BUILD_DIR ?= $(ROOT)/target/snitch_cluster/sw/apps/blas/$(APP)/build +SRC_DIR := $(ROOT)/sw/blas/$(APP)/src +SRCS := $(SRC_DIR)/main.c + +include $(ROOT)/sw/apps/common.mk +include $(ROOT)/target/snitch_cluster/sw/apps/common.mk diff --git a/target/snitch_cluster/sw/apps/blas/gemm/test/test.sh b/target/snitch_cluster/sw/apps/blas/gemm/test/test.sh index fa0eb6979..236631b82 100755 --- a/target/snitch_cluster/sw/apps/blas/gemm/test/test.sh +++ b/target/snitch_cluster/sw/apps/blas/gemm/test/test.sh @@ -13,5 +13,5 @@ TEST_LIST=$(pwd)/run.yaml CFG_FILES=$(pwd)/cfg/"*" CMD="$ROOT/sw/blas/gemm/scripts/verify.py \${sim_bin} \${elf} --dump-results" -$BUILD_PY sw/apps/blas/gemm --cfg $CFG_FILES --testlist $TEST_LIST --testlist-cmd "$CMD" +$BUILD_PY gemm --cfg $CFG_FILES --testlist $TEST_LIST --testlist-cmd "$CMD" $RUN_PY $TEST_LIST --simulator vsim -j diff --git a/target/snitch_cluster/sw/apps/common.mk b/target/snitch_cluster/sw/apps/common.mk index 0b7a10ebd..1877d6ad5 100644 --- a/target/snitch_cluster/sw/apps/common.mk +++ b/target/snitch_cluster/sw/apps/common.mk @@ -1,93 +1,85 @@ -# Copyright 2023 ETH Zurich and University of Bologna. +# Copyright 2024 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 - -# 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 - -############### -# Directories # -############### - -# Fixed paths in repository tree -ROOT := $(abspath $(MK_DIR)/../../../..) -SNRT_DIR := $(ROOT)/sw/snRuntime -ifeq ($(SELECT_RUNTIME), banshee) -RUNTIME_DIR := $(ROOT)/target/snitch_cluster/sw/runtime/banshee -RISCV_CFLAGS += -DBIST -else -RUNTIME_DIR := $(ROOT)/target/snitch_cluster/sw/runtime/rtl -endif - -# Paths relative to the app including this Makefile -APP_BUILDDIR ?= $(abspath build) +# Luca Colagrande $@ -$(ELF): $(SRCS) $(DEP) $(LIBS) | $(APP_BUILDDIR) +$(ELF): $(SRCS) $(DEP) $($(APP)_LIBS) | $($(APP)_BUILD_DIR) $(RISCV_CC) $(RISCV_CFLAGS) $(RISCV_LDFLAGS) $(SRCS) -o $@ -$(DUMP): $(ELF) | $(APP_BUILDDIR) +$(DUMP): $(ELF) | $($(APP)_BUILD_DIR) $(RISCV_OBJDUMP) $(RISCV_OBJDUMP_FLAGS) $< > $@ -$(DWARF): $(ELF) | $(APP_BUILDDIR) +$(DWARF): $(ELF) | $($(APP)_BUILD_DIR) $(RISCV_DWARFDUMP) $< > $@ ifneq ($(MAKECMDGOALS),clean) +ifneq ($(MAKECMDGOALS),clean-sw) -include $(DEP) endif +endif diff --git a/target/snitch_cluster/sw/apps/correlation/Makefile b/target/snitch_cluster/sw/apps/correlation/Makefile deleted file mode 100644 index e5588e8ad..000000000 --- a/target/snitch_cluster/sw/apps/correlation/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright 2024 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 - -include ../../../../../sw/apps/correlation/Makefile -include ../common.mk - -$(DEP): $(DATA_H) diff --git a/target/snitch_cluster/sw/apps/correlation/app.mk b/target/snitch_cluster/sw/apps/correlation/app.mk new file mode 100644 index 000000000..f2284a6ce --- /dev/null +++ b/target/snitch_cluster/sw/apps/correlation/app.mk @@ -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 +# +# Luca Colagrande + +APP := correlation +$(APP)_BUILD_DIR ?= $(ROOT)/target/snitch_cluster/sw/apps/$(APP)/build +SRC_DIR := $(ROOT)/sw/apps/$(APP)/src +SRCS := $(SRC_DIR)/main.c + +include $(ROOT)/sw/apps/common.mk +include $(ROOT)/target/snitch_cluster/sw/apps/common.mk diff --git a/target/snitch_cluster/sw/apps/covariance/Makefile b/target/snitch_cluster/sw/apps/covariance/Makefile deleted file mode 100644 index e3016de89..000000000 --- a/target/snitch_cluster/sw/apps/covariance/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright 2024 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 - -include ../../../../../sw/apps/covariance/Makefile -include ../common.mk - -$(DEP): $(DATA_H) diff --git a/target/snitch_cluster/sw/apps/covariance/app.mk b/target/snitch_cluster/sw/apps/covariance/app.mk new file mode 100644 index 000000000..c177a9d61 --- /dev/null +++ b/target/snitch_cluster/sw/apps/covariance/app.mk @@ -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 +# +# Luca Colagrande + +APP := covariance +$(APP)_BUILD_DIR ?= $(ROOT)/target/snitch_cluster/sw/apps/$(APP)/build +SRC_DIR := $(ROOT)/sw/apps/$(APP)/src +SRCS := $(SRC_DIR)/main.c + +include $(ROOT)/sw/apps/common.mk +include $(ROOT)/target/snitch_cluster/sw/apps/common.mk diff --git a/target/snitch_cluster/sw/apps/dnn/batchnorm/Makefile b/target/snitch_cluster/sw/apps/dnn/batchnorm/Makefile deleted file mode 100644 index f84fccea6..000000000 --- a/target/snitch_cluster/sw/apps/dnn/batchnorm/Makefile +++ /dev/null @@ -1,12 +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 -# -# Luca Colagrande - -APP ?= batchnorm - -include ../../../../../../sw/dnn/common.mk -include ../../common.mk - -$(DEP): $(DATA_H) \ No newline at end of file diff --git a/target/snitch_cluster/sw/apps/dnn/batchnorm/app.mk b/target/snitch_cluster/sw/apps/dnn/batchnorm/app.mk new file mode 100644 index 000000000..016162a66 --- /dev/null +++ b/target/snitch_cluster/sw/apps/dnn/batchnorm/app.mk @@ -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 +# +# Luca Colagrande + +APP := batchnorm +$(APP)_BUILD_DIR ?= $(ROOT)/target/snitch_cluster/sw/apps/dnn/$(APP)/build +SRC_DIR := $(ROOT)/sw/dnn/$(APP)/src +SRCS := $(SRC_DIR)/main.c + +include $(ROOT)/sw/dnn/common.mk +include $(ROOT)/target/snitch_cluster/sw/apps/common.mk diff --git a/target/snitch_cluster/sw/apps/dnn/concat/Makefile b/target/snitch_cluster/sw/apps/dnn/concat/Makefile deleted file mode 100644 index 088d29d66..000000000 --- a/target/snitch_cluster/sw/apps/dnn/concat/Makefile +++ /dev/null @@ -1,12 +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 -# -# Luca Colagrande - -APP ?= concat - -include ../../../../../../sw/dnn/common.mk -include ../../common.mk - -$(DEP): $(DATA_H) \ No newline at end of file diff --git a/target/snitch_cluster/sw/apps/dnn/concat/app.mk b/target/snitch_cluster/sw/apps/dnn/concat/app.mk new file mode 100644 index 000000000..3fd2b8ee5 --- /dev/null +++ b/target/snitch_cluster/sw/apps/dnn/concat/app.mk @@ -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 +# +# Luca Colagrande + +APP := concat +$(APP)_BUILD_DIR ?= $(ROOT)/target/snitch_cluster/sw/apps/dnn/$(APP)/build +SRC_DIR := $(ROOT)/sw/dnn/$(APP)/src +SRCS := $(SRC_DIR)/main.c + +include $(ROOT)/sw/dnn/common.mk +include $(ROOT)/target/snitch_cluster/sw/apps/common.mk diff --git a/target/snitch_cluster/sw/apps/dnn/conv2d/Makefile b/target/snitch_cluster/sw/apps/dnn/conv2d/Makefile deleted file mode 100644 index a9018b35d..000000000 --- a/target/snitch_cluster/sw/apps/dnn/conv2d/Makefile +++ /dev/null @@ -1,13 +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 -# -# Gianna Paulin -# Viviane Potocnik - -APP ?= conv2d - -include ../../../../../../sw/dnn/common.mk -include ../../common.mk - -$(DEP): $(DATA_H) diff --git a/target/snitch_cluster/sw/apps/dnn/conv2d/app.mk b/target/snitch_cluster/sw/apps/dnn/conv2d/app.mk new file mode 100644 index 000000000..5dcc592df --- /dev/null +++ b/target/snitch_cluster/sw/apps/dnn/conv2d/app.mk @@ -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 +# +# Luca Colagrande + +APP := conv2d +$(APP)_BUILD_DIR ?= $(ROOT)/target/snitch_cluster/sw/apps/dnn/$(APP)/build +SRC_DIR := $(ROOT)/sw/dnn/$(APP)/src +SRCS := $(SRC_DIR)/main.c + +include $(ROOT)/sw/dnn/common.mk +include $(ROOT)/target/snitch_cluster/sw/apps/common.mk diff --git a/target/snitch_cluster/sw/apps/dnn/flashattention_2/Makefile b/target/snitch_cluster/sw/apps/dnn/flashattention_2/Makefile deleted file mode 100644 index 75585b2d6..000000000 --- a/target/snitch_cluster/sw/apps/dnn/flashattention_2/Makefile +++ /dev/null @@ -1,12 +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 -# -# Luca Colagrande - -APP ?= flashattention_2 - -include ../../../../../../sw/dnn/common.mk -include ../../common.mk - -$(DEP): $(DATA_H) diff --git a/target/snitch_cluster/sw/apps/dnn/flashattention_2/app.mk b/target/snitch_cluster/sw/apps/dnn/flashattention_2/app.mk new file mode 100644 index 000000000..a08ae6874 --- /dev/null +++ b/target/snitch_cluster/sw/apps/dnn/flashattention_2/app.mk @@ -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 +# +# Luca Colagrande + +APP := flashattention_2 +$(APP)_BUILD_DIR ?= $(ROOT)/target/snitch_cluster/sw/apps/dnn/$(APP)/build +SRC_DIR := $(ROOT)/sw/dnn/$(APP)/src +SRCS := $(SRC_DIR)/main.c + +include $(ROOT)/sw/dnn/common.mk +include $(ROOT)/target/snitch_cluster/sw/apps/common.mk diff --git a/target/snitch_cluster/sw/apps/dnn/flashattention_2/test/test.sh b/target/snitch_cluster/sw/apps/dnn/flashattention_2/test/test.sh index 704d8146d..35cbf23e2 100755 --- a/target/snitch_cluster/sw/apps/dnn/flashattention_2/test/test.sh +++ b/target/snitch_cluster/sw/apps/dnn/flashattention_2/test/test.sh @@ -12,5 +12,5 @@ TEST_LIST=$(pwd)/run.yaml CFG_FILES=$(pwd)/cfg/"*" CMD="$ROOT/sw/dnn/flashattention_2/scripts/verify.py \${sim_bin} \${elf} --dump-results" -$BUILD_PY sw/apps/dnn/flashattention_2 --cfg $CFG_FILES --testlist $TEST_LIST --testlist-cmd "$CMD" +$BUILD_PY flashattention_2 --cfg $CFG_FILES --testlist $TEST_LIST --testlist-cmd "$CMD" $RUN_PY $TEST_LIST --simulator vsim -j diff --git a/target/snitch_cluster/sw/apps/dnn/fused_concat_linear/Makefile b/target/snitch_cluster/sw/apps/dnn/fused_concat_linear/Makefile deleted file mode 100644 index 827014a08..000000000 --- a/target/snitch_cluster/sw/apps/dnn/fused_concat_linear/Makefile +++ /dev/null @@ -1,12 +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 -# -# Luca Colagrande - -APP ?= fused_concat_linear - -include ../../../../../../sw/dnn/common.mk -include ../../common.mk - -$(DEP): $(DATA_H) diff --git a/target/snitch_cluster/sw/apps/dnn/fused_concat_linear/app.mk b/target/snitch_cluster/sw/apps/dnn/fused_concat_linear/app.mk new file mode 100644 index 000000000..c10af49be --- /dev/null +++ b/target/snitch_cluster/sw/apps/dnn/fused_concat_linear/app.mk @@ -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 +# +# Luca Colagrande + +APP := fused_concat_linear +$(APP)_BUILD_DIR ?= $(ROOT)/target/snitch_cluster/sw/apps/dnn/$(APP)/build +SRC_DIR := $(ROOT)/sw/dnn/$(APP)/src +SRCS := $(SRC_DIR)/main.c + +include $(ROOT)/sw/dnn/common.mk +include $(ROOT)/target/snitch_cluster/sw/apps/common.mk diff --git a/target/snitch_cluster/sw/apps/dnn/fusedconv/Makefile b/target/snitch_cluster/sw/apps/dnn/fusedconv/Makefile deleted file mode 100644 index 927d6b3e0..000000000 --- a/target/snitch_cluster/sw/apps/dnn/fusedconv/Makefile +++ /dev/null @@ -1,13 +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 -# -# Gianna Paulin -# Viviane Potocnik - -APP ?= fusedconv - -include ../../../../../../sw/dnn/common.mk -include ../../common.mk - -$(DEP): $(DATA_H) \ No newline at end of file diff --git a/target/snitch_cluster/sw/apps/dnn/fusedconv/app.mk b/target/snitch_cluster/sw/apps/dnn/fusedconv/app.mk new file mode 100644 index 000000000..b269f5cdb --- /dev/null +++ b/target/snitch_cluster/sw/apps/dnn/fusedconv/app.mk @@ -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 +# +# Luca Colagrande + +APP := fusedconv +$(APP)_BUILD_DIR ?= $(ROOT)/target/snitch_cluster/sw/apps/dnn/$(APP)/build +SRC_DIR := $(ROOT)/sw/dnn/$(APP)/src +SRCS := $(SRC_DIR)/main.c + +include $(ROOT)/sw/dnn/common.mk +include $(ROOT)/target/snitch_cluster/sw/apps/common.mk diff --git a/target/snitch_cluster/sw/apps/dnn/gelu/Makefile b/target/snitch_cluster/sw/apps/dnn/gelu/Makefile deleted file mode 100644 index 4225a8cd8..000000000 --- a/target/snitch_cluster/sw/apps/dnn/gelu/Makefile +++ /dev/null @@ -1,12 +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 -# -# Luca Colagrande - -APP ?= gelu - -include ../../../../../../sw/dnn/common.mk -include ../../common.mk - -$(DEP): $(DATA_H) \ No newline at end of file diff --git a/target/snitch_cluster/sw/apps/dnn/gelu/app.mk b/target/snitch_cluster/sw/apps/dnn/gelu/app.mk new file mode 100644 index 000000000..2032f0784 --- /dev/null +++ b/target/snitch_cluster/sw/apps/dnn/gelu/app.mk @@ -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 +# +# Luca Colagrande + +APP := gelu +$(APP)_BUILD_DIR ?= $(ROOT)/target/snitch_cluster/sw/apps/dnn/$(APP)/build +SRC_DIR := $(ROOT)/sw/dnn/$(APP)/src +SRCS := $(SRC_DIR)/main.c + +include $(ROOT)/sw/dnn/common.mk +include $(ROOT)/target/snitch_cluster/sw/apps/common.mk diff --git a/target/snitch_cluster/sw/apps/dnn/layernorm/Makefile b/target/snitch_cluster/sw/apps/dnn/layernorm/Makefile deleted file mode 100644 index f8df5a08a..000000000 --- a/target/snitch_cluster/sw/apps/dnn/layernorm/Makefile +++ /dev/null @@ -1,12 +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 -# -# Luca Colagrande - -APP ?= layernorm - -include ../../../../../../sw/dnn/common.mk -include ../../common.mk - -$(DEP): $(DATA_H) diff --git a/target/snitch_cluster/sw/apps/dnn/layernorm/app.mk b/target/snitch_cluster/sw/apps/dnn/layernorm/app.mk new file mode 100644 index 000000000..d2dc68c75 --- /dev/null +++ b/target/snitch_cluster/sw/apps/dnn/layernorm/app.mk @@ -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 +# +# Luca Colagrande + +APP := layernorm +$(APP)_BUILD_DIR ?= $(ROOT)/target/snitch_cluster/sw/apps/dnn/$(APP)/build +SRC_DIR := $(ROOT)/sw/dnn/$(APP)/src +SRCS := $(SRC_DIR)/main.c + +include $(ROOT)/sw/dnn/common.mk +include $(ROOT)/target/snitch_cluster/sw/apps/common.mk diff --git a/target/snitch_cluster/sw/apps/dnn/maxpool/Makefile b/target/snitch_cluster/sw/apps/dnn/maxpool/Makefile deleted file mode 100644 index e83838ca4..000000000 --- a/target/snitch_cluster/sw/apps/dnn/maxpool/Makefile +++ /dev/null @@ -1,12 +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 -# -# Luca Colagrande - -APP ?= maxpool - -include ../../../../../../sw/dnn/common.mk -include ../../common.mk - -$(DEP): $(DATA_H) \ No newline at end of file diff --git a/target/snitch_cluster/sw/apps/dnn/maxpool/app.mk b/target/snitch_cluster/sw/apps/dnn/maxpool/app.mk new file mode 100644 index 000000000..3d7af9652 --- /dev/null +++ b/target/snitch_cluster/sw/apps/dnn/maxpool/app.mk @@ -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 +# +# Luca Colagrande + +APP := maxpool +$(APP)_BUILD_DIR ?= $(ROOT)/target/snitch_cluster/sw/apps/dnn/$(APP)/build +SRC_DIR := $(ROOT)/sw/dnn/$(APP)/src +SRCS := $(SRC_DIR)/main.c + +include $(ROOT)/sw/dnn/common.mk +include $(ROOT)/target/snitch_cluster/sw/apps/common.mk diff --git a/target/snitch_cluster/sw/apps/dnn/softmax/Makefile b/target/snitch_cluster/sw/apps/dnn/softmax/Makefile deleted file mode 100644 index d4f685c7d..000000000 --- a/target/snitch_cluster/sw/apps/dnn/softmax/Makefile +++ /dev/null @@ -1,12 +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 -# -# Luca Colagrande - -APP ?= softmax - -include ../../../../../../sw/dnn/common.mk -include ../../common.mk - -$(DEP): $(DATA_H) diff --git a/target/snitch_cluster/sw/apps/dnn/softmax/app.mk b/target/snitch_cluster/sw/apps/dnn/softmax/app.mk new file mode 100644 index 000000000..7618d6c51 --- /dev/null +++ b/target/snitch_cluster/sw/apps/dnn/softmax/app.mk @@ -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 +# +# Luca Colagrande + +APP := softmax +$(APP)_BUILD_DIR ?= $(ROOT)/target/snitch_cluster/sw/apps/dnn/$(APP)/build +SRC_DIR := $(ROOT)/sw/dnn/$(APP)/src +SRCS := $(SRC_DIR)/main.c + +include $(ROOT)/sw/dnn/common.mk +include $(ROOT)/target/snitch_cluster/sw/apps/common.mk diff --git a/target/snitch_cluster/sw/apps/dnn/transpose/Makefile b/target/snitch_cluster/sw/apps/dnn/transpose/Makefile deleted file mode 100644 index b1c819cfe..000000000 --- a/target/snitch_cluster/sw/apps/dnn/transpose/Makefile +++ /dev/null @@ -1,12 +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 -# -# Luca Colagrande - -APP ?= transpose - -include ../../../../../../sw/dnn/common.mk -include ../../common.mk - -$(DEP): $(DATA_H) diff --git a/target/snitch_cluster/sw/apps/dnn/transpose/app.mk b/target/snitch_cluster/sw/apps/dnn/transpose/app.mk new file mode 100644 index 000000000..204ba4a0b --- /dev/null +++ b/target/snitch_cluster/sw/apps/dnn/transpose/app.mk @@ -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 +# +# Luca Colagrande + +APP := transpose +$(APP)_BUILD_DIR ?= $(ROOT)/target/snitch_cluster/sw/apps/dnn/$(APP)/build +SRC_DIR := $(ROOT)/sw/dnn/$(APP)/src +SRCS := $(SRC_DIR)/main.c + +include $(ROOT)/sw/dnn/common.mk +include $(ROOT)/target/snitch_cluster/sw/apps/common.mk diff --git a/target/snitch_cluster/sw/apps/dnn/transpose/test/test.sh b/target/snitch_cluster/sw/apps/dnn/transpose/test/test.sh index 8794e3d11..02e85373c 100755 --- a/target/snitch_cluster/sw/apps/dnn/transpose/test/test.sh +++ b/target/snitch_cluster/sw/apps/dnn/transpose/test/test.sh @@ -12,5 +12,5 @@ TEST_LIST=$(pwd)/run.yaml CFG_FILES=$(pwd)/cfg/"*" CMD="$ROOT/sw/dnn/transpose/scripts/verify.py \${sim_bin} \${elf} --dump-results" -$BUILD_PY sw/apps/dnn/transpose --cfg $CFG_FILES --testlist $TEST_LIST --testlist-cmd "$CMD" +$BUILD_PY transpose --cfg $CFG_FILES --testlist $TEST_LIST --testlist-cmd "$CMD" $RUN_PY $TEST_LIST --simulator vsim -j diff --git a/target/snitch_cluster/sw/apps/lto/Makefile b/target/snitch_cluster/sw/apps/lto/Makefile deleted file mode 100644 index a55bcac8a..000000000 --- a/target/snitch_cluster/sw/apps/lto/Makefile +++ /dev/null @@ -1,8 +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 -# -# Luca Colagrande - -include ../../../../../sw/apps/lto/Makefile -include ../common.mk diff --git a/target/snitch_cluster/sw/apps/montecarlo/pi_estimation/Makefile b/target/snitch_cluster/sw/apps/montecarlo/pi_estimation/Makefile deleted file mode 100644 index ed455b3b5..000000000 --- a/target/snitch_cluster/sw/apps/montecarlo/pi_estimation/Makefile +++ /dev/null @@ -1,14 +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 -# -# Luca Colagrande - -PI_ESTIMATION_DIR = ../../../../../../sw/apps/montecarlo/pi_estimation -PRNG_DIR = ../../../../../../sw/apps/prng - -APP ?= pi_estimation -SRCS ?= $(PI_ESTIMATION_DIR)/main.c -INCDIRS += $(PI_ESTIMATION_DIR) $(PRNG_DIR) - -include ../../common.mk diff --git a/target/snitch_cluster/sw/apps/montecarlo/pi_estimation/app.mk b/target/snitch_cluster/sw/apps/montecarlo/pi_estimation/app.mk new file mode 100644 index 000000000..998456aa0 --- /dev/null +++ b/target/snitch_cluster/sw/apps/montecarlo/pi_estimation/app.mk @@ -0,0 +1,15 @@ +# 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 + +PI_ESTIMATION_DIR := $(ROOT)/sw/apps/montecarlo/pi_estimation +PRNG_DIR := $(ROOT)/sw/apps/prng + +APP := pi_estimation +SRCS := $(PI_ESTIMATION_DIR)/main.c +$(APP)_INCDIRS := $(PI_ESTIMATION_DIR) $(PRNG_DIR) +$(APP)_BUILD_DIR ?= $(ROOT)/target/snitch_cluster/sw/apps/montecarlo/pi_estimation/build + +include $(ROOT)/target/snitch_cluster/sw/apps/common.mk diff --git a/target/snitch_cluster/sw/apps/nop/Makefile b/target/snitch_cluster/sw/apps/nop/Makefile deleted file mode 100644 index 1218113c9..000000000 --- a/target/snitch_cluster/sw/apps/nop/Makefile +++ /dev/null @@ -1,10 +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 -# -# Luca Colagrande - -APP = nop -SRCS = src/$(APP).c - -include ../common.mk diff --git a/target/snitch_cluster/sw/apps/nop/app.mk b/target/snitch_cluster/sw/apps/nop/app.mk new file mode 100644 index 000000000..9f3938f37 --- /dev/null +++ b/target/snitch_cluster/sw/apps/nop/app.mk @@ -0,0 +1,11 @@ +# 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 + +APP := nop +SRCS := $(ROOT)/target/snitch_cluster/sw/apps/$(APP)/src/main.c +$(APP)_BUILD_DIR ?= $(ROOT)/target/snitch_cluster/sw/apps/$(APP)/build + +include $(ROOT)/target/snitch_cluster/sw/apps/common.mk diff --git a/target/snitch_cluster/sw/apps/nop/src/nop.c b/target/snitch_cluster/sw/apps/nop/src/main.c similarity index 100% rename from target/snitch_cluster/sw/apps/nop/src/nop.c rename to target/snitch_cluster/sw/apps/nop/src/main.c diff --git a/target/snitch_cluster/sw/runtime/banshee/Makefile b/target/snitch_cluster/sw/runtime/banshee/Makefile deleted file mode 100644 index ae9ff7f77..000000000 --- a/target/snitch_cluster/sw/runtime/banshee/Makefile +++ /dev/null @@ -1,10 +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 -# -# Luca Colagrande - -SRCS = snitch_cluster_start.S -SRCS += snrt.c - -include ../common/common.mk diff --git a/target/snitch_cluster/sw/runtime/common/common.mk b/target/snitch_cluster/sw/runtime/common/common.mk deleted file mode 100644 index 08d7d15c2..000000000 --- a/target/snitch_cluster/sw/runtime/common/common.mk +++ /dev/null @@ -1,76 +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 -# -# Luca Colagrande - -# 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 - -############### -# Directories # -############### - -# Fixed paths in repository tree -ROOT = $(abspath $(MK_DIR)/../../../../..) -SNRT_DIR = $(ROOT)/sw/snRuntime - -# Paths relative to the runtime including this Makefile -BUILDDIR = $(abspath build) -SRC_DIR = $(abspath src) - -################### -# Build variables # -################### - -INCDIRS += $(SNRT_DIR)/src -INCDIRS += $(SNRT_DIR)/api -INCDIRS += $(SNRT_DIR)/src/omp -INCDIRS += $(SNRT_DIR)/api/omp -INCDIRS += $(SNRT_DIR)/vendor/riscv-opcodes -INCDIRS += $(ROOT)/target/snitch_cluster/sw/runtime/common - -########### -# Outputs # -########### - -OBJS = $(addprefix $(BUILDDIR)/,$(addsuffix .o,$(basename $(notdir $(SRCS))))) -DEPS = $(addprefix $(BUILDDIR)/,$(addsuffix .d,$(basename $(notdir $(SRCS))))) -LIB = $(BUILDDIR)/libsnRuntime.a -DUMP = $(BUILDDIR)/libsnRuntime.dump -ALL_OUTPUTS = $(LIB) $(DUMP) - -######### -# Rules # -######### - -.PHONY: all -all: $(ALL_OUTPUTS) - -.PHONY: clean -clean: - rm -rf $(BUILDDIR) - -$(BUILDDIR): - mkdir -p $@ - -$(BUILDDIR)/%.o: $(SRC_DIR)/%.S | $(BUILDDIR) - $(RISCV_CC) $(RISCV_CFLAGS) -c $< -o $@ - -$(BUILDDIR)/%.o: $(SRC_DIR)/%.c | $(BUILDDIR) - $(RISCV_CC) $(RISCV_CFLAGS) -c $< -o $@ - -$(BUILDDIR)/%.d: $(SRC_DIR)/%.c | $(BUILDDIR) - $(RISCV_CC) $(RISCV_CFLAGS) -MM -MT '$(@:.d=.o)' $< > $@ - -$(LIB): $(OBJS) | $(BUILDDIR) - $(RISCV_AR) $(RISCV_ARFLAGS) $@ $^ - -$(DUMP): $(LIB) | $(BUILDDIR) - $(RISCV_OBJDUMP) -D $< > $@ - -ifneq ($(MAKECMDGOALS),clean) --include $(DEPS) -endif diff --git a/target/snitch_cluster/sw/runtime/banshee/memory.ld b/target/snitch_cluster/sw/runtime/memory.ld similarity index 100% rename from target/snitch_cluster/sw/runtime/banshee/memory.ld rename to target/snitch_cluster/sw/runtime/memory.ld diff --git a/target/snitch_cluster/sw/runtime/rtl/Makefile b/target/snitch_cluster/sw/runtime/rtl/Makefile deleted file mode 100644 index ae9ff7f77..000000000 --- a/target/snitch_cluster/sw/runtime/rtl/Makefile +++ /dev/null @@ -1,10 +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 -# -# Luca Colagrande - -SRCS = snitch_cluster_start.S -SRCS += snrt.c - -include ../common/common.mk diff --git a/target/snitch_cluster/sw/runtime/rtl/memory.ld b/target/snitch_cluster/sw/runtime/rtl/memory.ld deleted file mode 100644 index 985c7cfd8..000000000 --- a/target/snitch_cluster/sw/runtime/rtl/memory.ld +++ /dev/null @@ -1,8 +0,0 @@ -/* Copyright 2020 ETH Zurich and University of Bologna. */ -/* Solderpad Hardware License, Version 0.51, see LICENSE for details. */ -/* SPDX-License-Identifier: SHL-0.51 */ - -MEMORY -{ - L3 (rwxa) : ORIGIN = 0x80000000, LENGTH = 0x80000000 -} diff --git a/target/snitch_cluster/sw/runtime/runtime.mk b/target/snitch_cluster/sw/runtime/runtime.mk new file mode 100644 index 000000000..8f15ebab1 --- /dev/null +++ b/target/snitch_cluster/sw/runtime/runtime.mk @@ -0,0 +1,82 @@ +# 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 + +############### +# Directories # +############### + +SNRT_DIR = $(ROOT)/sw/snRuntime +SNRT_TARGET_DIR = $(ROOT)/target/snitch_cluster/sw/runtime/$(SELECT_RUNTIME) +SNRT_BUILDDIR = $(SNRT_TARGET_DIR)/build +SNRT_SRCDIR = $(SNRT_TARGET_DIR)/src + +################### +# Build variables # +################### + +SNRT_SRCS = snitch_cluster_start.S +SNRT_SRCS += snrt.c + +SNRT_INCDIRS += $(SNRT_DIR)/src +SNRT_INCDIRS += $(SNRT_DIR)/api +SNRT_INCDIRS += $(SNRT_DIR)/src/omp +SNRT_INCDIRS += $(SNRT_DIR)/api/omp +SNRT_INCDIRS += $(SNRT_DIR)/vendor/riscv-opcodes +SNRT_INCDIRS += $(SNRT_SRCDIR) +SNRT_INCDIRS += $(SNRT_TARGET_DIR)/../common + +SNRT_RISCV_CFLAGS += $(RISCV_CFLAGS) +SNRT_RISCV_CFLAGS += $(addprefix -I,$(SNRT_INCDIRS)) + +########### +# Outputs # +########### + +SNRT_OBJS = $(addprefix $(SNRT_BUILDDIR)/,$(addsuffix .o,$(basename $(notdir $(SNRT_SRCS))))) +SNRT_DEPS = $(addprefix $(SNRT_BUILDDIR)/,$(addsuffix .d,$(basename $(notdir $(SNRT_SRCS))))) +SNRT_LIB = $(SNRT_BUILDDIR)/libsnRuntime.a +SNRT_DUMP = $(SNRT_BUILDDIR)/libsnRuntime.dump +SNRT_OUTPUTS = $(SNRT_LIB) $(SNRT_DUMP) + +######### +# Rules # +######### + +.PHONY: runtime clean-runtime + +sw: runtime +clean-sw: clean-runtime + +runtime: $(SNRT_OUTPUTS) + +clean-runtime: + rm -rf $(SNRT_BUILDDIR) + +$(SNRT_BUILDDIR): + mkdir -p $@ + +$(SNRT_BUILDDIR)/%.o: $(SNRT_SRCDIR)/%.S | $(SNRT_BUILDDIR) + $(RISCV_CC) $(SNRT_RISCV_CFLAGS) -c $< -o $@ + +$(SNRT_BUILDDIR)/%.o: $(SNRT_SRCDIR)/%.c | $(SNRT_BUILDDIR) + $(RISCV_CC) $(SNRT_RISCV_CFLAGS) -c $< -o $@ + +$(SNRT_BUILDDIR)/%.d: $(SNRT_SRCDIR)/%.c | $(SNRT_BUILDDIR) + $(RISCV_CC) $(SNRT_RISCV_CFLAGS) -MM -MT '$(@:.d=.o)' $< > $@ + +$(SNRT_LIB): $(SNRT_OBJS) | $(SNRT_BUILDDIR) + $(RISCV_AR) $(RISCV_ARFLAGS) $@ $^ + +$(SNRT_DUMP): $(SNRT_LIB) | $(SNRT_BUILDDIR) + $(RISCV_OBJDUMP) $(RISCV_OBJDUMP_FLAGS) $< > $@ + +$(SNRT_DEPS): | $(TARGET_C_HDRS) + +ifneq ($(MAKECMDGOALS),clean) +ifneq ($(MAKECMDGOALS),clean-sw) +-include $(SNRT_DEPS) +endif +endif diff --git a/target/snitch_cluster/sw/tests/Makefile b/target/snitch_cluster/sw/tests/Makefile deleted file mode 100644 index 87a488e9a..000000000 --- a/target/snitch_cluster/sw/tests/Makefile +++ /dev/null @@ -1,86 +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 -# -# Luca Colagrande - -# 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 - -############### -# Directories # -############### - -ROOT = $(abspath ../../../..) -SNRT_DIR = $(ROOT)/sw/snRuntime -SRC_DIR = $(ROOT)/sw/tests -BUILDDIR = $(ROOT)/target/snitch_cluster/sw/tests/build -ifeq ($(SELECT_RUNTIME), banshee) -RUNTIME_DIR = $(ROOT)/target/snitch_cluster/sw/runtime/banshee -else -RUNTIME_DIR = $(ROOT)/target/snitch_cluster/sw/runtime/rtl -endif - -################### -# Build variables # -################### - -INCDIRS += $(RUNTIME_DIR)/src -INCDIRS += $(RUNTIME_DIR)/../common -INCDIRS += $(SNRT_DIR)/api -INCDIRS += $(SNRT_DIR)/api/omp -INCDIRS += $(SNRT_DIR)/src -INCDIRS += $(SNRT_DIR)/src/omp -INCDIRS += $(SNRT_DIR)/vendor/riscv-opcodes - -RISCV_LDFLAGS += -L$(abspath $(RUNTIME_DIR)) -RISCV_LDFLAGS += -T$(abspath $(SNRT_DIR)/base.ld) -RISCV_LDFLAGS += -L$(abspath $(RUNTIME_DIR)/build/) -RISCV_LDFLAGS += -lsnRuntime - -########### -# Outputs # -########### - -APPS = $(basename $(notdir $(wildcard $(SRC_DIR)/*.c))) -ELFS = $(abspath $(addprefix $(BUILDDIR)/,$(addsuffix .elf,$(APPS)))) -DEPS = $(abspath $(addprefix $(BUILDDIR)/,$(addsuffix .d,$(APPS)))) -DUMPS = $(abspath $(addprefix $(BUILDDIR)/,$(addsuffix .dump,$(APPS)))) -DWARFS = $(abspath $(addprefix $(BUILDDIR)/,$(addsuffix .dwarf,$(APPS)))) -ALL_OUTPUTS = $(ELFS) - -ifeq ($(DEBUG), ON) -ALL_OUTPUTS += $(DUMPS) $(DWARFS) -endif - -######### -# Rules # -######### - -.PHONY: all -all: $(ALL_OUTPUTS) - -.PHONY: clean -clean: - rm -rf $(BUILDDIR) - -$(BUILDDIR): - mkdir -p $@ - -$(BUILDDIR)/%.d: $(SRC_DIR)/%.c | $(BUILDDIR) - $(RISCV_CC) $(RISCV_CFLAGS) -MM -MT '$(BUILDDIR)/$*.elf' $< > $@ - -$(BUILDDIR)/%.elf: $(SRC_DIR)/%.c $(BUILDDIR)/%.d | $(BUILDDIR) - $(RISCV_CC) $(RISCV_CFLAGS) $(RISCV_LDFLAGS) $(SRC_DIR)/$*.c -o $@ - -$(BUILDDIR)/%.dump: $(BUILDDIR)/%.elf | $(BUILDDIR) - $(RISCV_OBJDUMP) $(RISCV_OBJDUMP_FLAGS) $< > $@ - -$(BUILDDIR)/%.dwarf: $(BUILDDIR)/%.elf | $(BUILDDIR) - $(RISCV_DWARFDUMP) --all $< > $@ - -ifneq ($(MAKECMDGOALS),clean) --include $(DEPS) -endif diff --git a/target/snitch_cluster/sw/tests/tests.mk b/target/snitch_cluster/sw/tests/tests.mk new file mode 100644 index 000000000..35afa66ea --- /dev/null +++ b/target/snitch_cluster/sw/tests/tests.mk @@ -0,0 +1,77 @@ +# 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 + +############### +# Directories # +############### + +TESTS_SRCDIR = $(ROOT)/sw/tests +TESTS_BUILDDIR = $(ROOT)/target/snitch_cluster/sw/tests/build + +################### +# Build variables # +################### + +TESTS_RISCV_CFLAGS += $(RISCV_CFLAGS) +TESTS_RISCV_CFLAGS += $(addprefix -I,$(SNRT_INCDIRS)) + +TESTS_RISCV_LDFLAGS += $(RISCV_LDFLAGS) +TESTS_RISCV_LDFLAGS += -L$(abspath $(SNRT_TARGET_DIR)/..) +TESTS_RISCV_LDFLAGS += -T$(abspath $(SNRT_DIR)/base.ld) +TESTS_RISCV_LDFLAGS += -L$(SNRT_TARGET_DIR)/build +TESTS_RISCV_LDFLAGS += -lsnRuntime + +########### +# Outputs # +########### + +TEST_NAMES = $(basename $(notdir $(wildcard $(TESTS_SRCDIR)/*.c))) +TEST_ELFS = $(abspath $(addprefix $(TESTS_BUILDDIR)/,$(addsuffix .elf,$(TEST_NAMES)))) +TEST_DEPS = $(abspath $(addprefix $(TESTS_BUILDDIR)/,$(addsuffix .d,$(TEST_NAMES)))) +TEST_DUMPS = $(abspath $(addprefix $(TESTS_BUILDDIR)/,$(addsuffix .dump,$(TEST_NAMES)))) +TEST_DWARFS = $(abspath $(addprefix $(TESTS_BUILDDIR)/,$(addsuffix .dwarf,$(TEST_NAMES)))) +TEST_OUTPUTS = $(TEST_ELFS) + +ifeq ($(DEBUG), ON) +TEST_OUTPUTS += $(DUMPS) $(DWARFS) +endif + +######### +# Rules # +######### + +.PHONY: tests clean-tests + +sw: tests +clean-sw: clean-tests + +tests: $(TEST_OUTPUTS) + +clean-tests: + rm -rf $(TESTS_BUILDDIR) + +$(TESTS_BUILDDIR): + mkdir -p $@ + +$(TESTS_BUILDDIR)/%.d: $(TESTS_SRCDIR)/%.c | $(TESTS_BUILDDIR) + $(RISCV_CC) $(TESTS_RISCV_CFLAGS) -MM -MT '$(TESTS_BUILDDIR)/$*.elf' $< > $@ + +$(TESTS_BUILDDIR)/%.elf: $(TESTS_SRCDIR)/%.c $(SNRT_LIB) $(TESTS_BUILDDIR)/%.d | $(TESTS_BUILDDIR) + $(RISCV_CC) $(TESTS_RISCV_CFLAGS) $(TESTS_RISCV_LDFLAGS) $(TESTS_SRCDIR)/$*.c -o $@ + +$(TESTS_BUILDDIR)/%.dump: $(TESTS_BUILDDIR)/%.elf | $(TESTS_BUILDDIR) + $(RISCV_OBJDUMP) $(RISCV_OBJDUMP_FLAGS) $< > $@ + +$(TESTS_BUILDDIR)/%.dwarf: $(TESTS_BUILDDIR)/%.elf | $(TESTS_BUILDDIR) + $(RISCV_DWARFDUMP) $< > $@ + +$(TEST_DEPS): | $(TARGET_C_HDRS) + +ifneq ($(MAKECMDGOALS),clean) +ifneq ($(MAKECMDGOALS),clean-sw) +-include $(TEST_DEPS) +endif +endif diff --git a/target/snitch_cluster/sw/toolchain.mk b/target/snitch_cluster/sw/toolchain.mk index a57f229d2..9cadb8c44 100644 --- a/target/snitch_cluster/sw/toolchain.mk +++ b/target/snitch_cluster/sw/toolchain.mk @@ -26,8 +26,7 @@ RISCV_OBJDUMP ?= $(LLVM_BINROOT)/llvm-objdump RISCV_DWARFDUMP ?= $(LLVM_BINROOT)/llvm-dwarfdump # Compiler flags -RISCV_CFLAGS += $(addprefix -I,$(INCDIRS)) -RISCV_CFLAGS += -mcpu=snitch +RISCV_CFLAGS := -mcpu=snitch RISCV_CFLAGS += -menable-experimental-extensions RISCV_CFLAGS += -mabi=ilp32d RISCV_CFLAGS += -mcmodel=medany @@ -47,13 +46,13 @@ RISCV_CFLAGS += -DOPENOCD_SEMIHOSTING endif # Linker flags -RISCV_LDFLAGS += -fuse-ld=$(RISCV_LD) +RISCV_LDFLAGS := -fuse-ld=$(RISCV_LD) RISCV_LDFLAGS += -nostartfiles RISCV_LDFLAGS += -lm # Archiver flags -RISCV_ARFLAGS = rcs +RISCV_ARFLAGS := rcs # Objdump flags -RISCV_OBJDUMP_FLAGS += --mcpu=snitch +RISCV_OBJDUMP_FLAGS := --mcpu=snitch RISCV_OBJDUMP_FLAGS += -D diff --git a/target/snitch_cluster/util/build.py b/target/snitch_cluster/util/build.py index 11fe5cb95..f8a084ac9 100755 --- a/target/snitch_cluster/util/build.py +++ b/target/snitch_cluster/util/build.py @@ -13,15 +13,14 @@ It assumes a build system with a specific interface which most existing kernels comply with. In particular, it assumes the following: -- the data generation can be configured through a YAML file. The path to -this file is provided to the build system in the `DATA_CFG` environment -variable. -- the generated data is written to a header file at the path specified by -the `DATA_H` environment variable. -- all build artifacts are created in the directory specified by the -`APP_BUILDDIR` environment variable. - the build command should be a make target defined by the Snitch cluster target. +- the data generation can be configured through a JSON file. The path to +this file is provided to the build system in the `$(APP)_DATA_CFG` +environment variable, where `$(APP)` coincides with the build command +name. +- all build artifacts are created in the directory specified by the +`$(APP)_BUILD_DIR` environment variable. This utility takes a list of data configuration files as input and builds the application with the data generated from each configuration. Build @@ -59,21 +58,20 @@ def parser(): return parser -def extend_environment(env=None, **kwargs): +def extend_environment(vars, env=None): if env is None: env = os.environ.copy() - env.update(kwargs) + env.update(vars) return env # Build software target with a specific data configuration def build(target, cfg): # Define configuration-specific variables for build system - env = extend_environment( - DATA_CFG=cfg, - DATA_H=Path(f'include/{cfg.stem}/data.h').resolve(), - APP_BUILDDIR=Path(f'build/{cfg.stem}').resolve() - ) + env = extend_environment({ + f'{target}_DATA_CFG': cfg, + f'{target}_BUILD_DIR': Path(f'build/{cfg.stem}').resolve() + }) # Build the software mk_dir = Path(__file__).resolve().parent.parent