Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MATLAB: difference between Multithreading and Multicore

I have an i7-M620 processor that have 2 physical cores and 2 threads (multi-threaded CPU) per core (a total of 4 threads). When I use the MATLAB Parallel Computing Toolbox, I can only open 2 pools and not 4. Here is the code:

matlabpool(2)
parfor i = 1:20
    Test(i) = i^2;
end
matlabpool close
  • Could someone explain why?
  • Am I doing multithreading or multicore computation here?
  • Is it possible to do both with MATLAB?
like image 230
Maiss Avatar asked Oct 28 '25 02:10

Maiss


1 Answers

I got around this (with my core i5 with 2 cores and 4 threads) by editing the "local" configuration for the parallel computing stuff:

  1. Go to Parallel->Manage Cluster Profiles
  2. Depending on you Matlab version, you'll need to Validate the local profile before changing anything.
  3. Click edit and change the NumWorkers variable to suit your needs.

Then you can start matlabpool like this:

matlabpool local

Note I have never gotten a speedup using parfor. Matlab's overhead has always outweighed the benefits. What I'm saying is: benchmark your code first, then decide if parfor (or other parallel stuff) works for you or not.

like image 196
rubenvb Avatar answered Oct 30 '25 12:10

rubenvb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!