Blame examples/README

Packit 345191
# Memkind examples
Packit 345191
Packit 345191
The example directory contains example codes that use the memkind
Packit 345191
interface.
Packit 345191
Packit 345191
## PMEM
Packit 345191
Packit 345191
The pmem_*.c(pp) demonstrates how to create and use a file-backed memory kind.
Packit 345191
The default pmem path is "/tmp/".
Packit 345191
Custom directory is pass as first argument to all of PMEM example programs,
Packit 345191
e.g. to execute pmem_malloc example in /mnt/pmem location, call:
Packit 345191
Packit 345191
    ./pmem_malloc /mnt/pmem/
Packit 345191
Packit 345191
### pmem_kinds.c
Packit 345191
Packit 345191
This example shows how to create and destroy pmem kind with defined or unlimited size.
Packit 345191
Packit 345191
### pmem_malloc.c
Packit 345191
Packit 345191
This example shows how to allocate memory and possibility to exceed pmem kind size.
Packit 345191
Packit 345191
### pmem_malloc_unlimited.c
Packit 345191
Packit 345191
This example shows how to allocate memory with unlimited kind size.
Packit 345191
Packit 345191
### pmem_usable_size.c
Packit 345191
Packit 345191
This example shows difference between the expected and the actual allocation size.
Packit 345191
Packit 345191
### pmem_alignment.c
Packit 345191
Packit 345191
This example shows how to use memkind alignment and how it affects allocations.
Packit 345191
Packit 345191
### pmem_multithreads.c
Packit 345191
Packit 345191
This example shows how to use multithreading with independent pmem kinds.
Packit 345191
Packit 345191
### pmem_multithreads_onekind.c
Packit 345191
Packit 345191
This example shows how to use multithreading with one main pmem kind.
Packit 345191
Packit 345191
### pmem_and_dax_kmem_kind.c
Packit 345191
Packit 345191
This example shows how to allocate to PMEM memory using file-backed memory (pmem kind)
Packit 345191
and persistent memory NUMA node (MEMKIND_DAX_KMEM).
Packit 345191
Packit 345191
### pmem_and_default_kind.c
Packit 345191
Packit 345191
This example shows how to allocate in standard memory and file-backed memory (pmem kind).
Packit 345191
Packit 345191
### pmem_detect_kind.c
Packit 345191
Packit 345191
This example shows how to distinguish allocation from different kinds using detect kind function.
Packit 345191
Packit 345191
### pmem_config.c
Packit 345191
Packit 345191
This example shows how to use custom configuration to create pmem kind.
Packit 345191
Packit 345191
### pmem_free_with_unknown_kind.c
Packit 345191
Packit 345191
This example shows how to allocate in standard memory and file-backed memory (pmem kind)
Packit 345191
and free memory without a need to remember which kind it belongs to.
Packit 345191
Packit 345191
### pmem_cpp_allocator.cpp
Packit 345191
Packit 345191
This example shows usage of C++ allocator mechanism designed for file-backed memory
Packit 345191
kind with different data structures like: vector, list and map.
Packit 345191
Packit 345191
## Other memkind examples
Packit 345191
Packit 345191
### memkind_get_stat.c
Packit 345191
Packit 345191
This example shows how to get information about allocator and kind statistics.
Packit 345191
Packit 345191
### other
Packit 345191
Packit 345191
The simplest example is the hello_example.c which is a hello world
Packit 345191
variant.  The filter_example.c shows how you would use high bandwidth
Packit 345191
memory to store a reduction of a larger data set stored in DDR. There is
Packit 345191
also an example of how to create user defined kinds.  This example
Packit 345191
creates kinds which isolate allocations to a single NUMA node each
Packit 345191
backed by a single arena.
Packit 345191
Packit 345191
### memkind_cpp_allocator.cpp
Packit 345191
Packit 345191
This example shows usage of C++ allocator mechanism designed for static
Packit 345191
kinds with different data structures like: forward list, deque and multiset.
Packit 345191
Packit 345191
The memkind_allocated example is simple usage of memkind in C++11 which
Packit 345191
shows how memkind can be used to allocate objects, and consists of two files:
Packit 345191
memkind_allocated.hpp - which is definition of template class that should be
Packit 345191
inherited and parametrized by derived type (curiously recurring template
Packit 345191
pattern), to let deriving class allocate their objects using specified kind.
Packit 345191
memkind_allocated_example.cpp - which is usage example of this approach.
Packit 345191
Logic of memkind_allocated is based on overriding operator new() in template,
Packit 345191
and allocating memory on kind specified in new() parameter, or by overridable
Packit 345191
static method getClassKind(). This implementation also supports alignment
Packit 345191
specifier's (alignas() - new feature in C++11).
Packit 345191
The downside of this approach is that it will work properly only if
Packit 345191
memkind_allocated template is inherited once in inheritance chain (which
Packit 345191
probably makes that not very useful for most scenarios). Other thing is that it
Packit 345191
overriding class new() operator which can cause various problems if used
Packit 345191
unwisely.