Main Content

Execution-Time Profiling for PIL

During a processor-in-the-loop (PIL) execution, you can produce a profile of the execution times for code generated from entry-point functions. The software calculates execution times from data that is obtained through instrumentation probes added to the PIL application.

Use the execution-time profile to check whether your code runs within the required time on your target hardware:

  • If code execution overruns, look for ways to reduce execution time.

  • If your code easily meets time requirements, consider enhancing functionality to exploit the unused processing power.

At the end of the PIL execution, you can:

  • View a report of code execution times.

  • Use the Simulation Data Inspector to view and compare plots of function execution times.

  • Access and analyze execution time profiling data.

Note

PIL execution supports multiple entry-point functions. An entry-point function can call another entry-point function as a subfunction. However, the software generates execution-time profiles only for functions that are called at the entry-point level. The software does not generate execution-time profiles for entry-point functions that are called as subfunctions by other entry-point functions.

Note

When using PIL execution, make sure that the Benchmarking option in GPU Coder™ settings is false. Executing PIL with benchmarking results in compilation errors.

Generate Execution-Time Profile

Before running a processor-in-the-loop (PIL) execution, enable execution-time profiling:

  1. To open the GPU Coder app, on the MATLAB® toolstrip Apps tab, under Code Generation, click the app icon.

  2. To open your project, click and then click Open existing project. Select the project.

  3. On the Generate Code page, click Verify Code.

  4. Select the Enable entry point execution profiling check box.

Or, from the Command Window, specify the CodeExecutionProfiling property of your coder.gpuConfig object. For example:

cfg.CodeExecutionProfiling = true;

View Execution Times

When you run a PIL execution with execution time profiling enabled, the software generates a message in the Test Output tab. For example:

### Starting application: 'codegen\lib\mandelbrot_count\pil\mandelbrot_count.elf'
    To terminate execution: clear mandelbrot_count_pil
### Launching application mandelbrot_count.elf...
    Execution profiling data is available for viewing. Open Simulation Data Inspector.
    Execution profiling report available after termination.

To open the code execution profiling report:

  1. Click the Stop PIL Verification link.

    The software terminates the execution process and displays a new link.

        Execution profiling report: report(getCoderExecutionProfile('mandelbrot_count'))
    

  2. Click the new link.

The report provides:

  • A summary.

  • Information about profiled code sections, which includes time measurements for:

    • The entry_point_fn_initialize function, for example, mandelbrot_count_initialize.

    • The entry-point function, for example, mandelbrot_count.

    • The entry_point_fn_terminate function, for example, mandelbrot_count_terminate.

  • Definitions for metrics.

By default, the report displays time in ticks. You can specify the time unit and numeric display format. The report displays time in seconds only if the timer is calibrated, that is, the number of timer ticks per second is established. For example, if your processor speed is 2.035 GHz, specify the number of timer ticks per second by using the TimerTicksPerSecond property. To display time in microseconds (10-6 seconds), use the report (Embedded Coder) command.

executionProfile=getCoderExecutionProfile('mandelbrot_count'); % Create workspace var
executionProfile.TimerTicksPerSecond = 2035 * 1e6;
report(executionProfile, ...
       'Units', 'Seconds', ...
       'ScaleFactor', '1e-06', ...
       'NumericFormat', '%0.3f')

To display measured execution times for a code section, click the Simulation Data Inspector icon on the corresponding row. You can use the Simulation Data Inspector to manage and compare plots from various executions.

The following table lists the information provided in the code section profiles.

ColumnDescription
SectionName of function from which code is generated.
Maximum Execution TimeLongest time between start and end of code section.
Average Execution TimeAverage time between start and end of code section.
Maximum Self TimeMaximum execution time, excluding time in child sections.
Average Self TimeAverage execution time, excluding time in child sections.
CallsNumber of calls to the code section.
Icon that you click to display the profiled code section.
Icon that you click to display measured execution times with Simulation Data Inspector.

See Also

Functions

Objects

Related Examples

More About