File View Examples

Example 1:

We write contiguous data into a contiguous block defined by a file view. We give each process a different file view using MPI_File_set_view so that together, the processes lay out a series of blocks in the file, one block per process.

In the Task Order file layout, each task uses one segment in the output file and the order of the segments is determined by the task's MPI rank.
MPI task order.
Example 2:

We write contiguous data into two separate blocks defined by a file view. Each block is a contiguous type in memory, but the pair of blocks is a vector type in the file view. We again use displacements to lay out a series of blocks in the file, so that two blocks are written per process, in a repeating fashion.

In a round robin pattern, the first portion of each task's data is written to the first portion of the file, and the second portion of each task's data is written to the second portion of the file, and so on. The resulting file structure is a continuous block of first-portion data followed by a block of second-portion data.
Round robin order.
  • The data type in memory is just a contiguous set of NW ints.
  • The file view is of type fileblk, displaced by rank*NW*sizeof(int).
  • Two units of the data type are written into the file whose view has been set.
 
©  |   Cornell University    |   Center for Advanced Computing    |   Copyright Statement    |   Inclusivity Statement