Skip to content

Commit

Permalink
sw: Switch from recursive to non-recursive Make
Browse files Browse the repository at this point in the history
  • Loading branch information
colluca committed Aug 1, 2024
1 parent b462592 commit 0cb1525
Show file tree
Hide file tree
Showing 62 changed files with 533 additions and 707 deletions.
30 changes: 0 additions & 30 deletions sw/apps/atax/Makefile

This file was deleted.

23 changes: 23 additions & 0 deletions sw/apps/common.mk
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>

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)" $@
30 changes: 0 additions & 30 deletions sw/apps/correlation/Makefile

This file was deleted.

30 changes: 0 additions & 30 deletions sw/apps/covariance/Makefile

This file was deleted.

33 changes: 0 additions & 33 deletions sw/blas/axpy/Makefile

This file was deleted.

33 changes: 0 additions & 33 deletions sw/blas/gemm/Makefile

This file was deleted.

32 changes: 3 additions & 29 deletions sw/dnn/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,6 @@
#
# Luca Colagrande <[email protected]>

# 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
14 changes: 8 additions & 6 deletions target/snitch_cluster/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,24 @@
# 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 #
##########

MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
MKFILE_DIR := $(dir $(MKFILE_PATH))
ROOT := ${MKFILE_DIR}../..
ROOT := $(realpath ${MKFILE_DIR}../..)
SNITCH_ROOT := $(ROOT)

TARGET = snitch_cluster
Expand Down
56 changes: 26 additions & 30 deletions target/snitch_cluster/sw.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
#
# Luca Colagrande <[email protected]>

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 #
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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) \
)
10 changes: 0 additions & 10 deletions target/snitch_cluster/sw/apps/atax/Makefile

This file was deleted.

13 changes: 13 additions & 0 deletions target/snitch_cluster/sw/apps/atax/app.mk
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>

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
10 changes: 0 additions & 10 deletions target/snitch_cluster/sw/apps/blas/axpy/Makefile

This file was deleted.

13 changes: 13 additions & 0 deletions target/snitch_cluster/sw/apps/blas/axpy/app.mk
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>

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
10 changes: 0 additions & 10 deletions target/snitch_cluster/sw/apps/blas/dot/Makefile

This file was deleted.

Loading

0 comments on commit 0cb1525

Please sign in to comment.