software:matlab:mills

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
software:matlab:mills [2018-12-03 11:07] – [Submit job] anitasoftware:matlab:mills [2019-08-29 16:05] (current) – [Matlab script] anita
Line 4: Line 4:
 On Mills, MATLAB projects should be developed using a Desktop installation of MATLAB and then copied to the cluster On Mills, MATLAB projects should be developed using a Desktop installation of MATLAB and then copied to the cluster
 to be run in batch.  Here we to be run in batch.  Here we
-consider an extended MATLAB example involving tow simple MATLAB functions, and two MATLAB scripts to execute+consider an extended MATLAB example involving two simple MATLAB functions, and two MATLAB scripts to execute
 the first function in a loop, and to using the Parallel Toolbox. the first function in a loop, and to using the Parallel Toolbox.
  
 Details on how to run these two scripts in batch are given with the resulting output files.  There is also a Details on how to run these two scripts in batch are given with the resulting output files.  There is also a
-section with UNIX commands you can use to watch your jobs and gather [[#timing and core count]] numbers.  +section with UNIX commands you can use to watch your jobs and gather [[#timings-and-core-count | timing and core count]] numbers.  
 You will need to know how much memory and how many cores you should request for your jobs. You will need to know how much memory and how many cores you should request for your jobs.
  
Line 27: Line 27:
 ==== Matlab License Information ==== ==== Matlab License Information ====
  
-These are pushed into consumable (global, per-job) integer complexes in Grid Engine and can be checked using +Matlab licenses are pushed into consumable (global, per-job) integer complexes in Grid Engine and can be checked using 
  
 <code> <code>
Line 116: Line 116:
  
  
-The page will using a Matlab function to illustrate using Matlab in batch and interactively.  The function will be run on multiple cores using multiple computational threads, and 12 workers from a Matlab pool.  Finally it will be compiled an deployed.+The examples will be using a Matlab function to illustrate using Matlab in batch and interactively.  The function will be run on multiple cores using multiple computational threads, and 12 workers from a Matlab pool.  Finally it will be compiled and deployed.
  
-===== Batch example ===== 
  
-The basic steps to run [[:software:matlab#batch-job|batch MATLAB]]. 
 ==== Matlab script ==== ==== Matlab script ====
 First, write a Matlab script file. It should have a comment on the first line describing the purpose of the script and have the ''quit'' command on the last line. This script will call the [[#matlab-function|maxEig function]] 200 times and report the average: First, write a Matlab script file. It should have a comment on the first line describing the purpose of the script and have the ''quit'' command on the last line. This script will call the [[#matlab-function|maxEig function]] 200 times and report the average:
Line 139: Line 137:
 quit quit
 </file> </file>
 +
 +This is a detailed script example, which calls the maxEig function.  This example does no file I/O, all the I/O is to standard out.  In Matlab, assignments, not terminated by a semicolon, are display on the screen (standard out in batch).
 +
 +<note tip>
 +Several MATLAB commands could be added to the beginning of this script to set the maximum number of computational threads to the number of slots assigned to your job.  If the scheduler using CGROUPS to limit your job core count, then these commands are not necessary.
 +<code>
 +[compThreads,count]=sscanf(getenv('NSLOTS'),'%d');
 +if count == 1 
 +  warning('off','MATLAB:maxNumCompThreads:Deprecated');
 +  autoCompThreads = maxNumCompThreads(compThreads);
 +  disp(sprintf('NumCompThreads=%d, was %d',compThreads,autoCompThreads))
 +end
 +</code>
 +See [[maxNumCompThreadsGridEngine|Setting maximum number of computational threads]]</note>
 +
 +<note tip>
 +This script ends in a **__quit__** command (equivalent to MATLAB **__exit__**).  This is meant to be a complete script, which
 +terminates MATLAB when done.  If you run this from the bash command line with the ''-r script'' option, it will come back with a bash prompt when completed.  If this is run from a batch job, then you can do other commands in your batch script after the MATLAB script completes.
 +
 +Without the **__quit__** you will come back to the MATLAB prompt on completion for a interactive job.  If this is the last line of a batch queue script, then the only difference will be the MATLAB prompt ''>>'' at the very end of the output file.  MATLAB treats the end of batch script file the same as exiting the window, which is the preferred way to exit the MATLAB GUI.
 +</note>
  
 ==== Grid Engine script ==== ==== Grid Engine script ====
Line 206: Line 225:
 </code> </code>
  
-<note warning>See [[software:matlab:mills#matlab-license-information|Matlab licenses]] for details on specifying resources if there are limited number of license seats available for particular toolboxes.+<note warning>See [[#matlab-license-information|Matlab licenses]] for details on specifying resources if there are limited number of license seats available for particular toolboxes.
  
 In this example you will need a license for the base Matlab, and the parallel toolbox needs one license.  We are using the default local scheduler which give you 12 workers on the same node with one license. In this example you will need a license for the base Matlab, and the parallel toolbox needs one license.  We are using the default local scheduler which give you 12 workers on the same node with one license.
Line 363: Line 382:
 We have the correct Grid Engine options ''-pe threads 12'' for this case. We have the correct Grid Engine options ''-pe threads 12'' for this case.
  
-[[clusters:mills:matlab-two-samenode|Two Matlab interactive jobs on same node]]+[[software:matlab:mills:matlab-two-samenode|Two Matlab interactive jobs on same node]]
  
 ===== Batch parallel example ===== ===== Batch parallel example =====
Line 411: Line 430:
 ===== Interactive example ===== ===== Interactive example =====
  
-The basic steps to running a [[:software:matlab#interactive|MATLAB]] interactively on a compute node.  +This example is based on being in your workgroup environment, cd'ing to your MATLAB project directory and starting an interactive session on a compute node.
- +
-This demo starts in your MATLAB directory and with and active workgroup.  +
- +
 ==== Scheduling exclusive interactive job ==== ==== Scheduling exclusive interactive job ====
  
  • software/matlab/mills.1543853258.txt.gz
  • Last modified: 2018-12-03 11:07
  • by anita