Arax -8d09c51940345c86062e8ef2427c705ae66e5926
A Runtime Framework for Decoupling Applications from Heterogeneous Accelerators
Loading...
Searching...
No Matches
alloc.h File Reference
#include <stddef.h>
#include "conf.h"
#include "arax_types.h"
#include <utils/bitmap.h>
+ Include dependency graph for alloc.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  arch_alloc_s
 
struct  arch_alloc_stats_s
 

Macros

#define arch_alloc_free(ALLOC, MEM)
 

Typedefs

typedef void * arch_alloc_state
 

Functions

int arch_alloc_init_once (arch_alloc_s *alloc, size_t size)
 
void arch_alloc_init_always (arch_alloc_s *alloc)
 
void * arch_alloc_allocate (arch_alloc_s *alloc, size_t size)
 
void _arch_alloc_free (arch_alloc_s *alloc, void *mem)
 
void arch_alloc_exit (arch_alloc_s *alloc)
 
arch_alloc_stats_s arch_alloc_stats (arch_alloc_s *alloc)
 
void arch_alloc_inspect (arch_alloc_s *alloc, void(*inspector)(void *start, void *end, size_t size, void *arg), void *arg)
 
void * arax_mmap (size_t s)
 
void * arax_ummap (void *a, size_t s)
 
arch_alloc_sarch_alloc_create_sub_alloc (arch_alloc_s *parent)
 
utils_bitmap_sarch_alloc_get_bitmap ()
 

Macro Definition Documentation

◆ arch_alloc_free

#define arch_alloc_free ( ALLOC,
MEM )
Value:
({ \
_arch_alloc_free(ALLOC, MEM); \
MEM = 0; \
})

Free previously allocated memory from a arch_alloc_s instance.

Parameters
allocAn initialized arch_alloc_s instance.
memA pointer returned from arch_alloc_allocate.

Definition at line 70 of file alloc.h.

Referenced by arax_object_ref_dec(), arax_object_ref_dec_pre_locked(), arax_object_rename(), and async_semaphore_dec().

Typedef Documentation

◆ arch_alloc_state

typedef void* arch_alloc_state

Definition at line 12 of file alloc.h.

Function Documentation

◆ _arch_alloc_free()

◆ arax_mmap()

void * arax_mmap ( size_t s)

Allocate enough pages(4096 bytes) to hold s bytes.

Parameters
sNumber of bytes requested (has to be multiple of BIT_ALLOCATOR_BLOCK)
Returns
Page alligned pointer to memory

Definition at line 143 of file dlmalloc/alloc.c.

References arax_assert, BIT_ALLOCATOR_BLOCK, BIT_ALLOCATOR_BLOCK_MASK, BITMAP_NOT_FOUND, global_alloc, and utils_bitmap_alloc_bits().

+ Here is the call graph for this function:

◆ arax_ummap()

void * arax_ummap ( void * a,
size_t s )

Release the pages starting from a and ending after bytes

Parameters
aPointer returned from a call of arax_mmap().
sNumber of bytes to be freed (has to be multiple of BIT_ALLOCATOR_BLOCK)
Returns
NULL on success

Definition at line 154 of file dlmalloc/alloc.c.

References BIT_ALLOCATOR_BLOCK, global_alloc, arch_alloc_inner_s::start, and utils_bitmap_free_bits().

+ Here is the call graph for this function:

◆ arch_alloc_allocate()

void * arch_alloc_allocate ( arch_alloc_s * alloc,
size_t size )

Allocate contiguous memory from the alloc arch_alloc_s instance.

Parameters
allocAn initialized arch_alloc_s instance.
sizeThe size of the allocation.
Returns
Pointer to the beginning of size usable bytes, or NULL on failure.

Definition at line 62 of file dlmalloc/alloc.c.

References arch_alloc_inner_s::lock, arch_alloc_inner_s::root, arch_alloc_inner_s::start, utils_spinlock_lock, utils_spinlock_unlock, utils_timer_get_duration_ns, and utils_timer_set.

Referenced by arax_object_register(), arax_object_rename(), arax_plot_register_metric(), arch_alloc_create_sub_alloc(), and async_semaphore_dec().

+ Here is the caller graph for this function:

◆ arch_alloc_create_sub_alloc()

arch_alloc_s * arch_alloc_create_sub_alloc ( arch_alloc_s * parent)

Create a sub-allocator.

This allocator user the same global bitmap for requesting bulk allocations, but maintains separate metadata from the 'global' allocator.

Use arch_alloc_free(), arch_alloc_allocate() to alloc/free memory.

Returned allocator should be eventually released by calling arch_alloc_exit()

Parameters
parentallocator
Returns
New arch_alloc_s instance.

Definition at line 163 of file dlmalloc/alloc.c.

References arch_alloc_allocate(), and arch_alloc_inner_s::root.

+ Here is the call graph for this function:

◆ arch_alloc_exit()

void arch_alloc_exit ( arch_alloc_s * alloc)

Release any resources claimed by the alloc arch_alloc_s instance.

Note
The shared memory segment (shm in arch_alloc_init) must be freed by the user.

Definition at line 102 of file dlmalloc/alloc.c.

References arch_alloc_inner_s::root.

Referenced by arax_pipe_exit().

+ Here is the caller graph for this function:

◆ arch_alloc_get_bitmap()

utils_bitmap_s * arch_alloc_get_bitmap ( )

Definition at line 172 of file dlmalloc/alloc.c.

References global_alloc.

◆ arch_alloc_init_always()

void arch_alloc_init_always ( arch_alloc_s * alloc)

Perform necessary initialization for every arax application.

Note
This has to be called on new processes, that have not called arch_alloc_init_once
Parameters
alloc

Definition at line 57 of file dlmalloc/alloc.c.

References global_alloc.

Referenced by arax_pipe_init().

+ Here is the caller graph for this function:

◆ arch_alloc_init_once()

int arch_alloc_init_once ( arch_alloc_s * alloc,
size_t size )

Initialize a arch_alloc_s instance on a mapped shared memory segment.

Note
This only has to be called by the first process, to initialize global state
Parameters
allocPointer to be filled with initialized instance.
sizeThe size of the shared memory segment in bytes.
Returns
0 on success.

Definition at line 27 of file dlmalloc/alloc.c.

References BIT_ALLOCATOR_BLOCK, BIT_ALLOCATOR_BLOCK_MASK, BITS_PER_PAGE, arch_alloc_inner_s::bmp, global_alloc, arch_alloc_inner_s::lock, arch_alloc_inner_s::root, arch_alloc_inner_s::start, utils_bitmap_init(), and utils_spinlock_init.

Referenced by arax_pipe_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ arch_alloc_inspect()

void arch_alloc_inspect ( arch_alloc_s * alloc,
void(* inspector )(void *start, void *end, size_t size, void *arg),
void * arg )

Definition at line 135 of file dlmalloc/alloc.c.

References inspect_walker_state::arg, inspect_walker(), inspect_walker_state::inspector, and arch_alloc_inner_s::root.

+ Here is the call graph for this function:

◆ arch_alloc_stats()

arch_alloc_stats_s arch_alloc_stats ( arch_alloc_s * alloc)

Definition at line 117 of file dlmalloc/alloc.c.

References _arch_alloc_mspace_mallinfo(), and arch_alloc_inner_s::root.

+ Here is the call graph for this function: