From 006e861881150f221b680d074436508ed79e4416 Mon Sep 17 00:00:00 2001 From: Paul Keller Date: Fri, 20 Sep 2024 18:42:24 +0000 Subject: [PATCH] #11789: Fix alignment/padding --- tt_metal/hw/inc/blackhole/dev_mem_map.h | 7 +++++-- tt_metal/hw/inc/grayskull/dev_mem_map.h | 7 ++++--- tt_metal/hw/inc/wormhole/dev_mem_map.h | 7 ++++--- tt_metal/hw/toolchain/sections.ld | 15 +++++++-------- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/tt_metal/hw/inc/blackhole/dev_mem_map.h b/tt_metal/hw/inc/blackhole/dev_mem_map.h index 15776b262276..c8806430430d 100644 --- a/tt_metal/hw/inc/blackhole/dev_mem_map.h +++ b/tt_metal/hw/inc/blackhole/dev_mem_map.h @@ -92,8 +92,9 @@ #define MEM_TRISC2_STACK_BASE (MEM_LOCAL_BASE + MEM_TRISC_LOCAL_SIZE - MEM_TRISC2_STACK_SIZE) ///////////// -// Alignment restrictions needed in linker scripts -#define MEM_TENSIX_KERNEL_ALIGNMENT 16 +// Padding/alignment restrictions needed in linker scripts +// Note we pad then align so, for example, erisc can keep space between fw/kernels +#define MEM_TENSIX_KERNEL_PAD 12 ///////////// @@ -106,3 +107,5 @@ #define MEM_IERISC_INIT_LOCAL_L1_BASE_SCRATCH (MEM_IERISC_FIRMWARE_BASE + MEM_IERISC_FIRMWARE_SIZE) #define MEM_IERISC_STACK_SIZE 768 #define MEM_IERISC_STACK_BASE (MEM_LOCAL_BASE + MEM_IERISC_LOCAL_SIZE - MEM_IERISC_STACK_SIZE) + +#define MEM_IERISC_KERNEL_PAD 28 diff --git a/tt_metal/hw/inc/grayskull/dev_mem_map.h b/tt_metal/hw/inc/grayskull/dev_mem_map.h index c6214028bc7d..3339d267eee8 100644 --- a/tt_metal/hw/inc/grayskull/dev_mem_map.h +++ b/tt_metal/hw/inc/grayskull/dev_mem_map.h @@ -101,8 +101,9 @@ #define MEM_TRISC2_STACK_BASE (MEM_LOCAL_BASE + MEM_TRISC_LOCAL_SIZE - MEM_TRISC2_STACK_SIZE) ///////////// -// Alignment restrictions needed in linker scripts -#define MEM_TENSIX_KERNEL_ALIGNMENT 16 +// Padding/alignment restrictions needed in linker scripts +// Note we pad then align so, for example, erisc can keep space between fw/kernels +#define MEM_TENSIX_KERNEL_PAD 12 ///////////// @@ -115,4 +116,4 @@ #define MEM_IERISC_INIT_LOCAL_L1_BASE_SCRATCH 0 #define MEM_IERISC_STACK_SIZE 0 -#define MEM_IERISC_KERNEL_ALIGNMENT 32 +#define MEM_IERISC_KERNEL_PAD 0 diff --git a/tt_metal/hw/inc/wormhole/dev_mem_map.h b/tt_metal/hw/inc/wormhole/dev_mem_map.h index a5db4a5206d0..b8385fc0dd4d 100644 --- a/tt_metal/hw/inc/wormhole/dev_mem_map.h +++ b/tt_metal/hw/inc/wormhole/dev_mem_map.h @@ -102,8 +102,9 @@ #define MEM_TRISC2_STACK_BASE (MEM_LOCAL_BASE + MEM_TRISC_LOCAL_SIZE - MEM_TRISC2_STACK_SIZE) ///////////// -// Alignment restrictions needed in linker scripts -#define MEM_TENSIX_KERNEL_ALIGNMENT 16 +// Padding/alignment restrictions needed in linker scripts +// Note we pad then align so, for example, erisc can keep space between fw/kernels +#define MEM_TENSIX_KERNEL_PAD 12 ///////////// @@ -117,4 +118,4 @@ #define MEM_IERISC_STACK_SIZE 1024 #define MEM_IERISC_STACK_BASE (MEM_LOCAL_BASE + MEM_IERISC_LOCAL_SIZE - MEM_IERISC_STACK_SIZE) -#define MEM_IERISC_KERNEL_ALIGNMENT 32 +#define MEM_IERISC_KERNEL_PAD 28 diff --git a/tt_metal/hw/toolchain/sections.ld b/tt_metal/hw/toolchain/sections.ld index 137d2c6246fe..6f38e3fa7aca 100644 --- a/tt_metal/hw/toolchain/sections.ld +++ b/tt_metal/hw/toolchain/sections.ld @@ -24,17 +24,16 @@ __ldm_start = DEFINED(__fw_export_ldm_end) ? __fw_export_ldm_end : ORIGIN(REGION #if defined (TYPE_FIRMWARE) #if defined (TARGET_IERISC) -__padding = MEM_IERISC_KERNEL_ALIGNMENT - 4; -__alignment = MEM_IERISC_KERNEL_ALIGNMENT; +#define MEM_PAD MEM_IERISC_KERNEL_PAD #else -__padding = MEM_TENSIX_KERNEL_ALIGNMENT - 4; -__alignment = MEM_TENSIX_KERNEL_ALIGNMENT; +#define MEM_PAD MEM_TENSIX_KERNEL_PAD #endif #else -__padding = 0; -__alignment = 4; +#define MEM_PAD 0 #endif +#define MEM_ALIGN MEM_PAD + 4 + OUTPUT_FORMAT("elf32-littleriscv", "elf32-littleriscv", "elf32-littleriscv") OUTPUT_ARCH(riscv) @@ -72,8 +71,8 @@ SECTIONS *(l1_data_noinit) } > REGION_CODE - . += __padding; - . = ALIGN(__alignment); + . += MEM_PAD; + . = ALIGN(MEM_ALIGN); PROVIDE (__etext = .); PROVIDE (_etext = .);