How to compute execution time for code uses parfoor?

12 visualizaciones (últimos 30 días)
MatlabUser
MatlabUser el 24 de Mayo de 2022
Comentada: Walter Roberson el 27 de Mayo de 2022
I have a code that uses parfoor from the parallel toolbox, and I need to compute the execution time. using tic, toc is highly depending on the processes that are running in the same time, therefore I decided to use (cputime) from MATLAB that computes the cputime..
but is it OK to use cputime if the code uses (parfor) with multiple workers?
if I use parfor, does it mean I am usin GPU? or different clusters in CPU?
if a code uses GPU then how to compute the execution time without using (tic,toc)?? cputime is enough or not?

Respuestas (1)

Adit Alware
Adit Alware el 27 de Mayo de 2022
Hi Maryam,
Using parfor does not mean you are leveraging GPUs. Parfor runs multiple workers on the available cores of your system's CPU. Since GPU cores can not serve as parallel pool workers.
Thus using cputime function to calculate the time elasped looks fine to me.
However, if you want to run your code over GPUs, you can use parfor in conjunction with spmd statement.
To understand about how to use multiple GPUs in parallel pool you may refer to the following links:
To calculate total time elasped, you may also use the timeit function:
t = timeit(f) % f is the function handle
Timeit measures the time (in seconds) required to run the function specified by the function handle f. In order to perform a robust measurement, timeit calls the specified function multiple times and returns the median of the measurements. If the function runs fast, timeit might call the function many times.
Thanks
  1 comentario
Walter Roberson
Walter Roberson el 27 de Mayo de 2022
If you are using GPUs then gputimeit() instead of timeit()
When you use parfor you should cputime() within each worker, and total the results.

Iniciar sesión para comentar.

Categorías

Más información sobre Parallel Computing Fundamentals en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by