How to run 3 programs simultaneously?
2 次查看(过去 30 天)
显示 更早的评论
I have to run three functions or programs on a quad core processor such that function1 is run on core1 of the processor and function2 on core2 and function3 on core3, all simultaneously in one matlab session. Can any one help??
0 个评论
采纳的回答
Thomas
2012-3-14
I do not think there is a way to control which matlab processes run on a particular core. Matlab has a lot of inbuilt function that inherently now use multi-threading.
Though you could instantiate three MATLAB instances ( hopefully they run on different cores. haven't tried it) with the
-maxNumCompThreads
set to 1 so that each instance uses only 1 core and then run your function in each instance.
href=""<http://www.mathworks.com/help/techdoc/ref/maxnumcompthreads.html</a>>
5 个评论
更多回答(1 个)
Jason Ross
2012-3-14
Short answer:
There is no way to control processor affinity. The tasks are handed off to the operating system, which places them as they see fit.
If you wish to control what goes on in each lab, use the spmd construct and labIndex. There is an example of how to do this under "Defining an spmd Statement" on this page:
Long answer:
There are various utilities that are very OS-specific that will let you set processor affinity for a given process. It would be somehow possible to place things if you really wanted to, but the effort would likely be in vain, as modern operating systems are quite good at doing this already, and you'd end up with code that was very tightly coupled with your specific hardware and operating system -- for what could actually be a performance loss.
2 个评论
Jason Ross
2012-3-14
There is an example in the documentation link I provided that shows how to do this.
To be entirely pedantic and boring, I'm making an assumption that the operating system will choose to place each lab on one core -- hopefully it will. But it's not an ironclad guarantee. The only thing that can be guaranteed is that the tasks for lab1 will go to lab1, the tasks for lab2 will go to lab2 and so on.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Parallel for-Loops (parfor) 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!