How does MATLAB Parallel computing toolbox work?

10 views (last 30 days)
Dear All,
We have recently installed MATLAB and its parallel toolbox in our clusters for linux. We have transferred all of our scripts to linux in order to run them using the new installed MATLAB. However, we have so many difficulties using the parallel computing toolbox. For instance, we do not know how to change the number of processors in a node! Usually we ask for a single node (each of the nodes has 12 cores) and then run our codes on the requested nodes.
We do want to run our codes using 1 processor and monitor the performance, then run the same script with 2 and etc.Should we do/add anything to our scripts?
Basically how can we generally ask for different number of cores in a single node? How can we submit our jobs and monitor them using parallel toolbox in MATLAB? I know that these question are general but I do appreciate if anyone can help me.
Best,
HRJ
  1 Comment
Edric Ellis
Edric Ellis on 5 Nov 2015
Are you using PCT alone, or are you using MDCS with a scheduler? Are you trying to set up the MJS scheduler? For monitoring jobs in PCT, there's the job monitor...

Sign in to comment.

Accepted Answer

Federico Becattini
Federico Becattini on 5 Nov 2015
The simplest way of running matlab code in parallel is to open a parallel pool specifying the number of cores that you want to use with
parpool(numcores)
and then use a parfor loop instead of a for loop. Of course you have to be sure that your code is parallelizable.
Another way is to use the batch function to assign jobs to different workers.
If you are using a cluster you can also submit different jobs to different cores using different matlab instances. For example with Sun Grid Engine you can use qsub to submit jobs. In order to do this with matlab you can write you matlab script with the following line to get the job ID
job_id = getenv('SGE_TASK_ID');
then you have to write a simple .sh file that launches matlab with this script. Something like this:
#!/bin/sh
#$ -cwd
path_to_matlab -nojvm -nodisplay -r scriptname
To submit the jobs you can execute the following command from the command line:
qsub -t 1-num_jobs:1 -o output_path -e error_path matlab_job.sh
where num_jobs is the number of jobs that you want to submit, output_path is the path where you want to print matlab's output and error_path is the path for printing any possible errors. matlab_job.sh is the .sh script defined above.
Hope this is useful.

More Answers (0)

Categories

Find more on Cluster Configuration in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!