The Intel® MPI Library includes an Automatic Tuner program, called mpitune. You can use mpitune to find optimal settings for both a cluster and for a specific application. In order to tune a specific application (or to use a benchmark other than the default for a cluster-specific tuning), mpitune needs a way to determine the performance from a run of the application. By default, the runtime of the application will be used. But depending on the application, this could be inaccurate. You might want only the time for a specific portion of the application, or you might want a different measurement, such as FLOPS.
In cases such as these, mpitune provides an option to extract a value from the application’s output using a regular expression, along with an option to specify if this value should be maximized (e.g. FLOPS) or minimized (e.g. time). The command line option -avd (or --application-value-direction) is used to specify the direction of optimization:
-avd min -avd max
A full discussion of regular expressions is beyond the scope of this article. However, a short introduction to the key concepts necessary to get the performance value is necessary. The option -ar (or --application-regexp) allows the user to provide the regular expression needed to extract the application’s performance value. Since this is passed as a command line argument, appropriate escape characters will need to be added so that the correct regular expression gets to mpitune. For example, using
will pass the regular expression \d to mpitune.
The desired value should be enclosed in parentheses to be found. For example, to extract the runtime from output containing the following line
Runtime = 1.62 s
use the following argument:
This will find a line containing “Runtime” followed by any number of whitespace characters (space or tab), an equal sign, any number of whitespace characters, and any number of characters that are either a digit or decimal. The last group will be extracted as the performance measurement. In the example above, that will be 1.62. If there are multiple matches, only the first will be used.
In complex situations, there is another method you can use. If your situation matches any of the following:
- Multiple matching lines within output, and you don’t want the first
- Performance measurement is not directly output, i.e. a combination of factors must be read and the performance calculated from them
- Program writes output to a file rather than stdout
- You don’t want to deal with a complex regular expression
Write a wrapper that will run your program, parse the output, and write only the desired performance measurement to stdout. You can then direct mpitune to run this program and extract the output using a simple regular expression. If your wrapper outputs only the performance number and no associated text, you can use
This will take all output from stdout and use it as the performance measurement.
Another point to keep in mind is that mpitune can correctly handle scientific format. So you do not need to parse this beforehand.