void createabunch(struct count_log_data *log) { char filename[1024]; unsigned int count_recent = 0; unsigned int count_total = 0; unsigned int count_limit; unsigned int count_total_aggregate; time_t start; unsigned int current_timeindex = 0; unsigned int elapsed; int fd; if (args.file_count_set) { count_limit = args.file_count / mpi_size; if (mpi_rank < (args.file_count % mpi_size)) count_limit += 1; } MPI_Barrier(MPI_COMM_WORLD); start = time(NULL); while (1) { /* create the file */ snprintf(filename, 1024, "%s/many-%d-%d", args.test_directory_name, mpi_rank, count_total); fd = open(filename, O_CREAT|O_WRONLY|O_TRUNC|O_EXCL, S_IRUSR|S_IWUSR); close(fd); count_recent++; count_total++; /* log creation count at most once per second */ current_timeindex = timeindex(start); if (current_timeindex >= log->entries) { record_entry(log, current_timeindex, count_recent); count_recent = 0; } /* end conditions */ if (args.time_limit_set && current_timeindex > args.time_limit) break; if (args.file_count_set && count_total >= count_limit) { /* tally left over counts */ record_entry(log, current_timeindex, count_recent); break; } }; MPI_Barrier(MPI_COMM_WORLD); elapsed = timeindex(start); MPI_Reduce(&count_total, &count_total_aggregate, 1, MPI_UNSIGNED, MPI_SUM, 0, MPI_COMM_WORLD); if (mpi_rank == 0) { printf ("Created %d total files in %d secs (%d per sec)\n", count_total_aggregate, elapsed, count_total_aggregate/elapsed); } }
static void compile_database_entry(repo_t *repo, db_writer_t *writer, alpm_pkg_meta_t *pkg, int contents) { char entry[PATH_MAX]; snprintf(entry, PATH_MAX, "%s-%s", pkg->name, pkg->version); if (contents & DB_DESC) { compile_desc_entry(repo, pkg, &writer->buf); record_entry(writer, entry, "desc"); } if (contents & DB_DEPENDS) { compile_depends_entry(pkg, &writer->buf); record_entry(writer, entry, "depends"); } if (contents & DB_FILES) { compile_files_entry(repo, pkg, &writer->buf); record_entry(writer, entry, "files"); } }
static void varh(PA_variable *pp) {char *s, *pname, bf[MAXLINE]; int first, size; double tmax; pname = PA_VARIABLE_NAME(pp); conversion_s = 1.0/PA_VARIABLE_EXT_UNIT(pp); /* get the information off the command line */ tmax = PA_get_num_field("TMAX", "VARIABLE", REQU); size = PA_get_num_field("SIZE", "VARIABLE", REQU); /* allocate storage for the data */ data = CMAKE_N(double, size); count = 0; var_sz = size; /* cat the variable name and the indexes together to make a unique label */ first = TRUE; SC_strncpy(bf, MAXLINE, pname, -1); while ((s = PA_get_field("INDEX", "VARIABLE", OPTL)) != NULL) {if (!first) SC_strcat(bf, MAXLINE, ","); else SC_strcat(bf, MAXLINE, "("); SC_strcat(bf, MAXLINE, s); first = FALSE;}; if (!first) SC_strcat(bf, MAXLINE, ")"); /* record this entry */ record_entry(bf, tmax, data); return;}