39 #include "hc_sysdep.h"
40 #include "runtime-support.h"
41 #include "rt-accumulator.h"
51 void check_in_finish(
finish_t * finish) {
52 hc_atomic_inc(&(finish->counter));
59 void check_out_finish(
finish_t * finish) {
60 if (hc_atomic_dec(&(finish->counter))) {
62 rt_finish_reached_zero(finish);
70 check_in_finish(async_task->current_finish);
77 check_out_finish(async_task->current_finish);
85 if (async_task->phaser_context != NULL) {
87 destruct_phaser_context();
88 async_task->phaser_context = NULL;
101 if ((async_def != NULL) && async_def->ddf_list != NULL) {
104 async_task = rt_allocate_ddt(async_def->ddf_list);
107 async_task = rt_allocate_async_task();
110 if (async_def != NULL) {
111 async_task->def = *async_def;
114 async_task->phaser_context = NULL;
123 return rt_allocate_forasync1D_task();
130 return rt_allocate_forasync2D_task();
137 return rt_allocate_forasync3D_task();
144 rt_deallocate_async_task(async);
151 return rt_allocate_finish();
157 void deallocate_finish(
finish_t * finish) {
158 rt_deallocate_finish(finish);
167 return get_current_async()->current_finish;
170 void end_finish_notify(
finish_t * current_finish) {
171 accum_t ** accumulators = current_finish->accumulators;
172 if(accumulators != NULL) {
174 while (accumulators[i] != NULL) {
176 accum_impl->close(accum_impl);
182 static int is_eligible_to_schedule(
async_task_t * async_task) {
183 if (async_task->def.ddf_list != NULL) {
184 ddt_t * ddt = (
ddt_t *) rt_async_task_to_ddt(async_task);
185 return iterate_ddt_frontier(ddt);
191 int get_nb_workers() {
192 return rt_get_nb_workers();
195 int get_worker_id_hc() {
196 return rt_get_worker_id();
200 if (is_eligible_to_schedule(async_task)) {
201 rt_schedule_async(async_task);
207 async_task->current_finish = finish_scope;
209 async_check_in_finish(async_task);
212 phased_t * phased_clause = async_task->def.phased_clause;
214 if (phased_clause != NULL) {
215 phaser_context_t * currentCtx = get_phaser_context();
216 phaser_context_t * ctx = phaser_context_construct();
217 async_task->phaser_context = ctx;
218 transmit_specific_phasers(currentCtx, ctx,
219 phased_clause->count,
220 phased_clause->phasers,
221 phased_clause->phasers_mode);
224 phaser_context_t * currentCtx = get_phaser_context();
225 phaser_context_t * ctx = phaser_context_construct();
226 async_task->phaser_context = ctx;
227 transmit_all_phasers(currentCtx, ctx);
232 try_schedule_async(async_task);
238 void help_finish(
finish_t * finish) {
239 rt_help_finish(finish);