static int check_updates(struct unpack_trees_options *o) { unsigned cnt = 0, total = 0; struct progress *progress = NULL; struct index_state *index = &o->result; int i; int errs = 0; if (o->update && o->verbose_update) { for (total = cnt = 0; cnt < index->cache_nr; cnt++) { const struct cache_entry *ce = index->cache[cnt]; if (ce->ce_flags & (CE_UPDATE | CE_WT_REMOVE)) total++; } progress = start_progress_delay(_("Checking out files"), total, 50, 1); cnt = 0; } if (o->update) git_attr_set_direction(GIT_ATTR_CHECKOUT, &o->result); for (i = 0; i < index->cache_nr; i++) { const struct cache_entry *ce = index->cache[i]; if (ce->ce_flags & CE_WT_REMOVE) { display_progress(progress, ++cnt); if (o->update && !o->dry_run) unlink_entry(ce); continue; } } remove_marked_cache_entries(&o->result); remove_scheduled_dirs(); for (i = 0; i < index->cache_nr; i++) { struct cache_entry *ce = index->cache[i]; if (ce->ce_flags & CE_UPDATE) { if (ce->ce_flags & CE_WT_REMOVE) die("BUG: both update and delete flags are set on %s", ce->name); display_progress(progress, ++cnt); ce->ce_flags &= ~CE_UPDATE; if (o->update && !o->dry_run) { errs |= checkout_entry(ce, &state, NULL); } } } stop_progress(&progress); if (o->update) git_attr_set_direction(GIT_ATTR_CHECKIN, NULL); return errs != 0; }
void prune_packed_objects(int opts) { int i; static char pathname[PATH_MAX]; const char *dir = get_object_directory(); int len = strlen(dir); if (opts == VERBOSE) progress = start_progress_delay("Removing duplicate objects", 256, 95, 2); if (len > PATH_MAX - 42) die("impossible object directory"); memcpy(pathname, dir, len); if (len && pathname[len-1] != '/') pathname[len++] = '/'; for (i = 0; i < 256; i++) { DIR *d; display_progress(progress, i + 1); sprintf(pathname + len, "%02x/", i); d = opendir(pathname); if (!d) continue; prune_dir(i, d, pathname, len + 3, opts); closedir(d); } stop_progress(&progress); }
// // Consumer thread for testfile creation and verification. // void* consumer_fn(void* param) { workorder* wo = (workorder*) param; workqueue* q = wo->q; uint32_t shiftreg = PRBS23_INITIAL_VALUE; off_t progress = 0; long int found_corruption = 0; init_progress_display(wo->filesize * sizeof(uint32_t)); while (1) { wbuf* workbuf = (wbuf*) q->dequeue(); if (workbuf->buflen == 0) { q->release(workbuf); break; } if (wo->mode == VERIFY) { checkbuf(workbuf->buf, workbuf->buflen, shiftreg, found_corruption, progress, wo->bmode); } else { uint writtenbytes = 0; do { writtenbytes += write(wo->fd, workbuf->buf+writtenbytes, workbuf->buflen * sizeof(uint32_t) - writtenbytes); } while (writtenbytes < workbuf->buflen * sizeof(uint32_t)); } progress += (workbuf->buflen * sizeof(uint32_t)); q->release(workbuf); display_progress(progress); } return ((void*) found_corruption); }
static void prune_dir(int i, DIR *dir, char *pathname, int len, int opts) { struct dirent *de; char hex[40]; sprintf(hex, "%02x", i); while ((de = readdir(dir)) != NULL) { unsigned char sha1[20]; if (strlen(de->d_name) != 38) continue; memcpy(hex+2, de->d_name, 38); if (get_sha1_hex(hex, sha1)) continue; if (!has_sha1_pack(sha1)) continue; memcpy(pathname + len, de->d_name, 38); if (opts & DRY_RUN) printf("rm -f %s\n", pathname); else if (unlink(pathname) < 0) error("unable to unlink %s", pathname); display_progress(progress, i + 1); } pathname[len] = 0; rmdir(pathname); }
void bitmap_writer_select_commits(struct commit **indexed_commits, unsigned int indexed_commits_nr, int max_bitmaps) { unsigned int i = 0, j, next; qsort(indexed_commits, indexed_commits_nr, sizeof(indexed_commits[0]), date_compare); if (writer.show_progress) writer.progress = start_progress("Selecting bitmap commits", 0); if (indexed_commits_nr < 100) { for (i = 0; i < indexed_commits_nr; ++i) push_bitmapped_commit(indexed_commits[i], NULL); return; } for (;;) { struct ewah_bitmap *reused_bitmap = NULL; struct commit *chosen = NULL; next = next_commit_index(i); if (i + next >= indexed_commits_nr) break; if (max_bitmaps > 0 && writer.selected_nr >= max_bitmaps) { writer.selected_nr = max_bitmaps; break; } if (next == 0) { chosen = indexed_commits[i]; reused_bitmap = find_reused_bitmap(chosen->object.sha1); } else { chosen = indexed_commits[i + next]; for (j = 0; j <= next; ++j) { struct commit *cm = indexed_commits[i + j]; reused_bitmap = find_reused_bitmap(cm->object.sha1); if (reused_bitmap || (cm->object.flags & NEEDS_BITMAP) != 0) { chosen = cm; break; } if (cm->parents && cm->parents->next) chosen = cm; } } push_bitmapped_commit(chosen, reused_bitmap); i += next + 1; display_progress(writer.progress, i); } stop_progress(&writer.progress); }
static int prune_subdir(int nr, const char *path, void *data) { int *opts = data; display_progress(progress, nr + 1); if (!(*opts & PRUNE_PACKED_DRY_RUN)) rmdir(path); return 0; }
static void show_object(struct object *obj, const char *name, void *cb_data) { struct rev_list_info *info = cb_data; finish_object(obj, name, cb_data); display_progress(progress, ++progress_counter); if (info->flags & REV_LIST_QUIET) return; show_object_with_name(stdout, obj, name); }
void prune_packed_objects(int opts) { if (opts & PRUNE_PACKED_VERBOSE) progress = start_delayed_progress(_("Removing duplicate objects"), 256); for_each_loose_file_in_objdir(get_object_directory(), prune_object, NULL, prune_subdir, &opts); /* Ensure we show 100% before finishing progress */ display_progress(progress, 256); stop_progress(&progress); }
bool CommandGetParents::run() { m_vout << "Opening input file...\n"; osmium::io::Reader reader{m_input_file, get_needed_types()}; m_vout << "Opening output file...\n"; osmium::io::Header header = reader.header(); setup_header(header); osmium::io::Writer writer{m_output_file, header, m_output_overwrite, m_fsync}; m_vout << "Copying matching objects to output file...\n"; osmium::ProgressBar progress_bar{reader.file_size(), display_progress()}; while (osmium::memory::Buffer buffer = reader.read()) { progress_bar.update(reader.offset()); for (const auto& object : buffer.select<osmium::OSMObject>()) { if (m_add_self && m_ids(object.type()).get(object.positive_id())) { writer(object); continue; } if (object.type() == osmium::item_type::way) { const auto& way = static_cast<const osmium::Way&>(object); for (const auto& nr : way.nodes()) { if (m_ids(osmium::item_type::node).get(nr.positive_ref())) { writer(object); break; } } } else if (object.type() == osmium::item_type::relation) { const auto& relation = static_cast<const osmium::Relation&>(object); for (const auto& member : relation.members()) { if (m_ids(member.type()).get(member.positive_ref())) { writer(object); break; } } } } } progress_bar.done(); m_vout << "Closing output file...\n"; writer.close(); m_vout << "Closing input file...\n"; reader.close(); show_memory_used(); m_vout << "Done.\n"; return true; }
static int traverse_reachable(void) { struct progress *progress = NULL; unsigned int nr = 0; int result = 0; if (show_progress) progress = start_delayed_progress(_("Checking connectivity"), 0); while (pending.nr) { result |= traverse_one_object(object_array_pop(&pending)); display_progress(progress, ++nr); } stop_progress(&progress); return !!result; }
static uint8_t load_exec () { uint8_t ret; void (*laddr)(); int8_t done = 0; srinfo.sr_data = sr_data_buf; while (!done) { if ((ret = flash_get_srec_line (sr_buf)) != 0) return ret; if ((ret = decode_srec_line (sr_buf, &srinfo)) != 0) return ret; #ifdef VERBOSE display_progress (srec_line); #endif switch (srinfo.type) { case SREC_TYPE_0: break; case SREC_TYPE_1: case SREC_TYPE_2: case SREC_TYPE_3: memcpy ((void*)srinfo.addr, (void*)srinfo.sr_data, srinfo.dlen); break; case SREC_TYPE_5: break; case SREC_TYPE_7: case SREC_TYPE_8: case SREC_TYPE_9: laddr = (void (*)())srinfo.addr; done = 1; ret = 0; break; } } #ifdef VERBOSE print ("\r\nExecuting program starting at address: "); putnum ((uint32_t)laddr); print ("\r\n"); #endif (*laddr)(); /* We will be dead at this point */ return 0; }
static void fsck_object_dir(const char *path) { struct progress *progress = NULL; if (verbose) fprintf(stderr, "Checking object directory\n"); if (show_progress) progress = start_progress(_("Checking object directories"), 256); for_each_loose_file_in_objdir(path, fsck_loose, fsck_cruft, fsck_subdir, progress); display_progress(progress, 256); stop_progress(&progress); }
double burn_in(double* path, int n_burn, int nt, double g, double D) { /* Burn in path for n_burn reps */ int burn; int n_burn_sweeps = 100; printf("Burning in...\n"); for(burn = 0; burn < n_burn; burn++) { metropolis_update(path, g, n_burn_sweeps, nt, D); display_progress(burn, n_burn, 250); } return 0; }
/* * The blame_entry is found to be guilty for the range. * Show it in incremental output. */ static void found_guilty_entry(struct blame_entry *ent, void *data) { struct progress_info *pi = (struct progress_info *)data; if (incremental) { struct blame_origin *suspect = ent->suspect; printf("%s %d %d %d\n", oid_to_hex(&suspect->commit->object.oid), ent->s_lno + 1, ent->lno + 1, ent->num_lines); emit_one_suspect_detail(suspect, 0); write_filename_info(suspect); maybe_flush_or_die(stdout, "stdout"); } pi->blamed_lines += ent->num_lines; display_progress(pi->progress, pi->blamed_lines); }
bool CommandCheckRefs::run() { osmium::io::Reader reader{m_input_file}; osmium::ProgressBar progress_bar{reader.file_size(), display_progress()}; RefCheckHandler handler{m_vout, progress_bar, m_show_ids, m_check_relations}; while (osmium::memory::Buffer buffer = reader.read()) { progress_bar.update(reader.offset()); osmium::apply(buffer, handler); } progress_bar.done(); reader.close(); if (m_check_relations) { handler.find_missing_relations(); if (m_show_ids) { handler.show_missing_relation_ids(); } } std::cerr << "There are " << handler.node_count() << " nodes, " << handler.way_count() << " ways, and " << handler.relation_count() << " relations in this file.\n"; if (m_check_relations) { std::cerr << "Nodes in ways missing: " << handler.missing_nodes_in_ways() << "\n"; std::cerr << "Nodes in relations missing: " << handler.missing_nodes_in_relations() << "\n"; std::cerr << "Ways in relations missing: " << handler.missing_ways_in_relations() << "\n"; std::cerr << "Relations in relations missing: " << handler.missing_relations_in_relations() << "\n"; } else { std::cerr << "Nodes in ways missing: " << handler.missing_nodes_in_ways() << "\n"; } m_vout << "Memory used for indexes: " << (handler.used_memory() / (1024 * 1024)) << " MBytes\n"; show_memory_used(); m_vout << "Done.\n"; return handler.no_errors(); }
int try_format_sector (MifareTag tag, MifareClassicSectorNumber sector) { display_progress (); size_t i; for (i = 0; i < (sizeof (default_keys) / sizeof (MifareClassicKey)); i++) { MifareClassicBlockNumber block = mifare_classic_sector_last_block (sector); if ((0 == mifare_classic_connect (tag)) && (0 == mifare_classic_authenticate (tag, block, default_keys[i], MFC_KEY_A))) { if (0 == mifare_classic_format_sector (tag, sector)) { mifare_classic_disconnect (tag); return 1; } else if (EIO == errno) { err (EXIT_FAILURE, "sector %d", sector); } mifare_classic_disconnect (tag); } if ((0 == mifare_classic_connect (tag)) && (0 == mifare_classic_authenticate (tag, block, default_keys[i], MFC_KEY_B))) { if (0 == mifare_classic_format_sector (tag, sector)) { mifare_classic_disconnect (tag); return 1; } else if (EIO == errno) { err (EXIT_FAILURE, "sector %d", sector); } mifare_classic_disconnect (tag); } } sprintf(message_erreur,"No known authentication key for sector %d !", sector); return 0; }
static void show_commit(struct commit *commit, void *data) { struct rev_list_info *info = data; struct rev_info *revs = info->revs; display_progress(progress, ++progress_counter); if (info->flags & REV_LIST_QUIET) { finish_commit(commit, data); return; } graph_show_commit(revs->graph); if (revs->count) { if (commit->object.flags & PATCHSAME) revs->count_same++; else if (commit->object.flags & SYMMETRIC_LEFT) revs->count_left++; else revs->count_right++; finish_commit(commit, data); return; } if (info->show_timestamp) printf("%"PRItime" ", commit->date); if (info->header_prefix) fputs(info->header_prefix, stdout); if (!revs->graph) fputs(get_revision_mark(revs, commit), stdout); if (revs->abbrev_commit && revs->abbrev) fputs(find_unique_abbrev(commit->object.oid.hash, revs->abbrev), stdout); else fputs(oid_to_hex(&commit->object.oid), stdout); if (revs->print_parents) { struct commit_list *parents = commit->parents; while (parents) { printf(" %s", oid_to_hex(&parents->item->object.oid)); parents = parents->next; } } if (revs->children.name) { struct commit_list *children; children = lookup_decoration(&revs->children, &commit->object); while (children) { printf(" %s", oid_to_hex(&children->item->object.oid)); children = children->next; } } show_decorations(revs, commit); if (revs->commit_format == CMIT_FMT_ONELINE) putchar(' '); else putchar('\n'); if (revs->verbose_header && get_cached_commit_buffer(commit, NULL)) { struct strbuf buf = STRBUF_INIT; struct pretty_print_context ctx = {0}; ctx.abbrev = revs->abbrev; ctx.date_mode = revs->date_mode; ctx.date_mode_explicit = revs->date_mode_explicit; ctx.fmt = revs->commit_format; ctx.output_encoding = get_log_output_encoding(); ctx.color = revs->diffopt.use_color; pretty_print_commit(&ctx, commit, &buf); if (buf.len) { if (revs->commit_format != CMIT_FMT_ONELINE) graph_show_oneline(revs->graph); graph_show_commit_msg(revs->graph, stdout, &buf); /* * Add a newline after the commit message. * * Usually, this newline produces a blank * padding line between entries, in which case * we need to add graph padding on this line. * * However, the commit message may not end in a * newline. In this case the newline simply * ends the last line of the commit message, * and we don't need any graph output. (This * always happens with CMIT_FMT_ONELINE, and it * happens with CMIT_FMT_USERFORMAT when the * format doesn't explicitly end in a newline.) */ if (buf.len && buf.buf[buf.len - 1] == '\n') graph_show_padding(revs->graph); putchar(info->hdr_termination); } else { /* * If the message buffer is empty, just show * the rest of the graph output for this * commit. */ if (graph_show_remainder(revs->graph)) putchar('\n'); if (revs->commit_format == CMIT_FMT_ONELINE) putchar('\n'); } strbuf_release(&buf); } else { if (graph_show_remainder(revs->graph)) putchar('\n'); } maybe_flush_or_die(stdout, "stdout"); finish_commit(commit, data); }
int main(int argc, char* argv[]) { int x, y; char buffer[255]; FILE* file; int iteration = 0; int progress = -1; int add_headers = 0; double timer; clock_t start; if (argc < 7) { printf("Usage: %s screen_width screen_height wire_width wire_height wire_mili_voltage iteration_limit\n", argv[0]); return 1; } initialize_globals(argv); d("Simulating MPI world"); available_processes = 1; process_number = 0; wire_shift_x = (screen_width - wire_width) / 2; wire_shift_y = (screen_height - wire_height) / 2; process_board_x = sqrt(available_processes); process_board_y = available_processes / process_board_x; process_x = process_number % process_board_x; process_y = process_number / process_board_x; // printf("My rank: %d.\nMy location: %d:%d (board size: %d:%d)\n", process_number, process_x, process_y, process_board_x, process_board_y); if (process_number >= process_board_x * process_board_y) { printf("I'm out of board. Should never happen!\n"); finalize(); return 0; } d("Initiate data storage%s", "."); segment_size_x = screen_width / process_board_x + 2; segment_size_y = screen_height / process_board_y + 2; data = (double*) malloc(sizeof(double) * segment_size_x * segment_size_y); if (0 == process_number) { print_board(); } for (y = 0; y < segment_size_y; ++y) { for (x = 0; x < segment_size_x; ++x) { data[y * segment_size_x + x] = initial_voltage(x, y); } } d("Register custom MPI type (not applicable)%s", "."); start = clock(); communicate(iteration); while (iteration < iteration_limit) { d("Iterations start%s", "."); calculation(iteration); communicate(iteration); ++iteration; if (process_number == 0 && 100 * iteration / iteration_limit > progress) { progress = 100 * iteration / iteration_limit; display_progress(progress, 80); // printf("Progress: %d%% (%d of %d)\n", 5 * progress, iteration, iteration_limit); } } if (0 == process_number) { printf("\n"); } timer = (double) (clock() - start) / CLOCKS_PER_SEC; // Dump data from each process. sprintf(buffer, "data-%dx%d.txt", process_x, process_y); file = fopen(buffer, "w"); for (y = 1; y < segment_size_y - 1; ++y) { for (x = 1; x < segment_size_x - 1; ++x) { fprintf(file, "%f\t%f\t%f\n", 1.0 * (process_x * (segment_size_x - 2) + x) / screen_width, 1.0 * (process_y * (segment_size_y - 2) + y) / screen_height, data[y * segment_size_x + x] ); } fprintf(file, "\n"); } fclose(file); // Log program response. if (process_number == 0) { printf("Board size: %dx%d, iterations limit: %d, used processes: %d, elapsed time: %f\n", screen_width, screen_height, iteration_limit, available_processes, timer); if (file_exists("results.txt") == 0) { add_headers = 1; } file = fopen("results.txt", "a+"); if (add_headers) { fprintf(file, "W\tH\tmax\tproc\tT\n"); } fprintf(file, "%d\t%d\t%d\t%d\t%f\n", screen_width, screen_height, iteration_limit, available_processes, timer); fclose(file); } finalize(); return 0; }
BOOL read_usb_proc(void *arg) { char msg[128]; u32 bytes_already_read = 0; u32 data_length = *((u32*)arg); u32 bytes_read = 0; int bytes_read_once = 0; u32 bytes_left = 0; dprintf(DBG_DCACHE, "++[%d]Enter read_usb_proc\n", TIME_STAMP); while (bytes_already_read < data_length) { dprintf(DBG_DCACHE, "++[%d]Wait ID:%d cache to write\n", TIME_STAMP, ctx.flipIdxW); event_wait(&(ctx.dual_cache[ctx.flipIdxW].cache_available)); dprintf(DBG_DCACHE, "++[%d]Obtain ID:%d cache to write, \n", TIME_STAMP, ctx.flipIdxW); if(ctx.b_error) { sprintf(msg, "\nError Write?\n"); goto error; } bytes_read = 0; bytes_left = data_length - bytes_already_read; bytes_left = bytes_left >= CACHE_PAGE_SIZE ? CACHE_PAGE_SIZE : bytes_left; dprintf(DBG_DCACHE, "++[%d]READ USB to ID:%d\n", TIME_STAMP, ctx.flipIdxW); while(bytes_left > 0) { bytes_read_once = usb_read(ctx.dual_cache[ctx.flipIdxW].cache_buf + bytes_read, bytes_left); if (bytes_read_once < 0) { abort_engine(&ctx); dprintf(DBG_LV, "Read USB error.\n"); display_info("\nRead USB error\n"); fastboot_state = STATE_ERROR; return FALSE; } bytes_left -= bytes_read_once; bytes_read += bytes_read_once; } ctx.dual_cache[ctx.flipIdxW].content_length = bytes_read; bytes_already_read += bytes_read; dprintf(DBG_DCACHE, "++[%d]Notify ID:%d cache readable\n", TIME_STAMP, ctx.flipIdxW); event_signal(&ctx.dual_cache[ctx.flipIdxW].content_available, SIGNAL_RESCHEDULE); ctx.flipIdxW = cache_shift(ctx.flipIdxW); //change next buffer. display_progress("\rTransfer Data", bytes_already_read, data_length); } if(bytes_already_read != data_length) { dprintf(DBG_LV, "ASSERT error. bytes_already_read != data_length\n"); //cause assert. *((int*)0x00) = 0; } dprintf(DBG_DCACHE, "++[%d]USB read Fin\n", TIME_STAMP); //last package. //must wait for this can write again. event_wait(&(ctx.dual_cache[ctx.flipIdxW].cache_available)); ctx.dual_cache[ctx.flipIdxW].content_length = 0; event_signal(&ctx.dual_cache[ctx.flipIdxW].content_available, SIGNAL_RESCHEDULE); return TRUE; error: dprintf(DBG_LV, msg); display_info(msg); abort_engine(&ctx); return FALSE; }
int main( int argc, char *argv[] ) { signed char c; int work_queue_master_mode = WORK_QUEUE_MASTER_MODE_STANDALONE; char *project = NULL; int priority = 0; const char *progname = "wavefront"; debug_config(progname); struct option long_options[] = { {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'v'}, {"debug", required_argument, 0, 'd'}, {"advertise", no_argument, 0, 'a'}, {"project-name", required_argument, 0, 'N'}, {"debug-file", required_argument, 0, 'o'}, {"port", required_argument, 0, 'p'}, {"priority", required_argument, 0, 'P'}, {"estimated-time", required_argument, 0, 't'}, {"random-port", required_argument, 0, 'Z'}, {"bitmap", required_argument, 0, 'B'}, {0,0,0,0} }; while((c=getopt_long(argc,argv,"aB:d:hN:p:P:o:v:Z:", long_options, NULL)) >= 0) { switch(c) { case 'a': break; case 'd': debug_flags_set(optarg); break; case 'h': show_help(progname); exit(0); break; case 'N': work_queue_master_mode = WORK_QUEUE_MASTER_MODE_CATALOG; free(project); project = xxstrdup(optarg); break; case 'p': port = atoi(optarg); break; case 'P': priority = atoi(optarg); break; case 'o': debug_config_file(optarg); break; case 'v': cctools_version_print(stdout, progname); exit(0); break; case 'Z': port_file = optarg; port = 0; break; case 'B': progress_bitmap_file = optarg; break; default: show_help(progname); return 1; } } cctools_version_debug(D_DEBUG, argv[0]); if( (argc-optind)!=5 ) { show_help(progname); exit(1); } function = argv[optind]; xsize=atoi(argv[optind+1]); ysize=atoi(argv[optind+2]); infile=argv[optind+3]; outfile=argv[optind+4]; start_time = time(0); last_display_time = 0; cells_total = xsize*ysize; xsize++; ysize++; array = text_array_create(xsize,ysize); if(!text_array_load(array,infile)) { fprintf(stderr,"couldn't load %s: %s",infile,strerror(errno)); return 1; } int count = text_array_load(array,outfile); if(count>0) printf("recovered %d results from %s\n",count,outfile); logfile = fopen(outfile,"a"); if(!logfile) { fprintf(stderr,"couldn't open %s for append: %s\n",outfile,strerror(errno)); return 1; } if(work_queue_master_mode == WORK_QUEUE_MASTER_MODE_CATALOG && !project) { fprintf(stderr, "wavefront: wavefront master running in catalog mode. Please use '-N' option to specify the name of this project.\n"); fprintf(stderr, "wavefront: Run \"%s -h\" for help with options.\n", argv[0]); return 1; } queue = work_queue_create(port); //Read the port the queue is actually running, in case we just called //work_queue_create(LINK_PORT_ANY) port = work_queue_port(queue); if(!queue) { fprintf(stderr,"%s: could not create work queue on port %d: %s\n",progname,port,strerror(errno)); return 1; } if(port_file) opts_write_port_file(port_file, port); // advanced work queue options work_queue_specify_master_mode(queue, work_queue_master_mode); work_queue_specify_name(queue, project); work_queue_specify_priority(queue, priority); fprintf(stdout, "%s: listening for workers on port %d...\n",progname,work_queue_port(queue)); if(progress_bitmap_file) { bmap = bitmap_create(xsize,ysize); wavefront_bitmap_initialize(bmap); } task_prime(); struct work_queue_task *t; while(1) { if(time(0)!=last_display_time) display_progress(queue); t = work_queue_wait(queue,WORK_QUEUE_WAITFORTASK); if(!t) break; if(t->return_status==0) { int x,y; if(sscanf(t->tag,"%d %d",&x,&y)==2) { text_array_set(array,x,y,t->output); task_complete(x,y); fprintf(logfile,"%d %d %s\n",x,y,t->output); fflush(logfile); tasks_done++; } else { fprintf(stderr,"unexpected output: %s\nfrom command: %s\non host: %s",t->output,t->command_line,t->host); } } else { fprintf(stderr,"function failed return value (%i) result (%i) on host %s. output:\n%s\n",t->return_status,t->result,t->host,t->output); } work_queue_task_delete(t); if(work_queue_empty(queue)) break; } display_progress(queue); return 0; }
int main( int argc, char *argv[] ) { char c; const char *progname = "wavefront"; debug_config(progname); while((c=getopt(argc,argv,"p:Pd:o:vh"))!=(char)-1) { switch(c) { case 'p': port = atoi(optarg); break; case 'd': debug_flags_set(optarg); break; case 'o': debug_config_file(optarg); break; case 'v': show_version(progname); exit(0); break; case 'h': show_help(progname); exit(0); break; } } if( (argc-optind)!=5 ) { show_help(progname); exit(1); } function = argv[optind]; xsize=atoi(argv[optind+1]); ysize=atoi(argv[optind+2]); infile=argv[optind+3]; outfile=argv[optind+4]; start_time = time(0); last_display_time = 0; cells_total = xsize*ysize; xsize++; ysize++; array = text_array_create(xsize,ysize); if(!text_array_load(array,infile)) { fprintf(stderr,"couldn't load %s: %s",infile,strerror(errno)); return 1; } int count = text_array_load(array,outfile); if(count>0) printf("recovered %d results from %s\n",count,outfile); logfile = fopen(outfile,"a"); if(!logfile) { fprintf(stderr,"couldn't open %s for append: %s\n",outfile,strerror(errno)); return 1; } queue = work_queue_create(port); task_prime(); struct work_queue_task *t; while(1) { if(time(0)!=last_display_time) display_progress(queue); t = work_queue_wait(queue,WORK_QUEUE_WAITFORTASK); if(!t) break; if(t->return_status==0) { int x,y; if(sscanf(t->tag,"%d %d",&x,&y)==2) { text_array_set(array,x,y,t->output); task_complete(x,y); fprintf(logfile,"%d %d %s\n",x,y,t->output); fflush(logfile); tasks_done++; } else { fprintf(stderr,"unexpected output: %s\nfrom command: %s\non host: %s",t->output,t->command_line,t->host); } } else { fprintf(stderr,"function failed return value (%i) result (%i) on host %s. output:\n%s\n",t->return_status,t->result,t->host,t->output); } work_queue_task_delete(t); if(work_queue_empty(queue)) break; } display_progress(queue); return 0; }
void resolve_tree_islands(struct repository *r, int progress, struct packing_data *to_pack) { struct progress *progress_state = NULL; struct tree_islands_todo *todo; int nr = 0; int i; if (!island_marks) return; /* * We process only trees, as commits and tags have already been handled * (and passed their marks on to root trees, as well. We must make sure * to process them in descending tree-depth order so that marks * propagate down the tree properly, even if a sub-tree is found in * multiple parent trees. */ ALLOC_ARRAY(todo, to_pack->nr_objects); for (i = 0; i < to_pack->nr_objects; i++) { if (oe_type(&to_pack->objects[i]) == OBJ_TREE) { todo[nr].entry = &to_pack->objects[i]; todo[nr].depth = oe_tree_depth(to_pack, &to_pack->objects[i]); nr++; } } QSORT(todo, nr, tree_depth_compare); if (progress) progress_state = start_progress(_("Propagating island marks"), nr); for (i = 0; i < nr; i++) { struct object_entry *ent = todo[i].entry; struct island_bitmap *root_marks; struct tree *tree; struct tree_desc desc; struct name_entry entry; khiter_t pos; pos = kh_get_sha1(island_marks, ent->idx.oid.hash); if (pos >= kh_end(island_marks)) continue; root_marks = kh_value(island_marks, pos); tree = lookup_tree(r, &ent->idx.oid); if (!tree || parse_tree(tree) < 0) die(_("bad tree object %s"), oid_to_hex(&ent->idx.oid)); init_tree_desc(&desc, tree->buffer, tree->size); while (tree_entry(&desc, &entry)) { struct object *obj; if (S_ISGITLINK(entry.mode)) continue; obj = lookup_object(r, entry.oid->hash); if (!obj) continue; set_island_marks(obj, root_marks); } free_tree_buffer(tree); display_progress(progress_state, i+1); } stop_progress(&progress_state); free(todo); }
int main(int argc, char **argv) { debug_config(progname); // By default, turn on fast abort option since we know each job is of very similar size (in terms of runtime). // One can also set the fast_abort_multiplier by the '-f' option. wq_option_fast_abort_multiplier = 10; get_options(argc, argv, progname); outfile = fopen(outfilename, "a+"); if(!outfile) { fprintf(stderr, "%s: couldn't open %s: %s\n", progname, outfilename, strerror(errno)); exit(1); } if(!find_executable(filter_program_name, "PATH", filter_program_path, sizeof(filter_program_path))) { fprintf(stderr, "%s: couldn't find %s in your PATH.\n", progname, filter_program_path); exit(1); } if(work_queue_master_mode == WORK_QUEUE_MASTER_MODE_CATALOG && !project) { fprintf(stderr, "sand_filter: sand filter master running in catalog mode. Please use '-N' option to specify the name of this project.\n"); fprintf(stderr, "sand_filter: Run \"%s -h\" for help with options.\n", argv[0]); return 1; } q = work_queue_create(port); if(!q) { fprintf(stderr, "%s: couldn't listen on port %d: %s\n", progname, port, strerror(errno)); exit(1); } port = work_queue_port(q); if(port_file) { opts_write_port_file(port_file,port); } // advanced work queue options work_queue_specify_master_mode(q, work_queue_master_mode); work_queue_specify_name(q, project); work_queue_specify_priority(q, priority); load_sequences(sequence_filename); debug(D_DEBUG, "Sequence loaded.\n", curr_rect_y, curr_rect_x); init_checkpoint(); start_time = time(0); int curr_start_x = 0, curr_start_y = 0, curr_rect_x = 0, curr_rect_y = 0; while(1) { while(work_queue_hungry(q)) { if(curr_start_y >= num_seqs) break; display_progress(); if(checkpoint[curr_rect_y][curr_rect_x] != CHECKPOINT_STATUS_SUCCESS) task_submit(q, curr_rect_x, curr_rect_y); // Increment the x rectangle curr_rect_x++; curr_start_x += rectangle_size; // If we've reached the end of a row, move to the // next row by incrementing the y rectangle. if(curr_start_x >= num_seqs) { curr_rect_y++; curr_start_y += rectangle_size; curr_rect_x = curr_rect_y; curr_start_x = curr_rect_x * rectangle_size; } } if(work_queue_empty(q) && curr_start_y >= num_seqs) break; struct work_queue_task *t = work_queue_wait(q, 5); if(t) task_complete(t); display_progress(); } printf("%s: candidates generated: %lu\n", progname, cand_count); if(checkpoint_file) { fclose(checkpoint_file); } fprintf(outfile, "EOF\n"); fclose(outfile); work_queue_delete(q); if(!do_not_unlink) delete_dir(outdirname); return 0; }
void bitmap_writer_build(struct packing_data *to_pack) { static const double REUSE_BITMAP_THRESHOLD = 0.2; int i, reuse_after, need_reset; struct bitmap *base = bitmap_new(); struct rev_info revs; writer.bitmaps = kh_init_sha1(); writer.to_pack = to_pack; if (writer.show_progress) writer.progress = start_progress("Building bitmaps", writer.selected_nr); init_revisions(&revs, NULL); revs.tag_objects = 1; revs.tree_objects = 1; revs.blob_objects = 1; revs.no_walk = 0; revs.include_check = should_include; reset_revision_walk(); reuse_after = writer.selected_nr * REUSE_BITMAP_THRESHOLD; need_reset = 0; for (i = writer.selected_nr - 1; i >= 0; --i) { struct bitmapped_commit *stored; struct object *object; khiter_t hash_pos; int hash_ret; stored = &writer.selected[i]; object = (struct object *)stored->commit; if (stored->bitmap == NULL) { if (i < writer.selected_nr - 1 && (need_reset || !in_merge_bases(writer.selected[i + 1].commit, stored->commit))) { bitmap_reset(base); reset_all_seen(); } add_pending_object(&revs, object, ""); revs.include_check_data = base; if (prepare_revision_walk(&revs)) die("revision walk setup failed"); traverse_commit_list(&revs, show_commit, show_object, base); revs.pending.nr = 0; revs.pending.alloc = 0; revs.pending.objects = NULL; stored->bitmap = bitmap_to_ewah(base); need_reset = 0; } else need_reset = 1; if (i >= reuse_after) stored->flags |= BITMAP_FLAG_REUSE; hash_pos = kh_put_sha1(writer.bitmaps, object->sha1, &hash_ret); if (hash_ret == 0) die("Duplicate entry when writing index: %s", sha1_to_hex(object->sha1)); kh_value(writer.bitmaps, hash_pos) = stored; display_progress(writer.progress, writer.selected_nr - i); } bitmap_free(base); stop_progress(&writer.progress); compute_xor_offsets(); }
static int fsck_subdir(unsigned int nr, const char *path, void *progress) { display_progress(progress, nr + 1); return 0; }
CCFILEH ccfile_open(const char *fname) { CCFILEH ret; CCFILEH cc; CCFILEH stc; int fd; ret = NULL; stc = NULL; cc = fh; for (int i=0; i<DATACACHES; ++i) { if (!milstr_cmp(cc->name, fname)) { ret = cc; break; } cc++; } if (ret == NULL) { stc = (CCFILEH)&fh[stc_index++]; stc_index &= (DATACACHES-1); } if ((ret == NULL) && (stc != NULL)) { fd = open(fname,O_RDONLY); if (fd < 0) { goto cc_err1; } stc->size = file_size(fd); file_cpyname(stc->name, fname, MAX_PATH); if (stc->size > DATACACHESIZE) { goto cc_err2; } soundmng_stop(); long pos = 0; unsigned int size = stc->size; unsigned int len = size/256; ZeroMemory(stc->ptr, DATACACHESIZE); int n = 0; while (size > 0) { int r = pread(fd, stc->ptr + pos, len, pos); display_progress(n, 256); ++n; pos += r; size -= r; } soundmng_play(); close(fd); uLong adler; adler = adler32(0L, Z_NULL, 0); stc->id = adler32(adler, stc->ptr, stc->size); loadSaveDatafromVmu(stc->id); patchSaveData(stc->id, stc->ptr); ret = stc; } ret->pos = 0; return ret; cc_err2: close(fd); cc_err1: return NULL; }
bool CommandSort::run_single_pass() { std::vector<osmium::memory::Buffer> data; osmium::ObjectPointerCollection objects; osmium::Box bounding_box; uint64_t buffers_count = 0; uint64_t buffers_size = 0; uint64_t buffers_capacity = 0; m_vout << "Reading contents of input files...\n"; osmium::ProgressBar progress_bar{file_size_sum(m_input_files), display_progress()}; for (const std::string& file_name : m_filenames) { osmium::io::Reader reader{file_name, osmium::osm_entity_bits::object}; osmium::io::Header header{reader.header()}; bounding_box.extend(header.joined_boxes()); while (osmium::memory::Buffer buffer = reader.read()) { ++buffers_count; buffers_size += buffer.committed(); buffers_capacity += buffer.capacity(); progress_bar.update(reader.offset()); osmium::apply(buffer, objects); data.push_back(std::move(buffer)); } progress_bar.file_done(reader.file_size()); reader.close(); } progress_bar.done(); m_vout << "Number of buffers: " << buffers_count << "\n"; const auto buffers_size_rounded = static_cast<double>(buffers_size / (1000 * 1000)) / 1000; // NOLINT(bugprone-integer-division) m_vout << "Sum of buffer sizes: " << buffers_size << " (" << buffers_size_rounded << " GB)\n"; const auto buffers_capacity_rounded = static_cast<double>(buffers_capacity / (1000 * 1000)) / 1000; // NOLINT(bugprone-integer-division) if (buffers_capacity != 0) { const auto fill_factor = std::round(100 * static_cast<double>(buffers_size) / static_cast<double>(buffers_capacity)); m_vout << "Sum of buffer capacities: " << buffers_capacity << " (" << buffers_capacity_rounded << " GB, " << fill_factor << "% full)\n"; } else { m_vout << "Sum of buffer capacities: 0 (0 GB)\n"; } m_vout << "Opening output file...\n"; osmium::io::Header header; setup_header(header); if (bounding_box) { header.add_box(bounding_box); } osmium::io::Writer writer{m_output_file, header, m_output_overwrite, m_fsync}; m_vout << "Sorting data...\n"; objects.sort(osmium::object_order_type_id_version()); m_vout << "Writing out sorted data...\n"; auto out = osmium::io::make_output_iterator(writer); std::copy(objects.begin(), objects.end(), out); m_vout << "Closing output file...\n"; writer.close(); show_memory_used(); m_vout << "Done.\n"; return true; }
static void update_progress(struct connectivity_progress *cp) { cp->count++; if ((cp->count & 1023) == 0) display_progress(cp->progress, cp->count); }
/*********************************************************************** * Procedure: * main - start of afterstep ************************************************************************/ int main (int argc, char **argv, char **envp) { register int i ; int start_viewport_x = 0 ; int start_viewport_y = 0 ; int start_desk = 0 ; #ifdef LOCAL_DEBUG #if 0 LOCAL_DEBUG_OUT( "calibrating sleep_a_millisec : %s","" ); for( i = 0 ; i < 500 ; ++i ) sleep_a_millisec( 10 ); LOCAL_DEBUG_OUT( "500 sliip_a_millisec(10) completed%s","" ); for( i = 0 ; i < 50 ; ++i ) sleep_a_millisec( 100 ); LOCAL_DEBUG_OUT( "50 sliip_a_millisec(100) completed%s","" ); for( i = 0 ; i < 10 ; ++i ) sleep_a_millisec( 300 ); LOCAL_DEBUG_OUT( "10 sliip_a_millisec(300) completed%s","" ); #endif #endif _as_grab_screen_func = GrabEm; _as_ungrab_screen_func = UngrabEm; original_DISPLAY_string = getenv("DISPLAY"); if (original_DISPLAY_string) original_DISPLAY_string = mystrdup(original_DISPLAY_string); #ifdef DEBUG_TRACE_X trace_window_id2name_hook = &window_id2name; #endif set_DeadPipe_handler(DeadPipe); #if !HAVE_DECL_ENVIRON override_environ( envp ); #endif InitMyApp( CLASS_AFTERSTEP, argc, argv, NULL, AfterStep_usage, 0); LinkAfterStepConfig(); AfterStepState = MyArgs.flags ; clear_flags( AfterStepState, ASS_NormalOperation ); set_flags( AfterStepState, ASS_SuppressDeskBack ); #ifdef __CYGWIN__ CloseOnExec = ASCloseOnExec ; #endif #if defined(LOG_FONT_CALLS) fprintf (stderr, "logging font calls now\n"); #endif /* These signals are mandatory : */ signal (SIGUSR1, Restart); /* These signals we would like to handle only if those are not handled already (by debugger): */ IgnoreSignal(SIGINT); IgnoreSignal(SIGHUP); IgnoreSignal(SIGQUIT); IgnoreSignal(SIGTERM); if( ConnectX( ASDefaultScr, AS_ROOT_EVENT_MASK ) < 0 ) { show_error( "Hostile X server encountered - unable to proceed :-("); return 1;/* failed to accure window management selection - other wm is running */ } ASDBus_fd = asdbus_init(); XSetWindowBackground( dpy, Scr.Root, Scr.asv->black_pixel ); Scr.Look.desktop_animation_tint = get_random_tint_color(); cover_desktop(); if( get_flags( AfterStepState, ASS_Restarting )) { show_progress( "AfterStep v.%s is restarting ...", VERSION ); display_progress( True, "AfterStep v.%s is restarting ...", VERSION ); }else { show_progress( "AfterStep v.%s is starting up ...", VERSION ); display_progress( True, "AfterStep v.%s is starting up ...", VERSION ); } if (ASDBus_fd>=0) { show_progress ("Successfuly accured System DBus connection."); asdbus_RegisterSMClient(SMClientID_string); } SHOW_CHECKPOINT; InitSession(); SHOW_CHECKPOINT; XSync (dpy, 0); SHOW_CHECKPOINT; set_parent_hints_func( afterstep_parent_hints_func ); /* callback for collect_hints() */ SHOW_CHECKPOINT; SetupModules(); SHOW_CHECKPOINT; SetupScreen(); SHOW_CHECKPOINT; event_setup( True /*Bool local*/ ); SHOW_CHECKPOINT; /* * Lets init each and every screen separately : */ for (i = 0; i < Scr.NumberOfScreens; i++) { show_progress( "Initializing screen %d ...", i ); display_progress( True, "Initializing screen %d ...", i ); if (i != Scr.screen) { if( !get_flags(MyArgs.flags, ASS_SingleScreen) ) { int pid = spawn_child( MyName, (i<MAX_USER_SINGLETONS_NUM)?i:-1, i, NULL, None, C_NO_CONTEXT, True, True, NULL ); if( pid >= 0 ) show_progress( "\t instance of afterstep spawned with pid %d.", pid ); else show_error( "failed to launch instance of afterstep to handle screen #%d", i ); } }else { make_screen_envvars(ASDefaultScr); putenv (Scr.rdisplay_string); putenv (Scr.display_string); if( is_output_level_under_threshold( OUTPUT_LEVEL_PROGRESS ) ) { show_progress( "\t screen[%d].size = %ux%u", Scr.screen, Scr.MyDisplayWidth, Scr.MyDisplayHeight ); display_progress( True, " screen[%d].size = %ux%u", Scr.screen, Scr.MyDisplayWidth, Scr.MyDisplayHeight ); show_progress( "\t screen[%d].root = %lX", Scr.screen, Scr.Root ); show_progress( "\t screen[%d].color_depth = %d", Scr.screen, Scr.asv->true_depth ); display_progress( True, " screen[%d].color_depth = %d", Scr.screen, Scr.asv->true_depth ); show_progress( "\t screen[%d].colormap = 0x%lX", Scr.screen, Scr.asv->colormap ); show_progress( "\t screen[%d].visual.id = %X", Scr.screen, Scr.asv->visual_info.visualid ); display_progress( True, " screen[%d].visual.id = %X", Scr.screen, Scr.asv->visual_info.visualid ); show_progress( "\t screen[%d].visual.class = %d", Scr.screen, Scr.asv->visual_info.class ); display_progress( True, " screen[%d].visual.class = %d", Scr.screen, Scr.asv->visual_info.class ); show_progress( "\t screen[%d].visual.red_mask = 0x%8.8lX", Scr.screen, Scr.asv->visual_info.red_mask ); show_progress( "\t screen[%d].visual.green_mask = 0x%8.8lX", Scr.screen, Scr.asv->visual_info.green_mask ); show_progress( "\t screen[%d].visual.blue_mask = 0x%8.8lX", Scr.screen, Scr.asv->visual_info.blue_mask ); show_progress( "\t screen[%d].rdisplay_string = \"%s\"", Scr.screen, Scr.rdisplay_string ); show_progress( "\t screen[%d].display_string = \"%s\"", Scr.screen, Scr.display_string ); display_progress( True, " screen[%d].display_string = \"%s\"", Scr.screen, Scr.display_string ); } } } /* make sure we're on the right desk, and the _WIN_DESK property is set */ Scr.CurrentDesk = INVALID_DESK ; if( get_flags( Scr.wmprops->set_props, WMC_ASDesks ) ) { start_desk = Scr.wmprops->as_current_desk ; }else if( get_flags( Scr.wmprops->set_props, WMC_DesktopCurrent ) ) { int curr = Scr.wmprops->desktop_current ; start_desk = curr; if( get_flags( Scr.wmprops->set_props, WMC_DesktopViewport ) && curr < Scr.wmprops->desktop_viewports_num ) { /* we have to do that prior to capturing any window so that they'll get in * correct position and will not end up outside of the screen */ start_viewport_x = Scr.wmprops->desktop_viewport[curr<<1] ; start_viewport_y = Scr.wmprops->desktop_viewport[(curr<<1)+1] ; } } if( get_flags( Scr.wmprops->set_props, WMC_ASViewport ) ) { start_viewport_x = Scr.wmprops->as_current_vx ; start_viewport_y = Scr.wmprops->as_current_vy ; } /* temporarily setting up desktop 0 */ ChangeDesks(0); /* Load config ... */ /* read config file, set up menus, colors, fonts */ LoadASConfig (0, PARSE_EVERYTHING); /* Reparent all the windows and setup pan frames : */ XSync (dpy, 0); /***********************************************************/ #ifndef DONT_GRAB_SERVER /* grabbed !!!!!*/ grab_server(); /* grabbed !!!!!*/ #endif /* grabbed !!!!!*/ init_screen_panframes(ASDefaultScr); /* grabbed !!!!!*/ display_progress( True, "Capturing all windows ..." ); CaptureAllWindows (ASDefaultScr); /* grabbed !!!!!*/ display_progress( False, "Done." ); check_screen_panframes(ASDefaultScr); /* grabbed !!!!!*/ ASSync( False ); #ifndef DONT_GRAB_SERVER /* grabbed !!!!!*/ ungrab_server(); /* UnGrabbed !!!!!*/ #endif /* UnGrabbed !!!!!*/ /**********************************************************/ XDefineCursor (dpy, Scr.Root, Scr.Feel.cursors[ASCUR_Default]); display_progress( True, "Seting initial viewport to %+d%+d ...", Scr.wmprops->as_current_vx, Scr.wmprops->as_current_vy ); SetupFunctionHandlers(); display_progress( True, "Processing all pending events ..." ); ConfigureNotifyLoop(); display_progress( True, "All done." ); remove_desktop_cover(); if( !get_flags(AfterStepStartupFlags, ASSF_BypassAutoexec)) DoAutoexec(get_flags( AfterStepState, ASS_Restarting)); /* once all the windows are swallowed and placed in its proper desks - we cas restore proper desktop/viewport : */ clear_flags( AfterStepState, ASS_SuppressDeskBack ); ChangeDeskAndViewport ( start_desk, start_viewport_x, start_viewport_y, False); /* all system Go! we are completely Operational! */ set_flags( AfterStepState, ASS_NormalOperation); #if (defined(LOCAL_DEBUG)||defined(DEBUG)) && defined(DEBUG_ALLOCS) LOCAL_DEBUG_OUT( "printing memory%s",""); spool_unfreed_mem( "afterstep.allocs.startup", NULL ); #endif LOCAL_DEBUG_OUT( "entering main loop%s",""); HandleEvents (); return (0); }