lpel_task_t *LpelWorkerCurrentTask(void) { workerctx_t *w = LpelWorkerSelf(); /* It is quite a common bug to call LpelWorkerCurrentTask() from a non-task context. * Provide an assertion error instead of just segfaulting on a null dereference. */ assert(w && "Currently not in an LPEL worker context!"); return w->current_task; }
void LpelWorkerTaskWakeup(lpel_task_t *t) { workerctx_t *wc = t->worker_context; WORKER_DBG("worker %d: send wake up task %d\n", LpelWorkerSelf()->wid, t->uid); if (wc == NULL) sendWakeup(mastermb, t); else { if (wc->wid < 0) sendWakeup(wc->mailbox, t); else sendWakeup(mastermb, t); } }
lpel_stream_t *LpelWorkerGetStream() { lpel_stream_t *tmp; workerctx_t *wc = LpelWorkerSelf(); if (wc == NULL) { return NULL; } tmp = wc->free_stream; if (tmp) { wc->free_stream = tmp->next; tmp->next = NULL; assert(tmp->cons_sd == NULL && tmp->prod_sd == NULL); } return tmp; }
/** * Get the virtual worker id from within a spmd function */ int LpelSpmdVId(void) { int self_id, master_id; spmdreq_t *curreq; self_id = LpelWorkerSelf()->wid; assert( self_id >= 0 && self_id < num_workers ); /* if we are not in a spmd, curreq is NULL */ curreq = worker_data[self_id].curreq; assert(curreq != NULL); /* the virtual id for the master is 0, * all other worker ids are shifted * by the master id modulo num_workers */ master_id = curreq->wctx->wid; return GetVId(self_id, master_id); }