How to detect and solve performance issues using Arm MAP
Before you begin
Before you begin Download and install Arm Forge
Procedure
Procedure Prepare an application for profiling
Run the MAKEFILE to compile the sample application
The compilation command uses the -g flag to generate debug information
Run the application by using MPI with 8 processes
Profile the application and generate a MAP profile file
MAP generates a file containing the application profile and saves it to the current directory
Launch the generated profile file in the MAP GUI
The metrics view shows how numerical measurements change over time and across processes
Source code view
Call stack sorted by total core time
Green shows computing
Blue shows MPI messaging
Orange shows file read/write
Procedure
Procedure Identify workload imbalances
A bottleneck in MPI communications causes MPI_Finalize to take up 45% of the execution time
Note the overall application runtime
This is where the bottleneck occurs
Select a segment of the metrics view
Notice that MPI_Finalize executes at the same time as the mwrite function
Only 1 of 8 processes executes the mwrite function
mwrite takes 12% of the overall execution time of the selected segment
Process 0 calls mwrite to write the result of the matrix multiplication to a file
While process 0 is writing, the other 7 processes must wait for it to complete, causing a workload imbalance.
Check the data write transfer rate to see how fast the results are written to disk
To speed this up, we must rebalance the load across all processes.
In the main function, the partial results from the receiver processes are sent to the manager process.
Then the manager process saves the complete result to a file
Instead, use MPI I/O functions to make all the processes write their results to disk.
We will now modify this code to use MPI I/O functions, recompile it, and generate a new MAP file.
Procedure
Procedure Optimize the code with parallel I/O
Using these MPI I/O functions, we can expect a speedup close to the number of processes for this section of code.
Recompile the modified code and generate a new MAP file
The application runtime shows an increased disk write transfer rate from 2.05 MB/s to 21.1 MB/s
The application now spends 75% of the time in computation, and the total runtime is reduced from 13.1 to 6.6 seconds.