8 #ifdef ABT_CONFIG_USE_MEM_POOL
18 int num_requested_types = 0;
20 switch (p_global->mem_lp_alloc) {
21 case ABTI_MEM_LP_MMAP_RP:
25 case ABTI_MEM_LP_MMAP_HP_RP:
26 requested_types[num_requested_types++] =
31 case ABTI_MEM_LP_MMAP_HP_THP:
32 requested_types[num_requested_types++] =
34 requested_types[num_requested_types++] =
39 requested_types[num_requested_types++] =
47 size_t thread_stacksize = p_global->thread_stacksize;
53 ABTI_mem_pool_global_pool_mprotect_config mprotect_config;
54 if (p_global->stack_guard_kind == ABTI_STACK_GUARD_MPROTECT ||
55 p_global->stack_guard_kind == ABTI_STACK_GUARD_MPROTECT_STRICT) {
57 mprotect_config.check_error =
58 (p_global->stack_guard_kind == ABTI_STACK_GUARD_MPROTECT_STRICT)
61 mprotect_config.offset = 0;
62 mprotect_config.page_size = p_global->sys_page_size;
63 mprotect_config.alignment = p_global->sys_page_size;
72 ABTI_mem_pool_init_global_pool(&p_global->mem_pool_stack,
73 p_global->mem_max_stacks /
75 stacksize, thread_stacksize,
76 p_global->mem_sp_size, requested_types,
77 num_requested_types, p_global->mem_page_size,
80 ABTI_STATIC_ASSERT((ABTI_MEM_POOL_DESC_ELEM_SIZE &
82 ABTI_mem_pool_init_global_pool(&p_global->mem_pool_desc,
83 p_global->mem_max_descs /
85 ABTI_MEM_POOL_DESC_ELEM_SIZE, 0,
86 p_global->mem_page_size, requested_types,
87 num_requested_types, p_global->mem_page_size,
89 #ifndef ABT_CONFIG_DISABLE_EXT_THREAD
91 ABTD_spinlock_clear(&p_global->mem_pool_stack_lock);
92 abt_errno = ABTI_mem_pool_init_local_pool(&p_global->mem_pool_stack_ext,
93 &p_global->mem_pool_stack);
95 ABTI_mem_pool_destroy_global_pool(&p_global->mem_pool_stack);
96 ABTI_mem_pool_destroy_global_pool(&p_global->mem_pool_desc);
97 ABTI_HANDLE_ERROR(abt_errno);
99 ABTD_spinlock_clear(&p_global->mem_pool_desc_lock);
100 abt_errno = ABTI_mem_pool_init_local_pool(&p_global->mem_pool_desc_ext,
101 &p_global->mem_pool_desc);
103 ABTI_mem_pool_destroy_local_pool(&p_global->mem_pool_stack_ext);
104 ABTI_mem_pool_destroy_global_pool(&p_global->mem_pool_stack);
105 ABTI_mem_pool_destroy_global_pool(&p_global->mem_pool_desc);
106 ABTI_HANDLE_ERROR(abt_errno);
112 ABTU_ret_err int ABTI_mem_init_local(ABTI_global *p_global,
113 ABTI_xstream *p_local_xstream)
116 abt_errno = ABTI_mem_pool_init_local_pool(&p_local_xstream->mem_pool_stack,
117 &p_global->mem_pool_stack);
118 ABTI_CHECK_ERROR(abt_errno);
119 abt_errno = ABTI_mem_pool_init_local_pool(&p_local_xstream->mem_pool_desc,
120 &p_global->mem_pool_desc);
122 ABTI_mem_pool_destroy_local_pool(&p_local_xstream->mem_pool_stack);
123 ABTI_HANDLE_ERROR(abt_errno);
128 void ABTI_mem_finalize(ABTI_global *p_global)
130 #ifndef ABT_CONFIG_DISABLE_EXT_THREAD
131 ABTI_mem_pool_destroy_local_pool(&p_global->mem_pool_stack_ext);
132 ABTI_mem_pool_destroy_local_pool(&p_global->mem_pool_desc_ext);
134 ABTI_mem_pool_destroy_global_pool(&p_global->mem_pool_stack);
135 ABTI_mem_pool_destroy_global_pool(&p_global->mem_pool_desc);
138 void ABTI_mem_finalize_local(ABTI_xstream *p_local_xstream)
140 ABTI_mem_pool_destroy_local_pool(&p_local_xstream->mem_pool_stack);
141 ABTI_mem_pool_destroy_local_pool(&p_local_xstream->mem_pool_desc);
144 int ABTI_mem_check_lp_alloc(ABTI_global *p_global,
int lp_alloc)
146 size_t sp_size = p_global->mem_sp_size;
147 size_t pg_size = p_global->mem_page_size;
150 case ABTI_MEM_LP_MMAP_RP:
153 return ABTI_MEM_LP_MMAP_RP;
155 return ABTI_MEM_LP_MALLOC;
157 case ABTI_MEM_LP_MMAP_HP_RP:
160 return ABTI_MEM_LP_MMAP_HP_RP;
164 return ABTI_MEM_LP_MMAP_RP;
166 return ABTI_MEM_LP_MALLOC;
168 case ABTI_MEM_LP_MMAP_HP_THP:
171 return ABTI_MEM_LP_MMAP_HP_THP;
174 p_global->huge_page_size,
176 return ABTI_MEM_LP_THP;
178 return ABTI_MEM_LP_MALLOC;
180 case ABTI_MEM_LP_THP:
182 p_global->huge_page_size,
184 return ABTI_MEM_LP_THP;
186 return ABTI_MEM_LP_MALLOC;
189 return ABTI_MEM_LP_MALLOC;
200 ABTU_ret_err int ABTI_mem_init_local(ABTI_global *p_global,
201 ABTI_xstream *p_local_xstream)
206 void ABTI_mem_finalize(ABTI_global *p_global)
210 void ABTI_mem_finalize_local(ABTI_xstream *p_local_xstream)