#include #include #include #include /*----< main() >------------------------------------------------------------*/ int main(int argc, char **argv) { int i, err, rank, nprocs, flag; int root_striping_unit, striping_unit, root_striping_factor, striping_factor; char value[MPI_MAX_INFO_VAL]; MPI_File fh; MPI_Info info_used; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &nprocs); if (argc != 2) { printf("Usage: %s filename\n",argv[0]); MPI_Finalize(); return 1; } if (nprocs == 1) printf("Warning: this test program is designed for running on more than 1 process\n"); err = MPI_File_open(MPI_COMM_WORLD, argv[1], MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh); if (err != MPI_SUCCESS) { int errorStringLen; char errorString[MPI_MAX_ERROR_STRING]; MPI_Error_string(err, errorString, &errorStringLen); printf("Error: MPI_File_open() %s (%s)\n",argv[1], errorString); MPI_Finalize(); exit(1); } MPI_File_get_info(fh, &info_used); MPI_Info_get(info_used, "striping_unit", MPI_MAX_INFO_VAL-1, value, &flag); striping_unit = atoi(value); MPI_Info_get(info_used, "striping_factor", MPI_MAX_INFO_VAL-1, value, &flag); striping_factor = atoi(value); err = 0; root_striping_unit = striping_unit; root_striping_factor = striping_factor; MPI_Bcast(&root_striping_unit, 1, MPI_INT, 0, MPI_COMM_WORLD); MPI_Bcast(&root_striping_factor, 1, MPI_INT, 0, MPI_COMM_WORLD); if (root_striping_unit != striping_unit) { printf("Error at PE %2d: inconsistent striping_unit (root=%d local=%d)\n", rank, root_striping_unit, striping_unit); err++; } if (root_striping_factor != striping_factor) { printf("Error at PE %2d: inconsistent striping_factor (root=%d local=%d)\n", rank, root_striping_factor, striping_factor); err++; } if (err == 0 && rank == 0) printf("Success: striping_unit=%d striping_factor=%d\n",striping_unit,striping_factor); MPI_Info_free(&info_used); MPI_File_close(&fh); MPI_Finalize(); return 0; }