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 the maxNumCompThreads 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:

  1. calling Matlab with the -singleCompThread startup option, or

  2. reducing the computational threads available to Matlab using the maxNumCompThreads function, ideally as part of startup.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

  1. Run MATLAB on multicore and multiprocessor machines
    http://uk.mathworks.com/discovery/matlab-multicore.html

  2. Which MATLAB functions benefit from multithreaded computation?
    http://www.mathworks.com/matlabcentral/answers/95958#answer_105310

  3. MATLAB overutilizing CPUS
    https://wiki.hpcc.msu.edu/display/Issues/MATLAB+overutilizing+CPUS

  4. Matlab: Control maximum number of computational threads

http://uk.mathworks.com/help/matlab/ref/maxnumcompthreads.html

  1. Commonly Used Startup Options: singleCompThread
    http://uk.mathworks.com/help/matlab/matlab_env/commonly-used-startup-options.html?searchHighlight=singleCompThread

  2. How to run MATLAB jobs on the TIGRESS clusters
    http://www.princeton.edu/researchcomputing/faq/how-to-run-matlab-jobs-on/

  3. High Throughput Computing: How To Run Matlab
    https://htcondor-wiki.cs.wisc.edu/index.cgi/wiki?p=HowToRunMatlab

  4. Parallel Computing Toolbox
    http://uk.mathworks.com/help/distcomp/index.html

  5. Built-in Parallel Computing Support in MathWorks Products
    http://uk.mathworks.com/products/parallel-computing/builtin-parallel-support.html

  6. Matlab Programming Parallel Application
    http://uk.mathworks.com/products/parallel-computing/features.html#programming-parallel-applications

  7. Matlab: Create parallel pool on cluster
    http://uk.mathworks.com/help/distcomp/parpool.html

  8. Matlab: Distributed Computing Server
    http://uk.mathworks.com/products/distriben/index.html

  9. 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/