| Products & Services | Industries | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Parallel Computing Toolbox |
| Contents | Index |
| Learn more about Parallel Computing Toolbox |
| On this page… |
|---|
The parallel profiler provides an extension of the profile command and the profile viewer specifically for parallel jobs, to enable you to see how much time each lab spends evaluating each function and how much time communicating or waiting for communications with the other labs. Before using the parallel profiler, familiarize yourself with the standard profiler and its views, as described in Profiling for Improving Performance.
Note The parallel profiler works on parallel jobs, including inside pmode. It does not work on parfor-loops. |
For parallel profiling, you use the mpiprofile command within your parallel job (often within pmode) in a similar way to how you use profile.
To turn on the parallel profiler to start collecting data, enter the following line in your parallel job task M-file, or type at the pmode prompt in the Parallel Command Window:
mpiprofile on
Now the profiler is collecting information about the execution of code on each lab and the communications between the labs. Such information includes:
Execution time of each function on each lab
Execution time of each line of code in each function
Amount of data transferred between each lab
Amount of time each lab spends waiting for communications
With the parallel profiler on, you can proceed to execute your code while the profiler collects the data.
In the pmode Parallel Command Window, to find out if the profiler is on, type:
P>> mpiprofile status
For a complete list of options regarding profiler data details, clearing data, etc., see the mpiprofile reference page.
To open the parallel profile viewer from pmode, type in the Parallel Command Window:
P>> mpiprofile viewer
The remainder of this section is an example that illustrates some of the features of the parallel profile viewer. This example executes in a pmode session running on four local labs. Initiate pmode by typing in the MATLAB Command Window:
pmode start local 4
When the Parallel Command Window (pmode) starts, type the following code at the pmode prompt:
P>> R1 = rand(16, codistributor()) P>> R2 = rand(16, codistributor()) P>> mpiprofile on P>> P = R1*R2 P>> mpiprofile off P>> mpiprofile viewer
The last command opens the Profiler window, first showing the Parallel Profile Summary (or function summary report) for lab 1.

The function summary report displays the data for each function executed on a lab in sortable columns with the following headers:
| Column Header | Description |
|---|---|
| Calls | How many times the function was called on this lab |
| Total Time | The total amount of time this lab spent executing this function |
| Self Time | The time this lab spent inside this function, not within children or subfunctions |
| Total Comm Time | The total time this lab spent transferring data with other labs, including waiting time to receive data |
| Self Comm Waiting Time | The time this lab spent during this function waiting to receive data from other labs |
| Total Interlab Data | The amount of data transferred to and from this lab for this function |
| Computation Time Ratio | The ratio of time spent in computation for this function vs. total time (which includes communication time) for this function |
| Total Time Plot | Bar graph showing relative size of Self Time, Self Comm Waiting Time, and Total Time for this function on this lab |
Click the name of any function in the list for more details about the execution of that function. The function detail report for codistributed.mtimes includes this listing:

The code that is displayed in the report is taken from the client. If the code has changed on the client since the parallel job ran on the labs, or if the labs are running a different version of the functions, the display might not accurately reflect what actually executed.
You can display information for each lab, or use the comparison controls to display information for several labs simultaneously. Two buttons provide Automatic Comparison Selection, allowing you to compare the data from the labs that took the most versus the least amount of time to execute the code, or data from the labs that spent the most versus the least amount of time in performing interlab communication. Manual Comparison Selection allows you to compare data from specific labs or labs that meet certain criteria.
The following listing from the summary report shows the result of using the Automatic Comparison Selection of Compare (max vs. min TotalTime). The comparison shows data from lab 3 compared to lab 1 because these are the labs that spend the most versus least amount of time executing the code.

The following figure shows a summary of all the functions executed during the profile collection time. The Manual Comparison Selection of max Time Aggregate means that data is considered from all the labs for all functions to determine which lab spent the maximum time on each function. Next to each function's name is the lab that took the longest time to execute that function. The other columns list the data from that lab.

The next figure shows a summary report for the labs that spend the most versus least time for each function. A Manual Comparison Selection of max Time Aggregate against min Time >0 Aggregate generated this summary. Both aggregate settings indicate that the profiler should consider data from all labs for all functions, for both maximum and minimum. This report lists the data for codistributed.mtimes from labs 3 and 1, because they spent the maximum and minimum times on this function. Similarly, other functions are listed.

Click on a function name in the summary listing of a comparison to get a detailed comparison. The detailed comparison for codistributed.mtimes looks like this, displaying line-by-line data from both labs:

To see plots of communication data, select Plot All PerLab Communication in the Show Figures menu. The top portion of the plot view report plots how much data each lab receives from each other lab for all functions.

To see only a plot of interlab communication times, select Plot CommTimePerLab in the Show Figures menu.

Plots like those in the previous two figures can help you determine the best way to balance work among your labs, perhaps by altering the partition scheme of your codistributed arrays.
![]() | Programming Tips and Notes | Troubleshooting and Debugging | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |