Can I measure acceleration from parallelization in Matlab?

If I assume that the problem is a candidate for parallelization, for example. matrix multiplication or some other problem and I use Intel i7 haswell dualcore, is there a way to compare parallel execution with a serial version of the same program or will Matlab optimize the program for my architecture (dualcore, quadcore ..)? I would like to learn how to speed up the process of adding more processors from a good parallel program.

+5
source share
3 answers

You can try the "Run and time" function on MATLAB.

Or just put some tic and toc at the first and end of your code, respectively.

+5
source

Unfortunately, there is no such thing as a reference parallel program. If you measure acceleration for a reference algorithm, which does not mean that all algorithms will benefit from parallelization

Since your target architecture has only 2 cores, you might be better off avoiding parallelization and letting Matlab and the operating system optimize execution. Anyway, here are the steps that I followed.

  • Determine if your problem is suitable for parallelization by calculating theoretical acceleration. Some issues, such as matrix multiplication or Gaussian elimination, are well studied. Since I assume that your problem is more complex, try to decompose your algorithm into simple blocks and determine, block by block, the benefits of parallelization.
  • If you find that several parts of your algorithms may benefit from parallelization, study this part separately.
  • Get statistical information about the runtime of your sequential algorithm. That is, run your program X times under similar conditions (and similar inputs) and average the execution time.
  • Get statistical information about the runtime of your parallel algorithm.
  • Measure the profiler . Many people recommend using a function like tic or toc . The profiler will give you a more accurate picture of your work time, as well as detailed information about each function. For more information on how to use the profiler, see the documentation.
  • Make no mistake by not taking into account the time it takes Matlab to open the workers pool (I assume you are working with the Parallel Computing Toolbox). Depending on your number of employees, the pool takes more / less time, and in some cases it can be up to 1 minute (2011b)!
+8
source

Matlab provides a number of synchronization functions to help you evaluate the performance of your code: read the documentation here and select the function that you consider yourself most suitable in your case! In particular, note the difference between tic toc and the cputime function.

+2
source

Source: https://habr.com/ru/post/1200366/


All Articles