File Exchange

image thumbnail

Pass task-parallel jobs with multiple tasks to a scheduler.

version 1.0 (2.28 KB) by

This script creates 2 jobs, each with 2 parallel tasks, to pass to a local or remote scheduler.

1 Download


View License

This script demonstrates how to create jobs with tasks to be processed in parallel and how to pass them to either a local or remote scheduler.

To run the script with a local scheduler you will need the Parallel Computing Toolbox (in addition to MATLAB R2010a). To run it with a remote scheduler you will also need the Distributed Computing Server.

When running the parforv4 script you need to ensure that both files: parjobv4.m and myrand.m
are co-resident i.e. in the same folder. You can swap out myrand.m and put your own pet function in its place but if you do, be careful to observe the special syntax for both calling the function and passing parameters to it.

myrand.m takes one parameter and I call it twice in each job, hence 2 tasks per job are passed to the scheduler. You can change the literal parameter (i.e. the 3 passed to myrand) to a higher value to create larger n x n matrices of random numbers. You may want to alter the fprint statements to accommodate bigger matrices if you do this. Note that you cannot call myrand by itself as it must be called from the parjobv4.m script.

I don't use parfor in myrand.m but feel free to put this
in a function of your choice if you want to speed up 'for loops' as well as pass task-parallel jobs to a scheduler

Running the parforv4 script, as it stands, produces 4 3x3 matrices (2 per job) of random numbers.

>> parjobv4
Finished job one
Finished job two
Job 1 results
0.18715 0.23947 0.22958
0.97552 0.89324 0.63034
0.88797 0.38953 0.78726
0.41598 0.79888 0.78901
0.16128 0.41097 0.38039
0.63030 0.92824 0.74550
Job 2 results
0.96928 0.07264 0.63719
0.19574 0.54839 0.89868
0.51598 0.64808 0.54161
0.51760 0.00946 0.14139
0.49429 0.02560 0.41964
0.01753 0.60851 0.23285

Comments and Ratings (0)

MATLAB Release
MATLAB 7.10 (R2010a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video