13 static inline ABTI_thread *
50 ABTI_UB_ASSERT(ABTI_initialized());
52 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
53 ABTI_CHECK_NULL_POOL_PTR(p_pool);
82 ABTI_UB_ASSERT(ABTI_initialized());
83 ABTI_UB_ASSERT(thread);
85 ABTI_global *p_global = ABTI_global_get_global();
87 ABTI_thread *p_thread = ABTI_unit_get_thread(p_global, unit);
88 *thread = ABTI_thread_get_handle(p_thread);
96 void ABTI_unit_init_hash_table(ABTI_global *p_global)
101 void ABTI_unit_finalize_hash_table(ABTI_global *p_global)
107 ABTI_thread *p_thread)
112 void ABTI_unit_unmap_thread(ABTI_global *p_global,
ABT_unit unit)
117 ABTI_thread *ABTI_unit_get_thread_from_user_defined_unit(ABTI_global *p_global,
129 size_t val = (uintptr_t)unit;
131 size_t base_val = val >> 3;
132 #if ABTI_UNIT_HASH_TABLE_SIZE_EXP <= 14
133 base_val += val >> (ABTI_UNIT_HASH_TABLE_SIZE_EXP + 3);
135 #if ABTI_UNIT_HASH_TABLE_SIZE_EXP <= 9
136 base_val += val >> (ABTI_UNIT_HASH_TABLE_SIZE_EXP * 2 + 3);
138 return base_val & (ABTI_UNIT_HASH_TABLE_SIZE - 1);
147 return (
ABT_unit)ABTD_atomic_relaxed_load_ptr(&p_ptr->
val);
152 ABTD_atomic_relaxed_store_ptr(&p_ptr->
val, (
void *)val);
170 return (
unit_to_thread *)ABTD_atomic_acquire_load_ptr(&p_ptr->val);
176 return (
unit_to_thread *)ABTD_atomic_relaxed_load_ptr(&p_ptr->val);
183 ABTD_atomic_release_store_ptr(&p_ptr->val, (
void *)val);
190 ABTD_atomic_relaxed_store_ptr(&p_ptr->val, (
void *)val);
196 for (i = 0; i < (int)ABTI_UNIT_HASH_TABLE_SIZE; i++) {
200 ABTD_spinlock_clear(&p_global->unit_to_thread_entires[i].lock);
207 for (i = 0; i < (int)ABTI_UNIT_HASH_TABLE_SIZE; i++) {
208 ABTI_ASSERT(!ABTD_spinlock_is_locked(
209 &p_global->unit_to_thread_entires[i].lock));
211 &p_global->unit_to_thread_entires[i].list);
225 ABTI_ASSERT(!ABTI_unit_is_builtin(
unit));
227 ABTI_unit_to_thread_entry *p_entry =
228 &p_global->unit_to_thread_entires[hash_index];
230 ABTD_spinlock_acquire(&p_entry->lock);
238 ABTD_spinlock_release(&p_entry->lock);
249 ABTD_spinlock_release(&p_entry->lock);
255 p_new->p_next = p_cur;
257 ABTD_spinlock_release(&p_entry->lock);
263 ABTI_ASSERT(!ABTI_unit_is_builtin(
unit));
265 ABTI_unit_to_thread_entry *p_entry =
266 &p_global->unit_to_thread_entires[hash_index];
268 ABTD_spinlock_acquire(&p_entry->lock);
279 ABTD_spinlock_release(&p_entry->lock);
282 static inline ABTI_thread *
285 ABTI_ASSERT(!ABTI_unit_is_builtin(
unit));
288 ABTI_unit_to_thread_entry *p_entry =
289 &p_global->unit_to_thread_entires[hash_index];