summaryrefslogtreecommitdiffstats
path: root/testpar/t_posix_compliant.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2011-09-06 14:20:58 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2011-09-06 14:20:58 (GMT)
commita14f6882d41067156bb33dd9aab638e73cf91245 (patch)
tree04a7a265af04e28492e19bae2584dfbffd2f1184 /testpar/t_posix_compliant.c
parentb3bc8132c5661f9e2b5f0222bef8791d9193b25c (diff)
downloadhdf5-a14f6882d41067156bb33dd9aab638e73cf91245.zip
hdf5-a14f6882d41067156bb33dd9aab638e73cf91245.tar.gz
hdf5-a14f6882d41067156bb33dd9aab638e73cf91245.tar.bz2
[svn-r21364] Related files to files from HDF5-33 review - all changes ran correctly in trunk. Changes have been tested in cmake branch.
t_cache.c - define needed for windows t_posix_compliant.c - #ifdef around include <unistd.h> t_shapesame.c - HD prefix needed for stat function Tested: local linux
Diffstat (limited to 'testpar/t_posix_compliant.c')
-rw-r--r--testpar/t_posix_compliant.c728
1 files changed, 365 insertions, 363 deletions
diff --git a/testpar/t_posix_compliant.c b/testpar/t_posix_compliant.c
index 960f4c8..5ea089d 100644
--- a/testpar/t_posix_compliant.c
+++ b/testpar/t_posix_compliant.c
@@ -26,8 +26,8 @@
*
*
* 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.
+ * 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
@@ -40,7 +40,9 @@
* mpiexec -np 3 ./t_posix_compliant
*/
+#ifdef H5_HAVE_UNISTD_H
#include <unistd.h>
+#endif
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -48,16 +50,16 @@
#ifndef STANDALONE
#include "h5test.h"
#else
-#define HDmalloc(sz) malloc(sz)
-#define HDfree(p) free(p)
-#define getenv_all(comm, root, name) getenv(name)
+#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 */
+#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 */
+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 */
@@ -65,27 +67,27 @@ 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 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; \
+#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);
@@ -98,21 +100,21 @@ static int find_writesize(int rank, int numprocs, int write_size);
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;
+ 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<write_size; i++)
- writebuf[i] = i;
+ writebuf[i] = i;
amode = MPI_MODE_CREATE | MPI_MODE_RDWR | MPI_MODE_DELETE_ON_CLOSE;
mpio_result = MPI_File_open(MPI_COMM_WORLD, testfile, amode,
- MPI_INFO_NULL, &fh);
+ MPI_INFO_NULL, &fh);
CHECK_SUCCESS(mpio_result);
mpio_result = MPI_File_write_at(fh, offset, writebuf, write_size, MPI_INT, &Status);
@@ -138,41 +140,41 @@ static int allwrite_allread_blocks(int numprocs, int rank, int write_size)
static int posix_allwrite_allread_blocks(int numprocs, int rank, int write_size)
{
- int ret;
- int i;
- int offset = rank*write_size*sizeof(int);
+ int ret;
+ int i;
+ int offset = rank*write_size*sizeof(int);
int* writebuf = (int*)malloc(write_size*sizeof(int));
int* readbuf = (int*)malloc (write_size*sizeof(int));
- FILE* file = NULL;
+ FILE* file = NULL;
for(i=0; i<write_size; i++)
- writebuf[i] = i;
+ writebuf[i] = i;
if(rank==0)
- file = fopen(testfile, "w+");
+ file = fopen(testfile, "w+");
MPI_Barrier(MPI_COMM_WORLD);
if(rank != 0)
- file = fopen(testfile, "r+");
+ file = fopen(testfile, "r+");
if(file == NULL)
{
- fprintf(stderr, "Could not create testfile\n");
- MPI_Abort(MPI_COMM_WORLD, 1);
+ fprintf(stderr, "Could not create testfile\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
ret = fseek(file, offset, SEEK_SET);
if(ret == -1)
{
- perror("fseek");
- MPI_Abort(MPI_COMM_WORLD, 1);
+ perror("fseek");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
ret = fwrite(writebuf, sizeof(int), write_size, file);
if(ret != write_size)
{
- perror("fwrite");
- MPI_Abort(MPI_COMM_WORLD, 1);
+ perror("fwrite");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
MPI_Barrier(MPI_COMM_WORLD);
@@ -182,17 +184,17 @@ static int posix_allwrite_allread_blocks(int numprocs, int rank, int write_size)
ret = fseek(file, offset, SEEK_SET);
if(ret == -1)
{
- perror("fseek");
- MPI_Abort(MPI_COMM_WORLD, 1);
+ perror("fseek");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
ret = fread(readbuf, sizeof(int), write_size, file);
if( (ret == 0) && feof(file))
- printf("Process %d: Error. Prematurely reached end of file\n", rank);
+ printf("Process %d: Error. Prematurely reached end of file\n", rank);
else if( (ret != write_size) && ferror(file))
{
- perror("Error encountered in fread");
- MPI_Abort(MPI_COMM_WORLD, 1);
+ perror("Error encountered in fread");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
vrfy_elements(writebuf, readbuf, write_size, rank);
@@ -201,7 +203,7 @@ static int posix_allwrite_allread_blocks(int numprocs, int rank, int write_size)
MPI_Barrier(MPI_COMM_WORLD);
if(rank == 0)
- unlink(testfile);
+ unlink(testfile);
HDfree(writebuf);
HDfree(readbuf);
@@ -211,47 +213,47 @@ static int posix_allwrite_allread_blocks(int numprocs, int rank, int write_size)
static int posix_onewrite_allread_blocks(int numprocs, int rank, int write_size)
{
- int ret;
- int i;
- int offset = rank*write_size*sizeof(int);
+ int ret;
+ int i;
+ int offset = rank*write_size*sizeof(int);
int* writebuf = (int*)malloc(write_size*sizeof(int));
int* readbuf = (int*)malloc (write_size*sizeof(int));
- FILE* file = NULL;
+ FILE* file = NULL;
for(i=0; i<write_size; i++)
- writebuf[i] = i;
+ writebuf[i] = i;
if(rank==0)
- file = fopen(testfile, "w+");
+ file = fopen(testfile, "w+");
MPI_Barrier(MPI_COMM_WORLD);
if(rank != 0)
- file = fopen(testfile, "r+");
+ file = fopen(testfile, "r+");
if(file == NULL)
{
- fprintf(stderr, "Could not create testfile\n");
- MPI_Abort(MPI_COMM_WORLD, 1);
+ fprintf(stderr, "Could not create testfile\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
if(rank == 0)
{
- for(offset = 0; offset<numprocs*write_size*sizeof(int); offset+=(write_size*sizeof(int)))
- {
- ret = fseek(file, offset, SEEK_SET);
- if(ret == -1)
- {
- perror("fseek");
- MPI_Abort(MPI_COMM_WORLD, 1);
- }
-
-
- ret = fwrite(writebuf, sizeof(int), write_size, file);
- if(ret != write_size)
- {
- perror("fwrite");
- MPI_Abort(MPI_COMM_WORLD, 1);
- }
- }
+ for(offset = 0; offset<numprocs*write_size*sizeof(int); offset+=(write_size*sizeof(int)))
+ {
+ ret = fseek(file, offset, SEEK_SET);
+ if(ret == -1)
+ {
+ perror("fseek");
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+
+
+ ret = fwrite(writebuf, sizeof(int), write_size, file);
+ if(ret != write_size)
+ {
+ perror("fwrite");
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ }
}
MPI_Barrier(MPI_COMM_WORLD);
@@ -261,17 +263,17 @@ static int posix_onewrite_allread_blocks(int numprocs, int rank, int write_size)
ret = fseek(file, offset, SEEK_SET);
if(ret == -1)
{
- perror("fseek");
- MPI_Abort(MPI_COMM_WORLD, 1);
+ perror("fseek");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
ret = fread(readbuf, sizeof(int), write_size, file);
if( (ret == 0) && feof(file))
- printf("Process %d: Error. Prematurely reached end of file\n", rank);
+ printf("Process %d: Error. Prematurely reached end of file\n", rank);
else if( (ret != write_size) && ferror(file))
{
- perror("Error encountered in fread");
- MPI_Abort(MPI_COMM_WORLD, 1);
+ perror("Error encountered in fread");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
vrfy_elements(writebuf, readbuf, write_size, rank);
@@ -280,7 +282,7 @@ static int posix_onewrite_allread_blocks(int numprocs, int rank, int write_size)
MPI_Barrier(MPI_COMM_WORLD);
if(rank == 0)
- unlink(testfile);
+ unlink(testfile);
HDfree(writebuf);
HDfree(readbuf);
@@ -290,48 +292,48 @@ static int posix_onewrite_allread_blocks(int numprocs, int rank, int write_size)
static int posix_onewrite_allread_interlaced(int numprocs, int rank, int write_size)
{
- int ret;
- int i, fill, index;
- int offset = rank*write_size*sizeof(int);
+ int ret;
+ int i, fill, index;
+ int offset = rank*write_size*sizeof(int);
int* writebuf = (int*)malloc(write_size*sizeof(int));
int* readbuf = (int*)malloc (write_size*sizeof(int));
- FILE* file = NULL;
+ FILE* file = NULL;
if(rank==0)
- file = fopen(testfile, "w+");
+ file = fopen(testfile, "w+");
MPI_Barrier(MPI_COMM_WORLD);
if(rank != 0)
- file = fopen(testfile, "r+");
+ file = fopen(testfile, "r+");
if(file == NULL)
{
- fprintf(stderr, "Could not create testfile\n");
- MPI_Abort(MPI_COMM_WORLD, 1);
+ fprintf(stderr, "Could not create testfile\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
if(rank == 0)
{
- for(offset = 0; offset<numprocs*write_size*sizeof(int); offset+=(numprocs*sizeof(int)))
- {
- ret = fseek(file, offset, SEEK_SET);
- if(ret == -1)
- {
- perror("fseek");
- MPI_Abort(MPI_COMM_WORLD, 1);
- }
-
- fill = offset / (numprocs*sizeof(int));
- for(i=0; i<numprocs; i++)
- writebuf[i] = fill;
-
-
- ret = fwrite(writebuf, sizeof(int), numprocs, file);
- if(ret != numprocs)
- {
- perror("fwrite");
- MPI_Abort(MPI_COMM_WORLD, 1);
- }
- }
+ for(offset = 0; offset<numprocs*write_size*sizeof(int); offset+=(numprocs*sizeof(int)))
+ {
+ ret = fseek(file, offset, SEEK_SET);
+ if(ret == -1)
+ {
+ perror("fseek");
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+
+ fill = offset / (numprocs*sizeof(int));
+ for(i=0; i<numprocs; i++)
+ writebuf[i] = fill;
+
+
+ ret = fwrite(writebuf, sizeof(int), numprocs, file);
+ if(ret != numprocs)
+ {
+ perror("fwrite");
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ }
}
MPI_Barrier(MPI_COMM_WORLD);
@@ -340,27 +342,27 @@ static int posix_onewrite_allread_interlaced(int numprocs, int rank, int write_s
for(offset = rank*sizeof(int); offset<numprocs*write_size*sizeof(int); offset+=(numprocs*sizeof(int)))
{
- ret = fseek(file, offset, SEEK_SET);
- if(ret == -1)
- {
- perror("fseek");
- MPI_Abort(MPI_COMM_WORLD, 1);
- }
-
- ret = fread(readbuf+index, sizeof(int), 1, file);
- if( (ret == 0) && feof(file))
- printf("Process %d: Error. Prematurely reached end of file\n", rank);
- else if( (ret != 1) && ferror(file))
- {
- perror("Error encountered in fread");
- MPI_Abort(MPI_COMM_WORLD, 1);
- }
-
- index++;
+ ret = fseek(file, offset, SEEK_SET);
+ if(ret == -1)
+ {
+ perror("fseek");
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+
+ ret = fread(readbuf+index, sizeof(int), 1, file);
+ if( (ret == 0) && feof(file))
+ printf("Process %d: Error. Prematurely reached end of file\n", rank);
+ else if( (ret != 1) && ferror(file))
+ {
+ perror("Error encountered in fread");
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+
+ index++;
}
for(i=0; i<write_size; i++)
- writebuf[i] = i;
+ writebuf[i] = i;
vrfy_elements(writebuf, readbuf, write_size, rank);
@@ -368,7 +370,7 @@ static int posix_onewrite_allread_interlaced(int numprocs, int rank, int write_s
MPI_Barrier(MPI_COMM_WORLD);
if(rank == 0)
- unlink(testfile);
+ unlink(testfile);
HDfree(writebuf);
HDfree(readbuf);
@@ -382,17 +384,17 @@ static int posix_onewrite_allread_interlaced(int numprocs, int rank, int write_s
static int allwrite_allread_interlaced(int numprocs, int rank, int write_size)
{
- MPI_File fh = MPI_FILE_NULL;
- int mpio_result;
- int amode, i, counter = 0;
+ MPI_File fh = MPI_FILE_NULL;
+ int mpio_result;
+ int amode, i, counter = 0;
MPI_Datatype filetype;
- MPI_Status Status;
+ MPI_Status Status;
int* writebuf = (int*)malloc(write_size*sizeof(int));
- int* readbuf = (int*) malloc(numprocs*sizeof(int));
- int offset=0;
+ int* readbuf = (int*) malloc(numprocs*sizeof(int));
+ int offset=0;
for(i=0; i<write_size; i++)
- writebuf[i] = i;
+ writebuf[i] = i;
amode = MPI_MODE_CREATE | MPI_MODE_RDWR | MPI_MODE_DELETE_ON_CLOSE;
@@ -418,23 +420,23 @@ static int allwrite_allread_interlaced(int numprocs, int rank, int write_size)
for(offset = 0; offset<(write_size*numprocs*sizeof(int)); offset+=(numprocs*sizeof(int)))
{
- mpio_result = MPI_File_read_at(fh, offset, readbuf, numprocs, MPI_INT, &Status);
- CHECK_SUCCESS(mpio_result);
-
- for(i=0; i<numprocs; i++)
- {
- if(writebuf[offset/(numprocs*sizeof(int))] != readbuf[i])
- {
- if( (rank == 0) && (counter == 0))
- printf("\n");
- if(counter++ < max_err_print)
- fprintf(stderr, "Arrays do not match! Prcoess %d, element %d: [%d, %d]\n", rank, i, writebuf[offset/(numprocs*sizeof(int))], readbuf[i]);
- else if(counter++ == max_err_print+1)
- fprintf(stderr, "Printed %d errors. Omitting the rest\n", max_err_print);
- err_flag = -1;
- }
-
- }
+ mpio_result = MPI_File_read_at(fh, offset, readbuf, numprocs, MPI_INT, &Status);
+ CHECK_SUCCESS(mpio_result);
+
+ for(i=0; i<numprocs; i++)
+ {
+ if(writebuf[offset/(numprocs*sizeof(int))] != readbuf[i])
+ {
+ if( (rank == 0) && (counter == 0))
+ printf("\n");
+ if(counter++ < max_err_print)
+ fprintf(stderr, "Arrays do not match! Prcoess %d, element %d: [%d, %d]\n", rank, i, writebuf[offset/(numprocs*sizeof(int))], readbuf[i]);
+ else if(counter++ == max_err_print+1)
+ fprintf(stderr, "Printed %d errors. Omitting the rest\n", max_err_print);
+ err_flag = -1;
+ }
+
+ }
}
nmismatches += counter;
mpio_result = MPI_File_close(&fh);
@@ -449,10 +451,10 @@ static int allwrite_allread_interlaced(int numprocs, int rank, int write_size)
/* Overlapping pattern works as follows (this test requires at least 2 procs:
* Writes:
- * Task 0: 0 2 4 6 etc...
- * Task 1: 1 3 5 7 etc...
- * Task 2: 0 3 6 etc..
- * Task 3: 0 4 8 etc...
+ * Task 0: 0 2 4 6 etc...
+ * Task 1: 1 3 5 7 etc...
+ * Task 2: 0 3 6 etc..
+ * Task 3: 0 4 8 etc...
*
* The above describes only the pattern of the elements being written. The actual
* number of elements written is going to be:
@@ -464,11 +466,11 @@ static int allwrite_allread_interlaced(int numprocs, int rank, int write_size)
*
* So, if there are 5 tasks with write_size=4, the resulting pattern of writes is:
*
- * Task 0: 0 2 4 6 8 10 12 14
+ * Task 0: 0 2 4 6 8 10 12 14
* Task 1: 1 3 5 7 9 11 13 15
- * Task 2: 0 3 6 9 12 15
- * Task 3: 0 4 8 12
- * Task 4: 0 5 10 15
+ * Task 2: 0 3 6 9 12 15
+ * Task 3: 0 4 8 12
+ * Task 4: 0 5 10 15
*
*
*
@@ -481,34 +483,34 @@ static int allwrite_allread_interlaced(int numprocs, int rank, int write_size)
static int allwrite_allread_overlap(int numprocs, int rank, int write_size)
{
- MPI_File fh = MPI_FILE_NULL;
- int mpio_result;
- int amode, i, counter = 0;
+ MPI_File fh = MPI_FILE_NULL;
+ int mpio_result;
+ int amode, i, counter = 0;
MPI_Datatype filetype;
- MPI_Status Status;
- int* writebuf = (int*) malloc(write_size*(numprocs-1)*sizeof(int)); /* An upper bound...not all the elements will be written */
- int* readbuf = (int*) malloc(write_size*(numprocs-1)*sizeof(int));
+ MPI_Status Status;
+ int* writebuf = (int*) malloc(write_size*(numprocs-1)*sizeof(int)); /* An upper bound...not all the elements will be written */
+ int* readbuf = (int*) malloc(write_size*(numprocs-1)*sizeof(int));
if(numprocs < 2)
{
- fprintf(stderr, "The allwrite_allread_overlap test requires at least 2 procs\n");
- return -1;
+ fprintf(stderr, "The allwrite_allread_overlap test requires at least 2 procs\n");
+ return -1;
}
if(rank == 0)
{
- for(i=0; i<write_size*(numprocs-1); i++)
- writebuf[i] = 2*i;
+ for(i=0; i<write_size*(numprocs-1); i++)
+ writebuf[i] = 2*i;
}
else if(rank == 1)
{
- for(i=0; i<write_size*(numprocs-1); i++)
- writebuf[i] = (2*i)+1;
+ for(i=0; i<write_size*(numprocs-1); i++)
+ writebuf[i] = (2*i)+1;
}
else
{
- for(i=0; i<write_size*(numprocs-1); i++)
- writebuf[i] = (rank+1)*i;
+ for(i=0; i<write_size*(numprocs-1); i++)
+ writebuf[i] = (rank+1)*i;
}
amode = MPI_MODE_CREATE | MPI_MODE_RDWR | MPI_MODE_DELETE_ON_CLOSE;
@@ -516,24 +518,24 @@ static int allwrite_allread_overlap(int numprocs, int rank, int write_size)
CHECK_SUCCESS(mpio_result);
if( (rank == 0) || (rank == 1) )
- mpio_result = MPI_Type_vector(write_size*(numprocs-1), 1, 2, MPI_INT, &filetype);
+ mpio_result = MPI_Type_vector(write_size*(numprocs-1), 1, 2, MPI_INT, &filetype);
else
- mpio_result = MPI_Type_vector(write_size*(numprocs-1), 1, rank+1, MPI_INT, &filetype);
+ mpio_result = MPI_Type_vector(write_size*(numprocs-1), 1, rank+1, MPI_INT, &filetype);
CHECK_SUCCESS(mpio_result);
mpio_result = MPI_Type_commit(&filetype);
CHECK_SUCCESS(mpio_result);
if( rank == 1)
- mpio_result = MPI_File_set_view(fh, sizeof(int), MPI_INT, filetype, "native", MPI_INFO_NULL);
+ mpio_result = MPI_File_set_view(fh, sizeof(int), MPI_INT, filetype, "native", MPI_INFO_NULL);
else
- mpio_result = MPI_File_set_view(fh, 0, MPI_INT, filetype, "native", MPI_INFO_NULL);
+ mpio_result = MPI_File_set_view(fh, 0, MPI_INT, filetype, "native", MPI_INFO_NULL);
CHECK_SUCCESS(mpio_result);
if( rank == (numprocs - 1))
- mpio_result = MPI_File_write(fh, writebuf, write_size, MPI_INT, &Status);
+ mpio_result = MPI_File_write(fh, writebuf, write_size, MPI_INT, &Status);
else
- mpio_result = MPI_File_write(fh, writebuf, find_writesize(rank, numprocs, write_size), MPI_INT, &Status);
+ mpio_result = MPI_File_write(fh, writebuf, find_writesize(rank, numprocs, write_size), MPI_INT, &Status);
CHECK_SUCCESS(mpio_result);
@@ -546,16 +548,16 @@ static int allwrite_allread_overlap(int numprocs, int rank, int write_size)
for(i=0; i<write_size*(numprocs-1); i++)
{
- if(i != readbuf[i])
- {
- if( (rank == 0) && (counter == 0))
- printf("\n");
- if(counter++ < max_err_print)
- fprintf(stderr, "Arrays do not match! Prcoess %d, element %d: [%d, %d]\n", rank, i, i, readbuf[i]);
- else if(counter++ == max_err_print+1)
- fprintf(stderr, "Printed %d errors. Omitting the rest\n", max_err_print);
- err_flag = -1;
- }
+ if(i != readbuf[i])
+ {
+ if( (rank == 0) && (counter == 0))
+ printf("\n");
+ if(counter++ < max_err_print)
+ fprintf(stderr, "Arrays do not match! Prcoess %d, element %d: [%d, %d]\n", rank, i, i, readbuf[i]);
+ else if(counter++ == max_err_print+1)
+ fprintf(stderr, "Printed %d errors. Omitting the rest\n", max_err_print);
+ err_flag = -1;
+ }
}
nmismatches += counter;
@@ -575,30 +577,30 @@ static int allwrite_allread_overlap(int numprocs, int rank, int write_size)
*/
static int onewrite_allread_blocks(int numprocs, int rank, int write_size)
{
- MPI_File fh = MPI_FILE_NULL;
- int mpio_result;
- int amode, i;
- MPI_Status Status;
+ MPI_File fh = MPI_FILE_NULL;
+ int mpio_result;
+ int amode, i;
+ MPI_Status Status;
int* writebuf = (int*)malloc(write_size*sizeof(int));
int* readbuf = (int*)malloc (write_size*sizeof(int));
for(i=0; i<write_size; i++)
- writebuf[i] = i;
+ writebuf[i] = i;
amode = MPI_MODE_CREATE | MPI_MODE_RDWR | MPI_MODE_DELETE_ON_CLOSE;
mpio_result = MPI_File_open(MPI_COMM_WORLD, testfile, amode,
- MPI_INFO_NULL, &fh);
+ MPI_INFO_NULL, &fh);
CHECK_SUCCESS(mpio_result);
/* A random process writes out all the data */
if(rank == (rand() % numprocs))
{
- for(i=0; i<numprocs; i++)
- {
- mpio_result = MPI_File_write_at(fh, write_size*i*sizeof(int), writebuf, write_size, MPI_INT, &Status);
- CHECK_SUCCESS(mpio_result);
- }
+ for(i=0; i<numprocs; i++)
+ {
+ mpio_result = MPI_File_write_at(fh, write_size*i*sizeof(int), writebuf, write_size, MPI_INT, &Status);
+ CHECK_SUCCESS(mpio_result);
+ }
}
MPI_Barrier(MPI_COMM_WORLD);
@@ -625,12 +627,12 @@ static int onewrite_allread_blocks(int numprocs, int rank, int write_size)
* Each proc reads out 0 1 2 3 starting at displacement i */
static int onewrite_allread_interlaced(int numprocs, int rank, int write_size)
{
- MPI_File fh = MPI_FILE_NULL;
- int mpio_result;
- int amode, i;
+ MPI_File fh = MPI_FILE_NULL;
+ int mpio_result;
+ int amode, i;
MPI_Datatype filetype;
- MPI_Status Status;
- int* writebuf = (int*) malloc(numprocs*write_size*sizeof(int)); /* Upper bound, not all used */
+ MPI_Status Status;
+ int* writebuf = (int*) malloc(numprocs*write_size*sizeof(int)); /* Upper bound, not all used */
int* readbuf = (int*)malloc (write_size*sizeof(int));
@@ -647,15 +649,15 @@ static int onewrite_allread_interlaced(int numprocs, int rank, int write_size)
if(rank == (rand() % numprocs))
{
- for(i=0; i<write_size; i++)
- {
- int j;
- for(j=0; j<numprocs; j++)
- writebuf[j] = i;
-
- mpio_result = MPI_File_write_at(fh, i*numprocs*sizeof(int), writebuf, numprocs, MPI_INT, &Status);
- CHECK_SUCCESS(mpio_result);
- }
+ for(i=0; i<write_size; i++)
+ {
+ int j;
+ for(j=0; j<numprocs; j++)
+ writebuf[j] = i;
+
+ mpio_result = MPI_File_write_at(fh, i*numprocs*sizeof(int), writebuf, numprocs, MPI_INT, &Status);
+ CHECK_SUCCESS(mpio_result);
+ }
}
MPI_Barrier(MPI_COMM_WORLD);
@@ -667,7 +669,7 @@ static int onewrite_allread_interlaced(int numprocs, int rank, int write_size)
CHECK_SUCCESS(mpio_result);
for(i=0; i<write_size; i++)
- writebuf[i] = i;
+ writebuf[i] = i;
vrfy_elements(writebuf, readbuf, write_size, rank);
@@ -690,12 +692,12 @@ static int find_writesize(int rank, int numprocs, int size)
/* Find largest multiple not greater than tmp */
while(x <= tmp)
{
- if( (rank == 0) || (rank == 1) )
- x+=2;
- else
- x += (rank+1);
+ if( (rank == 0) || (rank == 1) )
+ x+=2;
+ else
+ x += (rank+1);
- write_size++;
+ write_size++;
}
return write_size;
@@ -708,16 +710,16 @@ vrfy_elements(int* a, int* b, int size, int rank)
for(i=0; i<size; i++)
{
- if(a[i] != b[i])
- {
- if( (rank == 0) && (counter == 0))
- printf("\n");
- if(counter++ < max_err_print)
- fprintf(stderr, "Arrays do not match! Prcoess %d, element %d: [%d, %d]\n", rank, i, a[i], b[i]);
- else if(counter++ == max_err_print+1)
- fprintf(stderr, "Printed %d errors. Omitting the rest\n", max_err_print);
- err_flag = -1;
- }
+ if(a[i] != b[i])
+ {
+ if( (rank == 0) && (counter == 0))
+ printf("\n");
+ if(counter++ < max_err_print)
+ fprintf(stderr, "Arrays do not match! Prcoess %d, element %d: [%d, %d]\n", rank, i, a[i], b[i]);
+ else if(counter++ == max_err_print+1)
+ fprintf(stderr, "Printed %d errors. Omitting the rest\n", max_err_print);
+ err_flag = -1;
+ }
}
nmismatches += counter;
fflush(stderr);
@@ -744,7 +746,7 @@ main(int argc, char* argv[])
int numprocs, rank, opt, mpi_tests=1, posix_tests=1;
int lb, ub, inc;
- int write_size = 0;
+ int write_size = 0;
char optstring[] = "h x m p: s: v:";
char *prefix;
@@ -755,63 +757,63 @@ main(int argc, char* argv[])
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank == 0)
- header_msg();
+ header_msg();
while((opt = getopt(argc, argv, optstring)) != -1)
{
- switch(opt)
- {
- case 'h':
- if(rank == 0)
- printf("Usage: %s [options]\n"
- "-h prints this help message\n"
- "-x run the posix i/o tests ONLY (default: posix and MPI)\n"
- "-m run the mpi i/o tests ONLY (default: posix and MPI)\n"
- "-s size Run the test for the specific size. Default is 1024, 4096, 16384, ..., 1048576\n"
- "-p path specifies path for test file. Default is current directory\n"
- "-v num Specifies number of unmatching entries to print (default 10, pass -1 for all)\n", argv[0]);
- goto done;
- case 'x':
- mpi_tests = 0;
- posix_tests = 1;
- break;
- case 'm':
- mpi_tests = 1;
- posix_tests = 0;
- break;
- case 'p':
- /* need 2 extra--1 for the / and 1 for the terminating NULL. */
- testfile = (char*) HDmalloc(strlen(optarg) + 2 + strlen(TESTFNAME));
- strcpy(testfile, optarg);
- /* Append a / just in case they didn't end their path with one */
- strcat(testfile, "/" TESTFNAME);
- break;
- case 's':
- write_size = atoi(optarg);
- break;
- case 'v':
- max_err_print = atoi(optarg);
- break;
- }
+ switch(opt)
+ {
+ case 'h':
+ if(rank == 0)
+ printf("Usage: %s [options]\n"
+ "-h prints this help message\n"
+ "-x run the posix i/o tests ONLY (default: posix and MPI)\n"
+ "-m run the mpi i/o tests ONLY (default: posix and MPI)\n"
+ "-s size Run the test for the specific size. Default is 1024, 4096, 16384, ..., 1048576\n"
+ "-p path specifies path for test file. Default is current directory\n"
+ "-v num Specifies number of unmatching entries to print (default 10, pass -1 for all)\n", argv[0]);
+ goto done;
+ case 'x':
+ mpi_tests = 0;
+ posix_tests = 1;
+ break;
+ case 'm':
+ mpi_tests = 1;
+ posix_tests = 0;
+ break;
+ case 'p':
+ /* need 2 extra--1 for the / and 1 for the terminating NULL. */
+ testfile = (char*) HDmalloc(strlen(optarg) + 2 + strlen(TESTFNAME));
+ strcpy(testfile, optarg);
+ /* Append a / just in case they didn't end their path with one */
+ strcat(testfile, "/" TESTFNAME);
+ break;
+ case 's':
+ write_size = atoi(optarg);
+ break;
+ case 'v':
+ max_err_print = atoi(optarg);
+ break;
+ }
}
if( (optind < argc) && (rank == 0))
- fprintf(stderr, "Unkown command-line argument passed. Continuing anyway...\n");
+ fprintf(stderr, "Unkown command-line argument passed. Continuing anyway...\n");
if (!testfile){
- /* Try environment variable if not given as option. */
- prefix = getenv_all(MPI_COMM_WORLD, 0, "HDF5_PARAPREFIX");
- if (prefix)
- {
- /* need 2 extra--1 for the / and 1 for the terminating NULL. */
- testfile = (char*) HDmalloc(strlen(prefix) + 2 + strlen(TESTFNAME));
- strcpy(testfile, prefix);
- /* Append a / just in case they didn't end their path with one */
- strcat(testfile, "/" TESTFNAME);
- }
- else
- {
- testfile = strdup(TESTFNAME);
- }
+ /* Try environment variable if not given as option. */
+ prefix = getenv_all(MPI_COMM_WORLD, 0, "HDF5_PARAPREFIX");
+ if (prefix)
+ {
+ /* need 2 extra--1 for the / and 1 for the terminating NULL. */
+ testfile = (char*) HDmalloc(strlen(prefix) + 2 + strlen(TESTFNAME));
+ strcpy(testfile, prefix);
+ /* Append a / just in case they didn't end their path with one */
+ strcat(testfile, "/" TESTFNAME);
+ }
+ else
+ {
+ testfile = strdup(TESTFNAME);
+ }
}
printf("Process %d: testfile=%s\n", rank, testfile);
fflush(stdout);
@@ -819,18 +821,18 @@ main(int argc, char* argv[])
if(write_size == 0)
{
- lb = 16*numprocs*sizeof(int);
- /* 1MB MPIO-IO overlapping is failing in copper. Lower it now pending
- permenant fix for copper.*/
- /* ub = 1024*1024;*/
- ub = lb*128;
- inc = 4;
+ lb = 16*numprocs*sizeof(int);
+ /* 1MB MPIO-IO overlapping is failing in copper. Lower it now pending
+ permenant fix for copper.*/
+ /* ub = 1024*1024;*/
+ ub = lb*128;
+ inc = 4;
}
else
{
- lb = write_size;
- ub = write_size+1;
- inc = 2;
+ lb = write_size;
+ ub = write_size+1;
+ inc = 2;
}
#ifndef STANDALONE
@@ -840,69 +842,69 @@ main(int argc, char* argv[])
for(write_size = lb; write_size <= ub; write_size*=inc)
{
- if(rank == 0)
- printf("\nTesting size %d\n", write_size);
-
- if(mpi_tests)
- {
- if(rank == 0)
- printf("Testing allwrite_allread_blocks with MPI IO\t\t"); fflush(stdout);
- allwrite_allread_blocks(numprocs, rank, write_size/(numprocs*sizeof(int)));
- PRINT_RESULT();
- MPI_Barrier(MPI_COMM_WORLD);
-
- if(rank == 0)
- printf("Testing allwrite_allread_interlaced with MPI IO\t\t"); fflush(stdout);
- allwrite_allread_interlaced(numprocs, rank, write_size/(numprocs*sizeof(int)));
- PRINT_RESULT();
- MPI_Barrier(MPI_COMM_WORLD);
-
- if(rank == 0)
- printf("Testing allwrite_allread_overlap with MPI IO\t\t"); fflush(stdout);
- allwrite_allread_overlap(numprocs, rank, write_size);
- PRINT_RESULT();
- MPI_Barrier(MPI_COMM_WORLD);
-
- if(rank == 0)
- printf("Testing onewrite_allread_blocks with MPI IO\t\t"); fflush(stdout);
- onewrite_allread_blocks(numprocs, rank, write_size/(numprocs*sizeof(int)));
- PRINT_RESULT();
- MPI_Barrier(MPI_COMM_WORLD);
-
- if(rank == 0)
- printf("Testing onewrite_allread_interlaced with MPI IO\t\t"); fflush(stdout);
- onewrite_allread_interlaced(numprocs, rank, write_size/(numprocs*sizeof(int)));
- PRINT_RESULT();
- MPI_Barrier(MPI_COMM_WORLD);
- }
-
- if(posix_tests)
- {
- if(rank == 0)
- printf("Testing allwrite_allread_blocks with POSIX IO\t\t"); fflush(stdout);
- posix_allwrite_allread_blocks(numprocs, rank, write_size/(numprocs*sizeof(int)));
- PRINT_RESULT();
- MPI_Barrier(MPI_COMM_WORLD);
-
- if(rank == 0)
- printf("Testing onewrite_allread_blocks with POSIX IO\t\t"); fflush(stdout);
- posix_onewrite_allread_blocks(numprocs, rank, write_size/(numprocs*sizeof(int)));
- PRINT_RESULT();
- MPI_Barrier(MPI_COMM_WORLD);
-
- if(rank == 0)
- printf("Testing onewrite_allread_interlaced with POSIX IO\t"); fflush(stdout);
- posix_onewrite_allread_interlaced(numprocs, rank, write_size/(numprocs*sizeof(int)));
- PRINT_RESULT();
- MPI_Barrier(MPI_COMM_WORLD);
-
- /* if(rank == 0)
- printf("Testing allwrite_allread_overlap with POSIX IO\t\t"); fflush(stdout);
- posix_allwrite_allread_overlap(numprocs, rank, write_size);
- PRINT_RESULT();
- MPI_Barrier(MPI_COMM_WORLD);
+ if(rank == 0)
+ printf("\nTesting size %d\n", write_size);
+
+ if(mpi_tests)
+ {
+ if(rank == 0)
+ printf("Testing allwrite_allread_blocks with MPI IO\t\t"); fflush(stdout);
+ allwrite_allread_blocks(numprocs, rank, write_size/(numprocs*sizeof(int)));
+ PRINT_RESULT();
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ if(rank == 0)
+ printf("Testing allwrite_allread_interlaced with MPI IO\t\t"); fflush(stdout);
+ allwrite_allread_interlaced(numprocs, rank, write_size/(numprocs*sizeof(int)));
+ PRINT_RESULT();
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ if(rank == 0)
+ printf("Testing allwrite_allread_overlap with MPI IO\t\t"); fflush(stdout);
+ allwrite_allread_overlap(numprocs, rank, write_size);
+ PRINT_RESULT();
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ if(rank == 0)
+ printf("Testing onewrite_allread_blocks with MPI IO\t\t"); fflush(stdout);
+ onewrite_allread_blocks(numprocs, rank, write_size/(numprocs*sizeof(int)));
+ PRINT_RESULT();
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ if(rank == 0)
+ printf("Testing onewrite_allread_interlaced with MPI IO\t\t"); fflush(stdout);
+ onewrite_allread_interlaced(numprocs, rank, write_size/(numprocs*sizeof(int)));
+ PRINT_RESULT();
+ MPI_Barrier(MPI_COMM_WORLD);
+ }
+
+ if(posix_tests)
+ {
+ if(rank == 0)
+ printf("Testing allwrite_allread_blocks with POSIX IO\t\t"); fflush(stdout);
+ posix_allwrite_allread_blocks(numprocs, rank, write_size/(numprocs*sizeof(int)));
+ PRINT_RESULT();
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ if(rank == 0)
+ printf("Testing onewrite_allread_blocks with POSIX IO\t\t"); fflush(stdout);
+ posix_onewrite_allread_blocks(numprocs, rank, write_size/(numprocs*sizeof(int)));
+ PRINT_RESULT();
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ if(rank == 0)
+ printf("Testing onewrite_allread_interlaced with POSIX IO\t"); fflush(stdout);
+ posix_onewrite_allread_interlaced(numprocs, rank, write_size/(numprocs*sizeof(int)));
+ PRINT_RESULT();
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ /* if(rank == 0)
+ printf("Testing allwrite_allread_overlap with POSIX IO\t\t"); fflush(stdout);
+ posix_allwrite_allread_overlap(numprocs, rank, write_size);
+ PRINT_RESULT();
+ MPI_Barrier(MPI_COMM_WORLD);
*/
- }
+ }
}
#ifndef STANDALONE
@@ -912,10 +914,10 @@ main(int argc, char* argv[])
done:
if (testfile)
- HDfree(testfile);
+ HDfree(testfile);
if (rank == 0){
- printf("\nSummary:\n");
- fflush(stdout);
+ printf("\nSummary:\n");
+ fflush(stdout);
}
MPI_Barrier(MPI_COMM_WORLD);
printf("Process %d: encountered %d mismatches.\n", rank, nmismatches);