1MEMKINDALLOCATOR(3) MEMKINDALLOCATOR MEMKINDALLOCATOR(3)
2
3
4
6 libmemkind::static_kind::allocator<T> - The C++ allocator compatible
7 with the C++ standard library allocator concepts
8 Note: memkind_allocator.h functionality is considered as stable API
9 (STANDARD API).
10
12 #include <memkind_allocator.h>
13
14 Link with -lmemkind
15
16 libmemkind::static_kind::allocator(libmemkind::kinds kind);
17 template <typename U> libmemkind::static_kind::allocator<T>::allocator(const libmemkind::static_kind::allocator<U>&) noexcept;
18 template <typename U> libmemkind::static_kind::allocator(const allocator<U>&& other) noexcept;
19 libmemkind::static_kind::allocator<T>::~allocator();
20 T *libmemkind::static_kind::allocator<T>::allocate(std::size_t n) const;
21 void libmemkind::static_kind::allocator<T>::deallocate(T *p, std::size_t n) const;
22 template <class U, class... Args> void libmemkind::static_kind::allocator<T>::construct(U *p, Args... args) const;
23 void libmemkind::static_kind::allocator<T>::destroy(T *p) const;
24
26 The libmemkind::static_kind::allocator<T> is intended to be used with
27 STL containers to allocate from static kinds memory. Memory management
28 is based on memkind library. Refer memkind(3) man page for more
29 details.
30
31 The libmemkind::kinds specifies allocator static kinds of memory, rep‐
32 resenting type of memory which offers different characteristics. The
33 available types of allocator kinds of memory:
34
35 libmemkind::kinds::DEFAULT Default allocation using standard memory and
36 default page size.
37
38 libmemkind::kinds::HUGETLB Allocate from standard memory using huge
39 pages. Note: This kind requires huge pages configuration described in
40 SYSTEM CONFIGURATION section.
41
42 libmemkind::kinds::INTERLEAVE Allocate pages interleaved across all
43 NUMA nodes with transparent huge pages disabled.
44
45 libmemkind::kinds::HBW Allocate from the closest high bandwidth memory
46 NUMA node at the time of allocation. If there is not enough high band‐
47 width memory to satisfy the request, errno is set to ENOMEM and the
48 allocated pointer is set to NULL.
49
50 libmemkind::kinds::HBW_ALL Same as libmemkind::kinds::HBW except deci‐
51 sion regarding closest NUMA node is postponed until the time of first
52 write.
53
54 libmemkind::kinds::HBW_HUGETLB Same as libmemkind::kinds::HBW except
55 the allocation is backed by huge pages. Note: This kind requires huge
56 pages configuration described in SYSTEM CONFIGURATION section.
57
58 libmemkind::kinds::HBW_ALL_HUGETLB Combination of lib‐
59 memkind::kinds::HBW_ALL and libmemkind::kinds::HBW_HUGETLB properties.
60 Note: This kind requires huge pages configuration described in SYSTEM
61 CONFIGURATION section.
62
63 libmemkind::kinds::HBW_PREFERRED Same as libmemkind::kinds::HBW except
64 that if there is not enough high bandwidth memory to satisfy the
65 request, the allocation will fall back on standard memory.
66
67 libmemkind::kinds::HBW_PREFERRED_HUGETLB Same as lib‐
68 memkind::kinds::HBW_PREFERRED except the allocation is backed by huge
69 pages. Note: This kind requires huge pages configuration described in
70 SYSTEM CONFIGURATION section.
71
72 libmemkind::kinds::HBW_INTERLEAVE Same as libmemkind::kinds::HBW except
73 that the pages that support the allocation are interleaved across all
74 high bandwidth nodes and transparent huge pages are disabled.
75
76 libmemkind::kinds::REGULAR Allocate from regular memory using the
77 default page size. Regular means general purpose memory from the NUMA
78 nodes containing CPUs.
79
80 libmemkind::kinds::DAX_KMEM Allocate from the closest persistent memory
81 NUMA node at the time of allocation. If there is not enough memory in
82 the closest persistent memory NUMA node to satisfy the request, errno
83 is set to ENOMEM and the allocated pointer is set to NULL.
84
85 libmemkind::kinds::DAX_KMEM_ALL Allocate from the closest persistent
86 memory NUMA node available at the time of allocation. If there is not
87 enough memory on any of persistent memory NUMA nodes to satisfy the
88 request, errno is set to ENOMEM and the allocated pointer is set to
89 NULL.
90
91 libmemkind::kinds::DAX_KMEM_PREFERRED Same as lib‐
92 memkind::kinds::DAX_KMEM except that if there is not enough memory in
93 the closest persistent memory NUMA node to satisfy the request, the
94 allocation will fall back on other memory NUMA nodes. Note: For this
95 kind, the allocation will not succeed if two or more persistent memory
96 NUMA nodes are in the same shortest distance to the same CPU on which
97 process is eligible to run. Check on that eligibility is done upon
98 starting the application.
99
100 All public member types and functions correspond to standard library
101 allocator concepts and definitions. The current implementation supports
102 C++11 standard.
103
104 Template arguments:
105 T is an object type aliased by value_type.
106 U is an object type.
107
108 Note:
109 T *libmemkind::static_kind::allocator<T>::allocate(std::size_t n) allo‐
110 cates memory using memkind_malloc(). Throw std::bad_alloc when:
111 n = 0
112 or there is not enough memory to satisfy the request.
113
114 libmemkind::static_kind::allocator<T>::deallocate(T *p, std::size_t n)
115 deallocates memory associated with pointer returned by allocate() using
116 memkind_free().
117
119 Interfaces for obtaining 2MB (HUGETLB) memory need allocated huge pages
120 in the kernel's huge page pool.
121
122 HUGETLB (huge pages)
123 Current number of "persistent" huge pages can be read from
124 /proc/sys/vm/nr_hugepages file. Proposed way of setting
125 hugepages is: sudo sysctl vm.nr_hugepages=<number_of_hugepages>.
126 More information can be found here:
127 ⟨https://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt⟩
128
130 Copyright (C) 2019 Intel Corporation. All rights reserved.
131
133 memkind(3)
134
135
136
137Intel Corporation 2019-09-24 MEMKINDALLOCATOR(3)