How is execution time (cpu time) calculated for multi-core cpu?

10 views (last 30 days)
1) For multi-core cpu, when I use profile to check the execution time, does profile include the hidden time due to the parallel processing?
2) Also, Matlab recommends using single core for accurate profiling, when I disable other cores and run the program it keeps showing 'not all cpus are enabled'. Does that affect the profile (by adding overhead or something)?
Thanks a lot guys!

Answers (2)

Anver Hisham
Anver Hisham on 23 Sep 2016
This is not a complete answer to your question. But I believe you can satisfy your requirement simply by using matlab function cputime.
function f1()
t = cputime;
\< ...Your code here ... \>
simulationTime = cputime -t;
end
In the above example, the computed simulationTime doesn't vary with multithreading, ie. you will get almost same simulationTime irrespective of number of threads/cores used by caller/callee functions.

Philip Borghesani
Philip Borghesani on 23 Sep 2016
The matlab profiler lets you select the timing source if you run it manually using the -timer option:
profile on -timer cpu % will give you total process cpu time across all threads.
profile on -timer real % returns result measured against a constant 'wall' clock.
Check with help for profile for other options and information on the defaults they changed with R2015b.
With current versions of MATLAB and available hardware and OSs it is not necessary to pin the MATLAB process to a single thread/core when profiling.

Categories

Find more on Graphics Performance in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!