/* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- Function: blysk__create_brood_Task Description: Creates a brood task and returns the task initialized */ blysk_task *blysk__create_brood_task (blysk_task *parent , void (*func)(void *), void *data , long start, long end) { blysk_task *new_task = allocTask (0 , 0, 0); new_task->tsk = func; new_task->args = data; new_task->_dependencies = 0; new_task->_udependencies = (Counter) {0}; if (expectTrue(parent == NULL)) { fetchAndAddCounter(&blysk__THREAD_get_task()->_parent->_children, 1, RELAXED); new_task->_parent = blysk__THREAD_get_task()->_parent; } else { fetchAndAddCounter(&parent->_children, 1, RELAXED); new_task->_parent = parent; } new_task->__dep_manager = NULL; new_task->FPN[0] = NULL; new_task->FPN[1] = NULL; new_task->Type = BROOD; new_task->iter_space[0] = start; new_task->iter_space[1] = end; trackTask(new_task); new_task->creator = blysk__THREAD_get_rid(); return new_task; }
static inline blysk_task* blysk__create_task(blysk_task* parent, void (*func)(void *), void *arg, void (*cpyfn) (void *, void *), u32 argsize, u32 arg_align, int nDeps) { blysk_task *new_task = allocTask(nDeps, argsize, arg_align); if (nDeps != 0 && parent->__dep_manager == NULL) blysk__DEP_init(parent); new_task->tsk = func; new_task->_dependencies = nDeps; new_task->_udependencies = (Counter) {(unsigned)nDeps}; if(expectFalse(cpyfn != 0)) { cpyfn(getTaskArgs(new_task), arg); } else { memcpy(getTaskArgs(new_task), arg, argsize); } new_task->_parent = parent; new_task->_children = (Counter) {0}; new_task->__dep_manager = NULL; new_task->FPN[0] = NULL; new_task->FPN[1] = NULL; new_task->Type = UNIT; trackTask(new_task); /* Clean this stuff up */ #if defined(__STAT_TASK) new_task-> stat__task = fetchAndAddCounter(&uniqueTask_ids, 1, RELAXED); new_task-> stat__parent = parent != NULL ? parent->stat__task : 0; new_task-> stat__create_instant = rdtsc(); new_task-> stat__child_number = parent->stat__num_children++; new_task-> stat__cpu_id_create = blysk__THREAD_get_rid(); new_task-> stat__num_children = 0; /* Set Others to default */ new_task-> stat__cpu_id = -1; new_task-> stat__num_children = 0; new_task-> stat__exec_cycles = 0; new_task-> stat__creation_cycles = 0; new_task-> stat__overhead_cycles = 0; new_task-> stat__queue_size = 0; new_task-> stat__exec_end_instant = -1; new_task-> stat__cpu_id_release = -1; new_task-> stat__release_instant= -1; new_task-> stat__dependency_resolution_time = -1; new_task-> stat__joins_at = -1; new_task-> stat__joins_counter = 0; #endif return new_task; }
Task * newBoundTask (void) { Task *task; if (!tasksInitialized) { errorBelch("newBoundTask: RTS is not initialised; call hs_init() first"); stg_exit(EXIT_FAILURE); } task = allocTask(); task->stopped = rtsFalse; newInCall(task); debugTrace(DEBUG_sched, "new task (taskCount: %d)", taskCount); return task; }