Borrar filtros
Borrar filtros

Why are profiler plots not matching numbers in the profiling report in R2022a?

1 visualización (últimos 30 días)
I have the same model and running at different step size, for example 100us and 40 us. The report from the profiler make sense, but not the plots. For example, the average CPU utilization for 100 us is 27.9% and for 40 us it is 72.55% for 40us. In the plots, both shown only about 15%.
I looked over the documentation and followed examples for both the "getProfilierData" function and the "plot" function here, which illustrates the data selection for viewing CPU usage:
"getProfilierData" function:
"plot" function:
It also appears that this can happen when multiple runs are completed without clearing Simulink Data Inspector, causing the data to overlap with a previous run and displaying an odd result. It was advised correct this to clear SDI after each run with the following command in the MATLAB Command Window:
>> Simulink.sdi.clear
However, this did not resolve the issue.

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 3 de Mayo de 2024
It appears that the similar names can cause some confusion when interpreting the results. For this replay, only used the script attached has been used. The following explanation will clarify any misunderstandings:
Starting from SDI, we display how tasks are scheduled and what happen in each core. Ignoring the BaseRate task and Core 2/3.
In the first two subplots, the tasks are executed every .002 and .04 seconds. They are both executed on core 1 as you can see in the third plot.
The fourth plot shows how busy Core 1 is: on the X-axis we have the simulation time and on the Y-axis the percentage of time the core was busy from the simulation start.
Looking at the numbers, to executed both tasks, Core 1 is busy for the 27% of the time. So, "Usage Core X" is how busy the core X is since the simulation start (considering all tasks/threads it runs).
The report shows something slightly different: for each task, it says the percentage of CPU time the task needs. Regardless of the Core it runs on.
For example, you have a task that is executed every second and it always takes 0.5s to run. When the time is even (0s, 2s,4s...) , it runs on Core 1 then, when it is odd (1s, 3s, 5s...) it runs on Core 2.
The CPU utilization for this task is 50% (average_execution_time / period = 0.5 / 1 = 0.5). Each core is busy for 0.5s every two instances of the task so, 0.5s / (1s + 1s) = 0.25 -> 25%. So each core is active for 25%. Note, the sum of the core usage is 50% like the task utilization.
To summarize, SDI shows what each core does while the report is more task oriented.
When looking at the schedule in SDI, you want to see how tasks are scheduled and executed.
When looking at the report, you want to see simple numbers. The CPU utilization in the report is an important number as it lets you see if the target can handle the tasks. For example, if you executed all tasks on a single core and the overall CPU utilization is higher than 70%, you may have task overrun (assuming that you use Rate Monotonic as scheduler.)
Going back to the data, both SubRate1 and SubRate2 are always executed on Core 1. If we sum their average CPU utilization, it is 23.49%+3.009%=26.5%. When we look at the final Usage for Core 1, it is 27% (if we zoom, it is 0.265). So, the math works in this case as the values match.
This is a lucky case because both tasks run always on the same core. If they ran on different cores, their utilization would be split among the different cores. The core usage would be lower than the 26.5% but their sum should be 26.5%.

Más respuestas (0)

Categorías

Más información sobre Multicore Processor Targets en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by