Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/laik/backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ struct _Laik_Backend {
// for elasticity: removal of processes which got started in a previous
// resize is finished. They can be marked as dead and resources freed
void (*finish_resize)();

Laik_Allocator* (*allocator)();
};


Expand Down
15 changes: 14 additions & 1 deletion src/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,18 @@ void laik_switchstat_free(Laik_SwitchStat* ss, uint64_t bytes)

static int data_id = 0;

// get backend specific allocator
static Laik_Allocator* allocator(Laik_Instance* inst, Laik_Data* d)
{
(void)d;
Laik_Allocator* (*create)();
create = inst->backend->allocator;

assert(laik_allocator_def);

return create ? create() : laik_allocator_def;
}

Laik_Data* laik_new_data(Laik_Space* space, Laik_Type* type)
{
Laik_Data* d = malloc(sizeof(Laik_Data));
Expand All @@ -177,7 +189,8 @@ Laik_Data* laik_new_data(Laik_Space* space, Laik_Type* type)
d->activePartitioning = 0;
d->activeMappings = 0;
assert(laik_allocator_def);
d->allocator = laik_allocator_def; // malloc/free + reuse if possible
d->allocator = allocator(space->inst, d); // malloc/free + reuse if possible
assert(d->allocator);
d->layout_factory = laik_new_layout_lex; // by default, use lex layouts
d->stat = laik_newSwitchStat();

Expand Down