Application Performance Snapshot User's Guide for Linux* OS
Application Performance Snapshot supports the region control with the MPI_Pcontrol() operation. This allows you to enable and disable statistics collection for specific application regions in the source code.
By default, the statistics collection is enabled for the entire application. To disable the collection starting from a certain point, insert the MPI_Pcontrol(0) call in your code. Similarly, insert the MPI_Pcontrol(1) call to enable collection again. For example:
... MPI_Pcontrol(0); MPI_Comm_size (MPI_COMM_WORLD, &size); MPI_Comm_rank (MPI_COMM_WORLD, &rank); MPI_Pcontrol(1); ...
MPI_Pcontrol() also allows you to mark specific code regions using unique numbers in the range between 5 and 14, inclusively. The beginning of the region is marked with a MPI_Pcontrol(<region>) call, and the end of the region is marked with MPI_Pcontrol(-<region>). You can mark several non-contiguous code sections with the same region number to include them into the same region. MPI_Pcontrol(0) and MPI_Pcontrol(1) disable and enable statistics collection for all regions at once, respectively.
The following example demonstrates how to mark code regions with MPI_Pcontrol():
... if (rank == 0) { MPI_Pcontrol(5); for (i = 1; i < size; i++) MPI_Recv (&rank, 1, MPI_INT, i, 1, MPI_COMM_WORLD, &stat); MPI_Pcontrol(-5); } else { MPI_Pcontrol(6); MPI_Send (&rank, 1, MPI_INT, 0, 1, MPI_COMM_WORLD); MPI_Pcontrol(-6); } ...
If an application contains regions, the statistics will be collected for the entire application and for that region specifically. Region statistics data is saved in a separate folder aps_result_<date>_<region>, for example aps_result_20171231_6.
As it was mentioned above, region numbers from 0 to 4 are unavailable (0 and 1 have special meanings; 2, 3 and 4 are ignored), and regular regions start with the number 5. You can change this behavior and also make 1, 2, 3 and 4 regular regions, or make regular regions start with a greater number. To do so, set the MPS_PCONTROL_REGION_BEGIN environment variable to the desired value (the default is 5, available values are numbers between 1 and 14, inclusively).
According to the MPI standard, MPI_Pcontrol() can have a variable number of arguments. For Application Performance Snapshot, only the first argument is relevant.