168
Listing 10-9. An example of a custom configuration and memory policy use
73 struct memkind_config *test_cfg =
74
memkind_config_new();
75 if (test_cfg == NULL) {
76
fprintf(stderr,
77
"memkind_config_new: out of memory\n");
78
exit(1);
79 }
80
81 memkind_config_set_path(test_cfg, path);
82 memkind_config_set_size(test_cfg, PMEM_MAX_SIZE);
83 memkind_config_set_memory_usage_policy(test_cfg,
84
MEMKIND_MEM_USAGE_POLICY_CONSERVATIVE);
85
86 // Create PMEM partition with the configuration
87 err = memkind_create_pmem_with_config(test_cfg,
88
&pmem_kind);
89 if (err) {
90
memkind_fatal(err);
91 }
Additional memkind Code Examples
The memkind source tree contains many additional code examples, available on GitHub
at https://github.com/memkind/memkind/tree/master/examples.
C++ Allocator for PMEM Kind
A new pmem::allocator class template is created to support allocations from persistent
memory, which conforms to C++11 allocator requirements. It can be used with C++
compliant data structures from:
• Standard Template Library (STL)
• Intel
®
Threading Building Blocks (Intel
®
TBB) library
Chapter 10 Volatile Use of persistent MeMory
Listing 10-9. An example of a custom configuration and memory policy use
73 struct memkind_config *test_cfg =
74
memkind_config_new();
75 if (test_cfg == NULL) {
76
fprintf(stderr,
77
"memkind_config_new: out of memory\n");
78
exit(1);
79 }
80
81 memkind_config_set_path(test_cfg, path);
82 memkind_config_set_size(test_cfg, PMEM_MAX_SIZE);
83 memkind_config_set_memory_usage_policy(test_cfg,
84
MEMKIND_MEM_USAGE_POLICY_CONSERVATIVE);
85
86 // Create PMEM partition with the configuration
87 err = memkind_create_pmem_with_config(test_cfg,
88
&pmem_kind);
89 if (err) {
90
memkind_fatal(err);
91 }
Additional memkind Code Examples
The memkind source tree contains many additional code examples, available on GitHub
at https://github.com/memkind/memkind/tree/master/examples.
C++ Allocator for PMEM Kind
A new pmem::allocator class template is created to support allocations from persistent
memory, which conforms to C++11 allocator requirements. It can be used with C++
compliant data structures from:
• Standard Template Library (STL)
• Intel
®
Threading Building Blocks (Intel
®
TBB) library
Chapter 10 Volatile Use of persistent MeMory
