/usr/include/hbwmalloc.h is in libmemkind-dev 1.1.0-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | /*
* Copyright (C) 2014 - 2016 Intel Corporation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice(s),
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice(s),
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
/*
* Header file for the high bandwidth memory interface.
*
* This file defines the external API's and enumerations for the
* hbwmalloc library. These interfaces define a heap manager that
* targets the high bandwidth memory numa nodes.
*
* hbwmalloc.h functionality is considered as stable API (STANDARD API).
*
* Please read hbwmalloc(3) man page for or more details.
*/
/*
* Fallback policy.
*
* Policy that determines behavior when there is not enough free high
* bandwidth memory to satisfy a user request. This enum is used with
* hbw_get_policy() and hbw_set_policy().
*/
typedef enum {
/*
* If insufficient high bandwidth memory pages are available then
* OOM killer will be triggered.
*/
HBW_POLICY_BIND = 1,
/*
* If insufficient high bandwidth memory pages are available fall
* back on standard memory pages.
*/
HBW_POLICY_PREFERRED = 2,
/*
* Interleave pages accross high bandwidth nodes. If insufficient memory
* pages are available then OOM killer will be triggered.
*/
HBW_POLICY_INTERLEAVE = 3
} hbw_policy_t;
/*
* Page size selection.
*
* The hbw_posix_memalign_psize() API gives the user the option to
* select the page size from this enumerated list.
*/
typedef enum {
/*
* The four kilobyte page size option. Note that with transparent huge
* pages enabled these allocations may be promoted by the operating system
* to two megabyte pages.
*/
HBW_PAGESIZE_4KB = 1,
/*
* The two megabyte page size option.
*/
HBW_PAGESIZE_2MB = 2,
/*
* The one gigabyte page size option. The total size of the allocation must
* be a multiple of 1GB with this option, otherwise the allocation will
* fail.
*/
HBW_PAGESIZE_1GB_STRICT = 3,
/*
* This option allows the user to specify arbitrary sizes backed by one
* gigabytes pages. Gigabyte pages are allocated even if the size is not a
* modulo of 1GB. A good example of using this feature with realloc is
* shown in gb_realloc_example.c
*/
HBW_PAGESIZE_1GB = 4
} hbw_pagesize_t;
/*
* Returns the current fallback policy when insufficient high bandwith memory
* is available.
*/
hbw_policy_t hbw_get_policy(void);
/*
* Sets the current fallback policy. The policy can be modified only once in
* the lifetime of an application and before calling hbw_*alloc() or
* hbw_posix_memalign*() function.
* Note: If the policy is not set, than HBW_POLICY_PREFERRED will be used by
* default.
*
* Returns:
* 0: on success
* EPERM: if hbw_set_policy () was called more than once
* EINVAL: if mode argument was neither HBW_POLICY_PREFERRED, HBW_POLICY_BIND nor HBW_POLICY_INTERLEAVE
*/
int hbw_set_policy(hbw_policy_t mode);
/*
* Verifies high bandwith memory availability.
* Returns:
* 0: if high bandwidth memory is available
* ENODEV: if high-bandwidth memory is unavailable.
*/
int hbw_check_available(void);
/*
* Allocates size bytes of uninitialized high bandwidth memory.
* The allocated space is suitably aligned (after possible pointer
* coercion) for storage of any type of object. If size is zero then
* hbw_malloc() returns NULL.
*/
void *hbw_malloc(size_t size);
/*
* Allocates space for num objects in high bandwidth memory, each size bytes
* in length.
* The result is identical to calling hbw_malloc() with an argument of
* num*size, with the exception that the allocated memory is explicitly
* initialized to zero bytes.
* If num or size is 0, then hbw_calloc() returns NULL.
*/
void *hbw_calloc(size_t num, size_t size);
/*
* Allocates size bytes of high bandwidth memory such that the allocation's
* base address is an even multiple of alignment, and returns the allocation
* in the value pointed to by memptr. The requested alignment must be a power
* of 2 at least as large as sizeof(void *).
* Returns:
* 0: on success
* ENOMEM: if there was insufficient memory to satisfy the request
* EINVAL: if the alignment parameter was not a power of two, or was less than sizeof(void *)
*/
int hbw_posix_memalign(void **memptr, size_t alignment, size_t size);
/*
* Allocates size bytes of high bandwidth memory such that the allocation's
* base address is an even multiple of alignment, and returns the allocation
* in the value pointed to by memptr. The requested alignment must be a power
* of 2 at least as large as sizeof(void *). The memory will be allocated
* using pages determined by the pagesize variable.
* Returns:
* 0: on success
* ENOMEM: if there was insufficient memory to satisfy the request
* EINVAL: if the alignment parameter was not a power of two, or was less than sizeof(void *)
*/
int hbw_posix_memalign_psize(void **memptr, size_t alignment, size_t size,
hbw_pagesize_t pagesize);
/*
* Changes the size of the previously allocated memory referenced by ptr to
* size bytes of the specified kind. The contents of the memory are unchanged
* up to the lesser of the new and old size.
* If the new size is larger, the contents of the newly allocated portion
* of the memory are undefined.
* Upon success, the memory referenced by ptr is freed and a pointer to the
* newly allocated high bandwidth memory is returned.
* Note: memkind_realloc() may move the memory allocation, resulting in a
* different return value than ptr.
* If ptr is NULL, the hbw_realloc() function behaves identically to
* hbw_malloc() for the specified size. The address ptr, if not NULL,
* was returned by a previous call to hbw_malloc(), hbw_calloc(),
* hbw_realloc(), or hbw_posix_memalign(). Otherwise, or if hbw_free(ptr)
* was called before, undefined behavior occurs.
* Note: hbw_realloc() cannot be used with a pointer returned by
* hbw_posix_memalign_psize().
*/
void *hbw_realloc(void *ptr, size_t size);
/*
* Causes the allocated memory referenced by ptr to be made
* available for future allocations. If ptr is NULL, no action occurs.
* The address ptr, if not NULL, must have been returned by a previous call
* to hbw_malloc(), hbw_calloc(), hbw_realloc(), hbw_posix_memalign(), or
* hbw_posix_memalign_psize(). Otherwise, if hbw_free(ptr) was called before,
* undefined behavior occurs.
*/
void hbw_free(void *ptr);
#ifdef __cplusplus
}
#endif
|