I would like to instruct HDF5 to read a page aggregated file using the page buffer. A complete reproducer at the end of the post. The file is created like this:
auto fcpl = H5Pcreate(H5P_FILE_CREATE);
H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, false, 0);
auto file = H5Fcreate(filename.c_str(), H5F_ACC_TRUNC, fcpl, H5P_DEFAULT);
To open the file with a page buffer configured I use the following snippet:
auto fapl = H5Pcreate(H5P_FILE_ACCESS);
H5Pset_page_buffer_size(fapl, 1024, 0, 0);
auto file = H5Fopen(filename.c_str(), H5F_ACC_RDONLY, fapl);
When building against the serial version of HDF5 everything works as expected. However, if I build against the parallel version of HDF5, without requesting any MPI-IO or any other change to the code, it fails, producing the following error:
#006: H5Fint.c line 1950 in H5F_open(): page buffering is disabled for parallel
major: File accessibility
minor: Unable to open file
Which leads us to the following line in the repository:
When reading “RFC: Page Buffering” I get the impression that this usecase should be covered, since it mentions regression testing for the parallel case and also alludes to partial support in the parallel version of HDF5. However, the line of code that raises the error is unconditional.
I don’t want to use any MPI-IO when reading this particular file. However, I’d like to still be able to build against the parallel version of HDF5 because:
- I’d like the possibility to read/write other files using MPI-IO.
- It would simplify dependency issues.
Is there some way around this issue? Does anyone know the reasons for why this “temporary” line is still present in the code base?
Many thanks in advance.
// file: paged_buffer.cpp
#include <string>
#include <hdf5.h>
void create_file(const std::string& filename) {
auto fcpl = H5Pcreate(H5P_FILE_CREATE);
H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, false, 0);
auto file = H5Fcreate(filename.c_str(), H5F_ACC_TRUNC, fcpl, H5P_DEFAULT);
H5Pclose(fcpl);
H5Fclose(file);
}
void read_file(const std::string& filename) {
auto fapl = H5Pcreate(H5P_FILE_ACCESS);
H5Pset_page_buffer_size(fapl, 1024, 0, 0);
auto file = H5Fopen(filename.c_str(), H5F_ACC_RDONLY, fapl);
H5Pclose(fapl);
H5Fclose(file);
}
int main() {
std::string filename = "page_allocated.h5";
create_file(filename);
read_file(filename);
return 0;
}
# file: CMakeLists.txt
project(page_buffer)
find_package(HDF5 REQUIRED)
add_executable(page_buffer)
target_sources(page_buffer PRIVATE page_buffer.cpp)
target_link_libraries(page_buffer PUBLIC HDF5::HDF5)