From 6071b0d70982ba89d9c0e777f2f75d984c3aa57c Mon Sep 17 00:00:00 2001 From: Luca Colagrande Date: Thu, 3 Oct 2024 20:58:23 +0200 Subject: [PATCH 01/21] treewide: Remove verible, unused in Snitch --- target/common/common.mk | 1 - util/container/Dockerfile | 7 ------- 2 files changed, 8 deletions(-) diff --git a/target/common/common.mk b/target/common/common.mk index 77d0e79d3..20aec8528 100644 --- a/target/common/common.mk +++ b/target/common/common.mk @@ -23,7 +23,6 @@ VERILATOR_SEPP ?= BENDER ?= bender VLT ?= $(VERILATOR_SEPP) verilator VCS ?= $(VCS_SEPP) vcs -VERIBLE_FMT ?= verible-verilog-format CLANG_FORMAT ?= clang-format VSIM ?= $(QUESTA_SEPP) vsim VOPT ?= $(QUESTA_SEPP) vopt diff --git a/util/container/Dockerfile b/util/container/Dockerfile index 4cd5c8ea5..7605d331d 100644 --- a/util/container/Dockerfile +++ b/util/container/Dockerfile @@ -12,7 +12,6 @@ ARG UBUNTU_VERSION=22.04 FROM ubuntu:${UBUNTU_VERSION} AS builder ARG BENDER_VERSION=0.28.1 ARG DOXYGEN_VERSION=1.12.0 -ARG VERIBLE_VERSION=0.0-3318-g8d254167 ARG SNITCH_LLVM_VERSION=latest ARG RUST_VERSION=1.63.0 ARG UBUNTU_VERSION @@ -47,11 +46,6 @@ WORKDIR /tools RUN wget https://github.com/pulp-platform/bender/releases/download/v${BENDER_VERSION}/bender-${BENDER_VERSION}-x86_64-linux-gnu-ubuntu${UBUNTU_VERSION}.tar.gz && \ tar xzf bender-${BENDER_VERSION}-x86_64-linux-gnu-ubuntu${UBUNTU_VERSION}.tar.gz -# Install Verible -RUN wget https://github.com/chipsalliance/verible/releases/download/v${VERIBLE_VERSION}/verible-v${VERIBLE_VERSION}-linux-static-x86_64.tar.gz && \ - tar -x -f verible-v${VERIBLE_VERSION}-linux-static-x86_64.tar.gz --strip-components=1 -C . && \ - rm -rf verible-v${VERIBLE_VERSION}-linux-static-x86_64.tar.gz - # Install Doxygen RUN wget https://www.doxygen.nl/files/doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz && \ tar xzf doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz && \ @@ -111,7 +105,6 @@ RUN ${VIRTUAL_ENV}/bin/pip install --upgrade pip && \ COPY --from=builder /tools/bender /tools/bin/ # COPY --from=builder /root/.cargo/bin/banshee /tools/bin/ COPY --from=builder /tools/doxygen/bin/doxygen /tools/bin/ -COPY --from=builder /tools/verible* /tools/bin/ COPY --from=builder /tools/riscv-llvm /tools/riscv-llvm # Modify environment and path variables From f69ba3aabf9c46415a2e19e256ae428ce370e643 Mon Sep 17 00:00:00 2001 From: Luca Colagrande Date: Fri, 20 Dec 2024 15:42:34 +0100 Subject: [PATCH 02/21] treewide: Update after iDMA integration --- .github/CODEOWNERS | 1 - Bender.yml | 4 ++-- Makefile | 2 +- target/common/common.mk | 2 +- target/snitch_cluster/Makefile | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 70ea7fe02..ef8a0e10d 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -5,6 +5,5 @@ * @paulsc96 @colluca @fischeti hw/snitch_cluster @paulsc96 @lucabertaccini -hw/snitch_dma @paulsc96 @thommythomaso sw @colluca @fischeti @viv-eth diff --git a/Bender.yml b/Bender.yml index 29fc783b5..797236bbe 100644 --- a/Bender.yml +++ b/Bender.yml @@ -184,9 +184,9 @@ sources: - target/common/test/tb_bin.sv # target/snitch_cluster - - target: snitch_cluster + - target: snitch_cluster_wrapper files: - target/snitch_cluster/generated/snitch_cluster_wrapper.sv - - target: all(snitch_cluster, any(simulation, verilator)) + - target: all(snitch_cluster_wrapper, any(simulation, verilator)) files: - target/snitch_cluster/test/testharness.sv diff --git a/Makefile b/Makefile index bdfa044c2..56f432f45 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ ROOT = $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) ############ NONFREE_REMOTE ?= git@iis-git.ee.ethz.ch:pulp-restricted/snitch-cluster-nonfree.git -NONFREE_COMMIT ?= e30961e20a23a76442da27d2ba07c9fe20f3b575 +NONFREE_COMMIT ?= 35cdb5b03778d3ec52e6d8fa0856ee789489b25a NONFREE_DIR = $(ROOT)/nonfree all: nonfree diff --git a/target/common/common.mk b/target/common/common.mk index 20aec8528..c9538d51a 100644 --- a/target/common/common.mk +++ b/target/common/common.mk @@ -51,7 +51,7 @@ MATCH_BGN := 's/+incdir+//g' MATCH_DEF := '/+define+/d' SED_SRCS := sed -e ${MATCH_END} -e ${MATCH_BGN} -e ${MATCH_DEF} -COMMON_BENDER_FLAGS += -t rtl +COMMON_BENDER_FLAGS += -t rtl -t snitch_cluster VSIM_BENDER += $(COMMON_BENDER_FLAGS) -t test -t simulation -t vsim VSIM_SOURCES = $(shell ${BENDER} script flist-plus ${VSIM_BENDER} | ${SED_SRCS}) diff --git a/target/snitch_cluster/Makefile b/target/snitch_cluster/Makefile index 1a5ab2388..ae6ec0ec0 100644 --- a/target/snitch_cluster/Makefile +++ b/target/snitch_cluster/Makefile @@ -66,7 +66,7 @@ $(BIN_DIR): # Simulator options # ##################### -COMMON_BENDER_FLAGS += -t snitch_cluster +COMMON_BENDER_FLAGS += -t snitch_cluster_wrapper QUESTA_64BIT = -64 VLOG_64BIT = -64 From 1d88a5eb73f400455651244bd649bd605be2a9f3 Mon Sep 17 00:00:00 2001 From: Luca Colagrande Date: Tue, 5 Nov 2024 18:57:18 +0100 Subject: [PATCH 03/21] treewide: Bump `cluster_icache` --- Bender.lock | 12 ++++++------ Bender.yml | 2 +- hw/snitch_cluster/src/snitch_cluster.sv | 17 +++++++++-------- .../snitch_cluster_peripheral.sv | 5 +++-- .../src/snitch_cluster_wrapper.sv.tpl | 4 ++-- hw/snitch_cluster/src/snitch_hive.sv | 13 +++++++------ target/snitch_cluster/cfg/default.hjson | 2 +- target/snitch_cluster/cfg/dma_mchan.hjson | 2 +- target/snitch_cluster/cfg/fdiv.hjson | 2 +- target/snitch_cluster/cfg/github-ci.hjson | 2 +- target/snitch_cluster/cfg/omega.hjson | 2 +- util/clustergen/cluster.py | 2 +- .../schema/snitch_cluster.schema.json | 4 ++-- 13 files changed, 36 insertions(+), 33 deletions(-) diff --git a/Bender.lock b/Bender.lock index d48a9c04d..00301ecb1 100644 --- a/Bender.lock +++ b/Bender.lock @@ -32,8 +32,8 @@ packages: dependencies: - common_cells cluster_icache: - revision: 0e1fb6751d9684d968ba7fb40836e6118b448ecd - version: 0.1.1 + revision: 64e21ae455bbdde850c4df13bef86ea55ac42537 + version: null source: Git: https://github.com/pulp-platform/cluster_icache.git dependencies: @@ -50,8 +50,8 @@ packages: - common_verification - tech_cells_generic common_verification: - revision: 9c07fa860593b2caabd9b5681740c25fac04b878 - version: 0.2.3 + revision: fa2630f61666f61d9d78451c4d8b4d1ea403944e + version: 0.2.4 source: Git: https://github.com/pulp-platform/common_verification.git dependencies: [] @@ -91,8 +91,8 @@ packages: - common_cells - common_verification register_interface: - revision: ae616e5a1ec2b41e72d200e5ab09c65e94aebd3d - version: 0.4.4 + revision: 5daa85d164cf6b54ad061ea1e4c6f3624556e467 + version: 0.4.5 source: Git: https://github.com/pulp-platform/register_interface dependencies: diff --git a/Bender.yml b/Bender.yml index 797236bbe..40a67ca48 100644 --- a/Bender.yml +++ b/Bender.yml @@ -26,7 +26,7 @@ dependencies: register_interface: { git: https://github.com/pulp-platform/register_interface, version: 0.4.2 } tech_cells_generic: { git: https://github.com/pulp-platform/tech_cells_generic, version: 0.2.11 } riscv-dbg: { git: https://github.com/pulp-platform/riscv-dbg, version: 0.8.0 } - cluster_icache: { git: https://github.com/pulp-platform/cluster_icache.git, version: 0.1.0 } + cluster_icache: { git: https://github.com/pulp-platform/cluster_icache.git, rev: 64e21ae455bbdde850c4df13bef86ea55ac42537 } idma: { git: https://github.com/pulp-platform/iDMA, rev: __deploy__9cbcd30__snitch-tracing } export_include_dirs: diff --git a/hw/snitch_cluster/src/snitch_cluster.sv b/hw/snitch_cluster/src/snitch_cluster.sv index 9d68831f3..e86bcd7e2 100644 --- a/hw/snitch_cluster/src/snitch_cluster.sv +++ b/hw/snitch_cluster/src/snitch_cluster.sv @@ -22,6 +22,7 @@ /// Snitch Cluster Top-Level. module snitch_cluster import snitch_pkg::*; + import snitch_icache_pkg::*; #( /// Width of physical address. parameter int unsigned PhysicalAddrWidth = 48, @@ -63,8 +64,8 @@ module snitch_cluster parameter int unsigned ICacheLineWidth [NrHives] = '{default: 0}, /// Number of icache lines per set. parameter int unsigned ICacheLineCount [NrHives] = '{default: 0}, - /// Number of icache sets. - parameter int unsigned ICacheSets [NrHives] = '{default: 0}, + /// Number of icache ways. + parameter int unsigned ICacheWays [NrHives] = '{default: 0}, /// Enable virtual memory support. parameter bit VMSupport = 1, /// Per-core enabling of the standard `E` ISA reduced-register extension. @@ -510,10 +511,10 @@ module snitch_cluster tcdm_req_t [NrTCDMPortsCores-1:0] tcdm_req; tcdm_rsp_t [NrTCDMPortsCores-1:0] tcdm_rsp; - core_events_t [NrCores-1:0] core_events; - tcdm_events_t tcdm_events; - dma_events_t [DMANumChannels-1:0] dma_events; - snitch_icache_pkg::icache_events_t [NrCores-1:0] icache_events; + core_events_t [NrCores-1:0] core_events; + tcdm_events_t tcdm_events; + dma_events_t [DMANumChannels-1:0] dma_events; + icache_l0_events_t [NrCores-1:0] icache_events; // 4. Memory Subsystem (Core side). reqrsp_req_t [NrCores-1:0] core_req; @@ -969,7 +970,7 @@ module snitch_cluster hive_req_t [HiveSize-1:0] hive_req_reshape; hive_rsp_t [HiveSize-1:0] hive_rsp_reshape; - snitch_icache_pkg::icache_events_t [HiveSize-1:0] icache_events_reshape; + icache_l0_events_t [HiveSize-1:0] icache_events_reshape; for (genvar j = 0; j < NrCores; j++) begin : gen_hive_matrix // Check whether the core actually belongs to the current hive. @@ -993,7 +994,7 @@ module snitch_cluster .CoreCount (HiveSize), .ICacheLineWidth (ICacheLineWidth[i]), .ICacheLineCount (ICacheLineCount[i]), - .ICacheSets (ICacheSets[i]), + .ICacheWays (ICacheWays[i]), .IsoCrossing (IsoCrossing), .sram_cfg_t (sram_cfg_t), .sram_cfgs_t (sram_cfgs_t), diff --git a/hw/snitch_cluster/src/snitch_cluster_peripheral/snitch_cluster_peripheral.sv b/hw/snitch_cluster/src/snitch_cluster_peripheral/snitch_cluster_peripheral.sv index d2e5ff319..df5c375ab 100644 --- a/hw/snitch_cluster/src/snitch_cluster_peripheral/snitch_cluster_peripheral.sv +++ b/hw/snitch_cluster/src/snitch_cluster_peripheral/snitch_cluster_peripheral.sv @@ -8,6 +8,7 @@ module snitch_cluster_peripheral import snitch_pkg::*; + import snitch_icache_pkg::*; import snitch_cluster_peripheral_reg_pkg::*; #( // Nr of cores in the cluster @@ -31,13 +32,13 @@ module snitch_cluster_peripheral input core_events_t [NrCores-1:0] core_events_i, input tcdm_events_t tcdm_events_i, input dma_events_t [DMANumChannels-1:0] dma_events_i, - input snitch_icache_pkg::icache_events_t [NrCores-1:0] icache_events_i + input icache_l0_events_t [NrCores-1:0] icache_events_i ); // Pipeline register to ease timing. tcdm_events_t tcdm_events_q; dma_events_t [DMANumChannels-1:0] dma_events_q; - snitch_icache_pkg::icache_events_t [NrCores-1:0] icache_events_q; + icache_l0_events_t [NrCores-1:0] icache_events_q; `FF(tcdm_events_q, tcdm_events_i, '0) `FF(dma_events_q, dma_events_i, '0) `FF(icache_events_q, icache_events_i, '0) diff --git a/hw/snitch_cluster/src/snitch_cluster_wrapper.sv.tpl b/hw/snitch_cluster/src/snitch_cluster_wrapper.sv.tpl index b3c35d9ac..6e30881ea 100644 --- a/hw/snitch_cluster/src/snitch_cluster_wrapper.sv.tpl +++ b/hw/snitch_cluster/src/snitch_cluster_wrapper.sv.tpl @@ -66,7 +66,7 @@ package ${cfg['pkg_name']}; localparam int unsigned ICacheLineWidth [NrHives] = '{${icache_cfg('cacheline')}}; localparam int unsigned ICacheLineCount [NrHives] = '{${icache_cfg('depth')}}; - localparam int unsigned ICacheSets [NrHives] = '{${icache_cfg('sets')}}; + localparam int unsigned ICacheWays [NrHives] = '{${icache_cfg('ways')}}; localparam int unsigned Hive [NrCores] = '{${core_cfg('hive')}}; @@ -277,7 +277,7 @@ module ${cfg['name']}_wrapper ( .DMANumChannels (${cfg['dma_nr_channels']}), .ICacheLineWidth (${cfg['pkg_name']}::ICacheLineWidth), .ICacheLineCount (${cfg['pkg_name']}::ICacheLineCount), - .ICacheSets (${cfg['pkg_name']}::ICacheSets), + .ICacheWays (${cfg['pkg_name']}::ICacheWays), .VMSupport (${int(cfg['vm_support'])}), .RVE (${core_isa('e')}), .RVF (${core_isa('f')}), diff --git a/hw/snitch_cluster/src/snitch_hive.sv b/hw/snitch_cluster/src/snitch_hive.sv index fbb5f6910..4e5064c46 100644 --- a/hw/snitch_cluster/src/snitch_hive.sv +++ b/hw/snitch_cluster/src/snitch_hive.sv @@ -7,15 +7,15 @@ `include "snitch_vm/typedef.svh" /// Shared subsystems for `CoreCount` cores. -module snitch_hive #( +module snitch_hive import snitch_icache_pkg::*; #( /// Number of cores which share an instruction frontend parameter int unsigned CoreCount = 4, /// Width of a single icache line. parameter int unsigned ICacheLineWidth = CoreCount > 2 ? CoreCount * 32 : 64, /// Number of icache lines per set. parameter int unsigned ICacheLineCount = 128, - /// Number of icache sets. - parameter int unsigned ICacheSets = 4, + /// Number of icache ways. + parameter int unsigned ICacheWays = 4, parameter bit IsoCrossing = 1, /// Address width of the buses parameter int unsigned AddrWidth = 0, @@ -53,7 +53,7 @@ module snitch_hive #( input sram_cfgs_t sram_cfgs_i, - output snitch_icache_pkg::icache_events_t [CoreCount-1:0] icache_events_o + output icache_l0_events_t [CoreCount-1:0] icache_events_o ); // Extend the ID to route back results to the appropriate core. localparam int unsigned IdWidth = 5; @@ -87,7 +87,7 @@ module snitch_hive #( .L0_LINE_COUNT ( 8 ), .LINE_WIDTH ( ICacheLineWidth ), .LINE_COUNT ( ICacheLineCount ), - .SET_COUNT ( ICacheSets ), + .WAY_COUNT ( ICacheWays ), .FETCH_AW ( AddrWidth ), .FETCH_DW ( 32 ), .FILL_AW ( AddrWidth ), @@ -107,7 +107,8 @@ module snitch_hive #( .clk_d2_i (clk_d2_i), .rst_ni (rst_ni), .enable_prefetching_i ( icache_prefetch_enable_i ), - .icache_events_o ( icache_events_o), + .icache_l0_events_o ( icache_events_o), + .icache_l1_events_o ( ), .flush_valid_i ( flush_valid ), .flush_ready_o ( flush_ready ), diff --git a/target/snitch_cluster/cfg/default.hjson b/target/snitch_cluster/cfg/default.hjson index 93cb2dbec..309a46638 100644 --- a/target/snitch_cluster/cfg/default.hjson +++ b/target/snitch_cluster/cfg/default.hjson @@ -64,7 +64,7 @@ { icache: { size: 8, // total instruction cache size in kByte - sets: 2, // number of ways + ways: 2, // number of ways cacheline: 256 // word size in bits }, cores: [ diff --git a/target/snitch_cluster/cfg/dma_mchan.hjson b/target/snitch_cluster/cfg/dma_mchan.hjson index ef551a2d2..9af10a1f2 100644 --- a/target/snitch_cluster/cfg/dma_mchan.hjson +++ b/target/snitch_cluster/cfg/dma_mchan.hjson @@ -70,7 +70,7 @@ { icache: { size: 8, // total instruction cache size in kByte - sets: 2, // number of ways + ways: 2, // number of ways cacheline: 256 // word size in bits }, cores: [ diff --git a/target/snitch_cluster/cfg/fdiv.hjson b/target/snitch_cluster/cfg/fdiv.hjson index c58409ef7..a14a1720c 100644 --- a/target/snitch_cluster/cfg/fdiv.hjson +++ b/target/snitch_cluster/cfg/fdiv.hjson @@ -64,7 +64,7 @@ { icache: { size: 8, // total instruction cache size in kByte - sets: 2, // number of ways + ways: 2, // number of ways cacheline: 256 // word size in bits }, cores: [ diff --git a/target/snitch_cluster/cfg/github-ci.hjson b/target/snitch_cluster/cfg/github-ci.hjson index 3b788754c..3ea025ed6 100644 --- a/target/snitch_cluster/cfg/github-ci.hjson +++ b/target/snitch_cluster/cfg/github-ci.hjson @@ -69,7 +69,7 @@ { icache: { size: 8, // total instruction cache size in kByte - sets: 2, // number of ways + ways: 2, // number of ways cacheline: 256 // word size in bits }, cores: [ diff --git a/target/snitch_cluster/cfg/omega.hjson b/target/snitch_cluster/cfg/omega.hjson index 65655936a..0c8f82406 100644 --- a/target/snitch_cluster/cfg/omega.hjson +++ b/target/snitch_cluster/cfg/omega.hjson @@ -65,7 +65,7 @@ { icache: { size: 8, // total instruction cache size in kByte - sets: 2, // number of ways + ways: 2, // number of ways cacheline: 256 // word size in bits }, cores: [ diff --git a/util/clustergen/cluster.py b/util/clustergen/cluster.py index 7c48ee92b..fe63ab6ae 100644 --- a/util/clustergen/cluster.py +++ b/util/clustergen/cluster.py @@ -247,7 +247,7 @@ def calc_cache_sizes(self): cl_bytes = self.cfg['hives'][i]['icache']['cacheline'] // 8 self.cfg['hives'][i]['icache']['depth'] = self.cfg['hives'][i][ 'icache']['size'] * 1024 // self.cfg['hives'][i]['icache'][ - 'sets'] // cl_bytes + 'ways'] // cl_bytes # tag width self.tag_width = self.cfg['addr_width'] - clog2( hive['icache']['cacheline'] // 8) - clog2(hive['icache']['depth']) + 3 diff --git a/util/clustergen/schema/snitch_cluster.schema.json b/util/clustergen/schema/snitch_cluster.schema.json index f9d5831ca..1473b1480 100644 --- a/util/clustergen/schema/snitch_cluster.schema.json +++ b/util/clustergen/schema/snitch_cluster.schema.json @@ -373,7 +373,7 @@ "description": "Detailed configuration of the current Hive's instruction cache.", "default": { "size": 8, - "sets": 2, + "ways": 2, "cacheline": 128 }, "properties": { @@ -381,7 +381,7 @@ "type": "number", "description": "Total instruction cache size in KiByte." }, - "sets": { + "ways": { "type": "number", "description": "Number of ways." }, From 25caa465baaf3e8b27b9322db406ba7738da0550 Mon Sep 17 00:00:00 2001 From: Luca Colagrande Date: Fri, 20 Dec 2024 15:44:53 +0100 Subject: [PATCH 04/21] bender: Bump AXI to release --- Bender.lock | 4 ++-- Bender.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Bender.lock b/Bender.lock index 00301ecb1..f982b08f0 100644 --- a/Bender.lock +++ b/Bender.lock @@ -7,8 +7,8 @@ packages: dependencies: - common_cells axi: - revision: 4e54ac6766b160217a83a74d5a23af9bbf59e6ee - version: null + revision: 39f5f2d51c5e524f6fc5cf8b6e901f7dcc5622d7 + version: 0.39.6 source: Git: https://github.com/pulp-platform/axi dependencies: diff --git a/Bender.yml b/Bender.yml index 40a67ca48..6eaa0e4f6 100644 --- a/Bender.yml +++ b/Bender.yml @@ -19,7 +19,7 @@ package: - Matheus Cavalcante dependencies: - axi: { git: https://github.com/pulp-platform/axi, rev: 4e54ac6766b160217a83a74d5a23af9bbf59e6ee } + axi: { git: https://github.com/pulp-platform/axi, version: 0.39.6 } axi_riscv_atomics: { git: https://github.com/pulp-platform/axi_riscv_atomics, version: 0.6.0 } common_cells: { git: https://github.com/pulp-platform/common_cells, version: 1.35.0 } FPnew: { git: "https://github.com/pulp-platform/cvfpu.git", rev: pulp-v0.1.3 } From e1ffaf098f21c9ee3e8e4116caca3dba3b268d59 Mon Sep 17 00:00:00 2001 From: Luca Colagrande Date: Fri, 20 Dec 2024 15:46:45 +0100 Subject: [PATCH 05/21] bender: Bump iDMA restoring Snitch tracer --- Bender.lock | 2 +- Bender.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Bender.lock b/Bender.lock index f982b08f0..7198724ab 100644 --- a/Bender.lock +++ b/Bender.lock @@ -71,7 +71,7 @@ packages: dependencies: - common_cells idma: - revision: 1a42da9d5c76f1cff0bcdaaacc474ed85631d734 + revision: d4010425e943c9845b8549b3c8f8cc8dba73ec47 version: null source: Git: https://github.com/pulp-platform/iDMA diff --git a/Bender.yml b/Bender.yml index 6eaa0e4f6..50c6cc9f9 100644 --- a/Bender.yml +++ b/Bender.yml @@ -27,7 +27,7 @@ dependencies: tech_cells_generic: { git: https://github.com/pulp-platform/tech_cells_generic, version: 0.2.11 } riscv-dbg: { git: https://github.com/pulp-platform/riscv-dbg, version: 0.8.0 } cluster_icache: { git: https://github.com/pulp-platform/cluster_icache.git, rev: 64e21ae455bbdde850c4df13bef86ea55ac42537 } - idma: { git: https://github.com/pulp-platform/iDMA, rev: __deploy__9cbcd30__snitch-tracing } + idma: { git: https://github.com/pulp-platform/iDMA, rev: __deploy__110fd06__master } export_include_dirs: - hw/reqrsp_interface/include From a672e3e0a01f50c022f7f066fd2977d3831cbf12 Mon Sep 17 00:00:00 2001 From: Luca Colagrande Date: Wed, 4 Sep 2024 10:29:28 +0200 Subject: [PATCH 06/21] target: Do not generate `*.dep` files on any `clean` target --- target/snitch_cluster/sw/apps/common.mk | 4 +--- target/snitch_cluster/sw/runtime/runtime.mk | 4 +--- target/snitch_cluster/sw/tests/tests.mk | 6 ++---- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/target/snitch_cluster/sw/apps/common.mk b/target/snitch_cluster/sw/apps/common.mk index 1877d6ad5..99a29cb14 100644 --- a/target/snitch_cluster/sw/apps/common.mk +++ b/target/snitch_cluster/sw/apps/common.mk @@ -78,8 +78,6 @@ $(DUMP): $(ELF) | $($(APP)_BUILD_DIR) $(DWARF): $(ELF) | $($(APP)_BUILD_DIR) $(RISCV_DWARFDUMP) $< > $@ -ifneq ($(MAKECMDGOALS),clean) -ifneq ($(MAKECMDGOALS),clean-sw) +ifneq ($(filter-out clean%,$(MAKECMDGOALS)),) -include $(DEP) endif -endif diff --git a/target/snitch_cluster/sw/runtime/runtime.mk b/target/snitch_cluster/sw/runtime/runtime.mk index 8f15ebab1..4d052f0b9 100644 --- a/target/snitch_cluster/sw/runtime/runtime.mk +++ b/target/snitch_cluster/sw/runtime/runtime.mk @@ -75,8 +75,6 @@ $(SNRT_DUMP): $(SNRT_LIB) | $(SNRT_BUILDDIR) $(SNRT_DEPS): | $(TARGET_C_HDRS) -ifneq ($(MAKECMDGOALS),clean) -ifneq ($(MAKECMDGOALS),clean-sw) +ifneq ($(filter-out clean%,$(MAKECMDGOALS)),) -include $(SNRT_DEPS) endif -endif diff --git a/target/snitch_cluster/sw/tests/tests.mk b/target/snitch_cluster/sw/tests/tests.mk index 35afa66ea..69ece41ca 100644 --- a/target/snitch_cluster/sw/tests/tests.mk +++ b/target/snitch_cluster/sw/tests/tests.mk @@ -70,8 +70,6 @@ $(TESTS_BUILDDIR)/%.dwarf: $(TESTS_BUILDDIR)/%.elf | $(TESTS_BUILDDIR) $(TEST_DEPS): | $(TARGET_C_HDRS) -ifneq ($(MAKECMDGOALS),clean) -ifneq ($(MAKECMDGOALS),clean-sw) --include $(TEST_DEPS) -endif +ifneq ($(filter-out clean%,$(MAKECMDGOALS)),) +-include $(DEP) endif From b2a2037f2a5e53fc477d12ffc4b694d27bb4af01 Mon Sep 17 00:00:00 2001 From: Luca Colagrande Date: Wed, 4 Sep 2024 10:29:50 +0200 Subject: [PATCH 07/21] target: Fix typo in `sw.mk` --- target/snitch_cluster/sw.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/snitch_cluster/sw.mk b/target/snitch_cluster/sw.mk index 6083a8ee1..2d03dd176 100644 --- a/target/snitch_cluster/sw.mk +++ b/target/snitch_cluster/sw.mk @@ -25,7 +25,7 @@ REGGEN_HEADERS = snitch_cluster_peripheral.h 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 From a5b83aef0636a93f4bffb900f73375ee5acc31e1 Mon Sep 17 00:00:00 2001 From: Luca Colagrande Date: Wed, 4 Sep 2024 10:40:27 +0200 Subject: [PATCH 08/21] target: Remove DWARF targets and dumps when `DEBUG=OFF` --- target/snitch_cluster/sw/apps/common.mk | 10 +++++----- target/snitch_cluster/sw/runtime/runtime.mk | 7 ++++++- target/snitch_cluster/sw/tests/tests.mk | 8 ++------ target/snitch_cluster/sw/toolchain.mk | 1 - 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/target/snitch_cluster/sw/apps/common.mk b/target/snitch_cluster/sw/apps/common.mk index 99a29cb14..ee647324f 100644 --- a/target/snitch_cluster/sw/apps/common.mk +++ b/target/snitch_cluster/sw/apps/common.mk @@ -37,8 +37,11 @@ $(APP)_RISCV_LDFLAGS += $(addprefix -l,$($(APP)_LIBNAMES)) ELF := $(abspath $(addprefix $($(APP)_BUILD_DIR)/,$(addsuffix .elf,$(APP)))) DEP := $(abspath $(addprefix $($(APP)_BUILD_DIR)/,$(addsuffix .d,$(APP)))) DUMP := $(abspath $(addprefix $($(APP)_BUILD_DIR)/,$(addsuffix .dump,$(APP)))) -DWARF := $(abspath $(addprefix $($(APP)_BUILD_DIR)/,$(addsuffix .dwarf,$(APP)))) -ALL_OUTPUTS := $(ELF) $(DEP) $(DUMP) $(DWARF) +ALL_OUTPUTS := $(ELF) + +ifeq ($(DEBUG), ON) +ALL_OUTPUTS += $(DUMP) +endif ######### # Rules # @@ -75,9 +78,6 @@ $(ELF): $(SRCS) $(DEP) $($(APP)_LIBS) | $($(APP)_BUILD_DIR) $(DUMP): $(ELF) | $($(APP)_BUILD_DIR) $(RISCV_OBJDUMP) $(RISCV_OBJDUMP_FLAGS) $< > $@ -$(DWARF): $(ELF) | $($(APP)_BUILD_DIR) - $(RISCV_DWARFDUMP) $< > $@ - ifneq ($(filter-out clean%,$(MAKECMDGOALS)),) -include $(DEP) endif diff --git a/target/snitch_cluster/sw/runtime/runtime.mk b/target/snitch_cluster/sw/runtime/runtime.mk index 4d052f0b9..f308819a9 100644 --- a/target/snitch_cluster/sw/runtime/runtime.mk +++ b/target/snitch_cluster/sw/runtime/runtime.mk @@ -39,7 +39,12 @@ SNRT_OBJS = $(addprefix $(SNRT_BUILDDIR)/,$(addsuffix .o,$(basename $(notdir 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) +SNRT_OUTPUTS = $(SNRT_LIB) + +ifeq ($(DEBUG), ON) +SNRT_OUTPUTS += $(SNRT_DUMP) +endif + ######### # Rules # diff --git a/target/snitch_cluster/sw/tests/tests.mk b/target/snitch_cluster/sw/tests/tests.mk index 69ece41ca..3bb4fece6 100644 --- a/target/snitch_cluster/sw/tests/tests.mk +++ b/target/snitch_cluster/sw/tests/tests.mk @@ -32,11 +32,10 @@ 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) +ifeq ($(DEBUG),ON) +TEST_OUTPUTS += $(TEST_DUMPS) endif ######### @@ -65,9 +64,6 @@ $(TESTS_BUILDDIR)/%.elf: $(TESTS_SRCDIR)/%.c $(SNRT_LIB) $(TESTS_BUILDDIR)/%.d | $(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 ($(filter-out clean%,$(MAKECMDGOALS)),) diff --git a/target/snitch_cluster/sw/toolchain.mk b/target/snitch_cluster/sw/toolchain.mk index 9cadb8c44..366d23d5d 100644 --- a/target/snitch_cluster/sw/toolchain.mk +++ b/target/snitch_cluster/sw/toolchain.mk @@ -23,7 +23,6 @@ RISCV_LD ?= $(LLVM_BINROOT)/ld.lld RISCV_AR ?= $(LLVM_BINROOT)/llvm-ar RISCV_OBJCOPY ?= $(LLVM_BINROOT)/llvm-objcopy RISCV_OBJDUMP ?= $(LLVM_BINROOT)/llvm-objdump -RISCV_DWARFDUMP ?= $(LLVM_BINROOT)/llvm-dwarfdump # Compiler flags RISCV_CFLAGS := -mcpu=snitch From edd3d16536f9ecff35099d6edf1fe593269bc4a1 Mon Sep 17 00:00:00 2001 From: Luca Colagrande Date: Mon, 2 Sep 2024 19:44:28 +0200 Subject: [PATCH 09/21] target: Improve Makefile reusability for use in Occamy --- target/snitch_cluster/sw.mk | 12 ++++++------ target/snitch_cluster/sw/apps/common.mk | 17 +++++++++++------ target/snitch_cluster/sw/runtime/runtime.mk | 12 ++++++------ target/snitch_cluster/sw/tests/tests.mk | 15 ++++++++++----- 4 files changed, 33 insertions(+), 23 deletions(-) diff --git a/target/snitch_cluster/sw.mk b/target/snitch_cluster/sw.mk index 2d03dd176..d56649770 100644 --- a/target/snitch_cluster/sw.mk +++ b/target/snitch_cluster/sw.mk @@ -22,22 +22,22 @@ CLUSTER_GEN_HEADERS = snitch_cluster_cfg.h \ REGGEN_HEADERS = snitch_cluster_peripheral.h -TARGET_C_HDRS_DIR = $(ROOT)/target/snitch_cluster/sw/runtime/common -TARGET_C_HDRS = $(addprefix $(TARGET_C_HDRS_DIR)/,$(CLUSTER_GEN_HEADERS) $(REGGEN_HEADERS)) +SNRT_HAL_HDRS_DIR = $(ROOT)/target/snitch_cluster/sw/runtime/common +SNRT_HAL_HDRS = $(addprefix $(SNRT_HAL_HDRS_DIR)/,$(CLUSTER_GEN_HEADERS) $(REGGEN_HEADERS)) # CLUSTERGEN headers -$(addprefix $(TARGET_C_HDRS_DIR)/,$(CLUSTER_GEN_HEADERS)): %.h: $(CFG) $(CLUSTER_GEN_PREREQ) %.h.tpl +$(addprefix $(SNRT_HAL_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 + $(CLUSTER_GEN) -c $< --outdir $(SNRT_HAL_HDRS_DIR) --template $@.tpl # REGGEN headers -$(TARGET_C_HDRS_DIR)/snitch_cluster_peripheral.h: $(ROOT)/hw/snitch_cluster/src/snitch_cluster_peripheral/snitch_cluster_peripheral_reg.hjson $(REGGEN) +$(SNRT_HAL_HDRS_DIR)/snitch_cluster_peripheral.h: $(ROOT)/hw/snitch_cluster/src/snitch_cluster_peripheral/snitch_cluster_peripheral_reg.hjson $(REGGEN) $(call reggen_generate_header,$@,$<) .PHONY: clean-headers clean-sw: clean-headers clean-headers: - rm -f $(TARGET_C_HDRS) + rm -f $(SNRT_HAL_HDRS) ################## # Subdirectories # diff --git a/target/snitch_cluster/sw/apps/common.mk b/target/snitch_cluster/sw/apps/common.mk index ee647324f..77dfb1196 100644 --- a/target/snitch_cluster/sw/apps/common.mk +++ b/target/snitch_cluster/sw/apps/common.mk @@ -8,10 +8,10 @@ # Build variables # ################### -$(APP)_HEADERS += $(TARGET_C_HDRS) +$(APP)_HEADERS += $(SNRT_HAL_HDRS) $(APP)_INCDIRS += $(SNRT_INCDIRS) -$(APP)_INCDIRS += $(ROOT)/sw/deps/riscv-opcodes +$(APP)_INCDIRS += $(SNITCH_ROOT)/sw/deps/riscv-opcodes $(APP)_RISCV_CFLAGS += $(RISCV_CFLAGS) $(APP)_RISCV_CFLAGS += $(addprefix -I,$($(APP)_INCDIRS)) @@ -19,17 +19,22 @@ ifeq ($(SELECT_RUNTIME), banshee) $(APP)_RISCV_CFLAGS += -DBIST endif -$(APP)_LIBS += $(SNRT_TARGET_DIR)/build/libsnRuntime.a +$(APP)_LIBS += $(SNRT_LIB) $(APP)_LIBDIRS = $(dir $($(APP)_LIBS)) $(APP)_LIBNAMES = $(patsubst lib%,%,$(notdir $(basename $($(APP)_LIBS)))) +BASE_LD = $(SNRT_DIR)/base.ld +MEMORY_LD ?= $(SNITCH_ROOT)/target/snitch_cluster/sw/runtime/memory.ld + $(APP)_RISCV_LDFLAGS += $(RISCV_LDFLAGS) -$(APP)_RISCV_LDFLAGS += -L$(abspath $(SNRT_TARGET_DIR)/..) -$(APP)_RISCV_LDFLAGS += -T$(abspath $(SNRT_DIR)/base.ld) +$(APP)_RISCV_LDFLAGS += -L$(dir $(MEMORY_LD)) +$(APP)_RISCV_LDFLAGS += -T$(BASE_LD) $(APP)_RISCV_LDFLAGS += $(addprefix -L,$($(APP)_LIBDIRS)) $(APP)_RISCV_LDFLAGS += $(addprefix -l,$($(APP)_LIBNAMES)) +LD_DEPS += $(MEMORY_LD) $(BASE_LD) $($(APP)_LIBS) + ########### # Outputs # ########### @@ -72,7 +77,7 @@ $(ELF): RISCV_LDFLAGS := $($(APP)_RISCV_LDFLAGS) $(DEP): $(SRCS) | $($(APP)_BUILD_DIR) $($(APP)_HEADERS) $(RISCV_CC) $(RISCV_CFLAGS) -MM -MT '$(ELF)' $< > $@ -$(ELF): $(SRCS) $(DEP) $($(APP)_LIBS) | $($(APP)_BUILD_DIR) +$(ELF): $(SRCS) $(DEP) $(LD_DEPS) | $($(APP)_BUILD_DIR) $(RISCV_CC) $(RISCV_CFLAGS) $(RISCV_LDFLAGS) $(SRCS) -o $@ $(DUMP): $(ELF) | $($(APP)_BUILD_DIR) diff --git a/target/snitch_cluster/sw/runtime/runtime.mk b/target/snitch_cluster/sw/runtime/runtime.mk index f308819a9..fc4a152f3 100644 --- a/target/snitch_cluster/sw/runtime/runtime.mk +++ b/target/snitch_cluster/sw/runtime/runtime.mk @@ -8,10 +8,10 @@ # 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 +SNRT_DIR = $(SNITCH_ROOT)/sw/snRuntime +SNRT_TARGET_DIR ?= $(SNITCH_ROOT)/target/snitch_cluster/sw/runtime/$(SELECT_RUNTIME) +SNRT_BUILDDIR = $(SNRT_TARGET_DIR)/build +SNRT_SRCDIR = $(SNRT_TARGET_DIR)/src ################### # Build variables # @@ -26,7 +26,7 @@ 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_INCDIRS += $(SNRT_HAL_HDRS_DIR) SNRT_RISCV_CFLAGS += $(RISCV_CFLAGS) SNRT_RISCV_CFLAGS += $(addprefix -I,$(SNRT_INCDIRS)) @@ -78,7 +78,7 @@ $(SNRT_LIB): $(SNRT_OBJS) | $(SNRT_BUILDDIR) $(SNRT_DUMP): $(SNRT_LIB) | $(SNRT_BUILDDIR) $(RISCV_OBJDUMP) $(RISCV_OBJDUMP_FLAGS) $< > $@ -$(SNRT_DEPS): | $(TARGET_C_HDRS) +$(SNRT_DEPS): | $(SNRT_HAL_HDRS) ifneq ($(filter-out clean%,$(MAKECMDGOALS)),) -include $(SNRT_DEPS) diff --git a/target/snitch_cluster/sw/tests/tests.mk b/target/snitch_cluster/sw/tests/tests.mk index 3bb4fece6..e6cfeb49c 100644 --- a/target/snitch_cluster/sw/tests/tests.mk +++ b/target/snitch_cluster/sw/tests/tests.mk @@ -18,12 +18,17 @@ TESTS_BUILDDIR = $(ROOT)/target/snitch_cluster/sw/tests/build TESTS_RISCV_CFLAGS += $(RISCV_CFLAGS) TESTS_RISCV_CFLAGS += $(addprefix -I,$(SNRT_INCDIRS)) +BASE_LD = $(SNRT_DIR)/base.ld +MEMORY_LD ?= $(ROOT)/target/snitch_cluster/sw/runtime/memory.ld + 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 += -L$(dir $(MEMORY_LD)) +TESTS_RISCV_LDFLAGS += -T$(BASE_LD) +TESTS_RISCV_LDFLAGS += -L$(SNRT_BUILDDIR) TESTS_RISCV_LDFLAGS += -lsnRuntime +LD_DEPS = $(MEMORY_LD) $(BASE_LD) $(SNRT_LIB) + ########### # Outputs # ########### @@ -58,13 +63,13 @@ $(TESTS_BUILDDIR): $(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) +$(TESTS_BUILDDIR)/%.elf: $(TESTS_SRCDIR)/%.c $(LD_DEPS) $(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) $< > $@ -$(TEST_DEPS): | $(TARGET_C_HDRS) +$(TEST_DEPS): | $(SNRT_HAL_HDRS) ifneq ($(filter-out clean%,$(MAKECMDGOALS)),) -include $(DEP) From d8d157db95461b32d8a2064e2717c31ed3a14b5b Mon Sep 17 00:00:00 2001 From: Luca Colagrande Date: Thu, 29 Aug 2024 19:40:12 +0200 Subject: [PATCH 10/21] target: Use Verilator to generate accurate dependency files --- target/common/common.mk | 22 +++----------------- target/common/vcs.mk | 37 ++++++++++++++++++++++++++++++++++ target/common/verilator.mk | 17 ++++++++++++++-- target/common/vsim.mk | 29 ++++++++++++++++++++------ target/snitch_cluster/Makefile | 13 +----------- 5 files changed, 79 insertions(+), 39 deletions(-) create mode 100644 target/common/vcs.mk diff --git a/target/common/common.mk b/target/common/common.mk index c9538d51a..d6ae8e3a8 100644 --- a/target/common/common.mk +++ b/target/common/common.mk @@ -12,7 +12,8 @@ UTIL_DIR ?= $(SNITCH_ROOT)/util LOGS_DIR = $(SIM_DIR)/logs # Files -BENDER_LOCK ?= $(ROOT)/Bender.lock +BENDER_LOCK = $(ROOT)/Bender.lock +BENDER_YML = $(ROOT)/Bender.yml # SEPP packages QUESTA_SEPP ?= @@ -46,15 +47,9 @@ VLT_ROOT ?= ${VERILATOR_ROOT} VLT_JOBS ?= $(shell nproc) VLT_NUM_THREADS ?= 1 -MATCH_END := '/+incdir+/ s/$$/\/*\/*/' -MATCH_BGN := 's/+incdir+//g' -MATCH_DEF := '/+define+/d' -SED_SRCS := sed -e ${MATCH_END} -e ${MATCH_BGN} -e ${MATCH_DEF} - COMMON_BENDER_FLAGS += -t rtl -t snitch_cluster VSIM_BENDER += $(COMMON_BENDER_FLAGS) -t test -t simulation -t vsim -VSIM_SOURCES = $(shell ${BENDER} script flist-plus ${VSIM_BENDER} | ${SED_SRCS}) VSIM_BUILDDIR ?= work-vsim VSIM_FLAGS += -t 1ps ifeq ($(DEBUG), ON) @@ -67,7 +62,6 @@ endif # VCS_BUILDDIR should to be the same as the `DEFAULT : ./work-vcs` # in target/snitch_cluster/synopsys_sim.setup VCS_BENDER += $(COMMON_BENDER_FLAGS) -t test -t simulation -t vcs -VCS_SOURCES = $(shell ${BENDER} script flist-plus ${VCS_BENDER} | ${SED_SRCS}) VCS_BUILDDIR := work-vcs # fesvr is being installed here @@ -75,7 +69,6 @@ FESVR ?= ${MKFILE_DIR}work FESVR_VERSION ?= 35d50bc40e59ea1d5566fbd3d9226023821b1bb6 VLT_BENDER += $(COMMON_BENDER_FLAGS) -DCOMMON_CELLS_ASSERTS_OFF -VLT_SOURCES = $(shell ${BENDER} script flist-plus ${VLT_BENDER} | ${SED_SRCS}) VLT_BUILDDIR := $(abspath work-vlt) VLT_FESVR = $(VLT_BUILDDIR)/riscv-isa-sim VLT_FLAGS += --timing @@ -90,7 +83,7 @@ VLT_FLAGS += -Wno-UNSIGNED VLT_FLAGS += -Wno-UNOPTFLAT VLT_FLAGS += -Wno-fatal VLT_FLAGS += --unroll-count 1024 -VLT_FLAGS += --threads $(VLT_NUM_THREADS) +VLT_FLAGS += --threads $(VLT_NUM_THREADS) VLT_CFLAGS += -std=c++20 -pthread VLT_CFLAGS += -I $(VLT_FESVR)/include -I $(TB_DIR) -I ${MKFILE_DIR}test @@ -169,15 +162,6 @@ $(VLT_BUILDDIR)/lib/libfesvr.a: $(VLT_FESVR)/${FESVR_VERSION}_unzip mkdir -p $(dir $@) cp $(dir $<)libfesvr.a $@ -####### -# VCS # -####### -$(VCS_BUILDDIR)/compile.sh: - mkdir -p $(VCS_BUILDDIR) - ${BENDER} script vcs ${VCS_BENDER} --vlog-arg="${VLOGAN_FLAGS}" --vcom-arg="${VHDLAN_FLAGS}" > $@ - chmod +x $@ - $(VCS_SEPP) $@ > $(VCS_BUILDDIR)/compile.log - ######## # Util # ######## diff --git a/target/common/vcs.mk b/target/common/vcs.mk new file mode 100644 index 000000000..0c477c09f --- /dev/null +++ b/target/common/vcs.mk @@ -0,0 +1,37 @@ +# 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 + +VCS_TOP_MODULE = tb_bin + +$(VCS_BUILDDIR): + mkdir -p $@ + +$(VCS_BUILDDIR)/compile.sh: $(BENDER_YML) $(BENDER_LOCK) | $(VCS_BUILDDIR) + $(BENDER) script vcs $(VCS_BENDER) --vlog-arg="$(VLOGAN_FLAGS)" --vcom-arg="$(VHDLAN_FLAGS)" > $@ + chmod +x $@ + +# Generate dependency file with RTL sources and headers using Verilator +$(VCS_BUILDDIR)/$(VCS_TOP_MODULE).d: $(BENDER_YML) $(BENDER_LOCK) $(GENERATED_RTL_SOURCES) | $(VCS_BUILDDIR) + $(VLT) $(shell $(BENDER) script verilator $(VCS_BENDER)) \ + --Mdir $(VCS_BUILDDIR) --MMD -E --top-module $(VCS_TOP_MODULE) > /dev/null + mv $(VCS_BUILDDIR)/V$(VCS_TOP_MODULE)__ver.d $@ + sed -i 's|^[^:]*:|$(BIN_DIR)/$(TARGET).vcs:|' $@ + +# Run compilation script and create VCS simulation binary +$(BIN_DIR)/$(TARGET).vcs: $(VCS_BUILDDIR)/compile.sh $(TB_CC_SOURCES) $(RTL_CC_SOURCES) work/lib/libfesvr.a | $(BIN_DIR) + $(VCS_SEPP) $< > $(VCS_BUILDDIR)/compile.log + $(VCS) -Mlib=$(VCS_BUILDDIR) -Mdir=$(VCS_BUILDDIR) -o $@ -cc $(CC) -cpp $(CXX) \ + -assert disable_cover -override_timescale=1ns/1ps -full64 $(VCS_TOP_MODULE) $(TB_CC_SOURCES) $(RTL_CC_SOURCES) \ + -CFLAGS "$(TB_CC_FLAGS)" -LDFLAGS "-L$(FESVR)/lib" -lfesvr + +# Clean all build directories and temporary files for VCS simulation +.PHONY: clean-vcs +clean-vcs: clean-work + rm -rf $(BIN_DIR)/$(TARGET).vcs $(VCS_BUILDDIR) vc_hdrs.h + +clean: clean-vcs + +ifneq ($(filter-out clean%,$(MAKECMDGOALS)),) +-include $(VCS_BUILDDIR)/$(VCS_TOP_MODULE).d +endif diff --git a/target/common/verilator.mk b/target/common/verilator.mk index eb02ee346..518a71de8 100644 --- a/target/common/verilator.mk +++ b/target/common/verilator.mk @@ -2,16 +2,29 @@ # Licensed under the Apache License, Version 2.0, see LICENSE for details. # SPDX-License-Identifier: Apache-2.0 -$(BIN_DIR)/$(TARGET).vlt: $(VLT_SOURCES) $(TB_CC_SOURCES) $(VLT_CC_SOURCES) $(VLT_BUILDDIR)/lib/libfesvr.a | $(BIN_DIR) +VLT_TOP_MODULE = testharness + +# Generate dependency file with RTL sources and headers using Verilator +$(VLT_BUILDDIR)/$(VLT_TOP_MODULE).d: $(BENDER_YML) $(BENDER_LOCK) $(GENERATED_RTL_SOURCES) | $(VLT_BUILDDIR) + $(VLT) $(shell $(BENDER) script verilator $(VLT_BENDER)) \ + --Mdir $(VLT_BUILDDIR) --MMD -E --top-module $(VLT_TOP_MODULE) > /dev/null + mv $(VLT_BUILDDIR)/V$(VLT_TOP_MODULE)__ver.d $@ + sed -i 's|^[^:]*:|$(BIN_DIR)/$(TARGET).vlt:|' $@ + +$(BIN_DIR)/$(TARGET).vlt: $(TB_CC_SOURCES) $(VLT_CC_SOURCES) $(VLT_BUILDDIR)/lib/libfesvr.a | $(BIN_DIR) $(VLT) $(shell $(BENDER) script verilator $(VLT_BENDER)) \ $(VLT_FLAGS) --Mdir $(VLT_BUILDDIR) \ -CFLAGS "$(VLT_CFLAGS)" \ -LDFLAGS "$(VLT_LDFLAGS)" \ -j $(VLT_JOBS) \ - -o ../$@ --cc --exe --build --top-module testharness $(TB_CC_SOURCES) $(VLT_CC_SOURCES) + -o ../$@ --cc --exe --build --top-module $(VLT_TOP_MODULE) $(TB_CC_SOURCES) $(VLT_CC_SOURCES) .PHONY: clean-vlt clean-vlt: clean-work rm -rf $(BIN_DIR)/$(TARGET).vlt $(VLT_BUILDDIR) clean: clean-vlt + +ifneq ($(filter-out clean%,$(MAKECMDGOALS)),) +-include $(VLT_BUILDDIR)/$(VLT_TOP_MODULE).d +endif diff --git a/target/common/vsim.mk b/target/common/vsim.mk index 38019240b..d5d05495d 100644 --- a/target/common/vsim.mk +++ b/target/common/vsim.mk @@ -2,34 +2,47 @@ # Licensed under the Apache License, Version 2.0, see LICENSE for details. # SPDX-License-Identifier: Apache-2.0 +VSIM_TOP_MODULE = tb_bin + $(VSIM_BUILDDIR): mkdir -p $@ -$(VSIM_BUILDDIR)/compile.vsim.tcl: $(BENDER_LOCK) | $(VSIM_BUILDDIR) +$(VSIM_BUILDDIR)/compile.vsim.tcl: $(BENDER_YML) $(BENDER_LOCK) | $(VSIM_BUILDDIR) $(VLIB) $(dir $@) $(BENDER) script vsim $(VSIM_BENDER) --vlog-arg="$(VLOG_FLAGS) -work $(dir $@) " > $@ echo '$(VLOG) -work $(dir $@) $(TB_CC_SOURCES) $(RTL_CC_SOURCES) -vv -ccflags "$(TB_CC_FLAGS)"' >> $@ echo 'return 0' >> $@ -# Build compilation script and compile all sources for Questasim simulation -$(BIN_DIR)/$(TARGET).vsim: $(VSIM_BUILDDIR)/compile.vsim.tcl $(VSIM_SOURCES) $(TB_SRCS) $(TB_CC_SOURCES) $(RTL_CC_SOURCES) work/lib/libfesvr.a | $(BIN_DIR) +# Intermediate file required to avoid "Argument list too long" errors in Occamy +# when invoking Verilator +$(VSIM_BUILDDIR)/$(TARGET).f: $(BENDER_YML) $(BENDER_LOCK) | $(VSIM_BUILDDIR) + $(BENDER) script verilator $(VSIM_BENDER) > $@ + +# Generate dependency file with RTL sources and headers using Verilator +$(VSIM_BUILDDIR)/$(VSIM_TOP_MODULE).d: $(VSIM_BUILDDIR)/$(TARGET).f $(GENERATED_RTL_SOURCES) | $(VSIM_BUILDDIR) + $(VLT) -f $< --Mdir $(VSIM_BUILDDIR) --MMD -E --top-module $(VSIM_TOP_MODULE) > /dev/null + mv $(VSIM_BUILDDIR)/V$(VSIM_TOP_MODULE)__ver.d $@ + sed -i 's|^[^:]*:|$(BIN_DIR)/$(TARGET).vsim:|' $@ + +# Run compilation script and create Questasim simulation binary +$(BIN_DIR)/$(TARGET).vsim: $(VSIM_BUILDDIR)/compile.vsim.tcl $(TB_CC_SOURCES) $(RTL_CC_SOURCES) work/lib/libfesvr.a | $(BIN_DIR) $(VSIM) -c -do "source $<; quit" | tee $(dir $<)vlog.log @! grep -P "Errors: [1-9]*," $(dir $<)vlog.log - $(VOPT) $(VOPT_FLAGS) -work $(VSIM_BUILDDIR) tb_bin -o tb_bin_opt | tee $(dir $<)vopt.log + $(VOPT) $(VOPT_FLAGS) -work $(VSIM_BUILDDIR) $(VSIM_TOP_MODULE) -o $(VSIM_TOP_MODULE)_opt | tee $(dir $<)vopt.log @! grep -P "Errors: [1-9]*," $(dir $<)vopt.log @echo "#!/bin/bash" > $@ @echo 'binary=$$(realpath $$1)' >> $@ @echo 'echo $$binary > .rtlbinary' >> $@ @echo '$(VSIM) +permissive $(VSIM_FLAGS) $$3 -work $(MKFILE_DIR)/$(VSIM_BUILDDIR) -c \ -ldflags "-Wl,-rpath,$(FESVR)/lib -L$(FESVR)/lib -lfesvr -lutil" \ - tb_bin_opt +permissive-off ++$$binary ++$$2' >> $@ + $(VSIM_TOP_MODULE)_opt +permissive-off ++$$binary ++$$2' >> $@ @chmod +x $@ @echo "#!/bin/bash" > $@.gui @echo 'binary=$$(realpath $$1)' >> $@.gui @echo 'echo $$binary > .rtlbinary' >> $@.gui @echo '$(VSIM) +permissive $(VSIM_FLAGS) -work $(MKFILE_DIR)/$(VSIM_BUILDDIR) \ -ldflags "-Wl,-rpath,$(FESVR)/lib -L$(FESVR)/lib -lfesvr -lutil" \ - tb_bin_opt +permissive-off ++$$binary ++$$2' >> $@.gui + $(VSIM_TOP_MODULE)_opt +permissive-off ++$$binary ++$$2' >> $@.gui @chmod +x $@.gui # Clean all build directories and temporary files for Questasim simulation @@ -38,3 +51,7 @@ clean-vsim: clean-work rm -rf $(BIN_DIR)/$(TARGET).vsim $(BIN_DIR)/$(TARGET).vsim.gui $(VSIM_BUILDDIR) vsim.wlf clean: clean-vsim + +ifneq ($(filter-out clean%,$(MAKECMDGOALS)),) +-include $(VSIM_BUILDDIR)/$(VSIM_TOP_MODULE).d +endif diff --git a/target/snitch_cluster/Makefile b/target/snitch_cluster/Makefile index ae6ec0ec0..dea529fb4 100644 --- a/target/snitch_cluster/Makefile +++ b/target/snitch_cluster/Makefile @@ -202,18 +202,7 @@ include $(ROOT)/target/common/vsim.mk # VCS # ####### -.PHONY: clean-vcs - -# Clean all build directories and temporary files for VCS simulation -clean-vcs: clean-work - rm -rf $(BIN_DIR)/$(TARGET).vcs $(VCS_BUILDDIR) vc_hdrs.h - -# Build compilation script and compile all sources for VCS simulation -$(BIN_DIR)/$(TARGET).vcs: ${VCS_SOURCES} ${TB_SRCS} $(TB_CC_SOURCES) $(RTL_CC_SOURCES) $(VCS_BUILDDIR)/compile.sh work/lib/libfesvr.a - mkdir -p $(BIN_DIR) - $(VCS) -Mlib=$(VCS_BUILDDIR) -Mdir=$(VCS_BUILDDIR) -o $(BIN_DIR)/$(TARGET).vcs -cc $(CC) -cpp $(CXX) \ - -assert disable_cover -override_timescale=1ns/1ps -full64 tb_bin $(TB_CC_SOURCES) $(RTL_CC_SOURCES) \ - -CFLAGS "$(TB_CC_FLAGS)" -LDFLAGS "-L${FESVR}/lib" -lfesvr +include $(ROOT)/target/common/vcs.mk ######## # Util # From 6c84fba029d39f0e96d82c83d358cc337a67c8a1 Mon Sep 17 00:00:00 2001 From: Luca Colagrande Date: Wed, 4 Sep 2024 16:30:11 +0200 Subject: [PATCH 11/21] snRuntime: Rename `snitch_cluster_start.S` to `snrt.S` The shift to a name which is not specific to a particular system makes building system-specific snRuntime implementations easier, as these can reuse existing build scripts directly. --- .../src/{snitch_cluster_start.S => snrt.S} | 0 .../rtl/src/{snitch_cluster_start.S => snrt.S} | 0 target/snitch_cluster/sw/runtime/runtime.mk | 15 ++++++--------- 3 files changed, 6 insertions(+), 9 deletions(-) rename target/snitch_cluster/sw/runtime/banshee/src/{snitch_cluster_start.S => snrt.S} (100%) rename target/snitch_cluster/sw/runtime/rtl/src/{snitch_cluster_start.S => snrt.S} (100%) diff --git a/target/snitch_cluster/sw/runtime/banshee/src/snitch_cluster_start.S b/target/snitch_cluster/sw/runtime/banshee/src/snrt.S similarity index 100% rename from target/snitch_cluster/sw/runtime/banshee/src/snitch_cluster_start.S rename to target/snitch_cluster/sw/runtime/banshee/src/snrt.S diff --git a/target/snitch_cluster/sw/runtime/rtl/src/snitch_cluster_start.S b/target/snitch_cluster/sw/runtime/rtl/src/snrt.S similarity index 100% rename from target/snitch_cluster/sw/runtime/rtl/src/snitch_cluster_start.S rename to target/snitch_cluster/sw/runtime/rtl/src/snrt.S diff --git a/target/snitch_cluster/sw/runtime/runtime.mk b/target/snitch_cluster/sw/runtime/runtime.mk index fc4a152f3..f5dbab97b 100644 --- a/target/snitch_cluster/sw/runtime/runtime.mk +++ b/target/snitch_cluster/sw/runtime/runtime.mk @@ -17,8 +17,8 @@ SNRT_SRCDIR = $(SNRT_TARGET_DIR)/src # Build variables # ################### -SNRT_SRCS = snitch_cluster_start.S -SNRT_SRCS += snrt.c +SNRT_S_SRCS = snrt.S +SNRT_C_SRCS = snrt.c SNRT_INCDIRS += $(SNRT_DIR)/src SNRT_INCDIRS += $(SNRT_DIR)/api @@ -35,8 +35,8 @@ 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_OBJS = $(addprefix $(SNRT_BUILDDIR)/,$(addsuffix .o,$(notdir $(SNRT_S_SRCS) $(SNRT_C_SRCS)))) +SNRT_DEPS = $(addprefix $(SNRT_BUILDDIR)/,$(addsuffix .d,$(notdir $(SNRT_S_SRCS) $(SNRT_C_SRCS)))) SNRT_LIB = $(SNRT_BUILDDIR)/libsnRuntime.a SNRT_DUMP = $(SNRT_BUILDDIR)/libsnRuntime.dump SNRT_OUTPUTS = $(SNRT_LIB) @@ -63,13 +63,10 @@ clean-runtime: $(SNRT_BUILDDIR): mkdir -p $@ -$(SNRT_BUILDDIR)/%.o: $(SNRT_SRCDIR)/%.S | $(SNRT_BUILDDIR) +$(SNRT_BUILDDIR)/%.o: $(SNRT_SRCDIR)/% $(SNRT_BUILDDIR)/%.d | $(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) +$(SNRT_BUILDDIR)/%.d: $(SNRT_SRCDIR)/% | $(SNRT_BUILDDIR) $(RISCV_CC) $(SNRT_RISCV_CFLAGS) -MM -MT '$(@:.d=.o)' $< > $@ $(SNRT_LIB): $(SNRT_OBJS) | $(SNRT_BUILDDIR) From 137873699e63ff47dddf3e4ab2b18973c3114da8 Mon Sep 17 00:00:00 2001 From: Luca Colagrande Date: Mon, 16 Sep 2024 13:43:22 +0200 Subject: [PATCH 12/21] snRuntime: Improve all-to-all reduction routine --- sw/snRuntime/api/cls_decls.h | 1 + sw/snRuntime/api/sync_decls.h | 2 ++ sw/snRuntime/src/sync.c | 2 ++ sw/snRuntime/src/sync.h | 34 +++++++++++++++++++++++++++++++--- 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/sw/snRuntime/api/cls_decls.h b/sw/snRuntime/api/cls_decls.h index 0e18fdf3d..a70c72556 100644 --- a/sw/snRuntime/api/cls_decls.h +++ b/sw/snRuntime/api/cls_decls.h @@ -10,6 +10,7 @@ typedef struct { uint32_t hw_barrier; + uint32_t reduction; snrt_allocator_t l1_allocator; } cls_t; diff --git a/sw/snRuntime/api/sync_decls.h b/sw/snRuntime/api/sync_decls.h index 0e18f943a..55f98d96c 100644 --- a/sw/snRuntime/api/sync_decls.h +++ b/sw/snRuntime/api/sync_decls.h @@ -28,3 +28,5 @@ inline void snrt_cluster_hw_barrier(); inline void snrt_global_barrier(); inline uint32_t snrt_global_all_to_all_reduction(uint32_t value); + +inline void snrt_wait_writeback(uint32_t val); diff --git a/sw/snRuntime/src/sync.c b/sw/snRuntime/src/sync.c index 112dc07a4..17bcfc9b1 100644 --- a/sw/snRuntime/src/sync.c +++ b/sw/snRuntime/src/sync.c @@ -32,3 +32,5 @@ extern void snrt_global_reduction_dma(double *dst_buffer, double *src_buffer, size_t len); extern uint32_t snrt_global_all_to_all_reduction(uint32_t value); + +extern void snrt_wait_writeback(uint32_t val); diff --git a/sw/snRuntime/src/sync.h b/sw/snRuntime/src/sync.h index add26fa08..9a052e612 100644 --- a/sw/snRuntime/src/sync.h +++ b/sw/snRuntime/src/sync.h @@ -162,9 +162,23 @@ inline void snrt_partial_barrier(snrt_barrier_t *barr, uint32_t n) { * will stall indefinitely. */ inline uint32_t snrt_global_all_to_all_reduction(uint32_t value) { - __atomic_add_fetch(&_reduction_result, value, __ATOMIC_RELAXED); - snrt_global_barrier(); - return _reduction_result; + // Reduce cores within cluster in TCDM + uint32_t *cluster_result = &(cls()->reduction); + uint32_t tmp = __atomic_fetch_add(cluster_result, value, __ATOMIC_RELAXED); + + // Wait for writeback to ensure AMO is seen by all cores after barrier + snrt_wait_writeback(tmp); + snrt_cluster_hw_barrier(); + + // Reduce DM cores across clusters in global memory + if (snrt_is_dm_core()) { + __atomic_add_fetch(&_reduction_result, *cluster_result, + __ATOMIC_RELAXED); + snrt_inter_cluster_barrier(); + *cluster_result = _reduction_result; + } + snrt_cluster_hw_barrier(); + return *cluster_result; } /** @@ -236,3 +250,17 @@ inline void snrt_global_reduction_dma(double *dst_buffer, double *src_buffer, } } } + +//================================================================================ +// Memory consistency +//================================================================================ + +/** + * @brief Ensure value is written back to the register file. + * @details This function introduces a RAW dependency on val to stall the + * core until val is written back to the register file. + * @param val The variable we want to wait on. + */ +inline void snrt_wait_writeback(uint32_t val) { + asm volatile("mv %0, %0" : "+r"(val)::); +} From a9fc49a5674c207793f9ee469b91204a8db11576 Mon Sep 17 00:00:00 2001 From: Luca Colagrande Date: Thu, 19 Sep 2024 17:55:09 +0200 Subject: [PATCH 13/21] snRuntime: Improve `riscv_decls.h` --- sw/snRuntime/api/riscv_decls.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sw/snRuntime/api/riscv_decls.h b/sw/snRuntime/api/riscv_decls.h index f0aae1779..c0db9c53f 100644 --- a/sw/snRuntime/api/riscv_decls.h +++ b/sw/snRuntime/api/riscv_decls.h @@ -6,9 +6,9 @@ #include -static inline void snrt_wfi(); +inline void snrt_wfi(); -static inline uint32_t snrt_mcycle(); +inline uint32_t snrt_mcycle(); inline void snrt_interrupt_enable(uint32_t irq); From 3a82f4dcfa58428fefdb5a75395997b7181cc449 Mon Sep 17 00:00:00 2001 From: Luca Colagrande Date: Mon, 18 Nov 2024 11:04:48 +0100 Subject: [PATCH 14/21] snRuntime: Explicitize transfer dependency in `snrt_init_tls` --- sw/snRuntime/src/start.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sw/snRuntime/src/start.c b/sw/snRuntime/src/start.c index 824c8231f..f169ec6ff 100644 --- a/sw/snRuntime/src/start.c +++ b/sw/snRuntime/src/start.c @@ -23,6 +23,7 @@ static inline void snrt_init_tls() { // First initialize the DM core's .tdata section from main memory asm volatile("mv %0, tp" : "=r"(tls_ptr) : :); snrt_dma_start_1d((void*)tls_ptr, (void*)(&__tdata_start), size); + snrt_dma_wait_all(); // Then initialize all other cores' .tdata sections from the DM // core's. The offset between the TLS section of successive cores From c222663ab475c1493321913441435c3d4a8aaa35 Mon Sep 17 00:00:00 2001 From: Luca Colagrande Date: Mon, 16 Sep 2024 13:49:05 +0200 Subject: [PATCH 15/21] util/sim: Improve Python imports in simulation classes --- util/sim/Simulation.py | 3 ++- util/sim/Simulator.py | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/util/sim/Simulation.py b/util/sim/Simulation.py index 5dd98ee35..def9124ac 100644 --- a/util/sim/Simulation.py +++ b/util/sim/Simulation.py @@ -36,7 +36,8 @@ def __init__(self, elf=None, dry_run=False, retcode=0, run_dir=None, name=None): self.dry_run = dry_run self.run_dir = run_dir if run_dir is not None else Path.cwd() if name is None: - self.testname = Path(self.elf).stem + if self.elf is not None: + self.testname = Path(self.elf).stem else: self.testname = name self.cmd = [] diff --git a/util/sim/Simulator.py b/util/sim/Simulator.py index a5d7e1909..4d5cd2883 100644 --- a/util/sim/Simulator.py +++ b/util/sim/Simulator.py @@ -4,7 +4,7 @@ # # Luca Colagrande -from Simulation import QuestaSimulation, VCSSimulation, VerilatorSimulation, BansheeSimulation +from snitch.util.sim import Simulation class Simulator(object): @@ -111,7 +111,7 @@ def __init__(self, binary): Arguments: binary: The VCS simulation binary. """ - super().__init__(binary, name='vcs', simulation_cls=VCSSimulation) + super().__init__(binary, name='vcs', simulation_cls=Simulation.VCSSimulation) class QuestaSimulator(RTLSimulator): @@ -128,7 +128,7 @@ def __init__(self, binary): Arguments: binary: The QuestaSim simulation binary. """ - super().__init__(binary, name='vsim', simulation_cls=QuestaSimulation) + super().__init__(binary, name='vsim', simulation_cls=Simulation.QuestaSimulation) class VerilatorSimulator(RTLSimulator): @@ -145,7 +145,7 @@ def __init__(self, binary): Arguments: binary: The Verilator simulation binary. """ - super().__init__(binary, name='verilator', simulation_cls=VerilatorSimulation) + super().__init__(binary, name='verilator', simulation_cls=Simulation.VerilatorSimulation) class BansheeSimulator(Simulator): @@ -161,7 +161,7 @@ def __init__(self, cfg): Arguments: cfg: A Banshee config file. """ - super().__init__(name='banshee', simulation_cls=BansheeSimulation) + super().__init__(name='banshee', simulation_cls=Simulation.BansheeSimulation) self.cfg = cfg def supports(self, test): From 0d5a46bbfb552175a717d2452b0fb9c76f0d7767 Mon Sep 17 00:00:00 2001 From: Luca Colagrande Date: Thu, 17 Oct 2024 17:42:51 +0200 Subject: [PATCH 16/21] util/sim: Report interrupted processes as not completed --- util/sim/Simulation.py | 3 ++- util/sim/sim_utils.py | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/util/sim/Simulation.py b/util/sim/Simulation.py index def9124ac..7be77bfca 100644 --- a/util/sim/Simulation.py +++ b/util/sim/Simulation.py @@ -43,6 +43,7 @@ def __init__(self, elf=None, dry_run=False, retcode=0, run_dir=None, name=None): self.cmd = [] self.log = None self.process = None + self.interrupted = False self.expected_retcode = int(retcode) def launch(self, dry_run=None): @@ -87,7 +88,7 @@ def completed(self): if self.dry_run: return True elif self.process: - return self.process.poll() is not None + return self.process.poll() is not None and not self.interrupted else: return False diff --git a/util/sim/sim_utils.py b/util/sim/sim_utils.py index 9844fa363..0cf05cf04 100755 --- a/util/sim/sim_utils.py +++ b/util/sim/sim_utils.py @@ -255,7 +255,7 @@ def get_living_subprocesses(): iterations = 0 while get_living_subprocesses() and iterations < 10: living_subprocs = get_living_subprocesses() - print(f'{len(living_subprocs)} living subprocesses of {ppid}\n{living_subprocs}') + print(f'{len(living_subprocs)} living subprocesses of {ppid}') for proc in living_subprocs: try: os.kill(proc.info['pid'], signal.SIGKILL) @@ -268,6 +268,8 @@ def get_living_subprocesses(): if get_living_subprocesses(): print('THERE ARE STILL LIVING SUBPROCESSES') print(get_living_subprocesses()) + else: + print('All subprocesses successfully killed') def get_unique_run_dir(sim, prefix=None): @@ -336,6 +338,8 @@ def run_simulations(simulations, n_procs=1, dry_run=None, early_exit=False, break time.sleep(POLL_PERIOD) except KeyboardInterrupt: + for sim in running_sims: + sim.interrupted = True early_exit_requested = True # Clean up after early exit From dff06dea171a0a2fcc216b1a19a01ceefc4df839 Mon Sep 17 00:00:00 2001 From: Luca Colagrande Date: Sat, 21 Sep 2024 10:10:56 +0200 Subject: [PATCH 17/21] util/trace: Log line number on exception in DMA trace --- util/trace/gen_trace.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/util/trace/gen_trace.py b/util/trace/gen_trace.py index 9583a1758..0c1f4a898 100755 --- a/util/trace/gen_trace.py +++ b/util/trace/gen_trace.py @@ -585,8 +585,17 @@ def eval_dma_metrics(dma_trans, dma_trace): bursts_in_transfer = 0 rec_bursts = 0 # Iterate lines in DMA trace - for line in f.readlines(): - dma = ast.literal_eval(line) + for lineno, (line, nextl) in enumerate(current_and_next(f.readlines())): + try: + dma = ast.literal_eval(line) + except SyntaxError: + message = 'Exception occured while processing ' + if not nextl: + message += 'last line. Did the simulation terminate?' + else: + message += f'line {lineno}.' + print(traceback.format_exc(), file=sys.stderr) + print(message, file=sys.stderr) time = dma['meta']['time'] # When the first burst in a transfer is granted, we record a new transfer in # the outstanding transfers queue, with the information obtained from the core From 80f3fb6b883a12d0a289a55e99ce19d46a487303 Mon Sep 17 00:00:00 2001 From: Luca Colagrande Date: Thu, 3 Oct 2024 19:24:55 +0200 Subject: [PATCH 18/21] ci: Encode `build-docker`->`deploy-docs` dependency --- .github/workflows/ci.yml | 24 +++++++++++++++++++++++- .github/workflows/publish-docs.yml | 28 ---------------------------- 2 files changed, 23 insertions(+), 29 deletions(-) delete mode 100644 .github/workflows/publish-docs.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 05b4fefb2..8b15858f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,7 +45,7 @@ jobs: # Docs # ######## - docs: + build-docs: name: Build documentation runs-on: ubuntu-22.04 needs: build-docker @@ -59,6 +59,28 @@ jobs: - name: Build docs run: make docs + deploy-docs: + name: Deploy documentation + runs-on: ubuntu-22.04 + needs: build-docker + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + container: + image: ghcr.io/pulp-platform/snitch_cluster:${{ github.ref_name }} + steps: + - uses: actions/checkout@v2 + # For some reason, the checkout is done by a different user, + # than that deploying to Github (root, possibly due to Docker). + # So we need to set the repository as a safe directory. + - name: Git config safe.directory + run: | + git config --global --add safe.directory $GITHUB_WORKSPACE + - name: Generate documentation sources + run: | + make doc-srcs + make doxygen-docs + - name: Build and deploy documentation + run: mkdocs gh-deploy --force + ##################### # Python unit tests # ##################### diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml deleted file mode 100644 index 23a53bf4a..000000000 --- a/.github/workflows/publish-docs.yml +++ /dev/null @@ -1,28 +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 -name: publish-docs -on: - push: - branches: [main] - workflow_dispatch: -jobs: - deploy: - name: Deploy documentation - runs-on: ubuntu-22.04 - container: - image: ghcr.io/pulp-platform/snitch_cluster:main - steps: - - uses: actions/checkout@v2 - # For some reason, the checkout is done by a different user, - # than that deploying to Github (root, possibly due to Docker). - # So we need to set the repository as a safe directory. - - name: Git config safe.directory - run: | - git config --global --add safe.directory $GITHUB_WORKSPACE - - name: Generate documentation sources - run: | - make doc-srcs - make doxygen-docs - - name: Build and deploy documentation - run: mkdocs gh-deploy --force From a50238e4104c4224fb13f2618073d7cc159a7869 Mon Sep 17 00:00:00 2001 From: Luca Colagrande Date: Fri, 11 Oct 2024 09:45:43 +0200 Subject: [PATCH 19/21] ci: Enable Docker build on forks --- .github/workflows/ci.yml | 12 ++++++------ util/lint/.yamllint.yml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8b15858f4..4dbda70d3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,7 @@ jobs: cache-to: type=gha,mode=max` file: util/container/Dockerfile push: true - tags: ghcr.io/pulp-platform/snitch_cluster:${{ github.ref_name }} + tags: ghcr.io/${{ github.repository_owner }}/snitch_cluster:${{ github.ref_name }} ######## # Docs # @@ -53,7 +53,7 @@ jobs: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository container: - image: ghcr.io/pulp-platform/snitch_cluster:${{ github.ref_name }} + image: ghcr.io/${{ github.repository_owner }}/snitch_cluster:${{ github.ref_name }} steps: - uses: actions/checkout@v2 - name: Build docs @@ -93,7 +93,7 @@ jobs: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository container: - image: ghcr.io/pulp-platform/snitch_cluster:${{ github.ref_name }} + image: ghcr.io/${{ github.repository_owner }}/snitch_cluster:${{ github.ref_name }} steps: - uses: actions/checkout@v2 - name: Run pytest @@ -111,7 +111,7 @@ jobs: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository container: - image: ghcr.io/pulp-platform/snitch_cluster:${{ github.ref_name }} + image: ghcr.io/${{ github.repository_owner }}/snitch_cluster:${{ github.ref_name }} steps: - uses: actions/checkout@v2 with: @@ -162,7 +162,7 @@ jobs: # github.event_name != 'pull_request' || # github.event.pull_request.head.repo.full_name != github.repository # container: - # image: ghcr.io/pulp-platform/snitch_cluster:${{ github.ref_name }} + # image: ghcr.io/${{ github.repository_owner }}/snitch_cluster:${{ github.ref_name }} # steps: # - uses: actions/checkout@v2 # with: @@ -189,7 +189,7 @@ jobs: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository container: - image: ghcr.io/pulp-platform/snitch_cluster:${{ github.ref_name }} + image: ghcr.io/${{ github.repository_owner }}/snitch_cluster:${{ github.ref_name }} steps: - uses: actions/checkout@v4 with: diff --git a/util/lint/.yamllint.yml b/util/lint/.yamllint.yml index 7cf910fc3..a5e6e098f 100644 --- a/util/lint/.yamllint.yml +++ b/util/lint/.yamllint.yml @@ -9,7 +9,7 @@ rules: comments: min-spaces-from-content: 1 line-length: - max: 90 + max: 100 allow-non-breakable-words: true allow-non-breakable-inline-mappings: true ignore: | From d293bd664725a59016bbe047e2db87d94b554ded Mon Sep 17 00:00:00 2001 From: Luca Colagrande Date: Wed, 16 Oct 2024 11:49:51 +0200 Subject: [PATCH 20/21] docs: Add missing `snitch_occupancy` metric --- docs/ug/trace_analysis.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/ug/trace_analysis.md b/docs/ug/trace_analysis.md index 2a9d1bad4..7ba1dfccb 100644 --- a/docs/ug/trace_analysis.md +++ b/docs/ug/trace_analysis.md @@ -128,6 +128,7 @@ In the following table you can find a complete list of all the performance metri |`snitch_issues` |Total number of instructions issued by Snitch, excluding those offloaded to the FPSS (see `snitch_fseq_offloads`). | |`snitch_fseq_offloads` |Total number of instructions offloaded by Snitch to the FPSS. | |`snitch_fseq_rel_offloads`|The ratio between `snitch_fseq_offloads` and the total number of instructions issued by Snitch core proper, i.e. `snitch_issues + snitch_fseq_offloads`. | +|`snitch_occupancy` |IPC of the Snitch core, calculated as `snitch_issues / cycles`. | |`fpss_issues` |Total number of instructions issued by the FPSS. It counts repeated issues from the FREP sequencer. | |`fpss_fpu_issues` |Similar to `fpss_issues`, but counts only instructions destined to the FPU proper. It does not for instance include instructions issued to the FPSS's LSU. | |`fseq_yield` |The ratio between `fpss_issues` and `snitch_fseq_offloads`. The difference lies in the FREP sequencer possibly replicating instructions. If the sequencer is not used this ratio should amount to 1.| From 6e85387195cba6f84d5387bc7a65f0376481b8eb Mon Sep 17 00:00:00 2001 From: Luca Colagrande Date: Thu, 24 Oct 2024 10:10:56 +0200 Subject: [PATCH 21/21] docs: Update Docker usage --- util/container/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/container/README.md b/util/container/README.md index 05a136926..83ddaeb64 100644 --- a/util/container/README.md +++ b/util/container/README.md @@ -35,7 +35,7 @@ sudo docker buildx build -t ghcr.io/pulp-platform/snitch_cluster:main -f util/co To run the container in interactive mode: ```shell -docker run -it -v :/repo -w /repo ghcr.io/pulp-platform/snitch_cluster:main +docker run -it --entrypoint /bin/bash -v :/repo -w /repo ghcr.io/pulp-platform/snitch_cluster:main ``` ## Limitations