User Tools

Site Tools


matlab

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
matlab [2022/06/05 14:39]
root
matlab [2022/06/05 16:21]
root
Line 11: Line 11:
 </code> </code>
  
-Matlab in recent years has recently added a number of modern features such as GPU support, data analysis and machine learning.   A simple benchmark follows for CPU vs GPU code.+==GPU computing== 
 + 
 +Matlab in recent years has recently added a number of modern features such as GPU support, big data analysis and machine learning.   A simple benchmark follows for CPU vs GPU code to find the eigenvalues of a fairly large matrix.
  
 <code> <code>
Line 20: Line 22:
 b = eig(a); b = eig(a);
 toc; toc;
-quit() 
 $ matlab -nodesktop -nosplash < eigcpu.m $ matlab -nodesktop -nosplash < eigcpu.m
 </code> </code>
  
-This requires about 2700 seconds on 32-core Intel nodes and 5300 seconds on 64-core AMD nodes.+This requires about 2700 seconds on 32-core Intel nodes and 5300 seconds on 64-core AMD nodes.  Matlab matrix functions make extensive use of Intel MKL and are often more performant on Intel systems.  Also Intel AVX512 functions not present on AMD may be significant.
  
-The GPU version is selected in code, commands are the same.  Initializing the first array as gpuArray is sufficient to use the available gpu methods, see [[https://www.mathworks.com/help/parallel-computing/gpu-computing-in-matlab.html]]+The GPU version is selected in code, commands are the same.  Initializing the first array as gpuArray is sufficient to use the available GPU functions, see [[https://www.mathworks.com/help/parallel-computing/gpu-computing-in-matlab.html]]  GPU and CPU multithreading are more effective on functions such as ''eig()'' than in serial Matlab code.
  
 <code> <code>
Line 35: Line 36:
 b = eig(a); b = eig(a);
 toc; toc;
-quit() 
 $ matlab -nodesktop -nosplash < eiggpu.m $ matlab -nodesktop -nosplash < eiggpu.m
 </code> </code>
  
 This requires about 850 seconds on V100 gpu nodes and 700 seconds on A100 single gpu nodes. This requires about 850 seconds on V100 gpu nodes and 700 seconds on A100 single gpu nodes.
 +
 +==Parallel Computing==
 +
 +Matlab has several forms of parallel computing.  Many functions are multithreaded.  Many matrix functions are implemented in Intel MKL which is also multithreaded.  Explicit parallel computing is available with parallel toolbox/parallel server, see [[https://www.nrel.gov/hpc/eagle-software-matlab-pct.html]] for an example on a similarly-configured cluster.  The configuration is simpler on a single node (to Matlab, parallel toolbox or the local cluster) as in the NREL example.
 +
 +See also [[https://www.cs.usask.ca/~spiteri/CMPT851/notes/parallelMatlab.pdf]] 
 +
 +[[https://research.unsw.edu.au/document/UNSW_Parallel%20Computing%20with%20MATLAB.pdf]]
 +
 +[[https://www.hpc.iastate.edu/guides/using-matlab-parallel-server]]
matlab.txt · Last modified: 2022/06/05 19:44 by root