/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* A series of tests for posix compliance * * These tests do increasingly complicated sets of writes followed by reads. * POSIX standards say that any read that can be proven to occur after a write * must include the data in that write. These tests attempt to verify whether the * underlying filesystem and i/o layer provide such guarantees. * * There are two sets of tests, one which uses POSIX i/o (fread, fwrite) and one which * uses MPI I/O (MPI_File_read, MPI_File_write). Each set has multiple sub-tests, which * test varying patters of writes and reads. * * * TODO: * Add corresponding posix i/o tests for each MPI i/o test. Currently, not all of the * MPI IO tests are implemented using fwrite/fread. * * Leon Arber * larber@ncsa.uiuc.edu */ /* To compile this outside of the HDF5 library, you can do so by defining the * macro STANDALONE. E.g., * mpicc -DSTANDALONE t_posix_compliant.c -o t_posix_compliant * then run it as an MPI application. E.g., * mpirun -np 3 ./t_posix_compliant */ #include #include #include #include #include #ifndef STANDALONE #include "h5test.h" #else #define HDmalloc(sz) malloc(sz) #define HDfree(p) free(p) #define getenv_all(comm, root, name) getenv(name) #endif #define TESTFNAME "posix_test" /* test file name */ static char* testfile = NULL; static int err_flag = 0; static int max_err_print = 5; int nmismatches = 0; /* warnings encountered */ /* globals needed for getopt * Although they *should* be defined in unistd.h */ extern char *optarg; extern int optind, opterr; #define CHECK_SUCCESS(res) \ { \ char err_got[MPI_MAX_ERROR_STRING]; \ int err_len; \ if(res != MPI_SUCCESS) \ { \ MPI_Error_string(res, err_got, &err_len); \ fprintf(stderr, "Line %d, Error: %s\n", __LINE__, err_got); \ MPI_Abort(MPI_COMM_WORLD, -2); \ } \ } #define PRINT_RESULT() \ { \ int err_result; \ MPI_Reduce(&err_flag, &err_result, 1, MPI_INT, MPI_MIN, 0, MPI_COMM_WORLD); \ if( (rank == 0) && (err_result == 0) ) \ printf("PASSED\n"); \ fflush(stdout); \ fflush(stderr); \ err_flag = 0; \ } static void vrfy_elements(int* a, int* b, int size, int rank); static int find_writesize(int rank, int numprocs, int write_size); /* All writes are to non-overlapping locations in the file * Then, each task reads another tasks' data * */ static int allwrite_allread_blocks(int numprocs, int rank, int write_size) { MPI_File fh = MPI_FILE_NULL; int mpio_result; int amode, i; MPI_Offset offset = rank*write_size*sizeof(int); MPI_Status Status; int* writebuf = (int*)malloc(write_size*sizeof(int)); int* readbuf = (int*)malloc (write_size*sizeof(int)); for(i=0; i