1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
3 * (C) 2015 by Argonne National Laboratory.
4 * See COPYRIGHT in top-level directory.
8 /* this deceptively simple test uncovered a bug in the way certain file systems
9 * dealt with tuning parameters. See
10 * https://github.com/open-mpi/ompi/issues/158 and
11 * http://trac.mpich.org/projects/mpich/ticket/2261
13 * originally uncovered in Darshan:
14 * http://lists.mcs.anl.gov/pipermail/darshan-users/2015-February/000256.html
16 * to really exercise the bug in simple_collective,
17 * we'd have to run on a Lustre or Panasas file system.
19 * I am surprised src/mpi/romio/test/create_excl.c did not uncover the bug
26 #include <sys/types.h>
35 #include "simgrid/plugins/file_system.h"
37 static char *opt_file = NULL;
40 static int parse_args(int argc, char **argv);
41 static void usage(const char *prog);
42 int test_write(char *file, int nprocs, int rank, MPI_Info info);
43 int test_write(char *file, int nprocs, int rank, MPI_Info info)
45 double stime, etime, wtime, w_elapsed, w_slowest, elapsed, slowest;
48 char buffer[700] = { 0 };
52 MPI_Barrier(MPI_COMM_WORLD);
55 ret = MPI_File_open(MPI_COMM_WORLD, file,
56 MPI_MODE_CREATE | MPI_MODE_WRONLY | MPI_MODE_EXCL, info, &fh);
59 fprintf(stderr, "Error: failed to open %s\n", file);
65 ret = MPI_File_write_at_all(fh, rank * 700, buffer, 700, MPI_BYTE, &status);
67 fprintf(stderr, "Error: failed to write %s\n", file);
75 elapsed = etime - stime;
76 w_elapsed = wtime - etime;
77 MPI_Reduce(&elapsed, &slowest, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD);
78 MPI_Reduce(&w_elapsed, &w_slowest, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD);
82 //to emulate unlink, use sg_file_unlink
83 sg_file_t fd = sg_file_open(file, NULL);
88 printf("file: %s, nprocs: %d, open_time: %f ms, write_time: %f ms\n",
89 file, nprocs, slowest, w_slowest);
95 int main(int argc, char **argv)
103 MPI_Init(&argc, &argv);
104 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
105 MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
107 /* parse the command line arguments */
108 parse_args(argc, argv);
110 sprintf(file, "%s", opt_file);
111 MPI_Info_create(&info);
112 nr_errors += test_write(file, nprocs, rank, info);
113 /* actual value does not matter. test only writes a small amount of data */
114 MPI_Info_set(info, "striping_factor", "50");
115 nr_errors += test_write(file, nprocs, rank, info);
116 MPI_Info_free(&info);
119 if (!rank && nr_errors == 0) {
120 printf(" No Errors\n");
125 static int parse_args(int argc, char **argv)
129 while ((c = getopt(argc, argv, "e")) != EOF) {
135 case '?': /* unknown */
144 if (argc - optind != 1) {
150 opt_file = argv[optind];
151 assert(opt_file!=NULL);
156 static void usage(const char *prog)
158 printf("Usage: %s [<OPTIONS>...] <FILE NAME>\n", prog);
159 printf("\n<OPTIONS> is one or more of\n");
160 printf(" -h print this help\n");
164 * vim: ts=8 sts=4 sw=4 noexpandtab