开发者

matlab distributed computing with sge(qsub)

开发者 https://www.devze.com 2023-02-28 09:40 出处:网络
Recently I got access to run my codes on a cluster. My code is totally paralleizable but I don\'t know how to best use its parallel nature. I\'ve to compute elements of a big matrix and each of them a

Recently I got access to run my codes on a cluster. My code is totally paralleizable but I don't know how to best use its parallel nature. I've to compute elements of a big matrix and each of them are independent of the others. I want to submit the job to run on several machine (like 100) to speed up the computation of the matrix.

Right now, I wrote a script to submit multiple jobs each responsible to compute a part of the matrix and save it in a .mat file. At the end I'm merging them to get the whole matrix. For submitting each individual job, I've created a new .m file (run1.m, run.2, ...) to set a variable and then run the function to compute the associated part in the matrix. So basically run1.m is

id=1;compute_dists_matrix

and then compute_dists_matrix uses id to find the part it is going to compute. Then I wrote a script to create run1.m through run60.m and the qsub them to the cluster.

I wonder if there is a better way to do this using some MATLAB features for example. Because this se开发者_高级运维ems to be a very typical task.


Yes, it works, but is not ideal, and as you say is a common problem. Matlab has a parallel programming toolkit.

Does your cluster have this? If so, the distributed arrays is worth having a look at. If they don't have access to it, then what you are doing is the only other way. You can wrap your run1.m,run2.m in a controlling script to automate it for you...


I believe you could use command line arguments for the id and submit jobs with a range of values for this id. Command line arguments can be processed by launching MATLAB from the command line without the IDE and providing the name of the script to be executed and the list of arguments. I would think you can set up dependencies in your job manager and create a "reduce" script to merge the partial results (from files). The whole process could be managed from a single script that would generate the id & other necessary arguments and submit the processing & postprocessing jobs with dependencies.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号