The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:
The memkind library is a user extensible heap manager built on top of jemalloc which enables control of memory characteristics and a partitioning of the heap between kinds of memory. The kinds of memory are defined by operating system memory policies that have been applied to virtual address ranges. Memory characteristics supported by memkind without user extension include control of NUMA and page size features. The jemalloc non-standard interface has been extended to enable specialized arenas to make requests for virtual memory from the operating system through the memkind partition interface. Through the other memkind interfaces the user can control and extend memory partition features and allocate memory while selecting enabled features. Memkind interface allows to create and control file-backed memory (PMEM kind) on specified device.
The memkind library delivers four interfaces: * hbwmalloc.h - recommended for high-bandwidth memory use cases (stable) * memkind.h - generic interface for more complex use cases (stable) * pmemallocator.h - the C++ allocator that satisfies the C++ Allocator requirements used for PMEM memory use cases (stable) * memkindallocator.h - the C++ allocator that satisfies the C++ Allocator requirements used for static kinds (stable)
For more detailed information about those interfaces see corresponding manpages (located in man/ subdir):
You will need to install required packages on the build system:
For using automatic recognition of PMEM NUMA in MEMKINDDAXKMEM:
The memkind library has a dependency on a related fork of jemalloc. The configure scripts and gtest source code are distributed with the source tarball included in the source RPM, and this tarball is created with the memkind "make dist" target. In contrast to the distributed source tarball, the git repository does not include any generated files. For this reason some additional steps are required when building from a checkout of the git repo. Those steps include running the bash script called "autogen.sh" prior to configure. This script will populate a VERSION file based on "git describe", and use autoreconf to generate a configure script.
Building and installing memkind in standard system location can be as simple as typing the following while in the root directory of the source tree:
./autogen.sh ./configure make make install
To install this library into other locations, you can use the prefix variable, e.g.:
./autogen.sh ./configure --prefix=/usr make make install
This will install files to /usr/lib, /usr/include, /usr/share/doc/, usr/share/man.
See the output of:
for more information about either the memkind or the jemalloc configuration options.
The jemalloc source was forked from jemalloc version 5.2.1. This source tree is located within the jemalloc subdirectory of the memkind source. The jemalloc source code has been kept close to the original form, except for the following items: - extend jemalloc API with "arenalookupx" and "check_reallocatex" functions - optimization for searching commands in mallctl - the build system has been lightly modified.
You will need to install required packages for applications, which are using the memkind library for dynamic linking at run time:
| Memory kind | NUMA | HBW Memory | Hugepages | Device DAX | Filesystem supporting hole punching | | ----------------------------- |:-----:|:-----------:|:---------:|:----------:|:-----------------------------------:| | MEMKINDDEFAULT | | | | | | | MEMKINDHUGETLB | X | | X | | | | MEMKINDHBW | X | X | | | | | MEMKINDHBWALL | X | X | | | | | MEMKINDHBWHUGETLB | X | X | X | | | | MEMKINDHBWALLHUGETLB | X | X | X | | | | MEMKINDHBWPREFERRED | X | X | | | | | MEMKINDHBWPREFERREDHUGETLB | X | X | X | | | | MEMKINDHBWINTERLEAVE | X | X | | | | | MEMKINDREGULAR | X | | | | | | MEMKINDDAXKMEM | X | | | X | | | MEMKINDDAXKMEMALL | X | | | X | | | MEMKINDDAXKMEMPREFERRED | X | | | X | | | PMEM kind | | | | | X |
To correctly control of NUMA, huge pages and file-backed memory following requirements regarding Linux kernel must be satisfied:
Requires kernel patch introduced in Linux v3.11 that impacts functionality of the NUMA system calls. Red Hat has back-ported this patch to the v3.10 kernel in the RHEL 7.0 GA release, so RHEL 7.0 onward supports memkind even though this kernel version predates v3.11.
To use the interfaces for obtaining 2MB pages please be sure to follow the instructions here and pay particular attention to the use of the procfs files:
for enabling the kernel's huge page pool.
To use the PMEM kind, please be sure that filesystem which is used for PMEM creation supports FALLOCFLPUNCH_HOLE flag.
and created DAX device. See article for details.
Memkind supports using persistent memory as an extension of DRAM. This volatile memory solution is provided by the library with two separate ways described below.
NVDIMM memory as DAX device is supported by MEMKINDDAXKMEM_* kinds. With this solution persistent memory will be seen in OS as separate NUMA nodes.
Memkind allows two ways to use this kind:
PMEM kind supports the traditional malloc/free interfaces on a memory mapped file. This allows the use of persistent memory as volatile memory, for cases where the region of persistent memory is useful to an application, but when the application doesn't need it to be persistent. PMEM kind is most useful when used with Direct Access storage DAX, which is memory-addressable persistent storage that supports load/store access without being paged via the system page cache.
Application using memkind library supports managing a data placement:
| Data placement | Memory kind | |----------------|---------------------------| | PMEM (fsdax) | PMEM kind | | PMEM (devdax) | MEMKINDDAXKMEM kind | | DRAM | e.g. MEMKIND_DEFAULT kind |
Currently, the PMEM kind is supported only by the jemalloc heap manager.
One of the notable features of the memkind is to detect the correct kind of previously allocated memory.
| Operations | Memkind API function | |---------------------------------------------|----------------------------------------| | Freeing memory | memkindfree(kind, ptr) | | Reallocating memory | memkindrealloc(kind, ptr, size) | | Obtaining the size of allocated memory | memkindmallocusablesize(kind, ptr) | | Reallocating memory to reduce fragmentation | memkinddefrag_reallocate(kind, ptr) |
Operations above could be unified for all used memory kinds by passing a NULL value as a kind to the functions mentioned above.
For more details, please see the following example.
Important Notes: The look up for correct kind could result in serious performance penalty, which can be avoided by specifying a correct kind explicitly.
In memkind library logging mechanism could be enabled by setting MEMKINDDEBUG environment variable. Setting MEMKINDDEBUG to "1" enables printing messages like errors and general information about environment to stderr.
In memkind library heap management can be adjusted with MEMKINDHEAPMANAGER environment variable, which allows for switching to one of the available heap managers. Values: - JEMALLOC - sets the jemalloc heap manager - TBB - sets Intel Threading Building Blocks heap manager. This option requires installed Intel Threading Building Blocks library.
If the MEMKINDHEAPMANAGER is not set then the jemalloc heap manager will be used by default.
A method for testing for the benefit of high bandwidth memory on a dual socket Intel(R) Xeon(TM) system is to use the QPI bus to simulate slow memory. This is not an accurate model of the bandwidth and latency characteristics of the Intel's 2nd generation Intel(R) Xeon Phi(TM) Product Family on package memory, but is a reasonable way to determine which data structures rely critically on bandwidth.
If the application a.out has been modified to use high bandwidth memory with the memkind library then this can be done with numactl as follows with the bash shell:
export MEMKIND_HBW_NODES=0 numactl --membind=1 --cpunodebind=0 a.out
or with csh:
setenv MEMKIND_HBW_NODES 0 numactl --membind=1 --cpunodebind=0 a.out
The MEMKINDHBWNODES environment variable set to zero will bind high bandwidth allocations to NUMA node 0. The --membind=1 flag to numactl will bind standard allocations, static and stack variables to NUMA node 1. The --cpunodebind=0 option to numactl will bind the process threads to CPUs associated with NUMA node 0. With this configuration standard allocations will be fetched across the QPI bus, and high bandwidth allocations will be local to the process CPU.
The following software use memkind library:
All existing tests pass. For more information on how to execute tests see the CONTRIBUTING file.
When tests are run on a NUMA platform without high bandwidth memory the MEMKINDHBWNODES environment variable is used in conjunction with "numactl --membind" to force standard allocations to one NUMA node and high bandwidth allocations through a different NUMA node. See next section for more details.
SEE COPYING FILE FOR LICENSE INFORMATION.
THIS SOFTWARE IS PROVIDED AS A DEVELOPMENT SNAPSHOT TO AID COLLABORATION AND WAS NOT ISSUED AS A RELEASED PRODUCT BY INTEL.