Reduce Bandwidth Usage During Code Execution Profiling - MATLAB & Simulink (original) (raw)

Main Content

This topic shows how you can reduce communication channel bandwidth usage when running software-in-the-loop (SIL), processor-in-the-loop (PIL), or XCP-based external mode simulations with code execution profiling enabled.

Capture Main Profiling Metrics on Target Hardware

For code execution profiling, to reduce the communication channel bandwidth usage during a software-in-the-loop (SIL) simulation, processor-in-the-loop simulation (PIL), or XCP-based external mode simulation, you can capture and store only these profiling metrics on the target hardware:

Enable the capture of the main profiling metrics by setting the configuration parameterSave options to Metrics only. At the end of the simulation, Simulink® uploads the metrics from the target hardware to your development computer.

To run a SIL simulation that generates only the main execution-time metrics:

  1. Open the model SILTopModel, which has two subsystemsCounterTypeA andCounterTypeB.
    openExample('ecoder/SILPILVerificationExample', ...
    supportingFile='SILTopModel.slx')
  2. On the SIL/PIL tab, in the Mode section, selectSIL/PIL Simulation Only.
  3. In the Prepare section, specify these settings:
    1. System Under TestTop model
    2. SIL/PIL ModeSoftware-in-the-Loop (SIL)
  4. To measure code execution times for the subsystems:
    1. Click .
    2. In the Configuration Parameters dialog box, select Measure task execution time, which provides execution-time metrics for the task generated from the top model SILTopModel.
    3. Set Measure function execution times toCoarse (referenced models and subsystems only), which provides execution-time metrics for the functions generated from the subsystems CounterTypeA andCounterTypeB.
    4. Specify a Workspace variable, for example,executionProfile. If the > check box is selected, the software creates the variable in theSimulink.SimulationOutput object that you specify.
    5. From the Save options drop-down list, selectMetrics only.
    6. Click OK.
  5. In the Prepare section, open theSettings gallery. Under Coverage, click the Coverage Collection button off.
  6. In the Run section, click Run SIL/PIL.

To open the code execution profiling report, in the Profiling details panel, click the displayed link. In section 2, the report displays the profiled code sections as a flattened list.

Section 2 of report shows profiled code sections as a flattened list.

The software cannot extract the hierarchy of calls to code sections because this information is not stored on the target hardware.

Overhead filtering is not supported when Save options is set to Metrics only.

Specify Memory Allocation for Code Execution Profiling

You can specify memory allocation for code profiling with XCP-based external mode simulations. If you want to:

The parameters control memory allocation only whenCodeProfilingSaveOptions is set to 'SummaryOnly' or'AllData'.

This table provides details.

Parameter Details
CodeProfilingXCPMaxMemory Purpose — Specify the maximum amount of memory to use for code profiling.Range — 0 to 232 - 1. Default is "0".Data type — string, which resolves touint32.Example:set_param(gcs, CodeProfilingXCPMaxMemory="4000") get_param(gcs, 'CodeProfilingXCPMaxMemory')
CodeProfilingXCPMaxBufferSize Purpose — Specify maximum size of profiling data buffer that is uploaded from target hardware to development computer.Range — 0 to 255. Default is "0".Data type —string, which resolves touint32.Example:set_param(gcs, CodeProfilingXCPMaxBufferSize="200") get_param(gcs, 'CodeProfilingXCPMaxBufferSize')

Display Absolute Time

During an XCP-based external mode simulation, the Simulation Data Inspector displays, by default, streamed signal values and execution-time metrics with respect to simulation time: after the execution of a task, the target application uploads data samples from the profiling buffer and associates all data samples from the profiling buffer with the same simulation time.

There are potential issues with streaming simulation time:

If the communication channel for the external mode simulation has a low bandwidth or the target application runs tasks with high sampling rates, the generation of profiling data can exceed data uploading, which leads to data loss.

To improve bandwidth usage during data uploading, specify the display of absolute time:

set_param(modelName, 'CodeProfilingXCPUseAbsoluteTime', 'on')

When the external mode simulation runs, the target application uploads data samples only when the profiling buffer is full. The Simulation Data Inspector displays streamed values with respect to absolute time instead of simulation time.

See Also

Save options | Measure function execution times | Workspace variable | Measure task execution time

Topics