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

版本 1.0.0.0 (2.3 KB) 作者: Bruce Raine
This script creates 2 jobs, each with 2 parallel tasks, to pass to a local or remote scheduler.
734.0 次下载
更新时间 2010/7/1

查看许可证

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
>>

引用格式

Bruce Raine (2024). Pass task-parallel jobs with multiple tasks to a scheduler. (https://www.mathworks.com/matlabcentral/fileexchange/28094-pass-task-parallel-jobs-with-multiple-tasks-to-a-scheduler), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2010a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Parallel Computing 的更多信息

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.0.0.0