ARGOBOTS
dce6e727ffc4ca5b3ffc04cb9517c6689be51ec5
|
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_ythread), ABT_CONFIG_STATIC_CACHELINE_SIZE)
32 #define ABTI_STACK_CANARY_VALUE ((uint64_t)0xbaadc0debaadc0de)
35 #if ABT_CONFIG_STACK_CHECK_TYPE == ABTI_STACK_CHECK_TYPE_CANARY
41 i +=
sizeof(uint64_t)) {
50 i +=
sizeof(uint64_t)) {
58 void *p_stacktop,
size_t stacksize,
61 void *p_stack = (
void *)(((
char *)p_stacktop) - stacksize);
62 if (mprotect_if_needed) {
76 #if ABT_CONFIG_STACK_CHECK_TYPE == ABTI_STACK_CHECK_TYPE_CANARY
83 #if ABT_CONFIG_STACK_CHECK_TYPE == ABTI_STACK_CHECK_TYPE_CANARY
95 void *p_stacktop,
size_t stacksize,
98 void *p_stack = (
void *)(((
char *)p_stacktop) - stacksize);
99 if (mprotect_if_needed) {
112 #if ABT_CONFIG_STACK_CHECK_TYPE == ABTI_STACK_CHECK_TYPE_CANARY
119 #if ABT_CONFIG_STACK_CHECK_TYPE == ABTI_STACK_CHECK_TYPE_CANARY
135 #ifdef ABT_CONFIG_USE_MEM_POOL
151 *pp_thread = p_thread;
160 #ifdef ABT_CONFIG_USE_MEM_POOL
162 #ifdef ABT_CONFIG_DISABLE_EXT_THREAD
166 if (p_local_xstream) {
188 #ifdef ABT_CONFIG_USE_MEM_POOL
193 (
void **)&p_ythread);
195 p_ythread->thread.type =
205 p_ythread->thread.type =
209 *pp_ythread = p_ythread;
217 #ifdef ABT_CONFIG_USE_MEM_POOL
219 #ifdef ABT_CONFIG_DISABLE_EXT_THREAD
223 if (p_local_xstream) {
239 #ifdef ABT_CONFIG_USE_MEM_POOL
240 ABTU_ret_err static inline int ABTI_mem_alloc_ythread_mempool_desc_stack_impl(
250 *pp_stacktop = (
void *)p_ythread;
257 size_t stacksize,
ABTI_ythread **pp_ythread,
void **pp_stacktop)
260 size_t alloc_stacksize =
267 *pp_stacktop = (
void *)(p_stack + alloc_stacksize);
268 *pp_ythread = (
ABTI_ythread *)(p_stack + alloc_stacksize);
279 #ifdef ABT_CONFIG_USE_MEM_POOL
280 #ifdef ABT_CONFIG_DISABLE_LAZY_STACK_ALLOC
285 if (use_lazy_stack) {
292 *pp_ythread = p_ythread;
299 int abt_errno = ABTI_mem_alloc_ythread_mempool_desc_stack_impl(
317 *pp_ythread = p_ythread;
330 *pp_ythread = p_ythread;
341 stacksize, pp_ythread);
358 *pp_ythread = p_ythread;
364 size_t stacksize,
void *p_stacktop,
378 *pp_ythread = p_ythread;
387 #ifdef ABT_CONFIG_USE_MEM_POOL
399 #ifndef ABT_CONFIG_DISABLE_EXT_THREAD
400 if (p_local_xstream == NULL) {
437 void *p_stack = (
void *)(((
char *)p_stacktop) - stacksize);
439 }
else if (p_thread->
type &
464 #ifdef ABT_CONFIG_USE_MEM_POOL
485 #ifdef ABT_CONFIG_USE_MEM_POOL
501 #define ABTI_MEM_POOL_DESC_SIZE (ABTI_MEM_POOL_DESC_ELEM_SIZE - 4)
506 #ifndef ABT_CONFIG_USE_MEM_POOL
534 #ifndef ABT_CONFIG_USE_MEM_POOL
538 #ifndef ABT_CONFIG_DISABLE_EXT_THREAD
543 }
else if (!p_local_xstream) {
#define ABTI_THREAD_TYPE_MEM_MALLOC_DESC_MEMPOOL_LAZY_STACK
ABTI_mem_pool_local_pool mem_pool_desc_ext
static void ABTI_mem_free_thread(ABTI_global *p_global, ABTI_local *p_local, ABTI_thread *p_thread)
int ABT_bool
Boolean type.
static void ABTI_mem_unregister_stack(const ABTI_global *p_global, void *p_stacktop, size_t stacksize, ABT_bool mprotect_if_needed)
static void * ABTD_ythread_context_get_stacktop(ABTD_ythread_context *p_ctx)
@ ABTI_MEM_LP_MMAP_HP_THP
static ABTU_ret_err int ABTI_mem_alloc_ythread_desc_impl(ABTI_local *p_local, ABT_bool use_lazy_stack, ABTI_ythread **pp_ythread)
@ ABTI_STACK_GUARD_MPROTECT_STRICT
static void * ABTU_roundup_ptr(void *ptr, size_t multiple)
static size_t ABTU_roundup_size(size_t val, size_t multiple)
#define ABTI_THREAD_TYPE_MEM_MEMPOOL_DESC
static void ABTI_mem_register_stack(const ABTI_global *p_global, void *p_stacktop, size_t stacksize, ABT_bool mprotect_if_needed)
#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)
ABTI_mem_pool_local_pool mem_pool_stack
#define ABTI_MEM_POOL_DESC_SIZE
static ABTU_ret_err int ABTI_mem_alloc_desc(ABTI_local *p_local, void **pp_desc)
#define ABTI_THREAD_TYPE_MEM_MEMPOOL_DESC_STACK
static ABTU_ret_err int ABTI_mem_alloc_ythread_mempool_desc_stack(ABTI_global *p_global, ABTI_local *p_local, size_t stacksize, ABTI_ythread **pp_ythread)
ABTU_ret_err int ABTU_mprotect(void *addr, size_t size, ABT_bool protect)
static void ABTI_mem_free_ythread_desc_mempool_impl(ABTI_global *p_global, ABTI_local *p_local, ABTI_ythread *p_ythread)
ABTI_stack_guard stack_guard_kind
ABTU_ret_err int ABTI_mem_init(ABTI_global *p_global)
#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 void ABTD_ythread_context_lazy_unset_stack(ABTD_ythread_context *p_ctx)
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 ABTU_malloc(size_t size, void **p_ptr)
void ABTI_mem_finalize(ABTI_global *p_global)
static void ABTI_mem_free_nythread_mempool_impl(ABTI_global *p_global, ABTI_local *p_local, ABTI_thread *p_thread)
static uint64_t ABTU_roundup_uint64(uint64_t val, uint64_t multiple)
ABTI_mem_pool_local_pool mem_pool_stack_ext
#define ABTI_ASSERT(cond)
static void ABTD_ythread_context_lazy_set_stack(ABTD_ythread_context *p_ctx, void *p_stacktop)
#define ABT_CONFIG_STATIC_CACHELINE_SIZE
#define ABTI_STATIC_ASSERT(cond)
#define ABT_SUCCESS
Error code: the routine returns successfully.
ABTI_mem_pool_local_pool mem_pool_desc
static ABTU_ret_err int ABTI_mem_alloc_ythread_malloc_desc_stack(ABTI_global *p_global, size_t stacksize, ABTI_ythread **pp_ythread)
static ABTU_ret_err int ABTI_mem_alloc_ythread_mempool_desc(ABTI_global *p_global, ABTI_local *p_local, size_t stacksize, void *p_stacktop, ABTI_ythread **pp_ythread)
static ABTI_xstream * ABTI_local_get_xstream_or_null(ABTI_local *p_local)
@ ABTI_STACK_GUARD_MPROTECT
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
#define ABT_TRUE
True constant for ABT_bool.
#define ABT_FALSE
False constant for ABT_bool.
static void ABTD_ythread_context_init(ABTD_ythread_context *p_ctx, void *p_stacktop, size_t stacksize)
#define ABTI_UB_ASSERT(cond)
static void ABTU_free(void *ptr)
static void ABTD_spinlock_release(ABTD_spinlock *p_lock)
static void ABTD_ythread_context_init_lazy(ABTD_ythread_context *p_ctx, size_t stacksize)
static void ABTI_mem_free_ythread_mempool_stack(ABTI_xstream *p_local_xstream, ABTI_ythread *p_ythread)
ABTD_spinlock mem_pool_desc_lock
ABTD_spinlock mem_pool_stack_lock
struct ABTI_local ABTI_local
#define ABTI_VALGRIND_UNREGISTER_STACK(p_stack)
#define ABT_CONFIG_STACK_CHECK_CANARY_SIZE
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)
static size_t ABTD_ythread_context_get_stacksize(ABTD_ythread_context *p_ctx)
#define ABTI_THREAD_TYPE_MEM_MEMPOOL_DESC_MEMPOOL_LAZY_STACK
static ABTU_ret_err int ABTI_mem_alloc_ythread_malloc_desc_stack_impl(size_t stacksize, ABTI_ythread **pp_ythread, void **pp_stacktop)
void ABTI_mem_finalize_local(ABTI_xstream *p_local_xstream)
#define ABTI_MEM_POOL_DESC_ELEM_SIZE
static void ABTI_mem_write_stack_canary(void *p_stack)
static ABT_bool ABTD_ythread_context_has_stack(const ABTD_ythread_context *p_ctx)
static void ABTI_mem_check_stack_canary(void *p_stack)
#define ABTI_THREAD_TYPE_MEM_MALLOC_DESC_STACK
static ABTU_ret_err int ABTI_mem_alloc_ythread_mempool_stack(ABTI_xstream *p_local_xstream, ABTI_ythread *p_ythread)
#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)