HDF5 write thread concurrency
Is HDF5 able to handle multiple threads on its own, or does it have to be externally synchronized? The OpenMP example suggests the latte开发者_如何学Cr.
If the former, what is the proper way to define the dataspace to write to?
Anycorn,
HDF5 can handle multiple threads without external synchronization, although the writes will still be serial. You should compile the latest version (1.8.6 as of 4/5/2011) and run ./configure
with the --enable-threadsafe
and -with-pthreads=/pthreads-include-path/,/pthreads-lib-path/
flags.
For example:
./configure --enable-threadsafe -with-pthreads=/usr/include,/usr/lib
With regards to defining a dataspace for writing, the simplest way is to construct a basic rectangular-hyperplane using a multi-dimensional array, a rank value, and the H5Screate_simple
function. Mine usually follow the same steps:
//NUM = Number of spaces in this dimension
//Create a 1 dimensional array
hsize_t dsDim[1] = {NUM};
//Create the 1x1xNUM data space (rank param = 1).
hid_t dSpace = H5Screate_simple(1, dsDim, NULL);
...
Create datasets using the dataspace
...
//Release the data space
H5Sclose(dSpace);
Hope this helps!
精彩评论