Snitch Runtime
Loading...
Searching...
No Matches
alloc_v2.h File Reference

Defines functions to dynamically allocate the cluster's L1 memory. More...

Go to the source code of this file.

Functions

snrt_allocator_tsnrt_l1_allocator_v2 ()
 Get a pointer to the L1 allocator.
 
void * snrt_l1_next_v2 ()
 Get the next pointer of the L1 allocator.
 
void snrt_l1_update_next_v2 (void *next)
 Override the L1 allocator next pointer.
 
void snrt_l1_alloc_check_bounds ()
 Check if the allocation exceeds the allocator bounds and raise an exception if it does.
 
void * snrt_l1_alloc_cluster_local (size_t size, const size_t alignment)
 Allocate space for a variable in the cluster's L1 memory.
 
void * snrt_l1_alloc_compute_core_local (size_t size, const size_t alignment)
 Allocate space for N variables in the cluster's L1 memory.
 
void * snrt_compute_core_local_ptr (void *ptr, uint32_t core_idx, size_t size)
 Get a pointer to the same variable allocated by another core.
 
void * snrt_remote_l1_ptr (void *ptr, uint32_t src_cluster_idx, uint32_t dst_cluster_idx)
 Get a pointer to the same offset in another cluster's L1 memory.
 
void snrt_alloc_init_v2 ()
 Initialize the L1 allocator.
 

Variables

__thread snrt_allocator_t l1_allocator_v2
 

Detailed Description

Defines functions to dynamically allocate the cluster's L1 memory.

This file provides functions to dynamically allocate the cluster's L1 memory. It includes functions for allocating memory for cluster-local variables, compute core-local variables, and for manipulating pointers to variables allocated by different cores or clusters.

Function Documentation

◆ snrt_alloc_init_v2()

void snrt_alloc_init_v2 ( )
inline

Initialize the L1 allocator.

This function initializes the L1 allocator by calculating the end address of the heap and setting the base, end, and next pointers of the allocator.

Note
This function should be called before using any of the allocation functions.

◆ snrt_compute_core_local_ptr()

void * snrt_compute_core_local_ptr ( void * ptr,
uint32_t core_idx,
size_t size )
inline

Get a pointer to the same variable allocated by another core.

This function takes a pointer to a variable allocated using snrt_l1_alloc_compute_core_local and returns a pointer to the same variable allocated by another core, as specified by core_idx. The size argument should be the same used during allocation.

Parameters
ptrPointer to the variable allocated by the current core.
core_idxIndex of the core that allocated the variable.
sizeThe size of the variable.
Returns
Pointer to the same variable allocated by the specified core.

◆ snrt_l1_alloc_cluster_local()

void * snrt_l1_alloc_cluster_local ( size_t size,
const size_t alignment )
inline

Allocate space for a variable in the cluster's L1 memory.

This function dynamically allocates space for a variable of size size in the cluster's L1 memory. The allocation is aligned to the specified alignment.

Parameters
sizeThe size of the variable to allocate.
alignmentThe alignment of the allocation.
Returns
Pointer to the allocated variable.

◆ snrt_l1_alloc_compute_core_local()

void * snrt_l1_alloc_compute_core_local ( size_t size,
const size_t alignment )
inline

Allocate space for N variables in the cluster's L1 memory.

This function dynamically allocates space for N variables of size size in the cluster's L1 memory, where N is the number of compute cores in the cluster. The variables are allocated in a contiguous block of memory. The whole block is aligned to the specified alignment.

Parameters
sizeThe size of each variable to allocate.
alignmentThe alignment of the allocation.
Returns
Pointer to the allocated variable for each compute core. The return value for the DM core is undefined.

◆ snrt_l1_allocator_v2()

snrt_allocator_t * snrt_l1_allocator_v2 ( )
inline

Get a pointer to the L1 allocator.

Returns
Pointer to the L1 allocator.

◆ snrt_l1_next_v2()

void * snrt_l1_next_v2 ( )
inline

Get the next pointer of the L1 allocator.

Returns
The next pointer of the L1 allocator.

◆ snrt_l1_update_next_v2()

void snrt_l1_update_next_v2 ( void * next)
inline

Override the L1 allocator next pointer.

Parameters
nextThe new value for the next pointer.

◆ snrt_remote_l1_ptr()

void * snrt_remote_l1_ptr ( void * ptr,
uint32_t src_cluster_idx,
uint32_t dst_cluster_idx )
inline

Get a pointer to the same offset in another cluster's L1 memory.

This function takes a pointer to a variable in the calling (source) cluster's L1 memory and returns a pointer to the same offset in the target (destination) cluster's L1 memory.

Parameters
ptrPointer to the variable in the source cluster's L1 memory.
src_cluster_idxIndex of the source cluster.
dst_cluster_idxIndex of the destination cluster.
Returns
Pointer to the same offset in the destination cluster's L1 memory.