MATLAB Distributed Computing Server

Speeding Up Frequency Response Estimation Using Parallel Computing

This example illustrates how to use parallel computing for speeding up frequency response estimation of Simulink models. In some scenarios, the command FRESTIMATE performs multiple Simulink simulations to estimate the frequency response of a Simulink model. You can distribute these simulations to a pool of MATLAB workers by using Parallel Computing Toolbox.

This example requires Parallel Computing Toolbox. You can optionally use MATLAB Distributed Computing Server to run simulations on a computer cluster. This example uses the local worker functionality available in Parallel Computing Toolbox.

Speeding up Simulink Simulations Performed by FRESTIMATE

When you compute frequency response using the FRESTIMATE command, the majority of computation time is usually spent in Simulink simulations. To reduce the total simulation time, you can:

1. Use rapid accelerator mode. See the "linearization validation example" as an example of using rapid accelerator mode with the FRESTIMATE command. Use this method when FRESTIMATE performs only one Simulink simulation.

2. Distribute simulations among workers in a MATLAB pool. Use this method when FRESTIMATE performs multiple Simulink simulations. FRESTIMATE performs more than one Simulink simulation when you specify the following:

A Sinestream input signal with "SimulationOrder" parameter set to "OneAtATime". In this case, each frequency in the Sinestream signal is simulated separately.

Linearization I/O points with more than one input point or a non-scalar input point. In this case, each linearization input point or each channel in a non-scalar linearization input point yields a separate Simulink simulation.

Distributing Simulink Simulations for Each Frequency in Sinestream Input

When you use a Sinestream input signal with FRESTIMATE command and you set the "SimulationOrder" parameter to "OneAtATime", each frequency in the Sinestream signal simulates in a separate Simulink simulation. If you enable the parallel computing option, the simulations corresponding to individual frequencies are distributed among workers in the MATLAB pool.

In the engine model above, there is a single linearization input point and a single linearization output point. There are 50 frequencies in the Sinestream signal and the FRESTIMATE command performs 50 separate Simulink simulations, because the "SimulationOrder" parameter is set to "OneAtATime". To enable the parallel computing option for FRESTIMATE to distribute these simulations among workers, create a frequency response estimation options object using the command frestimateOptions and set the "UseParallel" parameter to "on". Use this object as input argument for FRESTIMATE.

The time it takes for the FRESTIMATE command to run to completion with and without parallel computing option enabled is shown below. A PC with Intel® Core(TM)2 Quad 2.4GHz processor and 4GB of RAM is used.

Parallel computing significantly speeds up the frequency response estimation. The imperfect speedup can be caused by various factors including the overhead from data and code transfer between client and workers and resource competition between worker processes and OS processes. For first simulation (i.e. immediately after opening the pool of MATLAB workers), Simulink start-up time can add to the overhead.

bdclose(mdl);

Distributing Simulink Simulations for Input Channels

When the number of linearization input points or the number of channels in a linearization input point is greater than one, the FRESTIMATE command distributes individual Simulink simulations corresponding to these input channels among workers in the MATLAB pool.

With the linio commands, you specify two linearization input points, which are both located on scalar Simulink signals. If you run the FRESTIMATE command to estimate the frequency response for this model, two Simulink simulations occur, one for each input. If you enable the parallel computing option, the simulations are distributed among workers. Run FRESTIMATE command with parallel computing option enabled and plot the estimation result against analytical linearization:

The time it takes for the FRESTIMATE command to run to completion with and without parallel computing option enabled is shown below. A PC with Intel® Core(TM)2 Quad 2.4GHz processor and 4GB of RAM is used.

As in the case of distributing simulations for frequencies, the table shows nearly a two-fold speedup with the parallel computing option enabled. As mentioned before, several factors may contribute to imperfect speedup including data and code transfer between client and workers and resource competition between worker processes and OS processes.