[svn-r7848] Purpose:

Update

Description:
    This completes Phase I of the FPHDF5 testing. This test does the
    following:

        - Creates a file
        - Creates multiple non-root groups
        - For each process:
            For each non-root group:
                Create multiple datasets
            Access all datasets created above
            Write to all datasets created above
        - Close the file
        - Reopen the file and verify the data is correct

Platforms tested:
    AIX (w/ FPHDF5)
    Linux (w/ FPHDF5)
    Solaris (w/ Fortran & C++)

Misc. update:
This commit is contained in:
Bill Wendling 2003-11-13 15:08:43 -05:00
parent e3a280a165
commit ce045b62d2

View File

@ -35,19 +35,18 @@
* Local Functions
*===----------------------------------------------------------------------===
*/
static hid_t create_file(const char *filename);
static hid_t create_group(hid_t loc, const char *grp_name, size_t size_hint);
static hid_t create_dset(hid_t loc, const char *dset_name);
static void access_dset(hid_t loc, const char *dset_name);
static void slab_set(hssize_t start[], hsize_t count[],
hsize_t stride[], hsize_t block[]);
static void fill_data(hssize_t start[], hsize_t count[]);
static void write_data(hid_t loc, const char *dset_name,
hssize_t start[], hsize_t count[],
hsize_t stride[], hsize_t block[],
int *buf);
hsize_t stride[], hsize_t block[]);
static void verify_dataset(hid_t loc, const char *dset_name, hssize_t start[],
hsize_t count[], hsize_t stride[], hsize_t block[],
int *original);
static hid_t create_file(const char *filename);
hsize_t count[], hsize_t stride[], hsize_t block[]);
static void test_group_creation(hid_t loc);
static void test_dataset_creation(hid_t loc);
static void test_dataset_access(hid_t loc);
@ -86,15 +85,22 @@ enum {
DIM1 = 12
};
int nerrors = 0; /* Errors count */
int verbose = 0; /* Verbose, default is no */
static MPI_Comm SAP_Comm = MPI_COMM_NULL; /* COMM for FPHDF5 */
static MPI_Comm SAP_Barrier_Comm = MPI_COMM_NULL; /* COMM used in barriers*/
static hid_t fapl = -1; /* FPHDF5 file access property list */
static int mpi_rank; /* Rank of this process */
static int mpi_size; /* Size of the COMM passed to FPHDF5 */
static int *orig_data = NULL; /* Data that's written to datasets */
int nerrors = 0; /* Errors count */
int verbose = 0; /* Verbose, default is no */
/* Hyperslab settings */
static hssize_t start[RANK];
static hsize_t count[RANK];
static hsize_t stride[RANK];
static hsize_t block[RANK];
static const char *progname = "t_fphdf5";
@ -106,6 +112,27 @@ static char dset_name[128];
static const char *grp_tmpl = "Process %d's Datasets";
static char grp_name[128];
/*-------------------------------------------------------------------------
* Function: create_file
* Purpose: Create a new file with the given filename.
* Return: Success: Valid file ID
* Failure: -1
* Programmer: Bill Wendling
* 29. October 2003
* Modifications:
*-------------------------------------------------------------------------
*/
static hid_t
create_file(const char *filename)
{
hid_t fid = -1;
fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
VRFY((fid >= 0), "H5Fcreate");
printf("%d: Created file %s\n", mpi_rank, filename);
return fid;
}
/*-------------------------------------------------------------------------
* Function: create_group
* Purpose: Helper function that creates a group at the given
@ -122,10 +149,8 @@ create_group(hid_t loc, const char *grp_name, size_t size_hint)
{
hid_t group;
fprintf(stderr, "%d: Creating group \"%s\"\n", mpi_rank, grp_name);
VRFY(((group = H5Gcreate(loc, grp_name, size_hint)) >= 0), "H5Gcreate");
fprintf(stderr, "%d: Created group \"%s\"\n", mpi_rank, grp_name);
printf("%d: Created group \"%s\"\n", mpi_rank, grp_name);
return group;
}
@ -147,11 +172,11 @@ create_dset(hid_t loc, const char *dset_name)
hid_t dset, sid;
VRFY(((sid = H5Screate_simple(RANK, dims, NULL)) >= 0), "H5Screate_simple");
fprintf(stderr, "%d: Created simple dataspace\n", mpi_rank);
printf("%d: Created simple dataspace\n", mpi_rank);
dset = H5Dcreate(loc, dset_name, H5T_NATIVE_INT, sid, H5P_DEFAULT);
VRFY((dset >= 0), "H5Dcreate");
fprintf(stderr, "%d: Created dataset \"%s\"\n", mpi_rank, dset_name);
printf("%d: Created dataset \"%s\"\n", mpi_rank, dset_name);
VRFY((H5Sclose(sid) >= 0), "H5Sclose");
return dset;
@ -201,9 +226,30 @@ slab_set(hssize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[])
start[1] = 0;
}
/*-------------------------------------------------------------------------
* Function: fill_data
* Purpose: Fill data buffer with some data.
* Return: Nothing
* Programmer: Bill Wendling
* 13. November 2003
* Modifications:
*-------------------------------------------------------------------------
*/
static void
fill_data(hssize_t start[], hsize_t count[])
{
int *dataptr = orig_data;
int i, j;
/* put some trivial data in the buffer */
for (i = 0; i < block[0]; ++i)
for (j = 0; j < block[1]; ++j)
*dataptr++ = (j + start[0]) * 100 + j + start[1] + 1;
}
/*-------------------------------------------------------------------------
* Function: write_data
* Purpose: Helper function that writes data to a dataset.
* Purpose: Writes data to a dataset.
* Return: Nothing, but aborts if an error occurs.
* Programmer: Bill Wendling
* 29. October 2003
@ -212,13 +258,13 @@ slab_set(hssize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[])
*/
static void
write_data(hid_t loc, const char *dset_name, hssize_t start[], hsize_t count[],
hsize_t stride[], hsize_t block[], int *buf)
hsize_t stride[], hsize_t block[])
{
herr_t hrc;
hid_t file_dataspace, mem_dataspace;
hid_t dataset, xfer;
hsize_t j, k;
int *dataptr = buf;
int *dataptr = orig_data;
/* See if dataset is there */
VRFY(((dataset = H5Dopen(loc, dset_name)) >= 0), "H5Dopen");
@ -243,7 +289,7 @@ write_data(hid_t loc, const char *dset_name, hssize_t start[], hsize_t count[],
VRFY((mem_dataspace >= 0), "H5Screate_simple");
hrc = H5Dwrite(dataset, H5T_NATIVE_INT, mem_dataspace,
file_dataspace, H5P_DEFAULT, buf);
file_dataspace, H5P_DEFAULT, orig_data);
VRFY((hrc >= 0), "H5Dwrite");
VRFY((H5Sclose(mem_dataspace) >= 0), "H5Sclose");
@ -263,7 +309,7 @@ write_data(hid_t loc, const char *dset_name, hssize_t start[], hsize_t count[],
*/
static void
verify_dataset(hid_t loc, const char *dset_name, hssize_t start[], hsize_t count[],
hsize_t stride[], hsize_t block[], int *original)
hsize_t stride[], hsize_t block[])
{
hid_t dataset, file_dataspace, mem_dataspace;
hsize_t i, j;
@ -291,20 +337,22 @@ verify_dataset(hid_t loc, const char *dset_name, hssize_t start[], hsize_t count
/* Verify the contents of the dataset */
for (i = 0; i < block[0]; ++i)
for (j = 0; j < block[1]; ++j)
if (*data_array != *original) {
if (*data_array != *orig_data) {
if (vrfyerrs++ < MAX_ERR_REPORT)
fprintf(stderr,
"Dataset Verify failed at "
"[%ld][%ld](row %ld, col %ld): expect %d, got %d\n",
(long)i, (long)j, (long)(i + start[0]),
(long)(j + start[1]), *original, *data_array);
(long)(j + start[1]), *orig_data, *data_array);
++data_array;
++original;
++orig_data;
}
if (vrfyerrs)
if (vrfyerrs) {
fprintf(stderr, "%d errors found in verify_dataset\n", vrfyerrs);
++nerrors;
}
VRFY((H5Sclose(mem_dataspace) >= 0), "H5Sclose");
VRFY((H5Sclose(file_dataspace) >= 0), "H5Sclose");
@ -312,27 +360,6 @@ verify_dataset(hid_t loc, const char *dset_name, hssize_t start[], hsize_t count
free(data_array);
}
/*-------------------------------------------------------------------------
* Function: create_file
* Purpose: Create a new file with the given filename.
* Return: Success: Valid file ID
* Failure: -1
* Programmer: Bill Wendling
* 29. October 2003
* Modifications:
*-------------------------------------------------------------------------
*/
static hid_t
create_file(const char *filename)
{
hid_t fid = -1;
fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
VRFY((fid >= 0), "H5Fcreate");
fprintf(stderr, "%d: Created file %s\n", mpi_rank, filename);
return fid;
}
/*-------------------------------------------------------------------------
* Function: test_group_creation
* Purpose: Test creation of multiple groups in the file.
@ -346,11 +373,12 @@ static void
test_group_creation(hid_t loc)
{
if (mpi_rank == 0) {
hid_t group;
int i;
for (i = 0; i < mpi_size; ++i)
if (i != SAP_RANK) {
hid_t group;
sprintf(grp_name, grp_tmpl, i);
group = create_group(loc, grp_name, 4);
VRFY((H5Gclose(group) >= 0), "H5Gclose");
@ -415,28 +443,29 @@ test_dataset_creation(hid_t loc)
static void
test_dataset_access(hid_t loc)
{
hid_t group;
int i;
for (i = 0; i < mpi_size; ++i)
if (i != SAP_RANK) {
hid_t group;
sprintf(grp_name, grp_tmpl, i);
VRFY(((group = H5Gopen(loc, grp_name)) >= 0), "H5Gopen");
sprintf(dset_name, dset_tmpl, 0);
fprintf(stderr, "%d: Accessing dataset \"%s/%s\"\n", mpi_rank, grp_name, dset_name);
printf("%d: Accessing dataset \"%s/%s\"\n", mpi_rank, grp_name, dset_name);
access_dset(group, dset_name);
sprintf(dset_name, dset_tmpl, 1);
fprintf(stderr, "%d: Accessing dataset \"%s/%s\"\n", mpi_rank, grp_name, dset_name);
printf("%d: Accessing dataset \"%s/%s\"\n", mpi_rank, grp_name, dset_name);
access_dset(group, dset_name);
sprintf(dset_name, dset_tmpl, 2);
fprintf(stderr, "%d: Accessing dataset \"%s/%s\"\n", mpi_rank, grp_name, dset_name);
printf("%d: Accessing dataset \"%s/%s\"\n", mpi_rank, grp_name, dset_name);
access_dset(group, dset_name);
sprintf(dset_name, dset_tmpl, 3);
fprintf(stderr, "%d: Accessing dataset \"%s/%s\"\n", mpi_rank, grp_name, dset_name);
printf("%d: Accessing dataset \"%s/%s\"\n", mpi_rank, grp_name, dset_name);
access_dset(group, dset_name);
VRFY((H5Gclose(group) >= 0), "H5Gclose");
@ -458,19 +487,7 @@ test_dataset_access(hid_t loc)
static void
test_dataset_write(hid_t loc)
{
hid_t group;
int i, *data_array = NULL;
/* Hyperslab settings */
hssize_t start[RANK];
hsize_t count[RANK];
hsize_t stride[RANK];
hsize_t block[RANK];
data_array = (int *)malloc(DIM0 * DIM1 * sizeof(int));
VRFY((data_array != NULL), "data_array malloc succeeded");
slab_set(start, count, stride, block);
int i;
/*===-------------------------------------------------------------------===
* All processes write to each dataset.
@ -478,39 +495,39 @@ test_dataset_write(hid_t loc)
*/
for (i = 0; i < mpi_size; ++i)
if (i != SAP_RANK) {
hid_t group;
sprintf(grp_name, grp_tmpl, i);
VRFY(((group = H5Gopen(loc, grp_name)) >= 0), "H5Gopen");
/* Write to this dataset */
sprintf(dset_name, dset_tmpl, 0);
fprintf(stderr, "%d: Writing to \"/%s/%s\"\n", mpi_rank, grp_name, dset_name);
write_data(group, dset_name, start, count, stride, block, data_array);
fprintf(stderr, "%d: Verifying dataset \"/%s/%s\"\n", mpi_rank, grp_name, dset_name);
verify_dataset(group, dset_name, start, count, stride, block, data_array);
printf("%d: Writing to \"/%s/%s\"\n", mpi_rank, grp_name, dset_name);
write_data(group, dset_name, start, count, stride, block);
printf("%d: Verifying dataset \"/%s/%s\"\n", mpi_rank, grp_name, dset_name);
verify_dataset(group, dset_name, start, count, stride, block);
sprintf(dset_name, dset_tmpl, 1);
fprintf(stderr, "%d: Writing to \"/%s/%s\"\n", mpi_rank, grp_name, dset_name);
write_data(group, dset_name, start, count, stride, block, data_array);
fprintf(stderr, "%d: Verifying dataset \"/%s/%s\"\n", mpi_rank, grp_name, dset_name);
verify_dataset(group, dset_name, start, count, stride, block, data_array);
printf("%d: Writing to \"/%s/%s\"\n", mpi_rank, grp_name, dset_name);
write_data(group, dset_name, start, count, stride, block);
printf("%d: Verifying dataset \"/%s/%s\"\n", mpi_rank, grp_name, dset_name);
verify_dataset(group, dset_name, start, count, stride, block);
sprintf(dset_name, dset_tmpl, 2);
fprintf(stderr, "%d: Writing to \"/%s/%s\"\n", mpi_rank, grp_name, dset_name);
write_data(group, dset_name, start, count, stride, block, data_array);
fprintf(stderr, "%d: Verifying dataset \"/%s/%s\"\n", mpi_rank, grp_name, dset_name);
verify_dataset(group, dset_name, start, count, stride, block, data_array);
printf("%d: Writing to \"/%s/%s\"\n", mpi_rank, grp_name, dset_name);
write_data(group, dset_name, start, count, stride, block);
printf("%d: Verifying dataset \"/%s/%s\"\n", mpi_rank, grp_name, dset_name);
verify_dataset(group, dset_name, start, count, stride, block);
sprintf(dset_name, dset_tmpl, 3);
fprintf(stderr, "%d: Writing to \"/%s/%s\"\n", mpi_rank, grp_name, dset_name);
write_data(group, dset_name, start, count, stride, block, data_array);
fprintf(stderr, "%d: Verifying dataset \"/%s/%s\"\n", mpi_rank, grp_name, dset_name);
verify_dataset(group, dset_name, start, count, stride, block, data_array);
printf("%d: Writing to \"/%s/%s\"\n", mpi_rank, grp_name, dset_name);
write_data(group, dset_name, start, count, stride, block);
printf("%d: Verifying dataset \"/%s/%s\"\n", mpi_rank, grp_name, dset_name);
verify_dataset(group, dset_name, start, count, stride, block);
/* Close the group */
VRFY((H5Gclose(group) >= 0), "H5Gclose");
}
free(data_array);
}
/*-------------------------------------------------------------------------
@ -583,14 +600,14 @@ main(int argc, char *argv[])
h5_show_hostname();
if (MAINPROCESS) {
fprintf(stderr, "===================================\n");
fprintf(stderr, "FPHDF5 functionality tests\n");
fprintf(stderr, "===================================\n");
printf("===================================\n");
printf("FPHDF5 functionality tests\n");
printf("===================================\n");
}
hrc = H5FPinit(MPI_COMM_WORLD, SAP_RANK, &SAP_Comm, &SAP_Barrier_Comm);
VRFY((hrc == MPI_SUCCESS), "H5FP_init");
fprintf(stderr, "%d: Initialized FPHDF5\n", mpi_rank);
printf("%d: Initialized FPHDF5\n", mpi_rank);
if (mpi_rank != SAP_RANK) {
/*
@ -601,12 +618,18 @@ main(int argc, char *argv[])
fapl = H5Pcreate(H5P_FILE_ACCESS);
VRFY((fapl >= 0), "H5Pcreate");
fprintf(stderr, "%d: Created access property list\n", mpi_rank);
printf("%d: Created access property list\n", mpi_rank);
hrc = H5Pset_fapl_fphdf5(fapl, SAP_Comm, SAP_Barrier_Comm,
MPI_INFO_NULL, (unsigned)SAP_RANK);
VRFY((fapl >= 0), "H5Pset_fapl_fphdf5");
fprintf(stderr, "%d: Set access property list\n", mpi_rank);
printf("%d: Set access property list\n", mpi_rank);
orig_data = (int *)malloc(DIM0 * DIM1 * sizeof(int));
VRFY((orig_data != NULL), "orig_data malloc succeeded");
slab_set(start, count, stride, block);
fill_data(start, count);
for (i = 0; i < sizeof(FILENAME) / sizeof(FILENAME[0]) - 1; ++i) {
if (h5_fixname(FILENAME[i], fapl, filenames[i], sizeof(filenames[i])) == NULL) {
@ -627,20 +650,60 @@ main(int argc, char *argv[])
VRFY((H5Fclose(fid) >= 0), "H5Fclose");
SYNC(SAP_Barrier_Comm);
fprintf(stderr, "%d: Closed file\n", mpi_rank);
printf("%d: Closed file\n", mpi_rank);
fid = H5Fopen(filenames[i], H5F_ACC_RDONLY, fapl);
VRFY((fid >= 0), "H5Fopen");
SYNC(SAP_Barrier_Comm);
/*===------------------------------------------------------------===
* Reverify that the data is still "correct"
*===------------------------------------------------------------===
*/
for (i = 0; i < mpi_size; ++i)
if (i != SAP_RANK) {
hid_t group;
sprintf(grp_name, grp_tmpl, i);
VRFY(((group = H5Gopen(fid, grp_name)) >= 0), "H5Gopen");
/* Write to this dataset */
sprintf(dset_name, dset_tmpl, 0);
printf("%d: Reverifying dataset \"/%s/%s\"\n", mpi_rank,
grp_name, dset_name);
verify_dataset(group, dset_name, start, count, stride, block);
sprintf(dset_name, dset_tmpl, 1);
printf("%d: Reverifying dataset \"/%s/%s\"\n", mpi_rank,
grp_name, dset_name);
verify_dataset(group, dset_name, start, count, stride, block);
sprintf(dset_name, dset_tmpl, 2);
printf("%d: Reverifying dataset \"/%s/%s\"\n", mpi_rank,
grp_name, dset_name);
verify_dataset(group, dset_name, start, count, stride, block);
sprintf(dset_name, dset_tmpl, 3);
printf("%d: Reverifying dataset \"/%s/%s\"\n", mpi_rank,
grp_name, dset_name);
verify_dataset(group, dset_name, start, count, stride, block);
/* Close the group */
VRFY((H5Gclose(group) >= 0), "H5Gclose");
}
SYNC(SAP_Barrier_Comm);
VRFY((H5Fclose(fid) >= 0), "H5Fclose");
}
free(orig_data);
if (fapl > -1)
h5_cleanup(FILENAME, fapl);
}
VRFY((H5FPfinalize() >= 0), "H5FPfinalize");
fprintf(stderr, "%d: H5FP finalized\n", mpi_rank);
printf("%d: H5FP finalized\n", mpi_rank);
if (MAINPROCESS) { /* only process 0 reports */
fprintf(stderr, "===================================\n");
@ -671,7 +734,7 @@ main(int argc, char *argv[])
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
if (mpi_rank == 0)
fprintf(stderr, "No t_fphdf5 test because FPHDF5 is not configured in\n");
printf("No t_fphdf5 test because FPHDF5 is not configured in\n");
MPI_Finalize();
return 0;