Blame README.md

Packit 95bb47
# **PMDK: Persistent Memory Development Kit**
Packit 95bb47
Packit 95bb47
[![Build Status](https://travis-ci.org/pmem/pmdk.svg?branch=master)](https://travis-ci.org/pmem/pmdk)
Packit 95bb47
[![Build status](https://ci.appveyor.com/api/projects/status/u2l1db7ucl5ktq10/branch/master?svg=true&pr=false)](https://ci.appveyor.com/project/pmem/pmdk/branch/master)
Packit 95bb47
[![Coverity Scan Build Status](https://img.shields.io/coverity/scan/3015.svg)](https://scan.coverity.com/projects/pmem-pmdk)
Packit 95bb47
[![PMDK release version](https://img.shields.io/github/release/pmem/pmdk.svg)](https://github.com/pmem/pmdk/releases/latest)
Packit 95bb47
[![Coverage Status](https://codecov.io/github/pmem/pmdk/coverage.svg?branch=master)](https://codecov.io/gh/pmem/pmdk/branch/master)
Packit 95bb47
Packit 95bb47
The **Persistent Memory Development Kit (PMDK)** is a collection of libraries and tools for System Administrators and Application Developers to simplify managing and accessing persistent memory devices. For more information, see http://pmem.io.
Packit 95bb47
Packit 95bb47
To install PMDK libraries, either install pre-built packages, which we build for every stable release, or clone the tree and build it yourself. **Pre-built** packages can be found in popular Linux distribution package repositories, or you can check out our recent stable releases on our [github release page](https://github.com/pmem/pmdk/releases). Specific installation instructions are outlined below.
Packit 95bb47
Packit 95bb47
Bugs and feature requests for this repo are tracked in our [GitHub Issues Database](https://github.com/pmem/issues/issues).
Packit 95bb47
Packit 95bb47
## Contents
Packit 95bb47
1. [Libraries and Utilities](#libraries-and-utilities)
Packit 95bb47
2. [Getting Started](#getting-started)
Packit 95bb47
3. [Version Conventions](#version-conventions)
Packit 95bb47
4. [Pre-Built Packages for Windows](#pre-built-packages-for-windows)
Packit 95bb47
5. [Dependencies](#dependencies)
Packit 95bb47
	* [Linux](#linux)
Packit 95bb47
	* [Windows](#windows)
Packit 95bb47
	* [FreeBSD](#freebsd)
Packit 95bb47
6. [Building PMDK on Linux or FreeBSD](#building-pmdk-on-linux-or-freebsd)
Packit 95bb47
	* [Make Options](#make-options)
Packit 95bb47
	* [Testing Libraries](#testing-libraries-on-linux-and-freebsd)
Packit 95bb47
	* [Memory Management Tools](#memory-management-tools)
Packit 95bb47
7. [Building PMDK on Windows](#building-pmdk-on-windows)
Packit 95bb47
	* [Testing Libraries](#testing-libraries-on-windows)
Packit 95bb47
8. [Experimental Packages](#experimental-packages)
Packit 95bb47
	* [librpmem and rpmemd packages](#the-librpmem-and-rpmemd-packages)
Packit 95bb47
	* [Experimental support for 64-bit ARM](#experimental-support-for-64-bit-arm)
Packit 95bb47
9. [Contact Us](#contact-us)
Packit 95bb47
Packit 95bb47
## Libraries and Utilities
Packit 95bb47
Available Libraries:
Packit 95bb47
- [​libpmem](http://pmem.io/pmdk/libpmem/):  provides low level persistent memory support
Packit 95bb47
Packit 95bb47
- [​libpmemobj](http://pmem.io/pmdk/libpmemobj/):  provides a transactional object store, providing memory allocation, transactions, and general facilities for persistent memory programming.
Packit 95bb47
Packit 95bb47
- [​libpmemblk](http://pmem.io/pmdk/libpmemblk/):  supports arrays of pmem-resident blocks, all the same size, that are atomically updated.
Packit 95bb47
Packit 95bb47
- [​libpmemlog](http://pmem.io/pmdk/libpmemlog/):  provides a pmem-resident log file.
Packit 95bb47
Packit 95bb47
- [​libvmem](http://pmem.io/pmdk/libvmem/):  turns a pool of persistent memory into a volatile memory pool, similar to the system heap but kept separate and with its own malloc-style API.
Packit 95bb47
Packit 95bb47
- [​libvmmalloc](http://pmem.io/pmdk/libvmmalloc/)<sup>1</sup>:  transparently converts all the dynamic memory allocations into persistent memory allocations.
Packit 95bb47
Packit 95bb47
- [libpmempool](http://pmem.io/pmdk/libpmempool/):  provides support for off-line pool management and diagnostics.
Packit 95bb47
Packit 95bb47
- [​librpmem](http://pmem.io/pmdk/librpmem/)<sup>1</sup>:  provides low-level support for remote access to persistent memory utilizing RDMA-capable RNICs.
Packit 95bb47
Packit 95bb47
Available Utilities:
Packit 95bb47
Packit 95bb47
- [​pmempool](http://pmem.io/pmdk/pmempool/): Manage and analyze persistent memory pools with this stand-alone utility
Packit 95bb47
Packit 95bb47
- [​pmemcheck](http://pmem.io/2015/07/17/pmemcheck-basic.html): Use dynamic runtime analysis with an enhanced version of Valgrind for use with persistent memory.
Packit 95bb47
Packit 95bb47
Currently these libraries only work on 64-bit Linux, Windows<sup>2</sup>, and 64-bit FreeBSD 11+<sup>3</sup>.
Packit 95bb47
For information on how these libraries are licensed, see our [LICENSE](LICENSE) file.
Packit 95bb47
Packit 95bb47
><sup>1</sup> Not supported on Windows.
Packit 95bb47
>
Packit 95bb47
><sup>2</sup> PMDK for Windows is feature complete, but not yet considered production quality.
Packit 95bb47
>
Packit 95bb47
><sup>3</sup> DAX and **libfabric** are not yet supported in FreeBSD, so at this time PMDK is available as a technical preview release for development purposes.
Packit 95bb47
Packit 95bb47
## Getting Started
Packit 95bb47
Packit 95bb47
Getting Started with Persistent Memory Programming is a tutorial series created by Intel Architect, Andy Rudoff. In this tutorial, you will be introduced to persistent memory programming and learn how to apply it to your applications.
Packit 95bb47
- Part 1: [What is Persistent Memory?](https://software.intel.com/en-us/persistent-memory/get-started/series)
Packit 95bb47
- Part 2: [Describing The SNIA Programming Model](https://software.intel.com/en-us/videos/the-nvm-programming-model-persistent-memory-programming-series)
Packit 95bb47
- Part 3: [Introduction to PMDK Libraries](https://software.intel.com/en-us/videos/intro-to-the-nvm-libraries-persistent-memory-programming-series)
Packit 95bb47
- Part 4: [Thinking Transactionally](https://software.intel.com/en-us/videos/thinking-transactionally-persistent-memory-programming-series)
Packit 95bb47
- Part 5: [A C++ Example](https://software.intel.com/en-us/videos/a-c-example-persistent-memory-programming-series)
Packit 95bb47
Packit 95bb47
Packit 95bb47
Additionally, we recommend reading [Introduction to Programming with Persistent Memory from Intel](https://software.intel.com/en-us/articles/introduction-to-programming-with-persistent-memory-from-intel)
Packit 95bb47
Packit 95bb47
Packit 95bb47
## Version Conventions
Packit 95bb47
Packit 95bb47
- **Builds** are tagged something like `0.2+b1`, which means _Build 1 on top of version 0.2_
Packit 95bb47
- **Release Candidates** have a '-rc{version}' tag, e.g. `0.2-rc3, meaning _Release Candidate 3 for version 0.2_
Packit 95bb47
- **Stable Releases** use a _major.minor_ tag like `0.2`
Packit 95bb47
Packit 95bb47
## Pre-Built Packages for Windows
Packit 95bb47
Packit 95bb47
The recommended and easiest way to install PMDK on Windows is to use Microsoft vcpkg. Vcpkg is an open source tool and ecosystem created for library management.
Packit 95bb47
Packit 95bb47
To install the latest PMDK release and link it to your Visual Studio solution you first need to clone and set up vcpkg on your machine as described on the [vcpkg github page](https://github.com/Microsoft/vcpkg) in **Quick Start** section.
Packit 95bb47
Packit 95bb47
In brief:
Packit 95bb47
Packit 95bb47
```
Packit 95bb47
	> git clone https://github.com/Microsoft/vcpkg
Packit 95bb47
	> cd vcpkg
Packit 95bb47
	> .\bootstrap-vcpkg.bat
Packit 95bb47
	> .\vcpkg integrate install
Packit 95bb47
	> .\vcpkg install pmdk:x64-windows
Packit 95bb47
```
Packit 95bb47
Packit 95bb47
The last command can take a while - it is PMDK building and installation time.
Packit 95bb47
Packit 95bb47
After a successful completion of all of the above steps, the libraries are ready
Packit 95bb47
to be used in Visual Studio and no additional configuration is required.
Packit 95bb47
Just open VS with your already existing project or create a new one
Packit 95bb47
(remember to use platform **x64**) and then include headers to project as you always do.
Packit 95bb47
Packit 95bb47
## Dependencies
Packit 95bb47
Packit 95bb47
Required packages for each supported OS are listed below. It is important to note that some tests and example applications require additional packages, but they do not interrupt building if they are missing. An appropriate message is displayed instead. For details please read the DEPENDENCIES section in the appropriate README file.
Packit 95bb47
Packit 95bb47
See our **[Dockerfiles](utils/docker/images)**
Packit 95bb47
to get an idea what packages are required to build the entire PMDK,
Packit 95bb47
with all the tests and examples on the _Travis-CI_ system.
Packit 95bb47
Packit 95bb47
### Linux
Packit 95bb47
Packit 95bb47
You will need to install the following required packages on the build system:
Packit 95bb47
Packit 95bb47
* **autoconf**
Packit 95bb47
* **pkg-config**
Packit 95bb47
* **libndctl-devel** (v60.1 or later)
Packit 95bb47
* **libdaxctl-devel** (v60.1 or later)
Packit 95bb47
* **ndctl** (v60.1 or later)
Packit 95bb47
Packit 95bb47
The following packages are required only by selected PMDK components
Packit 95bb47
or features:
Packit 95bb47
Packit 95bb47
* **libfabric** (v1.4.2 or later) -- required by **librpmem**
Packit 95bb47
Packit 95bb47
### Windows
Packit 95bb47
Packit 95bb47
* **MS Visual Studio 2015**
Packit 95bb47
* [Windows SDK 10.0.16299.15](https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk)
Packit 95bb47
* **perl** (i.e. [ActivePerl](http://www.activestate.com/activeperl/downloads))
Packit 95bb47
* **PowerShell 5**
Packit 95bb47
Packit 95bb47
### FreeBSD
Packit 95bb47
Packit 95bb47
* **autoconf**
Packit 95bb47
* **bash**
Packit 95bb47
* **binutils**
Packit 95bb47
* **coreutils**
Packit 95bb47
* **e2fsprogs-libuuid**
Packit 95bb47
* **gmake**
Packit 95bb47
* **libunwind**
Packit 95bb47
* **ncurses**<sup>4</sup>
Packit 95bb47
* **pkgconf**
Packit 95bb47
Packit 95bb47
><sup>4</sup> The pkg version of ncurses is required for proper operation; the base version included in FreeBSD is not sufficient.
Packit 95bb47
Packit 95bb47
Packit 95bb47
## Building PMDK on Linux or FreeBSD
Packit 95bb47
Packit 95bb47
To build from source, clone this tree:
Packit 95bb47
```
Packit 95bb47
	$ git clone https://github.com/pmem/pmdk
Packit 95bb47
	$ cd pmdk
Packit 95bb47
```
Packit 95bb47
Packit 95bb47
For a stable version, checkout a [release tag](https://github.com/pmem/pmdk/releases) as follows. Otherwise skip this step to build the latest development release.
Packit 95bb47
```
Packit 95bb47
	$ git checkout tags/1.4.2
Packit 95bb47
```
Packit 95bb47
Packit 95bb47
Once the build system is setup, the Persistent Memory Development Kit is built using the `make` command at the top level:
Packit 95bb47
```
Packit 95bb47
	$ make
Packit 95bb47
```
Packit 95bb47
For FreeBSD, use `gmake` rather than `make`.
Packit 95bb47
Packit 95bb47
By default, all code is built with the `-Werror` flag, which fails
Packit 95bb47
the whole build when the compiler emits any warning. This is very useful during
Packit 95bb47
development, but can be annoying in deployment. If you want to **disable -Werror**,
Packit 95bb47
use the EXTRA_CFLAGS variable:
Packit 95bb47
```
Packit 95bb47
	$ make EXTRA_CFLAGS="-Wno-error"
Packit 95bb47
```
Packit 95bb47
>or
Packit 95bb47
```
Packit 95bb47
	$ make EXTRA_CFLAGS="-Wno-error=$(type-of-warning)"
Packit 95bb47
```
Packit 95bb47
Packit 95bb47
### Make Options
Packit 95bb47
Packit 95bb47
There are many options that follow `make`. If you want to invoke make with the same variables multiple times, you can create a user.mk file in the top level directory and put all variables there.
Packit 95bb47
For example:
Packit 95bb47
```
Packit 95bb47
	$ cat user.mk
Packit 95bb47
	EXTRA_CFLAGS_RELEASE = -ggdb -fno-omit-frame-pointer
Packit 95bb47
	PATH += :$HOME/valgrind/bin
Packit 95bb47
```
Packit 95bb47
This feature is intended to be used only by developers and it may not work for all variables. Please do not file bug reports about it. Just fix it and make a PR.
Packit 95bb47
Packit 95bb47
**Built-in tests:** can be compiled and ran with different compiler. To do this, you must provide the `CC` and `CXX` variables. These variables are independent and setting `CC=clang` does not set `CXX=clang++`.
Packit 95bb47
For example:
Packit 95bb47
```
Packit 95bb47
	$ make CC=clang CXX=clang++
Packit 95bb47
```
Packit 95bb47
Once make completes, all the libraries and examples are built. You can play with the library within the build tree, or install it locally on your machine. For information about running different types of tests, please refer to the [src/test/README](src/test/README).
Packit 95bb47
Packit 95bb47
Packit 95bb47
**Installing the library** is convenient since it installs man pages and libraries in the standard system locations:
Packit 95bb47
```
Packit 95bb47
	(as root...)
Packit 95bb47
	# make install
Packit 95bb47
```
Packit 95bb47
Packit 95bb47
To install this library into **other locations**, you can use the `prefix` variable, e.g.:
Packit 95bb47
```
Packit 95bb47
	$ make install prefix=/usr/local
Packit 95bb47
```
Packit 95bb47
This will install files to /usr/local/lib, /usr/local/include /usr/local/share/man.
Packit 95bb47
Packit 95bb47
**Prepare library for packaging** can be done using the DESTDIR variable, e.g.:
Packit 95bb47
```
Packit 95bb47
	$ make install DESTDIR=/tmp
Packit 95bb47
```
Packit 95bb47
This will install files to /tmp/usr/lib, /tmp/usr/include /tmp/usr/share/man.
Packit 95bb47
Packit 95bb47
**Man pages** (groff files) are generated as part of the `install` rule. To generate the documentation separately, run:
Packit 95bb47
```
Packit 95bb47
	$ make doc
Packit 95bb47
```
Packit 95bb47
This call requires the following dependencies: **pandoc**. Pandoc is provided by the hs-pandoc package on FreeBSD.
Packit 95bb47
Packit 95bb47
Packit 95bb47
**Install copy of source tree** can be done by specifying the path where you want it installed.
Packit 95bb47
```
Packit 95bb47
	$ make source DESTDIR=some_path
Packit 95bb47
```
Packit 95bb47
For this example, it will be installed at $(DESTDIR)/pmdk.
Packit 95bb47
Packit 95bb47
**Build rpm packages** on rpm-based distributions is done by:
Packit 95bb47
```
Packit 95bb47
	$ make rpm
Packit 95bb47
```
Packit 95bb47
Packit 95bb47
To build rpm packages without running tests:
Packit 95bb47
```
Packit 95bb47
	$ make BUILD_PACKAGE_CHECK=n rpm
Packit 95bb47
```
Packit 95bb47
This requires **rpmbuild** to be installed.
Packit 95bb47
Packit 95bb47
Packit 95bb47
**Build dpkg packages** on Debian-based distributions is done by:
Packit 95bb47
```
Packit 95bb47
	$ make dpkg
Packit 95bb47
```
Packit 95bb47
Packit 95bb47
To build dpkg packages without running tests:
Packit 95bb47
```
Packit 95bb47
	$ make BUILD_PACKAGE_CHECK=n dpkg
Packit 95bb47
```
Packit 95bb47
This requires **devscripts** to be installed.
Packit 95bb47
Packit 95bb47
### Testing Libraries on Linux and FreeBSD
Packit 95bb47
Packit 95bb47
Before running the tests, you may need to prepare a test configuration file (src/test/testconfig.sh). Please see the available configuration settings in the example file [src/test/testconfig.sh.example](src/test/testconfig.sh.example).
Packit 95bb47
Packit 95bb47
To build and run the **unit tests**:
Packit 95bb47
```
Packit 95bb47
	$ make check
Packit 95bb47
```
Packit 95bb47
Packit 95bb47
To run a specific **subset of tests**, run for example:
Packit 95bb47
```
Packit 95bb47
	$ make check TEST_TYPE=short TEST_BUILD=debug TEST_FS=pmem
Packit 95bb47
```
Packit 95bb47
Packit 95bb47
To **modify the timeout** which is available for **check** type tests, run:
Packit 95bb47
```
Packit 95bb47
	$ make check TEST_TIME=1m
Packit 95bb47
```
Packit 95bb47
This will set the timeout to 1 minute.
Packit 95bb47
Packit 95bb47
Please refer to the **src/test/README** for more details on how to
Packit 95bb47
run different types of tests.
Packit 95bb47
Packit 95bb47
### Memory Management Tools
Packit 95bb47
Packit 95bb47
The PMDK libraries support standard Valgrind DRD, Helgrind and Memcheck, as well as a PM-aware version of [Valgrind](https://github.com/pmem/valgrind) (not yet available for FreeBSD). By default, support for all tools is enabled. If you wish to disable it, supply the compiler with **VG_\<TOOL\>_ENABLED** flag set to 0, for example:
Packit 95bb47
```
Packit 95bb47
	$ make EXTRA_CFLAGS=-DVG_MEMCHECK_ENABLED=0
Packit 95bb47
```
Packit 95bb47
Packit 95bb47
**VALGRIND_ENABLED** flag, when set to 0, disables all Valgrind tools
Packit 95bb47
(drd, helgrind, memcheck and pmemcheck).
Packit 95bb47
Packit 95bb47
The **SANITIZE** flag allows the libraries to be tested with various
Packit 95bb47
sanitizers. For example, to test the libraries with AddressSanitizer
Packit 95bb47
and UndefinedBehaviorSanitizer, run:
Packit 95bb47
```
Packit 95bb47
	$ make SANITIZE=address,undefined clobber check
Packit 95bb47
```
Packit 95bb47
Packit 95bb47
The address sanitizer is not supported for libvmmalloc on FreeBSD and will be ignored.
Packit 95bb47
Packit 95bb47
## Building PMDK on Windows
Packit 95bb47
Packit 95bb47
Clone the PMDK tree and open the solution:
Packit 95bb47
```
Packit 95bb47
	> git clone https://github.com/pmem/pmdk
Packit 95bb47
	> cd pmdk/src
Packit 95bb47
	> devenv PMDK.sln
Packit 95bb47
```
Packit 95bb47
Packit 95bb47
Select the desired configuration (Debug or Release) and build the solution
Packit 95bb47
(i.e. by pressing Ctrl-Shift-B).
Packit 95bb47
Packit 95bb47
### Testing Libraries on Windows
Packit 95bb47
Packit 95bb47
Before running the tests, you may need to prepare a test configuration file (src/test/testconfig.ps1). Please see the available configuration settings in the example file [src/test/testconfig.ps1.example](src/test/testconfig.ps1.example).
Packit 95bb47
Packit 95bb47
To **run the unit tests**, open the PowerShell console and type:
Packit 95bb47
```
Packit 95bb47
	> cd pmdk/src/test
Packit 95bb47
	> RUNTESTS.ps1
Packit 95bb47
```
Packit 95bb47
Packit 95bb47
To run a specific **subset of tests**, run for example:
Packit 95bb47
```
Packit 95bb47
	> RUNTESTS.ps1 -b debug -t short
Packit 95bb47
```
Packit 95bb47
Packit 95bb47
To run **just one test**, run for example:
Packit 95bb47
```
Packit 95bb47
	> RUNTESTS.ps1 -b debug -i pmem_is_pmem
Packit 95bb47
```
Packit 95bb47
Packit 95bb47
To **modify the timeout**, run:
Packit 95bb47
```
Packit 95bb47
	> RUNTESTS.ps1 -o 3m
Packit 95bb47
```
Packit 95bb47
This will set the timeout to 3 minutes.
Packit 95bb47
Packit 95bb47
To **display all the possible options**, run:
Packit 95bb47
```
Packit 95bb47
	> RUNTESTS.ps1 -h
Packit 95bb47
```
Packit 95bb47
Packit 95bb47
Please refer to the **[src/test/README](src/test/README)** for more details on how to run different types of tests.
Packit 95bb47
Packit 95bb47
## Experimental Packages
Packit 95bb47
Packit 95bb47
Some components in the source tree are treated as experimental. By default,
Packit 95bb47
those components are built but not installed (and thus not included in
Packit 95bb47
packages).
Packit 95bb47
Packit 95bb47
If you want to build/install experimental packages run:
Packit 95bb47
```
Packit 95bb47
	$ make EXPERIMENTAL=y [install,rpm,dpkg]
Packit 95bb47
```
Packit 95bb47
Packit 95bb47
### The librpmem and rpmemd packages
Packit 95bb47
Packit 95bb47
**NOTE:**
Packit 95bb47
The **libfabric** package required to build the **librpmem** and **rpmemd** is
Packit 95bb47
not yet available on stable Debian-based distributions. This makes it
Packit 95bb47
impossible to create Debian packages.
Packit 95bb47
Packit 95bb47
If you want to build Debian packages of **librpmem** and **rpmemd** run:
Packit 95bb47
```
Packit 95bb47
	$ make RPMEM_DPKG=y dpkg
Packit 95bb47
```
Packit 95bb47
Packit 95bb47
### Experimental Support for 64-bit ARM
Packit 95bb47
Packit 95bb47
There is an initial support for 64-bit ARM processors provided,
Packit 95bb47
currently only for aarch64.  All the PMDK libraries except **librpmem**
Packit 95bb47
can be built for 64-bit ARM.  The examples, tools and benchmarks
Packit 95bb47
are not ported yet and may not get built on ARM cores.
Packit 95bb47
Packit 95bb47
**NOTE:**
Packit 95bb47
The support for ARM processors is highly experimental. The libraries
Packit 95bb47
are only validated to "early access" quality with Cortex-A53 processor.
Packit 95bb47
Packit 95bb47
## Contact Us
Packit 95bb47
Packit 95bb47
For more information on this library, contact
Packit 95bb47
Marcin Slusarz (marcin.slusarz@intel.com),
Packit 95bb47
Andy Rudoff (andy.rudoff@intel.com), or post to our
Packit 95bb47
[Google group](http://groups.google.com/group/pmem).