Line: 1 to 1  

MatlabMatlab is a numerical computing and programming environment with a broad range of functionality (matrix manipulation, numerical linear algebra, generalpurpose graphics, etc.). Additionally, special application areas are served by a large number of optional toolboxes. Matlab version 2011b is install on the cluster and can be accessed here: /usr/local/bin/matlab  
Added:  
> >  Running Matlab on the headnode  
Added:  
> >  Matlab Distributed Computing toolbox/server is installed on psycho and this requires running Matlab on the head node due to how it integrates with PBS. Otherwise, users should avoid running Matlab on the head node for processing.  
Interactive Matlab SessionsWhen running Matlab interactive, users should avoid running it on the head node. Instead, they should request an interactive session through the PBS job scheduler. 
Line: 1 to 1  

Matlab  
Line: 12 to 12  
[<username@compute node> ~]$ You can then run Matlab and any other interactive commands you would like:  
Changed:  
< <  [username@<compute node> ~]$ pwd [username@<compute node> ~]$ matlab  
> >  [username@<compute node> ~]$ pwd [username@<compute node> ~]$ module load matlab7.13 [username@<compute node> ~]$ matlab  
When you are done with your interactive commands, you can use the exit command to end the job:
[username@<compute node> ~]$ exit Noninteractive Matlab Sessions 
Line: 1 to 1  

Matlab  
Line: 3 to 3  
MatlabMatlab is a numerical computing and programming environment with a broad range of functionality (matrix manipulation, numerical linear algebra, generalpurpose graphics, etc.). Additionally, special application areas are served by a large number of optional toolboxes. Matlab version 2011b is install on the cluster and can be accessed here: /usr/local/bin/matlab  
Added:  
> >  
Interactive Matlab SessionsWhen running Matlab interactive, users should avoid running it on the head node. Instead, they should request an interactive session through the PBS job scheduler.  
Changed:  
< < 
[<username@headnode> ~]$ qsub I X l ncpus=1  
> >  [<username@headnode> ~]$ qsub I X l nodes=1:ppn=1  
qsub: waiting for job <some job name> to start qsub: job <some job name> ready
[<username@compute node> ~]$ 
Line: 1 to 1  

Matlab  
Line: 3 to 3  
MatlabMatlab is a numerical computing and programming environment with a broad range of functionality (matrix manipulation, numerical linear algebra, generalpurpose graphics, etc.). Additionally, special application areas are served by a large number of optional toolboxes. Matlab version 2011b is install on the cluster and can be accessed here: /usr/local/bin/matlab  
Deleted:  
< <  
Interactive Matlab SessionsWhen running Matlab interactive, users should avoid running it on the head node. Instead, they should request an interactive session through the PBS job scheduler.  
Changed:  
< <  [<username@headnode> ~]$ qsub I l ncpus=1  
> > 
[<username@headnode> ~]$ qsub I X l ncpus=1  
qsub: waiting for job <some job name> to start qsub: job <some job name> ready
[<username@compute node> ~]$ 
Line: 1 to 1  

Added:  
> > 
MatlabMatlab is a numerical computing and programming environment with a broad range of functionality (matrix manipulation, numerical linear algebra, generalpurpose graphics, etc.). Additionally, special application areas are served by a large number of optional toolboxes. Matlab version 2011b is install on the cluster and can be accessed here: /usr/local/bin/matlab
Interactive Matlab SessionsWhen running Matlab interactive, users should avoid running it on the head node. Instead, they should request an interactive session through the PBS job scheduler. [<username@headnode> ~]$ qsub I l ncpus=1 qsub: waiting for job <some job name> to start qsub: job <some job name> ready [<username@compute node> ~]$ You can then run Matlab and any other interactive commands you would like: [username@<compute node> ~]$ pwd [username@<compute node> ~]$ matlab When you are done with your interactive commands, you can use the exit command to end the job: [username@<compute node> ~]$ exit Noninteractive Matlab SessionsMatlab interactive mode can be used to take advantage of the integrated environment. But, it can also be run in a noninteractive mode for "batch processing" and to take advantage of cluster computing resources. If fact, the preferred mode of operation for Matlab on our cluster is noninteractive. One way to run Matlab noninteractively is through
Here is an example demonstrating a noninteractive Matlab program. A program file named
function [avg, med] = mystats(x) n = length(x); avg = mymean(x,n); med = mymedian(x,n); end function a = mymean(v,n) % MYMEAN Example of a local function. a = sum(v)/n; end function m = mymedian(v,n) % MYMEDIAN Another example of a local function. w = sort(v); if rem(n,2) == 1 m = w((n + 1)/2); else m = (w(n/2) + w(n/2 + 1))/2; end end The job is sent to the queue and executed on a backend node using the following PBS file provided and the command qsub run.sh. The script run.sh contains the following line to run the Matlab script: matlab nodisplay nosplash < mystats.m > run.log The flag nodisplay instructs Matlab to run without the GUI, while nosplash prevents the display of the Matlab logo. The < redirection operator ensures that Matlab runs the script main.m, while the > operator redirects the standard output (normally to the terminal) to run.log file. Running Matlab on parallel hardwareThe example is run in batch mode with the command qsub run.sh, using the following PBS file: #!/bin/bash #PBS V #PBS l nodes=1 #PBS l walltime=0:05:00 #PBS N matlab_test cd $PBS_O_WORKDIR matlab nodisplay nosplash < main.m > run.log Notice how MATLAB is instructed to not load the interactive window. Note: do not turn java off when lauching MATLAB (i.e. do not invoke matlab nojvm); matlabpool uses the Java Virtual Machine. After the job finishes, the CPU times spent executed the loops in main.m can be found in timings.dat, showing a clear speedup of the execution in parallel.
Running Matlab on parallel hardwareMatlab can also be run where you can take advantage of parallel hardware in at least two ways. The first is a builtin feature of Matlab, which "naturally" exploits multicore processing via the underlying multithreaded libraries Intel MKL and FFTW. Thus, linear algebra operations (such as the solution to a linear system A\b or matrix products A*B) and FFT operations (using the function fft) are implicitly multithreaded and make use of all the cores available on a multicore system without user intervention or special extra programming. Some of the vectorised operations in Matlab are also multithreaded. However, this type of operations are only a part of Matlab programming and the vast proportion of the Matlab functionality are scripts or functions that can only use a single core. You can also take advantage of parallel processing through a series of explicit programming techniques. The following techniques are:
The functionality of the Parallel Computing Toolbox is extended from single cluster node processing to distributed processing across multiple nodes by the Distributed Computing Server. To learn more about the product, please visit the Distributed Computing Server webpage.
Exploiting trivial parallelismAn easy way to exploit multicore systems is to split the workflow into parts that can be processed completely independently. The typical example in this category is a parameter sweep, where the same Matlab script is run a large number of times using different inputs; these runs are indepent from each other and can be carried out concurrently. Thus, the entire workflow can be scheduled in jobs that group 8 independent runs to match the 8 cores available per compute node. This strategy is best coupled with the use of the Matlab mcc compiler in order to avoid an excessive use of licenses.
Multithreaded MEX programmingYet another way to exploit multicore systems is via multithreaded Mex programming. Mex (Matlab EXecutable) files are dynamically linked subroutines compiled from C, C++ or Fortran source code that can be run from within Matlab in the same way as Mfiles or builtin functions. These guidelines assume knowledge of serial Mex programming and provide an example of how to augment serial execution with multithreading through OpenMP. Coupled with OpenMP multithreading, Mex files become a powerful method to accelerate key parts of a Matlab program. The main reason to write Mex files in C or Fortran (thus abandoning the highlevel abstracted Matlab programming) is to gain speed of execution in computationally intensive operations that otherwise become a bottleneck in an application. Typically, this is done to replace a function that is identified through profiling as being slow and/or called a large number of times. Nevertheless, this programming effort is rewarded to various degrees, with the greatest relative benefits normally met when a Mex replaces a Matlab script (Mfile). At the other extreme, Matlab operations that rely on performance libraries like FFTW (e.g. fftn) or BLAS/LAPACK (e.g. solution of a dense linear systems, A\b), which are highly optimised have nothing or very little to benefit from Mex programming. The best source for learning Mex programming is the Mathworks webpages
Comments
