static int task_consider( int x, int y ) { char command[WAVEFRONT_LINE_MAX]; char tag[WAVEFRONT_LINE_MAX]; struct work_queue_task* t; if(x>=xsize) return 1; if(y>=ysize) return 1; if(text_array_get(array,x,y)) return 0; const char *left = text_array_get(array,x-1,y); const char *bottom = text_array_get(array,x,y-1); const char *diag = text_array_get(array,x-1,y-1); if(!left || !bottom || !diag) return 1; sprintf(command,"./%s %d %d xfile yfile dfile",function,x,y); sprintf(tag,"%d %d",x,y); t = work_queue_task_create(command); work_queue_task_specify_tag(t,tag); work_queue_task_specify_input_file(t, function, function); work_queue_task_specify_input_buf(t, left, strlen(left), "xfile"); work_queue_task_specify_input_buf(t, bottom, strlen(bottom), "yfile"); work_queue_task_specify_input_buf(t, diag, strlen(diag), "dfile"); work_queue_submit(queue,t); return 1; }
static void task_submit(struct work_queue *q, int curr_rect_x, int curr_rect_y) { struct work_queue_task *t; char rname_x[32]; char rname_y[32]; char cmd[255]; char fname_x[255]; char fname_y[255]; char tag[32]; sprintf(tag, "%03d-%03d", curr_rect_y, curr_rect_x); sprintf(rname_x, "rect%03d.cfa", curr_rect_x); if(curr_rect_x != curr_rect_y) { sprintf(rname_y, "rect%03d.cfa", curr_rect_y); } else { sprintf(rname_y, "%s", ""); } sprintf(cmd, "./%s %s %s %s", filter_program_name, filter_program_args, rname_x, rname_y); // Create the task. t = work_queue_task_create(cmd); // Specify the tag for this task. Used for identifying which // ones are done. work_queue_task_specify_tag(t, tag); // Send the executable, if it's not already there. work_queue_task_specify_file(t, filter_program_path, filter_program_name, WORK_QUEUE_INPUT, WORK_QUEUE_CACHE); // Send the repeat file if we need it and it's not already there. if(repeat_filename) work_queue_task_specify_file(t, repeat_filename, string_basename(repeat_filename), WORK_QUEUE_INPUT, WORK_QUEUE_CACHE); // Add the rectangle. Add it as staged, so if the worker // already has these sequences, there's no need to send them again. sprintf(fname_x, "%s/%s", outdirname, rname_x); work_queue_task_specify_file(t, fname_x, rname_x, WORK_QUEUE_INPUT, WORK_QUEUE_CACHE); if(curr_rect_x != curr_rect_y) { sprintf(fname_y, "%s/%s", outdirname, rname_y); work_queue_task_specify_file(t, fname_y, rname_y, WORK_QUEUE_INPUT, WORK_QUEUE_CACHE); } work_queue_submit(q, t); total_submitted++; debug(D_DEBUG, "Submitted task for rectangle (%d, %d)\n", curr_rect_y, curr_rect_x); }