void create_modeling_task(Model *model, long type, long process_id) { /* Implemented this way (routine just calls another routine) for historical reasons */ process_model( model, type, process_id ) ; return ; }
virtual Belief create_belief() const { auto belief = Belief(process_model().state_dimension()); return belief; }
void process_tasks(long process_id) { Task *t ; retry_entry: t = DEQUEUE_TASK( taskqueue_id[process_id], QUEUES_VISITED, process_id ) ; while( t ) { switch( t->task_type ) { case TASK_MODELING: process_model( t->task.model.model, t->task.model.type, process_id ) ; break ; case TASK_BSP: define_patch( t->task.bsp.patch, t->task.bsp.parent, process_id ) ; break ; case TASK_FF_REFINEMENT: ff_refine_elements( t->task.ref.e1, t->task.ref.e2, 0, process_id ) ; break ; case TASK_RAY: process_rays( t->task.ray.e, process_id ) ; break ; case TASK_VISIBILITY: visibility_task( t->task.vis.e, t->task.vis.inter, t->task.vis.n_inter, t->task.vis.k, process_id ) ; break ; case TASK_RAD_AVERAGE: radiosity_averaging( t->task.rad.e, t->task.rad.mode, process_id ) ; break ; default: fprintf( stderr, "Panic:process_tasks:Illegal task type\n" ); } /* Free the task */ free_task( t, process_id ) ; /* Get next task */ t = DEQUEUE_TASK( taskqueue_id[process_id], QUEUES_VISITED, process_id ) ; } /* Barrier. While waiting for other processors to finish, poll the task queues and resume processing if there is any task */ LOCK(global->pbar_lock); /* Reset the barrier counter if not initialized */ if( global->pbar_count >= n_processors ) global->pbar_count = 0 ; /* Increment the counter */ global->pbar_count++ ; /* barrier spin-wait loop */ long bar_done = !(global->pbar_count < n_processors); UNLOCK(global->pbar_lock); while(!bar_done) { /* Wait for a while and then retry dequeue */ if( _process_task_wait_loop() ) break ; /* Waited for a while but other processors are still running. Poll the task queue again If polling succeeds (without actually getting a task) then we exit the barrier and try to get a task. This fixes the bug where all the threads might finish the barrier but in the meantime one reenters it to process some tasks. */ int has_task = peek_dequeue( taskqueue_id[process_id], QUEUES_VISITED, process_id ); if (has_task) { LOCK(global->pbar_lock); global->pbar_count-- ; UNLOCK(global->pbar_lock); goto retry_entry ; } LOCK(global->pbar_lock); bar_done = !(global->pbar_count < n_processors); UNLOCK(global->pbar_lock); } BARRIER(global->barrier, n_processors); }
int main(int argc, const char* argv[]) { FILE *log = get_log (NULL); switch (process_options(argc, argv, log)) { case 0: break; case -1: exit(EXIT_SUCCESS); default: exit(EXIT_FAILURE); } if ( ! arg_nodaemonize ) { close_log (log); /* close before daemonizing */ daemonize(); } log = get_log (log); /* reopen */ LOG_INF(log, "Initializing - lwes-journaller-%s\n", VERSION); if (write_pid_file() != 0) { LOG_ER(log,"Can't open PID file \"%s\"\n", arg_pid_file); } if ( arg_njournalls > 30 ) { LOG_WARN(log, "suspiciously large (%d) number of journals.", arg_njournalls); } LOG_INF(log, "Starting up - lwes-journaller-%s using %s model\n", VERSION, arg_proc_type); if ( strcmp(arg_proc_type, ARG_PROCESS) == 0 ) { process_model(argv, log); } if ( strcmp(arg_proc_type, ARG_THREAD) == 0 ) { thread_model(log); } if ( strcmp(arg_proc_type, ARG_SERIAL) == 0 ) { serial_model(log); } int r = 0; if ((r = delete_pid_file()) < 0) { LOG_ER(log,"Unable to delete pid file : %s\n", delete_pid_file, strerror(r)); } options_destructor(); LOG_INF(log, "Normal shutdown complete - lwes-journaller-%s\n", VERSION); close_log (log); return 0; }
void process_tasks(long process_id) { Task *t ; t = DEQUEUE_TASK( taskqueue_id[process_id], QUEUES_VISITED, process_id ) ; retry_entry: while( t ) { switch( t->task_type ) { case TASK_MODELING: process_model( t->task.model.model, t->task.model.type, process_id ) ; break ; case TASK_BSP: define_patch( t->task.bsp.patch, t->task.bsp.parent, process_id ) ; break ; case TASK_FF_REFINEMENT: ff_refine_elements( t->task.ref.e1, t->task.ref.e2, 0, process_id ) ; break ; case TASK_RAY: process_rays( t->task.ray.e, process_id ) ; break ; case TASK_VISIBILITY: visibility_task( t->task.vis.e, t->task.vis.inter, t->task.vis.n_inter, t->task.vis.k, process_id ) ; break ; case TASK_RAD_AVERAGE: radiosity_averaging( t->task.rad.e, t->task.rad.mode, process_id ) ; break ; default: fprintf( stderr, "Panic:process_tasks:Illegal task type\n" ); } /* Free the task */ free_task( t, process_id ) ; /* Get next task */ t = DEQUEUE_TASK( taskqueue_id[process_id], QUEUES_VISITED, process_id ) ; } /* Barrier. While waiting for other processors to finish, poll the task queues and resume processing if there is any task */ LOCK(global->pbar_lock); /* Reset the barrier counter if not initialized */ if( global->pbar_count >= n_processors ) global->pbar_count = 0 ; /* Increment the counter */ global->pbar_count++ ; UNLOCK(global->pbar_lock); /* barrier spin-wait loop */ while( global->pbar_count < n_processors ) { /* Wait for a while and then retry dequeue */ if( _process_task_wait_loop() ) break ; /* Waited for a while but other processors are still running. Poll the task queue again */ t = DEQUEUE_TASK( taskqueue_id[process_id], QUEUES_VISITED, process_id ) ; if( t ) { /* Task found. Exit the barrier and work on it */ LOCK(global->pbar_lock); global->pbar_count-- ; UNLOCK(global->pbar_lock); goto retry_entry ; } } BARRIER(global->barrier, n_processors); }