Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compression tests for subfiling #3769

Merged
merged 10 commits into from
Oct 25, 2023
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 132 additions & 12 deletions testpar/t_subfiling_vfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
#define PATH_MAX 4096
#endif

#define DEFAULT_DEFLATE_LEVEL 9

#define ARRAY_SIZE(a) sizeof(a) / sizeof(a[0])

#define CHECK_PASSED() \
Expand Down Expand Up @@ -82,12 +84,15 @@ static char *config_dir = NULL;
int nerrors = 0;
int curr_nerrors = 0;

bool enable_compression = false;

/* Function pointer typedef for test functions */
typedef void (*test_func)(void);

/* Utility functions */
static hid_t create_subfiling_ioc_fapl(MPI_Comm comm, MPI_Info info, bool custom_config,
H5FD_subfiling_params_t *custom_cfg, int32_t thread_pool_size);
static hid_t create_dcpl_id(int rank, const hsize_t dims[], hid_t dxpl_id);

/* Test functions */
static void test_create_and_close(void);
Expand Down Expand Up @@ -182,7 +187,47 @@ create_subfiling_ioc_fapl(MPI_Comm comm, MPI_Info info, bool custom_config,

return H5I_INVALID_HID;
}
/* ---------------------------------------------------------------------------
* Function: create_dcpl_id
*
* Purpose: Creates dataset creation property list identifier with
* chunking and compression, and enforces the
* required collective IO.
*
* Return: Success: HID Dataset creation property list identifier,
* a non-negative value.
* Failure: H5I_INVALID_HID, a negative value.
* ---------------------------------------------------------------------------
*/
static hid_t
create_dcpl_id(int rank, const hsize_t dset_dims[], hid_t dxpl_id)
{
hsize_t chunk_dims[1];
hid_t ret_value = H5I_INVALID_HID;

if ((ret_value = H5Pcreate(H5P_DATASET_CREATE)) < 0)
TEST_ERROR;

if (enable_compression) {
if (H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE) < 0)
TEST_ERROR;
chunk_dims[0] = dset_dims[0] / 2;
if (H5Pset_chunk(ret_value, rank, chunk_dims) < 0)
TEST_ERROR;
if (H5Pset_deflate(ret_value, DEFAULT_DEFLATE_LEVEL) < 0)
TEST_ERROR;
}

return ret_value;

error:
if ((H5I_INVALID_HID != ret_value) && (H5Pclose(ret_value) < 0)) {
H5_FAILED();
AT();
}

return H5I_INVALID_HID;
}
/*
* A simple test that creates and closes a file with the
* subfiling VFD
Expand Down Expand Up @@ -1060,6 +1105,7 @@ test_read_different_stripe_size(void)
hid_t fapl_id = H5I_INVALID_HID;
hid_t dset_id = H5I_INVALID_HID;
hid_t dxpl_id = H5I_INVALID_HID;
hid_t dcpl_id = H5I_INVALID_HID;
hid_t fspace_id = H5I_INVALID_HID;
char *tmp_filename = NULL;
void *buf = NULL;
Expand Down Expand Up @@ -1106,7 +1152,10 @@ test_read_different_stripe_size(void)
fspace_id = H5Screate_simple(1, dset_dims, NULL);
VRFY((fspace_id >= 0), "H5Screate_simple succeeded");

dset_id = H5Dcreate2(file_id, "DSET", SUBF_HDF5_TYPE, fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
dcpl_id = create_dcpl_id(1, dset_dims, dxpl_id);
VRFY((dcpl_id >= 0), "DCPL creation succeeded");

dset_id = H5Dcreate2(file_id, "DSET", SUBF_HDF5_TYPE, fspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT);
VRFY((dset_id >= 0), "Dataset creation succeeded");

/* Select hyperslab */
Expand All @@ -1129,6 +1178,7 @@ test_read_different_stripe_size(void)

VRFY((H5Sclose(fspace_id) >= 0), "File dataspace close succeeded");
VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded");
VRFY((H5Pclose(dcpl_id) >= 0), "DCPL close succeeded");
VRFY((H5Fclose(file_id) >= 0), "File close succeeded");

/* Ensure all the subfiles are present */
Expand All @@ -1153,10 +1203,12 @@ test_read_different_stripe_size(void)
VRFY((fclose(subfile_ptr) >= 0), "fclose on subfile succeeded");

/* Check file size */
VRFY((HDstat(tmp_filename, &subfile_info) >= 0), "HDstat succeeded");
subfile_size = (h5_stat_size_t)subfile_info.st_size;
if (!enable_compression) {
VRFY((HDstat(tmp_filename, &subfile_info) >= 0), "HDstat succeeded");
subfile_size = (h5_stat_size_t)subfile_info.st_size;

VRFY((subfile_size >= cfg.stripe_size), "File size verification succeeded");
VRFY((subfile_size >= cfg.stripe_size), "File size verification succeeded");
}
}
}

Expand Down Expand Up @@ -1376,10 +1428,12 @@ test_subfiling_precreate_rank_0(void)
VRFY((fclose(subfile_ptr) >= 0), "fclose on subfile succeeded");

/* Check file size */
VRFY((HDstat(tmp_filename, &subfile_info) >= 0), "HDstat succeeded");
file_size = (h5_stat_size_t)subfile_info.st_size;
if (!enable_compression) {
VRFY((HDstat(tmp_filename, &subfile_info) >= 0), "HDstat succeeded");
file_size = (h5_stat_size_t)subfile_info.st_size;

VRFY((file_size >= cfg.stripe_size), "File size verification succeeded");
VRFY((file_size >= cfg.stripe_size), "File size verification succeeded");
}
}

/* Verify that there aren't too many subfiles */
Expand Down Expand Up @@ -1470,6 +1524,7 @@ test_subfiling_write_many_read_one(void)
hid_t fapl_id = H5I_INVALID_HID;
hid_t dset_id = H5I_INVALID_HID;
hid_t dxpl_id = H5I_INVALID_HID;
hid_t dcpl_id = H5I_INVALID_HID;
hid_t fspace_id = H5I_INVALID_HID;
void *buf = NULL;

Expand Down Expand Up @@ -1517,7 +1572,10 @@ test_subfiling_write_many_read_one(void)
fspace_id = H5Screate_simple(1, dset_dims, NULL);
VRFY((fspace_id >= 0), "H5Screate_simple succeeded");

dset_id = H5Dcreate2(file_id, "DSET", SUBF_HDF5_TYPE, fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
dcpl_id = create_dcpl_id(1, dset_dims, dxpl_id);
VRFY((dcpl_id >= 0), "DCPL creation succeeded");

dset_id = H5Dcreate2(file_id, "DSET", SUBF_HDF5_TYPE, fspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT);
VRFY((dset_id >= 0), "Dataset creation succeeded");

/* Select hyperslab */
Expand All @@ -1539,6 +1597,7 @@ test_subfiling_write_many_read_one(void)
buf = NULL;

VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded");
VRFY((H5Pclose(dcpl_id) >= 0), "DCPL close succeeded");
VRFY((H5Fclose(file_id) >= 0), "File close succeeded");

mpi_code_g = MPI_Barrier(comm_g);
Expand Down Expand Up @@ -1616,6 +1675,7 @@ test_subfiling_write_many_read_few(void)
hid_t fapl_id = H5I_INVALID_HID;
hid_t dset_id = H5I_INVALID_HID;
hid_t dxpl_id = H5I_INVALID_HID;
hid_t dcpl_id = H5I_INVALID_HID;
hid_t fspace_id = H5I_INVALID_HID;
void *buf = NULL;

Expand Down Expand Up @@ -1673,7 +1733,10 @@ test_subfiling_write_many_read_few(void)
fspace_id = H5Screate_simple(1, dset_dims, NULL);
VRFY((fspace_id >= 0), "H5Screate_simple succeeded");

dset_id = H5Dcreate2(file_id, "DSET", SUBF_HDF5_TYPE, fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
dcpl_id = create_dcpl_id(1, dset_dims, dxpl_id);
VRFY((dcpl_id >= 0), "DCPL creation succeeded");

dset_id = H5Dcreate2(file_id, "DSET", SUBF_HDF5_TYPE, fspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT);
VRFY((dset_id >= 0), "Dataset creation succeeded");

/* Select hyperslab */
Expand All @@ -1695,6 +1758,7 @@ test_subfiling_write_many_read_few(void)
buf = NULL;

VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded");
VRFY((H5Pclose(dcpl_id) >= 0), "DCPL close succeeded");
VRFY((H5Fclose(file_id) >= 0), "File close succeeded");

/*
Expand Down Expand Up @@ -1808,6 +1872,7 @@ test_subfiling_h5fuse(void)
hid_t fapl_id = H5I_INVALID_HID;
hid_t dset_id = H5I_INVALID_HID;
hid_t dxpl_id = H5I_INVALID_HID;
hid_t dcpl_id = H5I_INVALID_HID;
hid_t fspace_id = H5I_INVALID_HID;
void *buf = NULL;
int skip_test = 0;
Expand Down Expand Up @@ -1898,7 +1963,10 @@ test_subfiling_h5fuse(void)
fspace_id = H5Screate_simple(1, dset_dims, NULL);
VRFY((fspace_id >= 0), "H5Screate_simple succeeded");

dset_id = H5Dcreate2(file_id, "DSET", SUBF_HDF5_TYPE, fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
dcpl_id = create_dcpl_id(1, dset_dims, dxpl_id);
VRFY((dcpl_id >= 0), "DCPL creation succeeded");

dset_id = H5Dcreate2(file_id, "DSET", SUBF_HDF5_TYPE, fspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT);
VRFY((dset_id >= 0), "Dataset creation succeeded");

/* Select hyperslab */
Expand All @@ -1919,8 +1987,11 @@ test_subfiling_h5fuse(void)
free(buf);
buf = NULL;

VRFY((H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_INDEPENDENT) >= 0), "H5Pset_dxpl_mpio succeeded");

VRFY((H5Sclose(fspace_id) >= 0), "File dataspace close succeeded");
VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded");
VRFY((H5Pclose(dcpl_id) >= 0), "DCPL close succeeded");
VRFY((H5Fclose(file_id) >= 0), "File close succeeded");

if (MAINPROCESS) {
Expand Down Expand Up @@ -1973,8 +2044,10 @@ test_subfiling_h5fuse(void)
}

/* Verify the size of the fused file */
VRFY((HDstat(SUBF_FILENAME, &file_info) >= 0), "HDstat succeeded");
VRFY(((size_t)file_info.st_size >= target_size), "File size verification succeeded");
if (!enable_compression) {
VRFY((HDstat(SUBF_FILENAME, &file_info) >= 0), "HDstat succeeded");
VRFY(((size_t)file_info.st_size >= target_size), "File size verification succeeded");
}

/* Re-open file with sec2 driver and verify the data */
file_id = H5Fopen(SUBF_FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT);
Expand Down Expand Up @@ -2414,7 +2487,30 @@ main(int argc, char **argv)
if (num_iocs_g > mpi_size)
num_iocs_g = mpi_size;

#ifdef H5_HAVE_FILTER_DEFLATE
if (MAINPROCESS) {
printf(" Re-running tests with compression enabled\n");
brtnfld marked this conversation as resolved.
Show resolved Hide resolved
}
enable_compression = true;
for (size_t i = 5; i < ARRAY_SIZE(tests); i++) {
brtnfld marked this conversation as resolved.
Show resolved Hide resolved
if (MPI_SUCCESS == (mpi_code_g = MPI_Barrier(comm_g))) {
(*tests[i])();
}
else {
if (MAINPROCESS)
MESG("MPI_Barrier failed");
nerrors++;
}
}
enable_compression = false;
#else
if (MAINPROCESS) {
TESTING_2("re-running tests with compression enabled");
SKIPPED();
}
#endif
if (MAINPROCESS) {
puts("");
printf("Re-running tests with environment variables set\n");
}

Expand All @@ -2429,6 +2525,30 @@ main(int argc, char **argv)
}
}

#ifdef H5_HAVE_FILTER_DEFLATE
if (MAINPROCESS) {
puts("");
printf(" Re-running tests with compression enabled\n");
}
enable_compression = true;
for (size_t i = 5; i < ARRAY_SIZE(tests); i++) {
if (MPI_SUCCESS == (mpi_code_g = MPI_Barrier(comm_g))) {
(*tests[i])();
}
else {
if (MAINPROCESS)
MESG("MPI_Barrier failed");
nerrors++;
}
}
enable_compression = false;
#else
if (MAINPROCESS) {
puts("");
TESTING_2("re-running tests with compression enabled");
SKIPPED();
}
#endif
if (MAINPROCESS)
puts("");

Expand Down