Skip to content

Commit

Permalink
sw: Multi-cluster runtime improvements (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
fischeti authored Aug 1, 2024
1 parent 02ce1b9 commit 9131849
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 56 deletions.
5 changes: 5 additions & 0 deletions docs/schema/snitch_cluster_tb.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
"cluster": {
"$ref": "http://pulp-platform.org/snitch_cluster/snitch_cluster.schema.json"
},
"nr_clusters": {
"type": "number",
"description": "Number of clusters. Relevant for the SW runtime.",
"default": 1
},
"dram": {
"title": "DRAM",
"type": "object",
Expand Down
3 changes: 1 addition & 2 deletions hw/snitch_cluster/test/bootdata.cc.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ const BootData BOOTDATA = {.boot_addr = ${hex(cfg['cluster']['boot_addr'])},
.tcdm_offset = ${hex(cfg['cluster']['cluster_base_offset'])},
.global_mem_start = ${hex(cfg['dram']['address'])},
.global_mem_end = ${hex(cfg['dram']['address'] + cfg['dram']['length'])},
.cluster_count = ${cfg['s1_quadrant']['nr_clusters']},
.s1_quadrant_count = ${cfg['nr_s1_quadrant']},
.cluster_count = ${cfg['nr_clusters']},
.clint_base = ${hex(cfg['peripherals']['clint']['address'])}};

} // namespace sim
1 change: 0 additions & 1 deletion target/common/test/tb_lib.hh
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ struct BootData {
uint64_t global_mem_start;
uint64_t global_mem_end;
uint32_t cluster_count;
uint32_t s1_quadrant_count;
uint32_t clint_base;
};
extern const BootData BOOTDATA;
Expand Down
5 changes: 0 additions & 5 deletions target/snitch_cluster/cfg/default.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@

// Cluster configuration for a simple testbench system.
{
nr_s1_quadrant: 1,
s1_quadrant: {
nr_clusters: 1,
},

cluster: {
boot_addr: 4096, // 0x1000
cluster_base_addr: 268435456, // 0x1000_0000
Expand Down
5 changes: 0 additions & 5 deletions target/snitch_cluster/cfg/fdiv.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@

// Cluster configuration for a simple testbench system.
{
nr_s1_quadrant: 1,
s1_quadrant: {
nr_clusters: 1,
},

cluster: {
boot_addr: 4096, // 0x1000
cluster_base_addr: 268435456, // 0x1000_0000
Expand Down
5 changes: 0 additions & 5 deletions target/snitch_cluster/cfg/omega.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@

// Cluster configuration for a simple testbench system.
{
nr_s1_quadrant: 1,
s1_quadrant: {
nr_clusters: 1,
},

cluster: {
boot_addr: 4096, // 0x1000
cluster_base_addr: 268435456, // 0x1000_0000
Expand Down
8 changes: 4 additions & 4 deletions target/snitch_cluster/sw/runtime/banshee/src/snrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
#include <stddef.h>
#include <stdint.h>

// Snitch cluster specific
#include "banshee_snitch_cluster_defs.h"
#include "snitch_cluster_memory.h"

// Forward declarations
#include "alloc_decls.h"
#include "cls_decls.h"
Expand All @@ -19,6 +15,10 @@
#include "sync_decls.h"
#include "team_decls.h"

// Snitch cluster specific
#include "banshee_snitch_cluster_defs.h"
#include "snitch_cluster_memory.h"

// Implementation
#include "alloc.h"
#include "cls.h"
Expand Down
2 changes: 1 addition & 1 deletion target/snitch_cluster/sw/runtime/common/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
snitch_cluster_cfg.h
snitch_cluster_addrmap.h
snitch_cluster_peripheral.h
snitch_cluster_peripheral.h
14 changes: 13 additions & 1 deletion target/snitch_cluster/sw/runtime/common/snitch_cluster_cfg.h.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,16 @@
// SPDX-License-Identifier: Apache-2.0

#define CFG_CLUSTER_NR_CORES ${cfg['cluster']['nr_cores']}
#define CFG_CLUSTER_BASE_HARTID ${cfg['cluster']['cluster_base_hartid']}
#define CFG_CLUSTER_BASE_HARTID ${cfg['cluster']['cluster_base_hartid']}
#define SNRT_BASE_HARTID CFG_CLUSTER_BASE_HARTID
#define SNRT_CLUSTER_CORE_NUM CFG_CLUSTER_NR_CORES
#define SNRT_CLUSTER_NUM ${cfg['nr_clusters']}
#define SNRT_CLUSTER_DM_CORE_NUM 1
#define SNRT_TCDM_START_ADDR CLUSTER_TCDM_BASE_ADDR
#define SNRT_TCDM_SIZE (CLUSTER_PERIPH_BASE_ADDR - CLUSTER_TCDM_BASE_ADDR)
#define SNRT_CLUSTER_OFFSET ${cfg['cluster']['cluster_base_offset']}
#define SNRT_CLUSTER_HW_BARRIER_ADDR \
(CLUSTER_PERIPH_BASE_ADDR + SNITCH_CLUSTER_PERIPHERAL_HW_BARRIER_REG_OFFSET)

// Software configuration
#define SNRT_LOG2_STACK_SIZE 10
14 changes: 0 additions & 14 deletions target/snitch_cluster/sw/runtime/common/snitch_cluster_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,3 @@
#include "snitch_cluster_addrmap.h"
#include "snitch_cluster_cfg.h"
#include "snitch_cluster_peripheral.h"

// Hardware parameters
#define SNRT_BASE_HARTID CFG_CLUSTER_BASE_HARTID
#define SNRT_CLUSTER_CORE_NUM CFG_CLUSTER_NR_CORES
#define SNRT_CLUSTER_NUM 1
#define SNRT_CLUSTER_DM_CORE_NUM 1
#define SNRT_TCDM_START_ADDR CLUSTER_TCDM_BASE_ADDR
#define SNRT_TCDM_SIZE (CLUSTER_PERIPH_BASE_ADDR - CLUSTER_TCDM_BASE_ADDR)
#define SNRT_CLUSTER_OFFSET 0x40000
#define SNRT_CLUSTER_HW_BARRIER_ADDR \
(CLUSTER_PERIPH_BASE_ADDR + SNITCH_CLUSTER_PERIPHERAL_HW_BARRIER_REG_OFFSET)

// Software configuration
#define SNRT_LOG2_STACK_SIZE 10
32 changes: 18 additions & 14 deletions target/snitch_cluster/sw/runtime/common/snitch_cluster_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,34 @@
// snRuntime interface functions
//===============================================================

inline uint32_t __attribute__((const)) snrt_l1_start_addr() {
return CLUSTER_TCDM_START_ADDR;
inline uint32_t cluster_base_offset() {
return snrt_cluster_idx() * SNRT_CLUSTER_OFFSET;
}

inline uint32_t __attribute__((const)) snrt_l1_end_addr() {
return CLUSTER_TCDM_END_ADDR;
inline uint32_t snrt_l1_start_addr() {
return CLUSTER_TCDM_BASE_ADDR + cluster_base_offset();
}

inline volatile uint32_t* __attribute__((const)) snrt_cluster_clint_set_ptr() {
return (uint32_t*)CLUSTER_CLINT_SET_ADDR;
inline uint32_t snrt_l1_end_addr() {
return CLUSTER_PERIPH_BASE_ADDR + cluster_base_offset();
}

inline volatile uint32_t* __attribute__((const)) snrt_cluster_clint_clr_ptr() {
return (uint32_t*)CLUSTER_CLINT_CLR_ADDR;
inline volatile uint32_t* snrt_cluster_clint_set_ptr() {
return (uint32_t*)(CLUSTER_CLINT_SET_ADDR + cluster_base_offset());
}

inline uint32_t __attribute__((const)) snrt_cluster_hw_barrier_addr() {
return CLUSTER_HW_BARRIER_ADDR;
inline volatile uint32_t* snrt_cluster_clint_clr_ptr() {
return (uint32_t*)(CLUSTER_CLINT_CLR_ADDR + cluster_base_offset());
}

inline uint32_t __attribute__((const)) snrt_cluster_perf_counters_addr() {
return CLUSTER_PERF_COUNTER_ADDR;
inline uint32_t snrt_cluster_hw_barrier_addr() {
return CLUSTER_HW_BARRIER_ADDR + cluster_base_offset();
}

inline volatile uint32_t* __attribute__((const)) snrt_zero_memory_ptr() {
return (uint32_t*)CLUSTER_ZERO_MEM_START_ADDR;
inline uint32_t snrt_cluster_perf_counters_addr() {
return CLUSTER_PERF_COUNTER_ADDR + cluster_base_offset();
}

inline volatile uint32_t* snrt_zero_memory_ptr() {
return (uint32_t*)(CLUSTER_ZERO_MEM_START_ADDR + cluster_base_offset());
}
8 changes: 4 additions & 4 deletions target/snitch_cluster/sw/runtime/rtl/src/snrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
#include <stddef.h>
#include <stdint.h>

// Snitch cluster specific
#include "snitch_cluster_defs.h"
#include "snitch_cluster_memory.h"

// Forward declarations
#include "alloc_decls.h"
#include "cls_decls.h"
Expand All @@ -19,6 +15,10 @@
#include "sync_decls.h"
#include "team_decls.h"

// Snitch cluster specific
#include "snitch_cluster_defs.h"
#include "snitch_cluster_memory.h"

// Implementation
#include "alloc.h"
#include "cls.h"
Expand Down

0 comments on commit 9131849

Please sign in to comment.