문제

Is HDF5 able to handle multiple threads on its own, or does it have to be externally synchronized? The OpenMP example suggests the latter.

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!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top