/** * Initialize buffer and start MPI benchmark */ int network_bandwidth_test(mpi_test_t arg) { unsigned_huge data_size = arg.data_size; unsigned_huge array_length = data_size / sizeof(TYPE); if((int)array_length < 0) { _printf("network_bandwidth_test has got invalid argument %d\n", data_size); _printf("(MPI_Send / MPI_Recv convert to int negative)\n"); return -1; } arg.array_length = array_length; MPI_Status status; TYPE *buffer; unsigned_huge bytes_sent = array_length * sizeof(TYPE); buffer = (TYPE *) malloc(bytes_sent); if(buffer == NULL) { char *size_str = sprint_num_bytes(bytes_sent); _printf("network_bandwidth_test: cannot allocate %Lu bytes (%s) for buffer\n", bytes_sent, size_str); free(size_str); return -1; } arg.buffer = buffer; soft_barrier(MPI_COMM_WORLD, 1000); unsigned repetitions = mpi_calculate_repetitions(arg); unsigned long steps = mpi_calculate_steps(arg); arg.steps = steps; char *data_size_str = sprint_num_bytes(bytes_sent); double time; unsigned_huge r; statistic_t network_bandwidth = STATISTIC_T_INIT; statistic_t network_time = STATISTIC_T_INIT; if(world_size >= arg.processes) { for(r=0; r<config.warmup; r++) { arg.testfn(&arg); } for(r=0; r<repetitions; r++) { time = arg.testfn(&arg); time /= steps; double bandwidth = ((double) (bytes_sent)) / MB / time; calculate_statistics_iterative(&network_bandwidth, bandwidth); calculate_statistics_iterative(&network_time, time); } } if(world_rank == 0) { print_table_cell("%{world size}5d, ", world_size); print_table_cell("%{processes}5d, ", arg.processes); print_table_cell("%{repetitions}5d, ", repetitions); print_table_cell("%{steps}10Lu, ", steps); print_table_cell("%{datasize}10Lu, ", data_size); print_table_cell("%{bytes}6s, ", data_size_str); print_table_cell("%{bandwidth}" PRECISSION "f, ", network_bandwidth.mean); print_table_cell("%{bandwidth deviation}" PRECISSION "f, ", network_bandwidth.deviation); print_table_cell("%{time}" PRECISSION "f, ", network_time.mean); print_table_cell("%{time deviation}" PRECISSION "f, ", network_time.deviation); print_table_line(); } free(data_size_str); free(buffer); //free(results); return 0; }
/** * Creates the content file. This is where most of the text (and the * code) actually resides. It is also the only file creation routine so * far that actually uses the data it is supplied with. * \param data A \a spreadconv_data structure from which to draw * information * \return 0 on success, -1 on error */ static int create_content_file(struct spreadconv_data *data) { FILE *f; int i, j; f = fopen("content.xml", "w"); if (f == 0) return -1; fprintf(f, "<?xml version=\"1.0\"?>\n"); fprintf(f, "<office:document-content "); print_namespaces(f); fprintf(f, ">\n"); /* print style information */ fprintf(f, "<office:automatic-styles>\n"); for (i=0; i<data->n_unique_rc_styles; i++) print_rc_style(&data->unique_rc_styles[i], f); for (i=0; i<data->n_unique_cell_styles; i++) print_cell_style(&data->unique_cell_styles[i], f); fprintf(f, "</office:automatic-styles>\n"); /* print the actual spreadsheet */ fprintf(f, "<office:body>\n"); fprintf(f, "<office:spreadsheet>\n"); /* avoid printing garbage if data->name is NULL */ if (data->name == 0) data->name = strdup("Sheet 1"); fprintf(f, "<table:table table:name=\"%s\">\n", data->name); /* print the columns */ for (i=0; i<data->n_cols; i++) { fprintf(f, "<table:table-column "); if (data->col_styles[i] != 0) { fprintf(f, "table:style-name=\""); print_escaped(f, data->col_styles[i]->name); fprintf(f, "\" "); } fprintf(f, "/>\n"); } /* print the rows, each with the associated cells */ for (i=0; i<data->n_rows; i++) { fprintf(f, "<table:table-row "); if (data->row_styles[i] != 0) { fprintf(f, "table:style-name=\""); print_escaped(f, data->row_styles[i]->name); fprintf(f, "\" "); } fprintf(f, ">\n"); for (j=0; j<data->n_cols; j++) print_table_cell(&data->cells[i][j], f); fprintf(f, "</table:table-row>\n"); } fprintf(f, "</table:table>\n"); fprintf(f, "</office:spreadsheet>\n"); fprintf(f, "</office:body>\n"); fprintf(f, "</office:document-content>\n"); fclose(f); return 0; }