Skip to content

Commit bc2833f

Browse files
authored
Arm backend: Move memory pools into NOLOAD section (pytorch#21741)
In the arm_executor_runner, the two large memory pools (60MiB by default) input_file_allocation_pool and memory_allocation_pool were put into the input_data_sec section. While the pools contain uninitialized memory, this section is also used for embedding data into the runner and can thus not be NOLOAD. Instead, introduce two new input sections, input_file_allocator_sec and method_allocator_sec, that are put into .ddr.bss which is already NOLOAD. Additionally, for Corstone-300 the .ddr.bss output section is placed after the DDR-backed scatter-load payloads to avoid creating a large file-backed hole in the ELF. This saves binary size, since the pools will only be initialized at runtime. It also has the benefit of making the placement of these pools more explicit. cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani Signed-off-by: Erik Lundell <erik.lundell@arm.com>
1 parent 4598f15 commit bc2833f

5 files changed

Lines changed: 19 additions & 15 deletions

File tree

‎examples/arm/executor_runner/Corstone-300.ld‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,6 @@ SECTIONS
254254
__asan_shadow_end = .;
255255
} > DDR :null
256256

257-
.ddr.bss (NOLOAD) :
258-
{
259-
#if (ETHOSU_ARENA == 1)
260-
. = ALIGN(32);
261-
*(.bss.tensor_arena)
262-
#endif
263-
} > DDR :null
264-
265257
__eddr_data = ALIGN(4);
266258
.sram.data :
267259
{
@@ -281,6 +273,17 @@ SECTIONS
281273
__rodata_end__ = .;
282274
} > DTCM AT >DDR :rom_dram
283275

276+
.ddr.bss (NOLOAD) :
277+
{
278+
. = ALIGN(16);
279+
*(input_file_allocator_sec)
280+
*(method_allocator_sec)
281+
#if (ETHOSU_ARENA == 1)
282+
. = ALIGN(32);
283+
*(.bss.tensor_arena)
284+
#endif
285+
} > DDR :null
286+
284287
.bss :
285288
{
286289
. = ALIGN(4);

‎examples/arm/executor_runner/Corstone-320.ld‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,9 @@ SECTIONS
261261

262262
.ddr.bss (NOLOAD) :
263263
{
264+
. = ALIGN(16);
265+
*(input_file_allocator_sec)
266+
*(method_allocator_sec)
264267
#if (ETHOSU_ARENA == 1)
265268
. = ALIGN(32);
266269
*(.bss.tensor_arena)

‎examples/arm/executor_runner/arm_executor_runner.cpp‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,7 @@ using printf_size_t = unsigned long;
150150
* e.g. the input file data and the pte file data
151151
* In our unit test flow, we have the capability to provide an enitre model to
152152
* the Corstone-3xx FVP using semi hosting. Hence, the input file allocation
153-
* pool needs to be large enough to take an entire model and input. On the FVP,
154-
* input_data_sec is linked to the DDR, which is large (256MB on
155-
* Corstone-300).
153+
* pool needs to be large enough to take an entire model and input.
156154
* If you use semihosting on your HW this can be lowered to fit your
157155
* files/memory
158156
*/
@@ -163,7 +161,7 @@ using printf_size_t = unsigned long;
163161
const size_t input_file_allocation_pool_size =
164162
ET_ARM_BAREMETAL_SEMIHOSTING_FILE_ALLOCATOR_POOL_SIZE;
165163
unsigned char __attribute__((
166-
section("input_data_sec"),
164+
section("input_file_allocator_sec"),
167165
aligned(16))) input_file_allocation_pool[input_file_allocation_pool_size];
168166
#endif
169167

@@ -231,7 +229,7 @@ using torch::executor::etdump_result;
231229
const size_t method_allocation_pool_size =
232230
ET_ARM_BAREMETAL_METHOD_ALLOCATOR_POOL_SIZE;
233231
unsigned char __attribute__((
234-
section("input_data_sec"),
232+
section("method_allocator_sec"),
235233
aligned(16))) method_allocation_pool[method_allocation_pool_size];
236234

237235
#if defined(ET_BUNDLE_IO)

‎examples/arm/image_classification_example_ethos_u/runtime/main.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ constexpr const char* labels[] = {
8585

8686
const size_t method_allocation_pool_size = 1 * 1024 * 1024;
8787
unsigned char __attribute__((
88-
section("input_data_sec"),
88+
section("method_allocator_sec"),
8989
aligned(16))) method_allocation_pool[method_allocation_pool_size];
9090

9191
/*

‎examples/arm/mobilesam_prompt_segmentation_example_ethos_u/runtime/main.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ using executorch::runtime::Span;
4646
const size_t method_allocation_pool_size =
4747
ET_SEGMENTATION_METHOD_ALLOCATOR_POOL_SIZE;
4848
unsigned char __attribute__((
49-
section("input_data_sec"),
49+
section("method_allocator_sec"),
5050
aligned(16))) method_allocation_pool[method_allocation_pool_size];
5151

5252
const size_t temp_allocation_pool_size =

0 commit comments

Comments
 (0)