#include "kmp.h"
#include "kmp_io.h"
#include "kmp_wrapper_malloc.h"
#if KMP_USE_BGET
bget_compact_t;
bget_acquire_t;
bget_release_t;
#if KMP_OS_WINDOWS
#if KMP_ARCH_X86 || KMP_ARCH_ARM
typedef kmp_int32 bufsize;
#else
typedef kmp_int64 bufsize;
#endif
#else
bufsize;
#endif
bget_mode_t;
static void bpool(kmp_info_t *th, void *buffer, bufsize len);
static void *bget(kmp_info_t *th, bufsize size);
static void *bgetz(kmp_info_t *th, bufsize size);
static void *bgetr(kmp_info_t *th, void *buffer, bufsize newsize);
static void brel(kmp_info_t *th, void *buf);
static void bectl(kmp_info_t *th, bget_compact_t compact,
bget_acquire_t acquire, bget_release_t release,
bufsize pool_incr);
#if KMP_ARCH_X86 || !KMP_HAVE_QUAD
#define SizeQuant …
#define AlignType …
#else
#define SizeQuant …
#define AlignType …
#endif
#define BufStats …
#ifdef KMP_DEBUG
#define BufDump …
#define BufValid …
#define DumpData …
#ifdef NOT_USED_NOW
#define FreeWipe …
#define BestFit …
#endif
#endif
static bufsize bget_bin_size[] = …;
#define MAX_BGET_BINS …
struct bfhead;
qlinks_t;
bhead2_t;
bhead_t;
#define BH(p) …
bdhead_t;
#define BDH(p) …
bfhead_t;
#define BFH(p) …
thr_data_t;
#define QLSize …
#define SizeQ …
#define MaxSize …
#define ESent …
static int bget_get_bin(bufsize size) { … }
static void set_thr_data(kmp_info_t *th) { … }
static thr_data_t *get_thr_data(kmp_info_t *th) { … }
static void __kmp_bget_dequeue(kmp_info_t *th) { … }
static void __kmp_bget_enqueue(kmp_info_t *th, void *buf
#ifdef USE_QUEUING_LOCK_FOR_BGET
,
kmp_int32 rel_gtid
#endif
) { … }
static void __kmp_bget_insert_into_freelist(thr_data_t *thr, bfhead_t *b) { … }
static void __kmp_bget_remove_from_freelist(bfhead_t *b) { … }
static void bcheck(kmp_info_t *th, bufsize *max_free, bufsize *total_free) { … }
static void *bget(kmp_info_t *th, bufsize requested_size) { … }
static void *bgetz(kmp_info_t *th, bufsize size) { … }
static void *bgetr(kmp_info_t *th, void *buf, bufsize size) { … }
static void brel(kmp_info_t *th, void *buf) { … }
static void bectl(kmp_info_t *th, bget_compact_t compact,
bget_acquire_t acquire, bget_release_t release,
bufsize pool_incr) { … }
static void bpool(kmp_info_t *th, void *buf, bufsize len) { … }
static void bfreed(kmp_info_t *th) { … }
void __kmp_initialize_bget(kmp_info_t *th) { … }
void __kmp_finalize_bget(kmp_info_t *th) { … }
void kmpc_set_poolsize(size_t size) { … }
size_t kmpc_get_poolsize(void) { … }
void kmpc_set_poolmode(int mode) { … }
int kmpc_get_poolmode(void) { … }
void kmpc_get_poolstat(size_t *maxmem, size_t *allmem) { … }
void kmpc_poolprint(void) { … }
#endif
void *kmpc_malloc(size_t size) { … }
#define IS_POWER_OF_TWO(n) …
void *kmpc_aligned_malloc(size_t size, size_t alignment) { … }
void *kmpc_calloc(size_t nelem, size_t elsize) { … }
void *kmpc_realloc(void *ptr, size_t size) { … }
void kmpc_free(void *ptr) { … }
void *___kmp_thread_malloc(kmp_info_t *th, size_t size KMP_SRC_LOC_DECL) { … }
void *___kmp_thread_calloc(kmp_info_t *th, size_t nelem,
size_t elsize KMP_SRC_LOC_DECL) { … }
void *___kmp_thread_realloc(kmp_info_t *th, void *ptr,
size_t size KMP_SRC_LOC_DECL) { … }
void ___kmp_thread_free(kmp_info_t *th, void *ptr KMP_SRC_LOC_DECL) { … }
static const char *kmp_mk_lib_name;
static void *h_memkind;
static void *(*kmp_mk_alloc)(void *k, size_t sz);
static void (*kmp_mk_free)(void *kind, void *ptr);
static int (*kmp_mk_check)(void *kind);
static void **mk_default;
static void **mk_interleave;
static void **mk_hbw;
static void **mk_hbw_interleave;
static void **mk_hbw_preferred;
static void **mk_hugetlb;
static void **mk_hbw_hugetlb;
static void **mk_hbw_preferred_hugetlb;
static void **mk_dax_kmem;
static void **mk_dax_kmem_all;
static void **mk_dax_kmem_preferred;
static void *(*kmp_target_alloc_host)(size_t size, int device);
static void *(*kmp_target_alloc_shared)(size_t size, int device);
static void *(*kmp_target_alloc_device)(size_t size, int device);
static void *(*kmp_target_lock_mem)(void *ptr, size_t size, int device);
static void *(*kmp_target_unlock_mem)(void *ptr, int device);
static void *(*kmp_target_free_host)(void *ptr, int device);
static void *(*kmp_target_free_shared)(void *ptr, int device);
static void *(*kmp_target_free_device)(void *ptr, int device);
static bool __kmp_target_mem_available;
#define KMP_IS_TARGET_MEM_SPACE(MS) …
#define KMP_IS_TARGET_MEM_ALLOC(MA) …
#if KMP_OS_UNIX && KMP_DYNAMIC_LIB && !KMP_OS_DARWIN
static inline void chk_kind(void ***pkind) { … }
#endif
void __kmp_init_memkind() { … }
void __kmp_fini_memkind() { … }
void __kmp_init_target_mem() { … }
omp_allocator_handle_t __kmpc_init_allocator(int gtid, omp_memspace_handle_t ms,
int ntraits,
omp_alloctrait_t traits[]) { … }
void __kmpc_destroy_allocator(int gtid, omp_allocator_handle_t allocator) { … }
void __kmpc_set_default_allocator(int gtid, omp_allocator_handle_t allocator) { … }
omp_allocator_handle_t __kmpc_get_default_allocator(int gtid) { … }
kmp_mem_desc_t;
static int alignment = …;
void *__kmpc_alloc(int gtid, size_t size, omp_allocator_handle_t allocator) { … }
void *__kmpc_aligned_alloc(int gtid, size_t algn, size_t size,
omp_allocator_handle_t allocator) { … }
void *__kmpc_calloc(int gtid, size_t nmemb, size_t size,
omp_allocator_handle_t allocator) { … }
void *__kmpc_realloc(int gtid, void *ptr, size_t size,
omp_allocator_handle_t allocator,
omp_allocator_handle_t free_allocator) { … }
void __kmpc_free(int gtid, void *ptr, omp_allocator_handle_t allocator) { … }
void *__kmp_alloc(int gtid, size_t algn, size_t size,
omp_allocator_handle_t allocator) { … }
void *__kmp_calloc(int gtid, size_t algn, size_t nmemb, size_t size,
omp_allocator_handle_t allocator) { … }
void *__kmp_realloc(int gtid, void *ptr, size_t size,
omp_allocator_handle_t allocator,
omp_allocator_handle_t free_allocator) { … }
void ___kmpc_free(int gtid, void *ptr, omp_allocator_handle_t allocator) { … }
struct kmp_mem_descr { … };
kmp_mem_descr_t;
static void *___kmp_allocate_align(size_t size,
size_t alignment KMP_SRC_LOC_DECL) { … }
void *___kmp_allocate(size_t size KMP_SRC_LOC_DECL) { … }
void *___kmp_page_allocate(size_t size KMP_SRC_LOC_DECL) { … }
void ___kmp_free(void *ptr KMP_SRC_LOC_DECL) { … }
#if USE_FAST_MEMORY == 3
#define KMP_FREE_LIST_LIMIT …
#define DCACHE_LINE …
void *___kmp_fast_allocate(kmp_info_t *this_thr, size_t size KMP_SRC_LOC_DECL) { … }
void ___kmp_fast_free(kmp_info_t *this_thr, void *ptr KMP_SRC_LOC_DECL) { … }
void __kmp_initialize_fast_memory(kmp_info_t *this_thr) { … }
void __kmp_free_fast_memory(kmp_info_t *th) { … }
#endif