There are three methods to submit a parallel MATLAB batch job on the Shared Computing Cluster, depending on the number of processors needed and whether the tasks for the job are mutually independent:

Method 1: Batch submission procedure for up to 12 cores

Quite often, many applications’ parallel efficiency peak at 4 to 16 processors. For these runs, it is suitable to use this method to submit batch jobs. In addition, this procedure guaranteed that any communication among the workers will be local within the node and hence more effective — especially for communication-bound applications.

  • Copy example files to your folder
    scc1% cp -r /project/scv/examples/matlab/misc/run-single-node-batch  your-path
    scc1% cd run-single-node-batch
  • Submit batch job using single_node_batch‘s default cores (-pe omp 4)
    scc1% qsub single_node_batch
  • Submit batch job — override script’s default 4 cores with 12 cores
    scc1% qsub -pe omp 12 single_node_batch

Method 2: Batch submission procedure for more than 12 cores

Currently unavailable
If your application needs more than twelve processors, MATLAB worker licenses will be required. Consequently, a special process is needed to handle the license request, automatically in the background, without any user action. The steps a user need to follow are described below.

  • A batch script, called pctBatch, is required. This script is very similar to that of Method 1. What differentiate the two methods is with which configuration matlabpool is invoked. This script is also not available on the system level. You will need to download and save it and enable the execute attribute with
    scc1% chmod +x pctBatch
  • runSGE.m is being used to open matlabpool to run an application program, matmulExample. These files are part of the download zip file.
    % runSGE.m wrapper script to open matlabpool and run user app
    matlabpool('SGE', N)      % N is passed at runtime;
    matmulExample(n, m)       % example user app
    matlabpool close

    Where SGE is a user-defined configuration that request the system to assign N workers for the batch job. You must define SGE before using it. Instructions for r2011a and r2012b are available.

  • Submit job with pctBatch:
    scc1% pctBatch "n=3000,m=3000,N=16,runSGE" myoutput

    The input parameters, n, m, are passed on to the user application code while N is the worker pool size. The job’s default runtime is 2 hours. This is set by the system and cannot be changed.

  • Unlike a job that is submitted with qsub directly, in this case it may take a while before the job appears in the batch queue and tracked with qstat. In the meantime, you can confirm that the process is registered with this unix command:
    scc1% ps -aux | grep runSGE
  • In addition to the matlab workspace output redirected to myoutput, a MATLAB file, JobX.mpiexe.out is also generated. This file contains miscellaneous information such as the splash screen as well as the processors assigned to job.

Practical considerations for Methods 1 and 2

The purpose for the two procedures are abundantly clear: Method 1 for up to 12 cores and Method 2 for larger number of workers. However, in practice, Method 1 may often turn out to be the better of the two choices for a variety of reasons, despite having fewer cores than with Method 2:

  • Many non-embarrassingly parallel codes naturally scale well for small number of cores but reaches the point of diminishing return beyond a certain number (code dependent). For these codes, Method 1 is highly suitable.
  • Inter-node communications generally have higher latency than on-node communications — especially since MATLAB supports only the 1 Gigabit Ethernet inter-node communication. For communication-bound applications, this make Method 2 more expensive.
  • The processor pool from which Method 2 picks has the slowest clock speed (i.e., the 2.4 Ghz AMD Opteron 2216HE). This may offset the advantage of using Method 2 to run with more processors.
    (See Technical Summary for the different processors available on the SCC.)
  • Submitting jobs with Method 2 for more than 12 processors means multiple nodes will be used. This reduces the likelihood for multi-threaded computations.
  • For some codes, the reason for choosing Method 2 may be driven by memory requirement considerations. With the “-l memory=96G” qsub switch, a job submitted with Method 1 allows access to more memory per processor than Method 2.
  • The wait time in queue may be longer with Method 2 because the SGE configuration requires one Distributed Computing Server (DCS) license for each worker. If the needed number of free DCS licenses — there are 64 — are not available, your batch job has to wait in spite of free processors. On the other hand, Method 1 wait only for free processors, not DCS licenses.

Method 3: Batch procedure for embarrassingly parallel codes

Through the submitmjobs script, multiple single-core jobs can be submitted with the potential to run concurrently (embarrassingly parallel).

  • Copy example files to your folder
    scc1% cp -r /project/scv/examples/matlab/misc/run-embarrassingly-parallel-batch  your-path
    scc1% cd run-embarrassingly-parallel-batch
  • Submit 1 batch job using run_matlab_job with default runtime.
    scc1% submitmjobs 1 run_matlab_job
  • Submit 3 batch jobs to run for a maximum of 24 hours
    scc1% submitmjobs 3 run_matlab_job "-l h_rt=24:00:00"

Method 4: Running multiple PCT Jobs

This is similar to Method 1. Through the submitmjobs script, multiple PCT jobs can be submitted automatically.

  • Copy example files to your folder
    scc1% cp -r /project/scv/examples/matlab/misc/run-multiple-pct-batch  your-path
    scc1% cd run-multiple-pct-batch
  • Submit 1 batch job using run_matlab_pct_job‘s default cores (-pe omp 4).
    scc1% submitmjobs 1 run_matlab_pct_job

    The above is equivalent to Method 1.

  • Submit 3 PCT batch jobs, each with 12 cores
    scc1% submitmjobs 3 run_matlab_pct_job "-pe omp 12"

Method 5: Run PCT Jobs without MATLAB licenses

If you run MATLAB single- or multi-processor jobs routinely, you may have had the experience of denied MATLAB access or having your MATLAB batch jobs killed due to a lack of MATLAB (or MATLAB toolbox) licenses. This can be avoided if you compile your MATLAB application into an executable with the MATLAB mcc compiler. The executable runs without MATLAB or licenses . . . How to create and run a standalone executable

Previous Home Next