Skip to content

Commit

Permalink
snRuntime: Fix synchronization bug
Browse files Browse the repository at this point in the history
Since only the DMA core initializes the allocator structs, but all
cores make use of it, it is important to place a barrier between
the initialization and its successive use.
  • Loading branch information
colluca committed Jul 4, 2024
1 parent 5ab7d18 commit 8231ab3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions sw/snRuntime/src/alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ inline void snrt_alloc_init() {
snrt_l3_allocator()->size = 0;
snrt_l3_allocator()->next = snrt_l3_allocator()->base;
}
// Synchronize with other cores
snrt_cluster_hw_barrier();
}

// TODO colluca: optimize by using DMA
Expand Down
3 changes: 2 additions & 1 deletion sw/snRuntime/src/start.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ void snrt_main() {
#endif

#if defined(SNRT_INIT_BSS) || defined(SNRT_INIT_CLS)
// Single DMA wait call for both snrt_init_bss() and snrt_init_cls()
// Single DMA wait call and barrier for both snrt_init_bss() and snrt_init_cls()
if (snrt_is_dm_core()) snrt_dma_wait_all();
snrt_cluster_hw_barrier();
#endif

#ifdef SNRT_CRT0_CALLBACK3
Expand Down

0 comments on commit 8231ab3

Please sign in to comment.