Skip to content

Commit 875d433

Browse files
committed
Add memkind hmat 'I' example templates
1 parent 1065944 commit 875d433

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

templates/examples/I/body.tmpl

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{{top "Allocation tiering based on memory-characteristics"}}
2+
3+
<p class="intro">
4+
Different memory types can have different performance characteristics. They
5+
can be distinguished by values of their latency, capacity or bandwidth.
6+
In programming with allocation tiering in mind we care about the performance
7+
characteristics of memory, not the exact media types.
8+
<p class="intro">
9+
In this example, an array of data and a hashmap are allocated to different
10+
memory types to effectively use the available memory.
11+
12+
{{template "scrollToContinue"}}
13+
14+
<p>
15+
When utilising a server with high capacity memory alongside standard memory,
16+
allocating memory randomly in two types of memory which have different
17+
performance characteristics might not be a good idea. Typically, a memory
18+
with high capacity have higher latency than standard memory. Because of that,
19+
the application may benefit from having some data allocated explicitly on
20+
memory with low latency. On the other hand, to utilise the whole available
21+
memory capacity in a server, we might allocate specific data always in
22+
a high capacity memory.
23+
<p>
24+
In this example, allocations of an array of data and a hashtable for accessing
25+
that data are made with the usage of the memkind library. Splitting
26+
allocations between a low latency memory and a high capacity memory is achieved
27+
by utlising two kinds (you can think of them as an additional parameter to
28+
malloc()): MEMKIND_LOWEST_LATENCY_LOCAL and MEMKIND_HIGHEST_CAPACITY.
29+
It's reasonable to have a reliably fast access to the hashtable. Also searching
30+
for data might benefit from keys being allocated in a low latency memory.
31+
To achieve this, the MEMKIND_LOWEST_LATENCY_LOCAL kind is used for allocating
32+
the hashtable and data keys. The memory with the lowest latency be allocated.
33+
Data that is being accessed from the hashtable have bigger size relative to
34+
a key size. Because of that, that data is a perfect fit for utilising the
35+
advantage of high capacity media. MEMKIND_HIGHEST_CAPACITY kind allows to
36+
explicitly allocate memory from this memory type.
37+
38+
{{step "Using memkind for allocations based on memory characteristics"}}
39+
40+
<p>
41+
This program allocates hashmap, keys and data using different memory
42+
characteristics for explicit allocations on specific media types. Note
43+
that functions highest_capacity_malloc() and lowest_latency_malloc() are
44+
wrappers for allocating with the usage of memkind and kinds based on
45+
performance characteristics retrieved from the hwloc library (memkind's
46+
dependency).
47+
<p>
48+
Complete hashmap implementation is in hashmap.c file (and a respective header
49+
file).
50+
51+
{{edit "hmat.c" "hashmap.c" "hashmap.h" "Makefile"}}
52+
53+
<p>
54+
Click the button below to build the program.
55+
56+
{{build "make"}}
57+
58+
If the program compiled without errors, run the example by clicking
59+
the button below:
60+
61+
{{run "./run.sh"}}
62+
63+
{{summary}}
64+
65+
<p>
66+
This example shows how memkind can be useful in programming based on the media
67+
characteristics. Developer doesn't have to know what setup is available on
68+
the machine the code is running on. In fact, the code will work when the only
69+
memory type available is DRAM, too. One may see these memkind kinds as a hint
70+
for the allocator as to whether allocated data should have fast access, huge
71+
storage or, not used in this example, fast bandwidth. You can also play with
72+
other memkind kinds listed
73+
<a href="https://pmem.io/memkind/manpages/memkind.3/#kind">here</a>.
74+
<p>
75+
In the <a href="I">next example</a>, you can experiment with some Java programs
76+
written with the usage of the Low-Level Persistence Library (LLPL).
77+
78+
{{bottom}}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{template "tocEntryStart" .}}
2+
{{template "tocShortText" .}}
3+
Allocation tiering based on memory-characteristics
4+
{{template "tocLongText" .}}
5+
{{template "tocRecommended" .}}
6+
This example shows allocation tiering with the usage of memkind.
7+
This is achieved by utilising memory performance characteristics provided by
8+
kernel and the libhwloc library. Allocation tiering is based on lowest latency
9+
and highest capacity tiers.
10+
<br><br>
11+
This example is intended for C programmers.
12+
{{template "tocEntryEnd" .}}

0 commit comments

Comments
 (0)