next up previous index
Next: Exercises Up: File Hints Previous: Program queryinfo.c

The Discussion

The program begins the same way our previous programs have. The master process reads the command line and then passes the options to other processes. Eventually a file is opened with the call to MPI_File_open. But we don't write anything on it in this program. Instead we extract the default info object from it by calling function  MPI_File_get_info:

    MPI_File_get_info(fh, &info_used);
Whatever info has been used on opening the file is returned on info_used. Now we ask about the number of (key, value) pairs inside the info by calling function  MPI_Info_get_nkeys
    MPI_Info_get_nkeys(info_used, &nkeys);
The number of pairs is returned on nkeys. Now we can loop through all the pairs and obtain the key string for each pair first, and then having the key string, we can obtain the value associated with the key. This is done by calling  MPI_Info_get_nthkey to get the key and then  MPI_Info_get to get the value.
    for (i = 0; i < nkeys; i++) {
       MPI_Info_get_nthkey(info_used, i, key);
       MPI_Info_get(info_used, key, MPI_MAX_INFO_VAL, value, &exists);
       if (verbose)
          if (exists)
             printf("%3d: key = %s, value = %s\n", my_rank, key, value);
In this case every key we pass to MPI_Info_get exists, because we got it from the info object in the first place with the call to MPI_Info_get_nthkey, but MPI_Info_get may be used in other ways, e.g., just to check whether a particular (key, value) pair is at all defined within the info, and then the exists flag comes handy.

And this is all the program does. The file gets closed, the info gets freed, the processes hit MPI_Finalize and exit:

  } /* end of the for loop */


A typical output from a process that has just opened on MPI file on our GPFS is going to look as follows:

  2: key = cb_buffer_size, value = 4194304
  2: key = romio_cb_read, value = automatic
  2: key = romio_cb_write, value = automatic
  2: key = cb_nodes, value = 4
  2: key = romio_no_indep_rw, value = false
  2: key = ind_rd_buffer_size, value = 4194304
  2: key = ind_wr_buffer_size, value = 524288
  2: key = romio_ds_read, value = automatic
  2: key = romio_ds_write, value = automatic
  2: key = cb_config_list, value = *:1
The cb_buffer_size and cb_nodes are the only hints reserved by the MPI-2 standard. All the other hints here are the implementation hints. In particular we find that the size of the buffer space that can be used for collective buffering on each target node (cb_buffer_size) is 4MB. We also find that the default value for ind_wr_buffer_size is pretty small, only 0.5MB. You may try to increase this value to 4194304 by calling function  MPI_Info_set:
int MPI_Info_set(MPI_Info info, char *key, char *value)
note that the value has to be a character string, not an integer, and then passing the modified info back to the file with  MPI_File_set_info:
int MPI_File_set_info(MPI_File fh, MPI_Info info)

next up previous index
Next: Exercises Up: File Hints Previous: Program queryinfo.c
Zdzislaw Meglicki