MATLAB DualCPU Hyper-Threading support

Hello everyone.
I'm going to buy a dual CPU workstation and would like to know if a vectorized MATLAB code uses
all the cores of both CPUs without the need to
use the Parallel Computing Toolbox.
Thanks!

4 Commenti

Some functions of matlab rely on libraries that are optimised to use parallelisation when it makes sense, even if you don't have the parallel toolbox.
It's not documented though and subject to change from version to version. Your m script/function itself will always use just one thread.
Emiliano Rosso
Emiliano Rosso il 30 Giu 2019
Modificato: Emiliano Rosso il 30 Giu 2019
Thanks,I refer to the use of " : " instead of " for " loop because I have independent process for my matrix. This is a general question not specific for any particular code. So,if I have 2 CPU with 4 (8 thread) cores each I'll use 4 (8) or 8 (16) cores when I use the vectorization function " : " ?
I verified that using 1 intel xeon w3680 6 cores 12 thread I can use all 12 thread even if not 100% powerfull because my RAM is slow. That's the same using 2 cpu (nodes)?
Thanks!
I do not understand what
use of " : " instead of " for " loop
means. Of course it depends on the specific code, how it is executed. Calling the colon operator "." a "vectorization function" is strange.
If your code exhausts 12 threads, you can expect that it let 8 threads work efficiently also. So what exactly is your question?
[m,n]=size(matrix);
for i=1:m
for l=1:n
matrix(i,l)=matrix(i,l)^2;
end
end
I vectorize the code :
[m,n]=size(matrix)
matrix(:,:)=matrix(:,:)^2
if I use 1 cpu xeon w3550 4 cores 8 thread:
1200 sec.
if I use 1 cpu xeon w3680 6 cores 12 thread:
800 sec.
The 2 cpu are identical except for the number of cores and I can verify that all thread are
working in both cases.
Now :
if I use 2 cpu xeon w3680 6 cores 12 thread does my code will use the second cpu?

Accedi per commentare.

 Risposta accettata

Jan
Jan il 30 Giu 2019
Modificato: Jan il 1 Lug 2019
Yes. Matlab will use the available cores. At least most likely. Matlab might split the array columnwise and if the input has 5 columns, there is a chance that only 5 cores are used. Many functions are multi-threaded, but this is applied for "large" arrays only.
I'm not sure, if hyper-threading is used in Matlab. Maybe only the physical cores are used for the reason of efficiency.
Note that:
[m,n]=size(matrix);
for i=1:m
for l=1:n
matrix(i,l) = matrix(i,l)^2;
end
end
and
[m,n]=size(matrix)
matrix(:,:)=matrix(:,:)^2;
do not compute the same result. The 2nd code works for square matrices only and is a matrix multiplication. Equivalent to the first code would be:
% No need to determine the size...
matrix(:,:) = matrix(:,:) .^ 2;
% ^ elementwise squaring
It would be even more efficient, to omit the (:,:):
matrix = matrix .^ 2;

1 Commento

Thanks for your answer.
The " ^ " instead of ".^ " was a mistake.

Accedi per commentare.

Più risposte (0)

Categorie

Prodotti

Richiesto:

il 30 Giu 2019

Modificato:

Jan
il 1 Lug 2019

Community Treasure Hunt

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

Start Hunting!

Translated by