int processArgs(int argc, char ** argv) { int i, j, nd, prod; char *end; if (argc < 5) { printUsage (argv[0]); return 1; } strncpy(infilename, argv[1], sizeof(infilename)); strncpy(outfilename, argv[2], sizeof(outfilename)); strncpy(methodname, argv[3], sizeof(methodname)); strncpy(methodparams, argv[4], sizeof(methodparams)); nd = 0; j = 5; while (argc > j && j<11) { // get max 6 dimensions errno = 0; decomp_values[nd] = strtol(argv[j], &end, 10); if (errno || (end != 0 && *end != '\0')) { print0 ("ERROR: Invalid decomposition number in argument %d: '%s'\n", j, argv[j]); printUsage(argv[0]); return 1; } nd++; j++; } if (argc > j) { print0 ("ERROR: Only 6 decompositon arguments are supported\n"); return 1; } for (i=nd; i<10; i++) { decomp_values[i] = 1; } prod = 1; for (i=0; i<nd; i++) { prod *= decomp_values[i]; } if (prod > numproc) { print0 ("ERROR: Product of decomposition numbers %d > number of processes %d\n", prod, numproc); printUsage(argv[0]); return 1; } return 0; }
static uint32_t func_1(void) { uint32_t l_2 = 0UL; int32_t l_4[7][5] = {{0x5872D9EEL, 0x9ED9BA07L, 0x9ED9BA07L, -1L, 0x9ED9BA07L}, {0x2285FAAFL, 0x9ED9BA07L, -1L, 6L, 0x5872D9EEL}, {-1L, 0x2285FAAFL, 0x5872D9EEL, 6L, 6L}, {6L, -1L, 0x9ED9BA07L, -1L, -3L}, {6L, -1L, -1L, 0x2285FAAFL, 0x5872D9EEL}, {-1L, -1L, -1L, -3L, 0x2285FAAFL}, {0x2285FAAFL, -1L, 0x9ED9BA07L, 0x2285FAAFL, 0x2285FAAFL}}; int i; int j; l_4[2][3] = print0((l_2 < g_3) & g_3, 43); for (g_3 = print1(-27, 44); g_3 <= 17; g_3 += print2(3, 44)) { uint32_t l_23 = 0xE3D1AA12L; if (((int8_t) func_9(g_3, g_3, g_3)) << ((int8_t) 0)) { g_30[2] = print3(((int16_t) (func_19(6L || 0UL, l_23, g_14[4][0]) && 0x5CL)) << ((int16_t) l_23), 49); } else { int16_t l_37 = 1L; l_4[2][3] = print4(func_31(((((uint16_t) ((l_4[0][4] == g_30[2]) <= l_37)) - ((uint16_t) l_23)) | g_29[0][7]) <= g_3, l_2, l_4[2][3]), 54); } for (g_13 = print5(2, 56); g_13 >= 0; g_13 -= print6(1, 56)) { int32_t l_46 = -1L; int i; g_43 = print7(g_30[g_13] ^ g_30[g_13], 60); l_46 ^= print8((((int16_t) (((g_30[g_13], g_13)) <= 1UL)) - ((int16_t) g_3)) ^ g_29[1][3], 61); } } return l_4[2][3]; }
static int32_t func_1(void) { int8_t *l_10 = &g_11; int8_t **l_9[4]; int32_t *l_20 = &g_21; int i; for (i = print0(0, 48); i < 4; i++) l_9[i] = print1(&l_10, 49); *l_20 |= print2(func_2(g_12[3][1] = print3((((int8_t) ((-((uint32_t) g_7)) | g_8)) - ((int8_t) g_8), (void *) 0), 50)), 50); return *l_20; }
static int32_t func_1(void) { int8_t l_6[2]; uint8_t l_7[2][8] = {{0UL, 1UL, 255UL, 0xE0L, 1UL, 1UL, 255UL, 255UL}, {255UL, 255UL, 255UL, 0xE0L, 255UL, 255UL, 255UL, 0xE0L}}; int i; int j; for (i = print0(0, 35); i < 2; i++) l_6[i] = print1(0x20L, 36); g_8[0][0] = print2(((int16_t) (((uint16_t) l_6[0]) << ((uint16_t) l_7[1][7]))) >> ((int16_t) l_6[0]), 37); return g_8[0][1]; }
void printUsage(char *prgname) { print0("Usage: %s input output method \"params\" <decomposition>\n" " input Input stream path\n" " output Output file path\n" " method ADIOS method to write with\n" " params Write method parameters (in quotes; comma-separated list)\n" " <decomposition> list of numbers e.g. 32 8 4\n" " Decomposition values in each dimension of an array\n" " The product of these number must be less then the number\n" " of processes. Processes whose rank is higher than the\n" " product, will not write anything.\n" " Arrays with less dimensions than the number of values,\n" " will be decomposed with using the appropriate number of\n" " values.\n" ,prgname); }
static void print(const char *msg, FILE *f) { print0(f, msg); if (is_master(rank)) print0(stderr, msg); }
int processArgs(int argc, char ** argv) { int i, j, nd, prod; char *end; if (argc < 5) { printUsage (argv[0]); return 1; } strncpy(infilename, argv[1], sizeof(infilename)); strncpy(outfilename, argv[2], sizeof(outfilename)); strncpy(rmethodname, argv[3], sizeof(rmethodname)); strncpy(rmethodparams, argv[4], sizeof(rmethodparams)); strncpy(wmethodname, argv[5], sizeof(wmethodname)); strncpy(wmethodparams, argv[6], sizeof(wmethodparams)); nd = 0; j = 7; while (argc > j && j<13) { // get max 6 dimensions errno = 0; decomp_values[nd] = strtol(argv[j], &end, 10); if (errno || (end != 0 && *end != '\0')) { print0 ("ERROR: Invalid decomposition number in argument %d: '%s'\n", j, argv[j]); printUsage(argv[0]); return 1; } nd++; j++; } if (argc > j) { print0 ("ERROR: Only 6 decompositon arguments are supported\n"); return 1; } for (i=nd; i<10; i++) { decomp_values[i] = 1; } prod = 1; for (i=0; i<nd; i++) { prod *= decomp_values[i]; } if (prod > numproc) { print0 ("ERROR: Product of decomposition numbers %d > number of processes %d\n", prod, numproc); printUsage(argv[0]); return 1; } if (!strcmp(rmethodname,"BP")) { read_method = ADIOS_READ_METHOD_BP; } else if (!strcmp(rmethodname,"DATASPACES")) { read_method = ADIOS_READ_METHOD_DATASPACES; } else if (!strcmp(rmethodname,"DIMES")) { read_method = ADIOS_READ_METHOD_DIMES; } else if (!strcmp(rmethodname,"FLEXPATH")) { read_method = ADIOS_READ_METHOD_FLEXPATH; } else { print0 ("ERROR: Supported read methods are: BP, DATASPACES, DIMES, FLEXPATH. You selected %s\n", rmethodname); } if (!strcmp(rmethodparams,"")) { strcpy (rmethodparams, "max_chunk_size=100; " "app_id =32767; \n" "verbose= 3;" "poll_interval = 100;"); } return 0; }
int process_metadata(int step) { int retval = 0; int i, j; char gdims[256], ldims[256], offs[256]; uint64_t sum_count; ADIOS_VARINFO *v; // shortcut pointer if (step > 1) { // right now, nothing to prepare in later steps print("Step %d. return immediately\n",step); return 0; } /* First step processing */ // get groupname of stream, then declare for output adios_get_grouplist(f, &group_namelist); print0("Group name is %s\n", group_namelist[0]); adios_declare_group(&gh,group_namelist[0],"",adios_flag_yes); varinfo = (VarInfo *) malloc (sizeof(VarInfo) * f->nvars); if (!varinfo) { print("ERROR: rank %d cannot allocate %lu bytes\n", rank, sizeof(VarInfo)*f->nvars); return 1; } write_total = 0; largest_block = 0; // Decompose each variable and calculate output buffer size for (i=0; i<f->nvars; i++) { print0 ("Get info on variable %d: %s\n", i, f->var_namelist[i]); varinfo[i].v = adios_inq_var_byid (f, i); v = varinfo[i].v; // just a shortcut if (v == NULL) { print ("rank %d: ERROR: Variable %s inquiry failed: %s\n", rank, f->var_namelist[i], adios_errmsg()); return 1; } // print variable type and dimensions print0(" %-9s %s", adios_type_to_string(v->type), f->var_namelist[i]); if (v->ndim > 0) { print0("[%llu", v->dims[0]); for (j = 1; j < v->ndim; j++) print0(", %llu", v->dims[j]); print0("] :\n"); } else { print0("\tscalar\n"); } // determine subset we will write decompose (numproc, rank, v->ndim, v->dims, decomp_values, varinfo[i].count, varinfo[i].start, &sum_count); varinfo[i].writesize = sum_count * adios_type_size(v->type, v->value); if (varinfo[i].writesize != 0) { write_total += varinfo[i].writesize; if (largest_block < varinfo[i].writesize) largest_block = varinfo[i].writesize; } } // determine output buffer size and allocate it uint64_t bufsize = write_total + f->nvars*128 + f->nattrs*32 + 1024; if (bufsize > max_write_buffer_size) { print ("ERROR: rank %d: write buffer size needs to hold about %llu bytes, " "but max is set to %d\n", rank, bufsize, max_write_buffer_size); return 1; } print0 ("Rank %d: allocate %llu MB for output buffer\n", rank, bufsize/1048576+1); adios_allocate_buffer (ADIOS_BUFFER_ALLOC_NOW, bufsize/1048576+1); // allocate read buffer bufsize = largest_block + 128; if (bufsize > max_read_buffer_size) { print ("ERROR: rank %d: read buffer size needs to hold at least %llu bytes, " "but max is set to %d\n", rank, bufsize, max_read_buffer_size); return 1; } print0 ("Rank %d: allocate %g MB for input buffer\n", rank, (double)bufsize/1048576.0); readbuf = (char *) malloc ((size_t)bufsize); if (!readbuf) { print ("ERROR: rank %d: cannot allocate %llu bytes for read buffer\n", rank, bufsize); return 1; } // Select output method adios_select_method (gh, wmethodname, wmethodparams, ""); // Define variables for output based on decomposition char *vpath, *vname; for (i=0; i<f->nvars; i++) { v = varinfo[i].v; if (varinfo[i].writesize != 0) { // define variable for ADIOS writes getbasename (f->var_namelist[i], &vpath, &vname); if (v->ndim > 0) { int64s_to_str (v->ndim, v->dims, gdims); int64s_to_str (v->ndim, varinfo[i].count, ldims); int64s_to_str (v->ndim, varinfo[i].start, offs); print ("rank %d: Define variable path=\"%s\" name=\"%s\" " "gdims=%s ldims=%s offs=%s\n", rank, vpath, vname, gdims, ldims, offs); adios_define_var (gh, vname, vpath, v->type, ldims, gdims, offs); } else { print ("rank %d: Define scalar path=\"%s\" name=\"%s\"\n", rank, vpath, vname); adios_define_var (gh, vname, vpath, v->type, "", "", ""); } free(vpath); free(vname); } } if (rank == 0) { // get and define attributes enum ADIOS_DATATYPES attr_type; void * attr_value; char * attr_value_str; int attr_size; for (i=0; i<f->nattrs; i++) { adios_get_attr_byid (f, i, &attr_type, &attr_size, &attr_value); attr_value_str = (char *)value_to_string (attr_type, attr_value, 0); getbasename (f->attr_namelist[i], &vpath, &vname); if (vpath && !strcmp(vpath,"/__adios__")) { // skip on /__adios/... attributes print ("rank %d: Ignore this attribute path=\"%s\" name=\"%s\" value=\"%s\"\n", rank, vpath, vname, attr_value_str); } else { adios_define_attribute (gh, vname, vpath, attr_type, attr_value_str, ""); print ("rank %d: Define attribute path=\"%s\" name=\"%s\" value=\"%s\"\n", rank, vpath, vname, attr_value_str); free (attr_value); } } } return retval; }
int main (int argc, char ** argv) { int err; int steps = 0, curr_step; int retval = 0; MPI_Init (&argc, &argv); comm = MPI_COMM_WORLD; MPI_Comm_rank (comm, &rank); MPI_Comm_size (comm, &numproc); if (processArgs(argc, argv)) { return 1; } print0("Input stream = %s\n", infilename); print0("Output stream = %s\n", outfilename); print0("Read method = %s (id=%d)\n", rmethodname, read_method); print0("Read method parameters = \"%s\"\n", rmethodparams); print0("Write method = %s\n", wmethodname); print0("Write method parameters = \"%s\"\n", wmethodparams); err = adios_read_init_method(read_method, comm, "max_chunk_size=100; " "app_id =32767; \n" "verbose= 3;" "poll_interval = 100;" ); if (!err) { print0 ("%s\n", adios_errmsg()); } adios_init_noxml(comm); print0 ("Waiting to open stream %s...\n", infilename); f = adios_read_open_stream (infilename, read_method, comm, ADIOS_LOCKMODE_ALL, timeout_sec); if (adios_errno == err_file_not_found) { print ("rank %d: Stream not found after waiting %d seconds: %s\n", rank, timeout_sec, adios_errmsg()); retval = adios_errno; } else if (adios_errno == err_end_of_stream) { print ("rank %d: Stream terminated before open. %s\n", rank, adios_errmsg()); retval = adios_errno; } else if (f == NULL) { print ("rank %d: Error at opening stream: %s\n", rank, adios_errmsg()); retval = adios_errno; } else { // process steps here... if (f->current_step != 0) { print ("rank %d: WARNING: First %d steps were missed by open.\n", rank, f->current_step); } while (1) { steps++; // start counting from 1 print0 ("File info:\n"); print0 (" current step: %d\n", f->current_step); print0 (" last step: %d\n", f->last_step); print0 (" # of variables: %d:\n", f->nvars); retval = process_metadata(steps); if (retval) break; retval = read_write(steps); if (retval) break; // advance to 1) next available step with 2) blocking wait curr_step = f->current_step; // save for final bye print adios_advance_step (f, 0, timeout_sec); if (adios_errno == err_end_of_stream) { break; // quit while loop } else if (adios_errno == err_step_notready) { print ("rank %d: No new step arrived within the timeout. Quit. %s\n", rank, adios_errmsg()); break; // quit while loop } else if (f->current_step != curr_step+1) { // we missed some steps print ("rank %d: WARNING: steps %d..%d were missed when advancing.\n", rank, curr_step+1, f->current_step-1); } } adios_read_close (f); } print0 ("Bye after processing %d steps\n", steps); adios_read_finalize_method (read_method); adios_finalize (rank); MPI_Finalize (); return retval; }