Difference between revisions of "Applications/Matlab"

From HPC
Jump to: navigation , search
(Executables)
Line 106: Line 106:
 
                                           R2016a (9.0.0.341360) 64-bit (glnxa64)
 
                                           R2016a (9.0.0.341360) 64-bit (glnxa64)
 
                                                     February 11, 2016
 
                                                     February 11, 2016
 
  
 
To get started, type one of these: helpwin, helpdesk, or demo.
 
To get started, type one of these: helpwin, helpdesk, or demo.
 
For product information, visit www.mathworks.com.
 
For product information, visit www.mathworks.com.
 
  
 
         Academic License
 
         Academic License
Line 125: Line 123:
 
#SBATCH -e %N.%j.err        # Standard error will be written here
 
#SBATCH -e %N.%j.err        # Standard error will be written here
 
#SBATCH -p compute          # Slurm partition, where you want the job to be queued  
 
#SBATCH -p compute          # Slurm partition, where you want the job to be queued  
#SBATCH -t 0-01:30          # Your expected run-time format in D-HH:MM
 
#SBATCH --exclusive
 
 
   
 
   
 
module purge
 
module purge
Line 145: Line 141:
  
 
=== Multi-threading ===
 
=== Multi-threading ===
Matlab can use multiple threads for certain built in functions for example linear algebra and numerical functions such as fft, \ (mldivide), eig, svd, and sort. These functions automatically execute on multiple computational threads in a single MATLAB session, allowing them to execute faster on multicore-enabled machines. Additionally, many functions in Image Processing Toolbox are multithreaded
+
Matlab can use multiple threads for certain built in functions for example linear algebra and numerical functions such as fft, \ (mldivide), eig, svd, and sort. These functions automatically execute on multiple computational threads in a single MATLAB session, allowing them to execute faster on multicore-enabled machines. Additionally, many functions in Image Processing Toolbox are multithreaded. Please see [[General/Interactive#Exclusive_interactive_session | Exclusive interactive]] or [[General/Batch#Exclusive_batch_session|Exclusive batch]].
 +
 
 +
Using the standard '''matlab''' command, on Viper this is aliased to ''matlab -singleCompThread'' to limit to one thread:
 +
<pre style="background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;">
 +
[username@c170 ~]$ matlab -nodisplay -nojvm -nodesktop -nosplash -r "maxNumCompThreads , exit"
 +
 
 +
                                                    < M A T L A B (R) >
 +
                                          Copyright 1984-2016 The MathWorks, Inc.
 +
                                          R2016a (9.0.0.341360) 64-bit (glnxa64)
 +
                                                    February 11, 2016
 +
 
 +
For online documentation, see http://www.mathworks.com/support
 +
For product information, visit www.mathworks.com.
 +
 
 +
        Academic License
 +
 
 +
Warning: maxNumCompThreads will be removed in a future release. Please remove any instances of this function from your code.
 +
> In maxNumCompThreads (line 26)
 +
 
 +
ans =
 +
 
 +
    1
 +
</pre>
 +
 
 +
Using the '''matlab-mt''' command, on Viper this starts Matlab with multithreading support enabled:
 +
<pre style="background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;">
 +
[username@c170 ~]$ matlab-mt -nodisplay -nojvm -nodesktop -nosplash -r "maxNumCompThreads , exit"
 +
 
 +
                                                    < M A T L A B (R) >
 +
                                          Copyright 1984-2016 The MathWorks, Inc.
 +
                                          R2016a (9.0.0.341360) 64-bit (glnxa64)
 +
                                                    February 11, 2016
 +
 
 +
For online documentation, see http://www.mathworks.com/support
 +
For product information, visit www.mathworks.com.
 +
 
 +
        Academic License
 +
 
 +
Warning: maxNumCompThreads will be removed in a future release. Please remove any instances of this function from your code.
 +
> In maxNumCompThreads (line 26)
 +
 
 +
ans =
 +
 
 +
    28
 +
</pre>
  
 
=== Parallel Computing Toolbox ===
 
=== Parallel Computing Toolbox ===
Line 166: Line 206:
 
</pre>
 
</pre>
  
=== Distributed Computing Toolbox ===
+
=== Matlab Distributed Computing Server ===
The distributed computing toolbox is not currently supported on Viper
+
The Matlab Distributed Computing Server is not currently supported on Viper.
  
 
== Change Log ==
 
== Change Log ==
Line 176: Line 216:
 
* [https://www.mathworks.com/products/matlab.html Matlab website]
 
* [https://www.mathworks.com/products/matlab.html Matlab website]
 
* [http://www.mathworks.com/academia/student_center/tutorials.html Useful Matlab tutorials]  
 
* [http://www.mathworks.com/academia/student_center/tutorials.html Useful Matlab tutorials]  
 +
* [https://uk.mathworks.com/discovery/matlab-multicore.html Matlab multicore]
 
* [[Main Page#General_Support|Wiki: General Support]]
 
* [[Main Page#General_Support|Wiki: General Support]]
 
* [[Main Page|Wiki: Home]]
 
* [[Main Page|Wiki: Home]]

Revision as of 10:21, 8 February 2017

Application Details

  • Description: MATLAB is a numerical computing environment and programming language developed by MathWorks, MATLAB allows matrix manipulations, plotting of functions and data, and implementation of algorithms. A range of toolboxes are available to extend functionality.
  • Versions: 2016a
  • Module names: matlab/2016a
  • License: University of Hull Total Academic Headcount license, available to everyone

Toolboxes

MATLAB Filter Design HDL Coder MATLAB Report Generator SimRF
Simulink Financial Instruments Toolbox Model Predictive Control Toolbox Simscape
Aerospace Blockset Financial Toolbox Neural Network Toolbox Simscape Electronics
Bioinformatics Toolbox Fixed-Point Designer Optimization Toolbox Simscape Multibody
Communications System Toolbox Fuzzy Logic Toolbox Parallel Computing Toolbox Simscape Power Systems
Computer Vision System Toolbox Global Optimization Toolbox Partial Differential Equation Toolbox Simulink Coder
Control System Toolbox Image Acquisition Toolbox Phased Array System Toolbox Simulink Control Design
Curve Fitting Toolbox Image Processing Toolbox RF Toolbox Simulink Design Optimization
DSP System Toolbox Instrument Control Toolbox Robotics System Toolbox Stateflow
Database Toolbox LTE System Toolbox Robust Control Toolbox Statistics and Machine Learning Toolbox
Datafeed Toolbox MATLAB Coder Signal Processing Toolbox Symbolic Math Toolbox
Econometrics Toolbox MATLAB Compiler SimBiology System Identification Toolbox
Embedded Coder MATLAB Compiler SDK SimEvents Wavelet Toolbox

Usage Examples

Executables

Executable Description
matlab By default Matlab will make use of multithreading for certain functions, with the maximum number of computational threads equal to the number of computational cores on the node. If a job or session hasn't requested appropriate resource, this multithreading can cause contention for CPU resource and negatively impact other users. For this reason the standard matlab command has been aliased so it runs with -singleCompThread option and will only use a single CPU core. See Parallel Matlab
matlab-mt To access standard matlab that supports multithreading, please use the matlab-mt command and request appropriate resource by either using an exclusive session with interactive --exclusive or submiting a task with the #SBATCH --exclusive. See Parallel Matlab

Interactive

Interactive with full graphical interface:

[username@login01 ~]$ interactive
salloc: Granted job allocation 289663
Job ID 289663 connecting to c170, please wait...
Last login: Thu Jan 26 12:59:11 2017 from 10.254.5.246
[username@c170 ~]$ module add matlab/2016a
[username@c170 ~]$ matlab

Interactive with command line only:

[username@c170 ~]$ matlab -nodisplay

                                                    < M A T L A B (R) >
                                          Copyright 1984-2016 The MathWorks, Inc.
                                           R2016a (9.0.0.341360) 64-bit (glnxa64)
                                                     February 11, 2016

To get started, type one of these: helpwin, helpdesk, or demo.
For product information, visit www.mathworks.com.

        Academic License

>>

Batch Submission

#!/bin/bash
#SBATCH -J MATLAB           # Job name, you can change it to whatever you want
#SBATCH -N 1                # Number of nodes (for Matlab should be always one)
#SBATCH -o %N.%j.out        # Standard output will be written here
#SBATCH -e %N.%j.err        # Standard error will be written here
#SBATCH -p compute          # Slurm partition, where you want the job to be queued 
 
module purge
module add matlab/2016a
 
matlab -nodisplay -nojvm -nodesktop -nosplash -r my_matlab_m_file

This submission script can be found at /path/to/sample/script Matlab

[username@login01 ~]$ sbatch MATLABtest.job
Submitted batch job 289522

Parallel Matlab

By default Matlab on Viper will run on a single core as mutli-threading conflicts with the schedulers resource management, however there are three ways in which Matlab can utilise multiple processors:

Multi-threading

Matlab can use multiple threads for certain built in functions for example linear algebra and numerical functions such as fft, \ (mldivide), eig, svd, and sort. These functions automatically execute on multiple computational threads in a single MATLAB session, allowing them to execute faster on multicore-enabled machines. Additionally, many functions in Image Processing Toolbox are multithreaded. Please see Exclusive interactive or Exclusive batch.

Using the standard matlab command, on Viper this is aliased to matlab -singleCompThread to limit to one thread:

[username@c170 ~]$ matlab -nodisplay -nojvm -nodesktop -nosplash -r "maxNumCompThreads , exit"

                                                    < M A T L A B (R) >
                                          Copyright 1984-2016 The MathWorks, Inc.
                                           R2016a (9.0.0.341360) 64-bit (glnxa64)
                                                     February 11, 2016

For online documentation, see http://www.mathworks.com/support
For product information, visit www.mathworks.com.

        Academic License

Warning: maxNumCompThreads will be removed in a future release. Please remove any instances of this function from your code.
> In maxNumCompThreads (line 26)

ans =

     1

Using the matlab-mt command, on Viper this starts Matlab with multithreading support enabled:

[username@c170 ~]$ matlab-mt -nodisplay -nojvm -nodesktop -nosplash -r "maxNumCompThreads , exit"

                                                    < M A T L A B (R) >
                                          Copyright 1984-2016 The MathWorks, Inc.
                                           R2016a (9.0.0.341360) 64-bit (glnxa64)
                                                     February 11, 2016

For online documentation, see http://www.mathworks.com/support
For product information, visit www.mathworks.com.

        Academic License

Warning: maxNumCompThreads will be removed in a future release. Please remove any instances of this function from your code.
> In maxNumCompThreads (line 26)

ans =

     28

Parallel Computing Toolbox

The Parallel Computing Toolbox allows you to open a number of workers (separate Matlab engines) on the local node, up to the number of cores on that node (28 for standard nodes in an exclusive session).

>> parpool('local',28)
Starting parallel pool (parpool) using the 'local' profile ... connected to 28 workers.

ans = 

 Pool with properties: 

            Connected: true
           NumWorkers: 28
              Cluster: local
        AttachedFiles: {}
          IdleTimeout: 30 minute(s) (30 minutes remaining)
          SpmdEnabled: true

Matlab Distributed Computing Server

The Matlab Distributed Computing Server is not currently supported on Viper.

Change Log

[2017-01-30] Changed default Matlab launch command in module to matlab -singleCompThread to disable multi-threading

Further Information