Go to the documentation of this file.
6 #ifndef ABTI_MEM_H_INCLUDED
7 #define ABTI_MEM_H_INCLUDED
14 #define ABTI_MEM_POOL_DESC_ELEM_SIZE \
15 ABTU_roundup_size(sizeof(ABTI_thread), ABT_CONFIG_STATIC_CACHELINE_SIZE)
32 #define ABTI_STACK_CANARY_VALUE ((uint64_t)0xbaadc0debaadc0de)
37 #if ABT_CONFIG_STACK_CHECK_TYPE == ABTI_STACK_CHECK_TYPE_CANARY
43 i +=
sizeof(uint64_t)) {
53 #if ABT_CONFIG_STACK_CHECK_TYPE == ABTI_STACK_CHECK_TYPE_CANARY
58 i +=
sizeof(uint64_t)) {
74 *pp_thread = p_thread;
78 #ifdef ABT_CONFIG_USE_MEM_POOL
93 *pp_thread = p_thread;
101 #ifdef ABT_CONFIG_USE_MEM_POOL
102 return ABTI_mem_alloc_nythread_mempool(p_local, pp_thread);
113 #ifdef ABT_CONFIG_USE_MEM_POOL
117 #ifndef ABT_CONFIG_DISABLE_EXT_THREAD
118 if (p_local_xstream == NULL) {
134 #ifdef ABT_CONFIG_USE_MEM_POOL
135 ABTU_ret_err static inline int ABTI_mem_alloc_ythread_mempool_desc_stack_impl(
145 *pp_stack = (
void *)(((
char *)p_ythread) - stacksize);
152 size_t stacksize,
ABTI_ythread **pp_ythread,
void **pp_stack)
155 size_t alloc_stacksize =
162 *pp_stack = (
void *)p_stack;
163 *pp_ythread = (
ABTI_ythread *)(p_stack + alloc_stacksize);
183 #ifdef ABT_CONFIG_USE_MEM_POOL
184 int abt_errno = ABTI_mem_alloc_ythread_mempool_desc_stack_impl(
185 &p_local_xstream->mem_pool_stack, stacksize, &p_ythread, &p_stack);
200 *pp_ythread = p_ythread;
204 #ifdef ABT_CONFIG_USE_MEM_POOL
205 ABTU_ret_err static inline int ABTI_mem_alloc_ythread_mempool_desc_stack(
221 int abt_errno = ABTI_mem_alloc_ythread_mempool_desc_stack_impl(
222 &p_local_xstream->mem_pool_stack, stacksize, &p_ythread, &p_stack);
230 *pp_ythread = p_ythread;
252 *pp_ythread = p_ythread;
277 *pp_ythread = p_ythread;
286 #ifdef ABT_CONFIG_USE_MEM_POOL
293 #ifndef ABT_CONFIG_DISABLE_EXT_THREAD
294 if (p_local_xstream == NULL) {
328 #define ABTI_MEM_POOL_DESC_SIZE (ABTI_MEM_POOL_DESC_ELEM_SIZE - 4)
333 #ifndef ABT_CONFIG_USE_MEM_POOL
361 #ifndef ABT_CONFIG_USE_MEM_POOL
365 #ifndef ABT_CONFIG_DISABLE_EXT_THREAD
370 }
else if (!p_local_xstream) {
static void ABTI_mem_free_thread(ABTI_global *p_global, ABTI_local *p_local, ABTI_thread *p_thread)
@ ABTI_MEM_LP_MMAP_HP_THP
static size_t ABTU_roundup_size(size_t val, size_t multiple)
#define ABTI_THREAD_TYPE_MEM_MEMPOOL_DESC
#define ABTI_CHECK_ERROR(abt_errno)
static ABTU_ret_err int ABTI_mem_alloc_nythread(ABTI_local *p_local, ABTI_thread **pp_thread)
static ABTI_ythread * ABTI_thread_get_ythread(ABTI_thread *p_thread)
#define ABTI_MEM_POOL_DESC_SIZE
static ABTU_ret_err int ABTI_mem_alloc_desc(ABTI_local *p_local, void **pp_desc)
static void ABTI_mem_register_stack(void *p_stack, size_t stacksize)
#define ABTI_THREAD_TYPE_MEM_MEMPOOL_DESC_STACK
static void ABTI_mem_unregister_stack(void *p_stack)
ABTU_ret_err int ABTI_mem_init(ABTI_global *p_global)
static void ABTI_mem_free_nythread(ABTI_global *p_global, ABTI_local *p_local, ABTI_thread *p_thread)
#define ABTI_VALGRIND_REGISTER_STACK(p_stack, size)
static ABTU_ret_err int ABTI_mem_pool_alloc(ABTI_mem_pool_local_pool *p_local_pool, void **p_mem)
static ABTI_ythread * ABTI_thread_get_ythread_or_null(ABTI_thread *p_thread)
static void ABTD_spinlock_acquire(ABTD_spinlock *p_lock)
static ABTU_ret_err int ABTI_mem_alloc_ythread_malloc_desc_stack_impl(size_t stacksize, ABTI_ythread **pp_ythread, void **pp_stack)
static ABTU_ret_err int ABTU_malloc(size_t size, void **p_ptr)
void ABTI_mem_finalize(ABTI_global *p_global)
static uint64_t ABTU_roundup_uint64(uint64_t val, uint64_t multiple)
#define ABTI_ASSERT(cond)
static ABTU_ret_err int ABTI_mem_alloc_ythread_mempool_desc(ABTI_local *p_local, ABTI_thread_attr *p_attr, ABTI_ythread **pp_ythread)
#define ABT_CONFIG_STATIC_CACHELINE_SIZE
#define ABTI_STATIC_ASSERT(cond)
#define ABT_SUCCESS
Error code: the routine returns successfully.
static ABTI_xstream * ABTI_local_get_xstream_or_null(ABTI_local *p_local)
ABTU_ret_err int ABTI_mem_init_local(ABTI_global *p_global, ABTI_xstream *p_local_xstream)
#define ABTI_IS_EXT_THREAD_ENABLED
#define ABTI_STACK_CANARY_VALUE
static ABTU_ret_err int ABTI_mem_alloc_nythread_malloc(ABTI_thread **pp_thread)
static void ABTU_free(void *ptr)
static void ABTD_spinlock_release(ABTD_spinlock *p_lock)
struct ABTI_local ABTI_local
#define ABTI_VALGRIND_UNREGISTER_STACK(p_stack)
#define ABT_CONFIG_STACK_CHECK_CANARY_SIZE
static ABTU_ret_err int ABTI_mem_alloc_ythread_malloc_desc_stack(ABTI_thread_attr *p_attr, ABTI_ythread **pp_ythread)
static void ABTI_mem_pool_free(ABTI_mem_pool_local_pool *p_local_pool, void *mem)
int ABTI_mem_check_lp_alloc(ABTI_global *p_global, int lp_alloc)
static void ABTI_mem_free_desc(ABTI_global *p_global, ABTI_local *p_local, void *p_desc)
void ABTI_mem_finalize_local(ABTI_xstream *p_local_xstream)
#define ABTI_MEM_POOL_DESC_ELEM_SIZE
#define ABTI_THREAD_TYPE_MEM_MALLOC_DESC_STACK
#define ABTI_THREAD_TYPE_MEM_MALLOC_DESC
static ABTU_ret_err int ABTI_mem_alloc_ythread_default(ABTI_global *p_global, ABTI_local *p_local, ABTI_ythread **pp_ythread)