To view and/or download the second example code, click on this file name: parallel_read.c

In this example, each MPI process (up to 4 processes) reads a different dataset from an HDF5 file. If the number of processes is less than four, some datasets will be empty (zeros). Note that we will read the two files created in the previous example. Again, the instructions are written to work on TACC's' Frontera, but with suitable modifications, they ought to work on other systems as well.

Compile the example code, parallel_read.c:

$ mpicc -o parallel_read.exe -I$TACC_HDF5_INC -L$TACC_HDF5_LIB -lhdf5 -lz parallel_read.c

Run the executable according to the following template (note that on TACC systems, ibrun normally replaces mpirun):


$ mpirun -np <procs> ./parallel_read.exe <filename> <dataset_dimx> <dataset_dimy> <dataset1> <dataset2>

For example, to have two processes read two 4x4 datasets from the first output file that was created previously, run the following command:

$ mpirun -np 2 ./parallel_read.exe test1.h5 4 4 v2 v4

The processes with rank 0 and rank 1 read datasets v2 and v4, respectively. The output is the first element of v4, i.e., the first element of the dataset that was read by the process with the highest rank.

To have two processes read the corresponding 4x4 datasets from the second output file that was created previously, run the following command:

$ mpirun -np 2 ./parallel_read.exe test2.h5 4 4 v2 v4

Is the difference in the output understandable to you? (Take a look back at how the two files were written.)

 
©  |   Cornell University    |   Center for Advanced Computing    |   Copyright Statement    |   Inclusivity Statement