Wrangling Matlab Computing Resource Usage
Matlab can use multithreading and parallel computing to speed up computations [1], which may have an impact on performance in shared workspaces.
tl;dr
-
Matlab is resource-greedy by default when computing built-in functions with implicit multithreading, of which there are many
-
multithreading resources in Matlab can be managed with the
-singleCompThread
startup option or themaxNumCompThreads
function to limit the number of computational threads available -
additionally, parallel computing resources in Matlab can be managed using the
parpool
function to limit the number of parallel 'workers' used by both built-in functions with implicit parallelisation and custom functions that use defined parallel programming constructs
Multithreading
A number of functions are implicitly multithreaded by default [2] in Matlab releases since 2008a [1].
This has been identified as a potential issue since Matlab will use all available processors for implicitly multithreaded functions [3].
The Matlab function maxNumCompThreads
[4] can be used to both set and query the current maximum number of computational threads, though this function is being deprecated.
On beastiexx, maxNumCompThreads
returned 32 when recently checked.
As a workaround, Matlab can be started with the command line option -singleCompThread
[5], which is suggested by various research computing guides [3] [6] [7], found via a quick online search of the topic.
Resource management on beastiexx may be improved by:
-
calling Matlab with the
-singleCompThread
startup option, or -
reducing the computational threads available to Matlab using the
maxNumCompThreads
function, ideally as part ofstartup.m
, until it is removed in a future version.
Parallel Computation
Matlab can perform parallel computations [8] using built-in functions with implicit parallelisation [9] or using defined programming constructs [10].
Resources allocated for parallel computing can be defined using the parpool
function [11].
Sharing of resources may be fascilitated through use of the Distributed Computing Server [12], though usability may be worth review prior to implementation [13].
References
-
Run MATLAB on multicore and multiprocessor machines
http://uk.mathworks.com/discovery/matlab-multicore.html -
Which MATLAB functions benefit from multithreaded computation?
http://www.mathworks.com/matlabcentral/answers/95958#answer_105310 -
MATLAB overutilizing CPUS
https://wiki.hpcc.msu.edu/display/Issues/MATLAB+overutilizing+CPUS -
Matlab: Control maximum number of computational threads
http://uk.mathworks.com/help/matlab/ref/maxnumcompthreads.html
-
Commonly Used Startup Options: singleCompThread
http://uk.mathworks.com/help/matlab/matlab_env/commonly-used-startup-options.html?searchHighlight=singleCompThread -
How to run MATLAB jobs on the TIGRESS clusters
http://www.princeton.edu/researchcomputing/faq/how-to-run-matlab-jobs-on/ -
High Throughput Computing: How To Run Matlab
https://htcondor-wiki.cs.wisc.edu/index.cgi/wiki?p=HowToRunMatlab -
Parallel Computing Toolbox
http://uk.mathworks.com/help/distcomp/index.html -
Built-in Parallel Computing Support in MathWorks Products
http://uk.mathworks.com/products/parallel-computing/builtin-parallel-support.html -
Matlab Programming Parallel Application
http://uk.mathworks.com/products/parallel-computing/features.html#programming-parallel-applications -
Matlab: Create parallel pool on cluster
http://uk.mathworks.com/help/distcomp/parpool.html -
Matlab: Distributed Computing Server
http://uk.mathworks.com/products/distriben/index.html -
A review of Matlab Distributed Computing Server
https://rwuncertainty.wordpress.com/2014/08/20/how-mathworks-hurts-research-a-review-of-matlab-distributed-computing-server/