~ubuntu-branches/ubuntu/vivid/mpich/vivid-proposed

« back to all changes in this revision

Viewing changes to test/mpi/io/async.c

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2014-04-01 20:24:20 UTC
  • mfrom: (5.2.4 sid)
  • Revision ID: package-import@ubuntu.com-20140401202420-t5ey1ia2klt5dkq3
Tags: 3.1-4
* [c3e3398] Disable test_primitives, which is unreliable on some platforms.
            (Closes: #743047)
* [265a699] Add minimal autotest.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
   reads them back. The file name is taken as a command-line argument,
21
21
   and the process rank is appended to it.*/ 
22
22
 
 
23
static void handle_error(int errcode, char *str)
 
24
{
 
25
        char msg[MPI_MAX_ERROR_STRING];
 
26
        int resultlen;
 
27
        MPI_Error_string(errcode, msg, &resultlen);
 
28
        fprintf(stderr, "%s: %s\n", str, msg);
 
29
        MPI_Abort(MPI_COMM_WORLD, 1);
 
30
}
 
31
 
23
32
int main(int argc, char **argv)
24
33
{
25
 
    int *buf, i, rank, nints, len;
 
34
    int *buf, i, rank, nints, len, err;
26
35
    char *filename=0, *tmp;
27
36
    int errs=0;
28
37
    int SIZE = DEFAULT_SIZE;
37
46
    MTest_Init(&argc,&argv);
38
47
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
39
48
 
 
49
 
40
50
/* process 0 takes the file name as a command-line argument and 
41
51
   broadcasts it to other processes */
42
52
    if (!rank) {
99
109
    sprintf(filename, "%s.%d", tmp, rank);
100
110
    free(tmp);
101
111
 
102
 
    MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, 
 
112
    err = MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, 
103
113
                  MPI_INFO_NULL, &fh);
104
 
    MPI_File_set_view(fh, 0, MPI_INT, MPI_INT, (char*)"native", MPI_INFO_NULL);
105
 
    MPI_File_iwrite(fh, buf, nints, MPI_INT, &request);
 
114
    if (err != MPI_SUCCESS) handle_error(err, "MPI_File_open");
 
115
 
 
116
    err = MPI_File_set_view(fh, 0, MPI_INT, MPI_INT, (char*)"native", MPI_INFO_NULL);
 
117
    if (err != MPI_SUCCESS) handle_error(err, "MPI_File_set_view");
 
118
    err = MPI_File_iwrite(fh, buf, nints, MPI_INT, &request);
 
119
    if (err != MPI_SUCCESS) handle_error(err, "MPI_File_iwrtie");
106
120
#ifdef MPIO_USES_MPI_REQUEST
107
121
    MPI_Wait( &request, &status );
108
122
#else    
113
127
    /* reopen the file and read the data back */
114
128
 
115
129
    for (i=0; i<nints; i++) buf[i] = 0;
116
 
    MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, 
 
130
    err = MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, 
117
131
                  MPI_INFO_NULL, &fh);
118
 
    MPI_File_set_view(fh, 0, MPI_INT, MPI_INT, (char*)"native", MPI_INFO_NULL);
119
 
    MPI_File_iread(fh, buf, nints, MPI_INT, &request);
 
132
    if (err != MPI_SUCCESS) handle_error(err, "MPI_File_open (read)");
 
133
    err = MPI_File_set_view(fh, 0, MPI_INT, MPI_INT, (char*)"native", MPI_INFO_NULL);
 
134
    if (err != MPI_SUCCESS) handle_error(err, "MPI_File_set_view (read)");
 
135
    err = MPI_File_iread(fh, buf, nints, MPI_INT, &request);
 
136
    if (err != MPI_SUCCESS) handle_error(err, "MPI_File_iread");
120
137
#ifdef MPIO_USES_MPI_REQUEST
121
138
    MPI_Wait( &request, &status );
122
139
#else