How to store 3D data in parallel always in the same coordinates?


I am trying to store 3D data (the memory layout is one array, the data sizes are NX * NY * NZ) in the HDF5 file. Since I want to distribute a large array to several MPI processes, each process has one data array with size myNX * NY * NZwhere myNX = NX / mpi_size.

I want him to always write the same data to the same "coordinates" inside the HDF5 file, so the number of processes that write / read the HDF5 file does not affect the data layout. Here are some of my code:

Setting up local arrays:

data = new double[myNX * NY * NZ];
for(unsigned int k = 0; k < NZ; k++) {
    for(unsigned int j = 0; j < NY; j++) {
        for(unsigned int i = 0; i < myNX; i++) {
            data[k * (myNX * NY) + j * myNX + i] = getValue(i, j, k);
        }
    }
}

getValue() double i.j0k, , (, i = 3, j = 2, k = 1 3.201). NX = 9; NY = NZ = 2.

:

hid_t h5_hyperslab_file_id = H5Dget_space(h5_dataset_id);
hsize_t offset[] = {0, 0, 0};
offset[0] = getOffsetX(mpi_rank, mpi_size);
hsize_t length[] = {myNX, NY, NZ};
hsize_t stride[] = {1, 1, 1};
H5Sselect_hyperslab(h5_hyperslab_file_id, H5S_SELECT_SET, offset, stride, length, NULL);

:

hid_t h5_memory_dataspace_id = H5Screate_simple(3, length, length);
h5_plist_id = H5Pcreate(H5P_DATASET_XFER);
H5Pset_dxpl_mpio(h5_plist_id, H5FD_MPIO_COLLECTIVE);
H5Dwrite(h5_dataset_id, H5T_NATIVE_DOUBLE, h5_memory_dataspace_id, h5_hyperslab_file_id, h5_plist_id, data);

, . , (, , :().

,
Velines

: : , . "" HDF5. ?

+3

All Articles