3

When I execute

matlabpool open 4;

everything works correctly, but when I try execute

matlabpool open 8;

error occurs immediately. I read about Hyper Threading and I know that 4 of 8 cores are virtual. Does than mean that I cannot use all 8 cores in an efficient way for

parfor loop 

in Matlab?

For example, I have 8 similar independent tasks.

Can I use all 8 cores in python or C#/C++ with acceleration 8 times faster?

Suever
  • 64,497
  • 14
  • 82
  • 101
Qwer
  • 33
  • 5
  • what error? show it – user3528438 Jan 12 '17 at 11:19
  • I can't remember exactly, but it seems to be like error when execute `matlabpool open 8;` on 4 core machine. The main question is "can I efficiently use all 8 cores (4 + 4 virtual) in Matlab" – Qwer Jan 12 '17 at 11:54
  • cannot remember but maeby error like this Error using matlabpool (line 148) Failed to start a parallel pool. (For information in addition to the causing error, validate the profile 'local' in the Cluster Profile Manager.) Caused by: Error using parallel.internal.pool.InteractiveClient/start (line 326) Failed to start pool. Error using parallel.Job/submit (line 304) You requested a minimum of 8 workers, but the cluster "local" has the NumWorkers property set to allow a maximum of 4 workers. – Qwer Jan 12 '17 at 11:57

1 Answers1

3

By default, MATLAB uses the number of physical cores rather than the number of hyperthreaded cores on your machine since the hyperthreads still ultimately share the same physical CPUs resources. There is more info about specific cases where there may/may not be a benefit to using hyperthreads in this post on MATLAB Answers

If you want to use 8 workers, you'll want to modify the NumWorkers property of your 'local' configuration

cluster = parcluster('local');
cluster.NumWorkers = 8;
saveProfile(cluster);

Alternately, you can set the maximum number of compute threads to use with maxNumCompThreads

maxNumCompThreads(8)
Suever
  • 64,497
  • 14
  • 82
  • 101
  • Thank you, but will such procedure accelerate independent similar processes? Unfortunately, I haven't core i7 now but when i use your code in core i5 to get 12 workers (haveing only 4 cores!), i can't get acceleration. Will your code get real 8x acceleration instead of 4x acceleration? – Qwer Jan 12 '17 at 14:42
  • @Qwer As stated in the linked answer, it very much depends on the problem but it is likely that for intensive tasks, you won't see any improvement by using the hyperthreads. – Suever Jan 12 '17 at 14:56
  • @Qwer If this worked for you consider marking it as a solution – Suever Jan 13 '17 at 13:20
  • It worked, but i didn't achieve any acceleration while using 8 workers instead of 4 workers. – Qwer Jan 17 '17 at 08:34
  • @Qwer Yes that is to be expected for some use cases. Did you look at the link I provided in the answer which discusses this in detail? As far as "marking this as a solution" it *is* the solution for utilize the hyperthreads for computations. Just because you don't get a speed up (you won't get a speed up using *any* method) doesn't mean that it's not an answer. – Suever Jan 17 '17 at 13:23
  • Yes, I have read your reference, thank you. I checked your answer as accepted. Is this checking you mean as 'marking this as a solution'? – Qwer Jan 18 '17 at 08:32