During a processor-in-the-loop (PIL) execution, you can produce a profile of 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.
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.
When using PIL execution, make sure that the
Benchmarking option in
GPU Coder™ settings is
false. Executing PIL with benchmarking results
in compilation errors.
Before running a processor-in-the-loop (PIL) execution, enable execution time profiling:
To open the GPU Coder app, on the MATLAB® Toolstrip Apps tab, under Code Generation, click the app icon.
To open your project, click and then click
project. Select the project.
On the Generate Code page, click Verify Code.
Select the Enable entry point execution profiling check box.
Or, from the Command Window, specify the
property of your
coder.gpuConfig object. For
cfg.CodeExecutionProfiling = true;
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:
Stop SIL Verification
The software terminates the execution process and displays a new link.
Execution profiling report: report(getCoderExecutionProfile('mandelbrot_count'))
Click the new link.
The report provides:
Information about profiled code sections, which includes time measurements for:
function, for example,
The entry-point function, for example,
function, for example,
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
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.
|Section||Name of function from which code is generated.|
|Maximum Execution Time||Longest time between start and end of code section.|
|Average Execution Time||Average time between start and end of code section.|
|Maximum Self Time||Maximum execution time, excluding time in child sections.|
|Average Self Time||Average execution time, excluding time in child sections.|
|Calls||Number 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.|