Parallel read of a single HDF5 file

Happy New Year!

I have read that I can open the same HDF5 file in parallel. But it does not work as advertised.

In what way does it not function as advertised?

1 Like

We are trying to open the same HDF5 file concurrently with three threads. We open with RDONLY, hid_t h5file = H5Fopen(fileName.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);. The error we got is as following:
thread_readonly1, open file /afdp/build/development/src/ftdp-test/jni-cpp-h5/Sim_Test_4_100Hz_AMS122.h5
thread_readonly2, open file /afdp/build/development/src/ftdp-test/jni-cpp-h5/Sim_Test_4_100Hz_AMS122.h5
thread_readonly3, open file /afdp/build/development/src/ftdp-test/jni-cpp-h5/Sim_Test_4_100Hz_AMS122.h5
HDF5-DIAG: Error detected in HDF5 (1.10.5) thread 0:
#000: …/…/src/H5F.c line 509 in H5Fopen(): unable to open file
major: File accessibilty
minor: Unable to open file
#001: …/…/src/H5Fint.c line 1690 in H5F_open(): file close degree doesn’t match
major: File accessibilty
minor: Unable to initialize object
Failed to open file /afdp/build/development/src/ftdp-test/jni-cpp-h5/Sim_Test_4_100Hz_AMS122.h5
HDF5-DIAG: Error detected in HDF5 (1.10.5) thread 0:
#000: …/…/src/H5F.c line 509 in H5Fopen(): unable to open file
major: File accessibilty
minor: Unable to open file
#001: …/…/src/H5Fint.c line 1690 in H5F_open(): file close degree doesn’t match
major: File accessibilty
minor: Unable to initialize object
#002: …/…/src/H5F.c line 509 in H5Fopen(): unable to open file
major: File accessibilty
minor: Unable to open file
#003: …/…/src/H5Fint.c line 1690 in H5F_open(): file close degree doesn’t match
major: File accessibilty
minor: Unable to initialize object
Failed to open file /afdp/build/development/src/ftdp-test/jni-cpp-h5/Sim_Test_4_100Hz_AMS122.h5
thread_readonly1, close file /afdp/build/development/src/ftdp-test/jni-cpp-h5/Sim_Test_4_100Hz_AMS122.h5". Please help. Thank you very much.

People often meen different things when they want to

Parallel as in ‘multiple threads’ (as you seem to suggest), or ‘multiple processes’ (e.g., MPI)?
Both are possible, but require different approaches. For multiple threads, you need a thread-safe built of the library. Note though that there won’t be any concurrency, but your multi-threaded application will behave correctly. For multiple processes a la MPI, you’d need to use the MPI-I/O virtual file driver via the file access property list in H5Fopen (or H5Fcreate). G.