NAME
SYNOPSIS
DESCRIPTION
ENVIRONMENT
COPYRIGHT
SEE ALSO
libmemtier - memory tiering interface.
Note: memkind_memtier.h functionality is considered as a stable API (STANDARD API).
#include <memkind_memtier.h>
Link with -lmemkind
The API can be used either directly with the usage of C-functions or via environment variables. See also ENVIRONMENT section.
TIER MANAGEMENT:
struct memtier_builder *memtier_builder_new(memtier_policy_t policy);
void memtier_builder_delete(struct memtier_builder *builder);
int memtier_builder_add_tier(struct memtier_builder *builder, memkind_t kind, unsigned kind_ratio);
struct memtier_memory *memtier_builder_construct_memtier_memory(struct memtier_builder *builder);
void memtier_delete_memtier_memory(struct memtier_memory *memory);
HEAP MANAGEMENT:
void *memtier_malloc(struct memtier_memory *memory, size_t size);
void *memtier_kind_malloc(memkind_t kind, size_t size);
void *memtier_calloc(struct memtier_memory *memory, size_t num, size_t size);
void *memtier_kind_calloc(memkind_t kind, size_t num, size_t size);
void *memtier_realloc(struct memtier_memory *memory, void *ptr, size_t size);
void *memtier_kind_realloc(memkind_t kind, void *ptr, size_t size);
int memtier_posix_memalign(struct memtier_memory *memory, void **memptr, size_t alignment, size_t size);
int memtier_kind_posix_memalign(memkind_t kind, void **memptr, size_t alignment, size_t size);
size_t memtier_usable_size(void *ptr);
void memtier_free(void *ptr);
void memtier_kind_free(memkind_t kind, void *ptr);
size_t memtier_kind_allocated_size(memkind_t kind);
DECORATORS:
void memtier_kind_malloc_post(memkind_t kind, size_t size, void **result);
void memtier_kind_calloc_post(memkind_t kind, size_t nmemb, size_t size, void **result);
void memtier_kind_posix_memalign_post(memkind_t kind, void **memptr, size_t alignment, size_t size, int *err);
void memtier_kind_realloc_post(memkind_t *kind, void *ptr, size_t size, void **result);
void memtier_kind_free_pre(void **ptr);
void memtier_kind_usable_size_post(void **ptr, size_t size);
MEMTIER PROPERTY MANAGEMENT:
int memtier_ctl_set(struct memtier_builder *builder, const char *name, const void *val);
This library enables explicit allocation-time memory tiering. It allows to make allocations with the usage of multiple kinds keeping a specified ratio between them. This ratio determines how much of total allocated memory should be allocated with the usage of each kind.
The functions in this section are used to set up, create and destroy the
memtier_memory object. This object is passed as an argument to the
memtier_malloc()
group of functions. It defines the way the allocations
are distributed between different memory tiers.
memtier_builder_new()
memtier_builder_delete()
memtier_builder_construct_memtier_memory()
.memtier_builder_add_tier()
memtier_builder_construct_memtier_memory()
memtier_builder_delete()
function.memtier_delete_memtier_memory()
The functions described in this section define a heap manager with an interface modeled on the ISO C standard API’s, except that the user must specify either the kind of memory with the first argument to each function or the tiered memory object which defines memory tiers used for allocations. See the KINDS section in the memkind(3) manual for a full description of the implemented kinds.
memtier_malloc()
memkind_malloc()
is used for allocations.
For further details on it’s behavior see
memkind(3).memtier_kind_malloc()
memkind_malloc()
function. See
memkind(3) for further details.memtier_calloc()
memkind_calloc()
is used for allocations.
For further details on it’s behavior see memkind(3).memtier_kind_calloc()
memkind_calloc()
function. See
memkind(3) for further details.memtier_realloc()
memkind_realloc()
is used for reallocation. See
memkind(3) for further details.memtier_kind_realloc()
memkind_free(kind, ptr)
and NULL is returned.
If ptr is NULL, memtier_kind_malloc()
is called to allocate new memory.
Otherwise, the memkind_realloc()
function is used. See
memkind(3) for further details.memtier_posix_memalign()
memkind_posix_memalign()
with the main difference that the
memory is used to determine the kind to be used for the allocation. See
memkind(3) for further details.memtier_kind_posix_memalign()
memkind_posix_memalign()
. See
memkind(3) for further details.memtier_usable_size()
memtier_free()
memtier_kind_free()
function with the kind
parameter passed as NULL.memtier_kind_free()
memkind_free()
. If kind is NULL, the kind used to allocate ptr
is detected automatically. See memkind(3)
for further details.memtier_kind_allocated_size()
This is the set of functions used to print information on each call to the
respective memtier_kind_*
function described in the
HEAP MANAGEMENT section. Printed information include
the name of the kind used, parameters passed to the underlying function from
the malloc family of functions and the address of the memory returned.
memtier_ctl_set()
In the above examples, ID should be replaced with the ID of thresholds configuration. The configuration between first two tiers added to builder has an ID equal to 0. The configuration ID of the next two tiers, that is, the second and third ones, is equal to 1, and so on. The last configuration’s ID is equal to the number of tiers minus one.
See libmemtier(7) for details on the usage of memkind tiering via environment variables.
Copyright (C) 2021 - 2022 Intel Corporation. All rights reserved.
libmemtier(7), memkind(3), memkind_malloc(3), memkind_calloc(3), memkind_realloc(3), memkind_free(3), memkind_posix_memalign(3)
The contents of this web site and the associated GitHub repositories are BSD-licensed open source.