Attention: : Confluence is not suitable for the storage of highly confidential data. Please ensure that any data classified as Highly Protected is stored using a more secure platform.
If you have any questions, please refer to the University's data classification guide or contact ict.askcyber@sydney.edu.au

Submitting jobs from MATLAB

You can submit non-interactive (batch) work to Artemis using the Artemis cluster profile configured in the previous section. This section will walk you through submitting an example Matlab script called quadrature.m to Artemis using the batch command. You may like to use this script to test submitting jobs to Artemis yourself. The script quadrature.m is:

n=50000000;
a=0.5;
b=1.0;
q=0.0;
w=(b-a)/n;
parfor i=1:n
    q = q + w*bessely(4.5,((n-1)*a+(i-1)*b)/(n-1));
end
q

If you save this script to your local computer, you can run it on your local computer with following command in the Matlab Command Window:

>> quadrature

Setting PBS directives for your job

The Artemis cluster profile provided for you contains settings for some PBS directives and job settings, such as Walltime, but leaves empty others, such as memory requested.

Ie, the default profile setting for Walltime is only 30 minutes, which will likely not be enough for your job. The default memory request, which is used when no memory parameter is set, is 4gb, which may also not be enough. You should therefore set these parameters in the Artemis cluster profile each time you submit an MDCS job.

To do this, you can either:

  1. Edit the cluster profile itself
    1. In the Matlab client, click the Home tab, select Parallel, then select Manage Cluster Profiles, and select Artemis (or whatever you named it).
    2. Set/Add the wall-time ('Walltime') and memory requested ('Mem') as String properties under Additional Properties in the SCHEDULER INTEGRATION pane.


  2. Use a 'cluster object' and set its properties, which will apply for the current Matlab session only.
    1. Create a cluster object from the Artemis profile

      >> mycluster = parcluster('Artemis')
      
    2.  Set the desired parameters as Additional Properties under the cluster object just created

      >> mycluster.AdditionalProperties.Walltime = '10:30:00';
      >> mycluster.AdditionalProperties.Mem = '16gb';
      
    3. These updated/added settings will now apply for each use of the 'Artemis' profile, until Matlab is restarted.


The main PBS job parameters that may be set this way are:

  • Project - the RDMP project you will be using for the job (PBS argument -P ProjectName)
  • Walltime - the wall-time you wish to request for your job (PBS argument -l walltime=HH:MM:SS)
  • Mem - the RAM resource request for the job (PBS argument -l mem=Mgb)
  • Ngpus - the number of GPU cores you wish to request (PBS argument -l ngpus=N)
  • Queue - the scheduler queue you wish to use (PBS argument -q queue_name)

Note that you do not specify the number of cores ('ncpus') in an MDCS job. The MDCS will request one core per MATLAB worker. Hence, an independent (ie non 'parallel pool') job will use one core.

Submiting work to Artemis using the “batch” command


The quadrature.m script can be run on Artemis using the batch command in the Matlab Command Window:

>> job = batch('quadrature','Profile','Artemis')

Using multiple cores

The quadrature.m script can be run using multiple cores since it has been explicitly parallelised with a “parfor” loop. Therefore, you can request multiple CPUs using the “Pool” option to batch:

>> job = batch('quadrature','Profile','Artemis','Pool',3)

The above command initialises a parallel computing pool with 3 cores that do the computation, and one additional head core that executes the script. Therefore, the above example requests 4 cores.

You can have up to 12 cores worth of work running simultaneously. Any work that would exceed the 12 core per user limit will remain queued until there are enough cores free to run your job.

Advanced ways of using the batch function

You can also submit a function to Artemis using the batch command, rather than a script:

>> job = batch(@my_func,N,{x1,...,x2},'Profile','Artemis','Pool',3)

This job will run the function my_func using the input arguments {x1,...,x2} and will return N output arguments. Note the use of @ to create a function handle; this points to the function, rather than calling it.

The batch function can take many other options in the standard Matlab form of ‘parameter’,’value’ pairs. See the Matlab documentation for details.

Two such options are worth noting:

Your Matlab job will switch directories into the remote folder specified via the ‘CurrentFolder’ parameter before execution on Artemis. If not given, Matlab uses the current local working directory as the default value for ‘CurrentFolder’ - a folder which may not exist on Artemis! To avoid the warnings this causes, call batch with 'CurrentFolder','.', which tells Matlab not to change directories before running the job.

You can also specify additional files or folders to transfer to Artemis on a per job basis (rather than modifying your cluster profile) by including the ‘AttachedFiles’ parameter. The value for this can be a string giving the path to a file or folder (e.g. file.m), or it can be a cell-array of such strings:

>> job = batch(...,'AttachedFiles',{'important/folder/','other/file.m'})