Skip to content

Commit

Permalink
#11789: Fix alignment/padding
Browse files Browse the repository at this point in the history
  • Loading branch information
pgkeller committed Sep 27, 2024
1 parent 913d2ac commit 006e861
Showing 4 changed files with 20 additions and 16 deletions.
7 changes: 5 additions & 2 deletions tt_metal/hw/inc/blackhole/dev_mem_map.h
Original file line number Diff line number Diff line change
@@ -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
7 changes: 4 additions & 3 deletions tt_metal/hw/inc/grayskull/dev_mem_map.h
Original file line number Diff line number Diff line change
@@ -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
7 changes: 4 additions & 3 deletions tt_metal/hw/inc/wormhole/dev_mem_map.h
Original file line number Diff line number Diff line change
@@ -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
15 changes: 7 additions & 8 deletions tt_metal/hw/toolchain/sections.ld
Original file line number Diff line number Diff line change
@@ -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 = .);

0 comments on commit 006e861

Please sign in to comment.