19 .get_migr_pool = NULL,
26 #ifdef ABT_CONFIG_USE_SCHED_SLEEP
27 struct timespec sleep_time;
40 ABTI_global *p_global = ABTI_global_get_global();
42 ABTI_sched *p_sched = ABTI_sched_get_ptr(sched);
43 ABTI_CHECK_NULL_SCHED_PTR(p_sched);
44 ABTI_sched_config *p_config = ABTI_sched_config_get_ptr(config);
48 abt_errno =
ABTU_malloc(
sizeof(sched_data), (
void **)&p_data);
49 ABTI_CHECK_ERROR(abt_errno);
50 #ifdef ABT_CONFIG_USE_SCHED_SLEEP
51 p_data->sleep_time.tv_sec = 0;
52 p_data->sleep_time.tv_nsec = p_global->sched_sleep_nsec;
56 p_data->event_freq = p_global->sched_event_freq;
63 p_data->event_freq = event_freq;
68 num_pools = p_sched->num_pools;
69 p_data->num_pools = num_pools;
72 if (ABTI_IS_ERROR_CHECK_ENABLED && abt_errno !=
ABT_SUCCESS) {
74 ABTI_HANDLE_ERROR(abt_errno);
76 memcpy(p_data->pools, p_sched->pools,
sizeof(
ABT_pool) * num_pools);
78 p_sched->data = p_data;
84 ABTI_global *p_global = ABTI_global_get_global();
85 ABTI_xstream *p_local_xstream =
86 ABTI_local_get_xstream(ABTI_local_get_local());
87 uint32_t work_count = 0;
92 unsigned seed = time(NULL);
95 ABTI_sched *p_sched = ABTI_sched_get_ptr(sched);
98 p_data = (sched_data *)p_sched->data;
99 num_pools = p_sched->num_pools;
100 pools = p_data->pools;
107 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
111 ABTI_thread *p_thread = ABTI_thread_get_ptr(thread);
112 ABTI_ythread_schedule(p_global, &p_local_xstream, p_thread);
114 }
else if (num_pools > 1) {
117 (num_pools == 2) ? 1 : (rand_r(&seed) % (num_pools - 1) + 1);
118 pool = pools[target];
119 p_pool = ABTI_pool_get_ptr(pool);
122 ABTI_thread *p_thread = ABTI_thread_get_ptr(thread);
123 ABTI_ythread_schedule(p_global, &p_local_xstream, p_thread);
128 if (++work_count >= p_data->event_freq) {
129 ABTI_xstream_check_events(p_local_xstream, p_sched);
130 if (ABTI_sched_has_to_stop(p_sched) ==
ABT_TRUE)
140 ABTI_sched *p_sched = ABTI_sched_get_ptr(sched);
141 ABTI_ASSERT(p_sched);
143 sched_data *p_data = (sched_data *)p_sched->data;