### memkind_default_create() Source: https://pmem.io/memkind/manpages/memkind_default.3.html Implements the required startup procedure for a memkind kind. ```APIDOC ## memkind_default_create() ### Description Implements the required startup for every kind. If a kind does not point to this function directly for its ops.create() operation, then the function that it points to must call memkind_default_create() at its start. ``` -------------------------------- ### hbw_get_policy, hbw_set_policy Source: https://pmem.io/memkind/manpages/hbwmalloc.3.html Functions to get or set the high bandwidth memory allocation policy. ```APIDOC ## hbw_get_policy, hbw_set_policy ### Description hbw_get_policy returns the current policy. hbw_set_policy sets the policy and returns zero on success or an error code (EPERM, EINVAL) on failure. ``` -------------------------------- ### Display help for memkind-auto-dax-kmem-nodes Source: https://pmem.io/memkind/manpages/memkind-auto-dax-kmem-nodes.1.html Use this command to view the help documentation and available options for the utility. ```bash memkind-auto-dax-kmem-nodes [-h|--help] ``` -------------------------------- ### memkind_hugetlb_init_once Source: https://pmem.io/memkind/manpages/memkind_hugetlb.3.html Initializes the MEMKIND_HUGETLB kind. ```APIDOC ## void memkind_hugetlb_init_once(void) ### Description Initializes the MEMKIND_HUGETLB kind. This function should not be called more than once and may reserve extra memory. ``` -------------------------------- ### Usage of memkind-hbw-nodes Source: https://pmem.io/memkind/manpages/memkind-hbw-nodes.1.html Displays the command-line syntax for invoking the utility. ```bash memkind-hbw-nodes [-h|--help] ``` -------------------------------- ### memkind_pmem_create Source: https://pmem.io/memkind/manpages/memkind_pmem.3.html Initializes a file-backed memory kind by allocating metadata and creating an arena. ```APIDOC ## int memkind_pmem_create(struct memkind *kind, struct memkind_ops *ops, const char *name) ### Description Allocates space for pmem-specific metadata and initializes the memory kind. ### Parameters - **kind** (struct memkind *) - Pointer to the memkind structure. - **ops** (struct memkind_ops *) - Pointer to the operations structure. - **name** (const char *) - Name of the memory kind. ``` -------------------------------- ### memkind_pmem_create Source: https://pmem.io/memkind/manpages/memkind_pmem.3 Initializes a file-backed memory kind by allocating metadata and creating an arena. ```APIDOC ## int memkind_pmem_create(struct memkind *kind, struct memkind_ops *ops, const char *name) ### Description Allocates space for pmem-specific metadata and initializes the memory kind. ### Parameters - **kind** (struct memkind *) - Pointer to the memkind structure to initialize. - **ops** (struct memkind_ops *) - Pointer to the operations structure. - **name** (const char *) - Name of the memory kind. ``` -------------------------------- ### Include libmemtier header Source: https://pmem.io/memkind/manpages/libmemtier.3.html Include the necessary header and link with -lmemkind to use the library. ```c #include Link with -lmemkind ``` -------------------------------- ### Enable memkind memory tiering via environment variables Source: https://pmem.io/memkind/manpages/libmemtier.7 Use LD_PRELOAD and MEMKIND_MEM_TIERS to enable memory tiering for an existing command. ```bash LD_PRELOAD=libmemtier.so MEMKIND_MEM_TIERS="..." command {arguments ...} ``` -------------------------------- ### memkind_create_pmem_with_config Source: https://pmem.io/memkind/manpages/memkind.3.html Creates a file-backed kind of memory using a configuration object. ```APIDOC ## int memkind_create_pmem_with_config(struct memkind_config *cfg, memkind_t *kind) ### Description Creates a file-backed kind of memory using characteristics defined in the provided configuration object. ### Parameters - **cfg** (struct memkind_config *) - Configuration object defining memory characteristics. - **kind** (memkind_t *) - Pointer to store the created kind object. ``` -------------------------------- ### Synopsis of libmemkind::static_kind::allocator Source: https://pmem.io/memkind/manpages/memkindallocator.3 This snippet outlines the constructor, destructor, and primary memory management methods for the allocator. ```cpp #include Link with -lmemkind libmemkind::static_kind::allocator(libmemkind::kinds kind); template libmemkind::static_kind::allocator::allocator(const libmemkind::static_kind::allocator&) noexcept; template libmemkind::static_kind::allocator(const allocator&& other) noexcept; libmemkind::static_kind::allocator::~allocator(); T *libmemkind::static_kind::allocator::allocate(std::size_t n) const; void libmemkind::static_kind::allocator::deallocate(T *p, std::size_t n) const; template void libmemkind::static_kind::allocator::construct(U *p, Args... args) const; void libmemkind::static_kind::allocator::destroy(T *p) const; ``` -------------------------------- ### void memkind_interleave_init_once(void) Source: https://pmem.io/memkind/manpages/memkind_interleave.3.html Initializes the MEMKIND_INTERLEAVE kind. This function should be called exactly once and may reserve extra memory. ```APIDOC ## void memkind_interleave_init_once(void) ### Description Initializes the MEMKIND_INTERLEAVE kind. This function should not be called more than once and may reserve extra memory. ### Prototype void memkind_interleave_init_once(void); ``` -------------------------------- ### Run Application with AutoHBW Source: https://pmem.io/memkind/manpages/autohbw.7 Use LD_PRELOAD to interpose heap allocations for a specific command. ```bash LD_PRELOAD=libautohbw.so command {arguments ...} ``` ```bash LD_PRELOAD=libautohbw.so /bin/ls ``` ```bash LD_PRELOAD=libautohbw.so /bin/ls -l ``` -------------------------------- ### Enable Hardware Locality and HMAT Support Source: https://pmem.io/memkind/manpages/memkindallocator.3 Configure the memkind library to include support for libhwloc, which is required for both locality information and HMAT-based performance characteristics. ```bash ./configure --enable-hwloc ``` -------------------------------- ### Include memkind header Source: https://pmem.io/memkind/manpages/memkind.3.html Include the primary header file and link against the memkind library. ```c #include Link with -lmemkind ``` -------------------------------- ### Experimental memkind API Source: https://pmem.io/memkind/manpages/memkind.3.html Functions for experimental heap and kind management. ```c HEAP MANAGEMENT: int memkind_posix_memalign(memkind_t kind, void **memptr, size_t alignment, size_t size); KIND MANAGEMENT: int memkind_create_kind(memkind_memtype_t memtype_flags, memkind_policy_t policy, memkind_bits_t flags, memkind_t *kind); ``` -------------------------------- ### Initialization Functions Source: https://pmem.io/memkind/manpages/memkind_hbw.3.html Functions to initialize specific HBW memory kinds. ```APIDOC ## Initialization Functions - void memkind_hbw_init_once(void) - void memkind_hbw_hugetlb_init_once(void) - void memkind_hbw_all_hugetlb_init_once(void) - void memkind_hbw_preferred_init_once(void) - void memkind_hbw_preferred_hugetlb_init_once(void) - void memkind_hbw_interleave_init_once(void) ### Description These functions initialize specific HBW memory kinds. Each function should be called only once during the application lifecycle. ``` -------------------------------- ### Standard memkind API Source: https://pmem.io/memkind/manpages/memkind.3.html Core functions for error handling, heap management, kind configuration, statistics, and decorators. ```c ERROR HANDLING: void memkind_error_message(int err, char *msg, size_t size); LIBRARY VERSION: int memkind_get_version(); HEAP MANAGEMENT: void *memkind_malloc(memkind_t kind, size_t size); void *memkind_calloc(memkind_t kind, size_t num, size_t size); void *memkind_realloc(memkind_t kind, void *ptr, size_t size); void memkind_free(memkind_t kind, void *ptr); size_t memkind_malloc_usable_size(memkind_t kind, void *ptr); void *memkind_defrag_reallocate(memkind_t kind, void *ptr); memkind_t memkind_detect_kind(void *ptr); KIND CONFIGURATION MANAGEMENT: struct memkind_config *memkind_config_new(); void memkind_config_delete(struct memkind_config *cfg); void memkind_config_set_path(struct memkind_config *cfg, const char *pmem_dir); void memkind_config_set_size(struct memkind_config *cfg, size_t pmem_size); void memkind_config_set_memory_usage_policy(struct memkind_config *cfg, memkind_mem_usage_policy policy); KIND MANAGEMENT: int memkind_create_fixed(void *addr, size_t size, memkind_t *kind); int memkind_create_pmem(const char *dir, size_t max_size, memkind_t *kind); int memkind_create_pmem_with_config(struct memkind_config *cfg, memkind_t *kind); int memkind_destroy_kind(memkind_t kind); int memkind_check_available(memkind_t kind); ssize_t memkind_get_capacity(memkind_t kind); int memkind_check_dax_path(const char *pmem_dir); void memkind_set_allow_zero_allocs(memkind_t kind, bool allow_zero_allocs); STATISTICS: int memkind_update_cached_stats(void); int memkind_get_stat(memkind_t kind, memkind_stat stat, size_t *value); int memkind_stats_print(void (*write_cb) (void *, const char *), void *cbopaque, memkind_stat_print_opt opts); DECORATORS: void memkind_malloc_pre(memkind_t *kind, size_t *size); void memkind_malloc_post(memkind_t kind, size_t size, void **result); void memkind_calloc_pre(memkind_t *kind, size_t *nmemb, size_t *size); void memkind_calloc_post(memkind_t kind, size_t nmemb, size_t size, void **result); void memkind_posix_memalign_pre(memkind_t *kind, void **memptr, size_t *alignment, size_t *size); void memkind_posix_memalign_post(memkind_t kind, void **memptr, size_t alignment, size_t size, int *err); void memkind_realloc_pre(memkind_t *kind, void **ptr, size_t *size); void memkind_realloc_post(memkind_t *kind, void *ptr, size_t size, void **result); void memkind_free_pre(memkind_t *kind, void **ptr); void memkind_free_post(memkind_t kind, void *ptr); ENHANCEMENTS: int memkind_set_bg_threads(bool state); ``` -------------------------------- ### memkind_pmem API Functions Source: https://pmem.io/memkind/manpages/memkind_pmem.3 Core functions for creating, destroying, and managing file-backed memory kinds. ```c int memkind_pmem_create(struct memkind *kind, struct memkind_ops *ops, const char *name); int memkind_pmem_destroy(struct memkind *kind); void *memkind_pmem_mmap(struct memkind *kind, void *addr, size_t size); int memkind_pmem_get_mmap_flags(struct memkind *kind, int *flags); int memkind_pmem_validate_dir(const char *dir); ``` -------------------------------- ### Synopsis of libmemkind::fixed::allocator Source: https://pmem.io/memkind/manpages/fixedallocator.3.html The header file and class member signatures for the fixed allocator. ```cpp #include Link with -lmemkind libmemkind::fixed::allocator(void *addr, size_t size); template libmemkind::fixed::allocator::allocator(const libmemkind::fixed::allocator&) noexcept; template libmemkind::fixed::allocator::allocator(allocator&& other) noexcept; libmemkind::fixed::allocator::~allocator(); T *libmemkind::fixed::allocator::allocate(std::size_t n) const; void libmemkind::fixed::allocator::deallocate(T *p, std::size_t n) const; template void libmemkind::fixed::allocator::construct(U *p, Args... &&args) const; void libmemkind::fixed::allocator::destroy(T *p) const; ``` -------------------------------- ### Run memtier with program arguments Source: https://pmem.io/memkind/manpages/memtier.1.html Basic syntax for executing a program through memtier to enable memory tiering. ```bash memtier [ -r ratio ] [ -t thresholds ] program args... ``` -------------------------------- ### memkind_create_pmem Source: https://pmem.io/memkind/manpages/memkind.3.html Creates a file-backed kind of memory in the specified directory. ```APIDOC ## int memkind_create_pmem(const char *dir, size_t max_size, memkind_t *kind) ### Description Creates a file-backed kind of memory. The file is created in the specified directory, truncated to max_size, and memory-mapped. ### Parameters - **dir** (const char *) - Directory path for the file-backed memory. - **max_size** (size_t) - Maximum size of the memory pool in bytes. - **kind** (memkind_t *) - Pointer to store the created kind object. ``` -------------------------------- ### libmemkind::pmem::allocator Synopsis Source: https://pmem.io/memkind/manpages/pmemallocator.3 The synopsis defines the constructors, destructor, and standard allocator methods for the pmem allocator. ```cpp #include Link with -lmemkind libmemkind::pmem::allocator(const char *dir, size_t max_size); libmemkind::pmem::allocator(const char &dir, size_t max_size, libmemkind::allocation_policy alloc_policy); libmemkind::pmem::allocator(const std::string &dir, size_t max_size); libmemkind::pmem::allocator(const std::string &dir, size_t max_size, libmemkind::allocation_policy alloc_policy); template libmemkind::pmem::allocator::allocator(const libmemkind::pmem::allocator&) noexcept; template libmemkind::pmem::allocator(const allocator&& other) noexcept; libmemkind::pmem::allocator::~allocator(); T *libmemkind::pmem::allocator::allocate(std::size_t n) const; void libmemkind::pmem::allocator::deallocate(T *p, std::size_t n) const; template void libmemkind::pmem::allocator::construct(U *p, Args... args) const; void libmemkind::pmem::allocator::destroy(T *p) const; ``` -------------------------------- ### Configure Dynamic Memory Thresholds Source: https://pmem.io/memkind/manpages/libmemtier.7 Configures dynamic thresholding for memory allocation between DRAM and PMEM based on allocation size. ```bash LD_PRELOAD=libmemtier.so MEMKIND_MEM_TIERS="KIND:DRAM,RATIO:1;KIND:KMEM_DAX,RATIO:4;POLICY:DYNAMIC_THRESHOLD" MEMKIND_MEM_THRESHOLDS="INIT_VAL:64,MIN_VAL:1,MAX_VAL:10000" ``` -------------------------------- ### memkind_config_new Source: https://pmem.io/memkind/manpages/memkind.3.html Creates a new memkind configuration object. ```APIDOC ## struct memkind_config *memkind_config_new() ### Description Creates the memkind configuration object used for managing kind-specific settings. ### Returns - **struct memkind_config*** - A pointer to the newly created configuration. ``` -------------------------------- ### Configure Huge Pages Source: https://pmem.io/memkind/manpages/memkindallocator.3 Set the number of persistent huge pages in the kernel. ```bash sudo sysctl vm.nr_hugepages= ``` -------------------------------- ### Configure Memory Tiering Ratios Source: https://pmem.io/memkind/manpages/libmemtier.7 Sets memory allocation ratios between PMEM and DRAM using the MEMKIND_MEM_TIERS variable. ```bash LD_PRELOAD=libmemtier.so MEMKIND_MEM_TIERS="KIND:FS_DAX,PATH:/mnt/pmem0,PMEM_SIZE_LIMIT:10G,RATIO:1;KIND:DRAM,RATIO:4;POLICY:STATIC_RATIO" /bin/ls -l ``` ```bash LD_PRELOAD=libmemtier.so MEMKIND_MEM_TIERS="KIND:FS_DAX,PATH:/mnt/pmem0,RATIO:1;POLICY:STATIC_RATIO" ``` -------------------------------- ### memkind_fixed_create Source: https://pmem.io/memkind/manpages/memkind_fixed.3.html Initializes a new fixed memory kind by allocating metadata and creating an arena. ```APIDOC ## int memkind_fixed_create(struct memkind *kind, struct memkind_ops *ops, const char *name) ### Description Allocates space for fixed-kind-specific metadata and initializes the kind by calling memkind_arena_create. ### Parameters - **kind** (struct memkind *) - Pointer to the memkind structure to initialize. - **ops** (struct memkind_ops *) - Pointer to the operations structure. - **name** (const char *) - Name of the memory kind. ### Returns - **int** - Returns 0 on success, or an error code on failure. ``` -------------------------------- ### hbw::allocator Allocation and Deallocation Methods Source: https://pmem.io/memkind/manpages/hbwallocator.3.html Signatures for memory allocation and deallocation methods within the hbw::allocator class. ```cpp hbw::allocator::pointer hbw::allocator::allocate(hbw::allocator::size_type n, const void * = 0) ``` ```cpp hbw::allocator::deallocate(hbw::allocator::pointer p, hbw::allocator::size_type n) ``` -------------------------------- ### memkind_arena API functions Source: https://pmem.io/memkind/manpages/memkind_arena.3 A collection of experimental functions for managing jemalloc arenas and memory allocation within memkind. ```c int memkind_arena_create(struct memkind *kind, struct memkind_ops *ops, const char *name); int memkind_arena_create_map(struct memkind *kind, extent_hooks_t *hooks); int memkind_arena_destroy(struct memkind *kind); void *memkind_arena_malloc(struct memkind *kind, size_t size); void *memkind_arena_calloc(struct memkind *kind, size_t num, size_t size); int memkind_arena_posix_memalign(struct memkind *kind, void **memptr, size_t alignment, size_t size); void *memkind_arena_realloc(struct memkind *kind, void *ptr, size_t size); void *memkind_arena_realloc_with_kind_detect(void *ptr, size_t size); int memkind_thread_get_arena(struct memkind *kind, unsigned int *arena, size_t size); int memkind_bijective_get_arena(struct memkind *kind, unsigned int *arena, size_t size); struct memkind *get_kind_by_arena(unsigned arena_ind); struct memkind *memkind_arena_detect_kind(void *ptr); int memkind_arena_finalize(struct memkind *kind); void memkind_arena_init(struct memkind *kind); void memkind_arena_free(struct memkind *kind, void *ptr); void memkind_arena_free_with_kind_detect(void *ptr); int memkind_arena_update_memory_usage_policy(struct memkind *kind, memkind_mem_usage_policy policy); int memkind_arena_set_max_bg_threads(size_t threads_limit); int memkind_arena_set_bg_threads(bool state); int memkind_arena_stats_print(void (*write_cb) (void *, const char *), void *cbopaque, memkind_stat_print_opt opts); ``` -------------------------------- ### memkind_config_set_path Source: https://pmem.io/memkind/manpages/memkind.3.html Sets the directory path for file-backed memory in a configuration. ```APIDOC ## void memkind_config_set_path(struct memkind_config *cfg, const char *pmem_dir) ### Description Updates the pmem_dir configuration parameter, which specifies the directory path where file-backed memory will be created. ### Parameters - **cfg** (struct memkind_config *) - The configuration object. - **pmem_dir** (const char *) - The directory path. ``` -------------------------------- ### hbw_calloc Source: https://pmem.io/memkind/manpages/hbwmalloc.3.html Allocates and initializes high bandwidth memory to zero. ```APIDOC ## void* hbw_calloc(size_t nmemb, size_t size) ### Description Allocates space for nmemb objects of size bytes in high bandwidth memory, initialized to zero. ``` -------------------------------- ### Configure AutoHBW Size Thresholds Source: https://pmem.io/memkind/manpages/autohbw.7 Set the size range for allocations to be redirected to HBW memory. ```bash AUTO_HBW_SIZE=4K ``` ```bash AUTO_HBW_SIZE=1M:5M ``` -------------------------------- ### hbw_posix_memalign_psize Source: https://pmem.io/memkind/manpages/hbwmalloc.3 Allocates aligned high bandwidth memory with specific page size requirements. ```APIDOC ## int hbw_posix_memalign_psize(void **memptr, size_t alignment, size_t size, hbw_pagesize_t pagesize) ### Description Allocates size bytes of high bandwidth memory with a specific alignment and page size (e.g., HBW_PAGESIZE_4KB or HBW_PAGESIZE_2MB). ``` -------------------------------- ### memkind_set_allow_zero_allocs Source: https://pmem.io/memkind/manpages/memkind.3.html Configures behavior for zero-size allocations. ```APIDOC ## void memkind_set_allow_zero_allocs(memkind_t kind, bool allow_zero_allocs) ### Description Determines if malloc-like functions return a valid pointer or NULL when a size of zero is requested. ### Parameters - **kind** (memkind_t) - The kind object to configure. - **allow_zero_allocs** (bool) - True to return a valid pointer, false to return NULL. ``` -------------------------------- ### memkind_default API Synopsis Source: https://pmem.io/memkind/manpages/memkind_default.3 Function signatures for the default memkind operations and helper functions. ```c int memkind_default_create(struct memkind *kind, struct memkind_ops *ops, const char *name); int memkind_default_destroy(struct memkind *kind); void *memkind_default_malloc(struct memkind *kind, size_t size); void *memkind_default_calloc(struct memkind *kind, size_t num, size_t size); int memkind_default_posix_memalign(struct memkind *kind, void **memptr, size_t alignment, size_t size); void *memkind_default_realloc(struct memkind *kind, void *ptr, size_t size); void memkind_default_free(struct memkind *kind, void *ptr); void *memkind_default_mmap(struct memkind *kind, void *addr, size_t size); int memkind_default_mbind(struct memkind *kind, void *ptr, size_t len); int memkind_default_get_mmap_flags(struct memkind *kind, int *flags); int memkind_default_get_mbind_mode(struct memkind *kind, int *mode); size_t memkind_default_malloc_usable_size(struct memkind *kind, void *ptr); int memkind_preferred_get_mbind_mode(struct memkind *kind, int *mode); int memkind_interleave_get_mbind_mode(struct memkind *kind, int *mode); int memkind_nohugepage_madvise(struct memkind *kind, void *addr, size_t size); int memkind_posix_check_alignment(struct memkind *kind, size_t alignment); int memkind_default_get_mbind_nodemask(struct memkind *kind, unsigned long *nodemask, unsigned long maxnode); void memkind_default_init_once(void); bool size_out_of_bounds(size_t size); ``` -------------------------------- ### memkind_default_malloc() Source: https://pmem.io/memkind/manpages/memkind_default.3.html Allocates memory using jemalloc's malloc. ```APIDOC ## memkind_default_malloc() ### Description Performs a direct call through the jemalloc malloc() function. ``` -------------------------------- ### memkind_hbw_hugetlb_check_available Source: https://pmem.io/memkind/manpages/memkind_hbw.3.html Checks for high bandwidth memory and 2MB huge pages. ```APIDOC ## int memkind_hbw_hugetlb_check_available(struct memkind *kind) ### Description Performs the same check as memkind_hbw_check_available and additionally verifies the availability of 2MB huge pages. ``` -------------------------------- ### Manage memory tiers Source: https://pmem.io/memkind/manpages/libmemtier.3.html Functions for creating, configuring, and deleting memory tier structures. ```c 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); ``` -------------------------------- ### memkind_arena_set_bg_threads Source: https://pmem.io/memkind/manpages/memkind_arena.3.html Configures jemalloc background threads. ```APIDOC ## memkind_arena_set_bg_threads ### Description Enables or disables internal background worker threads in jemalloc. ### Parameters - **enable** (bool) - Whether to enable or disable background threads. ``` -------------------------------- ### Initialize memkind_interleave Source: https://pmem.io/memkind/manpages/memkind_interleave.3.html Initializes the MEMKIND_INTERLEAVE kind. This function should be called exactly once and may reserve additional memory. ```c void memkind_interleave_init_once(void); ``` -------------------------------- ### memkind_calloc Source: https://pmem.io/memkind/manpages/memkind.3.html Allocates and initializes memory to zero. ```APIDOC ## void *memkind_calloc(memkind_t kind, size_t num, size_t size) ### Description Allocates space for `num` objects each `size` bytes in length in memory of the specified `kind`, explicitly initialized to zero bytes. ``` -------------------------------- ### Run MPI Application with AutoHBW Source: https://pmem.io/memkind/manpages/autohbw.7 Execute an MPI job using a wrapper script to set LD_PRELOAD for each rank. ```bash mpirun -n 2 ./autohbw_test.sh ``` -------------------------------- ### memkind-auto-dax-kmem-nodes Source: https://pmem.io/memkind/manpages/memkind-auto-dax-kmem-nodes.1 Prints a comma-separated list of automatically detected persistent memory NUMA nodes. ```APIDOC ## memkind-auto-dax-kmem-nodes ### Description Prints a comma-separated list of automatically detected persistent memory NUMA nodes that can be used with the numactl --membind option. ### Usage memkind-auto-dax-kmem-nodes [-h|--help] ### Options - -h, --help: Displays help text and exits. ### Exit Status - 0: Success - 1: Automatic detection disabled (memkind not built with suitable libdaxctl-devel version) - 2: Invalid argument - 3: Other failure ``` -------------------------------- ### Kind Management Functions Source: https://pmem.io/memkind/manpages/memkind.3.html Functions for creating, destroying, and configuring memory kinds. ```APIDOC ## int memkind_create_pmem(const char *dir, size_t max_size, memkind_t *kind) ### Description Creates a new kind of memory associated with a persistent memory directory. ## int memkind_destroy_kind(memkind_t kind) ### Description Destroys a previously created memory kind and releases associated resources. ``` -------------------------------- ### Configure AutoHBW Logging Source: https://pmem.io/memkind/manpages/autohbw.7 Set the verbosity level for allocation logging. ```bash AUTO_HBW_LOG=1 ``` -------------------------------- ### memkind_check_dax_path Source: https://pmem.io/memkind/manpages/memkind.3.html Checks if a directory path supports DAX for file-backed memory. ```APIDOC ## int memkind_check_dax_path(const char *pmem_dir) ### Description Returns zero if the specified directory path supports file-backed kind memory with DAX attributes. ### Parameters - **pmem_dir** (const char *) - The directory path to check. ``` -------------------------------- ### hbw_posix_memalign, hbw_posix_memalign_psize Source: https://pmem.io/memkind/manpages/hbwmalloc.3.html Functions for aligned high bandwidth memory allocation. ```APIDOC ## hbw_posix_memalign, hbw_posix_memalign_psize ### Description Allocates aligned memory in high bandwidth regions. Returns zero on success or an error code (EINVAL, ENOMEM) on failure. ``` -------------------------------- ### Library Utilities Source: https://pmem.io/memkind/manpages/memkind.3.html Utility functions for versioning and error handling. ```APIDOC ## int memkind_get_version() ### Description Returns the version number of the memkind library. ## void memkind_error_message(int err, char *msg, size_t size) ### Description Converts an error code into a human-readable error message. ``` -------------------------------- ### hbw_free Source: https://pmem.io/memkind/manpages/hbwmalloc.3.html Frees high bandwidth memory. ```APIDOC ## void hbw_free(void *ptr) ### Description Releases the memory block pointed to by ptr for future use. ``` -------------------------------- ### Property Management Source: https://pmem.io/memkind/manpages/libmemtier.3.html Function for setting properties on the memtier builder. ```APIDOC ## Property Management ### Function - `int memtier_ctl_set(struct memtier_builder *builder, const char *name, const void *val)`: Sets a property on the builder. ``` -------------------------------- ### memkind_default_create Source: https://pmem.io/memkind/manpages/memkind_default.3.html Creates a new memkind instance using default operations. ```APIDOC ## int memkind_default_create(struct memkind *kind, struct memkind_ops *ops, const char *name); ### Description Initializes a memkind structure with default operation handlers. ### Parameters - **kind** (struct memkind*) - Pointer to the memkind structure. - **ops** (struct memkind_ops*) - Pointer to the operations structure. - **name** (const char*) - Name of the memkind. ``` -------------------------------- ### libmemkind::fixed::allocator Constructor Source: https://pmem.io/memkind/manpages/fixedallocator.3 Initializes the allocator with a specific memory area and size. ```APIDOC ## libmemkind::fixed::allocator(void *addr, size_t size) ### Description Constructs a new fixed allocator instance that manages memory within the provided address range. ### Parameters - **addr** (void*) - Required - Pointer to the start of the memory area. - **size** (size_t) - Required - Size of the memory area. ``` -------------------------------- ### libmemkind::pmem::allocator Constructor Source: https://pmem.io/memkind/manpages/pmemallocator.3.html Constructs a new pmem allocator instance with a specified directory and maximum size, optionally providing an allocation policy. ```APIDOC ## Constructor ### Signature - libmemkind::pmem::allocator(const char *dir, size_t max_size) - libmemkind::pmem::allocator(const char &dir, size_t max_size, libmemkind::allocation_policy alloc_policy) - libmemkind::pmem::allocator(const std::string &dir, size_t max_size) - libmemkind::pmem::allocator(const std::string &dir, size_t max_size, libmemkind::allocation_policy alloc_policy) ### Description Initializes the allocator to manage persistent memory in the specified directory with a defined maximum size limit. ``` -------------------------------- ### hbw_posix_memalign Source: https://pmem.io/memkind/manpages/hbwmalloc.3.html Allocates aligned high bandwidth memory. ```APIDOC ## int hbw_posix_memalign(void **memptr, size_t alignment, size_t size) ### Description Allocates size bytes of high bandwidth memory aligned to a multiple of alignment. ``` -------------------------------- ### memkind_pmem_mmap Source: https://pmem.io/memkind/manpages/memkind_pmem.3 Allocates file system space for a block of memory. ```APIDOC ## void *memkind_pmem_mmap(struct memkind *kind, void *addr, size_t size) ### Description Allocates file system space for a block of size bytes in the memory-mapped file associated with the given kind. ### Parameters - **kind** (struct memkind *) - The memory kind. - **addr** (void *) - Memory address hint (ignored). - **size** (size_t) - Size of the allocation in bytes. ``` -------------------------------- ### memkind_arena_stats_print Source: https://pmem.io/memkind/manpages/memkind_arena.3 Prints statistics for the jemalloc arenas. ```APIDOC ## int memkind_arena_stats_print(void (*write_cb) (void *, const char *), void *cbopaque, memkind_stat_print_opt opts) ### Description Prints statistics about the jemalloc arenas using the provided write callback. ### Parameters - **write_cb** (void (*)(void *, const char *)) - Required - Callback function for writing output. - **cbopaque** (void *) - Required - Opaque pointer passed to the callback. - **opts** (memkind_stat_print_opt) - Required - Options for printing statistics. ``` -------------------------------- ### memkind_config_set_size Source: https://pmem.io/memkind/manpages/memkind.3.html Sets the size limit for file-backed memory in a configuration. ```APIDOC ## void memkind_config_set_size(struct memkind_config *cfg, size_t pmem_size) ### Description Updates the pmem_size configuration parameter to limit the file-backed memory partition. ### Parameters - **cfg** (struct memkind_config *) - The configuration object. - **pmem_size** (size_t) - The size limit. ``` -------------------------------- ### Hugetlb Memory Operations API Source: https://pmem.io/memkind/manpages/memkind_hugetlb.3.html Functions for checking 2MB page availability, retrieving mmap flags, and initializing the hugetlb kind. ```c int memkind_hugetlb_check_available_2mb(struct memkind *kind); int memkind_hugetlb_get_mmap_flags(struct memkind *kind, int *flags); void memkind_hugetlb_init_once(void); ``` -------------------------------- ### hbwmalloc API Synopsis Source: https://pmem.io/memkind/manpages/hbwmalloc.3.html Include the hbwmalloc header and link with -lmemkind to use these high bandwidth memory allocation functions. ```c #include Link with -lmemkind int hbw_check_available(void); void* hbw_malloc(size_t size); void* hbw_calloc(size_t nmemb, size_t size); void* hbw_realloc (void *ptr, size_t size); void hbw_free(void *ptr); size_t hbw_malloc_usable_size(void *ptr); int hbw_posix_memalign(void **memptr, size_t alignment, size_t size); int hbw_posix_memalign_psize(void **memptr, size_t alignment, size_t size, hbw_pagesize_t pagesize); hbw_policy_t hbw_get_policy(void); int hbw_set_policy(hbw_policy_t mode); int hbw_verify_memory_region(void *addr, size_t size, int flags); ``` -------------------------------- ### memkind_posix_check_alignment() Source: https://pmem.io/memkind/manpages/memkind_default.3.html Validates alignment requirements for posix_memalign. ```APIDOC ## memkind_posix_check_alignment() ### Description Checks the alignment value for memkind_posix_memalign() to ensure it abides by POSIX requirements: alignment must be a power of 2 at least as large as sizeof(void*). ``` -------------------------------- ### memkind_fixed API functions Source: https://pmem.io/memkind/manpages/memkind_fixed.3.html Core functions for managing fixed memory kinds, including creation, destruction, and memory mapping. ```c int memkind_fixed_create(struct memkind *kind, struct memkind_ops *ops, const char *name); int memkind_fixed_destroy(struct memkind *kind); void *memkind_fixed_mmap(struct memkind *kind, void *addr, size_t size); ``` -------------------------------- ### memkind_hbw_check_available Source: https://pmem.io/memkind/manpages/memkind_hbw.3.html Checks if the library can detect heterogeneous NUMA node bandwidths. ```APIDOC ## int memkind_hbw_check_available(struct memkind *kind) ### Description Returns zero if the library successfully detects heterogeneous NUMA node bandwidths. Returns MEMKIND_ERROR_UNAVAILABLE if the detection mechanism fails. ``` -------------------------------- ### memkind_pmem_validate_dir Source: https://pmem.io/memkind/manpages/memkind_pmem.3 Validates if a directory supports DAX. ```APIDOC ## int memkind_pmem_validate_dir(const char *dir) ### Description Checks if the specified directory supports DAX (direct mapping of persistent memory). Returns zero on success. ``` -------------------------------- ### memkind_create_kind Source: https://pmem.io/memkind/manpages/memkind.3.html Creates a kind with specific memory type, policy, and flags. ```APIDOC ## int memkind_create_kind(memkind_memtype_t memtype_flags, memkind_policy_t policy, memkind_bits_t flags, memkind_t *kind) ### Description Creates a kind that allocates memory based on specified memory types, binding policies, and flags. ### Parameters - **memtype_flags** (memkind_memtype_t) - Memory types to allocate. - **policy** (memkind_policy_t) - Page binding policy. - **flags** (memkind_bits_t) - Additional configuration flags. - **kind** (memkind_t *) - Pointer to store the created kind object. ``` -------------------------------- ### memkind_get_version Source: https://pmem.io/memkind/manpages/memkind.3.html Returns the library version as an integer. ```APIDOC ## int memkind_get_version() ### Description Returns the version number represented by a single integer calculated as: major * 1000000 + minor * 1000 + patch. ``` -------------------------------- ### memkind_arena_create Source: https://pmem.io/memkind/manpages/memkind_arena.3 Creates a new jemalloc arena associated with the specified kind. ```APIDOC ## int memkind_arena_create(struct memkind *kind, struct memkind_ops *ops, const char *name) ### Description Creates a new jemalloc arena for the given memkind object using the provided operations and name. ### Parameters - **kind** (struct memkind *) - Required - Pointer to the memkind structure. - **ops** (struct memkind_ops *) - Required - Pointer to the operations structure. - **name** (const char *) - Required - Name of the arena. ``` -------------------------------- ### Tier Management Functions Source: https://pmem.io/memkind/manpages/libmemtier.3.html Functions for creating, configuring, and managing memory tier structures. ```APIDOC ## Tier Management ### Functions - `struct memtier_builder *memtier_builder_new(memtier_policy_t policy)`: Creates a new memtier builder. - `void memtier_builder_delete(struct memtier_builder *builder)`: Deletes a memtier builder. - `int memtier_builder_add_tier(struct memtier_builder *builder, memkind_t kind, unsigned kind_ratio)`: Adds a tier to the builder. - `struct memtier_memory *memtier_builder_construct_memtier_memory(struct memtier_builder *builder)`: Constructs the memory object. - `void memtier_delete_memtier_memory(struct memtier_memory *memory)`: Deletes the memory object. ``` -------------------------------- ### hbw_malloc, hbw_calloc, hbw_realloc Source: https://pmem.io/memkind/manpages/hbwmalloc.3.html Functions for allocating high bandwidth memory. ```APIDOC ## hbw_malloc, hbw_calloc, hbw_realloc ### Description Allocates memory from high bandwidth memory regions. Returns a pointer to the allocated memory or NULL if the request fails. ``` -------------------------------- ### memkind_stats_print Source: https://pmem.io/memkind/manpages/memkind.3.html Prints summary statistics using a provided callback function. ```APIDOC ## int memkind_stats_print(void (*write_cb) (void *, const char *), void *cbopaque, memkind_stat_print_opt opts) ### Description Prints summary statistics by wrapping jemalloc's je_malloc_stats_print(). ### Parameters - **write_cb** (function pointer) - Callback function for printing output. Pass NULL to use the default stderr printer. - **cbopaque** (void *) - Data passed to the write_cb function. - **opts** (memkind_stat_print_opt) - Options for printing statistics. ``` -------------------------------- ### memkind_arena_stats_print Source: https://pmem.io/memkind/manpages/memkind_arena.3 Prints summary statistics for memory arenas. This function allows for custom output handling and configuration via options. ```APIDOC ## int memkind_arena_stats_print(void (*write_cb)(void *, const char *), void *cbopaque, const char *opts) ### Description Prints summary statistics. This function wraps jemalloc's function je_malloc_stats_print(). ### Parameters - **write_cb** (function pointer) - Optional - A custom writer function. Use syscall(2) rather than write(2) within this function. Pass NULL to use the default writer which prints to stderr. - **cbopaque** (void *) - Optional - Data to pass to the write_cb function. - **opts** (const char *) - Optional - Additional options string to configure the output format. ### Returns - **MEMKIND_SUCCESS** (int) - On success. - **MEMKIND_ERROR_INVALID** (int) - When failed to parse options string. ### Statistics Print Options - **MEMKIND_STAT_PRINT_ALL**: Print all statistics. - **MEMKIND_STAT_PRINT_JSON_FORMAT**: Print statistics in JSON format. - **MEMKIND_STAT_PRINT_OMIT_GENERAL**: Omit general information. - **MEMKIND_STAT_PRINT_OMIT_MERGED_ARENA**: Omit merged arena statistics. - **MEMKIND_STAT_PRINT_OMIT_DESTROYED_MERGED_ARENA**: Omit destroyed merged arena statistics. - **MEMKIND_STAT_PRINT_OMIT_PER_ARENA**: Omit per arena statistics. - **MEMKIND_STAT_PRINT_OMIT_PER_SIZE_CLASS_BINS**: Omit per size class statistics for bins. - **MEMKIND_STAT_PRINT_OMIT_PER_SIZE_CLASS_LARGE**: Omit per size class statistics for large objects. - **MEMKIND_STAT_PRINT_OMIT_MUTEX**: Omit all mutex statistics. - **MEMKIND_STAT_PRINT_OMIT_EXTENT**: Omit extent statistics. ```